Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e9e84ff8d90a420a0f78315303e8cb761c35b55b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*******************************************************************************
 * Copyright (c) 2000, 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.core.variables;

import org.eclipse.core.internal.variables.StringVariableManager;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;

/**
 * The plug-in runtime class for the Core Variables plug-in.
 * @since 3.0
 * @noinstantiate This class is not intended to be instantiated by clients.
 * @noextend This class is not intended to be subclassed by clients.
 */
public class VariablesPlugin extends Plugin {

	/**
	 * Status code indicating an unexpected internal error.
	 */
	public static final int INTERNAL_ERROR = 120;

	/**
	 * Status code indicating a variable reference cycle error.
	 */
	public static final int REFERENCE_CYCLE_ERROR = 130;

	/**
	 * The single instance of this plug-in runtime class.
	 */
	private static VariablesPlugin plugin;

	/**
	 * Unique identifier constant (value <code>"org.eclipse.core.variables"</code>)
	 * for the Core Variables plug-in.
	 */
	public static final String PI_CORE_VARIABLES = "org.eclipse.core.variables"; //$NON-NLS-1$


	/**
	 * Constructs an instance of this plug-in runtime class.
	 * <p>
	 * An instance of this plug-in runtime class is automatically created
	 * when the facilities provided by the Variables plug-in are required.
	 * <b>Clients must never explicitly instantiate a plug-in runtime class.</b>
	 * </p>
	 */
	public VariablesPlugin() {
		super();
		plugin = this;
	}

	/**
	 * Returns this plug-in instance.
	 *
	 * @return the single instance of this plug-in runtime class
	 */
	public static VariablesPlugin getDefault() {
		return plugin;
	}

	/**
	 * Logs the specified throwable with this plug-in's log.
	 *
	 * @param t throwable to log
	 */
	public static void log(Throwable t) {
		log(new Status(IStatus.ERROR, PI_CORE_VARIABLES, INTERNAL_ERROR, "Error logged from Core Variables: ", t)); //$NON-NLS-1$
	}

	/**
	 * Logs the given message with this plug-in's log and the given
	 * throwable or <code>null</code> if none.
	 * @param message the message to log
	 * @param throwable the exception that occurred or <code>null</code> if none
	 */
	public static void logMessage(String message, Throwable throwable) {
		log(new Status(IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, message, throwable));
	}

	/**
	 * Logs the specified status with this plug-in's log.
	 *
	 * @param status status to log
	 */
	public static void log(IStatus status) {
		getDefault().getLog().log(status);
	}

	/**
	 * Convenience method which returns the unique identifier of this plug-in.
	 * @return the identifier of this plug-in
	 */
	public static String getUniqueIdentifier() {
		return PI_CORE_VARIABLES;
	}

	/**
	 * Returns the string variable manager.
	 *
	 * @return the string variable manager
	 */
	public IStringVariableManager getStringVariableManager() {
		return StringVariableManager.getDefault();
	}
}

Back to the top