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:org.eclipse.cdt.cpp.ui.internal.CppPlugin.java

License:Open Source License

public ImageDescriptor getImageDescriptor(String name) {
    String baseDir = _corePath + java.io.File.separator;
    CppActionLoader loader = (CppActionLoader) CppActionLoader.getInstance();
    String file = loader.getImageString(name);

    return ImageDescriptor.createFromFile(null, file);
}

From source file:org.eclipse.cdt.dstore.core.DataStoreCorePlugin.java

License:Open Source License

public ImageDescriptor getImageDescriptor(String name, boolean qualify) {
    String file = name;/*from   w  w  w.j a v  a2s.c  om*/
    if (qualify) {
        String corePath = getInstallLocation() + "org.eclipse.cdt.dstore.core";
        file = corePath + java.io.File.separator + "icons" + java.io.File.separator + name;
    }

    if (file != null) {
        File fileObj = new File(file);
        if (fileObj.exists()) {
            return ImageDescriptor.createFromFile(null, file);
        } else {
            return null;
        }
    }
    return null;
}

From source file:org.eclipse.cdt.dstore.hosts.HostsPlugin.java

License:Open Source License

public ImageDescriptor getImageDescriptor(String name) {
    String baseDir = _corePath + java.io.File.separator;
    HostsActionLoader loader = HostsActionLoader.getInstance();
    String file = loader.getImageString(name);

    return ImageDescriptor.createFromFile(null, file);
}

From source file:org.eclipse.cdt.dstore.ui.widgets.DataElementLabelProvider.java

License:Open Source License

public DataElementLabelProvider(ImageRegistry registry, IActionLoader loader) {
    super();//w w  w.  jav a  2  s.c  o m
    setLabelProperty(DE.P_VALUE);

    _registry = registry;
    _actionLoader = loader;

    String baseDir = DataStoreUIPlugin.getInstance().getInstallLocation();
    String imageStr = baseDir + java.io.File.separator + "icons" + java.io.File.separator + "default.gif";

    Image image = _registry.get(imageStr);
    if (image == null) {
        _registry.put(imageStr, ImageDescriptor.createFromFile(null, imageStr));
        image = _registry.get(imageStr);
    }

    _default = image;
    _instance = this;
}

From source file:org.eclipse.cdt.dstore.ui.widgets.DataElementLabelProvider.java

License:Open Source License

public Image getImage(String imageStr) {
    Image image = null;// www .  ja v a  2s  .c om
    image = _registry.get(imageStr);
    if (image == null && imageStr != null) {
        File file = new File(imageStr);
        if (file.exists()) {
            try {
                image = ImageDescriptor.createFromFile(null, imageStr).createImage();
                _registry.put(imageStr, image);

                image = _registry.get(imageStr);
            } catch (org.eclipse.swt.SWTException e) {
                //System.out.println(e);
                System.out.println("invalid image: " + imageStr);
                return _default;
            }
        } else {
            return _default;
        }
    }

    return image;
}

From source file:org.eclipse.cdt.linux.help.HelpPlugin.java

License:Open Source License

public Image getImage(String name) {
    ImageRegistry reg = getImageRegistry();
    Image image = reg.get(getInstallLocation() + "icons" + File.separator + name);
    if (image == null) {
        ImageDescriptor des = ImageDescriptor.createFromFile(null,
                getInstallLocation() + "icons" + File.separator + name);
        image = des.createImage();//from   w w  w .  ja  v  a2s.  co  m
        reg.put(name, des);
    }
    return image;
}

From source file:org.eclipse.cdt.pa.ui.PAPlugin.java

License:Open Source License

public ImageDescriptor getImageDescriptor(String name) {
    PAActionLoader loader = (PAActionLoader) PAActionLoader.getInstance();
    String file = loader.getImageString(name);

    return ImageDescriptor.createFromFile(null, file);
}

