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

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

Introduction

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

Prototype

public static ImageDescriptor createFromFile(Class<?> location, String filename) 

Source Link

Document

Creates and returns a new image descriptor from a file.

Usage

From source file:repast.simphony.agents.designer.ui.editors.PaletteHelper.java

License:Open Source License

/**
 * Creates the Flowlets drawer in the palette
 * /*  w ww. j a  v  a2  s  .co  m*/
 * @return the filled drawer container
 */
static private PaletteContainer createFlowletsDrawer() {
    PaletteDrawer drawer = new PaletteDrawer(
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Category_Steps.label"), //$NON-NLS-1$
            ImageDescriptor.createFromFile(BehaviorStepModelPart.class, "icons/comp.gif"));//$NON-NLS-1$

    List entries = new ArrayList();
    CombinedTemplateCreationEntry combined;

    combined = new CombinedTemplateCreationEntry(
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_AgentProperty.label"), //$NON-NLS-1$
            AgentBuilderPlugin
                    .getResourceString("AgentEditor_Palette_Tool_CreationTool_AgentProperty.description"), //$NON-NLS-1$
            AgentPropertyModelPart.class, new SimpleFactory(AgentPropertyModelPart.class),
            ImageDescriptor.createFromFile(AgentPropertyModelPart.class, "icons/agentproperty16.gif"), //$NON-NLS-1$
            ImageDescriptor.createFromFile(AgentPropertyModelPart.class, "icons/agentproperty24.gif")//$NON-NLS-1$
    );
    entries.add(combined);

    combined = new CombinedTemplateCreationEntry(
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_BehaviorStep.label"), //$NON-NLS-1$
            AgentBuilderPlugin
                    .getResourceString("AgentEditor_Palette_Tool_CreationTool_BehaviorStep.description"), //$NON-NLS-1$
            BehaviorStepModelPart.class, new SimpleFactory(BehaviorStepModelPart.class),
            ImageDescriptor.createFromFile(BehaviorStepModelPart.class, "icons/behaviorstep16.gif"), //$NON-NLS-1$
            ImageDescriptor.createFromFile(BehaviorStepModelPart.class, "icons/behaviorstep24.gif")//$NON-NLS-1$
    );
    entries.add(combined);

    combined = new CombinedTemplateCreationEntry(
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_TaskStep.label"), //$NON-NLS-1$
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_TaskStep.description"), //$NON-NLS-1$
            TaskStepModelPart.class, new SimpleFactory(TaskStepModelPart.class),
            ImageDescriptor.createFromFile(TaskStepModelPart.class, "icons/taskstep16.gif"), //$NON-NLS-1$
            ImageDescriptor.createFromFile(TaskStepModelPart.class, "icons/taskstep24.gif")//$NON-NLS-1$
    );
    entries.add(combined);

    combined = new CombinedTemplateCreationEntry(
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_DecisionStep.label"), //$NON-NLS-1$
            AgentBuilderPlugin
                    .getResourceString("AgentEditor_Palette_Tool_CreationTool_DecisionStep.description"), //$NON-NLS-1$
            DecisionStepModelPart.class, new SimpleFactory(DecisionStepModelPart.class),
            ImageDescriptor.createFromFile(DecisionStepModelPart.class, "icons/decisionstep16.gif"), //$NON-NLS-1$
            ImageDescriptor.createFromFile(DecisionStepModelPart.class, "icons/decisionstep24.gif")//$NON-NLS-1$
    );
    entries.add(combined);

    combined = new CombinedTemplateCreationEntry(
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_JoinStep.label"), //$NON-NLS-1$
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_JoinStep.description"), //$NON-NLS-1$
            JoinStepModelPart.class, new SimpleFactory(JoinStepModelPart.class),
            ImageDescriptor.createFromFile(JoinStepModelPart.class, "icons/joinstep16.gif"), //$NON-NLS-1$
            ImageDescriptor.createFromFile(JoinStepModelPart.class, "icons/joinstep24.gif")//$NON-NLS-1$
    );
    entries.add(combined);

    combined = new CombinedTemplateCreationEntry(
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_LoopStep.label"), //$NON-NLS-1$
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_LoopStep.description"), //$NON-NLS-1$
            DecisionStepModelPart.class, new SimpleFactory(DecisionStepModelPart.class) {

                @Override
                public Object getNewObject() {
                    // TODO Auto-generated method stub
                    Object obj = super.getNewObject();
                    if (obj instanceof DecisionStepModelPart) {
                        ((DecisionStepModelPart) obj)
                                .setBranchType(DecisionStepModelPart.PROP_DECISION_BRANCH_TYPE_WHILE);
                        ((DecisionStepModelPart) obj).setComment("This is a loop.");
                    }
                    return obj;
                }

            }

            , ImageDescriptor.createFromFile(DecisionStepModelPart.class, "icons/loopstep16.gif"), //$NON-NLS-1$
            ImageDescriptor.createFromFile(DecisionStepModelPart.class, "icons/loopstep24.gif")//$NON-NLS-1$
    );
    entries.add(combined);

    combined = new CombinedTemplateCreationEntry(
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_EndStep.label"), //$NON-NLS-1$
            AgentBuilderPlugin.getResourceString("AgentEditor_Palette_Tool_CreationTool_EndStep.description"), //$NON-NLS-1$
            EndStepModelPart.class, new SimpleFactory(EndStepModelPart.class),
            ImageDescriptor.createFromFile(EndStepModelPart.class, "icons/endstep16.gif"), //$NON-NLS-1$
            ImageDescriptor.createFromFile(EndStepModelPart.class, "icons/endstep24.gif")//$NON-NLS-1$
    );
    entries.add(combined);

    entries.add(new PaletteSeparator());
    drawer.addAll(entries);

    return drawer;
}

