List of usage examples for org.eclipse.jface.viewers IDecoration BOTTOM_LEFT
int BOTTOM_LEFT
To view the source code for org.eclipse.jface.viewers IDecoration BOTTOM_LEFT.
Click Source Link
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;/*w w w . ja v a 2s. c om*/ 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.CloudFoundryDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (element instanceof ModuleServer) { ModuleServer moduleServer = (ModuleServer) element; IServer s = moduleServer.getServer(); if (s != null && isCloudFoundryServerType(s)) { IModule[] modules = moduleServer.getModule(); if (modules != null && modules.length == 1) { CloudFoundryServer server = getCloudFoundryServer(moduleServer.getServer()); if (server == null || !server.isConnected()) { return; }/*from w ww . j av a 2 s . c o m*/ ApplicationModule module = server.getApplication(modules[0]); if (module.getLocalModule() != null) { // show local information? } CloudApplication application = module.getApplication(); // if (application != null) { // decoration.addSuffix(NLS.bind(" [{0}, {1}, {2}]", // new Object[]{application.getName(), // getAppStateString(application.getState()), // application.getUris()})); // } else if (module.getName() != null) { // decoration.addSuffix(NLS.bind(" [{0}]", // module.getName())); // } if (application != null) { decoration.addSuffix(NLS.bind(" - Deployed as {0}", application.getName())); } else { decoration.addSuffix(" - Not Deployed"); } if (module.getErrorMessage() != null) { decoration.addOverlay(CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT); } } } } else if (element instanceof Server) { Server server = (Server) element; if (isCloudFoundryServerType(server)) { CloudFoundryServer cfServer = getCloudFoundryServer(server); if (cfServer != null && cfServer.getUsername() != null) { // decoration.addSuffix(NLS.bind(" [{0}, {1}]", // cfServer.getUsername(), cfServer.getUrl())); List<CloudURL> cloudUrls = CloudUiUtil .getAllUrls(cfServer.getBehaviour().getServer().getServerType().getId()); String url = cfServer.getUrl(); // decoration.addSuffix(NLS.bind(" {0}", cfServer.getUsername())); for (CloudURL cloudUrl : cloudUrls) { if (cloudUrl.getUrl().equals(url)) { decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl())); break; } } } } } }
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.j a v a 2s . 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.CloudFoundryDecorator.java
License:Open Source License
public void decorate(Object element, final IDecoration decoration) { if (element instanceof ModuleServer) { ModuleServer moduleServer = (ModuleServer) element; IServer s = moduleServer.getServer(); if (s != null && CloudServerUtil.isCloudFoundryServer(s)) { IModule[] modules = moduleServer.getModule(); if (modules != null && modules.length == 1) { CloudFoundryServer server = getCloudFoundryServer(moduleServer.getServer()); if (server == null || !server.isConnected()) { return; }//from www . j a v a 2 s.c o m CloudFoundryApplicationModule module = server.getExistingCloudModule(modules[0]); // module may no longer exist if (module == null) { return; } if (module.getLocalModule() != null) { // show local information? } CloudApplication application = module.getApplication(); if (application != null) { String deployedAppName = application.getName(); IModule localModule = module.getLocalModule(); // Only show "Deployed as" when the local module name does not match the deployed app name. if (localModule != null && !localModule.getName().equals(deployedAppName)) { decoration.addSuffix( NLS.bind(Messages.CloudFoundryDecorator_SUFFIX_DEPLOYED_AS, deployedAppName)); } else { decoration.addSuffix(Messages.CloudFoundryDecorator_SUFFIX_DEPLOYED); } } else { decoration.addSuffix(Messages.CloudFoundryDecorator_SUFFIX_NOT_DEPLOYED); } if (module.getErrorMessage() != null) { decoration.addOverlay(CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT); } } } } else if (element instanceof Server) { Server server = (Server) element; if (CloudServerUtil.isCloudFoundryServer(server)) { final CloudFoundryServer cfServer = getCloudFoundryServer(server); if (cfServer != null && cfServer.getUsername() != null) { // This now runs on a non UI thread, so we need to join this // update to a UI thread. Display.getDefault().syncExec(new Runnable() { @Override public void run() { // decoration.addSuffix(NLS.bind(" [{0}, {1}]", // cfServer.getUsername(), cfServer.getUrl())); if (cfServer.hasCloudSpace()) { CloudFoundrySpace clSpace = cfServer.getCloudFoundrySpace(); if (clSpace != null) { decoration.addSuffix( NLS.bind(" - {0} - {1}", clSpace.getOrgName(), clSpace.getSpaceName())); //$NON-NLS-1$ } } try { List<AbstractCloudFoundryUrl> cloudUrls = CloudServerUIUtil.getAllUrls( cfServer.getBehaviour().getServer().getServerType().getId(), null); String url = cfServer.getUrl(); // decoration.addSuffix(NLS.bind(" {0}", // cfServer.getUsername())); for (AbstractCloudFoundryUrl cloudUrl : cloudUrls) { if (cloudUrl.getUrl().equals(url)) { decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl())); //$NON-NLS-1$ break; } } } catch (CoreException e) { CloudFoundryServerUiPlugin.logError(e); } } }); } } } }
From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.editor.ApplicationMasterPart.java
License:Open Source License
private void createApplicationsSection() { Section section = getSection();/*from w ww . j av 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.cs3.pdt.navigator.internal.decorators.PDTConsultDecoratorContributor.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (!(element instanceof IFile) && !(element instanceof IFolder)) { return;//w ww . java 2s . co m } try { // get active pif from console PrologInterface currentPif = PDTCommonUtil.getActivePrologInterface(); if (currentPif == null) { if (element instanceof IFile) { decoration.addOverlay( ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FILE_UNCONSULTED), IDecoration.UNDERLAY); } return; } if (element instanceof IFile) { IFile file = (IFile) element; // final DecorationContext decorationContext = (DecorationContext) decoration.getDecorationContext(); // decorationContext.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); // check if file is in consulted files list (important for qlf files) String prologFileName = getPrologFileName(file); // XXX: don't mark qlf file if only the pl file is consulted if (prologFileName.endsWith(".qlf")) { prologFileName = prologFileName.substring(0, prologFileName.length() - 3) + "pl"; } // check if file is source_file if (isCurrent(prologFileName)) { decoration.addSuffix(" [consulted]"); if (file.getFileExtension().equalsIgnoreCase("QLF")) { decoration.addOverlay( ImageRepository.getImageDescriptor(ImageRepository.QLF_FILE_CONSULTED), IDecoration.BOTTOM_LEFT); } else { decoration.addOverlay( ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FILE_CONSULTED), IDecoration.UNDERLAY); } } else if (isOld(prologFileName)) { decoration.addSuffix(" [consulted]"); if (file.getFileExtension().equalsIgnoreCase("QLF")) { decoration.addOverlay( ImageRepository.getImageDescriptor(ImageRepository.QLF_FILE_CONSULTED_OLD), IDecoration.BOTTOM_LEFT); } else { decoration.addOverlay( ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FILE_CONSULTED_OLD), IDecoration.UNDERLAY); } } else { decoration.addOverlay( ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FILE_UNCONSULTED), IDecoration.UNDERLAY); } } else { IFolder folder = (IFolder) element; String dirName = Util.prologFileName(folder.getRawLocation().toFile()); if (isContainingFolder(dirName)) { decoration.addOverlay( ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FOLDER_CONSULTED), IDecoration.TOP_LEFT); } } } catch (Exception e) { Debug.error("Error during decoration of " + (element == null ? null : element.toString())); Debug.report(e); } }
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. *//*from w w w . j ava2 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.cdt.internal.ui.language.settings.providers.LanguageSettingsImages.java
License:Open Source License
/** * Returns image for the given entry from internally managed repository including * necessary overlays for given configuration description. * * @param entry - language settings entry to get an image for. * @param cfgDescription - configuration description of the entry. * @return the image for the entry with appropriate overlays. *//*w w w . j av a2 s.co m*/ public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) { int kind = entry.getKind(); int flags = entry.getFlags(); boolean isProjectRelative = isProjectRelative(entry); String imageKey = getImageKey(kind, flags, isProjectRelative); if (imageKey != null) { if ((flags & ICSettingEntry.UNDEFINED) != 0) { return CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT); } String overlayKey = null; IStatus status = getStatus(entry, cfgDescription); switch (status.getSeverity()) { case IStatus.ERROR: overlayKey = CDTSharedImages.IMG_OVR_ERROR; break; case IStatus.WARNING: overlayKey = CDTSharedImages.IMG_OVR_WARNING; break; case IStatus.INFO: overlayKey = CDTSharedImages.IMG_OVR_WARNING; break; } if (overlayKey != null) { return CDTSharedImages.getImageOverlaid(imageKey, overlayKey, IDecoration.BOTTOM_LEFT); } return CDTSharedImages.getImage(imageKey); } return null; }
From source file:org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersLabelProvider.java
License:Open Source License
/** * Returns keys for image overlays. Returning {@code null} is not allowed. *///from w ww. ja v a2 s . com protected String[] getOverlayKeys(ILanguageSettingsProvider provider) { String[] overlayKeys = new String[5]; if (provider.getName() == null) { overlayKeys[IDecoration.BOTTOM_LEFT] = CDTSharedImages.IMG_OVR_ERROR; } return overlayKeys; }
From source file:org.eclipse.cdt.make.ui.tests.MakeUIImagesTest.java
License:Open Source License
/** * Test images with overlays./*from ww w. j a va 2 s . c o m*/ */ @Test public void testOverlays() throws Exception { { Image image1 = MakeUIImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, new String[5]); Image image2 = MakeUIImages.getImage(KEY_ETOOL_MAKEFILE); assertSame(image1, image2); } { String[] overlayKeys = new String[5]; overlayKeys[IDecoration.BOTTOM_LEFT] = MakeUIImages.IMG_OVR_AUTOMATIC; Image imageOver1 = MakeUIImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, overlayKeys); Image imageOver2 = MakeUIImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, MakeUIImages.IMG_OVR_AUTOMATIC, IDecoration.BOTTOM_LEFT); assertSame(imageOver1, imageOver2); } }