public final void dispose() {

    if (isDisposed()) {
      return;
    }

    // Store the current title, tooltip, etc. so that anyone that they can be returned to
    // anyone that held on to the disposed reference.
    partName = getPartName();
    contentDescription = getContentDescription();
    tooltip = getTitleToolTip();
    title = getTitle();

    if (state == STATE_CREATION_IN_PROGRESS) {
      IStatus result =
          WorkbenchPlugin.getStatus(
              new PartInitException(
                  NLS.bind(
                      "Warning: Blocked recursive attempt by part {0} to dispose itself during creation", //$NON-NLS-1$
                      getId())));
      WorkbenchPlugin.log(result);
      return;
    }

    doDisposeNestedParts();

    // Disposing the pane disposes the part's widgets. The part's widgets need to be disposed before
    // the part itself.
    if (pane != null) {
      // Remove the dispose listener since this is the correct place for the widgets to get disposed
      Control targetControl = getPane().getControl();
      if (targetControl != null) {
        targetControl.removeDisposeListener(prematureDisposeListener);
      }
      pane.dispose();
    }

    doDisposePart();

    if (pane != null) {
      pane.removeContributions();
    }

    clearListenerList(internalPropChangeListeners);
    clearListenerList(partChangeListeners);
    Image oldImage = image;
    ImageDescriptor oldDescriptor = imageDescriptor;
    image = null;

    state = STATE_DISPOSED;
    imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
    defaultImageDescriptor = ImageDescriptor.getMissingImageDescriptor();
    immediateFirePropertyChange(IWorkbenchPartConstants.PROP_TITLE);
    clearListenerList(propChangeListeners);

    if (oldImage != null) {
      JFaceResources.getResources().destroy(oldDescriptor);
    }
  }
 /** @generated */
 static {
   TOEDiagramEditorPlugin.getInstance()
       .getImageRegistry()
       .put(
           "Navigator?UnknownElement", ImageDescriptor.getMissingImageDescriptor()); // $NON-NLS-1$
   TOEDiagramEditorPlugin.getInstance()
       .getImageRegistry()
       .put("Navigator?ImageNotFound", ImageDescriptor.getMissingImageDescriptor()); // $NON-NLS-1$
 }
 /** @generated */
 static {
   GMFMapDiagramEditorPlugin.getInstance()
       .getImageRegistry()
       .put("Navigator?InvalidElement", ImageDescriptor.getMissingImageDescriptor());
   GMFMapDiagramEditorPlugin.getInstance()
       .getImageRegistry()
       .put("Navigator?UnknownElement", ImageDescriptor.getMissingImageDescriptor());
   GMFMapDiagramEditorPlugin.getInstance()
       .getImageRegistry()
       .put("Navigator?ImageNotFound", ImageDescriptor.getMissingImageDescriptor());
 }
 /** @generated */
 static {
   BreezeModel.diagram
       .part
       .BreezeDiagramEditorPlugin
       .getInstance()
       .getImageRegistry()
       .put(
           "Navigator?UnknownElement", ImageDescriptor.getMissingImageDescriptor()); // $NON-NLS-1$
   BreezeModel.diagram
       .part
       .BreezeDiagramEditorPlugin
       .getInstance()
       .getImageRegistry()
       .put("Navigator?ImageNotFound", ImageDescriptor.getMissingImageDescriptor()); // $NON-NLS-1$
 }
Beispiel #5
0
 public Image getIcon(String imageName) {
   ImageDescriptor descriptor = imageDescriptorFromPlugin(PLUGIN_ID, "icons/" + imageName);
   if (descriptor == null) {
     descriptor = ImageDescriptor.getMissingImageDescriptor();
   }
   return descriptor.createImage();
 }
