source: trunk/org.modelica.mdt/src/org/modelica/mdt/MdtPlugin.java @ 64

Last change on this file since 64 was 61, checked in by boris, 19 years ago
  • added copyright notice to all source files
File size: 3.6 KB
Line 
1/*
2 * This file is part of Modelica Development Tooling.
3 *
4 * Copyright (c) 2005, Linköpings universitet, Department of
5 * Computer and Information Science, PELAB
6 *
7 * All rights reserved.
8 *
9 * (The new BSD license, see also
10 * http://www.opensource.org/licenses/bsd-license.php)
11 *
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are
15 * met:
16 *
17 * * Redistributions of source code must retain the above copyright
18 *   notice, this list of conditions and the following disclaimer.
19 *
20 * * Redistributions in binary form must reproduce the above copyright
21 *   notice, this list of conditions and the following disclaimer in
22 *   the documentation and/or other materials provided with the
23 *   distribution.
24 *
25 * * Neither the name of Linköpings universitet nor the names of its
26 *   contributors may be used to endorse or promote products derived from
27 *   this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42package org.modelica.mdt;
43import org.eclipse.core.resources.IProject;
44import org.eclipse.core.resources.IProjectDescription;
45import org.eclipse.core.runtime.CoreException;
46import org.eclipse.swt.widgets.Widget;
47import org.eclipse.ui.plugin.AbstractUIPlugin;
48import org.osgi.framework.BundleContext;
49
50public class MdtPlugin extends AbstractUIPlugin
51{
52
53    public static final String MODELICA_NATURE = 
54        "org.modelica.mdt.ModelicaNature";
55   
56    //The shared instance.
57    private static MdtPlugin plugin;
58   
59    /**
60     * The constructor.
61     */
62    public MdtPlugin()
63    {
64        plugin = this;
65    }
66
67   
68    public static void addModelicaNature(IProject project) throws CoreException
69    {
70        if (project.hasNature(MODELICA_NATURE)) 
71            return;
72
73        IProjectDescription description = project.getDescription();
74        String[] ids= description.getNatureIds();
75        String[] newIds= new String[ids.length + 1];
76        System.arraycopy(ids, 0, newIds, 0, ids.length);
77        newIds[ids.length]= MODELICA_NATURE;
78        description.setNatureIds(newIds);
79        project.setDescription(description, null);
80    }
81   
82    /**
83     * Returns the shared instance.
84     */
85    public static MdtPlugin getDefault()
86    {
87        return plugin;
88    }
89   
90    /**
91     * This method is called upon plug-in activation
92     */
93    public void start(BundleContext context) throws Exception
94    {
95        super.start(context);
96    }
97
98    /**
99     * This method is called when the plug-in is stopped
100     */
101    public void stop(BundleContext context) throws Exception
102    {
103        super.stop(context);
104        plugin = null;
105    }
106
107    /**
108     * @return returns this plugins symbolic name e.g. stuff like org.foo.bar
109     */
110    public static String getSymbolicName()
111    {
112        return getDefault().getBundle().getSymbolicName();
113    }
114
115    public static void tag(Widget widget, String tag)
116    {
117        widget.setData("name", tag);
118    }
119}
Note: See TracBrowser for help on using the repository browser.