KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > navigator > resources > plugin > WorkbenchNavigatorPlugin


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.navigator.resources.plugin;
12
13 import org.eclipse.core.resources.IWorkspace;
14 import org.eclipse.core.resources.ResourcesPlugin;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.ui.plugin.AbstractUIPlugin;
18
19 /**
20  * The main plugin class for the workbench Navigator.
21  *
22  *
23  * <p>
24  * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
25  * part of a work in progress. There is a guarantee neither that this API will
26  * work nor that it will remain the same. Please do not use this API without
27  * consulting with the Platform/UI team.
28  * </p>
29  *
30  * @since 3.2
31  */

32 public class WorkbenchNavigatorPlugin extends AbstractUIPlugin {
33     // The shared instance.
34
private static WorkbenchNavigatorPlugin plugin;
35
36     /** The plugin id */
37     public static String JavaDoc PLUGIN_ID = "org.eclipse.ui.navigator.resources"; //$NON-NLS-1$
38

39     /**
40      * Creates a new instance of the receiver
41      */

42     public WorkbenchNavigatorPlugin() {
43         super();
44         plugin = this;
45     }
46
47     /**
48      * @return the shared instance.
49      */

50     public static WorkbenchNavigatorPlugin getDefault() {
51         return plugin;
52     }
53
54     /**
55      * @return the workspace instance.
56      */

57     public static IWorkspace getWorkspace() {
58         return ResourcesPlugin.getWorkspace();
59     }
60
61     /**
62      * Logs errors.
63      * @param message The message to log
64      * @param status The status to log
65      */

66     public static void log(String JavaDoc message, IStatus status) {
67         if (message != null) {
68             getDefault().getLog().log(
69                     new Status(IStatus.ERROR, PLUGIN_ID, 0, message, null));
70             System.err.println(message + "\nReason:"); //$NON-NLS-1$
71
}
72         if(status != null) {
73             getDefault().getLog().log(status);
74             System.err.println(status.getMessage());
75         }
76     }
77
78     /**
79      * Create a status associated with this plugin.
80      *
81      * @param severity
82      * @param aCode
83      * @param aMessage
84      * @param exception
85      * @return A status configured with this plugin's id and the given
86      * parameters.
87      */

88     public static IStatus createStatus(int severity, int aCode,
89             String JavaDoc aMessage, Throwable JavaDoc exception) {
90         return new Status(severity, PLUGIN_ID, aCode,
91                 aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
92
}
93
94     /**
95      *
96      * @param aCode
97      * @param aMessage
98      * @param exception
99      * @return A status configured with this plugin's id and the given
100      * parameters.
101      */

102     public static IStatus createErrorStatus(int aCode, String JavaDoc aMessage,
103             Throwable JavaDoc exception) {
104         return createStatus(IStatus.ERROR, aCode, aMessage, exception);
105     }
106     
107
108     /**
109      *
110      * @param aMessage
111      * @param exception
112      * @return A status configured with this plugin's id and the given
113      * parameters.
114      */

115     public static IStatus createErrorStatus(String JavaDoc aMessage, Throwable JavaDoc exception) {
116         return createStatus(IStatus.ERROR, 0, aMessage, exception);
117     }
118     
119     /**
120      *
121      * @param aMessage
122      * @return A status configured with this plugin's id and the given
123      * parameters.
124      */

125     public static IStatus createErrorStatus(String JavaDoc aMessage) {
126         return createStatus(IStatus.ERROR, 0, aMessage, null);
127     }
128     
129     
130     /**
131      *
132      * @param aMessage
133      * @return A status configured with this plugin's id and the given
134      * parameters.
135      */

136     public static IStatus createInfoStatus(String JavaDoc aMessage) {
137         return createStatus(IStatus.INFO, 0, aMessage, null);
138     }
139     
140     
141     /**
142      *
143      * @param aMessage
144      * @return A status configured with this plugin's id and the given
145      * parameters.
146      */

147     public static IStatus createWarningStatus(String JavaDoc aMessage) {
148         return createStatus(IStatus.WARNING, 0, aMessage, null);
149     }
150 }
151
Popular Tags