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