--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.issues.ui.internal;\r
+\r
+import java.net.URL;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.jface.resource.ImageRegistry;\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.Bundle;\r
+import org.osgi.framework.BundleContext;\r
+import org.osgi.util.tracker.ServiceTracker;\r
+import org.simantics.issues.Severity;\r
+import org.simantics.message.IMessageSchemeManager;\r
+import org.simantics.utils.ui.gfx.AlphaAdjustmentImageDescriptor;\r
+import org.simantics.utils.ui.gfx.HSVAdjustmentImageDescriptor;\r
+\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+ public static final String PLUGIN_ID = "org.simantics.issues.ui";\r
+ \r
+ static Activator instance;\r
+ ServiceTracker messageScheme;\r
+\r
+ public static ImageDescriptor HIDE_ICON;\r
+ public static ImageDescriptor UNHIDE_ICON;\r
+ public static ImageDescriptor RESOLVE_ICON;\r
+ public static ImageDescriptor UNRESOLVE_ICON;\r
+\r
+ public static ImageDescriptor PURGE_ICON;\r
+\r
+ public static ImageDescriptor FATAL_ICON;\r
+ public static ImageDescriptor ERROR_ICON;\r
+ public static ImageDescriptor WARNING_ICON;\r
+ public static ImageDescriptor INFO_ICON;\r
+ public static ImageDescriptor NOTE_ICON;\r
+ public static ImageDescriptor OK_ICON;\r
+\r
+ public static ImageDescriptor FATAL_DECORATION_ICON;\r
+ public static ImageDescriptor ERROR_DECORATION_ICON;\r
+ public static ImageDescriptor WARNING_DECORATION_ICON;\r
+ public static ImageDescriptor INFO_DECORATION_ICON;\r
+ public static ImageDescriptor NOTE_DECORATION_ICON;\r
+\r
+ @Override\r
+ public void start(BundleContext context) throws Exception {\r
+ super.start(context);\r
+ instance = this;\r
+ messageScheme = new ServiceTracker(context, IMessageSchemeManager.class.getName(), null);\r
+\r
+ Bundle bundle = context.getBundle();\r
+\r
+ HIDE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/hide.png"));\r
+ UNHIDE_ICON = AlphaAdjustmentImageDescriptor.adjustAlpha(HSVAdjustmentImageDescriptor.adjust(\r
+ HIDE_ICON, 0f, 0f, 1f), 96);\r
+ //RESOLVE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/lightbulb.png"));\r
+ //UNRESOLVE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/lightbulb_off.png"));\r
+ RESOLVE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tick.png"));\r
+ UNRESOLVE_ICON = AlphaAdjustmentImageDescriptor.adjustAlpha(HSVAdjustmentImageDescriptor.adjust(\r
+ RESOLVE_ICON, 0f, 0f, 1f), 96);\r
+\r
+ PURGE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/purge.gif"));\r
+\r
+ FATAL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/fatal.png"));\r
+ ERROR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/error.png"));\r
+ WARNING_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/warning.png"));\r
+ INFO_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/information.png"));\r
+ NOTE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/note.png"));\r
+ OK_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/noissue.png"));\r
+\r
+ FATAL_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/fatal_decoration.png"));\r
+ ERROR_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/error_decoration.png"));\r
+ WARNING_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/warning_decoration.png"));\r
+ INFO_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/information_decoration.png"));\r
+ NOTE_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/note_decoration.png"));\r
+ }\r
+\r
+ @Override\r
+ protected ImageRegistry createImageRegistry() {\r
+ return super.createImageRegistry();\r
+ }\r
+\r
+ @Override\r
+ protected void initializeImageRegistry(ImageRegistry reg) {\r
+ reg.put(Severity.FATAL.toString()+"-full", FATAL_ICON);\r
+ reg.put(Severity.ERROR.toString()+"-full", ERROR_ICON);\r
+ reg.put(Severity.WARNING.toString()+"-full", WARNING_ICON);\r
+ reg.put(Severity.INFO.toString()+"-full", INFO_ICON);\r
+ reg.put(Severity.NOTE.toString()+"-full", NOTE_ICON);\r
+ reg.put(Severity.FATAL.toString(), FATAL_DECORATION_ICON);\r
+ reg.put(Severity.ERROR.toString(), ERROR_DECORATION_ICON);\r
+ reg.put(Severity.WARNING.toString(), WARNING_DECORATION_ICON);\r
+ reg.put(Severity.INFO.toString(), INFO_DECORATION_ICON);\r
+ reg.put(Severity.NOTE.toString(), NOTE_DECORATION_ICON);\r
+ }\r
+\r
+ @Override\r
+ public void stop(BundleContext context) throws Exception {\r
+ messageScheme.close();\r
+ instance = null;\r
+ super.stop(context);\r
+ }\r
+\r
+ /**\r
+ * Returns the shared instance\r
+ *\r
+ * @return the shared instance\r
+ */\r
+ public static Activator getDefault() {\r
+ return instance;\r
+ }\r
+\r
+ public static ImageDescriptor getImageDescriptor(String path) {\r
+ return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);\r
+ }\r
+\r
+ public static URL getDefaultResource(String name) {\r
+ Activator plugin = getDefault();\r
+ if(plugin == null) throw new IllegalStateException("The plugin is not active.");\r
+ Bundle bundle = plugin.getBundle(); \r
+ return bundle.getResource(name);\r
+ }\r
+\r
+}\r