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

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

Introduction

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

Prototype

public static ImageDescriptor createFromURL(URL url) 

Source Link

Document

Creates and returns a new image descriptor from a URL.

Usage

From source file:com.bb.extensions.plugin.unittests.Activator.java

License:Open Source License

@Override
protected void initializeImageRegistry(ImageRegistry registry) {
    super.initializeImageRegistry(registry);
    Bundle bundle = Platform.getBundle("org.eclipse.cdt.ui");

    ImageDescriptor myImage = ImageDescriptor
            .createFromURL(FileLocator.find(bundle, new Path("icons/ovr16/referencedby_co.gif"), null));
    registry.put(outOfDateImageId, myImage);
}

From source file:com.bb.extensions.plugin.unittests.internal.actions.FileNewAction.java

License:Open Source License

@Override
public ImageDescriptor getImageDescriptor() {
    try {/*from  w  w  w  . j  a  v a 2 s  .co  m*/
        URL imageUrl;
        switch (_type) {
        case HEADER_FILE:
            imageUrl = new URL("platform:/plugin/org.eclipse.cdt.ui/icons/etool16/newhfile_wiz.gif"); //$NON-NLS-1$
            break;
        default:
            imageUrl = new URL("platform:/plugin/org.eclipse.cdt.ui/icons/etool16/newcfile_wiz.gif"); //$NON-NLS-1$
            break;
        }
        return ImageDescriptor.createFromURL(imageUrl);
    } catch (MalformedURLException e) {
    }
    return null;
}

From source file:com.bb.extensions.plugin.unittests.internal.navigator.UnitTestsLabelProvider.java

License:Open Source License

@Override
public Image getImage(Object element) {
    Image result = null;/*from  w w  w .  j  a  va  2  s. c om*/

    if (element instanceof IUnitTestsNavigatorElement) {
        Object icon = ((IUnitTestsNavigatorElement) element).getIcon();

        if (icon instanceof String) {
            // it's a registered key
            result = Activator.getDefault().getImageRegistry().get((String) icon);
        } else if (icon instanceof Image) {
            result = (Image) icon;
        } else {
            ImageDescriptor descriptor = null;
            String key = null;

            if (icon instanceof URL) {
                key = icon.toString();
                descriptor = ImageDescriptor.createFromURL((URL) icon);
            } else if (icon instanceof ImageDescriptor) {
                key = icon.toString(); // URLImageDescriptors have sensible
                // toString()s
                descriptor = (ImageDescriptor) icon;
            }

            if (key != null) {
                result = images.get(key);
                if (result == null) {
                    images.put(key, descriptor);
                    result = images.get(key);
                }
            }
        }
    }

    return result;
}

From source file:com.beck.ep.team.views.TeamFileListView.java

License:BSD License

private void makeActions(boolean newBlockSelection) {
    loadListMgr = new FileListMenuMgr("&Saved File list", "loadFileList", fAT,
            TFMPlugin.getDefault().getPreferences().node("fmenu"));
    customUnpackMgr = new CustomUnpackMgr("&Unpack defined setting", "runCustomAction", fAT,
            TFMPlugin.getDefault().getPreferences().node("customUnpack"));

    createListAction = new XAction(1);
    createListAction.setText("Create file list");
    createListAction.setToolTipText("List changed files of selected project");
    createListAction.setImageDescriptor(TFMPlugin.getImageDescriptor("/icons/cmp_tree.ico"));

    zipAction = new XAction(2);
    zipAction.setText("Zip files");
    zipAction.setToolTipText("Copy workspace files in the list to a zip file");
    zipAction.setImageDescriptor(/* w  ww .j  a  v  a2 s  .  c om*/
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor("IMG_ETOOL_EXPORT_WIZ"));

    unzipAction = new XAction(3);
    unzipAction.setText("Unzip files");
    unzipAction.setToolTipText("Unzip from external file to workspace project");
    unzipAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor("IMG_ETOOL_IMPORT_WIZ"));

    otherCfgAction = new XAction(6);
    otherCfgAction.setText("set root folder for new zip...");
    Preferences option = TFMPlugin.getDefault().getPreferences().node("option");
    ckCheckFileAction = new XAction(900, "show error when file not exists", IAction.AS_CHECK_BOX);
    ckCheckFileAction.setChecked(option.getBoolean("fileNotExist", true));
    ckSaveWhenExitAction = new XAction(900, "save file list when exit", IAction.AS_CHECK_BOX);
    ckSaveWhenExitAction.setChecked(option.getBoolean("saveWhenExit", false));

    if (TFMPlugin.getDefault().newFilePacker(TFMPlugin.PACKER_WAR_PATCH) != null) {
        warPatchAction = new XAction(5);
        warPatchAction.setText("Create WAR patch");
        warPatchAction.setToolTipText("Create WAR patch base on file list to a zip file");
        warPatchAction.setImageDescriptor(TFMPlugin.getImageDescriptor("/icons/war_patch.ico"));
    }

    if (newBlockSelection) {
        ckBlockAction = new XAction(4, "Taggle Block Selection Mode", Action.AS_CHECK_BOX);
        try {
            ckBlockAction.setImageDescriptor(ImageDescriptor.createFromURL(new java.net.URL(
                    "platform:/plugin/org.eclipse.ui.workbench.texteditor/icons/full/etool16/block_selection_mode.gif")));
        } catch (Exception e) {
        }
    }
    sortAction = new XAction(7);
    sortAction.setText("Sort file list");
    try {
        sortAction.setImageDescriptor(ImageDescriptor.createFromURL(
                new java.net.URL("platform:/plugin/org.eclipse.jdt.ui/icons/full/dlcl16/alphab_sort_co.gif")));
    } catch (Exception e) {
    }

    /*testAction = new XAction(999);
    testAction.setText("test...");
    testAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
    getImageDescriptor(ISharedImages.IMG_OBJ_ELEMENT));*/
}

