List of usage examples for org.eclipse.jface.viewers DecorationOverlayIcon DecorationOverlayIcon
public DecorationOverlayIcon(ImageDescriptor baseImageDescriptor, ImageDescriptor overlayImageDescriptor, int quadrant)
From source file:org.bonitasoft.studio.configuration.ui.wizard.WizardPageDecorator.java
License:Open Source License
@Override public Image decorateImage(Image image, Object element) { IProcessConfigurationWizardPage page = (IProcessConfigurationWizardPage) element; String erroMessage = page.isConfigurationPageValid(dialog.getConfiguration()); if (image != null && erroMessage != null) { return new DecorationOverlayIcon(image, Pics.getImageDescriptor("problem.gif", ConfigurationPlugin.getDefault()), IDecoration.BOTTOM_RIGHT).createImage(); }/* w w w . j a v a 2 s. c om*/ return null; }
From source file:org.bonitasoft.studio.dependencies.ui.MissingDependenciesDecorator.java
License:Open Source License
protected Image getErrorDecoratedImage(Image image) { if (errorIcon == null) { errorIcon = new DecorationOverlayIcon(image, new ImageDescriptor() { @Override/* w w w . j a v a 2s . c o m*/ public ImageData getImageData() { return errorDecoratorImage.getImageData(); } }, IDecoration.BOTTOM_RIGHT).createImage(); } return errorIcon; }
From source file:org.bonitasoft.studio.dependencies.ui.MissingDependenciesDecorator.java
License:Open Source License
protected Image getWarningDecoratedImage(Image image) { if (warningIcon == null) { warningIcon = new DecorationOverlayIcon(image, new ImageDescriptor() { @Override//from w w w . jav a 2s. com public ImageData getImageData() { return warningDecoratorImage.getImageData(); } }, IDecoration.BOTTOM_RIGHT).createImage(); } return warningIcon; }
From source file:org.bonitasoft.studio.model.edit.custom.process.CustomDataItemProvider.java
License:Open Source License
@Override public Object getImage(Object object) { Object icon = super.getImage(object); if (object instanceof Data) { Image iconImage = null;//from w w w . ja v a 2 s.c o m if (icon instanceof URL) { iconImage = ExtendedImageRegistry.getInstance().getImage(icon); } else if (icon instanceof Image) { iconImage = (Image) icon; } if (iconImage != null) { boolean formTransient = ((Data) object).getDatasourceId() != null && ((Data) object).getDatasourceId().equals("PAGEFLOW"); if (formTransient) { Image img = EMFEditCustomPlugin.getDefault().getImageRegistry() .get("decoratedImageFor" + ((EObject) object).eClass().getName()); if (img == null) { img = new DecorationOverlayIcon(iconImage, Pics.getImageDescriptor("form_decorator.png", EMFEditCustomPlugin.getDefault()), IDecoration.BOTTOM_LEFT).createImage(); EMFEditCustomPlugin.getDefault().getImageRegistry() .put("decoratedImageFor" + ((EObject) object).eClass().getName(), img); } return img; } } } return icon; }
From source file:org.bonitasoft.studio.model.edit.custom.process.CustomJavaObjectDataItemProvider.java
License:Open Source License
@Override public Object getImage(Object object) { Object icon = super.getImage(object); if (object instanceof Data) { Image iconImage = null;/*from ww w . j av a2 s . co m*/ boolean formTransient = ((Data) object).getDatasourceId() != null && ((Data) object).getDatasourceId().equals("PAGEFLOW"); if (object instanceof JavaObjectData) { if (((JavaObjectData) object).getClassName() != null) { try { IType t = RepositoryManager.getInstance().getCurrentRepository().getJavaProject() .findType(((JavaObjectData) object).getClassName()); if (t != null && t.isInterface()) { iconImage = Pics.getImage("int_obj.gif"); if (EMFEditCustomPlugin.getDefault().getImageRegistry() .get("decoratedImageForInterfaceJavaObject") == null) { EMFEditCustomPlugin.getDefault().getImageRegistry().put( "decoratedImageForInterfaceJavaObject", new DecorationOverlayIcon(iconImage, Pics.getImageDescriptor("form_decorator.png", EMFEditCustomPlugin.getDefault()), IDecoration.BOTTOM_LEFT).createImage()); } if (formTransient) { return EMFEditCustomPlugin.getDefault().getImageRegistry() .get("decoratedImageForInterfaceJavaObject"); } return iconImage; } else { iconImage = Pics.getImage("class_obj.gif"); if (EMFEditCustomPlugin.getDefault().getImageRegistry() .get("decoratedImageForClassJavaObject") == null) { EMFEditCustomPlugin.getDefault().getImageRegistry().put( "decoratedImageForClassJavaObject", new DecorationOverlayIcon(iconImage, Pics.getImageDescriptor("form_decorator.png", EMFEditCustomPlugin.getDefault()), IDecoration.BOTTOM_LEFT).createImage()); } if (formTransient) { return EMFEditCustomPlugin.getDefault().getImageRegistry() .get("decoratedImageForClassJavaObject"); } return iconImage; } } catch (JavaModelException e) { } } } } return icon; }
From source file:org.cloudfoundry.ide.eclipse.internal.server.ui.editor.ApplicationMasterPart.java
License:Open Source License
private void createApplicationsSection() { Section section = getSection();/*from w w w.jav a2s. co m*/ section.setLayout(new GridLayout()); GridDataFactory.fillDefaults().grab(true, true).applyTo(section); section.setText("Applications"); section.setDescription("List of currently deployed applications."); Composite client = toolkit.createComposite(section); client.setLayout(new GridLayout()); GridDataFactory.fillDefaults().grab(true, true).applyTo(client); section.setClient(client); Composite headerComposite = toolkit.createComposite(section, SWT.NONE); RowLayout rowLayout = new RowLayout(); rowLayout.marginTop = 0; rowLayout.marginBottom = 0; headerComposite.setLayout(rowLayout); headerComposite.setBackground(null); ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); toolBarManager.createControl(headerComposite); applicationsViewer = new TableViewer(toolkit.createTable(client, SWT.NONE)); applicationsViewer.setContentProvider(new ApplicationsMasterPartContentProvider()); applicationsViewer.setLabelProvider(new ServerLabelProvider() { @Override public Image getImage(Object element) { Image image = super.getImage(element); if (element instanceof IModule) { IModule module = (IModule) element; ApplicationModule appModule = editorPage.getCloudServer().getApplication(module); if (appModule.getErrorMessage() != null) { return CloudFoundryImages.getImage(new DecorationOverlayIcon(image, CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT)); } } return image; } }); applicationsViewer.setInput(new CloudApplication[0]); applicationsViewer.setSorter(new CloudFoundryViewerSorter()); applicationsViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); IModule module = (IModule) selection.getFirstElement(); if (currentModule != module) { currentModule = module; getManagedForm().fireSelectionChanged(ApplicationMasterPart.this, selection); } } }); GridDataFactory.fillDefaults().grab(true, true).hint(250, SWT.DEFAULT) .applyTo(applicationsViewer.getControl()); int ops = DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT; Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() }; ApplicationViewersDropAdapter listener = new ApplicationViewersDropAdapter(applicationsViewer); applicationsViewer.addDropSupport(ops, transfers, listener); // create context menu MenuManager menuManager = new MenuManager(); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillApplicationsContextMenu(manager); } }); Menu menu = menuManager.createContextMenu(applicationsViewer.getControl()); applicationsViewer.getControl().setMenu(menu); editorPage.getSite().registerContextMenu(menuManager, applicationsViewer); Action addRemoveApplicationAction = new Action("Add/Remove Applications", ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_MODIFY_MODULES)) { @Override public void run() { ModifyModulesWizard wizard = new ModifyModulesWizard(cloudServer.getServerOriginal()); WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard); dialog.open(); } }; toolBarManager.add(addRemoveApplicationAction); toolBarManager.update(true); section.setTextClient(headerComposite); getManagedForm().getToolkit().paintBordersFor(client); }
From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.editor.ApplicationMasterPart.java
License:Open Source License
private void createApplicationsSection() { Section section = getSection();// ww w . jav a 2 s . c o m section.setLayout(new GridLayout()); GridDataFactory.fillDefaults().grab(true, true).applyTo(section); section.setText(Messages.COMMONTXT_APPLICATIONS); section.setDescription(Messages.ApplicationMasterPart_TEXT_APP_DESCRIP); section.setExpanded(true); Composite client = toolkit.createComposite(section); client.setLayout(new GridLayout()); GridDataFactory.fillDefaults().grab(true, true).applyTo(client); section.setClient(client); Composite headerComposite = toolkit.createComposite(section, SWT.NONE); RowLayout rowLayout = new RowLayout(); rowLayout.marginTop = 0; rowLayout.marginBottom = 0; headerComposite.setLayout(rowLayout); headerComposite.setBackground(null); ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); toolBarManager.createControl(headerComposite); applicationsViewer = new TableViewer(toolkit.createTable(client, SWT.NONE)); applicationsViewer.setContentProvider(new TreeContentProvider()); applicationsViewer.setLabelProvider(new ServerLabelProvider() { @Override public Image getImage(Object element) { Image image = super.getImage(element); if (element instanceof IModule) { IModule module = (IModule) element; CloudFoundryApplicationModule appModule = editorPage.getCloudServer() .getExistingCloudModule(module); if (appModule != null && appModule.getErrorMessage() != null) { return CloudFoundryImages.getImage(new DecorationOverlayIcon(image, CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT)); } } return image; } @Override public String getText(Object element) { // This is the WTP module name (usually, it's the workspace // project name) String moduleName = super.getText(element); // However, the user has the option to specify a different name // when pushing an app, which is used as the cf app name. If // they are different, and the // corresponding workspace project is accessible, show both. // Otherwise, show the cf app name. if (element instanceof IModule) { IModule module = (IModule) element; // Find the corresponding Cloud Foundry-aware application // Module. CloudFoundryApplicationModule appModule = cloudServer.getExistingCloudModule((IModule) element); if (appModule != null) { String cfAppName = appModule.getDeployedApplicationName(); if (cfAppName != null) { // Be sure not to show a null WTP module name, // although // that should not be encountered if (moduleName != null && !cfAppName.equals(moduleName) && CloudFoundryProperties.isModuleProjectAccessible .testProperty(new IModule[] { module }, cloudServer)) { moduleName = cfAppName + " (" + moduleName + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } else { moduleName = cfAppName; } } } } return moduleName; } }); applicationsViewer.setInput(new CloudApplication[0]); applicationsViewer.setSorter(new CloudFoundryViewerSorter()); applicationsViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); IModule module = (IModule) selection.getFirstElement(); if (currentModule != module) { currentModule = module; getManagedForm().fireSelectionChanged(ApplicationMasterPart.this, selection); } } }); GridDataFactory.fillDefaults().grab(true, true).hint(250, SWT.DEFAULT) .applyTo(applicationsViewer.getControl()); int ops = DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT; Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() }; ApplicationViewersDropAdapter listener = new ApplicationViewersDropAdapter(applicationsViewer); applicationsViewer.addDropSupport(ops, transfers, listener); // create context menu MenuManager menuManager = new MenuManager(); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillApplicationsContextMenu(manager); } }); Menu menu = menuManager.createContextMenu(applicationsViewer.getControl()); applicationsViewer.getControl().setMenu(menu); editorPage.getSite().registerContextMenu(menuManager, applicationsViewer); Action addRemoveApplicationAction = new Action(Messages.ApplicationMasterPart_TEXT_ADD_REMOVE, ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_MODIFY_MODULES)) { @Override public void run() { ModifyModulesWizard wizard = new ModifyModulesWizard(cloudServer.getServerOriginal()); WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard); dialog.open(); } }; toolBarManager.add(addRemoveApplicationAction); // Fix for STS-2996. Moved from CloudFoundryApplicationsEditorPage toolBarManager.add(RefreshEditorAction.getRefreshAction(editorPage, null)); toolBarManager.update(true); section.setTextClient(headerComposite); getManagedForm().getToolkit().paintBordersFor(client); }
From source file:org.eclipse.acceleo.internal.ide.ui.editors.template.AcceleoEditor.java
License:Open Source License
/** * Change the error image in the editor's tab. *//*w w w. ja v a 2 s .c om*/ protected void changeErrorImage() { final AcceleoEditor editor = this; Image currentImage = editor.getTitleImage(); if (originalTitleImage == null) { // when closing Eclipse, the image could be disposed and we can still try to change the image if (currentImage.isDisposed()) { return; } // make a copy because the original image will be disposed originalTitleImage = new Image(Display.getDefault(), currentImage.getImageData()); } try { IMarker[] problemMarkers = getFile().findMarkers(AcceleoMarkerUtils.PROBLEM_MARKER_ID, false, IResource.DEPTH_INFINITE); boolean hasProblemMarkers = problemMarkers.length > 0; IMarker[] warningMarkers = getFile().findMarkers(AcceleoMarkerUtils.WARNING_MARKER_ID, false, IResource.DEPTH_INFINITE); boolean hasWarningMarkers = warningMarkers.length > 0; if (hasProblemMarkers) { if (errorTitleImage == null) { ImageDescriptor errorDescriptor = PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR); errorTitleImage = new DecorationOverlayIcon(originalTitleImage, errorDescriptor, IDecoration.BOTTOM_LEFT).createImage(); } if (currentImage != errorTitleImage) { editor.setTitleImage(errorTitleImage); } } else if (hasWarningMarkers) { if (warningTitleImage == null) { ImageDescriptor errorDescriptor = PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING); warningTitleImage = new DecorationOverlayIcon(originalTitleImage, errorDescriptor, IDecoration.BOTTOM_LEFT).createImage(); } if (currentImage != warningTitleImage && !warningTitleImage.isDisposed()) { editor.setTitleImage(warningTitleImage); } } else { if (currentImage != originalTitleImage && !originalTitleImage.isDisposed()) { editor.setTitleImage(originalTitleImage); } } if (AcceleoEditor.this.getSourceViewer() instanceof ProjectionViewer) { ProjectionViewer viewer = (ProjectionViewer) AcceleoEditor.this.getSourceViewer(); viewer.getControl().redraw(); } } catch (CoreException e) { AcceleoUIActivator.getDefault().getLog().log(e.getStatus()); } }
From source file:org.eclipse.acceleo.internal.ide.ui.editors.template.outline.AcceleoOutlinePageItemProvider.java
License:Open Source License
/** * Computes the image of the template that should appears in the outline view. * /* ww w . j a v a 2s .c o m*/ * @param template * The template * @return The image that will illustrate the template in the outline view */ private Object computeImage(final Template template) { Object result = null; if (template.getVisibility().getValue() == VisibilityKind.PROTECTED_VALUE) { result = AcceleoUIActivator.getDefault().getImage("icons/template-editor/Template_protected.gif"); //$NON-NLS-1$ } else if (template.getVisibility().getValue() == VisibilityKind.PRIVATE_VALUE) { result = AcceleoUIActivator.getDefault().getImage("icons/template-editor/Template_private.gif"); //$NON-NLS-1$ } else { boolean isMain = false; Iterator<EObject> iChildren = template.eAllContents(); while (!isMain && iChildren.hasNext()) { EObject iChild = iChildren.next(); if (iChild instanceof Comment && ((Comment) iChild).getBody() != null && ((Comment) iChild).getBody().indexOf(IAcceleoConstants.TAG_MAIN) > -1) { isMain = true; } } if (isMain) { result = AcceleoUIActivator.getDefault().getImage("icons/template-editor/Template_main.gif"); //$NON-NLS-1$ } else { result = AcceleoUIActivator.getDefault().getImage("icons/template-editor/Template.gif"); //$NON-NLS-1$ } } if (template.getOverrides().size() > 0 && result instanceof Image) { Image image = AcceleoUIActivator.getDefault().getImage("icons/template-editor/Override_overlay.gif"); //$NON-NLS-1$ ImageDescriptor descriptor = ImageDescriptor.createFromImage(image); result = new DecorationOverlayIcon((Image) result, descriptor, IDecoration.TOP_RIGHT).createImage(); } return result; }
From source file:org.eclipse.babel.editor.tree.internal.KeyTreeLabelProvider.java
License:Open Source License
/** * @see ILabelProvider#getImage(Object)/*w w w . j ava 2s . co m*/ */ public Image getImage(Object element) { if (element instanceof KeyTreeNode) { KeyTreeNode node = (KeyTreeNode) element; Collection<IMessageCheck> c = editor.getMarkers().getFailedChecks(node.getMessageKey()); if (c == null || c.isEmpty()) { // Return the default key image as no issue exists return UIUtils.getKeyImage(); } if (editor.getMarkers().isUnusedKey(node.getMessageKey(), false)) { if (editor.getMarkers().isMissingKey(node.getMessageKey())) { return UIUtils.getMissingAndUnusedTranslationsImage(); } else if (editor.getMarkers().isDuplicateValue(node.getMessageKey())) { return UIUtils.getDuplicateEntryAndUnusedTranslationsImage(); } return UIUtils.getUnusedTranslationsImage(); } else if (editor.getMarkers().isMissingKey(node.getMessageKey())) { return UIUtils.getMissingTranslationImage(); } else if (editor.getMarkers().isDuplicateValue(node.getMessageKey())) { return UIUtils.getDuplicateEntryImage(); } // This shouldnt happen, but just in case a default key with a // warning icon will be showed Image someWarning = UIUtils.getKeyImage(); ImageDescriptor warning = ImageDescriptor.createFromImage(UIUtils.getImage(UIUtils.IMAGE_WARNING)); someWarning = new DecorationOverlayIcon(someWarning, warning, IDecoration.BOTTOM_RIGHT).createImage(); return someWarning; // return UIUtils.getImage(UIUtils.IMAGE_WARNED_TRANSLATION); } else { /* * // Figure out background icon if * (messagesBundleGroup.isMessageKey(key)) { //TODO create check (or * else) // if (!noInactiveKeyCheck.checkKey(messagesBundleGroup, * node.getPath())) { // iconFlags += KEY_COMMENTED; // } else { * iconFlags += KEY_DEFAULT; * * // } } else { iconFlags += KEY_VIRTUAL; } */ return UIUtils.getKeyImage(); } }