-
Notifications
You must be signed in to change notification settings - Fork 3
/
activator.mtl
135 lines (114 loc) · 3.63 KB
/
activator.mtl
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
[comment encoding = UTF-8 /]
[module activator('http://www.eclipse.org/acceleo/4.0')/]
[import org::eclipse::acceleo::aql::ide::ui::module::services::Services/]
[**
* Generate the Activator Java file.
* @param projectUIName the UI project name
*/]
[template public activatorFile(projectUIName : String)]
[file (projectUIName + '/src/' + projectUIName.replaceAll('\\.', '/') + '/Activator.java', overwrite, 'UTF-8')]
[protected ('copyright') startTagPrefix('//') endTagPrefix('//')]
[/protected]
package [projectUIName/];
[protected ('imports') startTagPrefix('//') endTagPrefix('//')]
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
[/protected]
/**
* Plugin's activator class.
*
* @author [''.getUserName()/]
*/
public class Activator extends EMFPlugin {
/**
* Plugin's id.
*/
public static final String PLUGIN_ID = "[projectUIName/]"; //$NON-NLS-1$
/**
* The shared instance.
*/
public static final Activator INSTANCE = new Activator();
/**
* The implementation plugin for Eclipse.
*/
private static Implementation plugin;
/**
* The constructor.
*/
public Activator() {
super(new ResourceLocator['['/]] {});
}
@Override
public ResourceLocator getPluginResourceLocator() {
return plugin;
}
public static Implementation getPlugin() {
return plugin;
}
/**
* Class implementing the EclipsePlugin instance, instanciated when the code is run in an OSGi context.
*
* @author cedric
*/
public static class Implementation extends EclipsePlugin {
/**
* Create the Eclipse Implementation.
*/
public Implementation() {
super();
// Remember the static instance.
//
plugin = this;
}
}
/**
* Returns the shared instance.
*
* @return the shared instance.
*/
public static Activator getDefault() {
return INSTANCE;
}
/**
* Logs the given exception as error or warning.
*
* @param exception
* The exception to log.
* @param blocker
* <code>True</code> if the message must be logged as error, <code>False</code> to log it as a
* warning.
*/
public static void log(Exception exception, boolean blocker) {
final int severity;
if (blocker) {
severity = IStatus.ERROR;
} else {
severity = IStatus.WARNING;
}
Activator.INSTANCE.log(new Status(severity, PLUGIN_ID, exception.getMessage(), exception));
}
/**
* Puts the given message in the error log view, as error or warning.
*
* @param message
* The message to put in the error log view.
* @param blocker
* <code>True</code> if the message must be logged as error, <code>False</code> to log it as a
* warning.
*/
public static void log(String message, boolean blocker) {
int severity = IStatus.WARNING;
if (blocker) {
severity = IStatus.ERROR;
}
String errorMessage = message;
if (errorMessage == null || "".equals(errorMessage)) { //$NON-NLS-1$
errorMessage = "Logging null message should never happens."; //$NON-NLS-1$
}
Activator.INSTANCE.log(new Status(severity, PLUGIN_ID, errorMessage));
}
}
[/file]
[/template]