@Override
 public Image loadImage(Class<?> clazz, String path) {
   final Bundle bundle = FrameworkUtil.getBundle(clazz);
   final URL url = FileLocator.find(bundle, new Path(path), null);
   final ImageDescriptor imageDescr = ImageDescriptor.createFromURL(url);
   return imageDescr.createImage();
 }
    /*
     * @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 PaletteContainer createComplexPartsDrawer() {
    PaletteDrawer drawer =
        new PaletteDrawer(
            LogicMessages.LogicPlugin_Category_ComplexParts_Label,
            ImageDescriptor.createFromFile(Circuit.class, "icons/can.gif")); // $NON-NLS-1$

    List entries = new ArrayList();

    CombinedTemplateCreationEntry combined =
        new CombinedTemplateCreationEntry(
            LogicMessages.LogicPlugin_Tool_CreationTool_HalfAdder_Label,
            LogicMessages.LogicPlugin_Tool_CreationTool_HalfAdder_Description,
            LogicDiagramFactory.getHalfAdderFactory(),
            ImageDescriptor.createFromFile(Circuit.class, "icons/halfadder16.gif"), // $NON-NLS-1$
            ImageDescriptor.createFromFile(Circuit.class, "icons/halfadder24.gif") // $NON-NLS-1$
            );
    entries.add(combined);

    combined =
        new CombinedTemplateCreationEntry(
            LogicMessages.LogicPlugin_Tool_CreationTool_FullAdder_Label,
            LogicMessages.LogicPlugin_Tool_CreationTool_FullAdder_Description,
            LogicDiagramFactory.getFullAdderFactory(),
            ImageDescriptor.createFromFile(Circuit.class, "icons/fulladder16.gif"), // $NON-NLS-1$
            ImageDescriptor.createFromFile(Circuit.class, "icons/fulladder24.gif") // $NON-NLS-1$
            );
    entries.add(combined);

    drawer.addAll(entries);
    return drawer;
  }
 /** @param configurationElement */
 private void processSplashElementIcon(IConfigurationElement configurationElement) {
   // Get attribute icon
   String iconImageFilePath = configurationElement.getAttribute(F_ELEMENT_ICON);
   // Abort if an icon attribute was not specified
   if ((iconImageFilePath == null) || (iconImageFilePath.length() == 0)) {
     return;
   }
   // Create a corresponding image descriptor
   ImageDescriptor descriptor =
       AbstractUIPlugin.imageDescriptorFromPlugin(
           configurationElement.getNamespaceIdentifier(), iconImageFilePath);
   // Abort if no corresponding image was found
   if (descriptor == null) {
     return;
   }
   // Create the image
   Image image = descriptor.createImage();
   // Abort if image creation failed
   if (image == null) {
     return;
   }
   // Abort if the image does not have dimensions of 50x50
   if ((image.getBounds().width != F_IMAGE_WIDTH)
       || (image.getBounds().height != F_IMAGE_HEIGHT)) {
     // Dipose of the image
     image.dispose();
     return;
   }
   // Store the image and tooltip
   fImageList.add(image);
 }
 protected void initializeImageRegistry(ImageRegistry registry) {
   registry.put(
       IMG_PHPUNIT,
       ImageDescriptor.createFromURL(resolvePluginResourceURL("icons/full/obj16/phpunit.gif")));
   registry.put(
       IMG_PHPUNIT_TEST,
       ImageDescriptor.createFromURL(resolvePluginResourceURL("icons/full/obj16/test.gif")));
   registry.put(
       IMG_PHPUNIT_TEST_ERROR,
       ImageDescriptor.createFromURL(resolvePluginResourceURL("icons/full/obj16/testerr.gif")));
   registry.put(
       IMG_PHPUNIT_TEST_FAIL,
       ImageDescriptor.createFromURL(resolvePluginResourceURL("icons/full/obj16/testfail.gif")));
   registry.put(
       IMG_PHPUNIT_TEST_IGNORED,
       ImageDescriptor.createFromURL(
           resolvePluginResourceURL("icons/full/obj16/testignored.gif")));
   registry.put(
       IMG_PHPUNIT_TEST_OK,
       ImageDescriptor.createFromURL(resolvePluginResourceURL("icons/full/obj16/testok.gif")));
   registry.put(
       IMG_PHPUNIT_TEST_SUITE,
       ImageDescriptor.createFromURL(resolvePluginResourceURL("icons/full/obj16/tsuite.gif")));
   registry.put(
       IMG_PHPUNIT_TEST_SUITE_ERROR,
       ImageDescriptor.createFromURL(
           resolvePluginResourceURL("icons/full/obj16/tsuiteerror.gif")));
   registry.put(
       IMG_PHPUNIT_TEST_SUITE_FAIL,
       ImageDescriptor.createFromURL(resolvePluginResourceURL("icons/full/obj16/tsuitefail.gif")));
   registry.put(
       IMG_PHPUNIT_TEST_SUITE_OK,
       ImageDescriptor.createFromURL(resolvePluginResourceURL("icons/full/obj16/tsuiteok.gif")));
 }
  /** @param form2 */
  private Composite getPageHeader(Composite parent) {
    final Composite header = new Composite(parent, SWT.FILL);
    final FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    header.setLayout(layout);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(header);

    header.setBackground(parent.getBackground());

    final Label titleImage = new Label(header, SWT.FILL);
    final ImageDescriptor imageDescriptor =
        ImageDescriptor.createFromURL(
            Activator.getDefault().getBundle().getResource("icons/view.png")); // $NON-NLS-1$
    titleImage.setImage(new Image(parent.getDisplay(), imageDescriptor.getImageData()));
    final FormData titleImageData = new FormData();
    final int imageOffset = -titleImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).y / 2;
    titleImageData.top = new FormAttachment(50, imageOffset);
    titleImageData.left = new FormAttachment(0, 10);
    titleImage.setLayoutData(titleImageData);

    final Label title = new Label(header, SWT.WRAP);
    title.setText("View Editor"); // $NON-NLS-1$
    titleFont = new Font(title.getDisplay(), getDefaultFontName(title), 12, SWT.BOLD);
    title.setFont(titleFont);
    title.setForeground(getTitleColor(parent));
    final FormData titleData = new FormData();
    title.setLayoutData(titleData);
    titleData.left = new FormAttachment(titleImage, 5, SWT.DEFAULT);

    return header;
  }
