package eu.etaxonomy.taxeditor;\r
\r
+import java.net.URL;\r
+import java.util.MissingResourceException;\r
+import java.util.ResourceBundle;\r
+\r
+import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.Path;\r
import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.jface.resource.ImageRegistry;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.ui.forms.FormColors;\r
import org.eclipse.ui.plugin.AbstractUIPlugin;\r
import org.osgi.framework.BundleContext;\r
\r
* (non-Javadoc)\r
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
*/\r
- public void stop(BundleContext context) throws Exception {\r
+ /*public void stop(BundleContext context) throws Exception {\r
plugin = null;\r
super.stop(context);\r
- }\r
+ }*/\r
\r
/**\r
* Returns the shared instance\r
* @param path the path\r
* @return the image descriptor\r
*/\r
- public static ImageDescriptor getImageDescriptor(String path) {\r
+ public static ImageDescriptor getImageDescriptorOrig(String path) {\r
return imageDescriptorFromPlugin(PLUGIN_ID, path);\r
}\r
+ \r
+ /**\r
+ * EVERYTHING BELOW HERE WAS PASTED FROM FORMARTICLEPLUGIN.JAVA\r
+ **/\r
+ //Resource bundle.\r
+ private ResourceBundle resourceBundle;\r
+ private FormColors formColors;\r
+ public static final String IMG_FORM_BG = "formBg"; //$NON-NLS-1$\r
+ public static final String IMG_LARGE = "large"; //$NON-NLS-1$\r
+ public static final String IMG_HORIZONTAL = "horizontal"; //$NON-NLS-1$\r
+ public static final String IMG_VERTICAL = "vertical"; //$NON-NLS-1$\r
+ public static final String IMG_SAMPLE = "sample"; //$NON-NLS-1$\r
+ public static final String IMG_WIZBAN = "wizban"; //$NON-NLS-1$\r
+ public static final String IMG_LINKTO_HELP = "linkto_help"; //$NON-NLS-1$\r
+ public static final String IMG_HELP_TOPIC = "help_topic"; //$NON-NLS-1$\r
+ public static final String IMG_CLOSE = "close"; //$NON-NLS-1$\r
+ \r
+ protected void initializeImageRegistry(ImageRegistry registry) {\r
+ registerImage(registry, IMG_FORM_BG, "form_banner.gif"); //$NON-NLS-1$\r
+ registerImage(registry, IMG_LARGE, "large_image.gif"); //$NON-NLS-1$\r
+ registerImage(registry, IMG_HORIZONTAL, "th_horizontal.gif"); //$NON-NLS-1$\r
+ registerImage(registry, IMG_VERTICAL, "th_vertical.gif"); //$NON-NLS-1$\r
+ registerImage(registry, IMG_SAMPLE, "sample.gif"); //$NON-NLS-1$\r
+ registerImage(registry, IMG_WIZBAN, "newprj_wiz.gif"); //$NON-NLS-1$\r
+ registerImage(registry, IMG_LINKTO_HELP, "linkto_help.gif"); //$NON-NLS-1$\r
+ registerImage(registry, IMG_HELP_TOPIC, "help_topic.gif"); //$NON-NLS-1$\r
+ registerImage(registry, IMG_CLOSE, "close_view.gif"); //$NON-NLS-1$\r
+ }\r
+\r
+ private void registerImage(ImageRegistry registry, String key,\r
+ String fileName) {\r
+ try {\r
+ IPath path = new Path("icons/" + fileName); //$NON-NLS-1$\r
+ URL url = find(path);\r
+ if (url!=null) {\r
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);\r
+ registry.put(key, desc);\r
+ }\r
+ } catch (Exception e) {\r
+ }\r
+ }\r
+\r
+ public FormColors getFormColors(Display display) {\r
+ if (formColors == null) {\r
+ formColors = new FormColors(display);\r
+ formColors.markShared();\r
+ }\r
+ return formColors;\r
+ }\r
+ /**\r
+ * Returns the workspace instance.\r
+ */\r
+/* public static IWorkspace getWorkspace() {\r
+ return ResourcesPlugin.getWorkspace();\r
+ }*/\r
+ /**\r
+ * Returns the string from the plugin's resource bundle, or 'key' if not\r
+ * found.\r
+ */\r
+ public static String getResourceString(String key) {\r
+ ResourceBundle bundle = Activator.getDefault().getResourceBundle();\r
+ try {\r
+ return (bundle != null ? bundle.getString(key) : key);\r
+ } catch (MissingResourceException e) {\r
+ return key;\r
+ }\r
+ }\r
+ /**\r
+ * Returns the plugin's resource bundle,\r
+ */\r
+ public ResourceBundle getResourceBundle() {\r
+ return resourceBundle;\r
+ }\r
+ public void stop(BundleContext context) throws Exception {\r
+ plugin = null;\r
+ try {\r
+ if (formColors != null) {\r
+ formColors.dispose();\r
+ formColors = null;\r
+ }\r
+ } finally {\r
+ super.stop(context);\r
+ }\r
+ }\r
+ public Image getImage(String key) {\r
+ return getImageRegistry().get(key);\r
+ }\r
+ public ImageDescriptor getImageDescriptor(String key) {\r
+ return getImageRegistry().getDescriptor(key);\r
+ }\r
+ \r
}\r