From source file:sernet.gs.ui.rcp.main.ImageCache.java

License:Open Source License

public Image getCustomImage(String url) {
    ImageDescriptor descriptor = null;//w  w w . ja  v a  2s  . co m
    if (new File(url).isAbsolute()) {
        descriptor = ImageDescriptor.createFromFile(null, url);
    } else {
        descriptor = ImageDescriptor.createFromURL(FileLocator.find(bundle, new Path(url), null));
    }
    if (descriptor.equals(ImageDescriptor.getMissingImageDescriptor())) {
        LOG.warn("Image not found: " + url);
        descriptor = ImageDescriptor
                .createFromURL(FileLocator.find(bundle, new Path(getIconPath(UNKNOWN)), null));
    }
    return getImage(descriptor);
}

From source file:sernet.verinice.rcp.IconDescriptor.java

License:Open Source License

/**
 * @param file
 */
public IconDescriptor(File file) {
    path = file.getPath();
    imageDescriptor = ImageDescriptor.createFromFile(null, file.getPath());
}

From source file:tern.eclipse.jface.images.TernImagesRegistry.java

License:Open Source License

public static Image getImage(ITernModule module) {
    TernModuleMetadata metadata = module.getMetadata();
    if (metadata == null) {
        return null;
    }//  w  ww .j  av a  2s  . co  m
    File icon = metadata.getFileIcon();
    if (icon == null) {
        return null;
    }
    String key = icon.getPath();
    Image image = getImage(key);
    if (image != null) {
        return image;
    }
    ImageDescriptor desc = ImageDescriptor.createFromFile(null, icon.getPath());
    registerImageDescriptor(key, desc);
    return TernImagesRegistry.getImage(key);
}

From source file:tern.eclipse.jface.images.TernImagesRegistry.java

License:Open Source License

public static ImageDescriptor getImageDescriptor(ITernModule module) {
    TernModuleMetadata metadata = module.getMetadata();
    if (metadata == null) {
        return null;
    }/*from   w  ww. j  a v  a  2  s  .  c o m*/
    File icon = metadata.getFileIcon();
    if (icon == null) {
        return null;
    }
    String key = icon.getPath();
    ImageDescriptor desc = getImageDescriptor(key);
    if (desc != null) {
        return desc;
    }
    desc = ImageDescriptor.createFromFile(null, icon.getPath());
    registerImageDescriptor(key, desc);
    return desc;
}

From source file:testlink.eclipse.plugin.views.tree.ViewLabelProvider.java

License:Open Source License

private ImageDescriptor getImageDescriptor(String strIcon) {
    try {/*  ww  w. j  ava2s .c o m*/
        ImageDescriptor imageDescriptor = getImageDescriptor(configElement, strIcon);
        if (imageDescriptor == null) {
            imageDescriptor = ImageDescriptor.createFromFile(this.getClass(), strIcon);
        }
        return imageDescriptor;
    } catch (Exception e) {
        return null;
    }
}

From source file:uk.ac.diamond.sda.navigator.decorator.LightweightMetadataDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IFile) {
        IFile ifile = (IFile) element;/*from w  ww. j av a  2 s  .c om*/
        IPath path = ifile.getLocation();
        if (path != null) {
            File file = path.toFile();
            String lastModified = new SimpleDateFormat("dd/MM/yy hh:mm aaa")
                    .format(new Date(file.lastModified()));
            String filePermission = getFilePermission(file);
            // file size - date of last modification - file permissions
            decoration.addSuffix("  " + readableFileSize(file.length()) + "  " + lastModified);// +"  "+filePermission);
            // Image overlay decoration according to file permission:
            if (filePermission.equals("- - -")) {
                ImageDescriptor lockOverlay = ImageDescriptor.createFromFile(this.getClass(),
                        "/icons/decorators/unconfigured_co.gif");
                decoration.addOverlay(lockOverlay);
            }
        }
    }
}

From source file:uk.ac.gda.client.hrpd.views.EpicsProcessProgressMonitor.java

License:Open Source License

private Button createCancelButton(Composite parent) {
    Button button = new Button(parent, SWT.PUSH);
    button.addSelectionListener(listener);
    final Image stopImage = ImageDescriptor.createFromFile(EpicsProcessProgressMonitor.class, "icons/stop.gif") //$NON-NLS-1$
            .createImage(getDisplay());//w  w w.  j  a  v  a 2  s.  c  om
    button.setImage(stopImage);
    button.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
    button.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            stopImage.dispose();
        }
    });
    button.setEnabled(false);
    button.setToolTipText("Cancel current cvscan"); //$NON-NLS-1$
    return button;
}

From source file:uk.ac.gda.epics.client.mythen.views.EpicsDetectorProgressMonitor.java

License:Open Source License

private Button createCancelButton(Composite parent) {
    Button button = new Button(parent, SWT.PUSH);
    button.addSelectionListener(listener);
    final Image stopImage = ImageDescriptor.createFromFile(EpicsDetectorProgressMonitor.class, "icons/stop.gif") //$NON-NLS-1$
            .createImage(getDisplay());//  w w  w .  j  a  va2 s  .c o m
    button.setImage(stopImage);
    button.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
    button.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            stopImage.dispose();
        }
    });
    button.setEnabled(false);
    button.setToolTipText("Cancel current cvscan"); //$NON-NLS-1$
    return button;
}

From source file:uk.co.saiman.eclipse.model.ui.provider.editor.CellContributionEditor.java

License:Open Source License

@Override
public Image getImage(Object element) {
    return ImageDescriptor.createFromFile(VListEditor.class, "/icons/full/obj16/CellContribution.gif")
            .createImage();//ww w . j ava2s  .  c  o m
}