KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > lifl > eclipse > plugin > project > OpenCCM > MainPlugin


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 /*
27  * Created on 23 mai 2003 by jerome OFFROY (offroy@lifl.fr)
28  *
29  */

30
31 package org.omg.lifl.eclipse.plugin.project.OpenCCM;
32
33 import java.net.MalformedURLException JavaDoc;
34 import java.net.URL JavaDoc;
35
36 import org.eclipse.core.resources.IWorkspace;
37 import org.eclipse.core.resources.ResourcesPlugin;
38 import org.eclipse.core.runtime.IPluginDescriptor;
39 import org.eclipse.core.runtime.IStatus;
40 import org.eclipse.core.runtime.Status;
41 import org.eclipse.jface.resource.ImageDescriptor;
42 import org.eclipse.ui.plugin.AbstractUIPlugin;
43
44 /**
45  * @author LIFL
46  *
47  */

48 public class MainPlugin extends AbstractUIPlugin {
49
50     private static MainPlugin fgPlugin;
51
52     /**
53      * @param descriptor
54      */

55     public MainPlugin(IPluginDescriptor descriptor) {
56         super(descriptor);
57         fgPlugin = this;
58     }
59
60     /**
61      * Returns the shared instance.
62      */

63     public static MainPlugin getDefault() {
64         return fgPlugin;
65     }
66
67     /**
68      * Returns the workspace instance.
69      */

70     public static IWorkspace getWorkspace() {
71         return ResourcesPlugin.getWorkspace();
72     }
73
74     /**
75      * @param name
76      * @return
77      */

78     public ImageDescriptor getImageDescriptor(String JavaDoc name) {
79         try {
80             URL JavaDoc url = new URL JavaDoc(getDescriptor().getInstallURL(), name);
81             return ImageDescriptor.createFromURL(url);
82         } catch (MalformedURLException JavaDoc e) {
83             return ImageDescriptor.getMissingImageDescriptor();
84         }
85     }
86
87     public static String JavaDoc getPluginId() {
88         return getDefault().getDescriptor().getUniqueIdentifier();
89     }
90
91     /**
92      * @param status
93      */

94     public static void log(IStatus status) {
95         getDefault().getLog().log(status);
96     }
97
98     /**
99      * @param message
100      */

101     public static void log(String JavaDoc message) {
102         log(
103             new Status(
104                 IStatus.ERROR,
105                 getPluginId(),
106                 IStatus.ERROR,
107                 message,
108                 null));
109     }
110
111     /**
112      * @param e
113      */

114     public static void log(Throwable JavaDoc e) {
115         log(
116             new Status(
117                 IStatus.ERROR,
118                 getPluginId(),
119                 IStatus.ERROR,
120                 "Internal Error",
121                 e));
122     }
123
124 }
125
Popular Tags