Example usage for org.eclipse.jface.resource JFaceResources getResources

List of usage examples for org.eclipse.jface.resource JFaceResources getResources

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getResources.

Prototype

public static ResourceManager getResources() 

Source Link

Document

Returns the ResourceManager for the current display.

Usage

From source file:org.eclipse.ui.internal.WorkbenchPartReference.java

License:Open Source License

protected void setImageDescriptor(ImageDescriptor descriptor) {
    if (Util.equals(imageDescriptor, descriptor)) {
        return;/*from w  w w .j  av a2  s  . com*/
    }

    Image oldImage = image;
    ImageDescriptor oldDescriptor = imageDescriptor;
    image = null;
    imageDescriptor = descriptor;

    // Don't queue events triggered by image changes. We'll dispose the image
    // immediately after firing the event, so we need to fire it right away.
    immediateFirePropertyChange(IWorkbenchPartConstants.PROP_TITLE);
    // If we had allocated the old image, deallocate it now (AFTER we fire the property change 
    // -- listeners may need to clean up references to the old image)
    if (oldImage != null) {
        JFaceResources.getResources().destroy(oldDescriptor);
    }
}

From source file:org.eclipse.ui.internal.WorkbenchPartReference.java

License:Open Source License

public final Image getTitleImage() {
    if (isDisposed()) {
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
    }//from  www.  j  a v a2s.c om

    if (image == null) {
        image = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
    }
    return image;
}

From source file:org.eclipse.ui.menus.CommandContributionItem.java

License:Open Source License

private void updateIcons() {
    if (widget instanceof MenuItem) {
        MenuItem item = (MenuItem) widget;
        LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
        try {//from w  w  w.  ja v a 2 s .  c o m
            item.setImage(icon == null ? null : m.createImage(icon));
        } catch (DeviceResourceException e) {
            icon = ImageDescriptor.getMissingImageDescriptor();
            item.setImage(m.createImage(icon));
            // as we replaced the failed icon, log the message once.
            StatusManager.getManager()
                    .handle(new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, "Failed to load image", e)); //$NON-NLS-1$
        }
        disposeOldImages();
        localResourceManager = m;
    } else if (widget instanceof ToolItem) {
        ToolItem item = (ToolItem) widget;
        LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
        item.setDisabledImage(disabledIcon == null ? null : m.createImage(disabledIcon));
        item.setHotImage(hoverIcon == null ? null : m.createImage(hoverIcon));
        item.setImage(icon == null ? null : m.createImage(icon));
        disposeOldImages();
        localResourceManager = m;
    }
}

From source file:org.eclipse.ui.part.IntroPart.java

License:Open Source License

/**
 * The <code>IntroPart</code> implementation of this
 * <code>IIntroPart</code> method disposes the title image loaded by
 * <code>setInitializationData</code>. Subclasses may extend.
 *//* www  .j  av a2  s  . co m*/
public void dispose() {
    if (titleImage != null) {
        JFaceResources.getResources().destroyImage(imageDescriptor);
        titleImage = null;
    }

    // Clear out the property change listeners as we
    // should not be notifying anyone after the part
    // has been disposed.
    clearListeners();
}

From source file:org.eclipse.ui.part.IntroPart.java

License:Open Source License

/**
 * The <code>IntroPart</code> implementation of this
 * <code>IExecutableExtension</code> records the configuration element in
 * and internal state variable (accessible via <code>getConfigElement</code>).
 * It also loads the title image, if one is specified in the configuration
 * element. Subclasses may extend./*from  w  w  w .j  ava  2  s. co m*/
 * 
 * Should not be called by clients. It is called by the core plugin when
 * creating this executable extension.
 */
public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {

    // Save config element.
    configElement = cfig;

    titleLabel = cfig.getAttribute(IWorkbenchRegistryConstants.ATT_LABEL);

    // Icon.
    String strIcon = cfig.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
    if (strIcon == null) {
        return;
    }

    imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(configElement.getNamespace(), strIcon);

    if (imageDescriptor == null) {
        return;
    }

    Image image = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
    titleImage = image;
}

From source file:org.eclipse.ui.part.WorkbenchPart.java

License:Open Source License

/**
 * The <code>WorkbenchPart</code> implementation of this 
 * <code>IWorkbenchPart</code> method disposes the title image
 * loaded by <code>setInitializationData</code>. Subclasses may extend.
 *///ww  w  . java2  s. c o  m
public void dispose() {
    if (imageDescriptor != null) {
        JFaceResources.getResources().destroyImage(imageDescriptor);
    }

    // Clear out the property change listeners as we
    // should not be notifying anyone after the part
    // has been disposed.
    clearListeners();
    partChangeListeners.clear();
}

From source file:org.eclipse.ui.part.WorkbenchPart.java

License:Open Source License

/**
 * {@inheritDoc}/*from   w w  w  .j a v a2  s.c  om*/
 * The <code>WorkbenchPart</code> implementation of this
 * <code>IExecutableExtension</code> records the configuration element in
 * and internal state variable (accessible via <code>getConfigElement</code>).
 * It also loads the title image, if one is specified in the configuration element.
 * Subclasses may extend.
 * 
 * Should not be called by clients. It is called by the core plugin when creating
 * this executable extension.
 */
public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {

    // Save config element.
    configElement = cfig;

    // Part name and title.  
    partName = Util.safeString(cfig.getAttribute("name"));//$NON-NLS-1$;
    title = partName;

    // Icon.
    String strIcon = cfig.getAttribute("icon");//$NON-NLS-1$
    if (strIcon == null) {
        return;
    }

    imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(configElement.getNamespace(), strIcon);

    if (imageDescriptor == null) {
        return;
    }

    titleImage = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
}

From source file:org.eclipse.ui.part.WorkbenchPart.java

License:Open Source License

/**
 * Sets or clears the title image of this part.
 *
 * @param titleImage the title image, or <code>null</code> to clear
 *//*ww  w . j av  a2 s .co  m*/
protected void setTitleImage(Image titleImage) {
    Assert.isTrue(titleImage == null || !titleImage.isDisposed());
    //Do not send changes if they are the same
    if (this.titleImage == titleImage) {
        return;
    }
    this.titleImage = titleImage;
    firePropertyChange(IWorkbenchPart.PROP_TITLE);
    if (imageDescriptor != null) {
        JFaceResources.getResources().destroyImage(imageDescriptor);
        imageDescriptor = null;
    }
}

From source file:org.eclipse.ui.tests.manual.SaveablesView.java

License:Open Source License

/**
 * The constructor.
 */
public SaveablesView() {
    this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
}

From source file:org.eclipse.ui.views.bookmarkexplorer.BookmarkLabelProvider.java

License:Open Source License

public BookmarkLabelProvider(BookmarkNavigator view) {
    desc = IDEWorkbenchPlugin.getIDEImageDescriptor("obj16/bkmrk_tsk.gif"); //$NON-NLS-1$
    image = JFaceResources.getResources().createImageWithDefault(desc);
}