]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/internal/Activator.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / internal / Activator.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.ui.internal;
13
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;
25
26
27 /**
28  * The activator class controls the plug-in life cycle
29  */
30 public class Activator extends AbstractUIPlugin {
31
32     // The plug-in ID
33     public static final String PLUGIN_ID = SimanticsUI.PLUGIN_ID;
34
35     // The shared instance
36     private static Activator plugin;
37     
38     /**
39      * The constructor
40      */
41     public Activator() {
42     }
43
44     /*
45      * (non-Javadoc)
46      * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
47      */
48     public void start(BundleContext context) throws Exception {
49         super.start(context);
50         plugin = this;
51
52         TimedSessionCache.initialize(context);
53
54         // Initialize extension managers.
55         // Disposed respectively in #stop().
56         DoubleClickExtensionManager.getInstance();
57         PerspectiveContextBindingManager.getInstance();
58         PerspectiveBarsManager.getInstance();
59
60         // Will be started when getInstance is first invoked.
61         //ResourceEditorRegistry.getInstance();
62         
63         initializeDefaultPreferences(plugin.getPreferenceStore());
64     }
65
66     /*
67      * (non-Javadoc)
68      * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
69      */
70     public void stop(BundleContext context) throws Exception {
71         TimedSessionCache.close();
72
73         plugin = null;
74
75         // Dispose extension managers.
76         EditorRegistry.dispose();
77
78         PerspectiveContextBindingManager.dispose();
79         PerspectiveBarsManager.dispose();
80         DoubleClickExtensionManager.dispose();
81
82         // Backup for disposing of the UI database session
83         SimanticsUI.closeSessions();
84
85         super.stop(context);
86     }
87
88     /**
89      * Returns the shared instance
90      *
91      * @return the shared instance
92      */
93     public static Activator getDefault() {
94         return plugin;
95     }
96     
97     /**
98      * Returns an image descriptor for the image file at the given
99      * plug-in relative path.
100      *
101      * @param path the path
102      * @return the image descriptor
103      */
104     public static ImageDescriptor getImageDescriptor(String path) {
105         return BundleUtils.getImageDescriptorFromPlugin(PLUGIN_ID, path);
106     }
107     
108     /** 
109      * Initializes a preference store with default preference values 
110      * for this plug-in.
111      */
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);
119     }
120
121
122 }