1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 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.modeling.ui;
\r
14 import java.util.Hashtable;
\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.simantics.Simantics;
\r
22 import org.simantics.modeling.ui.scl.imports.OntologyImportModulesAction;
\r
23 import org.simantics.modeling.ui.scl.imports.SCLModulesImportModulesAction;
\r
24 import org.simantics.scl.compiler.commands.SCLConsoleListener;
\r
25 import org.simantics.scl.ui.imports.ImportModulesAction;
\r
26 import org.simantics.utils.FileUtils;
\r
27 import org.simantics.utils.ui.BundleUtils;
\r
29 public class Activator extends AbstractUIPlugin {
\r
31 public static final String PLUGIN_ID = "org.simantics.modeling.ui";
\r
33 // The shared instance
\r
34 private static Activator plugin;
\r
35 private static BundleContext context;
\r
37 public static String DOCUMENT_SVG_TEXT;
\r
38 public static String FATAL_SVG_TEXT;
\r
39 public static String ERROR_SVG_TEXT;
\r
40 public static String WARNING_SVG_TEXT;
\r
41 public static String INFO_SVG_TEXT;
\r
42 public static String NOTE_SVG_TEXT;
\r
44 public static ImageDescriptor BULLET_GREEN_ICON;
\r
45 public static ImageDescriptor BULLET_YELLOW_ICON;
\r
47 public static ImageDescriptor MODEL_ICON;
\r
48 public static ImageDescriptor COMPONENT_ICON;
\r
49 public static ImageDescriptor COMPONENT_TYPE_ICON;
\r
50 public static ImageDescriptor COMPOSITE_ICON;
\r
51 public static ImageDescriptor INTERFACE_ICON;
\r
52 public static ImageDescriptor VARIABLE_ICON;
\r
53 public static ImageDescriptor CONNECTION_ICON;
\r
54 public static ImageDescriptor CONNECTION_PROPERTY_ICON;
\r
55 public static ImageDescriptor OPEN_CONNECTION_ICON;
\r
56 public static ImageDescriptor ARROW_LEFT_ICON;
\r
57 public static ImageDescriptor ARROW_RIGHT_ICON;
\r
58 public static ImageDescriptor SYMBOL_ICON;
\r
59 public static ImageDescriptor EXPERIMENTS_ICON;
\r
60 public static ImageDescriptor STATES_ICON;
\r
61 public static ImageDescriptor QUERY_ICON;
\r
62 public static ImageDescriptor EXPERIMENT_ICON;
\r
63 public static ImageDescriptor EXPERIMENT_RESULT_ICON;
\r
64 public static ImageDescriptor EXPERIMENT_RESULT_TRANSIENT_ICON;
\r
65 public static ImageDescriptor ATTACHED_EXPERIMENT_ICON;
\r
66 public static ImageDescriptor STATE_ICON;
\r
67 public static ImageDescriptor TRENDS_ICON;
\r
68 public static ImageDescriptor TREND_ICON;
\r
69 public static ImageDescriptor CHARTGROUP_ICON;
\r
70 public static ImageDescriptor CHART_ICON;
\r
71 public static ImageDescriptor CHARTS_ICON;
\r
72 public static ImageDescriptor SPREADSHEET_ICON;
\r
73 public static ImageDescriptor SPREADSHEETS_ICON;
\r
74 public static ImageDescriptor SUBSCRIPTION_ICON;
\r
75 public static ImageDescriptor SUBSCRIPTION_DISABLED_ICON;
\r
76 public static ImageDescriptor SUBSCRIPTION_ITEM_ICON;
\r
77 public static ImageDescriptor SUBSCRIPTIONS_ICON;
\r
78 public static ImageDescriptor IMAGE_ICON;
\r
79 public static ImageDescriptor IMAGES_ICON;
\r
80 public static ImageDescriptor PLOT_ICON;
\r
81 public static ImageDescriptor SEGMENT_ICON;
\r
83 public static ImageDescriptor TICK_ICON;
\r
84 public static ImageDescriptor CROSS_ICON;
\r
85 public static ImageDescriptor STOP_ICON;
\r
86 public static ImageDescriptor ARROW_IN_ICON;
\r
87 public static ImageDescriptor ARROW_UP_ICON;
\r
88 public static ImageDescriptor ARROW_DOWN_ICON;
\r
89 public static ImageDescriptor SHOW_PROFILE_MONITOR_ICON;
\r
90 public static ImageDescriptor HIDE_PROFILE_MONITOR_ICON;
\r
92 public static ImageDescriptor POINTER_MODE;
\r
93 public static ImageDescriptor CONNECT_MODE;
\r
96 public void start(BundleContext context) throws Exception {
\r
97 super.start(context);
\r
99 this.context = context;
\r
101 Bundle bundle = context.getBundle();
\r
103 DOCUMENT_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/Gnome-mime-document.svg"));
\r
104 FATAL_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/fatal.svg"));
\r
105 ERROR_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/error.svg"));
\r
106 WARNING_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/warning.svg"));
\r
107 INFO_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/info.svg"));
\r
108 NOTE_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/note4.svg"));
\r
110 BULLET_GREEN_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_green.png"));
\r
111 BULLET_YELLOW_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_yellow.png"));
\r
113 MODEL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_organisation.png"));
\r
114 COMPONENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/brick.png"));
\r
115 COMPONENT_TYPE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/box.png"));
\r
116 COMPOSITE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bricks.png"));
\r
117 INTERFACE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/application_view_list.png"));
\r
118 CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/connection.png"));
\r
119 CONNECTION_PROPERTY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table_relationship.png"));
\r
120 OPEN_CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/open_connection.png"));
\r
121 VARIABLE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/variable.png"));
\r
123 ARROW_LEFT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_left.png"));
\r
124 ARROW_RIGHT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_right.png"));
\r
126 SYMBOL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/photo.png"));
\r
128 EXPERIMENTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));
\r
129 ATTACHED_EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time_attach.png"));
\r
130 EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time.png"));
\r
131 EXPERIMENT_RESULT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar.png"));
\r
132 EXPERIMENT_RESULT_TRANSIENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar_light.png"));
\r
134 QUERY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/report.png"));
\r
136 STATES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_tag_red.png"));
\r
137 STATE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_red.png"));
\r
139 TRENDS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));
\r
140 TREND_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png"));
\r
142 CHARTGROUP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_group2.png"));
\r
143 CHARTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));
\r
144 CHART_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png"));
\r
145 PLOT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png"));
\r
147 SPREADSHEET_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table.png"));
\r
148 SPREADSHEETS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_table.png"));
\r
150 SUBSCRIPTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription.png"));
\r
151 SUBSCRIPTION_DISABLED_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription_disabled.png"));
\r
152 SUBSCRIPTIONS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscriptions.png"));
\r
153 SUBSCRIPTION_ITEM_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png"));
\r
155 IMAGE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/image.png"));
\r
156 IMAGES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/images.png"));
\r
158 SEGMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/segment_edit.gif"));
\r
160 TICK_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tick.png"));
\r
161 CROSS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/silk/cross.png"));
\r
162 STOP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/stop_red.png"));
\r
163 ARROW_IN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_in.png");
\r
164 ARROW_UP_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_up.png");
\r
165 ARROW_DOWN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_down.png");
\r
166 SHOW_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/show-profile-monitors.png"));
\r
167 HIDE_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/hide-profile-monitors.png"));
\r
169 POINTER_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/pointertool.png"));
\r
170 CONNECT_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/connecttool.png"));
\r
172 Hashtable<String, String> properties = new Hashtable<String, String>();
\r
173 context.registerService(SCLConsoleListener.class,
\r
174 new SCLConsoleListener() {
\r
176 public void startedExecution() {
\r
177 Simantics.getSession().markUndoPoint();
\r
181 public void finishedExecution() {
\r
185 public void consoleIsNotEmptyAnymore() {
\r
189 context.registerService(ImportModulesAction.class, OntologyImportModulesAction.INSTANCE,
\r
191 context.registerService(ImportModulesAction.class, SCLModulesImportModulesAction.INSTANCE,
\r
196 protected void initializeImageRegistry(ImageRegistry reg) {
\r
197 reg.put("tick", TICK_ICON);
\r
198 reg.put("cross", CROSS_ICON);
\r
199 reg.put("stop", STOP_ICON);
\r
200 reg.put("arrowIn", ARROW_IN_ICON);
\r
201 reg.put("arrowUp", ARROW_UP_ICON);
\r
202 reg.put("arrowDown", ARROW_DOWN_ICON);
\r
203 reg.put("showProfileMonitors", SHOW_PROFILE_MONITOR_ICON);
\r
204 reg.put("hideProfileMonitors", HIDE_PROFILE_MONITOR_ICON);
\r
209 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
\r
212 public void stop(BundleContext context) throws Exception {
\r
214 super.stop(context);
\r
218 * Returns the shared instance
\r
220 * @return the shared instance
\r
222 public static Activator getDefault() {
\r
226 public static BundleContext getContext() {
\r