Example usage for org.eclipse.jface.resource ImageDescriptor createImage

List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ImageDescriptor createImage.

Prototype

public Image createImage() 

Source Link

Document

Creates and returns a new SWT image for this image descriptor.

Usage

From source file:fr.liglab.adele.cilia.workbench.monitoring.topologyview.providers.CiliaLabelProvider.java

License:Apache License

public Image getImage(Object obj) {
    String imageName;//  ww w  .  j  a v a  2s  .c om
    if (obj instanceof MonitoredApplication)
        imageName = "icons/16/start.png";
    else if (obj instanceof CiliaContextReadOnly)
        imageName = "icons/16/chain.png";
    else if (obj instanceof ChainReadOnly)
        imageName = "icons/16/chain.png";
    else if (obj instanceof AdapterReadOnly) {
        AdapterReadOnly adapter = (AdapterReadOnly) obj;

        // adapter.getPattern().equal(PatternType.IN_ONLY)
        // adapter.getPattern().equal(PatternType.OUT_ONLY)

        int in = adapter.getInBindings() == null ? 0 : adapter.getInBindings().length;
        int out = adapter.getOutBindings() == null ? 0 : adapter.getOutBindings().length;

        if (in == 0 && out != 0)
            imageName = "icons/16/adapterIn.png";
        else if (in != 0 && out == 0)
            imageName = "icons/16/adapterOut.png";
        else
            imageName = "icons/16/mediator.png";
    } else if (obj instanceof MediatorReadOnly)
        imageName = "icons/16/mediator.png";
    else if (obj instanceof EntityConnectionData) {
        imageName = null;
    } else
        throw new RuntimeException("Unsupported type: " + obj.getClass());

    if (imageName != null) {
        Bundle bundle = Activator.getDefault().getBundle();
        URL url = FileLocator.find(bundle, new Path(imageName), null);
        try {
            url = new URL("platform:/plugin/fr.liglab.adele.cilia.workbench.common/" + imageName);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url);

        return imageDesc.createImage();
    } else
        return null;
}

From source file:fr.lip6.move.coloane.core.ui.views.TreeLabelProvider.java

License:Open Source License

/** {@inheritDoc} */
@Override//from  ww w  .  j  ava  2  s.c  o  m
public Image getImage(Object element) {
    if (element instanceof Tree) {
        ImageDescriptor descriptor = ((Tree) element).getIcon();
        if (descriptor != null) {
            Image icon = descriptor.createImage();
            images.add(icon);
            return icon;
        }
    }
    return null;
}

From source file:fr.obeo.intent.specification.parser.SpecificationParserActivator.java

License:Open Source License

/**
 * Returns the image at the given plug-in relative path ; if this image
 * hasn't been loaded yet, load this image and add it to the imageMap.
 * //from   www  .j a  va  2s  .c  o  m
 * @param path
 *            path of the image to load (plug-in relative path)
 * @return the image corresponding to the given path
 */
public Image getImage(final String path) {
    Image result = imageMap.get(path);
    if (result == null) {
        ImageDescriptor descriptor = getImageDescriptor(path);
        if (descriptor != null) {
            result = descriptor.createImage();
            imageMap.put(path, result);
        }
    }
    return result;
}

From source file:fr.opensagres.eclipse.jsbuild.internal.ui.views.actions.BuildFileOpenWithMenu.java

License:Open Source License

/**
 * Returns an image to show for the corresponding editor descriptor.
 * /*  w w  w.  j  a v  a 2 s.com*/
 * @param editorDesc
 *            the editor descriptor, or <code>null</code> for the system
 *            editor
 * @return the image or <code>null</code>
 */
private Image getImage(IEditorDescriptor editorDesc) {
    ImageDescriptor imageDesc = getImageDescriptor(editorDesc);
    if (imageDesc == null) {
        return null;
    }
    Image image = imageCache.get(imageDesc);
    if (image == null) {
        image = imageDesc.createImage();
        imageCache.put(imageDesc, image);
    }
    return image;
}

From source file:gda.rcp.views.StageCompositeFactory.java

License:Open Source License

