예제 #1
0
  protected static void handleGeneratorImageDelta(IExtensionDelta delta) {
    if (imageRegistry == null) // not loaded yet
    return;

    IConfigurationElement[] cf = delta.getExtension().getConfigurationElements();

    if (delta.getKind() == IExtensionDelta.ADDED) loadGeneratorImages(cf);
    else {
      int size = cf.length;
      for (int i = 0; i < size; i++) {
        String typeId = cf[i].getAttribute("typeIds");
        imageRegistry.remove(typeId);
        imageDescriptors.remove(typeId);
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent)
   */
  public void registryChanged(final IRegistryChangeEvent event) {
    Display display = Display.getDefault();
    if (part != null) {
      display = part.getSite().getPage().getWorkbenchWindow().getWorkbench().getDisplay();
    }
    // check the delta to see if there are any viewer contribution changes.  if so, null our builder
    // to cause reparsing on the next menu show
    IExtensionDelta[] deltas = event.getExtensionDeltas();
    for (int i = 0; i < deltas.length; i++) {
      IExtensionDelta delta = deltas[i];
      IExtensionPoint extensionPoint = delta.getExtensionPoint();
      if (extensionPoint.getContributor().getName().equals(WorkbenchPlugin.PI_WORKBENCH)
          && extensionPoint
              .getSimpleIdentifier()
              .equals(IWorkbenchRegistryConstants.PL_POPUP_MENU)) {

        boolean clearPopups = false;
        IConfigurationElement[] elements = delta.getExtension().getConfigurationElements();
        for (int j = 0; j < elements.length; j++) {
          IConfigurationElement element = elements[j];
          if (element.getName().equals(IWorkbenchRegistryConstants.TAG_VIEWER_CONTRIBUTION)) {
            clearPopups = true;
            break;
          }
        }

        if (clearPopups) {
          display.syncExec(
              new Runnable() {
                public void run() {
                  clearStaticActions();
                }
              });
        }
      }
    }
  }