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

Last change on this file since 288 was 288, checked in by boris, 19 years ago
  • added a 'parent package' field to new package dialog and implemented infrastructure to be animate it among others:
  • IModelicaProject.getPackageRoots() method to fetch all top level package in a project
  • IModelicaProject.getPackage() method to fetch a package by its full name
  • IModelicaProject.findElement() method to fetch project's elements by path
  • modelica source files are now wraped by IModelicaSourceFile
  • plain files are now wraped by IModelicaFile inside a modelica project
  • an abstract wizard page superclass NewTypePage? added wich implemets source and parent package fields which are used in createing new classes/packages
  • some other stuff i forgot about, this kinda got out of hand, smaller commits in the future !
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        manager.registerAdapters(factory, IModelicaElement.class);
36    }
37
38    /**
39     * This method is called when the plug-in is stopped
40     */
41    public void stop(BundleContext context) throws Exception
42    {
43        super.stop(context);           
44        plugin = null;
45    }
46
47    /**
48     * Returns the shared instance.
49     */
50    public static UIPlugin getDefault() 
51    {
52        return plugin;
53    }
54   
55    /**
56     * Returns the standard display to be used. The method first checks, if
57     * the thread calling this method has an associated display. If so, this
58     * display is returned. Otherwise the method returns the default display.
59     */
60    public static Display getStandardDisplay() 
61    {
62        Display display;
63        display = Display.getCurrent();
64        if (display == null)
65            display = Display.getDefault();
66        return display;     
67    }
68   
69    /**
70     * @return returns this plugins symbolic name e.g. stuff like org.foo.bar
71     */
72    public static String getSymbolicName()
73    {
74        return getDefault().getBundle().getSymbolicName();
75    }
76
77    /**
78     * set an abbot tag, used by GUI regressions tests to find
79     * specific widgets.
80     *
81     * @param widget the widget to tag
82     * @param tag the tag to set
83     */
84    public static void tag(Widget widget, String tag)
85    {
86        widget.setData("name", tag);
87    }       
88}
Note: See TracBrowser for help on using the repository browser.