Beispiel #7
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;
      }
    }
  }
 @Inject
 protected void setImages(PluginImageHelper imageHelper) {
   setImageDescriptor(
       ImageDescriptor.createFromImage(imageHelper.getImage("elcl16/arrangeall.gif")));
   setDisabledImageDescriptor(
       ImageDescriptor.createFromImage(imageHelper.getImage("dlcl16/arrangeall.gif")));
 }
 private static ImageDescriptor create(String prefix, String name) {
   try {
     return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
   } catch (MalformedURLException e) {
     return ImageDescriptor.getMissingImageDescriptor();
   }
 }
Beispiel #10
0
  /*
   * Gets and caches an image for a JarEntryFile.
   * The image for a JarEntryFile is retrieved from the EditorRegistry.
   */
  private Image getImageForJarEntry(IStorage element) {
    if (fJarImageMap == null) return getDefaultImage();

    if (element == null || element.getName() == null) return getDefaultImage();

    // Try to find icon for full name
    String name = element.getName();
    Image image = (Image) fJarImageMap.get(name);
    if (image != null) return image;
    IFileEditorMapping[] mappings = getEditorRegistry().getFileEditorMappings();
    int i = 0;
    while (i < mappings.length) {
      if (mappings[i].getLabel().equals(name)) break;
      i++;
    }
    String key = name;
    if (i == mappings.length) {
      // Try to find icon for extension
      IPath path = element.getFullPath();
      if (path == null) return getDefaultImage();
      key = path.getFileExtension();
      if (key == null) return getDefaultImage();
      image = (Image) fJarImageMap.get(key);
      if (image != null) return image;
    }

    // Get the image from the editor registry
    ImageDescriptor desc = getEditorRegistry().getImageDescriptor(name);
    image = desc.createImage();

    fJarImageMap.put(key, image);

    return image;
  }
