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