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.motorolamobility.preflighting.ui.AppValidatorClearActionDelegate.java

License:Apache License

public void init(IViewPart view) {
    IActionBars actionBar = view.getViewSite().getActionBars();
    IToolBarManager toolBar = actionBar.getToolBarManager();
    //defines action 
    Action action = new Action() {
        @Override/*ww w. j  a va 2 s .c om*/
        public void run() {
            try {
                IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
                //clear app validator markers for every opened project and its subfiles
                for (int i = 0; projects != null && i < projects.length; i++) {
                    if (projects[i].isOpen()) {
                        projects[i].deleteMarkers(AnalyzeApkHandler.DEFAULT_APP_VALIDATOR_MARKER_TYPE, true,
                                IResource.DEPTH_INFINITE);
                    }
                }
            } catch (CoreException e) {
                PreflightingLogger.error("Error removing markers from projects.");
            }

            super.run();
        }
    };
    //set icon
    URL imageUrl = PreflightingUIPlugin.getDefault().getBundle()
            .getEntry("icons/MOTODEVAppValidator_16x16_clear.png");
    ImageDescriptor imageDesc = ImageDescriptor.createFromURL(imageUrl);
    action.setImageDescriptor(imageDesc);
    action.setEnabled(true);
    action.setToolTipText(PreflightingUiNLS.ProblemsView_ClearAppValidatorMarkers);
    //add to tool bar and update it
    toolBar.add(action);

    toolBar.add(new Separator());
    actionBar.updateActionBars();
}

From source file:com.motorolamobility.studio.android.db.core.ui.AbstractTreeNode.java

License:Apache License

/**
 * Retrieves an icon image descriptor from other Eclipse bundles (JDT, Datatools, ADT, etc).
 * /*w  ww.  j av a 2  s . c o  m*/
 * @param bundleId The id of the bundle where the icon should be retrieved from
 * @param iconPath The path of the icon inside the bundle
 * 
 * @return The image descriptor for the desired icon, or the default icon from the db code plugin
 *         in case the process of retrieving the desired icon fails
 */
protected final ImageDescriptor getSpecificIcon(String bundleId, String iconPath) {
    ImageDescriptor imgDesc = null;

    try {
        Bundle bundle = Platform.getBundle(bundleId);
        URL path = bundle.getEntry("/"); //$NON-NLS-1$
        URL fullPathString = new URL(path, iconPath);
        imgDesc = ImageDescriptor.createFromURL(fullPathString);
    } catch (Exception e) {
        StudioLogger.error(getClass(), "Error retrieving icon for tree node", e); //$NON-NLS-1$
    }
    if (imgDesc == null) {
        imgDesc = getIcon();
    }

    return imgDesc;

}

From source file:com.mountainminds.eclemma.internal.ui.EclEmmaUIPlugin.java

License:Open Source License

private static ImageRegistry loadImage(String path) {
    ImageRegistry reg = getInstance().getImageRegistry();
    if (reg.getDescriptor(path) == null) {
        URL url = instance.getBundle().getEntry(path);
        reg.put(path, ImageDescriptor.createFromURL(url));
    }//  www.  j a  v a2 s  .c o  m
    return reg;
}

From source file:com.nokia.carbide.cpp.internal.codescanner.markers.CSMarkerResolution.java

License:Open Source License

