1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.ui.internal;
14 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.ui.plugin.AbstractUIPlugin;
17 import org.osgi.framework.BundleContext;
18 import org.simantics.internal.TimedSessionCache;
19 import org.simantics.ui.DoubleClickExtensionManager;
20 import org.simantics.ui.SimanticsUI;
21 import org.simantics.ui.workbench.PerspectiveBarsManager;
22 import org.simantics.ui.workbench.PerspectiveContextBindingManager;
23 import org.simantics.ui.workbench.editor.EditorRegistry;
24 import org.simantics.utils.ui.BundleUtils;
28 * The activator class controls the plug-in life cycle
30 public class Activator extends AbstractUIPlugin {
33 public static final String PLUGIN_ID = SimanticsUI.PLUGIN_ID;
35 // The shared instance
36 private static Activator plugin;
46 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
48 public void start(BundleContext context) throws Exception {
52 TimedSessionCache.initialize(context);
54 // Initialize extension managers.
55 // Disposed respectively in #stop().
56 DoubleClickExtensionManager.getInstance();
57 PerspectiveContextBindingManager.getInstance();
58 PerspectiveBarsManager.getInstance();
60 // Will be started when getInstance is first invoked.
61 //ResourceEditorRegistry.getInstance();
63 initializeDefaultPreferences(plugin.getPreferenceStore());
68 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
70 public void stop(BundleContext context) throws Exception {
71 TimedSessionCache.close();
75 // Dispose extension managers.
76 EditorRegistry.dispose();
78 PerspectiveContextBindingManager.dispose();
79 PerspectiveBarsManager.dispose();
80 DoubleClickExtensionManager.dispose();
82 // Backup for disposing of the UI database session
83 SimanticsUI.closeSessions();
89 * Returns the shared instance
91 * @return the shared instance
93 public static Activator getDefault() {
98 * Returns an image descriptor for the image file at the given
99 * plug-in relative path.
101 * @param path the path
102 * @return the image descriptor
104 public static ImageDescriptor getImageDescriptor(String path) {
105 return BundleUtils.getImageDescriptorFromPlugin(PLUGIN_ID, path);
109 * Initializes a preference store with default preference values
112 protected void initializeDefaultPreferences(IPreferenceStore store) {
113 // store.setDefault("showRequirements", true);
114 // store.setDefault("hasStructuralModelling", true);
115 // store.setDefault("showPropertyTypes", true);
116 // store.setDefault("showAllowedChildren", true);
117 // store.setDefault("showConnectionInterface", true);
118 // store.setDefault("showDataInterface", true);