this.workbench = workbench;
}
public void registryChanged(IRegistryChangeEvent event) {
try {
IExtensionDelta delta[] = event
.getExtensionDeltas(WorkbenchPlugin.PI_WORKBENCH);
IExtension ext;
IExtensionPoint extPt;
IWorkbenchWindow[] win = PlatformUI.getWorkbench()
.getWorkbenchWindows();
if (win.length == 0) {
return;
}
Display display = win[0].getShell().getDisplay();
if (display == null) {
return;
}
ArrayList appearList = new ArrayList(5);
ArrayList revokeList = new ArrayList(5);
String id = null;
int numPerspectives = 0;
int numActionSetPartAssoc = 0;
// push action sets and perspectives to the top because incoming
// actionSetPartAssociations and perspectiveExtensions may depend upon
// them for their bindings.
for (int i = 0; i < delta.length; i++) {
id = delta[i].getExtensionPoint().getSimpleIdentifier();
if (delta[i].getKind() == IExtensionDelta.ADDED) {
if (id.equals(IWorkbenchRegistryConstants.PL_ACTION_SETS)) {
appearList.add(0, delta[i]);
} else if (!id.equals(IWorkbenchRegistryConstants.PL_PERSPECTIVES)
&& !id.equals(IWorkbenchRegistryConstants.PL_VIEWS)
&& !id.equals(IWorkbenchRegistryConstants.PL_ACTION_SETS)) {
appearList.add(appearList.size() - numPerspectives,
delta[i]);
}
} else {
if (delta[i].getKind() == IExtensionDelta.REMOVED) {
if (id
.equals(IWorkbenchRegistryConstants.PL_ACTION_SET_PART_ASSOCIATIONS)) {
revokeList.add(0, delta[i]);
numActionSetPartAssoc++;
} else if (id
.equals(IWorkbenchRegistryConstants.PL_PERSPECTIVES)) {
revokeList.add(numActionSetPartAssoc, delta[i]);
} else {
revokeList.add(delta[i]);
}
}
}
}
Iterator iter = appearList.iterator();
IExtensionDelta extDelta = null;
while (iter.hasNext()) {
extDelta = (IExtensionDelta) iter.next();
extPt = extDelta.getExtensionPoint();
ext = extDelta.getExtension();
asyncAppear(display, extPt, ext);
}
// Suspend support for removing a plug-in until this is more stable
// iter = revokeList.iterator();
// while(iter.hasNext()) {