public Image getImage() {
    try {//  w  w  w.  j av  a 2  s  .c  om
        String iconPath = "icons/NoReference.png"; //$NON-NLS-1$
        if (reference != null) {
            iconPath = "icons/Reference.png"; //$NON-NLS-1$
        }
        URL installURL = CSPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$
        URL url = new URL(installURL, iconPath);
        return ImageDescriptor.createFromURL(url).createImage();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.nokia.carbide.cpp.internal.pi.visual.GraphComposite.java

License:Open Source License

/**
 * Initializes images for titlebar buttons
 */// w  w  w . ja  v  a2 s .co  m
private void createImagesForTitleBar() {

    // Get budle's location in file system
    URL url;
    ImageDescriptor createFromURL;
    Bundle piBundle = Platform.getBundle("com.nokia.carbide.cpp.pi"); //$NON-NLS-1$
    if (piBundle == null)
        return;

    // Maximize
    url = FileLocator.find(piBundle, new Path(Messages.getString("PIPageEditorContributor.maximizeGraphIcon")), //$NON-NLS-1$
            null);
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        imageMaximizeGraph = createFromURL.createImage();
        buttonMaximize.setImage(imageMaximizeGraph);

    }

    // Maximize restore
    url = FileLocator.find(piBundle,
            new Path(Messages.getString("PIPageEditorContributor.maximizeRestoreGraphIcon")), null); //$NON-NLS-1$
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        imageMaximizeRestoreGraph = createFromURL.createImage();

    }

    // Minimize
    url = FileLocator.find(piBundle, new Path(Messages.getString("PIPageEditorContributor.minimizeGraphIcon")), //$NON-NLS-1$
            null);
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        imageMinimizeGraph = createFromURL.createImage();
        buttonMinimize.setImage(imageMinimizeGraph);
    }

    // Minimize restore
    url = FileLocator.find(piBundle,
            new Path(Messages.getString("PIPageEditorContributor.minimizeRestoreGraphIcon")), null); //$NON-NLS-1$
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        imageMinimizeRestoreGraph = createFromURL.createImage();

    }

    // Move down
    url = FileLocator.find(piBundle, new Path(Messages.getString("PIPageEditorContributor.moveGraphDown")), //$NON-NLS-1$
            null);
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        imageMoveGraphDown = createFromURL.createImage();
        buttonMoveGraphDown.setImage(imageMoveGraphDown);

    }

    // Move Up
    url = FileLocator.find(piBundle, new Path(Messages.getString("PIPageEditorContributor.moveGraphUp")), null); //$NON-NLS-1$
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        imageMoveGraphUp = createFromURL.createImage();
        buttonMoveGraphUp.setImage(imageMoveGraphUp);
    }

}

From source file:com.nokia.carbide.cpp.internal.project.ui.views.SPNViewActionGroup.java

License:Open Source License

