Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.ui.internal.WorkbenchPlugin;

/**
* A registry for common images used by the workbench which may be useful to
Expand Down Expand Up @@ -855,4 +856,12 @@ public interface ISharedImages {
* @return the image descriptor, or <code>null</code> if not found
*/
ImageDescriptor getImageDescriptor(String symbolicName);

/**
* @since 3.135
* @return the default {@link ISharedImages} instance
*/
static ISharedImages get() {
return WorkbenchPlugin.getDefault().getSharedImages();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public NewWizardAction(IWorkbenchWindow window) {
this.workbenchWindow = window;
tracker = new PerspectiveTracker(window, this);
// @issues should be IDE-specific images
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
ISharedImages images = window.getWorkbench().getSharedImages();
setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD_DISABLED));
setToolTipText(WorkbenchMessages.NewWizardAction_toolTip);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IWorkbenchHelpContextIds.NEW_ACTION);
window.getWorkbench().getHelpSystem().setHelp(this, IWorkbenchHelpContextIds.NEW_ACTION);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ protected final String getRawTitle() {
@Override
public final Image getTitleImage() {
if (isDisposed()) {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
return ISharedImages.get().getImage(ISharedImages.IMG_DEF_VIEW);
}

WorkbenchWindow wbw = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
Expand All @@ -341,7 +341,7 @@ public final Image getTitleImage() {
}
}

return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
return wbw.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
}

/* package */ void fireVisibilityChange() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected final void addCopySupport(Table table) {
MenuItem copyItem = new MenuItem(menu, SWT.NONE);
copyItem.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> handler.copySelection(table)));
copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
copyItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_COPY));
copyItem.setImage(ISharedImages.get().getImage(ISharedImages.IMG_TOOL_COPY));

table.setMenu(menu);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IPluginContribution;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.SelectionEnabler;
Expand Down Expand Up @@ -169,7 +170,7 @@ public ImageDescriptor getImageDescriptor() {
}
imageDescriptor = ResourceLocator
.imageDescriptorFromBundle(configurationElement.getNamespaceIdentifier(), iconName)
.orElse(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(iconName));
.orElse(ISharedImages.get().getImageDescriptor(iconName));
}
return imageDescriptor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.WorkbenchMessages;

/**
Expand All @@ -44,9 +43,9 @@ public final class RedoActionHandler extends OperationHistoryActionHandler {
*/
public RedoActionHandler(IWorkbenchPartSite site, IUndoContext context) {
super(site, context);
setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
setImageDescriptor(ISharedImages.get().getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
setDisabledImageDescriptor(
PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_REDO_DISABLED));
ISharedImages.get().getImageDescriptor(ISharedImages.IMG_TOOL_REDO_DISABLED));
setActionDefinitionId(IWorkbenchCommandConstants.EDIT_REDO);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.WorkbenchMessages;

/**
Expand All @@ -44,9 +43,9 @@ public final class UndoActionHandler extends OperationHistoryActionHandler {
*/
public UndoActionHandler(IWorkbenchPartSite site, IUndoContext context) {
super(site, context);
setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
setImageDescriptor(ISharedImages.get().getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
setDisabledImageDescriptor(
PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED));
ISharedImages.get().getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED));
setActionDefinitionId(IWorkbenchCommandConstants.EDIT_UNDO);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.internal.WorkbenchMessages;

Expand Down Expand Up @@ -166,7 +165,7 @@ public void run() {
homeAction.setImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_ETOOL_HOME_NAV));

// Back.
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
ISharedImages images = ISharedImages.get();
backAction = new Action(WorkbenchMessages.GoBack_text) {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.intro.IntroMessages;
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
import org.eclipse.ui.intro.IIntroPart;
Expand Down Expand Up @@ -151,7 +150,7 @@ protected IConfigurationElement getConfigurationElement() {
* @return the default image
*/
protected Image getDefaultImage() {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
return ISharedImages.get().getImage(ISharedImages.IMG_DEF_VIEW);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.eclipse.ui.IWorkbenchPart3;
import org.eclipse.ui.IWorkbenchPartConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.internal.WorkbenchPlugin;
Expand Down Expand Up @@ -168,7 +167,7 @@ protected IConfigurationElement getConfigurationElement() {
* @return the default image
*/
protected Image getDefaultImage() {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
return ISharedImages.get().getImage(ISharedImages.IMG_DEF_VIEW);
}

@Override
Expand Down Expand Up @@ -233,7 +232,7 @@ public void setInitializationData(IConfigurationElement cfig, String propertyNam
}
imageDescriptor = ResourceLocator.imageDescriptorFromBundle(configElement.getContributor().getName(), strIcon);
if (!imageDescriptor.isPresent()) {
ImageDescriptor shared = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(strIcon);
ImageDescriptor shared = ISharedImages.get().getImageDescriptor(strIcon);
imageDescriptor = Optional.ofNullable(shared);
}
imageDescriptor.ifPresent(d -> titleImage = JFaceResources.getResources().createImageWithDefault(d));
Expand Down
Loading