From source file:com.bluexml.side.application.ui.action.utils.Generate.java

License:Open Source License

private ImageDescriptor getImage() {
    Bundle plugin = Platform.getBundle(Activator.PLUGIN_ID);
    URL imgPath = plugin.getResource("/icon/side_16.gif");
    ImageDescriptor imgDesc = ImageDescriptor.createFromURL(imgPath);
    return imgDesc;
}

From source file:com.bluexml.side.Requirements.modeler.goalDiagram.edit.is_responsibleEditPart.java

License:Open Source License

@Override
protected void refreshEdgeObjects() {
    super.refreshEdgeObjects();

    URL url = null;/*from   w ww. jav  a 2 s.  c  o m*/
    Image image;
    try {
        url = new URL(RequirementsPlugin.getDefault().getDescriptor().getInstallURL(),
                "icons/ResponsibilityDecoration.png");
        image = ImageDescriptor.createFromURL(url).createImage();
        ((PolylineConnection) figure).setTargetDecoration(new ImageDecoration(image));
    } catch (MalformedURLException e) {
    }

}

From source file:com.bluexml.side.Requirements.modeler.goalDiagram.edit.PrivilegeEditPart.java

License:Open Source License

@Override
protected void refreshTextAndFont() {
    super.refreshTextAndFont();
    Privilege p = (Privilege) Utils.getElement(getGraphNode());
    getLabel().setText(createLabel(p));/*from   ww  w .  java2  s .c  o  m*/

    if (p.getElement() instanceof Entity) {
        FontData[] fData = Display.getDefault().getSystemFont().getFontData();
        fData[0].setStyle(SWT.BOLD);
        JFaceResources.getFontRegistry().put("font", fData);
        getLabel().setFont(JFaceResources.getFontRegistry().get("font"));
        ((Label) getLabel()).setAlignment(Label.LEFT);

        URL url = null;
        Image image;
        try {
            url = new URL(RequirementsPlugin.getDefault().getDescriptor().getInstallURL(),
                    "icons/EntityLittle.png");
            image = ImageDescriptor.createFromURL(url).createImage();
            ((Label) getLabel()).setIcon(image);
        } catch (MalformedURLException e) {
        }
    } else {
        FontData[] fData = Display.getDefault().getSystemFont().getFontData();
        fData[0].setStyle(SWT.ITALIC);
        JFaceResources.getFontRegistry().put("font", fData);
        getLabel().setFont(JFaceResources.getFontRegistry().get("font"));
        ((Label) getLabel()).setAlignment(Label.LEFT);

        URL url = null;
        Image image;
        try {
            url = new URL(RequirementsPlugin.getDefault().getDescriptor().getInstallURL(),
                    "icons/AttributeLittle.png");
            image = ImageDescriptor.createFromURL(url).createImage();
            ((Label) getLabel()).setIcon(image);
        } catch (MalformedURLException e) {
        }
    }
}

From source file:com.bluexml.side.Requirements.modeler.goalDiagram.edit.PrivilegeGroupEditPart.java

License:Open Source License

