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

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

Introduction

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

Prototype

public static ImageRegistry getImageRegistry() 

Source Link

Document

Returns the image registry for JFace itself.

Usage

From source file:net.enilink.komma.edit.ui.dialogs.FilteredTree.java

License:Open Source License

/**
 * Create the button that clears the text.
 * //from  ww w.j  a  v  a 2s  .co  m
 * @param parent
 *            parent <code>Composite</code> of toolbar button
 */
private void createClearText(Composite parent) {
    // only create the button if the text widget doesn't support one
    // natively
    if ((filterText.getStyle() & SWT.CANCEL) == 0) {
        filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
        filterToolBar.createControl(parent);

        IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$
            /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.jface.action.Action#run()
             */
            public void run() {
                clearText();
            }
        };

        clearTextAction.setToolTipText("Clear");
        clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON));
        clearTextAction
                .setDisabledImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(DCLEAR_ICON));

        filterToolBar.add(clearTextAction);
    }
}

From source file:net.officefloor.eclipse.common.dialog.input.impl.BeanListInput.java

License:Open Source License

/**
 * Obtains the check box image.//from w  w  w .  ja  v a2 s  .  com
 * 
 * @param tableViewer
 *            {@link TableViewer}.
 * @param type
 *            Type of image.
 * @return {@link Image} for the check box.
 */
private Image getCheckboxImage(TableViewer tableViewer, boolean type) {

    /*
     * Method code derived from:
     * 
     * http://tom-eclipse-dev.blogspot.com.au/2007/01/tableviewers-and-
     * nativelooking.html
     */

    // Obtain the control for the table viewer
    Control control = tableViewer.getControl();

    // Obtain the image registry key
    String imageRegistryKey = (type ? "CHECKED" : "UNCHECKED");

    // Lazy create the image
    Image image = JFaceResources.getImageRegistry().get(imageRegistryKey);
    if (image != null) {
        return image;
    }

    // Colour to use for transparency
    Color greenScreen = new Color(control.getDisplay(), 222, 223, 224);

    // Create shell to screen capture the image
    Shell shell = new Shell(control.getShell(), SWT.NO_TRIM | SWT.NO_BACKGROUND);
    shell.setBackground(greenScreen);
    Button button = new Button(shell, SWT.CHECK);
    button.setBackground(greenScreen);
    button.setSelection(type);
    Point buttonSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    // Stop image being stretched by width
    buttonSize.x = Math.max(buttonSize.x - 1, buttonSize.y - 1);
    buttonSize.y = Math.max(buttonSize.x - 1, buttonSize.y - 1);
    button.setSize(buttonSize);
    shell.setSize(buttonSize);

    // Remove focus highlighting
    button.setEnabled(false);

    // Open shell and take the screen shot
    shell.open();
    button.setEnabled(true); // re-enable
    while (shell.getDisplay().readAndDispatch()) {
        // Ensure open and displaying for screen shot
    }
    GC gc = new GC(shell);
    Image tempImage = new Image(control.getDisplay(), buttonSize.x, buttonSize.y);
    gc.copyArea(tempImage, 0, 0);
    gc.dispose();
    shell.close();

    // Make the background of image transparent
    ImageData imageData = tempImage.getImageData();
    imageData.transparentPixel = imageData.palette.getPixel(greenScreen.getRGB());

    // Create and register the image
    image = new Image(control.getDisplay(), imageData);
    JFaceResources.getImageRegistry().put(imageRegistryKey, image);

    // Clean up temporary image
    tempImage.dispose();

    // Return the image
    return image;
}

From source file:net.officefloor.eclipse.skin.standard.woof.StandardAccessFigure.java

License:Open Source License

/**
 * Initiate./* ww w. ja v a  2 s .co m*/
 * 
 * @param context
 *            {@link AccessFigureContext}.
 */