Beispiel #6
0
  /**
   * Return the image descriptor with the given key.
   *
   * @param key java.lang.String
   * @return org.eclipse.jface.resource.ImageDescriptor
   */
  public static ImageDescriptor getImageDescriptor(String key) {
    if (imageRegistry == null) initializeImageRegistry();
    ImageDescriptor id = imageDescriptors.get(key);
    if (id != null) return id;

    return ImageDescriptor.getMissingImageDescriptor();
  }
 private void updateIcons() {
   if (this.widget instanceof MenuItem) {
     final MenuItem item = (MenuItem) this.widget;
     final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
     try {
       item.setImage(this.icon == null ? null : m.createImage(this.icon));
     } catch (final DeviceResourceException e) {
       this.icon = ImageDescriptor.getMissingImageDescriptor();
       item.setImage(m.createImage(this.icon));
       // as we replaced the failed icon, log the message once.
       StatusManager.getManager()
           .handle(
               new Status(
                   IStatus.ERROR,
                   SharedUIResources.PLUGIN_ID,
                   "Failed to load image",
                   e)); //$NON-NLS-1$
     }
     disposeOldImages();
     this.localResourceManager = m;
   } else if (this.widget instanceof ToolItem) {
     final ToolItem item = (ToolItem) this.widget;
     final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
     item.setDisabledImage(this.disabledIcon == null ? null : m.createImage(this.disabledIcon));
     item.setHotImage(this.hoverIcon == null ? null : m.createImage(this.hoverIcon));
     item.setImage(this.icon == null ? null : m.createImage(this.icon));
     disposeOldImages();
     this.localResourceManager = m;
   }
 }
 /**
  * Returns the image for the element
  *
  * @param editPart the edit part that displays the element
  * @return the image
  */
 public Image getImage(GraphicalEditPart editPart) {
   Element element = getUMLElement(editPart);
   String key = "";
   if (element instanceof NamedElement) {
     key = ((NamedElement) element).getName() + "::" + ((NamedElement) element).getVisibility();
   } else if (element != null) {
     key = element.getClass().getName();
   } else {
     return null;
   }
   ImageRegistry imageRegistry = Activator.getDefault().getImageRegistry();
   Image image = imageRegistry.get(key);
   ImageDescriptor descriptor = null;
   if (image == null) {
     AdapterFactory factory = Activator.getDefault().getItemProvidersAdapterFactory();
     IItemLabelProvider labelProvider =
         (IItemLabelProvider) factory.adapt(getUMLElement(editPart), IItemLabelProvider.class);
     if (labelProvider != null) {
       descriptor =
           ExtendedImageRegistry.getInstance()
               .getImageDescriptor(labelProvider.getImage(getUMLElement(editPart)));
     }
     if (descriptor == null) {
       descriptor = ImageDescriptor.getMissingImageDescriptor();
     }
     imageRegistry.put(key, descriptor);
     image = imageRegistry.get(key);
   }
   return image;
 }
    /*
     * @see CompositeImageDescriptor#drawCompositeImage(int, int)
     */
    @Override
    protected void drawCompositeImage(int width, int height) {
      drawImage(baseImageData, 0, 0);

      for (int i = 0; i < imageDescriptors.length; i++) {
        ImageDescriptor descriptor = imageDescriptors[i];
        if (descriptor == null) {
          continue;
        }

        ImageData imageData = descriptor.getImageData();
        if (imageData == null) {
          imageData = ImageDescriptor.getMissingImageDescriptor().getImageData();
        }

        switch (i) {
          case IDecoration.TOP_LEFT:
            drawImage(imageData, 0, 0);
            break;
          case IDecoration.TOP_RIGHT:
            drawImage(imageData, imageSize.x - imageData.width, 0);
            break;
          case IDecoration.BOTTOM_LEFT:
            drawImage(imageData, 0, imageSize.y - imageData.height);
            break;
          case IDecoration.BOTTOM_RIGHT:
            drawImage(imageData, imageSize.x - imageData.width, imageSize.y - imageData.height);
            break;
        }
      }
    }
 private static ImageDescriptor create(String prefix, String name) {
   try {
     return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
   } catch (MalformedURLException e) {
     return ImageDescriptor.getMissingImageDescriptor();
   }
 }
