List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromImage
public static ImageDescriptor createFromImage(Image img)
From source file:org.eclipse.photran.internal.ui.views.vpgproblems.ShowFullMessageAction.java
License:Open Source License
@Override public ImageDescriptor getImageDescriptor() { Image img = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); return ImageDescriptor.createFromImage(img); }
From source file:org.eclipse.scout.rt.ui.rap.workbench.window.editor.ScoutFormEditorInput.java
License:Open Source License
@Override public ImageDescriptor getImageDescriptor() { final Image icon = getUiEnvironment().getIcon(getScoutObject().getIconId()); return ImageDescriptor.createFromImage(icon); }
From source file:org.eclipse.scout.rt.ui.swt.window.desktop.editor.ScoutFormEditorInput.java
License:Open Source License
@Override public ImageDescriptor getImageDescriptor() { final Image icon = getEnvironment().getIcon(getScoutObject().getIconId()); return ImageDescriptor.createFromImage(icon); }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.palette.PaletteImageProvider.java
License:Open Source License
/** * Returns the image descriptor from corresponding to the tool description * argument./*w w w . java 2 s . c o m*/ * * @param abstractToolDescription * the tool description. * @return the image. */ public ImageDescriptor getImageDescriptor(final AbstractToolDescription abstractToolDescription) { String path = null; if (abstractToolDescription.eClass().getEStructuralFeature(ICON_PATH) != null) { path = (String) abstractToolDescription .eGet(abstractToolDescription.eClass().getEStructuralFeature(ICON_PATH)); } if (path == null || StringUtil.isEmpty(path.trim())) { /* try to find the image descriptor with mappings */ final String domainClassToUse = PaletteImageProvider .getDomainClass(PaletteImageProvider.mappings(abstractToolDescription)); if (domainClassToUse != null) { /* * we can find the image of the tool with the domain class :) */ try { final EObject anInstance = SiriusPlugin.getDefault().getModelAccessorRegistry() .getModelAccessor(abstractToolDescription).createInstance(domainClassToUse); return DiagramUIPlugin.getPlugin().getItemImageDescriptor(anInstance); } catch (final MetaClassNotFoundException e) { SiriusPlugin.getDefault().warning("No icon is available for the tool " + abstractToolDescription.getName() + ". A default icon has been set instead.", null); } } if (abstractToolDescription instanceof EdgeCreationDescription) { path = DiagramImagesPath.PALETTE_EDGE_PATH; } else { path = DiagramImagesPath.PALETTE_FACTORY_DEFAULT_PATH; } } final Image res = getImageFromPath(path); ImageDescriptor desc; if (res == null) { desc = DiagramUIPlugin.Implementation .getBundledImageDescriptor(DiagramImagesPath.PALETTE_FACTORY_ERROR_PATH); } else { desc = ImageDescriptor.createFromImage(res); } return desc; }
From source file:org.eclipse.sirius.ui.tools.internal.actions.creation.CreateRepresentationAction.java
License:Open Source License
void updateActionLabels() { ImageDescriptor descriptor = ImageDescriptor.getMissingImageDescriptor(); final Image descImage = labelProvider.getImage(description); if (descImage != null) { descriptor = ImageDescriptor.createFromImage(descImage); }// www . j ava 2s . com this.setImageDescriptor(descriptor); computeRepresentationName(); this.setText(name); this.setToolTipText(description.getEndUserDocumentation()); if (session instanceof DAnalysisSessionImpl) { // Disable the action in case of the representation cannot be // created Collection<DRepresentationContainer> containers = ((DAnalysisSessionImpl) session) .getAvailableRepresentationContainers(description); // If containers is empty, a new one will be created, so the action // is enabled if (!containers.isEmpty()) { // Try to find one valid container candidate boolean enabled = false; for (DRepresentationContainer container : containers) { IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault() .getPermissionAuthority(container); if (permissionAuthority == null || permissionAuthority.canCreateIn(container)) { enabled = true; break; } } // for this.setEnabled(enabled); } } }
From source file:org.eclipse.sirius.ui.tools.internal.views.common.navigator.SiriusCommonLabelProvider.java
License:Open Source License
/** * {@inheritDoc}//from w w w. j a v a2 s. co m */ public Image getImage(Object element) { Image img = null; if (!(element instanceof IResource) && sessionLabelProvider != null) { try { // Let eclipse look for file and project icons + nature // decoration img = sessionLabelProvider.getImage(element); // If the current element is a dangling representation, its icon // is grayed. The grayed image is computed only once for each // type of representation. if (img != null && isDanglingRepresentation(element)) { DSemanticDecorator dSemanticDecorator = getDSemanticDecorator(element); String key = dSemanticDecorator.eClass().getName() + "_disabled"; Image disabledImage = SiriusEditPlugin.getPlugin().getImageRegistry().get(key); if (disabledImage == null) { ImageDescriptor desc = ImageDescriptor.createFromImage(img); ImageDescriptor disabledDesc = ImageDescriptor.createWithFlags(desc, SWT.IMAGE_DISABLE); SiriusEditPlugin.getPlugin().getImageRegistry().put(key, disabledDesc); disabledImage = SiriusEditPlugin.getPlugin().getImageRegistry().get(key); } img = disabledImage; } } catch (IllegalStateException e) { // This can happen when trying to get the label of a CDOObject // which // Transaction has just been closed // Nothing to do, null will returned } catch (NullPointerException e) { // This can happen when trying to get the label of a CDOObject // which transaction has just been closed // Nothing to do, null will returned } } else if (element instanceof IFile) { // This file is not in a ModelingProject (check in // <possibleChildren> and <triggerPoints> of // "org.eclipse.ui.navigator.navigatorContent" of plugin.xml) IFile file = (IFile) element; if (new IFileQuery(file).isResourceHandledByOpenedSession()) { // Add "Sirius Modeling" overlay on this semantic file. String fileExtension = file.getFileExtension(); // Create a key to store/restore the image in image registry of // SiriusEditPlugin String imgKey = fileExtension + "Decorated"; // Get the existing image (if any) img = SiriusEditPlugin.getPlugin().getImageRegistry().get(imgKey); // If the image has already been computed, use it. if (img == null) { // Get the base image to overlay ImageDescriptor imageDescriptor = null; IWorkbenchAdapter wbAdapter = (IWorkbenchAdapter) file.getAdapter(IWorkbenchAdapter.class); if (wbAdapter != null) { imageDescriptor = wbAdapter.getImageDescriptor(file); } if (imageDescriptor != null) { // Add an overlay with the "Sirius Modeling" overlay ImageDescriptor[] imageDescriptors = new ImageDescriptor[5]; imageDescriptors[IDecoration.TOP_RIGHT] = SIRIUS_MODELING_OVERLAY_DESC; img = new DecorationOverlayIcon(imageDescriptor.createImage(), imageDescriptors) .createImage(); SiriusEditPlugin.getPlugin().getImageRegistry().put(imgKey, img); } } } } return img; }
From source file:org.eclipse.stem.ui.views.SimulationControlView.java
License:Open Source License
/** * This is the method where the view is put together piece by piece * // w ww . j a va 2s.co m * @param parent */ @Override public void createPartControl(Composite parent) { final int COLUMNS = 1; scrollComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER); scrollComposite.setExpandHorizontal(true); scrollComposite.setExpandVertical(true); scrollComposite.setMinSize(SCROLL_MIN_LENGTH, SCROLL_MIN_HEIGTH); scrollComposite.setLayout(new GridLayout()); controlComposite = new Composite(scrollComposite, SWT.NONE); scrollComposite.setContent(controlComposite); // setup the layout GridData data = new GridData(GridData.FILL_BOTH); controlComposite.setLayoutData(data); GridLayout layout = new GridLayout(); layout.numColumns = COLUMNS; layout.marginHeight = 0; layout.marginWidth = 0; controlComposite.setLayout(layout); // Create the actions for master simulation control runAction = new Action(Messages.getString("SCView.Run"), ImageDescriptor.createFromImage(Activator //$NON-NLS-1$ .getDefault().getImageRegistry().get(ISharedImages.RUN_ICON))) { public void run() { masterRunAction(); } }; pauseAction = new Action(Messages.getString("SCView.Pause"), ImageDescriptor //$NON-NLS-1$ .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.PAUSE_ICON))) { public void run() { masterPauseAction(); } }; resetAction = new Action(Messages.getString("SCView.Reset"), ImageDescriptor //$NON-NLS-1$ .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.RESET_ICON))) { public void run() { masterResetAction(); } }; stepAction = new Action(Messages.getString("SCView.Step"), ImageDescriptor //$NON-NLS-1$ .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.STEP_ICON))) { public void run() { masterStepAction(); } }; stopAction = new Action(Messages.getString("SCView.Stop"), ImageDescriptor //$NON-NLS-1$ .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.STOP_ICON))) { public void run() { masterStopAction(); } }; // Set disabled icons for our master control runAction.setDisabledImageDescriptor(ImageDescriptor .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.DISABLED_RUN_ICON))); pauseAction.setDisabledImageDescriptor(ImageDescriptor .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.DISABLED_PAUSE_ICON))); resetAction.setDisabledImageDescriptor(ImageDescriptor .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.DISABLED_RESET_ICON))); stepAction.setDisabledImageDescriptor(ImageDescriptor .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.DISABLED_STEP_ICON))); stopAction.setDisabledImageDescriptor(ImageDescriptor .createFromImage(Activator.getDefault().getImageRegistry().get(ISharedImages.DISABLED_STOP_ICON))); // Initial state if master control should be DISABLED runAction.setEnabled(false); pauseAction.setEnabled(false); resetAction.setEnabled(false); stepAction.setEnabled(false); stopAction.setEnabled(false); // get the action manager for this view actionBars = getViewSite().getActionBars(); // get the drop down menu manager for this view dropDownMenu = actionBars.getMenuManager(); // get the tool bar manager for this view toolBar = actionBars.getToolBarManager(); // Add all actions to drop down menu on the right corner of this view dropDownMenu.add(runAction); dropDownMenu.add(pauseAction); dropDownMenu.add(resetAction); dropDownMenu.add(stepAction); dropDownMenu.add(stopAction); // Add all actions to the tool bar of this view toolBar.add(runAction); toolBar.add(pauseAction); toolBar.add(resetAction); toolBar.add(stepAction); toolBar.add(stopAction); // if any active Simulations, use them List<ISimulation> list = simulationManager.getActiveSimulations(); for (ISimulation sim : list) { addSimulation(sim); } }
From source file:org.eclipse.tcf.te.tcf.filesystem.ui.internal.compare.LocalFileSaveable.java
License:Open Source License
@Override public ImageDescriptor getImageDescriptor() { Image image = input.getImage(); if (image != null) return ImageDescriptor.createFromImage(image); return null;/*from ww w .j a v a 2 s . c o m*/ }
From source file:org.eclipse.tcf.te.tcf.ui.handler.DefaultContextSelectorToolbarContribution.java
License:Open Source License
protected IAction getAction(final IPeerNode peerNode) { IAction action = new Action() { private IPeerNode node = peerNode; @Override/* w ww .j av a2 s . c o m*/ public void run() { ServiceManager.getInstance().getService(IDefaultContextService.class).setDefaultContext(node); } }; DelegatingLabelProvider labelProvider = new DelegatingLabelProvider(); action.setText(labelProvider.getText(peerNode)); Image image = labelProvider.decorateImage(labelProvider.getImage(peerNode), peerNode); action.setImageDescriptor(ImageDescriptor.createFromImage(image)); return action; }
From source file:org.eclipse.team.internal.ui.synchronize.LocalResourceSaveableComparison.java
License:Open Source License
public ImageDescriptor getImageDescriptor() { Image image = input.getImage(); if (image != null) return ImageDescriptor.createFromImage(image); return TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_SYNC_VIEW); }