public Control getTabControl(Composite parent) {
    Composite cmp;/*from w  w  w .jav a 2 s .  com*/
    if (label != null) {
        Group translationGroup = new Group(parent, SWT.SHADOW_NONE);
        translationGroup.setText(label);
        cmp = translationGroup;
    } else {
        cmp = new Composite(parent, SWT.NONE);
    }
    GridDataFactory.fillDefaults().applyTo(cmp);
    GridLayoutFactory.fillDefaults().margins(1, 1).spacing(1, 1).applyTo(cmp);

    Composite c1 = new Composite(cmp, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(1, 1).spacing(2, 2).numColumns(2).applyTo(c1);
    Label label2 = new Label(c1, SWT.NONE);
    label2.setText("Stop all motors on this stage");
    GridDataFactory.swtDefaults().applyTo(label2);
    Button button = new Button(c1, SWT.PUSH);
    ImageDescriptor descr = GDAClientActivator.getImageDescriptor("icons/stop.png");
    if (descr != null) {
        image = descr.createImage();
        button.setImage(image);

    }
    button.setToolTipText("Stop all the motors on this stage");
    GridDataFactory.swtDefaults().applyTo(button);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            for (StageCompositeDefinition s : stageCompositeDefinitions) {
                try {
                    s.scannable.stop();
                } catch (DeviceException e1) {
                    logger.error("Error stopping " + s.scannable.getName(), e1);
                }
            }
        }

    });

    Label sep = new Label(cmp, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(sep);
    for (StageCompositeDefinition s : stageCompositeDefinitions) {

        try {
            Composite motorComp = new Composite(cmp, SWT.NONE);
            GridDataFactory.fillDefaults().grab(true, false).applyTo(motorComp);
            motorComp.setLayout(new GridLayout(2, false));

            Label label = new Label(motorComp, SWT.NONE);
            label.setText(s.label != null ? s.label : s.scannable.getName());
            GridDataFactory.swtDefaults().hint(labelWidth != null ? labelWidth : 120, SWT.DEFAULT)
                    .applyTo(label);

            MotorPositionEditorControl motorPosControl;
            motorPosControl = new MotorPositionEditorControl(motorComp, SWT.NONE,
                    new ScannableWrapper(s.scannable), true, false);
            motorPosControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
            double d = s.stepSize * Math.pow(10, s.getDecimalPlaces());
            motorPosControl.setDigits(s.getDecimalPlaces());
            motorPosControl.setIncrement((int) d);
        } catch (Exception e1) {
            logger.error("Error creating control for '", s.scannable.getName() + "'");
        }

        Label sep1 = new Label(cmp, SWT.SEPARATOR | SWT.HORIZONTAL);
        GridDataFactory.fillDefaults().grab(true, false).applyTo(sep1);
    }

    cmp.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (image != null) {
                image.dispose();
                image = null;
            }

        }
    });
    return cmp;
}

From source file:gov.nasa.arc.spife.core.plan.editor.timeline.TimelinePlugin.java

License:Open Source License

public Image getIcon(String imageName) {
    ImageDescriptor descriptor = imageDescriptorFromPlugin(ID, "icons/" + imageName);
    if (descriptor == null) {
        descriptor = ImageDescriptor.getMissingImageDescriptor();
    }/*from  w w w.  ja  v a 2s  .  c  o  m*/
    return descriptor.createImage();
}

From source file:gov.nasa.arc.spife.core.plan.rules.view.RuleIcons.java

License:Open Source License

RuleIcons(String iconPath) {
    ImageDescriptor descriptor = Activator.getImageDescriptor("icons/" + iconPath);
    if (descriptor != null) {
        image = descriptor.createImage();
    } else {//from  ww w .j  a  v a2  s  .  c  o m
        image = null;
    }
}

From source file:gov.nasa.arc.spife.ui.timeline.Activator.java

License:Open Source License

public Image getIcon(String imageName) {
    ImageDescriptor descriptor = imageDescriptorFromPlugin(PLUGIN_ID, "icons/" + imageName);
    if (descriptor == null) {
        descriptor = ImageDescriptor.getMissingImageDescriptor();
    }/*from   w ww .  j av a  2 s  .c o m*/
    return descriptor.createImage();
}

From source file:gov.nasa.ensemble.common.ui.WidgetPlugin.java

License:Open Source License

public static Image getImage(String path) {
    ImageDescriptor imageDescriptor = getImageDescriptor(path);
    if (imageDescriptor != null) {
        return imageDescriptor.createImage();
    }/*from  www . j ava  2s.  c o m*/
    return null;
}

From source file:gov.nasa.ensemble.core.detail.emf.binding.TableBindingFactory.java

License:Open Source License

private Image getImage(String key) {
    Activator activator = Activator.getDefault();
    ImageRegistry imageRegistry = activator.getImageRegistry();
    Image image = imageRegistry.get(key);
    if (image == null) {
        ImageDescriptor imageDescriptorFromPlugin = AbstractUIPlugin
                .imageDescriptorFromPlugin(Activator.PLUGIN_ID, key);
        image = imageDescriptorFromPlugin.createImage();
        imageRegistry.put(key, image);//w ww .  ja  va  2  s.co m
    }
    return image;
}