]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/Activator.java
565c30895da465eec60cfbaf72298d312ee77b4f
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / Activator.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.modeling.ui;
13
14 import java.util.Hashtable;
15
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.jface.resource.ImageRegistry;
18 import org.eclipse.ui.plugin.AbstractUIPlugin;
19 import org.osgi.framework.Bundle;
20 import org.osgi.framework.BundleContext;
21 import org.simantics.Simantics;
22 import org.simantics.modeling.ui.scl.imports.OntologyImportModulesAction;
23 import org.simantics.modeling.ui.scl.imports.SCLModulesImportModulesAction;
24 import org.simantics.scl.compiler.commands.SCLConsoleListener;
25 import org.simantics.scl.ui.imports.ImportModulesAction;
26 import org.simantics.utils.FileUtils;
27 import org.simantics.utils.ui.BundleUtils;
28
29 public class Activator extends AbstractUIPlugin {
30
31     public static final String PLUGIN_ID = "org.simantics.modeling.ui"; //$NON-NLS-1$
32
33     // The shared instance
34     private static Activator plugin;
35     private static BundleContext context;
36
37     public static String          DOCUMENT_SVG_TEXT;
38     public static String          FATAL_SVG_TEXT;
39     public static String          ERROR_SVG_TEXT;
40     public static String          WARNING_SVG_TEXT;
41     public static String          INFO_SVG_TEXT;
42     public static String          NOTE_SVG_TEXT;
43     
44     public static ImageDescriptor BULLET_GREEN_ICON;
45     public static ImageDescriptor BULLET_YELLOW_ICON;
46
47     public static ImageDescriptor MODEL_ICON;
48     public static ImageDescriptor COMPONENT_ICON;
49     public static ImageDescriptor COMPONENT_TYPE_ICON;
50     public static ImageDescriptor COMPOSITE_ICON;
51     public static ImageDescriptor INTERFACE_ICON;
52     public static ImageDescriptor VARIABLE_ICON;
53     public static ImageDescriptor CONNECTION_ICON;
54     public static ImageDescriptor CONNECTION_PROPERTY_ICON;
55     public static ImageDescriptor OPEN_CONNECTION_ICON;
56     public static ImageDescriptor ARROW_LEFT_ICON;
57     public static ImageDescriptor ARROW_RIGHT_ICON;
58     public static ImageDescriptor SYMBOL_ICON;
59     public static ImageDescriptor EXPERIMENTS_ICON;
60     public static ImageDescriptor STATES_ICON;
61     public static ImageDescriptor QUERY_ICON;
62     public static ImageDescriptor EXPERIMENT_ICON;
63     public static ImageDescriptor EXPERIMENT_RESULT_ICON;
64     public static ImageDescriptor EXPERIMENT_RESULT_TRANSIENT_ICON;
65     public static ImageDescriptor ATTACHED_EXPERIMENT_ICON;
66     public static ImageDescriptor STATE_ICON;
67     public static ImageDescriptor TRENDS_ICON;
68     public static ImageDescriptor TREND_ICON;
69     public static ImageDescriptor CHARTGROUP_ICON;
70     public static ImageDescriptor CHART_ICON;
71     public static ImageDescriptor CHARTS_ICON;
72     public static ImageDescriptor SPREADSHEET_ICON;
73     public static ImageDescriptor SPREADSHEETS_ICON;
74     public static ImageDescriptor SUBSCRIPTION_ICON;
75     public static ImageDescriptor SUBSCRIPTION_DISABLED_ICON;
76     public static ImageDescriptor SUBSCRIPTION_ITEM_ICON;
77     public static ImageDescriptor SUBSCRIPTIONS_ICON;
78     public static ImageDescriptor IMAGE_ICON;
79     public static ImageDescriptor IMAGES_ICON;
80     public static ImageDescriptor PLOT_ICON;
81     public static ImageDescriptor SEGMENT_ICON;
82
83     public static ImageDescriptor TICK_ICON;
84     public static ImageDescriptor CROSS_ICON;
85     public static ImageDescriptor STOP_ICON;
86     public static ImageDescriptor ARROW_IN_ICON;
87     public static ImageDescriptor ARROW_UP_ICON;
88     public static ImageDescriptor ARROW_DOWN_ICON;
89     public static ImageDescriptor SHOW_PROFILE_MONITOR_ICON;
90     public static ImageDescriptor HIDE_PROFILE_MONITOR_ICON;
91
92     public static ImageDescriptor POINTER_MODE;
93     public static ImageDescriptor CONNECT_MODE;
94
95     public static ImageDescriptor ARROW_REFRESH;
96
97     @Override
98     public void start(BundleContext context) throws Exception {
99         super.start(context);
100         plugin = this;
101         Activator.context = context;
102
103         Bundle bundle = context.getBundle();
104
105         DOCUMENT_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/Gnome-mime-document.svg")); //$NON-NLS-1$
106         FATAL_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/fatal.svg")); //$NON-NLS-1$
107         ERROR_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/error.svg")); //$NON-NLS-1$
108         WARNING_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/warning.svg")); //$NON-NLS-1$
109         INFO_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/info.svg")); //$NON-NLS-1$
110         NOTE_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/note4.svg")); //$NON-NLS-1$
111
112         BULLET_GREEN_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_green.png")); //$NON-NLS-1$
113         BULLET_YELLOW_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_yellow.png")); //$NON-NLS-1$
114
115         MODEL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_organisation.png")); //$NON-NLS-1$
116         COMPONENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/brick.png")); //$NON-NLS-1$
117         COMPONENT_TYPE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/box.png")); //$NON-NLS-1$
118         COMPOSITE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bricks.png")); //$NON-NLS-1$
119         INTERFACE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/application_view_list.png")); //$NON-NLS-1$
120         CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/connection.png")); //$NON-NLS-1$
121         CONNECTION_PROPERTY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table_relationship.png")); //$NON-NLS-1$
122         OPEN_CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/open_connection.png")); //$NON-NLS-1$
123         VARIABLE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/variable.png")); //$NON-NLS-1$
124
125         ARROW_LEFT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_left.png")); //$NON-NLS-1$
126         ARROW_RIGHT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_right.png")); //$NON-NLS-1$
127
128         SYMBOL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/photo.png")); //$NON-NLS-1$
129
130         EXPERIMENTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png")); //$NON-NLS-1$
131         ATTACHED_EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time_attach.png")); //$NON-NLS-1$
132         EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time.png")); //$NON-NLS-1$
133         EXPERIMENT_RESULT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar.png")); //$NON-NLS-1$
134         EXPERIMENT_RESULT_TRANSIENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar_light.png")); //$NON-NLS-1$
135
136         QUERY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/report.png")); //$NON-NLS-1$
137
138         STATES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_tag_red.png")); //$NON-NLS-1$
139         STATE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_red.png")); //$NON-NLS-1$
140
141         TRENDS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png")); //$NON-NLS-1$
142         TREND_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png")); //$NON-NLS-1$
143
144         CHARTGROUP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_group2.png")); //$NON-NLS-1$
145         CHARTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png")); //$NON-NLS-1$
146         CHART_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png")); //$NON-NLS-1$
147         PLOT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png")); //$NON-NLS-1$
148
149         SPREADSHEET_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table.png")); //$NON-NLS-1$
150         SPREADSHEETS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_table.png")); //$NON-NLS-1$
151
152         SUBSCRIPTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription.png")); //$NON-NLS-1$
153         SUBSCRIPTION_DISABLED_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription_disabled.png")); //$NON-NLS-1$
154         SUBSCRIPTIONS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscriptions.png")); //$NON-NLS-1$
155         SUBSCRIPTION_ITEM_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png")); //$NON-NLS-1$
156
157         IMAGE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/image.png")); //$NON-NLS-1$
158         IMAGES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/images.png")); //$NON-NLS-1$
159
160         SEGMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/segment_edit.gif")); //$NON-NLS-1$
161
162         TICK_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tick.png")); //$NON-NLS-1$
163         CROSS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/silk/cross.png")); //$NON-NLS-1$
164         STOP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/stop_red.png")); //$NON-NLS-1$
165         ARROW_IN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_in.png"); //$NON-NLS-1$ //$NON-NLS-2$
166         ARROW_UP_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_up.png"); //$NON-NLS-1$ //$NON-NLS-2$
167         ARROW_DOWN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_down.png"); //$NON-NLS-1$ //$NON-NLS-2$
168         SHOW_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/show-profile-monitors.png")); //$NON-NLS-1$
169         HIDE_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/hide-profile-monitors.png")); //$NON-NLS-1$
170
171         POINTER_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/pointertool.png")); //$NON-NLS-1$
172         CONNECT_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/connecttool.png")); //$NON-NLS-1$
173         
174         ARROW_REFRESH = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_refresh.png")); //$NON-NLS-1$
175         
176         Hashtable<String, String> properties = new Hashtable<String, String>();
177         context.registerService(SCLConsoleListener.class,
178                 new SCLConsoleListener() {
179                     @Override
180                     public void startedExecution() {
181                         Simantics.getSession().markUndoPoint();
182                     }
183                 }, properties);
184         
185         context.registerService(ImportModulesAction.class, OntologyImportModulesAction.INSTANCE,
186                 properties);
187         context.registerService(ImportModulesAction.class, SCLModulesImportModulesAction.INSTANCE,
188                 properties);
189     }
190
191     @Override
192     protected void initializeImageRegistry(ImageRegistry reg) {
193         reg.put("tick", TICK_ICON); //$NON-NLS-1$
194         reg.put("cross", CROSS_ICON); //$NON-NLS-1$
195         reg.put("stop", STOP_ICON); //$NON-NLS-1$
196         reg.put("arrowIn", ARROW_IN_ICON); //$NON-NLS-1$
197         reg.put("arrowUp", ARROW_UP_ICON); //$NON-NLS-1$
198         reg.put("arrowDown", ARROW_DOWN_ICON); //$NON-NLS-1$
199         reg.put("showProfileMonitors", SHOW_PROFILE_MONITOR_ICON); //$NON-NLS-1$
200         reg.put("hideProfileMonitors", HIDE_PROFILE_MONITOR_ICON); //$NON-NLS-1$
201         reg.put("arrow_refresh", ARROW_REFRESH); //$NON-NLS-1$
202     }
203
204     /*
205      * (non-Javadoc)
206      * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
207      */
208     @Override
209     public void stop(BundleContext context) throws Exception {
210         plugin = null;
211         super.stop(context);
212     }
213
214     /**
215      * Returns the shared instance
216      *
217      * @return the shared instance
218      */
219     public static Activator getDefault() {
220         return plugin;
221     }
222     
223     public static BundleContext getContext() {
224         return context;
225     }
226
227 }