KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > variables > VariablesPlugin


1 /*******************************************************************************
2  * Copyright (c) 2000, 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
12 package org.eclipse.core.variables;
13
14 import org.eclipse.core.internal.variables.StringVariableManager;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Plugin;
17 import org.eclipse.core.runtime.Status;
18
19 /**
20  * The plug-in runtime class for the Core Variables plug-in.
21  * @since 3.0
22  */

23 public class VariablesPlugin extends Plugin {
24
25     /**
26      * Status code indicating an unexpected internal error.
27      */

28     public static final int INTERNAL_ERROR = 120;
29     
30     /**
31      * Status code indicating a variable reference cycle error.
32      */

33     public static final int REFERENCE_CYCLE_ERROR = 130;
34     
35     /**
36      * The single instance of this plug-in runtime class.
37      */

38     private static VariablesPlugin plugin;
39
40     /**
41      * Unique identifier constant (value <code>"org.eclipse.core.variables"</code>)
42      * for the Core Variables plug-in.
43      */

44     public static final String JavaDoc PI_CORE_VARIABLES = "org.eclipse.core.variables"; //$NON-NLS-1$
45

46
47     /**
48      * Constructs an instance of this plug-in runtime class.
49      * <p>
50      * An instance of this plug-in runtime class is automatically created
51      * when the facilities provided by the Variables plug-in are required.
52      * <b>Clients must never explicitly instantiate a plug-in runtime class.</b>
53      * </p>
54      */

55     public VariablesPlugin() {
56         super();
57         plugin = this;
58     }
59
60     /**
61      * Returns this plug-in instance.
62      *
63      * @return the single instance of this plug-in runtime class
64      */

65     public static VariablesPlugin getDefault() {
66         return plugin;
67     }
68     
69     /**
70      * Logs the specified throwable with this plug-in's log.
71      *
72      * @param t throwable to log
73      */

74     public static void log(Throwable JavaDoc t) {
75         log(new Status(IStatus.ERROR, PI_CORE_VARIABLES, INTERNAL_ERROR, "Error logged from Core Variables: ", t)); //$NON-NLS-1$
76
}
77     
78     /**
79      * Logs the given message with this plug-in's log and the given
80      * throwable or <code>null</code> if none.
81      * @param message the message to log
82      * @param throwable the exception that occurred or <code>null</code> if none
83      */

84     public static void logMessage(String JavaDoc message, Throwable JavaDoc throwable) {
85         log(new Status(IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, message, throwable));
86     }
87     
88     /**
89      * Logs the specified status with this plug-in's log.
90      *
91      * @param status status to log
92      */

93     public static void log(IStatus status) {
94         getDefault().getLog().log(status);
95     }
96     
97     /**
98      * Convenience method which returns the unique identifier of this plug-in.
99      */

100     public static String JavaDoc getUniqueIdentifier() {
101         return PI_CORE_VARIABLES;
102     }
103     
104     /**
105      * Returns the string variable manager.
106      *
107      * @return the string variable manager
108      */

109     public IStringVariableManager getStringVariableManager() {
110         return StringVariableManager.getDefault();
111     }
112 }
113
Popular Tags