--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modeling.ui;\r
+\r
+import java.util.Hashtable;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.eclipse.jface.resource.ImageRegistry;\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.Bundle;\r
+import org.osgi.framework.BundleContext;\r
+import org.simantics.Simantics;\r
+import org.simantics.modeling.ui.scl.imports.OntologyImportModulesAction;\r
+import org.simantics.modeling.ui.scl.imports.SCLModulesImportModulesAction;\r
+import org.simantics.scl.compiler.commands.SCLConsoleListener;\r
+import org.simantics.scl.ui.imports.ImportModulesAction;\r
+import org.simantics.utils.FileUtils;\r
+import org.simantics.utils.ui.BundleUtils;\r
+\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+ public static final String PLUGIN_ID = "org.simantics.modeling.ui";\r
+\r
+ // The shared instance\r
+ private static Activator plugin;\r
+ private static BundleContext context;\r
+\r
+ public static String DOCUMENT_SVG_TEXT;\r
+ public static String FATAL_SVG_TEXT;\r
+ public static String ERROR_SVG_TEXT;\r
+ public static String WARNING_SVG_TEXT;\r
+ public static String INFO_SVG_TEXT;\r
+ public static String NOTE_SVG_TEXT;\r
+ \r
+ public static ImageDescriptor BULLET_GREEN_ICON;\r
+ public static ImageDescriptor BULLET_YELLOW_ICON;\r
+\r
+ public static ImageDescriptor MODEL_ICON;\r
+ public static ImageDescriptor COMPONENT_ICON;\r
+ public static ImageDescriptor COMPONENT_TYPE_ICON;\r
+ public static ImageDescriptor COMPOSITE_ICON;\r
+ public static ImageDescriptor INTERFACE_ICON;\r
+ public static ImageDescriptor VARIABLE_ICON;\r
+ public static ImageDescriptor CONNECTION_ICON;\r
+ public static ImageDescriptor CONNECTION_PROPERTY_ICON;\r
+ public static ImageDescriptor OPEN_CONNECTION_ICON;\r
+ public static ImageDescriptor ARROW_LEFT_ICON;\r
+ public static ImageDescriptor ARROW_RIGHT_ICON;\r
+ public static ImageDescriptor SYMBOL_ICON;\r
+ public static ImageDescriptor EXPERIMENTS_ICON;\r
+ public static ImageDescriptor STATES_ICON;\r
+ public static ImageDescriptor QUERY_ICON;\r
+ public static ImageDescriptor EXPERIMENT_ICON;\r
+ public static ImageDescriptor EXPERIMENT_RESULT_ICON;\r
+ public static ImageDescriptor EXPERIMENT_RESULT_TRANSIENT_ICON;\r
+ public static ImageDescriptor ATTACHED_EXPERIMENT_ICON;\r
+ public static ImageDescriptor STATE_ICON;\r
+ public static ImageDescriptor TRENDS_ICON;\r
+ public static ImageDescriptor TREND_ICON;\r
+ public static ImageDescriptor CHARTGROUP_ICON;\r
+ public static ImageDescriptor CHART_ICON;\r
+ public static ImageDescriptor CHARTS_ICON;\r
+ public static ImageDescriptor SPREADSHEET_ICON;\r
+ public static ImageDescriptor SPREADSHEETS_ICON;\r
+ public static ImageDescriptor SUBSCRIPTION_ICON;\r
+ public static ImageDescriptor SUBSCRIPTION_DISABLED_ICON;\r
+ public static ImageDescriptor SUBSCRIPTION_ITEM_ICON;\r
+ public static ImageDescriptor SUBSCRIPTIONS_ICON;\r
+ public static ImageDescriptor IMAGE_ICON;\r
+ public static ImageDescriptor IMAGES_ICON;\r
+ public static ImageDescriptor PLOT_ICON;\r
+ public static ImageDescriptor SEGMENT_ICON;\r
+\r
+ public static ImageDescriptor TICK_ICON;\r
+ public static ImageDescriptor CROSS_ICON;\r
+ public static ImageDescriptor STOP_ICON;\r
+ public static ImageDescriptor ARROW_IN_ICON;\r
+ public static ImageDescriptor ARROW_UP_ICON;\r
+ public static ImageDescriptor ARROW_DOWN_ICON;\r
+ public static ImageDescriptor SHOW_PROFILE_MONITOR_ICON;\r
+ public static ImageDescriptor HIDE_PROFILE_MONITOR_ICON;\r
+\r
+ public static ImageDescriptor POINTER_MODE;\r
+ public static ImageDescriptor CONNECT_MODE;\r
+\r
+ @Override\r
+ public void start(BundleContext context) throws Exception {\r
+ super.start(context);\r
+ plugin = this;\r
+ this.context = context;\r
+\r
+ Bundle bundle = context.getBundle();\r
+\r
+ DOCUMENT_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/Gnome-mime-document.svg"));\r
+ FATAL_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/fatal.svg"));\r
+ ERROR_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/error.svg"));\r
+ WARNING_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/warning.svg"));\r
+ INFO_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/info.svg"));\r
+ NOTE_SVG_TEXT = FileUtils.getContents(bundle.getResource("icons/note4.svg"));\r
+\r
+ BULLET_GREEN_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_green.png"));\r
+ BULLET_YELLOW_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bullet_yellow.png"));\r
+\r
+ MODEL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_organisation.png"));\r
+ COMPONENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/brick.png"));\r
+ COMPONENT_TYPE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/box.png"));\r
+ COMPOSITE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/bricks.png"));\r
+ INTERFACE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/application_view_list.png"));\r
+ CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/connection.png"));\r
+ CONNECTION_PROPERTY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table_relationship.png"));\r
+ OPEN_CONNECTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/open_connection.png"));\r
+ VARIABLE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/variable.png"));\r
+\r
+ ARROW_LEFT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_left.png"));\r
+ ARROW_RIGHT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/arrow_right.png"));\r
+\r
+ SYMBOL_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/photo.png"));\r
+\r
+ EXPERIMENTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));\r
+ ATTACHED_EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time_attach.png"));\r
+ EXPERIMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/time.png"));\r
+ EXPERIMENT_RESULT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar.png"));\r
+ EXPERIMENT_RESULT_TRANSIENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_bar_light.png"));\r
+\r
+ QUERY_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/report.png"));\r
+\r
+ STATES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_tag_red.png"));\r
+ STATE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_red.png"));\r
+\r
+ TRENDS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));\r
+ TREND_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png"));\r
+\r
+ CHARTGROUP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_group2.png"));\r
+ CHARTS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder.png"));\r
+ CHART_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/chart_line.png"));\r
+ PLOT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png"));\r
+\r
+ SPREADSHEET_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/table.png"));\r
+ SPREADSHEETS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/folder_table.png"));\r
+\r
+ SUBSCRIPTION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription.png"));\r
+ SUBSCRIPTION_DISABLED_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscription_disabled.png"));\r
+ SUBSCRIPTIONS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/subscriptions.png"));\r
+ SUBSCRIPTION_ITEM_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_blue.png"));\r
+\r
+ IMAGE_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/image.png"));\r
+ IMAGES_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/images.png"));\r
+\r
+ SEGMENT_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/segment_edit.gif"));\r
+\r
+ TICK_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/tick.png"));\r
+ CROSS_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/silk/cross.png"));\r
+ STOP_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/stop_red.png"));\r
+ ARROW_IN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_in.png");\r
+ ARROW_UP_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_up.png");\r
+ ARROW_DOWN_ICON = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/bullet_arrow_down.png");\r
+ SHOW_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/show-profile-monitors.png"));\r
+ HIDE_PROFILE_MONITOR_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/hide-profile-monitors.png"));\r
+\r
+ POINTER_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/pointertool.png"));\r
+ CONNECT_MODE = ImageDescriptor.createFromURL(bundle.getResource("icons/connecttool.png"));\r
+ \r
+ Hashtable<String, String> properties = new Hashtable<String, String>();\r
+ context.registerService(SCLConsoleListener.class,\r
+ new SCLConsoleListener() {\r
+ @Override\r
+ public void startedExecution() {\r
+ Simantics.getSession().markUndoPoint();\r
+ }\r
+ \r
+ @Override\r
+ public void finishedExecution() {\r
+ }\r
+ \r
+ @Override\r
+ public void consoleIsNotEmptyAnymore() {\r
+ }\r
+ }, properties);\r
+ \r
+ context.registerService(ImportModulesAction.class, OntologyImportModulesAction.INSTANCE,\r
+ properties);\r
+ context.registerService(ImportModulesAction.class, SCLModulesImportModulesAction.INSTANCE,\r
+ properties);\r
+ }\r
+\r
+ @Override\r
+ protected void initializeImageRegistry(ImageRegistry reg) {\r
+ reg.put("tick", TICK_ICON);\r
+ reg.put("cross", CROSS_ICON);\r
+ reg.put("stop", STOP_ICON);\r
+ reg.put("arrowIn", ARROW_IN_ICON);\r
+ reg.put("arrowUp", ARROW_UP_ICON);\r
+ reg.put("arrowDown", ARROW_DOWN_ICON);\r
+ reg.put("showProfileMonitors", SHOW_PROFILE_MONITOR_ICON);\r
+ reg.put("hideProfileMonitors", HIDE_PROFILE_MONITOR_ICON);\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
+ */\r
+ @Override\r
+ public void stop(BundleContext context) throws Exception {\r
+ plugin = null;\r
+ super.stop(context);\r
+ }\r
+\r
+ /**\r
+ * Returns the shared instance\r
+ *\r
+ * @return the shared instance\r
+ */\r
+ public static Activator getDefault() {\r
+ return plugin;\r
+ }\r
+ \r
+ public static BundleContext getContext() {\r
+ return context;\r
+ }\r
+\r
+}\r