List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromURL
public static ImageDescriptor createFromURL(URL url)
From source file:com.liferay.ide.xml.search.ui.markerResolutions.DecreaseInstanceScopeXmlValidationLevel.java
License:Open Source License
@Override public Image getImage() { final URL url = LiferayXMLSearchUI.getDefault().getBundle().getEntry("/icons/arrow_down.png"); return ImageDescriptor.createFromURL(url).createImage(); }
From source file:com.lmpessoa.sonarview.ui.Images.java
License:Open Source License
private static ImageDescriptor createImageDescriptor(String key) { ImageRegistry imageRegistry = getImageRegistry(); if (imageRegistry != null) { ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(key); if (imageDescriptor == null) { try { imageDescriptor = ImageDescriptor.createFromURL(getUrl(key)); } catch (MalformedURLException e) { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); }//www .ja v a 2 s. c om imageRegistry.put(key, imageDescriptor); } return imageDescriptor; } return null; }
From source file:com.matlab.eclipse.mconsole.views.MatlabConsoleView.java
License:Open Source License
private void makeActions() { pauseMatlabAction = new Action() { @Override// www.j a va2s . co m public void run() { try { MConsolePlugin.getDefault().getMatlab().sendBreak(); } catch (Exception e) { MatclipseUtilPlugin.getDefault().errorDialog("Unable to cancel Matlab evaluation", e); } } }; pauseMatlabAction.setText("Cancel Evaluation"); pauseMatlabAction.setToolTipText("Cancel Evaluation"); pauseMatlabAction.setImageDescriptor(ImageDescriptor .createFromURL(MConsolePlugin.getDefault().getBundle().getEntry("icons/matlab_pause_action.gif"))); pauseMatlabAction.setEnabled(false); startMatlabAction = new Action() { @Override public void run() { try { MConsolePlugin.getDefault().getMatlab().start(); } catch (Exception e) { MatclipseUtilPlugin.getDefault().errorDialog("Unable to start Matlab", e); } } }; startMatlabAction.setText("Start Matlab"); startMatlabAction.setToolTipText("Start Matlab"); startMatlabAction.setImageDescriptor(ImageDescriptor .createFromURL(MConsolePlugin.getDefault().getBundle().getEntry("icons/matlab_start_action.gif"))); stopMatlabAction = new Action() { @Override public void run() { MConsolePlugin.getDefault().getMatlab().stop(); } }; stopMatlabAction.setText("Stop Matlab"); stopMatlabAction.setToolTipText("Stop Matlab"); stopMatlabAction.setImageDescriptor(ImageDescriptor .createFromURL(MConsolePlugin.getDefault().getBundle().getEntry("icons/matlab_stop_action.gif"))); clearCommandHistoryAction = new Action() { @Override public void run() { commandLineResultsText.setText(""); commandLineText.setFocus(); } }; clearCommandHistoryAction.setText("Clear"); clearCommandHistoryAction.setToolTipText("Clear Matlab Console"); clearCommandHistoryAction.setImageDescriptor( ImageDescriptor.createFromURL(MConsolePlugin.getDefault().getBundle().getEntry("icons/clear.gif"))); copyCommandHistoryAction = new Action() { @Override public void run() { Clipboard clipboard = new Clipboard(MatlabConsoleView.this.getSite().getShell().getDisplay()); String plainText = commandLineResultsText.getSelectionText(); TextTransfer textTransfer = TextTransfer.getInstance(); clipboard.setContents(new String[] { plainText }, new Transfer[] { textTransfer }); clipboard.dispose(); } }; copyCommandHistoryAction.setText("Copy"); copyCommandHistoryAction.setToolTipText("Copy"); copyCommandHistoryAction.setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); copyCommandHistoryAction.setEnabled(false); selectAllCommandHistoryAction = new Action() { @Override public void run() { commandLineResultsText.selectAll(); copyCommandHistoryAction.setEnabled(true); } }; selectAllCommandHistoryAction.setText("Select All"); selectAllCommandHistoryAction.setToolTipText("Select All"); dirChooseAction = new Action() { @Override public void run() { Shell shell = MatlabConsoleView.this.getSite().getShell(); DirectoryDialog dialog = new DirectoryDialog(shell); try { dialog.setText(MConsolePlugin.getDefault().getMatlab().getMatlabPwd()); } catch (MatlabCommunicationException e) { return; } catch (MatlabNotStartedException e) { return; } dialog.setMessage("Select directory"); String path = dialog.open(); if (path == null) return; else MatlabConsoleView.getDefault().run("cd " + path, null); } }; dirChooseAction.setText("Open Directory"); dirChooseAction.setToolTipText("Open Directory"); dirChooseAction.setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER)); dirUpAction = new Action() { @Override public void run() { String path = ""; try { path = MConsolePlugin.getDefault().getMatlab().getMatlabPwd(); } catch (MatlabCommunicationException e) { return; } catch (MatlabNotStartedException e) { return; } File pathfile = new File(path); int index; if (!MConsolePlugin.getSystem().contains("windows")) index = pathfile.getAbsolutePath().lastIndexOf("/"); else index = pathfile.getAbsolutePath().lastIndexOf("\\"); String pathwo = pathfile.getAbsolutePath().substring(0, index); MatlabConsoleView.getDefault().run("cd " + pathwo, null); } }; dirUpAction.setText("Change to parent directory"); dirUpAction.setToolTipText("Change to parent directory"); dirUpAction.setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_UP)); raiseFiguresAction = new Action() { @Override public void run() { try { MConsolePlugin.getDefault().getMatlab().eval("raise_figure('')", false, false); } catch (MatlabCommunicationException e) { } catch (MatlabNotStartedException e) { } } }; raiseFiguresAction.setText("Raise my figures"); raiseFiguresAction.setToolTipText("Raise my figures"); raiseFiguresAction.setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD)); closeAllFiguresAction = new Action() { @Override public void run() { try { MConsolePlugin.getDefault().getMatlab().eval("close_figure('')", false, false); } catch (MatlabCommunicationException e) { } catch (MatlabNotStartedException e) { } } }; closeAllFiguresAction.setText("Close my figures"); closeAllFiguresAction.setToolTipText("Close my figures"); closeAllFiguresAction.setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW)); helpBrowserAction = new Action() { @Override public void run() { try { MConsolePlugin.getDefault().getMatlab().eval("helpbrowser", false, false); } catch (MatlabCommunicationException e) { } catch (MatlabNotStartedException e) { } } }; helpBrowserAction.setText("Matlab Helpbrowser"); helpBrowserAction.setToolTipText("Matlab Helpbrowser"); helpBrowserAction.setImageDescriptor( ImageDescriptor.createFromURL(MConsolePlugin.getDefault().getBundle().getEntry("icons/help.gif"))); // TODO: Hide Debug View on Shutdown debugConsoleViewAction = new Action() { @Override public void run() { try { if (!debugConsoleViewAction.isChecked()) { MConsolePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView("com.matlab.eclipse.mconsole.views.MatlabConsoleDebugView"); MConsolePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView("com.matlab.eclipse.mconsole.views.MatlabConsoleView"); MConsolePlugin.getDefault().getMatlab().setLogging(true); debugConsoleViewAction.setChecked(true); debugConsoleViewAction.setText("Turn debugging off"); } else { IViewPart debugConsoleView = MConsolePlugin.getDefault().getWorkbench() .getActiveWorkbenchWindow().getActivePage() .findView("com.matlab.eclipse.mconsole.views.MatlabConsoleDebugView"); MConsolePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage() .hideView(debugConsoleView); MConsolePlugin.getDefault().getMatlab().setLogging(false); debugConsoleViewAction.setChecked(false); debugConsoleViewAction.setText("Turn debugging off"); } // Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().hi } catch (Exception e) { } } }; debugConsoleViewAction.setText("Turn debugging on"); debugConsoleViewAction.setToolTipText("Toggle Matlab Console Debug"); debugConsoleViewAction.setImageDescriptor(ImageDescriptor .createFromURL(MConsolePlugin.getDefault().getBundle().getEntry("icons/debug_view.gif"))); }
From source file:com.mentor.nucleus.bp.core.CorePlugin.java
License:Open Source License
/** * Returns the ImageDescriptor instance identified by the passed * string.// ww w . j av a 2 s. c o m */ public static ImageDescriptor getImageDescriptor(String name) { String iconPath = "icons/"; try { CorePlugin plugin = getDefault(); if (plugin == null) { RuntimeException rtException = new RuntimeException( "Unable to acquire the CorePlugin therefore the icon " + iconPath + name + " can not be loaded."); throw rtException; } URL installURL = plugin.getBundle().getEntry("/"); URL url = new URL(installURL, iconPath + name); InputStream check = null; try { check = url.openStream(); } catch (IOException e1) { logError("Can not load the icon: " + iconPath + name, e1); } finally { if (check != null) { try { check.close(); } catch (IOException e2) { } } } ImageDescriptor imageDescriptor = getStaticImageRegistry().getDescriptor(name); if (imageDescriptor == null) { imageDescriptor = ImageDescriptor.createFromURL(url); if ((!name.equals("InterfaceOperation_c")) && (!name.equals("InterfaceSignal_c") && (!name.equals("ProvidedOperation_c")) && (!name.equals("ProvidedSignal_c")) && (!name.equals("RequiredOperation_c")) && (!name.equals("RequiredSignal_c")))) { getStaticImageRegistry().put(name, imageDescriptor); } } return imageDescriptor; } catch (RuntimeException e) { // this can happen if we fail to acquire a model builder license. return ImageDescriptor.getMissingImageDescriptor(); } catch (MalformedURLException e) { // this can happen if we fail to acquire a model builder license. return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:com.mentor.nucleus.bp.ui.canvas.CanvasPlugin.java
License:Open Source License
public static ImageDescriptor getImageDescriptor(String name) { String iconPath = "icons/"; try {// ww w. j av a 2 s .c o m URL installURL = getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ URL url = new URL(installURL, iconPath + name); return ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { // should not happen return ImageDescriptor.getMissingImageDescriptor(); } }
From source file:com.mercatis.lighthouse3.security.ui.editors.AccessorBasedPermissionEditor.java
License:Apache License
@Override protected void addPages() { userPermissionAccessorBasedEditorPage = new UserPermissionAccessorBasedEditorPage(this, "Users"); groupPermissionAccessorBasedEditorPage = new GroupPermissionAccessorBasedEditorPage(this, "Groups"); try {// w ww . j ava2 s . com int pageIndex = this.addPage(userPermissionAccessorBasedEditorPage); setPageImage(pageIndex, ImageDescriptor.createFromURL(getClass().getResource("/icons/user.png")).createImage()); pageIndex = this.addPage(groupPermissionAccessorBasedEditorPage); setPageImage(pageIndex, ImageDescriptor.createFromURL(getClass().getResource("/icons/group.png")).createImage()); } catch (PartInitException ex) { Activator.getDefault().getLog() .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex)); } }
From source file:com.mercatis.lighthouse3.security.ui.editors.ContextBasedPermissionEditor.java
License:Apache License
@Override protected void addPages() { userPermissionContextBasedEditorPage = new UserPermissionContextBasedEditorPage(this, "Users"); groupPermissionContextBasedEditorPage = new GroupPermissionContextBasedEditorPage(this, "Groups"); try {/*w w w .ja v a2 s.c om*/ int pageIndex = this.addPage(userPermissionContextBasedEditorPage); setPageImage(pageIndex, ImageDescriptor.createFromURL(getClass().getResource("/icons/user.png")).createImage()); pageIndex = this.addPage(groupPermissionContextBasedEditorPage); setPageImage(pageIndex, ImageDescriptor.createFromURL(getClass().getResource("/icons/group.png")).createImage()); } catch (PartInitException ex) { Activator.getDefault().getLog() .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex)); } }
From source file:com.mercatis.lighthouse3.security.ui.model.GroupAccessor.java
License:Apache License
@Override public Image getImage() { if (image == null) { image = ImageDescriptor.createFromURL(getClass().getResource("/icons/group.png")).createImage(); }/*from w w w . j ava 2s. c o m*/ return image; }
From source file:com.mercatis.lighthouse3.security.ui.model.UserAccessor.java
License:Apache License
@Override public Image getImage() { if (image == null) { image = ImageDescriptor.createFromURL(getClass().getResource("/icons/user.png")).createImage(); }/*from w w w. ja v a 2s . c o m*/ return image; }
From source file:com.mercatis.lighthouse3.security.ui.providers.GroupLabelProvider.java
License:Apache License
public Image getImage(Object element) { if (image == null) { image = ImageDescriptor.createFromURL(getClass().getResource("/icons/group.png")).createImage(); }//w w w. j ava2 s .co m return image; }