Beispiel #11
0
  public void testRotatingImagesWithDifferentDepths() {
    Image result1 = null, result2 = null, result3 = null, result4 = null;
    Image img1 =
        ImageDescriptor.createFromFile(getClass(), "icons/bits1.bmp").createImage(); // $NON-NLS-1$
    Image img2 =
        ImageDescriptor.createFromFile(getClass(), "icons/bits4.bmp").createImage(); // $NON-NLS-1$;
    Image img3 =
        ImageDescriptor.createFromFile(getClass(), "icons/bits8.gif").createImage(); // $NON-NLS-1$;
    Image img4 =
        ImageDescriptor.createFromFile(getClass(), "icons/bits24.jpg")
            .createImage(); //$NON-NLS-1$;

    try {
      result1 = ImageUtilities.createRotatedImage(img1);
      result2 = ImageUtilities.createRotatedImage(img2);
      result3 = ImageUtilities.createRotatedImage(img3);
      result4 = ImageUtilities.createRotatedImage(img4);
    } catch (Throwable error) {
      fail(error.toString() + "\n" + error.getStackTrace()[0]); // $NON-NLS-1$
    } finally {
      img1.dispose();
      img2.dispose();
      img3.dispose();
      img4.dispose();
      if (result1 != null && !result1.isDisposed()) result1.dispose();
      if (result2 != null && !result2.isDisposed()) result2.dispose();
      if (result3 != null && !result3.isDisposed()) result3.dispose();
      if (result4 != null && !result4.isDisposed()) result4.dispose();
    }
  }
Beispiel #12
0
 public Image getImage(Object obj) {
   if (obj instanceof IFolder) {
     IFolder folder = (IFolder) obj;
     String name = folder.getName().toLowerCase();
     Image image = imageCache.get(name);
     if (image == null) {
       ImageDescriptor imageDesc = UIActivator.getImageDescriptor("icons/" + name + ".png");
       if (imageDesc != null) {
         image = imageDesc.createImage();
         imageCache.put(name, image);
         return image;
       }
     } else {
       return image;
     }
     // use the folder image as a default
     return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
   } else if (obj instanceof IFile) {
     IFile file = (IFile) obj;
     String fileExt = file.getFileExtension();
     Image image = imageCache.get(fileExt);
     if (image == null) {
       ImageDescriptor imageDesc =
           PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor("." + fileExt);
       image = imageDesc.createImage();
       imageCache.put(fileExt, image);
     }
     return image;
   } else {
     return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
   }
 }
  /** @param args */
  public static void main(String[] args) {
    Display display = new Display();
    JFaceResources.getImageRegistry()
        .put(
            "IMG_1",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/cancel.png")));
    JFaceResources.getImageRegistry()
        .put(
            "IMG_2",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/filesave.png")));
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    new Snippet033CellEditorPerRowPre33(shell);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    display.dispose();
  }
Beispiel #14
0
 public Image getIcon(String imageName) {
   ImageDescriptor descriptor = imageDescriptorFromPlugin(PLUGIN_ID, "icons/" + imageName);
   if (descriptor == null) {
     descriptor = ImageDescriptor.getMissingImageDescriptor();
   }
   return descriptor.createImage();
 }
 private Image createMyImage(String urlPath) {
   ImageDescriptor imgDescriptor = null;
   imgDescriptor =
       JsonEditorPlugin.imageDescriptorFromPlugin(
           JsonEditorPlugin.getDefault().getBundle().getSymbolicName(), urlPath);
   return imgDescriptor.createImage();
 }
  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);
    }
  }
 private Image getOpenPerspectiveImage() {
   if (perspectiveImage == null || perspectiveImage.isDisposed()) {
     ImageDescriptor desc =
         WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_PAGE);
     perspectiveImage = desc.createImage();
   }
   return perspectiveImage;
 }
  public static Image getImage(String imagePath) {

    ImageDescriptor imageDescriptor =
        AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, imagePath);
    Image image = imageDescriptor.createImage();

    return image;
  }
 /**
  * Create an Image associated to the editor used to render the specified pageIdentifier
  *
  * @return
  */
 public Image createEditorIcon(Object pageIdentifier) {
   ImageDescriptor imageDescriptor = editorDescriptor.getIcon();
   if (imageDescriptor == null) {
     return null;
   }
   Image image = imageDescriptor.createImage();
   return image;
 }
 private ImageData getImageData(ImageDescriptor descriptor) {
   ImageData data = descriptor.getImageData(); // see bug 51965: getImageData can return null
   if (data == null) {
     data = DEFAULT_IMAGE_DATA;
     System.err.println("Image data not available: " + descriptor.toString()); // $NON-NLS-1$
   }
   return data;
 }
 /** @generated */
 static {
   TOEDiagramEditorPlugin.getInstance()
       .getImageRegistry()
       .put(
           "Navigator?UnknownElement", ImageDescriptor.getMissingImageDescriptor()); // $NON-NLS-1$
   TOEDiagramEditorPlugin.getInstance()
       .getImageRegistry()
       .put("Navigator?ImageNotFound", ImageDescriptor.getMissingImageDescriptor()); // $NON-NLS-1$
 }
 static {
   String iconPath = "icons/";
   imageRegistry.put(
       CHECKED_IMAGE,
       ImageDescriptor.createFromFile(TefkatPlugin.class, iconPath + CHECKED_IMAGE + ".gif"));
   imageRegistry.put(
       UNCHECKED_IMAGE,
       ImageDescriptor.createFromFile(TefkatPlugin.class, iconPath + UNCHECKED_IMAGE + ".gif"));
 }
