01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.registry;
11:
12: import org.eclipse.core.runtime.IExtension;
13: import org.eclipse.core.runtime.dynamichelpers.ExtensionTracker;
14: import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
15: import org.eclipse.swt.widgets.Display;
16: import org.eclipse.ui.internal.WorkbenchPlugin;
17:
18: /**
19: * @since 3.1
20: */
21: public class UIExtensionTracker extends ExtensionTracker {
22: private Display display;
23:
24: // SOMETHING HAS NOT BEEN DONE IN THE REGISTTRY CHANGED CODE
25: // if (!PlatformUI.isWorkbenchRunning())
26: // return;
27: // int numDeltas = 0;
28: // Display display = PlatformUI.getWorkbench().getDisplay();
29: // if (display == null || display.isDisposed())
30: // return;
31: // It seems that the tracker should be closed.
32:
33: /**
34: * @param display
35: */
36: public UIExtensionTracker(Display display) {
37: this .display = display;
38: }
39:
40: protected void applyRemove(final IExtensionChangeHandler handler,
41: final IExtension removedExtension, final Object[] objects) {
42: display.syncExec(new Runnable() {
43:
44: public void run() {
45: try {
46: handler.removeExtension(removedExtension, objects);
47: } catch (Exception e) {
48: WorkbenchPlugin.log(getClass(), "doRemove", e); //$NON-NLS-1$
49: }
50: }
51: });
52: }
53:
54: protected void applyAdd(final IExtensionChangeHandler handler,
55: final IExtension addedExtension) {
56: display.syncExec(new Runnable() {
57: public void run() {
58: try {
59: handler.addExtension(UIExtensionTracker.this ,
60: addedExtension);
61: } catch (Exception e) {
62: WorkbenchPlugin.log(getClass(), "doAdd", e); //$NON-NLS-1$
63: }
64: }
65: });
66: }
67: }
|