]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/Activator.java
View for used SCL expressions
[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";
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         this.context = context;
102
103         Bundle bundle = context.getBundle();
104
105         DOCUMENT_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/Gnome-mime-document.svg"));
106         FATAL_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/fatal.svg"));
107         ERROR_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/error.svg"));
108         WARNING_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/warning.svg"));
109         INFO_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/info.svg"));
110         NOTE_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/note4.svg"));
111
112         BULLET_GREEN_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_green.png"));
113         BULLET_YELLOW_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_yellow.png"));
114
115         MODEL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_organisation.png"));
116         COMPONENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/brick.png"));
117         COMPONENT_TYPE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/box.png"));
118         COMPOSITE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bricks.png"));
119         INTERFACE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/application_view_list.png"));
120         CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/connection.png"));
121         CONNECTION_PROPERTY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table_relationship.png"));
122         OPEN_CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/open_connection.png"));
123         VARIABLE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/variable.png"));
124
125         ARROW_LEFT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_left.png"));
126         ARROW_RIGHT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_right.png"));
127
128         SYMBOL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/photo.png"));
129
130         EXPERIMENTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));
131         ATTACHED_EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time_attach.png"));
132         EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time.png"));
133         EXPERIMENT_RESULT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar.png"));
134         EXPERIMENT_RESULT_TRANSIENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar_light.png"));
135
136         QUERY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/report.png"));
137
138         STATES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_tag_red.png"));
139         STATE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_red.png"));
140
141         TRENDS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));
142         TREND_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png"));
143
144         CHARTGROUP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_group2.png"));
145         CHARTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));
146         CHART_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png"));
147         PLOT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png"));
148
149         SPREADSHEET_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table.png"));
150         SPREADSHEETS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_table.png"));
151
152         SUBSCRIPTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription.png"));
153         SUBSCRIPTION_DISABLED_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription_disabled.png"));
154         SUBSCRIPTIONS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscriptions.png"));
155         SUBSCRIPTION_ITEM_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png"));
156
157         IMAGE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/image.png"));
158         IMAGES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/images.png"));
159
160         SEGMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/segment_edit.gif"));
161
162         TICK_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tick.png"));
163         CROSS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/silk/cross.png"));
164         STOP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/stop_red.png"));
165         ARROW_IN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_in.png");
166         ARROW_UP_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_up.png");
167         ARROW_DOWN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_down.png");
168         SHOW_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/show-profile-monitors.png"));
169         HIDE_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/hide-profile-monitors.png"));
170
171         POINTER_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/pointertool.png"));
172         CONNECT_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/connecttool.png"));
173         
174         ARROW_REFRESH = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_refresh.png"));
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                     
184                     @Override
185                     public void finishedExecution() {
186                     }
187                     
188                     @Override
189                     public void consoleIsNotEmptyAnymore() {
190                     }
191                 }, properties);
192         
193         context.registerService(ImportModulesAction.class, OntologyImportModulesAction.INSTANCE,
194                 properties);
195         context.registerService(ImportModulesAction.class, SCLModulesImportModulesAction.INSTANCE,
196                 properties);
197     }
198
199     @Override
200     protected void initializeImageRegistry(ImageRegistry reg) {
201         reg.put("tick", TICK_ICON);
202         reg.put("cross", CROSS_ICON);
203         reg.put("stop", STOP_ICON);
204         reg.put("arrowIn", ARROW_IN_ICON);
205         reg.put("arrowUp", ARROW_UP_ICON);
206         reg.put("arrowDown", ARROW_DOWN_ICON);
207         reg.put("showProfileMonitors", SHOW_PROFILE_MONITOR_ICON);
208         reg.put("hideProfileMonitors", HIDE_PROFILE_MONITOR_ICON);
209         reg.put("arrow_refresh", ARROW_REFRESH);
210     }
211
212     /*
213      * (non-Javadoc)
214      * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
215      */
216     @Override
217     public void stop(BundleContext context) throws Exception {
218         plugin = null;
219         super.stop(context);
220     }
221
222     /**
223      * Returns the shared instance
224      *
225      * @return the shared instance
226      */
227     public static Activator getDefault() {
228         return plugin;
229     }
230     
231     public static BundleContext getContext() {
232         return context;
233     }
234
235 }