diff options
| author | Alex Blewitt | 2020-06-05 18:39:38 +0000 |
|---|---|---|
| committer | Alexander Fedorov | 2020-06-08 11:16:36 +0000 |
| commit | 242011c7455ba2aff4862dcb04b6b56c9b4da773 (patch) | |
| tree | 2b616f4d62d9f774e26dbf3778df7db29017df12 | |
| parent | 7fe2cc03eeb4e8e779cd4d3c66d81b282846999b (diff) | |
| download | eclipse.platform.runtime-242011c7455ba2aff4862dcb04b6b56c9b4da773.tar.gz eclipse.platform.runtime-242011c7455ba2aff4862dcb04b6b56c9b4da773.tar.xz eclipse.platform.runtime-242011c7455ba2aff4862dcb04b6b56c9b4da773.zip | |
Bug 564004 - Remove CoreToolsPlugin activator
The CoreToolsPlugin activator does not achieve much, and can be removed.
Change-Id: Id30ad12ef9edc4a7205f2c586dfa0f520da77fb9
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
12 files changed, 34 insertions, 86 deletions
diff --git a/bundles/org.eclipse.core.tools/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.tools/META-INF/MANIFEST.MF index b0dff7266..7c992437b 100644 --- a/bundles/org.eclipse.core.tools/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.core.tools/META-INF/MANIFEST.MF @@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.tools; singleton:=true Bundle-Version: 1.7.500.qualifier -Bundle-Activator: org.eclipse.core.tools.CoreToolsPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.tools;x-internal:=true, diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/ClearTextAction.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/ClearTextAction.java index d58252317..d1c9365c4 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/ClearTextAction.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/ClearTextAction.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.core.tools; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkbenchCommandConstants; @@ -42,7 +43,9 @@ public class ClearTextAction extends GlobalAction { // then we need to provide an action definition id // so clients can register this action in their key binding services this.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE); - this.setImageDescriptor(CoreToolsPlugin.createImageDescriptor("clear.gif")); //$NON-NLS-1$ + this.setImageDescriptor(ImageDescriptor.createFromURLSupplier(true, () -> { + return ClearTextAction.class.getResource("/icons/clear.gif"); //$NON-NLS-1$ + })); } /** diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/CollapseAllAction.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/CollapseAllAction.java index 13a8ed371..99313e998 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/CollapseAllAction.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/CollapseAllAction.java @@ -14,6 +14,7 @@ package org.eclipse.core.tools; import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.TreeViewer; /** @@ -22,14 +23,15 @@ import org.eclipse.jface.viewers.TreeViewer; public class CollapseAllAction extends Action { private static final String label = "Collapse All"; //$NON-NLS-1$ - private static final String imageName = "collapseall.gif"; //$NON-NLS-1$ private TreeViewer viewer; public CollapseAllAction(TreeViewer viewer) { super(label); this.setToolTipText(label); this.viewer = viewer; - this.setImageDescriptor(CoreToolsPlugin.createImageDescriptor(imageName)); + this.setImageDescriptor(ImageDescriptor.createFromURLSupplier(true, () -> { + return CollapseAllAction.class.getResource("/icons/collapseall.gif"); //$NON-NLS-1$ + })); } @Override diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/CoreToolsPlugin.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/CoreToolsPlugin.java deleted file mode 100644 index 45a9e6e45..000000000 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/CoreToolsPlugin.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2013 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.core.tools; - -import java.net.URL; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -//import org.eclipse.core.runtime.internal.stats.ClassloaderStats; -//import org.eclipse.core.runtime.internal.stats.StatsManager; -//import org.eclipse.core.tools.runtime.VMClassInfo; -//import org.eclipse.core.tools.runtime.VMClassloaderInfo; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -public class CoreToolsPlugin extends AbstractUIPlugin { - private static CoreToolsPlugin instance; - public static String PI_TOOLS = "org.eclipse.core.tools"; //$NON-NLS-1$ - private BundleContext context; - - public static CoreToolsPlugin getDefault() { - return instance; - } - - /** - * find an icon - caller must dispose of it - */ - public static ImageDescriptor createImageDescriptor(String imageName) { - URL url = getDefault().getBundle().getEntry("icons/" + imageName); //$NON-NLS-1$ - if (url != null) - return ImageDescriptor.createFromURL(url); - return ImageDescriptor.getMissingImageDescriptor(); - } - - public CoreToolsPlugin() { - super(); - instance = this; - } - - @Override - public void start(BundleContext bundleContext) throws Exception { - super.start(bundleContext); - this.context = bundleContext; - } - - public BundleContext getContext() { - return context; - } - - public void log(String message, Throwable exception) { - getLog().log(new Status(IStatus.ERROR, PI_TOOLS, 0, message, exception)); - } -} diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/ErrorUtil.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/ErrorUtil.java index 10785d5a3..75763d87c 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/ErrorUtil.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/ErrorUtil.java @@ -13,8 +13,7 @@ *******************************************************************************/ package org.eclipse.core.tools; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.*; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; @@ -32,11 +31,10 @@ public class ErrorUtil { * @param userMessage an optional higher-level explanation for the exception */ public static void logException(Exception exception, String userMessage) { - String pluginID = CoreToolsPlugin.PI_TOOLS; if (userMessage == null) userMessage = exception.getMessage(); - IStatus status = new Status(IStatus.ERROR, pluginID, -1, userMessage, exception); - CoreToolsPlugin.getDefault().getLog().log(status); + IStatus status = new Status(IStatus.ERROR, ErrorUtil.class, -1, userMessage, exception); + Platform.getLog(ErrorUtil.class).log(status); } /** diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumpContentsView.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumpContentsView.java index a6f3d4a03..ae0eae807 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumpContentsView.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumpContentsView.java @@ -14,6 +14,7 @@ package org.eclipse.core.tools.metadata; import java.io.File; +import org.eclipse.core.runtime.*; import org.eclipse.core.tools.*; import org.eclipse.jface.action.*; import org.eclipse.jface.text.Document; @@ -109,7 +110,9 @@ public class DumpContentsView extends SpyView { // dumps file IDump dump = dumper.dump(file); if (dump.isFailed()) { - CoreToolsPlugin.getDefault().log("Error during file dump", dump.getFailureReason()); //$NON-NLS-1$ + Status status = new Status(IStatus.ERROR, DumpContentsView.class, 0, "Error during file dump", //$NON-NLS-1$ + dump.getFailureReason()); + Platform.getLog(DumpContentsView.class).log(status); String message = "File dumping did not complete successfully. Reason: " + dump.getFailureReason(); //$NON-NLS-1$ ErrorUtil.showErrorMessage(message, "Error during file dump"); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumperFactory.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumperFactory.java index 3d9151d9f..1380c9d45 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumperFactory.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumperFactory.java @@ -16,13 +16,13 @@ package org.eclipse.core.tools.metadata; import java.io.File; import java.util.Properties; import org.eclipse.core.runtime.*; -import org.eclipse.core.tools.CoreToolsPlugin; /** * A dumper factory creates a dumper object given a file name. */ public class DumperFactory { + private static final String TOOLS_EXTENSION_POINT = "org.eclipse.core.tools"; //$NON-NLS-1$ private static final String ELEM_DUMPER = "dumper"; //$NON-NLS-1$ private static final String ATTR_FILE_NAME = "file-name"; //$NON-NLS-1$ private static final String PT_METADATA_DUMPERS = "metadataDumpers"; //$NON-NLS-1$ @@ -57,7 +57,8 @@ public class DumperFactory { } private void loadDumpers() { - IExtensionPoint dumpersPoint = Platform.getExtensionRegistry().getExtensionPoint(CoreToolsPlugin.PI_TOOLS, PT_METADATA_DUMPERS); + IExtensionPoint dumpersPoint = Platform.getExtensionRegistry().getExtensionPoint(TOOLS_EXTENSION_POINT, + PT_METADATA_DUMPERS); IConfigurationElement[] dumperDefinitions = dumpersPoint.getConfigurationElements(); for (IConfigurationElement dumperDefinition : dumperDefinitions) if (dumperDefinition.getName().equals(ELEM_DUMPER)) diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/MessageBundleRefactoring.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/MessageBundleRefactoring.java index e3da74e7b..13deddd19 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/MessageBundleRefactoring.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/MessageBundleRefactoring.java @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.core.filebuffers.*; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.*; -import org.eclipse.core.tools.CoreToolsPlugin; import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.dom.*; import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; @@ -91,7 +90,8 @@ public class MessageBundleRefactoring extends Refactoring { LocationKind.NORMALIZE, null); } } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, CoreToolsPlugin.PI_TOOLS, IStatus.ERROR, e.getMessage(), e)); + throw new CoreException( + new Status(IStatus.ERROR, MessageBundleRefactoring.class, IStatus.ERROR, e.getMessage(), e)); } } diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/RemoveUnusedMessages.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/RemoveUnusedMessages.java index 98b28afcd..877d36a4f 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/RemoveUnusedMessages.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/RemoveUnusedMessages.java @@ -19,7 +19,6 @@ import java.util.List; import org.eclipse.core.filebuffers.*; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.*; -import org.eclipse.core.tools.CoreToolsPlugin; import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.dom.*; import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; @@ -151,7 +150,8 @@ public class RemoveUnusedMessages extends Refactoring { LocationKind.NORMALIZE, null); } } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, CoreToolsPlugin.PI_TOOLS, IStatus.ERROR, e.getMessage(), e)); + throw new CoreException( + new Status(IStatus.ERROR, RemoveUnusedMessages.class, IStatus.ERROR, e.getMessage(), e)); } } diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/EventsView.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/EventsView.java index 67518d454..3fa664b2d 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/EventsView.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/EventsView.java @@ -19,6 +19,7 @@ import java.util.Iterator; import org.eclipse.core.runtime.PerformanceStats; import org.eclipse.core.tools.*; import org.eclipse.jface.action.*; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.*; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; @@ -211,7 +212,9 @@ public class EventsView extends TableWithTotalView { } }; resetAction.setToolTipText("Reset all event statistics"); //$NON-NLS-1$ - resetAction.setImageDescriptor(CoreToolsPlugin.createImageDescriptor("clear.gif")); //$NON-NLS-1$ + resetAction.setImageDescriptor(ImageDescriptor.createFromURLSupplier(true, () -> { + return EventsView.class.getResource("/icons/clear.gif"); //$NON-NLS-1$ + })); // Add copy selection action IActionBars bars = getViewSite().getActionBars(); diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PluginListView.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PluginListView.java index 15ca50104..1e9628538 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PluginListView.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PluginListView.java @@ -15,15 +15,15 @@ package org.eclipse.core.tools.runtime; import java.util.*; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.tools.*; +import org.eclipse.core.tools.Messages; +import org.eclipse.core.tools.SpyView; import org.eclipse.jface.viewers.*; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.service.resolver.State; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; +import org.osgi.framework.*; public class PluginListView extends SpyView implements IStructuredContentProvider { @@ -61,7 +61,7 @@ public class PluginListView extends SpyView implements IStructuredContentProvide return id1.compareTo(id2); }; Set<BundleDescription> set = new TreeSet<>(comparator); - BundleContext context = CoreToolsPlugin.getDefault().getContext(); + BundleContext context = FrameworkUtil.getBundle(PluginListView.class).getBundleContext(); Bundle[] allBundles = context.getBundles(); State state = Platform.getPlatformAdmin().getState(false); for (Bundle allBundle : allBundles) diff --git a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PreferenceStatsView.java b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PreferenceStatsView.java index 3961523d5..902085caf 100644 --- a/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PreferenceStatsView.java +++ b/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PreferenceStatsView.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IPreferenceNodeVisitor; import org.eclipse.core.tools.*; import org.eclipse.jface.action.*; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.*; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; @@ -62,7 +63,9 @@ public class PreferenceStatsView extends SpyView { UpdateAction() { super("Update view"); //$NON-NLS-1$ this.setToolTipText("Update"); //$NON-NLS-1$ - this.setImageDescriptor(CoreToolsPlugin.createImageDescriptor("refresh.gif")); //$NON-NLS-1$ + this.setImageDescriptor(ImageDescriptor.createFromURLSupplier(true, () -> { + return PreferenceStatsView.class.getResource("/icons/refresh.gif"); //$NON-NLS-1$ + })); } @Override |