Beispiel #11
0
  /** Load the generator images. */
  private static void loadGeneratorImages(IConfigurationElement[] cf) {
    int size = cf.length;
    for (int i = 0; i < size; i++) {
      try {
        String name = cf[i].getDeclaringExtension().getContributor().getName();
        String iconPath = cf[i].getAttribute("icon");
        ImageDescriptor imageDescriptor =
            AbstractUIPlugin.imageDescriptorFromPlugin(name, iconPath);
        if (imageDescriptor == null && iconPath != null && iconPath.length() > 0)
          imageDescriptor = ImageDescriptor.getMissingImageDescriptor();

        if (imageDescriptor != null) {
          String[] typeIds = StringUtils.tokenize(cf[i].getAttribute("typeIds"), ",");
          int size2 = typeIds.length;
          for (int j = 0; j < size2; j++) {
            imageRegistry.put(typeIds[j], imageDescriptor);
            imageDescriptors.put(typeIds[j], imageDescriptor);
          }
        }
        Trace.trace(Trace.CONFIG, "  Loaded generatorImage: " + cf[i].getAttribute("id"));
      } catch (Throwable t) {
        Trace.trace(
            Trace.SEVERE, "  Could not load generatorImage: " + cf[i].getAttribute("id"), t);
      }
    }
  }
Beispiel #12
0
  /** Draw the fOverlays for the reciever. */
  protected void drawOverlays(ImageDescriptor[] overlays) {
    Point size = getSize();

    for (int i = 0; i < overlays.length; i++) {
      ImageDescriptor overlay = overlays[i];
      if (overlay == null) continue;
      ImageData overlayData = overlay.getImageData();
      // Use the missing descriptor if it is not there.
      if (overlayData == null)
        overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData();
      switch (i) {
        case TOP_LEFT:
          drawImage(overlayData, 0, 0);
          break;
        case TOP_RIGHT:
          drawImage(overlayData, size.x - overlayData.width, 0);
          break;
        case BOTTOM_LEFT:
          drawImage(overlayData, 0, size.y - overlayData.height);
          break;
        case BOTTOM_RIGHT:
          drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height);
          break;
      }
    }
  }
 /**
  * @param category
  * @return
  */
 public Image getBookCategoryImage(BookCategory category) {
   String key = "image.category." + category.toString();
   ImageRegistry registry = getImageRegistry();
   Image image = registry.get(key);
   if (image == null) {
     return ImageDescriptor.getMissingImageDescriptor().createImage();
   }
   return image;
 }
 /** @generated */
 static {
   hub.top
       .adaptiveSystem
       .diagram
       .part
       .AdaptiveSystemDiagramEditorPlugin
       .getInstance()
       .getImageRegistry()
       .put(
           "Navigator?UnknownElement", ImageDescriptor.getMissingImageDescriptor()); // $NON-NLS-1$
   hub.top
       .adaptiveSystem
       .diagram
       .part
       .AdaptiveSystemDiagramEditorPlugin
       .getInstance()
       .getImageRegistry()
       .put("Navigator?ImageNotFound", ImageDescriptor.getMissingImageDescriptor()); // $NON-NLS-1$
 }
  /**
   * Returns the image descriptor for the icon path specified by the given configuration element.
   *
   * @param iconPath the icon path
   * @param element the configuration element
   * @return the image descriptor
   * @since 3.0
   */
  private ImageDescriptor getImageDescriptor(String iconPath, IConfigurationElement element) {
    String pluginId = element.getContributor().getName();
    Bundle bundle = Platform.getBundle(pluginId);
    if (bundle == null) return null;

    URL url = FileLocator.find(bundle, new Path(iconPath), null);
    if (url != null) return ImageDescriptor.createFromURL(url);

    return ImageDescriptor.getMissingImageDescriptor();
  }
