Lines 15-21
Link Here
|
15 |
package org.eclipse.emf.validation.internal; |
15 |
package org.eclipse.emf.validation.internal; |
16 |
|
16 |
|
17 |
import java.util.Collection; |
17 |
import java.util.Collection; |
|
|
18 |
import java.util.Dictionary; |
18 |
import java.util.HashMap; |
19 |
import java.util.HashMap; |
|
|
20 |
import java.util.Hashtable; |
19 |
import java.util.Iterator; |
21 |
import java.util.Iterator; |
20 |
import java.util.Map; |
22 |
import java.util.Map; |
21 |
|
23 |
|
Lines 26-31
Link Here
|
26 |
import org.eclipse.emf.common.EMFPlugin; |
28 |
import org.eclipse.emf.common.EMFPlugin; |
27 |
import org.eclipse.emf.common.util.ResourceLocator; |
29 |
import org.eclipse.emf.common.util.ResourceLocator; |
28 |
import org.eclipse.emf.validation.internal.l10n.ValidationMessages; |
30 |
import org.eclipse.emf.validation.internal.l10n.ValidationMessages; |
|
|
31 |
import org.eclipse.osgi.service.debug.DebugOptions; |
32 |
import org.eclipse.osgi.service.debug.DebugOptionsListener; |
29 |
import org.eclipse.osgi.util.NLS; |
33 |
import org.eclipse.osgi.util.NLS; |
30 |
import org.osgi.framework.BundleContext; |
34 |
import org.osgi.framework.BundleContext; |
31 |
|
35 |
|
Lines 213-219
Link Here
|
213 |
* |
217 |
* |
214 |
* @author Christian W. Damus (cdamus) |
218 |
* @author Christian W. Damus (cdamus) |
215 |
*/ |
219 |
*/ |
216 |
public static class Implementation extends EMFPlugin.EclipsePlugin { |
220 |
public static class Implementation extends EMFPlugin.EclipsePlugin implements DebugOptionsListener { |
217 |
/** |
221 |
/** |
218 |
* Track extensions for extension points defined in this bundle. |
222 |
* Track extensions for extension points defined in this bundle. |
219 |
*/ |
223 |
*/ |
Lines 237-242
Link Here
|
237 |
super.start(context); |
241 |
super.start(context); |
238 |
|
242 |
|
239 |
extensionTracker = new ExtensionTracker(); |
243 |
extensionTracker = new ExtensionTracker(); |
|
|
244 |
|
245 |
// register listener that is notified whenever debug options change |
246 |
Dictionary<String, Object> props = new Hashtable<String, Object>(4); |
247 |
props.put(DebugOptions.LISTENER_SYMBOLICNAME, getPluginId()); |
248 |
context.registerService(DebugOptionsListener.class.getName(), this, props); |
240 |
} |
249 |
} |
241 |
|
250 |
|
242 |
@Override |
251 |
@Override |
Lines 246-251
Link Here
|
246 |
|
255 |
|
247 |
super.stop(context); |
256 |
super.stop(context); |
248 |
} |
257 |
} |
|
|
258 |
|
259 |
public void optionsChanged(DebugOptions options) { |
260 |
Tracing.invalidateCache(); |
261 |
} |
249 |
} |
262 |
} |
250 |
|
263 |
|
251 |
public static class Tracing { |
264 |
public static class Tracing { |
Lines 255-267
Link Here
|
255 |
private static final Map<String, Boolean> cachedOptions = new HashMap<String, Boolean>(); |
268 |
private static final Map<String, Boolean> cachedOptions = new HashMap<String, Boolean>(); |
256 |
|
269 |
|
257 |
/** |
270 |
/** |
|
|
271 |
* The cached Boolean value indicating whether tracing is enabled. |
272 |
*/ |
273 |
private static Boolean debugging = null; |
274 |
|
275 |
/** |
276 |
* Invalidates the cached debug options and the cached Boolean value |
277 |
* indicating whether tracing is enabled. |
278 |
*/ |
279 |
protected static void invalidateCache() { |
280 |
cachedOptions.clear(); |
281 |
debugging = null; |
282 |
} |
283 |
|
284 |
/** |
258 |
* Retrieves a Boolean value indicating whether tracing is enabled. |
285 |
* Retrieves a Boolean value indicating whether tracing is enabled. |
259 |
* |
286 |
* |
260 |
* @return Whether tracing is enabled for the plug-in. |
287 |
* @return Whether tracing is enabled for the plug-in. |
261 |
* |
288 |
* |
262 |
*/ |
289 |
*/ |
263 |
protected static boolean shouldTrace() { |
290 |
protected static boolean shouldTrace() { |
264 |
return plugin.isDebugging(); |
291 |
synchronized (cachedOptions) { |
|
|
292 |
if (debugging == null) { |
293 |
debugging = plugin.isDebugging(); |
294 |
} |
295 |
} |
296 |
return debugging.booleanValue(); |
265 |
} |
297 |
} |
266 |
|
298 |
|
267 |
/** |
299 |
/** |