KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > registry > UIExtensionTracker


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.registry;
12
13 import org.eclipse.core.runtime.IExtension;
14 import org.eclipse.core.runtime.dynamichelpers.ExtensionTracker;
15 import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
16 import org.eclipse.swt.widgets.Display;
17 import org.eclipse.ui.internal.WorkbenchPlugin;
18
19 /**
20  * @since 3.1
21  */

22 public class UIExtensionTracker extends ExtensionTracker {
23     private Display display;
24
25     // SOMETHING HAS NOT BEEN DONE IN THE REGISTTRY CHANGED CODE
26
// if (!PlatformUI.isWorkbenchRunning())
27
// return;
28
// int numDeltas = 0;
29
// Display display = PlatformUI.getWorkbench().getDisplay();
30
// if (display == null || display.isDisposed())
31
// return;
32
// It seems that the tracker should be closed.
33

34     /**
35      * @param display
36      */

37     public UIExtensionTracker(Display display) {
38         this.display = display;
39     }
40
41     protected void applyRemove(final IExtensionChangeHandler handler, final IExtension removedExtension, final Object JavaDoc[] objects) {
42         display.syncExec(new Runnable JavaDoc() {
43
44             public void run() {
45                 try {
46                     handler.removeExtension(removedExtension, objects);
47                 } catch (Exception JavaDoc e) {
48                     WorkbenchPlugin.log(getClass(), "doRemove", e); //$NON-NLS-1$
49
}
50             }
51         });
52     }
53
54     protected void applyAdd(final IExtensionChangeHandler handler, final IExtension addedExtension) {
55         display.syncExec(new Runnable JavaDoc() {
56             public void run() {
57                 try {
58                     handler.addExtension(UIExtensionTracker.this, addedExtension);
59                 } catch (Exception JavaDoc e) {
60                     WorkbenchPlugin.log(getClass(), "doAdd", e); //$NON-NLS-1$
61
}
62             }
63         });
64     }
65 }
66
Popular Tags