1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.issues.ui.internal;
\r
14 import java.net.URL;
\r
16 import org.eclipse.jface.resource.ImageDescriptor;
\r
17 import org.eclipse.jface.resource.ImageRegistry;
\r
18 import org.eclipse.ui.plugin.AbstractUIPlugin;
\r
19 import org.osgi.framework.Bundle;
\r
20 import org.osgi.framework.BundleContext;
\r
21 import org.osgi.util.tracker.ServiceTracker;
\r
22 import org.simantics.issues.Severity;
\r
23 import org.simantics.message.IMessageSchemeManager;
\r
24 import org.simantics.utils.ui.gfx.AlphaAdjustmentImageDescriptor;
\r
25 import org.simantics.utils.ui.gfx.HSVAdjustmentImageDescriptor;
\r
27 public class Activator extends AbstractUIPlugin {
\r
29 public static final String PLUGIN_ID = "org.simantics.issues.ui";
\r
31 static Activator instance;
\r
32 ServiceTracker messageScheme;
\r
34 public static ImageDescriptor HIDE_ICON;
\r
35 public static ImageDescriptor UNHIDE_ICON;
\r
36 public static ImageDescriptor RESOLVE_ICON;
\r
37 public static ImageDescriptor UNRESOLVE_ICON;
\r
39 public static ImageDescriptor PURGE_ICON;
\r
41 public static ImageDescriptor FATAL_ICON;
\r
42 public static ImageDescriptor ERROR_ICON;
\r
43 public static ImageDescriptor WARNING_ICON;
\r
44 public static ImageDescriptor INFO_ICON;
\r
45 public static ImageDescriptor NOTE_ICON;
\r
46 public static ImageDescriptor OK_ICON;
\r
48 public static ImageDescriptor FATAL_DECORATION_ICON;
\r
49 public static ImageDescriptor ERROR_DECORATION_ICON;
\r
50 public static ImageDescriptor WARNING_DECORATION_ICON;
\r
51 public static ImageDescriptor INFO_DECORATION_ICON;
\r
52 public static ImageDescriptor NOTE_DECORATION_ICON;
\r
55 public void start(BundleContext context) throws Exception {
\r
56 super.start(context);
\r
58 messageScheme = new ServiceTracker(context, IMessageSchemeManager.class.getName(), null);
\r
60 Bundle bundle = context.getBundle();
\r
62 HIDE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/hide.png"));
\r
63 UNHIDE_ICON = AlphaAdjustmentImageDescriptor.adjustAlpha(HSVAdjustmentImageDescriptor.adjust(
\r
64 HIDE_ICON, 0f, 0f, 1f), 96);
\r
65 //RESOLVE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/lightbulb.png"));
\r
66 //UNRESOLVE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/lightbulb_off.png"));
\r
67 RESOLVE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tick.png"));
\r
68 UNRESOLVE_ICON = AlphaAdjustmentImageDescriptor.adjustAlpha(HSVAdjustmentImageDescriptor.adjust(
\r
69 RESOLVE_ICON, 0f, 0f, 1f), 96);
\r
71 PURGE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/purge.gif"));
\r
73 FATAL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/fatal.png"));
\r
74 ERROR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/error.png"));
\r
75 WARNING_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/warning.png"));
\r
76 INFO_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/information.png"));
\r
77 NOTE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/note.png"));
\r
78 OK_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/noissue.png"));
\r
80 FATAL_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/fatal_decoration.png"));
\r
81 ERROR_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/error_decoration.png"));
\r
82 WARNING_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/warning_decoration.png"));
\r
83 INFO_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/information_decoration.png"));
\r
84 NOTE_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/note_decoration.png"));
\r
88 protected ImageRegistry createImageRegistry() {
\r
89 return super.createImageRegistry();
\r
93 protected void initializeImageRegistry(ImageRegistry reg) {
\r
94 reg.put(Severity.FATAL.toString()+"-full", FATAL_ICON);
\r
95 reg.put(Severity.ERROR.toString()+"-full", ERROR_ICON);
\r
96 reg.put(Severity.WARNING.toString()+"-full", WARNING_ICON);
\r
97 reg.put(Severity.INFO.toString()+"-full", INFO_ICON);
\r
98 reg.put(Severity.NOTE.toString()+"-full", NOTE_ICON);
\r
99 reg.put(Severity.FATAL.toString(), FATAL_DECORATION_ICON);
\r
100 reg.put(Severity.ERROR.toString(), ERROR_DECORATION_ICON);
\r
101 reg.put(Severity.WARNING.toString(), WARNING_DECORATION_ICON);
\r
102 reg.put(Severity.INFO.toString(), INFO_DECORATION_ICON);
\r
103 reg.put(Severity.NOTE.toString(), NOTE_DECORATION_ICON);
\r
107 public void stop(BundleContext context) throws Exception {
\r
108 messageScheme.close();
\r
110 super.stop(context);
\r
114 * Returns the shared instance
\r
116 * @return the shared instance
\r
118 public static Activator getDefault() {
\r
122 public static ImageDescriptor getImageDescriptor(String path) {
\r
123 return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
\r
126 public static URL getDefaultResource(String name) {
\r
127 Activator plugin = getDefault();
\r
128 if(plugin == null) throw new IllegalStateException("The plugin is not active.");
\r
129 Bundle bundle = plugin.getBundle();
\r
130 return bundle.getResource(name);
\r