public StandardAccessFigure(AccessFigureContext context) {

    final Color titleBarTopColour = new Color(null, 255, 248, 220);
    final Color titleBarBottomColour = new Color(null, 131, 76, 36);

    // Create the rounded rectangle container
    RoundedRectangle container = new RoundedRectangle();
    NoSpacingGridLayout containerLayout = new NoSpacingGridLayout(1);
    container.setLayoutManager(containerLayout);
    container.setBackgroundColor(titleBarTopColour);
    container.setOutline(false);

    // Create the access image
    final String ACCESS_IMAGE_KEY = WoofPlugin.PLUGIN_ID + ".access";
    Image accessImage = JFaceResources.getImageRegistry().get(ACCESS_IMAGE_KEY);
    if (accessImage == null) {
        // Create and register the image
        ImageDescriptor secureImageData = WoofPlugin.getImageDescriptor("icons/key.png");
        accessImage = secureImageData.createImage();
        JFaceResources.getImageRegistry().put(ACCESS_IMAGE_KEY, accessImage);
    }

    // Add the title bar
    TitleBarFigure titleBar = new TitleBarFigure(titleBarTopColour, titleBarBottomColour,
            new ImageFigure(accessImage));
    container.add(titleBar);
    containerLayout.setConstraint(titleBar, new GridData(SWT.FILL, 0, true, false));

    // Provide window border to content
    Figure contentPane = new Figure();
    contentPane.setLayoutManager(new NoSpacingGridLayout(1));
    contentPane.setBorder(new MarginBorder(2, 2, 2, 2));
    container.add(contentPane);
    containerLayout.setConstraint(contentPane, new GridData(SWT.FILL, 0, true, false));

    // Specify the figures
    this.setFigure(container);
    this.setContentPane(contentPane);
}

From source file:net.officefloor.eclipse.skin.standard.woof.StandardTemplateFigure.java

License:Open Source License

/**
 * Initiate.//from  w w  w  .  j  a v a2  s  .c  o m
 * 
 * @param context
 *            {@link TemplateFigureContext}.
 */
public StandardTemplateFigure(TemplateFigureContext context) {

    // Colours
    final Color titleBarTextColor = new Color(null, 0, 0, 0);
    final Color titleBarTopColour = new Color(null, 203, 235, 255);
    final Color titleBarBottomColour = new Color(null, 0, 139, 255);
    final Color windowColour = new Color(null, 229, 229, 229);
    final Color contentColour = new Color(null, 240, 249, 255);

    // Create the figure
    Figure figure = new Figure();
    NoSpacingGridLayout layout = new NoSpacingGridLayout(2);
    figure.setLayoutManager(layout);

    // Link to template
    ConnectorFigure templateInput = new ConnectorFigure(ConnectorDirection.WEST,
            CommonWoofColours.CONNECTIONS());
    templateInput.setBorder(new MarginBorder(10, 0, 0, 0));
    ConnectionAnchor templateInputAnchor = templateInput.getConnectionAnchor();
    this.registerConnectionAnchor(WoofTemplateOutputToWoofTemplateModel.class, templateInputAnchor);
    this.registerConnectionAnchor(WoofSectionOutputToWoofTemplateModel.class, templateInputAnchor);
    this.registerConnectionAnchor(WoofAccessOutputToWoofTemplateModel.class, templateInputAnchor);
    this.registerConnectionAnchor(WoofExceptionToWoofTemplateModel.class, templateInputAnchor);
    layout.setConstraint(templateInput, new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    figure.add(templateInput);

    // Create the rounded rectangle container
    final RoundedRectangle window = new RoundedRectangle();
    NoSpacingGridLayout windowLayout = new NoSpacingGridLayout(1);
    window.setLayoutManager(windowLayout);
    window.setBackgroundColor(windowColour);
    window.setOutline(false);
    figure.add(window);

    // Create the label for the template name
    this.templateNameFigure = new Label(context.getTemplateDisplayName());
    this.templateNameFigure.setForegroundColor(titleBarTextColor);

    // Create the image for identifying the template as secure
    final String SECURE_IMAGE_KEY = WoofPlugin.PLUGIN_ID + ".secure";
    Image secureImage = JFaceResources.getImageRegistry().get(SECURE_IMAGE_KEY);
    if (secureImage == null) {
        // Create and register the image
        ImageDescriptor secureImageData = WoofPlugin.getImageDescriptor("icons/padlock.png");
        secureImage = secureImageData.createImage();
        JFaceResources.getImageRegistry().put(SECURE_IMAGE_KEY, secureImage);
    }
    this.secureFigure = new ImageFigure(secureImage);
    this.secureFigure.setVisible(context.isTemplateSecure());

    // Create the title bar for URI and security
    TitleBarFigure titleBar = new TitleBarFigure(titleBarTopColour, titleBarBottomColour,
            this.templateNameFigure, this.secureFigure);
    window.add(titleBar);
    windowLayout.setConstraint(titleBar, new GridData(SWT.FILL, 0, true, false));

    // Provide window border to content
    Figure contentPaneWrap = new Figure();
    NoSpacingGridLayout contentPaneWrapLayout = new NoSpacingGridLayout(1);
    contentPaneWrap.setLayoutManager(contentPaneWrapLayout);
    contentPaneWrap.setBorder(new MarginBorder(4, 4, 4, 4));
    window.add(contentPaneWrap);
    windowLayout.setConstraint(contentPaneWrap, new GridData(SWT.FILL, 0, true, false));

    // Add content pane
    RectangleFigure contentPane = new RectangleFigure();
    contentPane.setLayoutManager(new NoSpacingToolbarLayout(false));
    contentPane.setBorder(new MarginBorder(2, 2, 2, 2));
    contentPane.setBackgroundColor(contentColour);
    contentPane.setOutline(false);
    contentPaneWrap.add(contentPane);
    contentPaneWrapLayout.setConstraint(contentPane, new GridData(SWT.FILL, 0, true, false));

    // Specify the figures
    this.setFigure(figure);
    this.setContentPane(contentPane);
}

From source file:net.refractions.udig.style.sld.editor.internal.FilteredTree.java

License:Open Source License

/**
 * Create the button that clears the text.
 * // www.  ja  v a 2s .  c o  m
 * @param filterToolBar
 */
private void createClearText(ToolBarManager filterToolBar) {

    IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$
        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.jface.action.Action#run()
         */
        public void run() {
            clearText();
        }
    };

    clearTextAction.setToolTipText(Messages.FilteredTree_clear);
    clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON));
    clearTextAction.setDisabledImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(DCLEAR_ICON));

    filterToolBar.add(clearTextAction);
}

