source: trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/Plugin.java @ 254

Last change on this file since 254 was 254, checked in by boris, 19 years ago
  • fixed problem with images that fail to be loaded
File size: 1.6 KB
Line 
1package org.modelica.mdt.ui;
2
3import org.eclipse.swt.widgets.Display;
4import org.eclipse.ui.plugin.*;
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
13 */
14public class Plugin extends AbstractUIPlugin
15{
16
17    /* the shared instance */
18    private static Plugin plugin;
19   
20    public Plugin() 
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 Plugin 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}
Note: See TracBrowser for help on using the repository browser.