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

Last change on this file since 365 was 365, checked in by boris, 19 years ago
  • added a new IStandardLibrary package that acts as grand parent of all packages defined in standard library
  • removed dummy object for the standard library node in the modelica project view tree
  • added test for ui aspects of modelica elements and standard library
  • accidently renamed system library to standard library
File size: 2.1 KB
Line 
1package org.modelica.mdt.ui;
2
3import org.eclipse.swt.widgets.Display;
4import org.eclipse.swt.widgets.Widget;
5import org.eclipse.ui.plugin.AbstractUIPlugin;
6import org.eclipse.core.runtime.IAdapterFactory;
7import org.eclipse.core.runtime.IAdapterManager;
8import org.eclipse.core.runtime.Platform;
9import org.modelica.mdt.core.IModelicaElement;
10import org.osgi.framework.BundleContext;
11
12/**
13 * The main plugin class for the org.modelica.mdt.ui plugin
14 */
15public class UIPlugin extends AbstractUIPlugin
16{
17
18    /* the shared instance */
19    private static UIPlugin plugin;
20   
21    public UIPlugin() 
22    {
23        plugin = this;
24    }
25
26    /**
27     * This method is called upon plug-in activation
28     */
29    public void start(BundleContext context) throws Exception
30    {
31        super.start(context);
32       
33        IAdapterManager manager = Platform.getAdapterManager();
34        IAdapterFactory factory = new ModelicaElementAdapterFactory();
35
36        manager.registerAdapters(factory, IModelicaElement.class);
37    }
38
39    /**
40     * This method is called when the plug-in is stopped
41     */
42    public void stop(BundleContext context) throws Exception
43    {
44        super.stop(context);           
45        plugin = null;
46    }
47
48    /**
49     * Returns the shared instance.
50     */
51    public static UIPlugin getDefault() 
52    {
53        return plugin;
54    }
55   
56    /**
57     * Returns the standard display to be used. The method first checks, if
58     * the thread calling this method has an associated display. If so, this
59     * display is returned. Otherwise the method returns the default display.
60     */
61    public static Display getStandardDisplay() 
62    {
63        Display display;
64        display = Display.getCurrent();
65        if (display == null)
66            display = Display.getDefault();
67        return display;     
68    }
69   
70    /**
71     * @return returns this plugins symbolic name e.g. stuff like org.foo.bar
72     */
73    public static String getSymbolicName()
74    {
75        return getDefault().getBundle().getSymbolicName();
76    }
77
78    /**
79     * set an abbot tag, used by GUI regressions tests to find
80     * specific widgets.
81     *
82     * @param widget the widget to tag
83     * @param tag the tag to set
84     */
85    public static void tag(Widget widget, String tag)
86    {
87        widget.setData("name", tag);
88    }       
89}
Note: See TracBrowser for help on using the repository browser.