From 27dd1e52d45c0b0dac8685bf2059772b64809c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 21 Jan 2025 09:15:03 +0100 Subject: [PATCH] Make JavaPlugin.getActivePage() aware of not running platform and inline Currently JavaPlugin.getActivePage() fails if no workbench is running, while the method itself can return null if there is no active window anyways. Beside that is unnecessary access the default java plugin even though all code called there is static anyways. This now changes the following parts: 1) guard getActiveWorkbenchWindow against not running workbench 2) used getActiveWorkbenchWindow instead of similar code in getActivePage like in getActiveWorkbenchShell 3) delete no longer needed private method 4) Use JavaPlugin.getActiveWorkbenchWindow() instead of PlatformUI 5) Use JavaPlugin.getActiveWorkbenchShell() instead of PlatformUI --- .../corext/fix/CleanUpPostSaveListener.java | 5 ++--- .../RefactoringExecutionStarter.java | 5 ++--- .../eclipse/jdt/internal/ui/JavaPlugin.java | 18 +++++++++--------- .../actions/AddGetterSetterTypeProposal.java | 4 ++-- .../actions/EnablePreviewFeaturesAction.java | 3 +-- .../ui/actions/HashCodeEqualsTypeProposal.java | 4 ++-- .../SurroundWithTemplateMenuAction.java | 2 +- .../ui/actions/ToStringTypeProposal.java | 4 ++-- .../JavaCompareWithEditionActionImpl.java | 5 ++--- .../jdt/internal/ui/infoviews/JavadocView.java | 2 +- .../jarpackager/CreateJarActionDelegate.java | 4 +--- .../JavaElementImplementationHyperlink.java | 3 +-- .../GetterSetterCorrectionSubProcessor.java | 3 +-- .../PreviewFeaturesSubProcessor.java | 2 +- .../proposals/FixCorrectionProposal.java | 6 ++---- .../ui/text/java/JavaContentAssistHandler.java | 4 ++-- .../java/hover/AbstractAnnotationHover.java | 3 +-- .../hover/ConfigureProblemSeverityAction.java | 4 ++-- .../javadoc/JavaDocAutoIndentStrategy.java | 3 +-- 19 files changed, 36 insertions(+), 48 deletions(-) diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPostSaveListener.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPostSaveListener.java index e8010fbefb9..3a31eaf25c3 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPostSaveListener.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPostSaveListener.java @@ -71,7 +71,6 @@ import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ltk.core.refactoring.Change; @@ -474,7 +473,7 @@ private int showStatus(RefactoringStatus status) { if (!status.hasError()) return Window.OK; - Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + Shell shell= JavaPlugin.getActiveWorkbenchShell(); Dialog dialog= RefactoringUI.createRefactoringStatusDialog(status, shell, "", false); //$NON-NLS-1$ return dialog.open(); @@ -674,7 +673,7 @@ private void showSlowCleanUpsWarning(HashSet slowCleanUps) { private void showSlowCleanUpDialog(final StringBuilder cleanUpNames) { if (OptionalMessageDialog.isDialogEnabled(SlowCleanUpWarningDialog.ID)) { - Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + Shell shell= JavaPlugin.getActiveWorkbenchShell(); new SlowCleanUpWarningDialog(shell, FixMessages.CleanUpPostSaveListener_SlowCleanUpDialog_title, cleanUpNames.toString()).open(); } } diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java index 660a66b19fb..4331fdd2bae 100644 --- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java +++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringExecutionStarter.java @@ -36,8 +36,6 @@ import org.eclipse.jface.text.ITextSelection; -import org.eclipse.ui.PlatformUI; - import org.eclipse.ltk.core.refactoring.Refactoring; import org.eclipse.ltk.core.refactoring.RefactoringCore; import org.eclipse.ltk.core.refactoring.RefactoringStatus; @@ -109,6 +107,7 @@ import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper; import org.eclipse.jdt.ui.refactoring.RenameSupport; +import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ActionMessages; import org.eclipse.jdt.internal.ui.fix.CleanUpRefactoringWizard; import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; @@ -249,7 +248,7 @@ public static void startCleanupRefactoring(ICompilationUnit[] cus, ICleanUp[] cl if (refactoring.getCleanUpTargetsSize() > 1) { context= new ProgressMonitorDialog(shell); } else { - context= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + context= JavaPlugin.getActiveWorkbenchWindow(); } RefactoringExecutionHelper helper= new RefactoringExecutionHelper(refactoring, IStatus.INFO, IRefactoringSaveModes.SAVE_REFACTORING, shell, context); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java index d95a28904d9..78de1a795fa 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java @@ -284,11 +284,18 @@ public static IWorkspace getWorkspace() { } public static IWorkbenchPage getActivePage() { - return getDefault().internalGetActivePage(); + IWorkbenchWindow window= getActiveWorkbenchWindow(); + if (window != null) { + return window.getActivePage(); + } + return null; } public static IWorkbenchWindow getActiveWorkbenchWindow() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (PlatformUI.isWorkbenchRunning()) { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + } + return null; } public static Shell getActiveWorkbenchShell() { @@ -544,13 +551,6 @@ public void stop(BundleContext context) throws Exception { } } - private IWorkbenchPage internalGetActivePage() { - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return null; - return window.getActivePage(); - } - /** * Private deprecated method to avoid deprecation warnings * diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddGetterSetterTypeProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddGetterSetterTypeProposal.java index ab929f5f734..680e1068488 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddGetterSetterTypeProposal.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddGetterSetterTypeProposal.java @@ -23,7 +23,6 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.IType; @@ -33,6 +32,7 @@ import org.eclipse.jdt.ui.actions.AddGetterSetterAction; import org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal; +import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages; @@ -68,7 +68,7 @@ public void apply(IDocument document) { Display.getDefault().syncExec(() -> { try { IStructuredSelection selection= new StructuredSelection(fType); - IWorkbenchSite site= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite(); + IWorkbenchSite site= JavaPlugin.getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite(); new AddGetterSetterAction(site).run(selection); } catch (NullPointerException e) { // do nothing diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/EnablePreviewFeaturesAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/EnablePreviewFeaturesAction.java index b07cd16b6df..63a0ae8f20a 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/EnablePreviewFeaturesAction.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/EnablePreviewFeaturesAction.java @@ -34,7 +34,6 @@ import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.jdt.core.IJavaProject; @@ -106,7 +105,7 @@ public void run(IAction action) { map.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); fJavaProject.setOptions(map); - Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + Shell shell= JavaPlugin.getActiveWorkbenchShell(); Map data= new HashMap<>(); data.put(CompliancePreferencePage.DATA_SELECT_OPTION_KEY, JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES); data.put(CompliancePreferencePage.DATA_SELECT_OPTION_QUALIFIER, JavaCore.PLUGIN_ID); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/HashCodeEqualsTypeProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/HashCodeEqualsTypeProposal.java index 4c24a78cbf5..68f5f00a848 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/HashCodeEqualsTypeProposal.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/HashCodeEqualsTypeProposal.java @@ -23,7 +23,6 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.IType; @@ -33,6 +32,7 @@ import org.eclipse.jdt.ui.actions.GenerateHashCodeEqualsAction; import org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal; +import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages; @@ -68,7 +68,7 @@ public void apply(IDocument document) { Display.getDefault().syncExec(() -> { try { IStructuredSelection selection= new StructuredSelection(fType); - IWorkbenchSite site= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite(); + IWorkbenchSite site= JavaPlugin.getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite(); new GenerateHashCodeEqualsAction(site).run(selection); } catch (NullPointerException e) { // do nothing diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/SurroundWithTemplateMenuAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/SurroundWithTemplateMenuAction.java index c5078456224..a3df92664bd 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/SurroundWithTemplateMenuAction.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/SurroundWithTemplateMenuAction.java @@ -101,7 +101,7 @@ public void run() { } private Shell getShell() { - return JavaPlugin.getActiveWorkbenchWindow().getShell(); + return JavaPlugin.getActiveWorkbenchShell(); } } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ToStringTypeProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ToStringTypeProposal.java index df707d3e832..8006e2fc352 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ToStringTypeProposal.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ToStringTypeProposal.java @@ -23,7 +23,6 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.IType; @@ -33,6 +32,7 @@ import org.eclipse.jdt.ui.actions.GenerateToStringAction; import org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal; +import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages; @@ -68,7 +68,7 @@ public void apply(IDocument document) { Display.getDefault().syncExec(() -> { try { IStructuredSelection selection= new StructuredSelection(fType); - IWorkbenchSite site= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite(); + IWorkbenchSite site= JavaPlugin.getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite(); new GenerateToStringAction(site).run(selection); } catch (NullPointerException e) { // do nothing diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareWithEditionActionImpl.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareWithEditionActionImpl.java index 85e7eefd451..edef0b56b8e 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareWithEditionActionImpl.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareWithEditionActionImpl.java @@ -21,14 +21,13 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.PlatformUI; - import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.CompareUI; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; +import org.eclipse.jdt.internal.ui.JavaPlugin; /** @@ -67,7 +66,7 @@ public void run(ISelection selection) { ci.setHelpContextId(IJavaHelpContextIds.COMPARE_ELEMENT_WITH_HISTORY_DIALOG); CompareUI.openCompareDialog(ci); } else { - TeamUI.showHistoryFor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), input, pageSource); + TeamUI.showHistoryFor(JavaPlugin.getActiveWorkbenchWindow().getActivePage(), input, pageSource); } } } 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 d01793a9195..405cb3417c4 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 @@ -792,7 +792,7 @@ protected Object computeInput(Object input) { return null; IWorkbenchPart part= null; - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page= window.getActivePage(); if (page != null) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/CreateJarActionDelegate.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/CreateJarActionDelegate.java index 2c44c5ecd83..223e394eafa 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/CreateJarActionDelegate.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/CreateJarActionDelegate.java @@ -32,8 +32,6 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.ui.PlatformUI; - import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.corext.util.Messages; @@ -97,7 +95,7 @@ private IStatus export(JarPackageData[] jarPackages) { Shell shell= getShell(); IJarExportRunnable op= jarPackages[0].createJarExportRunnable(jarPackages, shell); try { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(false, true, op); + JavaPlugin.getActiveWorkbenchWindow().run(false, true, op); //PlatformUI.getWorkbench().getProgressService().run(false, true, op); // see bug 118152 } catch (InvocationTargetException ex) { if (ex.getTargetException() != null) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementImplementationHyperlink.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementImplementationHyperlink.java index 7cd12046cd7..da1267ea018 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementImplementationHyperlink.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementImplementationHyperlink.java @@ -35,7 +35,6 @@ import org.eclipse.jface.text.hyperlink.IHyperlink; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; @@ -290,7 +289,7 @@ public void acceptSearchMatch(SearchMatch match) throws CoreException { IStatus status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(JavaEditorMessages.JavaElementImplementationHyperlink_error_status_message, javaElement.getElementName()), e.getCause()); JavaPlugin.log(status); - ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + ErrorDialog.openError(JavaPlugin.getActiveWorkbenchShell(), JavaEditorMessages.JavaElementImplementationHyperlink_hyperlinkText, JavaEditorMessages.JavaElementImplementationHyperlink_error_no_implementations_found_message, status); } catch (InterruptedException e) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java index f2ae641428d..510de5e5f7b 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java @@ -29,7 +29,6 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.ltk.core.refactoring.TextFileChange; @@ -105,7 +104,7 @@ public void apply(IDocument document) { refactoring.setConsiderVisibility(false);//private field references are just searched in local file }); if (fNoDialog) { - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); final RefactoringExecutionHelper helper= new RefactoringExecutionHelper(compositeRefactoring, RefactoringStatus.ERROR, IRefactoringSaveModes.SAVE_REFACTORING, JavaPlugin.getActiveWorkbenchShell(), window); if (Display.getCurrent() != null) { try { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java index 54832830e3a..3b21b8a6b43 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java @@ -143,7 +143,7 @@ public static void getOpenCompliancePageToEnablePreviewFeaturesProposal(IInvocat @Override public void apply(IDocument document) { - Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + Shell shell= JavaPlugin.getActiveWorkbenchShell(); boolean usePropertyPage; if (!hasProjectSpecificOptions) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java index b5256dd5251..acbc8e7cef2 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java @@ -35,8 +35,6 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; -import org.eclipse.ui.PlatformUI; - import org.eclipse.ltk.core.refactoring.RefactoringCore; import org.eclipse.jdt.core.dom.CompilationUnit; @@ -108,7 +106,7 @@ public void resolve(MultiFixTarget[] targets, final IProgressMonitor monitor) th IRunnableContext context= (fork, cancelable, runnable) -> runnable.run(monitor == null ? new NullProgressMonitor() : monitor); - Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + Shell shell= JavaPlugin.getActiveWorkbenchShell(); RefactoringExecutionHelper helper= new RefactoringExecutionHelper(refactoring, IStatus.INFO, IRefactoringSaveModes.SAVE_REFACTORING, shell, context); try { helper.perform(true, true); @@ -208,7 +206,7 @@ public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) { int stopSeverity= RefactoringCore.getConditionCheckingFailedSeverity(); Shell shell= JavaPlugin.getActiveWorkbenchShell(); - IRunnableContext context= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow(); RefactoringExecutionHelper executer= new RefactoringExecutionHelper(refactoring, stopSeverity, IRefactoringSaveModes.SAVE_NOTHING, shell, context); try { executer.perform(true, true); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaContentAssistHandler.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaContentAssistHandler.java index 79f19b80452..9bf1dd422d0 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaContentAssistHandler.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaContentAssistHandler.java @@ -20,10 +20,10 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; import org.eclipse.jdt.internal.ui.javaeditor.SpecificContentAssistExecutor; @@ -56,7 +56,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { } private ITextEditor getActiveEditor() { - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page= window.getActivePage(); if (page != null) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/AbstractAnnotationHover.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/AbstractAnnotationHover.java index 346ffb02e0f..c044102ed71 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/AbstractAnnotationHover.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/AbstractAnnotationHover.java @@ -81,7 +81,6 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IStorageEditorInput; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.texteditor.AnnotationPreference; @@ -656,7 +655,7 @@ public ConfigureAnnotationsAction(Annotation annotation, IInformationControl inf */ @Override public void run() { - Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + Shell shell= JavaPlugin.getActiveWorkbenchShell(); Object data= null; AnnotationPreference preference= getAnnotationPreference(fAnnotation); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java index 8871155f382..02b44a0921a 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java @@ -25,7 +25,6 @@ import org.eclipse.jface.text.IInformationControl; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.jdt.core.IJavaProject; @@ -34,6 +33,7 @@ import org.eclipse.jdt.ui.JavaElementLabels; +import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog; import org.eclipse.jdt.internal.ui.preferences.ComplianceConfigurationBlock; @@ -85,7 +85,7 @@ public ConfigureProblemSeverityAction(IJavaProject project, String optionId, Str public void run() { boolean showPropertyPage; - Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + Shell shell= JavaPlugin.getActiveWorkbenchShell(); if (!hasProjectSpecificOptions()) { String message= Messages.format( diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java index 12690865297..4481064d8ab 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java @@ -28,7 +28,6 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.ITextEditorExtension3; @@ -528,7 +527,7 @@ private static IMethod getInheritedMethod(IMethod method) throws JavaModelExcept */ private static ICompilationUnit getCompilationUnit() { - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window == null) return null;