[releng] Fix some deprecations
diff --git a/examples/org.eclipse.ocl.examples.debug.ui/src/org/eclipse/ocl/examples/debug/ui/OCLDebugUIPlugin.java b/examples/org.eclipse.ocl.examples.debug.ui/src/org/eclipse/ocl/examples/debug/ui/OCLDebugUIPlugin.java
index 2a2857b..d5c7eaa 100644
--- a/examples/org.eclipse.ocl.examples.debug.ui/src/org/eclipse/ocl/examples/debug/ui/OCLDebugUIPlugin.java
+++ b/examples/org.eclipse.ocl.examples.debug.ui/src/org/eclipse/ocl/examples/debug/ui/OCLDebugUIPlugin.java
@@ -26,6 +26,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -43,7 +44,7 @@
private static final Logger logger = Logger.getLogger(OCLDebugUIPlugin.class);
protected ImageRegistry imageDescriptorRegistry;
-
+
/**
* The constructor
*/
@@ -54,6 +55,7 @@
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
@@ -63,6 +65,7 @@
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(BundleContext context) throws Exception {
plugin = null;
if (imageDescriptorRegistry != null) {
@@ -81,11 +84,11 @@
return plugin;
}
-
+
public Image createImage(String path) {
-
+
Image image = getImageRegistry().get(path);
-
+
if (image == null) {
try {
ImageDescriptor imageDescriptor = getImageDescriptor(path);
@@ -96,14 +99,14 @@
}
catch(Exception e) { logger.error("Failed to createImage '" + path + "'", e); }
}
-
+
return image;
}
-
+
public ImageDescriptor getImageDescriptor(String path) {
-
+
ImageDescriptor imageDescriptor = getImageDescriptorRegistry().getDescriptor(path);
-
+
if (imageDescriptor == null) {
URL url = FileLocator.find(getBundle(), new Path(path), Collections.<String, String>emptyMap());
if (url != null) {
@@ -111,33 +114,33 @@
if (imageDescriptor != null) getImageDescriptorRegistry().put(path, imageDescriptor);
}
}
-
+
return imageDescriptor;
}
-
+
protected ImageRegistry getImageDescriptorRegistry() {
if (imageDescriptorRegistry == null) {
imageDescriptorRegistry = createImageRegistry();
}
return imageDescriptorRegistry;
}
-
+
public static BasicDiagnostic createDiagnostic(String message) {
return new BasicDiagnostic(Diagnostic.OK, PLUGIN_ID, 0, message, null);
}
-
+
public static Diagnostic createErrorDiagnostic(String message, Throwable throwable) {
Object[] data = (throwable == null) ? null : new Object [] { throwable };
return new BasicDiagnostic(Diagnostic.ERROR, PLUGIN_ID, 0, message, data);
}
-
+
public static Diagnostic createWarnDiagnostic(String message) {
return new BasicDiagnostic(Diagnostic.ERROR, PLUGIN_ID, 0, message, null);
- }
+ }
/**
* Indicates that the given diagnostic is neither error or canceled.
- *
+ *
* @param diagnostic
* the diagnostic to test
* @return <code>true</code> in case of success, <code>false</code>
@@ -147,7 +150,7 @@
int severity = diagnostic.getSeverity();
return severity != Diagnostic.ERROR && severity != Diagnostic.CANCEL;
}
-
+
public static void log(int severity, int code, String message, Throwable throwable) {
//
// Status ctor requires a non-null message
@@ -194,7 +197,7 @@
if(debugPlugin != null) {
debugPlugin.getLog().log(status);
}
- }
+ }
public static void log(Throwable e) {
log(new Status(IStatus.ERROR, PLUGIN_ID, "Exception caught", e)); //$NON-NLS-1$
@@ -210,16 +213,16 @@
/**
* Returns the active workbench window
- *
+ *
* @return the active workbench window
*/
public static IWorkbenchWindow getActiveWorkbenchWindow() {
- return getDefault().getWorkbench().getActiveWorkbenchWindow();
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
/**
* Returns the active workbench shell or <code>null</code> if none
- *
+ *
* @return the active workbench shell or <code>null</code> if none
*/
public static Shell getActiveWorkbenchShell() {
diff --git a/examples/org.eclipse.ocl.examples.debug.vm.ui/src/org/eclipse/ocl/examples/debug/vm/ui/DebugVMUIPlugin.java b/examples/org.eclipse.ocl.examples.debug.vm.ui/src/org/eclipse/ocl/examples/debug/vm/ui/DebugVMUIPlugin.java
index 84a56e9..06b19d5 100644
--- a/examples/org.eclipse.ocl.examples.debug.vm.ui/src/org/eclipse/ocl/examples/debug/vm/ui/DebugVMUIPlugin.java
+++ b/examples/org.eclipse.ocl.examples.debug.vm.ui/src/org/eclipse/ocl/examples/debug/vm/ui/DebugVMUIPlugin.java
@@ -25,12 +25,14 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.resource.ResourceLocator;
import org.eclipse.ocl.examples.debug.vm.ui.actions.DebugVMImages;
import org.eclipse.ocl.examples.debug.vm.ui.messages.DebugVMUIMessages;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -221,7 +223,7 @@
* @return the active workbench window
*/
public static IWorkbenchWindow getActiveWorkbenchWindow() {
- return getDefault().getWorkbench().getActiveWorkbenchWindow();
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
/**
@@ -325,7 +327,7 @@
}
private ImageDescriptor imageDescriptor(String imagePath) {
- return imageDescriptorFromPlugin(PLUGIN_ID, "icons/" + imagePath); //$NON-NLS-1$
+ return ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, "icons/" + imagePath).orElse(null); //$NON-NLS-1$
}
/* private final ImageDescriptor overlayImage(String overImagePath, Image base, int quadrant) {
diff --git a/plugins/org.eclipse.ocl.xtext.base.ui/src/org/eclipse/ocl/xtext/base/ui/BaseUiPluginHelper.java b/plugins/org.eclipse.ocl.xtext.base.ui/src/org/eclipse/ocl/xtext/base/ui/BaseUiPluginHelper.java
index f7d7dc1b..604c790 100644
--- a/plugins/org.eclipse.ocl.xtext.base.ui/src/org/eclipse/ocl/xtext/base/ui/BaseUiPluginHelper.java
+++ b/plugins/org.eclipse.ocl.xtext.base.ui/src/org/eclipse/ocl/xtext/base/ui/BaseUiPluginHelper.java
@@ -17,16 +17,16 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ResourceLocator;
import org.eclipse.ocl.xtext.base.ui.internal.BaseActivator;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
public class BaseUiPluginHelper extends EMFPlugin.InternalHelper
{
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.ocl.xtext.base.ui"; //$NON-NLS-1$
- public static final BaseUiPluginHelper INSTANCE = new BaseUiPluginHelper(BaseActivator.getInstance());
-
+ public static final BaseUiPluginHelper INSTANCE = new BaseUiPluginHelper(BaseActivator.getInstance());
+
private BaseUiPluginHelper(Plugin plugin) {
super(plugin);
}
@@ -34,27 +34,27 @@
public Status createErrorStatus(Exception e) {
return new Status(Status.ERROR, getSymbolicName(), e.getMessage(), e);
}
-
+
/**
* Returns an image descriptor for the image file at the given plug-in
* relative path
- *
+ *
* @param path
* the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
+ return ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, path).orElse(null);
}
-
+
/**
* Logs the given message and throwable to the platform log.
- *
+ *
* If you have a status object in hand call log(String, IStatus) instead.
- *
+ *
* This convenience method is for internal use by the IDE Workbench only and
* must not be called outside the IDE Workbench.
- *
+ *
* @param message
* A high level UI message describing when the problem happened.
* @param t
@@ -67,10 +67,10 @@
/**
* Logs the given message and status to the platform log.
- *
+ *
* This convenience method is for internal use by the IDE Workbench only and
* must not be called outside the IDE Workbench.
- *
+ *
* @param message
* A high level UI message describing when the problem happened.
* May be <code>null</code>.
@@ -91,10 +91,10 @@
* Logs the given throwable to the platform log, indicating the class and
* method from where it is being logged (this is not necessarily where it
* occurred).
- *
+ *
* This convenience method is for internal use by the IDE Workbench only and
* must not be called outside the IDE Workbench.
- *
+ *
* @param clazz
* The calling class.
* @param methodName
@@ -117,7 +117,7 @@
/**
* Logs a message with given level into the Eclipse log file
- *
+ *
* @param message
* the message to log
* @param severity