Beispiel #23
0
 public static Image getImage(String path) {
   Image img = (Image) hmImage.get(path);
   if (img == null) {
     ImageDescriptor imgDesc = getImageDesc(path);
     img = imgDesc.createImage();
     hmImage.put(path, img);
   }
   return img;
 }
 private ImageData getImageData(ImageDescriptor descriptor) {
   ImageData data = descriptor.getImageData(); // see bug 51965: getImageData can return null
   if (data == null) {
     data = DEFAULT_IMAGE_DATA;
     DLTKUIPlugin.logErrorMessage(
         "Image data not available: " + descriptor.toString()); // $NON-NLS-1$
   }
   return data;
 }
  @Override
  public Image getImage(Object element) {
    if (element instanceof Folder) {
      return m_imagedescriptorfolder.createImage();
    } else if (element instanceof Property) {
      return m_imagedescriptorproperty.createImage();
    }

    return null;
  }
 private void setRemoveInfo(IAction action) {
   action.setImageDescriptor(
       ImageDescriptor.createFromURL(
           Plugin.getDefault().getBundle().getEntry("/icons/full/obj16/delete_enabled.gif")));
   action.setDisabledImageDescriptor(
       ImageDescriptor.createFromURL(
           Plugin.getDefault().getBundle().getEntry("/icons/full/obj16/delete_disabled.gif")));
   action.setToolTipText("Remove the selected object");
   action.setText("Delete");
 }
 private void setScriptInfo(IAction action) {
   action.setImageDescriptor(
       ImageDescriptor.createFromURL(
           Plugin.getDefault().getBundle().getEntry("/icons/full/obj16/new_script_enabled.gif")));
   action.setDisabledImageDescriptor(
       ImageDescriptor.createFromURL(
           Plugin.getDefault().getBundle().getEntry("/icons/full/obj16/new_script_disabled.gif")));
   action.setToolTipText("Add a script action");
   action.setText("New Script");
 }
Beispiel #28
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();
   }
 }
  /** Lazily initializes image map. */
  public static Image getImage(ImageDescriptor imageDescriptor) {
    ImageRegistry imageRegistry = getImageRegistry();

    Image image = imageRegistry.get("" + imageDescriptor.hashCode()); // $NON-NLS-1$
    if (image == null) {
      image = imageDescriptor.createImage();
      imageRegistry.put("" + imageDescriptor.hashCode(), image); // $NON-NLS-1$
    }
    return image;
  }
  /**
   * 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();
  }