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.eclipse.cdt.ui.CDTSharedImages.java
License:Open Source License
/** * Helper method to return an image with warning overlay. * * @param baseKey - key of the base image. Expected to be in repository. * @return an image with warning overlay. *//*w ww . j a v a 2s . c o m*/ public static Image getImageWithWarning(String baseKey) { return getImageOverlaid(baseKey, CDTSharedImages.IMG_OVR_WARNING, IDecoration.BOTTOM_LEFT); }
From source file:org.eclipse.cdt.ui.CDTSharedImages.java
License:Open Source License
/** * Helper method to return an image with error overlay. * * @param baseKey - key of the base image. Expected to be in repository. * @return an image with error overlay./* w w w . j a va 2s. c o m*/ */ public static Image getImageWithError(String baseKey) { return getImageOverlaid(baseKey, CDTSharedImages.IMG_OVR_ERROR, IDecoration.BOTTOM_LEFT); }
From source file:org.eclipse.cdt.ui.tests.misc.CDTSharedImagesTests.java
License:Open Source License
/** * Test images with overlays./* w ww.j ava 2 s .c o m*/ */ public void testOverlays() throws Exception { { Image image1 = CDTSharedImages.getImageOverlaid(KEY_OBJS_TUNIT, new String[5]); Image image2 = CDTSharedImages.getImage(KEY_OBJS_TUNIT); assertSame(image1, image2); } { String[] overlayKeys = new String[5]; overlayKeys[IDecoration.BOTTOM_LEFT] = CDTSharedImages.IMG_OVR_WARNING; Image imageOver1 = CDTSharedImages.getImageOverlaid(KEY_OBJS_TUNIT, overlayKeys); Image imageOver2 = CDTSharedImages.getImageOverlaid(KEY_OBJS_TUNIT, CDTSharedImages.IMG_OVR_WARNING, IDecoration.BOTTOM_LEFT); Image imageOver3 = CDTSharedImages.getImageWithWarning(KEY_OBJS_TUNIT); assertSame(imageOver1, imageOver2); assertSame(imageOver1, imageOver3); } }
From source file:org.eclipse.cft.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 ww w.ja va2 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.getStatus() != null && !module.getStatus().isOK()) { if (module.getStatus().getSeverity() == IStatus.ERROR) { decoration.addOverlay(CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT); } else if (module.getStatus().getSeverity() == IStatus.WARNING) { decoration.addOverlay(CloudFoundryImages.OVERLAY_WARNING, 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.eclipse.cft.server.ui.internal.editor.ApplicationMasterPart.java
License:Open Source License
private void createApplicationsSection() { Section section = getSection();/*w w w .j ava2s. co 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.getStatus() != null && !appModule.getStatus().isOK()) { if (appModule.getStatus().getSeverity() == IStatus.ERROR) { return CloudFoundryImages.getImage(new DecorationOverlayIcon(image, CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT)); } else if (appModule.getStatus().getSeverity() == IStatus.WARNING) { return CloudFoundryImages.getImage(new DecorationOverlayIcon(image, CloudFoundryImages.OVERLAY_WARNING, 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.compare.internal.patch.DecoratorOverlayIcon.java
License:Open Source License
/** * Draw the overlays for the receiver./* w w w. jav a2 s . c o m*/ * @param overlaysArray the overlay images */ protected void drawOverlays(ImageDescriptor[] overlaysArray) { for (int i = 0; i < overlays.length; i++) { ImageDescriptor overlay = overlaysArray[i]; if (overlay == null) { continue; } ImageData overlayData = overlay.getImageData(); //Use the missing descriptor if it is not there. if (overlayData == null) { overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData(); } switch (i) { case IDecoration.TOP_LEFT: drawImage(overlayData, 0, 0); break; case IDecoration.TOP_RIGHT: drawImage(overlayData, size.x - overlayData.width, 0); break; case IDecoration.BOTTOM_LEFT: drawImage(overlayData, 0, size.y - overlayData.height); break; case IDecoration.BOTTOM_RIGHT: drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height); break; } } }
From source file:org.eclipse.ease.modules.unittest.ui.decorators.TestDecorator.java
License:Open Source License
private void addOverlay(final TestStatus status, final IDecoration decoration) { switch (status) { case PASS:// w w w .j av a 2s.c om decoration.addOverlay(getImage(IMAGE_OK), IDecoration.BOTTOM_LEFT); break; case ERROR: decoration.addOverlay(getImage(IMAGE_ERROR), IDecoration.BOTTOM_LEFT); break; case FAILURE: decoration.addOverlay(getImage(IMAGE_FAILURE), IDecoration.BOTTOM_LEFT); break; case RUNNING: decoration.addOverlay(getImage(IMAGE_RUNNING), IDecoration.BOTTOM_LEFT); break; default: // nothing to do break; } }
From source file:org.eclipse.egit.ui.internal.DecorationOverlayDescriptor.java
License:Open Source License
/** * Draw the overlays for the receiver.//from w w w . jav a 2 s. co m * * @param overlaysArray */ private void drawOverlays(ImageDescriptor[] overlaysArray) { for (int i = 0; i < overlays.length; i++) { ImageDescriptor overlay = overlaysArray[i]; if (overlay == null) continue; ImageData overlayData = overlay.getImageData(); // Use the missing descriptor if it is not there. if (overlayData == null) overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData(); switch (i) { case IDecoration.TOP_LEFT: drawImage(overlayData, 0, 0); break; case IDecoration.TOP_RIGHT: drawImage(overlayData, size.x - overlayData.width, 0); break; case IDecoration.BOTTOM_LEFT: drawImage(overlayData, 0, size.y - overlayData.height); break; case IDecoration.BOTTOM_RIGHT: drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height); break; } } }
From source file:org.eclipse.elk.core.ui.views.ValidatingPropertySheetEntry.java
License:Open Source License
/** * {@inheritDoc}/* w w w . j a v a 2 s .c om*/ */ @Override public Image getImage() { Image image = super.getImage(); List<GraphIssue> issues = validate(); if (issues.isEmpty()) { return image; } else if (image != null) { String overlayKey = "error_overlay/" + image.toString(); Image result = ElkUiPlugin.getInstance().getImageRegistry().get(overlayKey); if (result == null) { DecorationOverlayIcon overlayIcon = new DecorationOverlayIcon(image, ElkUiPlugin.getImageDescriptor("icons/error_overlay.png"), IDecoration.BOTTOM_LEFT); result = overlayIcon.createImage(); ElkUiPlugin.getInstance().getImageRegistry().put(overlayKey, result); } return result; } return null; }
From source file:org.eclipse.emf.ecp.emfstore.internal.ui.decorator.EMFStoreDirtyDecorator.java
License:Open Source License
/** {@inheritDoc} */ @Override// ww w . java2 s. c o m public void decorate(Object element, IDecoration decoration) { if (element instanceof ECPProject) { final InternalProject project = (InternalProject) element; if (ECPUtil.getECPProjectManager().getProject(project.getName()) == null) { return; } final ProjectSpace projectSpace = ((ESLocalProjectImpl) EMFStoreProvider.INSTANCE .getProjectSpace(project)).toInternalAPI(); if (!observers.containsKey(element)) { final EMFStoreDirtyObserver emfStoreDirtyObserver = new EMFStoreDirtyObserver(projectSpace, project); ESWorkspaceProviderImpl.getObserverBus().register(emfStoreDirtyObserver); // projectSpace.getOperationManager().addOperationObserver(emfStoreDirtyObserver); observers.put((ECPProject) element, emfStoreDirtyObserver); } if (project.isOpen() && projectSpace.isShared() && observers.get(element).isDirty()) { decoration.addOverlay(Activator.getImageDescriptor(dirtyPath), IDecoration.BOTTOM_LEFT); } } else if (element instanceof EObject) { InternalProject project = null; try { project = (InternalProject) ECPUtil.getECPProjectManager().getProject(element); } catch (final IllegalArgumentException iae) { // ignore } if (project != null && project.isOpen() && EMFStoreProvider.INSTANCE.getProjectSpace(project).isShared() && EMFStoreDirtyDecoratorCachedTree.getInstance(project).getCachedValue(element) > 0) { decoration.addOverlay(Activator.getImageDescriptor(dirtyPath), IDecoration.BOTTOM_LEFT); } else { decoration.addOverlay(null); } return; } }