protected ImageDescriptor getImageDescriptor(String relativePath) {
    String iconPath = "icons/"; //$NON-NLS-1$
    try {//  w  ww . ja v a  2s .  com
        URL installURL = CUIPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$
        URL url = new URL(installURL, iconPath + relativePath);
        return ImageDescriptor.createFromURL(url);
    } catch (MalformedURLException e) {
        // should not happen
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:com.nokia.carbide.cpp.internal.ui.SharedImages.java

License:Open Source License

private ImageDescriptor createImageDescriptor(IPath path) {
    ImageDescriptor result;/*  ww  w. j  av a  2 s.c om*/
    URL url = FileLocator.find(CarbideUIPlugin.getDefault().getBundle(), path, null);
    if (url != null) {
        result = ImageDescriptor.createFromURL(url);
    } else {
        result = ImageDescriptor.getMissingImageDescriptor();
    }
    return result;
}

From source file:com.nokia.carbide.cpp.pi.editors.PIPageEditor.java

License:Open Source License

public static void createActions() {
    URL url;/*ww w.  j  av  a2  s  .c  o  m*/
    ImageDescriptor createFromURL;

    Bundle piBundle = Platform.getBundle("com.nokia.carbide.cpp.pi"); //$NON-NLS-1$
    if (piBundle == null)
        return;

    zoomInAction = new Action(Messages.getString("PIPageEditor.zoomIn")) { //$NON-NLS-1$
        public void run() {
            PIChangeEvent.action("-"); //$NON-NLS-1$
        }
    };
    zoomInAction.setToolTipText(Messages.getString("PIPageEditor.zoomIn")); //$NON-NLS-1$
    url = Platform.find(piBundle, new Path(Messages.getString("PIPageEditorContributor.zoomInIcon"))); //$NON-NLS-1$
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        zoomInAction.setImageDescriptor(createFromURL);
    }

    zoomOutAction = new Action(Messages.getString("PIPageEditor.zoomOut")) { //$NON-NLS-1$
        public void run() {
            PIChangeEvent.action("+"); //$NON-NLS-1$
        }
    };
    zoomOutAction.setToolTipText(Messages.getString("PIPageEditor.zoomOut")); //$NON-NLS-1$
    url = Platform.find(piBundle,
            new Path(Messages.getString("PIPageEditor.PIPageEditorContributor.zoomOutIcon"))); //$NON-NLS-1$
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        zoomOutAction.setImageDescriptor(createFromURL);
    }

    zoomToTraceAction = new Action(Messages.getString("PIPageEditor.showEntireGraph")) { //$NON-NLS-1$
        public void run() {
            PIChangeEvent.action("++"); //$NON-NLS-1$
        }
    };
    zoomToTraceAction.setToolTipText(Messages.getString("PIPageEditor.showEntireGraph")); //$NON-NLS-1$
    url = Platform.find(piBundle,
            new Path(Messages.getString("PIPageEditor.PIPageEditorContributor.showEntireGraphIcon"))); //$NON-NLS-1$
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        zoomToTraceAction.setImageDescriptor(createFromURL);
    }

    zoomToSelectionAction = new Action(Messages.getString("PIPageEditor.zoomToInterval")) { //$NON-NLS-1$
        public void run() {
            PIChangeEvent.action("--"); //$NON-NLS-1$
        }
    };
    zoomToSelectionAction.setToolTipText(Messages.getString("PIPageEditor.zoomToInterval")); //$NON-NLS-1$
    url = Platform.find(piBundle,
            new Path(Messages.getString("PIPageEditor.PIPageEditorContributor.ZoomToIntervalIcon"))); //$NON-NLS-1$
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        zoomToSelectionAction.setImageDescriptor(createFromURL);
    }

    selectTimeAction = new Action(Messages.getString("PIPageEditor.selectInterval")) { //$NON-NLS-1$
        public void run() {
            // remember the old time interval
            double startTime = PIPageEditor.currentPageEditor().getStartTime();
            double endTime = PIPageEditor.currentPageEditor().getEndTime();

            // get the new time interval
            new TimeSetDialog(PIPageEditor.currentPageEditor.getSite().getShell().getDisplay(), startTime,
                    endTime);

            if ((startTime == PIPageEditor.currentPageEditor().getStartTime())
                    && (endTime == PIPageEditor.currentPageEditor().getEndTime()))
                return;

            // propagate the new time interval
            PIChangeEvent.action("changeInterval"); //$NON-NLS-1$

            // after the graphs have been updated, notify plugins that might have tables but no graphs
            Enumeration enu = PluginInitialiser
                    .getPluginInstances("com.nokia.carbide.cpp.internal.pi.plugin.model.IEventListener"); //$NON-NLS-1$
            if (enu != null) {
                Event event = new Event();
                Double[] times = new Double[2];
                times[0] = PIPageEditor.currentPageEditor().getStartTime();
                times[1] = PIPageEditor.currentPageEditor().getEndTime();
                event.data = times;

                while (enu.hasMoreElements()) {
                    IEventListener plugin = (IEventListener) enu.nextElement();
                    plugin.receiveEvent("changeInterval", event); //$NON-NLS-1$
                }
            }
        }
    };
    selectTimeAction.setToolTipText(Messages.getString("PIPageEditor.selectInterval")); //$NON-NLS-1$
    url = Platform.find(piBundle,
            new Path(Messages.getString("PIPageEditor.PIPageEditorContributor.selectIntervalIcon"))); //$NON-NLS-1$
    if (url != null) {
        createFromURL = ImageDescriptor.createFromURL(url);
        selectTimeAction.setImageDescriptor(createFromURL);
    }
}

From source file:com.nokia.carbide.cpp.pi.PiPlugin.java

License:Open Source License

/**
 * Returns an image descriptor for the image file at the given
 * plug-in relative path./*  w ww. j a  va2 s.  c  o m*/
 *
 * @param path the path
 * @return the image descriptor
 */
public static ImageDescriptor getImageDescriptor(String path) {
    ImageDescriptor descriptor = getDefault().getImageRegistry().getDescriptor(path);
    if (descriptor == null) {
        descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getEntry(path));
        getDefault().getImageRegistry().put(path, descriptor);
    }
    return descriptor;
}

From source file:com.nokia.carbide.cpp.pi.wizards.WizardsPlugin.java

License:Open Source License

/**
 * Returns an image descriptor for the image file at the given plug-in
 * relative path.//from w w  w.java 2s.c o m
 * 
 * @param path
 *            the path
 * @return the image descriptor
 */
public static ImageDescriptor getImageDescriptor(final String path) {
    ImageDescriptor descriptor = getDefault().getImageRegistry().getDescriptor(path);
    if (descriptor == null) {
        descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getEntry(path));
        getDefault().getImageRegistry().put(path, descriptor);
    }
    return descriptor;
}