source: trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/UIPlugin.java @ 286

Last change on this file since 286 was 286, checked in by boris, 19 years ago
  • bunch of cosmetic changes
File size: 1.8 KB
Line 
1package org.modelica.mdt.ui;
2
3import org.eclipse.swt.widgets.Display;
4import org.eclipse.ui.plugin.AbstractUIPlugin;
5import org.eclipse.core.runtime.IAdapterFactory;
6import org.eclipse.core.runtime.IAdapterManager;
7import org.eclipse.core.runtime.Platform;
8import org.modelica.mdt.core.IModelicaElement;
9import org.osgi.framework.BundleContext;
10
11/**
12 * The main plugin class for the org.modelica.mdt.ui plugin
13 */
14public class UIPlugin extends AbstractUIPlugin
15{
16
17    /* the shared instance */
18    private static UIPlugin plugin;
19   
20    public UIPlugin() 
21    {
22        plugin = this;
23    }
24
25    /**
26     * This method is called upon plug-in activation
27     */
28    public void start(BundleContext context) throws Exception
29    {
30        super.start(context);
31       
32        IAdapterManager manager = Platform.getAdapterManager();
33        IAdapterFactory factory = new ModelicaElementAdapterFactory();
34        manager.registerAdapters(factory, IModelicaElement.class);
35    }
36
37    /**
38     * This method is called when the plug-in is stopped
39     */
40    public void stop(BundleContext context) throws Exception
41    {
42        super.stop(context);           
43        plugin = null;
44    }
45
46    /**
47     * Returns the shared instance.
48     */
49    public static UIPlugin getDefault() 
50    {
51        return plugin;
52    }
53   
54    /**
55     * Returns the standard display to be used. The method first checks, if
56     * the thread calling this method has an associated display. If so, this
57     * display is returned. Otherwise the method returns the default display.
58     */
59    public static Display getStandardDisplay() 
60    {
61        Display display;
62        display = Display.getCurrent();
63        if (display == null)
64            display = Display.getDefault();
65        return display;     
66    }
67   
68    /**
69     * @return returns this plugins symbolic name e.g. stuff like org.foo.bar
70     */
71    public static String getSymbolicName()
72    {
73        return getDefault().getBundle().getSymbolicName();
74    }
75
76}
Note: See TracBrowser for help on using the repository browser.