From source file:org.apache.directory.studio.ApplicationWorkbenchAdvisor.java

License:Apache License

/**
 * Performs arbitrary initialization before the workbench starts running.<br />
 * <br />// w  ww . jav  a2 s.  co  m
 * This method is called during workbench initialization prior to any windows 
 * being opened. Clients must not call this method directly (although super calls 
 * are okay). The default implementation does nothing. Subclasses may override. 
 * Typical clients will use the configurer passed in to tweak the workbench. If 
 * further tweaking is required in the future, the configurer may be obtained using 
 * getWorkbenchConfigurer
 */
public void initialize(IWorkbenchConfigurer configurer) {
    //enable the save/restore windows size & position feature
    configurer.setSaveAndRestore(true);

    //enable help button in dialogs 
    TrayDialog.setDialogHelpAvailable(true);
    ImageRegistry reg = JFaceResources.getImageRegistry();
    ImageDescriptor helpImage = PlatformUI.getWorkbench().getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_LCL_LINKTO_HELP);
    reg.put(Dialog.DLG_IMG_HELP, helpImage);
}

From source file:org.bonitasoft.studio.migration.ui.view.CheckboxLabelProvider.java

License:Open Source License

public CheckboxLabelProvider(Control control) {
    if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY) == null) {
        JFaceResources.getImageRegistry().put(UNCHECK_KEY, makeShot(control, false));
        JFaceResources.getImageRegistry().put(CHECKED_KEY, makeShot(control, true));
    }/*from  w w  w.ja  v a2s  .co m*/
}

From source file:org.csstudio.apputil.ui.swt.CheckBoxImages.java

License:Open Source License

/** Singleton */
private CheckBoxImages(final Control control) {
    final ImageRegistry registry = JFaceResources.getImageRegistry();
    if (registry.getDescriptor(CHECKED_KEY) != null)
        return;/*from  w  w w . j  a  va2s. com*/
    if (use_fixed_images) {
        registry.put(CHECKED_KEY, Activator.getImageDescriptor("icons/checked.gif"));
        registry.put(UNCHECK_KEY, Activator.getImageDescriptor("icons/unchecked.gif"));
    } else {
        registry.put(UNCHECK_KEY, makeShot(control, false));
        registry.put(CHECKED_KEY, makeShot(control, true));
    }
}

From source file:org.csstudio.apputil.ui.swt.CheckBoxImages.java

License:Open Source License

/** @return Image of selected or unselected button image */
public Image getImage(final boolean selected) {
    return selected ? JFaceResources.getImageRegistry().get(CHECKED_KEY)
            : JFaceResources.getImageRegistry().get(UNCHECK_KEY);
}

From source file:org.eclipse.birt.chart.examples.view.util.UIHelper.java

License:Open Source License

/**
 * This is a convenience method to get an imgIcon from a URL.
 * /*from   www. j  a  va2 s.  co m*/
 * @param sPluginRelativePath
 *            The URL for the imgIcon.
 * @return The imgIcon represented by the given URL.
 * @see #setImageCached( boolean )
 */
public static Image getImage(String sPluginRelativePath) {
    ImageRegistry registry = JFaceResources.getImageRegistry();
    Image image = registry.get(sPluginRelativePath);
    if (image == null) {
        image = createImage(sPluginRelativePath);
        registry.put(sPluginRelativePath, image);
    }
    return image;
}