From b62b694b516513fa7a553c03fbe228e07337427a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 19 Jan 2025 13:43:03 +0100 Subject: [PATCH] Use the new ISharedImages.get() to not require a running platform Currently some actions require a running platform, but with the new ISharedImages.get() method this is no longer required making the classes less coupled. --- .../reorg/CopyToClipboardAction.java | 2 +- .../ui/refactoring/reorg/CutAction.java | 2 +- .../ui/refactoring/reorg/DeleteAction.java | 2 +- .../ui/refactoring/reorg/PasteAction.java | 2 +- .../callhierarchy/RemoveFromViewAction.java | 2 +- .../ui/infoviews/CopyToClipboardAction.java | 2 +- .../internal/ui/infoviews/JavadocView.java | 4 ++-- .../CompilationUnitDocumentProvider.java | 3 +-- .../ui/packageview/ClassPathContainer.java | 6 +++--- .../JavadocConfigurationBlock.java | 3 +-- .../correction/JavadocTagsSubProcessor.java | 5 ++--- .../LocalCorrectionsSubProcessor.java | 19 +++++++++---------- .../SuppressWarningsSubProcessor.java | 5 ++--- .../UnresolvedElementsSubProcessor.java | 3 +-- .../VarargsWarningsSubProcessor.java | 3 +-- .../RemoveDeclarationCorrectionProposal.java | 3 +-- .../ui/text/java/hover/JavadocHover.java | 5 ++--- .../viewsupport/JavaElementImageProvider.java | 3 +-- .../ui/viewsupport/StorageLabelProvider.java | 4 ++-- .../wizards/buildpaths/BuildPathsBlock.java | 4 ++-- .../CPVariableElementLabelProvider.java | 5 ++--- .../buildpaths/JARFileSelectionDialog.java | 6 +++--- .../ui/wizards/buildpaths/ModuleDialog.java | 3 ++- 23 files changed, 43 insertions(+), 53 deletions(-) diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/CopyToClipboardAction.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/CopyToClipboardAction.java index fc0c7ccadb0..c99af11ccc1 100644 --- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/CopyToClipboardAction.java +++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/CopyToClipboardAction.java @@ -90,7 +90,7 @@ public void setAutoRepeatOnFailure(boolean autorepeatOnFailure){ } private static ISharedImages getWorkbenchSharedImages() { - return PlatformUI.getWorkbench().getSharedImages(); + return ISharedImages.get(); } @Override diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/CutAction.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/CutAction.java index 478d14e5238..57705502fb5 100644 --- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/CutAction.java +++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/CutAction.java @@ -43,7 +43,7 @@ public CutAction(IWorkbenchSite site) { setText(ReorgMessages.CutAction_text); fCopyToClipboardAction= new CopyToClipboardAction(site); - ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages workbenchImages= ISharedImages.get(); setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED)); setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT)); setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT)); diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java index f94c8e2a04e..e7785434aef 100644 --- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java +++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java @@ -78,7 +78,7 @@ public DeleteAction(IWorkbenchSite site) { super(site); setText(ReorgMessages.DeleteAction_3); setDescription(ReorgMessages.DeleteAction_4); - ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages workbenchImages= ISharedImages.get(); setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/PasteAction.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/PasteAction.java index 8389340e841..dbd1bb10e54 100644 --- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/PasteAction.java +++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/PasteAction.java @@ -192,7 +192,7 @@ public PasteAction(IWorkbenchSite site, Clipboard clipboard) { setText(ReorgMessages.PasteAction_4); setDescription(ReorgMessages.PasteAction_5); - ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages workbenchImages= ISharedImages.get(); setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/RemoveFromViewAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/RemoveFromViewAction.java index 5887a52ae6b..16e23903884 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/RemoveFromViewAction.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/RemoveFromViewAction.java @@ -59,7 +59,7 @@ public RemoveFromViewAction(CallHierarchyViewPart part, CallHierarchyViewer view setToolTipText(CallHierarchyMessages.RemoveFromViewAction_removeFromView_tooltip); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_REMOVE_FROM_VIEW_ACTION); - ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages workbenchImages= ISharedImages.get(); setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE_DISABLED)); setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE)); setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE)); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/CopyToClipboardAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/CopyToClipboardAction.java index 80ad80009fb..46391cf9300 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/CopyToClipboardAction.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/CopyToClipboardAction.java @@ -44,7 +44,7 @@ public CopyToClipboardAction(IWorkbenchSite site) { setToolTipText(InfoViewMessages.CopyAction_tooltip); setDescription(InfoViewMessages.CopyAction_description); - ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages workbenchImages= ISharedImages.get(); setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java index 31d56f2d487..d01793a9195 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java @@ -232,7 +232,7 @@ private final class ForthAction extends Action { public ForthAction() { setText(InfoViewMessages.JavadocView_action_forward_name); - ISharedImages images= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages images= ISharedImages.get(); setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD)); setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD_DISABLED)); @@ -266,7 +266,7 @@ private final class BackAction extends Action { public BackAction() { setText(InfoViewMessages.JavadocView_action_back_name); - ISharedImages images= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages images= ISharedImages.get(); setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_BACK)); setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED)); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java index 094a36bb422..613ed2ab263 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java @@ -84,7 +84,6 @@ import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IStorageEditorInput; import org.eclipse.ui.IURIEditorInput; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE.SharedImages; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; @@ -277,7 +276,7 @@ private void initializeImages() { fgQuickFixErrorImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_ERROR); fgQuickFixInfoImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_FIXABLE_INFO); - ISharedImages sharedImages= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages sharedImages= ISharedImages.get(); fgTaskImage= sharedImages.getImage(SharedImages.IMG_OBJS_TASK_TSK); fgInfoImage= sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK); fgWarningImage= sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/ClassPathContainer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/ClassPathContainer.java index f5098b24e95..352806db2e3 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/ClassPathContainer.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/ClassPathContainer.java @@ -28,7 +28,7 @@ import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ISharedImages; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.model.IWorkbenchAdapter; @@ -40,13 +40,13 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; -import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; /** * Representation of class path containers in Java UI. @@ -99,7 +99,7 @@ public ImageDescriptor getImageDescriptor(Object object) { if (fClasspathEntry.isTest()) return JavaPluginImages.DESC_OBJS_PROJECT_TEST; else - return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT); + return ISharedImages.get().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT); } @Override diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java index 8c62e0d3bb5..185d0f48c4f 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationBlock.java @@ -60,7 +60,6 @@ import org.eclipse.jface.window.Window; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.model.WorkbenchContentProvider; @@ -894,7 +893,7 @@ private static class ZipDialogLabelProvider extends LabelProvider { private final Image IMG_JAR= JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_JAR); private final Image IMG_FOLDER= - PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); + ISharedImages.get().getImage(ISharedImages.IMG_OBJ_FOLDER); private ZipFileStructureProvider fProvider; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java index 5cb0189d741..ac1196b99d5 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java @@ -25,7 +25,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.ASTNode; @@ -174,7 +173,7 @@ protected ICommandAccess addJavadocCommentProposal(String label, ICompilationUni @Override protected ICommandAccess createRemoveJavadocTagProposals(String label, ICompilationUnit compilationUnit, ASTRewrite rewrite, int removeTag) { - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); return new ASTRewriteCorrectionProposal(label, compilationUnit, rewrite, IProposalRelevance.REMOVE_TAG, image); } @@ -182,7 +181,7 @@ protected ICommandAccess createRemoveJavadocTagProposals(String label, ICompilat protected ICommandAccess createRemoveDuplicateModuleJavadocTagProposal(String label, ICompilationUnit compilationUnit, int start, int length, String string, int removeTag) { ReplaceCorrectionProposal proposal= new ReplaceCorrectionProposal(label, compilationUnit, start, length, "", IProposalRelevance.REMOVE_TAG); //$NON-NLS-1$ - proposal.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE)); + proposal.setImage(ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE)); return proposal; } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java index 9bdd21247a8..19bf9e7dfbe 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java @@ -45,7 +45,6 @@ import org.eclipse.ui.IEditorSite; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.jdt.core.ICompilationUnit; @@ -247,7 +246,7 @@ public Object getAdditionalProposalInfo(IProgressMonitor monitor) { public static void getUnnecessaryNLSTagProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException { IProposableFix fix= StringFixCore.createFix(context.getASTRoot(), problem, true, false); if (fix != null) { - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); Map options= new Hashtable<>(); options.put(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new StringCleanUp(options), IProposalRelevance.UNNECESSARY_NLS_TAG, image, context); @@ -389,7 +388,7 @@ public static void addRedundantSuperInterfaceProposal(IInvocationContext context private static void addProposal(IInvocationContext context, Collection proposals, final UnusedCodeFixCore fix) { if (fix != null) { - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, fix.getCleanUp(), IProposalRelevance.UNUSED_MEMBER, image, context); proposals.add(proposal); } @@ -810,7 +809,7 @@ private static void addRemoveProposal(IInvocationContext context, ASTNode select } private static void addRemoveIncludingConditionProposal(IInvocationContext context, ASTNode toRemove, ASTNode replacement, Collection proposals) { - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); String label= CorrectionMessages.LocalCorrectionsSubProcessor_removeunreachablecode_including_condition_description; AST ast= toRemove.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); @@ -864,7 +863,7 @@ private static void addRemoveIncludingConditionProposal(IInvocationContext conte } private static void addRemoveProposal(IInvocationContext context, ASTRewrite rewrite, String label, Collection proposals) { - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 10, image); proposals.add(proposal); } @@ -934,7 +933,7 @@ public static void getUnusedObjectAllocationProposals(IInvocationContext context rewrite.remove(parent, null); String label= CorrectionMessages.LocalCorrectionsSubProcessor_remove_allocated_description; - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_UNUSED_ALLOCATED_OBJECT, image); proposals.add(proposal); } @@ -1123,7 +1122,7 @@ private static void addTypeArgumentsFromContext(IInvocationContext context, IPro public static void addRemoveRedundantTypeArgumentsProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) { IProposableFix fix= TypeParametersFixCore.createRemoveRedundantTypeArgumentsFix(context.getASTRoot(), problem); if (fix != null) { - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); Map options= new HashMap<>(); options.put(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS, CleanUpOptions.TRUE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new TypeParametersCleanUp(options), IProposalRelevance.REMOVE_REDUNDANT_TYPE_ARGUMENTS, image, context); @@ -1352,7 +1351,7 @@ protected ICommandAccess fixCorrectionProposalToT(FixCorrectionProposalCore core image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); } case UNUSED_CODE -> { - image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); } case RENAME_CODE -> { image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LINKED_RENAME); @@ -1383,10 +1382,10 @@ protected ICommandAccess createVariableReferenceProposalToT(CreateVariableRefere @Override protected ICommandAccess astRewriteCorrectionProposalToT(ASTRewriteCorrectionProposalCore core, int uid) { - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); switch (uid) { case REMOVE_REDUNDANT_SUPERINTERFACE, REMOVE_PROPOSAL -> { - image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); } case REMOVE_UNNECESSARY_INSTANCEOF, UNQUALIFY_ENUM_CONSTANT, MOVE_ELSE_CLAUSE, CHANGE_EXTENDS_TO_IMPLEMENTS, CHANGE_TO_INTERFACE, diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java index b4e20616cca..46ee3bf6628 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java @@ -20,7 +20,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.ASTNode; @@ -75,7 +74,7 @@ protected ICommandAccess createASTRewriteCorrectionProposal(String name, ICompil if(relevance == IProposalRelevance.FIX_SUPPRESS_TOKEN) { image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); } else if (relevance == IProposalRelevance.REMOVE_ANNOTATION) { - image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + image = ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); } return new ASTRewriteCorrectionProposal(name, cu, rewrite, relevance, image); } @@ -85,7 +84,7 @@ protected ICommandAccess createFixCorrectionProposal(IProposableFix fix, ICleanU // Initialize as default image, though it should always trigger one of the two if statements below Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); if (relevance == IProposalRelevance.REMOVE_ANNOTATION) { - image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + image = ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); } FixCorrectionProposal proposal= new FixCorrectionProposal(fix, cleanUp, relevance, image, context); proposal.setCommandId(ADD_SUPPRESSWARNINGS_ID); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java index 27a0bd0e1ca..6ccfbf09ac7 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java @@ -23,7 +23,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; import org.eclipse.ltk.core.refactoring.Change; @@ -88,7 +87,7 @@ private static Image findImage(int id) { case EnhancedForWithoutTypeProposal1: return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL); case NewVariableProposal3: - return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + return ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); case NewFieldForTypeProposal1: case NewFieldForTypeProposal3: case NewFieldForTypeProposal5: diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java index 0869cba6b7a..33e6707db8d 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java @@ -20,7 +20,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.IMethodBinding; @@ -70,7 +69,7 @@ protected ICommandAccess createAddSafeVarargsToDeclarationProposal1(String label @Override protected ICommandAccess createRemoveSafeVarargsProposal1(String label, ICompilationUnit compilationUnit, ASTRewrite rewrite, int relevance) { - Image image= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); + Image image= ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE); return new ASTRewriteCorrectionProposal(label, compilationUnit, rewrite, relevance, image); } } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java index 87432e98d0c..0a6395ad7a7 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.ASTVisitor; @@ -85,7 +84,7 @@ public boolean visit(SuperMethodInvocation node) { public RemoveDeclarationCorrectionProposal(ICompilationUnit cu, SimpleName name, int relevance) { - super("", cu, null, relevance, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE), new RemoveDeclarationCorrectionProposalCore(cu, name, relevance)); //$NON-NLS-1$ + super("", cu, null, relevance, ISharedImages.get().getImage(ISharedImages.IMG_TOOL_DELETE), new RemoveDeclarationCorrectionProposalCore(cu, name, relevance)); //$NON-NLS-1$ super.getDisplayString(); } } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java index 96fcd298bdf..72b3f82a508 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java @@ -72,7 +72,6 @@ import org.eclipse.ui.IWorkbenchPreferenceConstants; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.editors.text.EditorsUI; @@ -173,7 +172,7 @@ private static final class BackAction extends Action { public BackAction(BrowserInformationControl infoControl) { fInfoControl= infoControl; setText(JavaHoverMessages.JavadocHover_back); - ISharedImages images= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages images= ISharedImages.get(); setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_BACK)); setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED)); @@ -213,7 +212,7 @@ private static final class ForwardAction extends Action { public ForwardAction(BrowserInformationControl infoControl) { fInfoControl= infoControl; setText(JavaHoverMessages.JavadocHover_forward); - ISharedImages images= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages images= ISharedImages.get(); setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD)); setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD_DISABLED)); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java index 6ad85ec33ed..83036113586 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java @@ -27,7 +27,6 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.model.IWorkbenchAdapter; @@ -81,7 +80,7 @@ public class JavaElementImageProvider { private static ImageDescriptor DESC_OBJ_PROJECT_CLOSED; private static ImageDescriptor DESC_OBJ_PROJECT; { - ISharedImages images= PlatformUI.getWorkbench().getSharedImages(); + ISharedImages images= ISharedImages.get(); DESC_OBJ_PROJECT_CLOSED= images.getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED); DESC_OBJ_PROJECT= images.getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT); } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/StorageLabelProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/StorageLabelProvider.java index 85e7b9136fe..a8d27abff99 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/StorageLabelProvider.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/StorageLabelProvider.java @@ -87,7 +87,7 @@ public void dispose() { */ private Image getImageForJarEntry(IStorage element) { if (element instanceof IJarEntryResource && !((IJarEntryResource) element).isFile()) { - return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); + return ISharedImages.get().getImage(ISharedImages.IMG_OBJ_FOLDER); } if (fJarImageMap == null) @@ -133,7 +133,7 @@ private Image getImageForJarEntry(IStorage element) { private Image getDefaultImage() { if (fDefaultImage == null) - fDefaultImage= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); + fDefaultImage= ISharedImages.get().getImage(ISharedImages.IMG_OBJ_FILE); return fDefaultImage; } } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java index edc2284238c..5dcc9361918 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java @@ -60,7 +60,7 @@ import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.window.Window; -import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ISharedImages; import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.model.WorkbenchContentProvider; @@ -244,7 +244,7 @@ public Control createControl(Composite parent) { item.setData(fSourceContainerPage); item.setControl(fSourceContainerPage.getControl(folder)); - Image projectImage= PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT); + Image projectImage= ISharedImages.get().getImage(IDE.SharedImages.IMG_OBJ_PROJECT); fProjectsPage= new ProjectsWorkbookPage(fClassPathList, fPageContainer); item= new CTabItem(folder, SWT.NONE); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPVariableElementLabelProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPVariableElementLabelProvider.java index 720acc1c389..ced01dc1353 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPVariableElementLabelProvider.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPVariableElementLabelProvider.java @@ -25,13 +25,12 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; +import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; -import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; @@ -49,7 +48,7 @@ public class CPVariableElementLabelProvider extends LabelProvider { public CPVariableElementLabelProvider(boolean highlightReadOnly) { ImageRegistry reg= JavaPlugin.getDefault().getImageRegistry(); fJARImage= reg.get(JavaPluginImages.IMG_OBJS_EXTJAR); - fFolderImage= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); + fFolderImage= ISharedImages.get().getImage(ISharedImages.IMG_OBJ_FOLDER); fDeprecatedJARImage= new DecorationOverlayIcon(fJARImage, JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_LEFT).createImage(); fDeprecatedFolderImage= new DecorationOverlayIcon(fFolderImage, JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_LEFT).createImage(); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JARFileSelectionDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JARFileSelectionDialog.java index 7ea599114bd..5150894b93a 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JARFileSelectionDialog.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/JARFileSelectionDialog.java @@ -27,13 +27,13 @@ import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ISelectionStatusValidator; +import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; + import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; -import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.ui.viewsupport.FilteredElementTreeSelectionDialog; /** @@ -74,7 +74,7 @@ public JARFileSelectionDialog(Shell parent, boolean multiSelect, boolean acceptF private static class FileLabelProvider extends LabelProvider { - private final Image IMG_FOLDER= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); + private final Image IMG_FOLDER= ISharedImages.get().getImage(ISharedImages.IMG_OBJ_FOLDER); private final Image IMG_JAR= JavaPlugin.getDefault().getImageRegistry().get(JavaPluginImages.IMG_OBJS_EXTJAR); @Override diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java index 24d143f5972..779541a02ed 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java @@ -60,6 +60,7 @@ import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.jface.window.Window; +import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.IClasspathAttribute; @@ -485,7 +486,7 @@ public int compare(Viewer viewer, Object e1, Object e2) { } private void createHorizontalButtons(Composite parent) { - org.eclipse.ui.ISharedImages sharedImages= PlatformUI.getWorkbench().getSharedImages(); + org.eclipse.ui.ISharedImages sharedImages= ISharedImages.get(); Composite box= new Composite(parent, SWT.NONE); box.setLayout(new GridLayout(1, true));