1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.model.base;
19
20 import org.apache.log4j.ConsoleAppender;
21 import org.apache.log4j.Level;
22 import org.apache.log4j.Logger;
23 import org.apache.log4j.PatternLayout;
24 import org.eclipse.core.runtime.IConfigurationElement;
25 import org.eclipse.core.runtime.Platform;
26 import org.eclipse.ui.plugin.AbstractUIPlugin;
27 import org.osgi.framework.BundleContext;
28
29
30
31
32
33
34
35 public class BasePlugin extends AbstractUIPlugin {
36
37
38
39
40 public static final String PLUGIN_ID = "pl.edu.agh.cast.base";
41
42
43
44
45 public static final String MODEL_EXTENSION_ID = "pl.edu.agh.cast.model";
46
47
48
49
50 public static final String ABSTRACT_MODEL_ID = "pl.edu.agh.cast.model.base";
51
52
53
54
55 public static final String COLUMN = "column";
56
57
58
59
60 public static final String COLUMN_DEFAULTVALUE = "defaultvalue";
61
62
63
64
65 public static final String COLUMN_MODEL_INDEX = "modelIndex";
66
67
68
69
70 public static final String COLUMN_NAME = "name";
71
72
73
74
75 public static final String COLUMN_USE = "use";
76
77
78
79
80 public static final String COLUMN_ID = "id";
81
82
83
84
85 public static final String COLUMN_TYPE = "type";
86
87
88
89
90 public static final String PARAMETER = "parameter";
91
92
93
94
95 public static final String PARAMETER_ID = "id";
96
97
98
99
100 public static final String PARAMETER_NAME = "name";
101
102
103
104
105 public static final String LOADER = "loader";
106
107
108
109
110 public static final String MODEL_NAME = "name";
111
112
113
114
115 public static final String MODEL_ID = "id";
116
117
118
119
120 public static final String COLUMN_REQUIRED = "required";
121
122
123
124
125 public static final String COLUMN_OPTIONAL = "optional";
126
127
128
129
130 public static final String COLUMN_TYPE_STRING = "String";
131
132
133
134
135 public static final String COLUMN_TYPE_LONG = "Long";
136
137
138
139
140 public static final String COLUMN_TYPE_DOUBLE = "Double";
141
142
143
144
145 public static final String COLUMN_TYPE_DATE = "Date";
146
147
148
149
150 public static final String COLUMN_TYPE_BOOLEAN = "Boolean";
151
152
153
154
155 public static final String TYPE = "type";
156
157
158
159
160 public static final String TYPE_ID = "id";
161
162
163
164
165 public static final String ATTRIBUTE = "attribute";
166
167
168
169
170 public static final String ATTRIBUTE_ID = "id";
171
172
173
174
175 public static final String ATTRIBUTE_NAME = "name";
176
177
178
179
180 public static final String SOURCE_ATTRIBUTE_NAME = "Source";
181
182
183
184
185 public static final String TARGET_ATTRIBUTE_NAME = "Target";
186
187
188
189
190 public static final String DATE_ATTRIBUTE_NAME = "Date";
191
192
193 private static BasePlugin plugin;
194
195
196 private static volatile Logger log;
197
198 private static Object lock = new Object();
199
200
201
202
203 public BasePlugin() {
204 }
205
206
207
208
209
210
211
212 @Override
213 public void start(BundleContext context) throws Exception {
214 super.start(context);
215 plugin = this;
216 }
217
218
219
220
221
222
223
224 @Override
225 public void stop(BundleContext context) throws Exception {
226 plugin = null;
227 super.stop(context);
228 }
229
230
231
232
233
234
235 public static BasePlugin getDefault() {
236 return plugin;
237 }
238
239
240
241
242
243
244 public static Logger getLogger() {
245 if (log == null) {
246 synchronized (lock) {
247 log = Logger.getLogger(BasePlugin.class);
248 if (!log.getAllAppenders().hasMoreElements()) {
249
250 log.addAppender(new ConsoleAppender(new PatternLayout("%c: %5p [%t] (%F:%L) - %m%n ")));
251 log.setLevel(Level.INFO);
252 }
253 }
254 }
255 return log;
256 }
257
258
259
260
261
262
263 public static IConfigurationElement[] getModelConfigurations() {
264 return Platform.getExtensionRegistry().getConfigurationElementsFor(MODEL_EXTENSION_ID);
265 }
266
267 }