]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/Activator.java
Configurable connection crossing styles
[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 CHANGED_DECORATOR_ICON;
45
46     public static ImageDescriptor BULLET_GREEN_ICON;
47     public static ImageDescriptor BULLET_YELLOW_ICON;
48
49     public static ImageDescriptor MODEL_ICON;
50     public static ImageDescriptor COMPONENT_ICON;
51     public static ImageDescriptor COMPONENT_TYPE_ICON;
52     public static ImageDescriptor COMPOSITE_ICON;
53     public static ImageDescriptor INTERFACE_ICON;
54     public static ImageDescriptor VARIABLE_ICON;
55     public static ImageDescriptor CONNECTION_ICON;
56     public static ImageDescriptor CONNECTION_PROPERTY_ICON;
57     public static ImageDescriptor OPEN_CONNECTION_ICON;
58     public static ImageDescriptor ARROW_LEFT_ICON;
59     public static ImageDescriptor ARROW_RIGHT_ICON;
60     public static ImageDescriptor SYMBOL_ICON;
61     public static ImageDescriptor EXPERIMENTS_ICON;
62     public static ImageDescriptor STATES_ICON;
63     public static ImageDescriptor QUERY_ICON;
64     public static ImageDescriptor EXPERIMENT_ICON;
65     public static ImageDescriptor EXPERIMENT_RESULT_ICON;
66     public static ImageDescriptor EXPERIMENT_RESULT_TRANSIENT_ICON;
67     public static ImageDescriptor ATTACHED_EXPERIMENT_ICON;
68     public static ImageDescriptor STATE_ICON;
69     public static ImageDescriptor TRENDS_ICON;
70     public static ImageDescriptor TREND_ICON;
71     public static ImageDescriptor CHARTGROUP_ICON;
72     public static ImageDescriptor CHART_ICON;
73     public static ImageDescriptor CHARTS_ICON;
74     public static ImageDescriptor SPREADSHEET_ICON;
75     public static ImageDescriptor SPREADSHEETS_ICON;
76     public static ImageDescriptor SUBSCRIPTION_ICON;
77     public static ImageDescriptor SUBSCRIPTION_DISABLED_ICON;
78     public static ImageDescriptor SUBSCRIPTION_ITEM_ICON;
79     public static ImageDescriptor SUBSCRIPTIONS_ICON;
80     public static ImageDescriptor IMAGE_ICON;
81     public static ImageDescriptor IMAGES_ICON;
82     public static ImageDescriptor PLOT_ICON;
83     public static ImageDescriptor SEGMENT_ICON;
84
85     public static ImageDescriptor TICK_ICON;
86     public static ImageDescriptor CROSS_ICON;
87     public static ImageDescriptor STOP_ICON;
88     public static ImageDescriptor ARROW_IN_ICON;
89     public static ImageDescriptor ARROW_UP_ICON;
90     public static ImageDescriptor ARROW_DOWN_ICON;
91     public static ImageDescriptor SHOW_PROFILE_MONITOR_ICON;
92     public static ImageDescriptor HIDE_PROFILE_MONITOR_ICON;
93
94     public static ImageDescriptor POINTER_MODE;
95     public static ImageDescriptor CONNECT_MODE;
96
97     public static ImageDescriptor ARROW_REFRESH;
98
99     @Override
100     public void start(BundleContext context) throws Exception {
101         super.start(context);
102         plugin = this;
103         Activator.context = context;
104
105         Bundle bundle = context.getBundle();
106
107         DOCUMENT_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/Gnome-mime-document.svg")); //$NON-NLS-1$
108         FATAL_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/fatal.svg")); //$NON-NLS-1$
109         ERROR_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/error.svg")); //$NON-NLS-1$
110         WARNING_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/warning.svg")); //$NON-NLS-1$
111         INFO_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/info.svg")); //$NON-NLS-1$
112         NOTE_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/note4.svg")); //$NON-NLS-1$
113
114         CHANGED_DECORATOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/changed_decorator.png")); //$NON-NLS-1$
115
116         BULLET_GREEN_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_green.png")); //$NON-NLS-1$
117         BULLET_YELLOW_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_yellow.png")); //$NON-NLS-1$
118
119         MODEL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_organisation.png")); //$NON-NLS-1$
120         COMPONENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/brick.png")); //$NON-NLS-1$
121         COMPONENT_TYPE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/box.png")); //$NON-NLS-1$
122         COMPOSITE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bricks.png")); //$NON-NLS-1$
123         INTERFACE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/application_view_list.png")); //$NON-NLS-1$
124         CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/connection.png")); //$NON-NLS-1$
125         CONNECTION_PROPERTY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table_relationship.png")); //$NON-NLS-1$
126         OPEN_CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/open_connection.png")); //$NON-NLS-1$
127         VARIABLE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/variable.png")); //$NON-NLS-1$
128
129         ARROW_LEFT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_left.png")); //$NON-NLS-1$
130         ARROW_RIGHT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_right.png")); //$NON-NLS-1$
131
132         SYMBOL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/photo.png")); //$NON-NLS-1$
133
134         EXPERIMENTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png")); //$NON-NLS-1$
135         ATTACHED_EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time_attach.png")); //$NON-NLS-1$
136         EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time.png")); //$NON-NLS-1$
137         EXPERIMENT_RESULT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar.png")); //$NON-NLS-1$
138         EXPERIMENT_RESULT_TRANSIENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar_light.png")); //$NON-NLS-1$
139
140         QUERY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/report.png")); //$NON-NLS-1$
141
142         STATES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_tag_red.png")); //$NON-NLS-1$
143         STATE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_red.png")); //$NON-NLS-1$
144
145         TRENDS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png")); //$NON-NLS-1$
146         TREND_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png")); //$NON-NLS-1$
147
148         CHARTGROUP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_group2.png")); //$NON-NLS-1$
149         CHARTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png")); //$NON-NLS-1$
150         CHART_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png")); //$NON-NLS-1$
151         PLOT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png")); //$NON-NLS-1$
152
153         SPREADSHEET_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table.png")); //$NON-NLS-1$
154         SPREADSHEETS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_table.png")); //$NON-NLS-1$
155
156         SUBSCRIPTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription.png")); //$NON-NLS-1$
157         SUBSCRIPTION_DISABLED_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription_disabled.png")); //$NON-NLS-1$
158         SUBSCRIPTIONS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscriptions.png")); //$NON-NLS-1$
159         SUBSCRIPTION_ITEM_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png")); //$NON-NLS-1$
160
161         IMAGE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/image.png")); //$NON-NLS-1$
162         IMAGES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/images.png")); //$NON-NLS-1$
163
164         SEGMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/segment_edit.gif")); //$NON-NLS-1$
165
166         TICK_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tick.png")); //$NON-NLS-1$
167         CROSS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/silk/cross.png")); //$NON-NLS-1$
168         STOP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/stop_red.png")); //$NON-NLS-1$
169         ARROW_IN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_in.png"); //$NON-NLS-1$ //$NON-NLS-2$
170         ARROW_UP_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_up.png"); //$NON-NLS-1$ //$NON-NLS-2$
171         ARROW_DOWN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_down.png"); //$NON-NLS-1$ //$NON-NLS-2$
172         SHOW_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/show-profile-monitors.png")); //$NON-NLS-1$
173         HIDE_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/hide-profile-monitors.png")); //$NON-NLS-1$
174
175         POINTER_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/pointertool.png")); //$NON-NLS-1$
176         CONNECT_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/connecttool.png")); //$NON-NLS-1$
177         
178         ARROW_REFRESH = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_refresh.png")); //$NON-NLS-1$
179         
180         Hashtable<String, String> properties = new Hashtable<String, String>();
181         context.registerService(SCLConsoleListener.class,
182                 new SCLConsoleListener() {
183                     @Override
184                     public void startedExecution() {
185                         Simantics.getSession().markUndoPoint();
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); //$NON-NLS-1$
198         reg.put("cross", CROSS_ICON); //$NON-NLS-1$
199         reg.put("stop", STOP_ICON); //$NON-NLS-1$
200         reg.put("arrowIn", ARROW_IN_ICON); //$NON-NLS-1$
201         reg.put("arrowUp", ARROW_UP_ICON); //$NON-NLS-1$
202         reg.put("arrowDown", ARROW_DOWN_ICON); //$NON-NLS-1$
203         reg.put("showProfileMonitors", SHOW_PROFILE_MONITOR_ICON); //$NON-NLS-1$
204         reg.put("hideProfileMonitors", HIDE_PROFILE_MONITOR_ICON); //$NON-NLS-1$
205         reg.put("arrow_refresh", ARROW_REFRESH); //$NON-NLS-1$
206     }
207
208     /*
209      * (non-Javadoc)
210      * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
211      */
212     @Override
213     public void stop(BundleContext context) throws Exception {
214         plugin = null;
215         super.stop(context);
216     }
217
218     /**
219      * Returns the shared instance
220      *
221      * @return the shared instance
222      */
223     public static Activator getDefault() {
224         return plugin;
225     }
226     
227     public static BundleContext getContext() {
228         return context;
229     }
230
231 }