Beispiel #16
0
 private static ImageDescriptor createManaged(String name) {
   try {
     ImageDescriptor result =
         ImageDescriptor.createFromURL(makeIconFileURL(name.substring(NAME_PREFIX_LENGTH)));
     fgAvoidSWTErrorMap.put(name, result);
     return result;
   } catch (MalformedURLException e) {
     return ImageDescriptor.getMissingImageDescriptor();
   }
 }
Beispiel #17
0
 /**
  * Declare an Image in the registry table.
  *
  * @param key The key to use when registering the image
  * @param path The path where the image can be found. This path is relative to where this plugin
  *     class is found (i.e. typically the packages directory)
  */
 private static void declareRegistryImage(String key, String path) {
   ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
   Bundle bundle = Platform.getBundle(IOUIPlugin.PLUGIN_ID);
   URL url = null;
   if (bundle != null) {
     url = FileLocator.find(bundle, new Path(path), null);
     desc = ImageDescriptor.createFromURL(url);
   }
   fgImageRegistry.put(key, desc);
 }
Beispiel #18
0
 public static ImageDescriptor getImageDescriptor(String name) {
   String iconPath = "icons/";
   try {
     URL installURL = getDefault().getBundle().getEntry("/"); // $NON-NLS-1$
     URL url = new URL(installURL, iconPath + name);
     return ImageDescriptor.createFromURL(url);
   } catch (MalformedURLException e) {
     // should not happen
     return ImageDescriptor.getMissingImageDescriptor();
   }
 }
 public final ImageDescriptor createImageDescriptor(String key) {
   try {
     return ImageDescriptor.createFromURL(makeIconFileURL(key));
   } catch (MalformedURLException e) {
     if (parentRegistry == null) {
       return ImageDescriptor.getMissingImageDescriptor();
     } else {
       return parentRegistry.createImageDescriptor(key);
     }
   }
 }
Beispiel #20
0
 @SuppressWarnings("deprecation")
 private static ImageDescriptor createImageDescriptor(String path) {
   URL url = Activator.getDefault().getDescriptor().getInstallURL();
   ImageDescriptor id = null;
   try {
     id = ImageDescriptor.createFromURL(new URL(url, path));
   } catch (Exception e) {
     id = ImageDescriptor.getMissingImageDescriptor();
   }
   return id;
 }
 /**
  * Creates an image descriptor for the given path in a bundle. The path can contain variables like
  * $NL$. If no image could be found, <code>useMissingImageDescriptor</code> decides if either the
  * 'missing image descriptor' is returned or <code>null</code>.
  *
  * @param bundle a bundle
  * @param path path in the bundle
  * @param useMissingImageDescriptor if <code>true</code>, returns the shared image descriptor for
  *     a missing image. Otherwise, returns <code>null</code> if the image could not be found
  * @return an {@link ImageDescriptor}, or <code>null</code> iff there's no image at the given
  *     location and <code>useMissingImageDescriptor</code> is <code>true</code>
  */
 private static ImageDescriptor createImageDescriptor(
     Bundle bundle, IPath path, boolean useMissingImageDescriptor) {
   URL url = FileLocator.find(bundle, path, null);
   if (url != null) {
     return ImageDescriptor.createFromURL(url);
   }
   if (useMissingImageDescriptor) {
     return ImageDescriptor.getMissingImageDescriptor();
   }
   return null;
 }
Beispiel #22
0
  private static ImageDescriptor loadImageDescriptor(String id) {
    String iconPath = "icons/"; // $NON-NLS-1$

    try {
      URL installURL = Activator.getDefault().getBundle().getEntry("/"); // $NON-NLS-1$
      URL url = new URL(installURL, iconPath + id);
      return ImageDescriptor.createFromURL(url);
    } catch (MalformedURLException e) {
      return ImageDescriptor.getMissingImageDescriptor();
    }
  }
  /**
   * Creates an image descriptor from the given imageFilePath and adds the image descriptor to the
   * image descriptor registry. If an image descriptor could not be created, the default "missing"
   * image descriptor is returned but not added to the image descriptor registry.
   *
   * @param imageFilePath
   * @return ImageDescriptor image descriptor for imageFilePath or default "missing" image
   *     descriptor if resource could not be found
   */
  private ImageDescriptor createImageDescriptor(String imageFilePath) {
    ImageDescriptor imageDescriptor =
        AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath);
    if (imageDescriptor != null) {
      getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
    } else {
      imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
    }

    return imageDescriptor;
  }