@Override
protected void refreshEdgeObjects() {
    super.refreshEdgeObjects();

    PrivilegeGroup pGroup = (PrivilegeGroup) Utils.getElement(getGraphEdge());

    Map<BasicElement, Set<Privilege>> s = filterPrivileges(pGroup.getPrivileges());
    List<BasicElement> keys = sortPrivileges(s.keySet());

    String value = "";
    char nl = '\r';
    for (BasicElement elt : keys) {
        if (elt != null) {
            value += nl;//  w w w. j  av a2s  . c o  m
            String label = elt.getName();
            if (!(elt instanceof Entity))
                value += "   ";
            value += label + " (";

            Set<Privilege> ps = s.get(elt);
            boolean[] rules = { false, false, false, false };
            for (Privilege p : ps) {
                if (p.getCategory().equals(PrivilegeNature.CREATE))
                    rules[0] = true;
                if (p.getCategory().equals(PrivilegeNature.READ))
                    rules[1] = true;
                if (p.getCategory().equals(PrivilegeNature.UPDATE))
                    rules[2] = true;
                if (p.getCategory().equals(PrivilegeNature.DELETE))
                    rules[3] = true;
            }

            int begin, end;
            if (elt instanceof Entity) {
                begin = 0;
                end = 3;
            } else {
                begin = 1;
                end = 2;
            }

            for (int i = begin; i <= end; ++i) {
                if (rules[i]) {
                    switch (i) {
                    case 0:
                        value += "C";
                        break;
                    case 1:
                        value += "R";
                        break;
                    case 2:
                        value += "U";
                        break;
                    case 3:
                        value += "D";
                        break;
                    default:
                        break;
                    }
                }
            }
            value += ")";
        }
    }

    PrivilegeGroupFigure fig = (PrivilegeGroupFigure) getFigure();
    CommentFigure lbl = (CommentFigure) fig.getmiddleNameEdgeObjectFigure();
    lbl.setText(value);

    //Set decoration

    URL url = null;
    Image image;
    try {
        url = new URL(RequirementsPlugin.getDefault().getDescriptor().getInstallURL(),
                "icons/StrategyDecoration_Entity.png");
        image = ImageDescriptor.createFromURL(url).createImage();
        ((PolylineConnection) figure).setTargetDecoration(new ImageDecoration(image));

        url = new URL(RequirementsPlugin.getDefault().getDescriptor().getInstallURL(),
                "icons/StrategyDecoration_Goal.png");
        image = ImageDescriptor.createFromURL(url).createImage();
        ((PolylineConnection) figure).setSourceDecoration(new ImageDecoration(image));
    } catch (MalformedURLException e) {
    }
}

From source file:com.bluexml.side.util.libs.ui.UIUtils.java

License:Open Source License

public static ImageDescriptor getImage(String pluginID, String imgPath) {
    Bundle plugin = Platform.getBundle(pluginID);
    URL imgURL = plugin.getResource(imgPath);
    ImageDescriptor imgDesc = ImageDescriptor.createFromURL(imgURL);
    return imgDesc;
}

From source file:com.bluexml.side.Workflow.modeler.editor.ModelerContextMenuProvider.java

License:Open Source License

protected IMenuManager buildActionMenu() {
    IMenuManager submenuAddAction = new MenuManager(WorkflowPlugin.Messages.getString("AddAction.1"));
    Map<String, Set<IAction>> actions = new HashMap<String, Set<IAction>>();

    IConfigurationElement[] contributions = Platform.getExtensionRegistry()
            .getConfigurationElementsFor(EXTENSIONPOINT_ID);
    for (IConfigurationElement configurationElement : contributions) {
        String name = configurationElement.getAttribute("name");
        String code = configurationElement.getAttribute("code");
        String icon = configurationElement.getAttribute("icon");
        String javaClass = configurationElement.getAttribute("javaClass");
        String technology = configurationElement.getAttribute("technology");

        String codeValue = "";
        try {/*from w w  w. j a v  a  2s .c om*/
            URL url = Platform.getBundle(configurationElement.getContributor().getName()).getResource(code);
            InputStream fis = url.openStream();
            BufferedInputStream bis = new BufferedInputStream(fis);
            DataInputStream dis = new DataInputStream(bis);
            while (dis.available() != 0)
                codeValue += dis.readLine() + "\r\n";
            fis.close();
            bis.close();
            dis.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        ImageDescriptor iconDescriptor = null;
        if (icon != null && icon.length() > 0) {
            URL url = Platform.getBundle(configurationElement.getContributor().getName()).getResource(icon);
            iconDescriptor = ImageDescriptor.createFromURL(url);
        }

        AddAction action = new AddAction(editor, name, codeValue, iconDescriptor, javaClass);
        actionRegistry.registerAction(action);
        if (!actions.containsKey(technology))
            actions.put(technology, new HashSet<IAction>());
        actions.get(technology).add(action);
    }

    for (String technology : actions.keySet()) {
        submenuAddAction.add(buildTechnologyMenu(technology, actions.get(technology)));
    }

    return submenuAddAction;
}