From source file:org.eclipse.conesc.plugin.factories.ConesCEditorPaletteFactory.java

License:Open Source License

/** Create the "Tools" group. */
private static PaletteContainer createToolsGroup(PaletteRoot palette) {
    PaletteToolbar toolbar = new PaletteToolbar("Tools");

    // Add a selection tool to the group
    ToolEntry tool = new PanningSelectionToolEntry();
    toolbar.add(tool);//  w  w w.  j a v  a  2  s. c  o m
    palette.setDefaultEntry(tool);

    // Add a marquee tool to the group
    toolbar.add(new MarqueeToolEntry());

    // Add (solid-line) connection tool
    tool = new ConnectionCreationToolEntry("Solid connection", "Create a solid-line connection",
            new CreationFactory() {
                @Override
                public Object getNewObject() {
                    return null;
                }

                // see ShapeEditPart#createEditPolicies()
                // this is abused to transmit the desired line style
                @Override
                public Object getObjectType() {
                    return new Integer(Graphics.LINE_SOLID);
                }
            }, ImageDescriptor.createFromFile(ConesCPlugin.class, "icons/connection_s16.gif"),
            ImageDescriptor.createFromFile(ConesCPlugin.class, "icons/connection_s24.gif"));
    toolbar.add(tool);

    return toolbar;
}

From source file:org.eclipse.conesc.plugin.figure.ContextFigure.java

License:Open Source License

public void redraw() {
    behaviours.removeAll();//from  w  ww .j a  v  a  2  s  .c  om
    name.setIcon(null);
    if (isDefault)
        name.setIcon(ImageDescriptor.createFromFile(ConesCPlugin.class, "icons/default_8.png").createImage());
    else if (isError)
        name.setIcon(ImageDescriptor.createFromFile(ConesCPlugin.class, "icons/error_8.png").createImage());
    if (!triggers.getText().isEmpty()) {
        behaviours.add(triggers, ToolbarLayout.ALIGN_CENTER, 0);
        behaviours.add(triggersLabel, ToolbarLayout.ALIGN_CENTER, 0);
    }
    if (!onLeave.getText().isEmpty()) {
        behaviours.add(onLeave, ToolbarLayout.ALIGN_CENTER, 0);
        behaviours.add(onLeaveLabel, ToolbarLayout.ALIGN_CENTER, 0);
    }

    if (!onActive.getText().isEmpty()) {
        behaviours.add(onActive, ToolbarLayout.ALIGN_TOPLEFT, 0);
        behaviours.add(onActiveLabel, ToolbarLayout.ALIGN_TOPLEFT, 0);
    }

    if (!onEnter.getText().isEmpty()) {
        behaviours.add(onEnter, ToolbarLayout.ALIGN_TOPLEFT, 0);
        behaviours.add(onEnterLabel, ToolbarLayout.ALIGN_TOPLEFT, 0);
    }
    add(behaviours, 0);
    add(name, ToolbarLayout.ALIGN_CENTER, 0);
}

From source file:org.eclipse.datatools.sqltools.sqlbuilder.actions.SQLBuilderActionBarContributor.java

License:Open Source License

/**
 * Constructs an instance of this class.  This is the default constructor.
 *//*from  w ww .j  a v  a 2  s . c om*/
