]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/internal/Activator.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / internal / Activator.java
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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.ui.internal;\r
13 \r
14 import org.eclipse.jface.preference.IPreferenceStore;\r
15 import org.eclipse.jface.resource.ImageDescriptor;\r
16 import org.eclipse.ui.plugin.AbstractUIPlugin;\r
17 import org.osgi.framework.BundleContext;\r
18 import org.simantics.internal.TimedSessionCache;\r
19 import org.simantics.ui.DoubleClickExtensionManager;\r
20 import org.simantics.ui.SimanticsUI;\r
21 import org.simantics.ui.workbench.PerspectiveBarsManager;\r
22 import org.simantics.ui.workbench.PerspectiveContextBindingManager;\r
23 import org.simantics.ui.workbench.editor.EditorRegistry;\r
24 import org.simantics.utils.ui.BundleUtils;\r
25 \r
26 \r
27 /**\r
28  * The activator class controls the plug-in life cycle\r
29  */\r
30 public class Activator extends AbstractUIPlugin {\r
31 \r
32     // The plug-in ID\r
33     public static final String PLUGIN_ID = SimanticsUI.PLUGIN_ID;\r
34 \r
35     // The shared instance\r
36     private static Activator plugin;\r
37     \r
38     /**\r
39      * The constructor\r
40      */\r
41     public Activator() {\r
42     }\r
43 \r
44     /*\r
45      * (non-Javadoc)\r
46      * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)\r
47      */\r
48     public void start(BundleContext context) throws Exception {\r
49         super.start(context);\r
50         plugin = this;\r
51 \r
52         TimedSessionCache.initialize(context);\r
53 \r
54         // Initialize extension managers.\r
55         // Disposed respectively in #stop().\r
56         DoubleClickExtensionManager.getInstance();\r
57         PerspectiveContextBindingManager.getInstance();\r
58         PerspectiveBarsManager.getInstance();\r
59 \r
60         // Will be started when getInstance is first invoked.\r
61         //ResourceEditorRegistry.getInstance();\r
62         \r
63         initializeDefaultPreferences(plugin.getPreferenceStore());\r
64     }\r
65 \r
66     /*\r
67      * (non-Javadoc)\r
68      * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)\r
69      */\r
70     public void stop(BundleContext context) throws Exception {\r
71         TimedSessionCache.close();\r
72 \r
73         plugin = null;\r
74 \r
75         // Dispose extension managers.\r
76         EditorRegistry.dispose();\r
77 \r
78         PerspectiveContextBindingManager.dispose();\r
79         PerspectiveBarsManager.dispose();\r
80         DoubleClickExtensionManager.dispose();\r
81 \r
82         // Backup for disposing of the UI database session\r
83         SimanticsUI.closeSessions();\r
84 \r
85         super.stop(context);\r
86     }\r
87 \r
88     /**\r
89      * Returns the shared instance\r
90      *\r
91      * @return the shared instance\r
92      */\r
93     public static Activator getDefault() {\r
94         return plugin;\r
95     }\r
96     \r
97     /**\r
98      * Returns an image descriptor for the image file at the given\r
99      * plug-in relative path.\r
100      *\r
101      * @param path the path\r
102      * @return the image descriptor\r
103      */\r
104     public static ImageDescriptor getImageDescriptor(String path) {\r
105         return BundleUtils.getImageDescriptorFromPlugin(PLUGIN_ID, path);\r
106     }\r
107     \r
108     /** \r
109      * Initializes a preference store with default preference values \r
110      * for this plug-in.\r
111      */\r
112     protected void initializeDefaultPreferences(IPreferenceStore store) {\r
113 //        store.setDefault("showRequirements", true);\r
114 //        store.setDefault("hasStructuralModelling", true);\r
115 //        store.setDefault("showPropertyTypes", true);\r
116 //        store.setDefault("showAllowedChildren", true);\r
117 //        store.setDefault("showConnectionInterface", true);\r
118 //        store.setDefault("showDataInterface", true);\r
119     }\r
120 \r
121 \r
122 }\r