Beispiel #24
0
 public ImageDescriptor imageDescriptorFromURI(URI iconPath) {
   try {
     return ImageDescriptor.createFromURL(new URL(iconPath.toString()));
   } catch (MalformedURLException e) {
     System.err.println(
         "iconURI \""
             + iconPath.toString()
             + "\" is invalid, a \"missing image\" icon will be shown");
     return ImageDescriptor.getMissingImageDescriptor();
   }
 }
Beispiel #25
0
  public static void setImageDescriptors(IAction action, String type) {
    ImageDescriptor id = create("d", type); // $NON-NLS-1$
    if (id != null) action.setDisabledImageDescriptor(id);

    id = create("c", type); // $NON-NLS-1$
    if (id != null) {
      action.setHoverImageDescriptor(id);
      action.setImageDescriptor(id);
    } else {
      action.setImageDescriptor(ImageDescriptor.getMissingImageDescriptor());
    }
  }
 /** @generated */
 public static ImageDescriptor getImageDescriptor(ENamedElement element) {
   String key = getImageRegistryKey(element);
   ImageDescriptor imageDescriptor = getImageRegistry().getDescriptor(key);
   if (imageDescriptor == null) {
     imageDescriptor = getProvidedImageDescriptor(element);
     if (imageDescriptor == null) {
       imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
     }
     getImageRegistry().put(key, imageDescriptor);
   }
   return imageDescriptor;
 }
Beispiel #27
0
 /**
  * Return the image with the given key.
  *
  * @param key java.lang.String
  * @return org.eclipse.swt.graphics.Image
  */
 public static Image getImage(String key, String keyIfImageNull) {
   if (imageRegistry == null) initializeImageRegistry();
   Image image = imageRegistry.get(key);
   if (image == null) {
     if (keyIfImageNull != null) {
       return getImage(keyIfImageNull, null);
     }
     imageRegistry.put(key, ImageDescriptor.getMissingImageDescriptor());
     image = imageRegistry.get(key);
   }
   return image;
 }
Beispiel #28
0
  public static Image getImage(String pluginId, String path) {
    Image image = JFaceResources.getImageRegistry().get(path);
    if (image == null) {
      ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, path);
      if (descriptor == null) {
        descriptor = ImageDescriptor.getMissingImageDescriptor();
      }
      JFaceResources.getImageRegistry().put(path, image = descriptor.createImage());
    }

    return image;
  }
Beispiel #29
0
 protected Image getImageImage(String path) {
   Image image = JFaceResources.getImageRegistry().get(path);
   if (image == null) {
     ImageDescriptor descriptor =
         AbstractUIPlugin.imageDescriptorFromPlugin(
             "org.reuseware.application.taipan", path); // $NON-NLS-1$
     if (descriptor == null) {
       descriptor = ImageDescriptor.getMissingImageDescriptor();
     }
     JFaceResources.getImageRegistry().put(path, image = descriptor.createImage());
   }
   return image;
 }
  /**
   * Returns the image assiciated with the given image descriptor.
   *
   * @param descriptor the image descriptor for which the registry manages an image
   * @return the image associated with the image descriptor or <code>null</code> if the image
   *     descriptor can't create the requested image.
   */
  public Image get(ImageDescriptor descriptor) {
    if (descriptor == null) descriptor = ImageDescriptor.getMissingImageDescriptor();

    Image result = fRegistry.get(descriptor);
    if (result != null) return result;

    Assert.isTrue(
        fDisplay == SWTUtil.getStandardDisplay(),
        "Allocating image for wrong display."); //$NON-NLS-1$
    result = descriptor.createImage();
    if (result != null) fRegistry.put(descriptor, result);
    return result;
  }