public SQLBuilderActionBarContributor() {
    super();

    /* Create the actions objects that are added to the menus and toolbar. */
    ResourceBundle resourceBundle = SQLBuilderPlugin.getPlugin().getResourceBundle();

    /* RetargetTextEditorActions are meant for text actions such as cut/copy/paste */
    fEditMenuContentAssistAction = new RetargetTextEditorAction(resourceBundle, CONTENT_ASSIST_ACTION_PREFIX);
    fEditMenuContentAssistAction.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);

    fEditMenuContentTipAction = new RetargetTextEditorAction(resourceBundle, CONTENT_TIP_ACTION_PREFIX);
    fEditMenuContentTipAction
            .setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);

    ImageDescriptor runSQLImage = ImageDescriptor.createFromFile(
            org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilderPlugin.getPlugin().getClass(),
            RUN_SQL_ACTION_ICON_PATH);

    /* RetargetActions are all other actions. */
    fRunMenuRunSQLAction = new RetargetAction(RUN_MENU_RUN_SQL_ACTION_ID,
            Messages.datatools_sqlbuilder_RunSQLAction_label);
    fRunMenuRunSQLAction.setImageDescriptor(runSQLImage);

    fSQLMenuRunSQLAction = new RetargetAction(SQL_MENU_RUN_SQL_ACTION_ID,
            Messages.datatools_sqlbuilder_RunSQLAction_label);
    fSQLMenuRunSQLAction.setImageDescriptor(runSQLImage);

    fToolBarRunSQLAction = new RetargetAction(TOOLBAR_RUN_SQL_ACTION_ID,
            Messages.datatools_sqlbuilder_RunSQLAction_label);
    fToolBarRunSQLAction.setToolTipText(Messages.datatools_sqlbuilder_RunSQLAction_tooltip);
    fToolBarRunSQLAction.setImageDescriptor(runSQLImage);

    fSQLMenuRevertToPreviousAction = new RetargetAction(SQL_MENU_REVERT_TO_PREVIOUS_ACTION_ID,
            Messages.datatools_sqlbuilder_RevertToPreviousAction_label);
    fSQLMenuRevertToDefaultAction = new RetargetAction(SQL_MENU_REVERT_TO_DEFAULT_ACTION_ID,
            Messages.datatools_sqlbuilder_RevertToDefaultAction_label);
    fSQLMenuChangeStatementTypeAction = new RetargetAction(SQL_MENU_CHANGE_STATEMENT_TYPE_ACTION_ID,
            Messages.datatools_sqlbuilder_ChangeStatementTypeAction_label);
    fSQLMenuOmitCurrentSchemaAction = new RetargetAction(SQL_MENU_OMIT_CURRENT_SCHEMA_ACTION_ID,
            Messages.datatools_sqlbuilder_OmitCurrentSchemaAction_label);

    /* Create the "handler" actions.  (These actions get bound to the menu and toolbar
     * action objects.  These actions do the actual work.) */
    fRunSQLAction = new ExecuteAction();
    fRunSQLAction.setId(RUN_SQL_ACTION_ID);
    setAction(RUN_SQL_ACTION_ID, fRunSQLAction);

    fRevertToPreviousAction = new RevertToPreviousAction();
    fRevertToPreviousAction.setId(REVERT_TO_PREVIOUS_ACTION_ID);
    fRevertToPreviousAction.setShell(Display.getCurrent().getActiveShell());
    setAction(REVERT_TO_PREVIOUS_ACTION_ID, fRevertToPreviousAction);

    fRevertToDefaultAction = new RevertToDefaultAction();
    fRevertToDefaultAction.setId(REVERT_TO_DEFAULT_ACTION_ID);
    setAction(REVERT_TO_DEFAULT_ACTION_ID, fRevertToDefaultAction);

    fChangeStatementTypeAction = new ChangeStatementTypeAction();
    fChangeStatementTypeAction.setId(CHANGE_STATEMENT_TYPE_ACTION_ID);
    fChangeStatementTypeAction.setShell(Display.getCurrent().getActiveShell());
    setAction(CHANGE_STATEMENT_TYPE_ACTION_ID, fChangeStatementTypeAction);

    fOmitCurrentSchemaAction = new OmitCurrentSchemaAction();
    fOmitCurrentSchemaAction.setId(OMIT_CURRENT_SCHEMA_ACTION_ID);
    fOmitCurrentSchemaAction.setShell(Display.getCurrent().getActiveShell());
    setAction(OMIT_CURRENT_SCHEMA_ACTION_ID, fOmitCurrentSchemaAction);
}