List of usage examples for org.eclipse.jface.viewers IDecoration TOP_LEFT
int TOP_LEFT
To view the source code for org.eclipse.jface.viewers IDecoration TOP_LEFT.
Click Source Link
From source file:org.eclipse.dltk.ruby.internal.ui.editor.RubyOutlineLabelDecorator.java
License:Open Source License
public Image decorateImage(Image image, Object obj) { try {/*from w w w . j a v a2s .c o m*/ if (obj instanceof IMember) { final IMember member = (IMember) obj; if (member.exists()) { final int flags = member.getFlags(); final ImageDescriptor left = getTopLeft(flags); final ImageDescriptor right = getTopRight(flags); if (left != null || right != null) { final ImageDescriptor[] decorations = new ImageDescriptor[5]; decorations[IDecoration.TOP_LEFT] = left; decorations[IDecoration.TOP_RIGHT] = right; return registry.get(new DecorationOverlayIcon(image, decorations)); } } } } catch (ModelException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); } } return image; }
From source file:org.eclipse.eatop.examples.explorer.decorators.ModelReferenceDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (elementIsReferenced(element) && elementIsInstanceReferenced(element)) { decoration.addOverlay(referenceOverlay, IDecoration.TOP_LEFT); decoration.addOverlay(instanceRefOverlay, IDecoration.BOTTOM_RIGHT); } else if (elementIsReferenced(element)) { decoration.addOverlay(referenceOverlay, IDecoration.TOP_LEFT); } else if (elementIsInstanceReferenced(element)) { decoration.addOverlay(instanceRefOverlay, IDecoration.BOTTOM_RIGHT); } else {/*ww w . j a v a 2s .c o m*/ decoration.addOverlay(null); } }
From source file:org.eclipse.eatop.workspace.ui.decorators.EastADLProjectLabelDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { // Handle only projects if (element instanceof IProject) { // Try to retrieve eastADL release descriptor from given project EastADLReleaseDescriptor eastADLRelease = IEastADLWorkspacePreferences.EAST_ADL_RELEASE .get((IProject) element); if (eastADLRelease != null && hasEastADLNatureOnly((IProject) element)) { // Adapt eastADL release descriptor in order to get its item label provider IItemLabelProvider itemLabelProvider = (IItemLabelProvider) Platform.getAdapterManager() .loadAdapter(eastADLRelease, IItemLabelProvider.class.getName()); if (itemLabelProvider != null) { try { // URL of the image given by item label provider Object imageURL = itemLabelProvider.getImage(eastADLRelease); if (imageURL instanceof URL) { // Obtain corresponding image descriptor from image URL ImageDescriptor imageDescriptor = Activator.getPlugin() .getImageDescriptor((URL) imageURL); // Add image as top left decoration decoration.addOverlay(imageDescriptor, IDecoration.TOP_LEFT); }/* www . ja v a 2s .c o m*/ } catch (MissingResourceException ex) { PlatformLogUtil.logAsWarning(Activator.getPlugin(), ex); } } } } }
From source file:org.eclipse.egit.ui.internal.DecorationOverlayDescriptor.java
License:Open Source License
/** * Draw the overlays for the receiver.//from w w w . j a v a2 s .c o 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.jdt.internal.ui.wizards.buildpaths.CPVariableElementLabelProvider.java
License:Open Source License
public CPVariableElementLabelProvider(boolean highlightReadOnly) { ImageRegistry reg = JavaPlugin.getDefault().getImageRegistry(); fJARImage = reg.get(JavaPluginImages.IMG_OBJS_EXTJAR); fFolderImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); fDeprecatedJARImage = new DecorationOverlayIcon(fJARImage, JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_LEFT).createImage(); fDeprecatedFolderImage = new DecorationOverlayIcon(fFolderImage, JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_LEFT).createImage(); fHighlightReadOnly = highlightReadOnly; }
From source file:org.eclipse.jpt.common.ui.internal.jface.OverlayImageDescriptor.java
License:Open Source License
/** * Draw the underlay image first, followed by either the base image or the * replacement image, followed by the overlay images in the order indicated * by the overlay constants defined on {@link IDecoration}. *//*from w w w. j a v a2s .c o m*/ @Override protected void drawCompositeImage(int width, int height) { if (this.overlays.length > IDecoration.UNDERLAY) { ImageDescriptor underlay = this.overlays[IDecoration.UNDERLAY]; if (underlay != null) { this.drawImage(underlay.getImageData(), 0, 0); } } ImageDescriptor temp = this.base; if (this.overlays.length > IDecoration.REPLACE) { ImageDescriptor replace = this.overlays[IDecoration.REPLACE]; if (replace != null) { temp = replace; } } this.drawImage(this.convertToImageData(temp), 0, 0); for (int i = 0; i < this.overlays.length; i++) { ImageDescriptor overlay = this.overlays[i]; if (overlay == null) { continue; } ImageData overlayData = this.convertToImageData(overlay); switch (i) { case IDecoration.TOP_LEFT: this.drawImage(overlayData, 0, 0); break; case IDecoration.TOP_RIGHT: this.drawImage(overlayData, (this.size.x - overlayData.width), 0); break; case IDecoration.BOTTOM_LEFT: this.drawImage(overlayData, 0, (this.size.y - overlayData.height)); break; case IDecoration.BOTTOM_RIGHT: this.drawImage(overlayData, (this.size.x - overlayData.width), (this.size.y - overlayData.height)); break; default: // NOP } } }
From source file:org.eclipse.jubula.client.ui.rcp.provider.labelprovider.OMEditorTreeLabelProvider.java
License:Open Source License
/** * //from ww w . j a v a 2 s.co m * @param element Object the Object * @return Image an Image */ public Image getImage(Object element) { Image image = null; if (element instanceof IComponentNamePO) { image = IconConstants.LOGICAL_NAME_IMAGE; } else if (element instanceof IObjectMappingAssoziationPO) { int status = getQualitySeverity(((IObjectMappingAssoziationPO) element).getCompIdentifier()); switch (status) { case IStatus.OK: image = IconConstants.TECH_NAME_OK_IMAGE; break; case IStatus.WARNING: image = IconConstants.TECH_NAME_WARNING_IMAGE; break; case IStatus.ERROR: image = IconConstants.TECH_NAME_ERROR_IMAGE; break; default: image = IconConstants.TECHNICAL_NAME_IMAGE; break; } if (((IObjectMappingAssoziationPO) element).getTechnicalName().getProfile() != null) { image = IconConstants.decorateImage(image, IconConstants.TRIANGLE_OVERLAY, IDecoration.TOP_LEFT); } } else if (element instanceof IObjectMappingCategoryPO) { image = IconConstants.CATEGORY_IMAGE; } else if (element instanceof String) { // Missing Component Name image = IconConstants.LOGICAL_NAME_IMAGE; } else { String elementType = element != null ? element.getClass().getName() : "null"; //$NON-NLS-1$ StringBuilder msg = new StringBuilder(); msg.append(Messages.ElementType).append(StringConstants.SPACE).append(StringConstants.APOSTROPHE) .append(elementType).append(StringConstants.APOSTROPHE).append(StringConstants.SPACE) .append(Messages.NotSupported).append(StringConstants.DOT); Assert.notReached(msg.toString()); return null; } LocalSelectionClipboardTransfer transfer = LocalSelectionClipboardTransfer.getInstance(); if (transfer.getIsItCut()) { Object cbContents = m_clipboard.getContents(transfer); if (cbContents instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) cbContents; if (sel.toList().contains(element)) { image = Plugin.getCutImage(image); } } } return image; }
From source file:org.eclipse.m2e.core.ui.internal.components.MavenProjectLabelProvider.java
License:Open Source License
public Image getImage(Object element) { if (Beans.isDesignTime()) { // windowbuilder compat return null; }/* w ww . j av a 2 s . c om*/ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); if (element instanceof IProject && !((IProject) element).isAccessible()) { return sharedImages.getImage(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED); } Image img = MavenImages.createOverlayImage(MavenImages.MVN_PROJECT, sharedImages.getImage(IDE.SharedImages.IMG_OBJ_PROJECT), MavenImages.MAVEN_OVERLAY, IDecoration.TOP_LEFT); return img; }
From source file:org.eclipse.m2e.core.ui.internal.dialogs.UpdateDepenciesDialog.java
License:Open Source License
/** * Create contents of the dialog./*from w w w . j a va 2s . com*/ * @param parent */ @Override @SuppressWarnings("rawtypes") protected Control createDialogArea(Composite parent) { Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginLeft = 12; container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_BOTH)); Label lblAvailable = new Label(container, SWT.NONE); lblAvailable.setText(Messages.UpdateDepenciesDialog_availableCodebasesLabel); lblAvailable.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1)); codebaseViewer = new CheckboxTreeViewer(container, SWT.BORDER); codebaseViewer.setContentProvider(new ITreeContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object element) { if (element instanceof Collection) { return ((Collection) element).toArray(); } return null; } public Object[] getChildren(Object parentElement) { if (parentElement instanceof IProject) { String elePath = new File(((IProject) parentElement).getLocationURI()).toString() + SEPARATOR; String prevPath = null; List<IProject> children = new ArrayList<IProject>(); for (String path : projectPaths) { if (path.length() != elePath.length() && path.startsWith(elePath)) { if (prevPath == null || !path.startsWith(prevPath)) { prevPath = path; children.add(getProject(path)); } } } return children.toArray(); } else if (parentElement instanceof Collection) { return ((Collection) parentElement).toArray(); } return null; } public Object getParent(Object element) { String elePath = new File(((IProject) element).getLocationURI()).toString() + SEPARATOR; String prevPath = null; for (String path : projectPaths) { if (elePath.length() != path.length() && elePath.startsWith(path) && (prevPath == null || prevPath.length() < path.length())) { prevPath = path; } } return prevPath == null ? projects : getProject(prevPath); } public boolean hasChildren(Object element) { if (element instanceof IProject) { String elePath = new File(((IProject) element).getLocationURI()).toString() + SEPARATOR; for (String path : projectPaths) { if (elePath.length() != path.length() && path.startsWith(elePath)) { return true; } } } else if (element instanceof Collection) { return !((Collection) element).isEmpty(); } return false; } }); codebaseViewer.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return MavenImages.createOverlayImage(MavenImages.MVN_PROJECT, PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT), MavenImages.MAVEN_OVERLAY, IDecoration.TOP_LEFT); } public String getText(Object element) { return element instanceof IProject ? ((IProject) element).getName() : ""; //$NON-NLS-1$ } }); projects = getMavenCodebases(); codebaseViewer.setInput(projects); codebaseViewer.expandAll(); for (IProject project : initialSelection) { codebaseViewer.setSubtreeChecked(project, true); } // Reveal the first element if (initialSelection.length > 0) { codebaseViewer.reveal(initialSelection[0]); } Tree tree = codebaseViewer.getTree(); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4); gd.heightHint = 300; gd.widthHint = 300; tree.setLayoutData(gd); Button selectAllBtn = new Button(container, SWT.NONE); selectAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); selectAllBtn.setText(Messages.UpdateDepenciesDialog_selectAll); selectAllBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { for (IProject project : projects) { codebaseViewer.setSubtreeChecked(project, true); } } public void widgetDefaultSelected(SelectionEvent e) { } }); Button deselectAllBtn = new Button(container, SWT.NONE); deselectAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1)); deselectAllBtn.setText(Messages.UpdateDepenciesDialog_deselectAll); deselectAllBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { for (IProject project : projects) { codebaseViewer.setSubtreeChecked(project, false); } } public void widgetDefaultSelected(SelectionEvent e) { } }); Button expandAllBtn = new Button(container, SWT.NONE); expandAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, true, 1, 1)); expandAllBtn.setText(Messages.UpdateDepenciesDialog_expandAll); expandAllBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { codebaseViewer.expandAll(); } public void widgetDefaultSelected(SelectionEvent e) { } }); Button collapseAllBtn = new Button(container, SWT.NONE); collapseAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1)); collapseAllBtn.setText(Messages.UpdateDepenciesDialog_collapseAll); collapseAllBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { codebaseViewer.collapseAll(); } public void widgetDefaultSelected(SelectionEvent e) { } }); offlineModeBtn = new Button(container, SWT.CHECK); offlineModeBtn.setText(Messages.UpdateDepenciesDialog_offline); offlineModeBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1)); offlineModeBtn.setSelection(offlineMode); forceUpdateBtn = new Button(container, SWT.CHECK); forceUpdateBtn.setText(Messages.UpdateDepenciesDialog_forceUpdate); forceUpdateBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1)); forceUpdateBtn.setSelection(forceUpdate); setTitle(Messages.UpdateDepenciesDialog_title); setMessage(Messages.UpdateDepenciesDialog_dialogMessage); createMenu(); return area; }
From source file:org.eclipse.m2e.core.ui.internal.dialogs.UpdateMavenProjectsDialog.java
License:Open Source License
/** * Create contents of the dialog.//from www . j ava2s .c o m * * @param parent */ @Override @SuppressWarnings("rawtypes") protected Control createDialogArea(Composite parent) { Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginLeft = 10; container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_BOTH)); Label lblAvailable = new Label(container, SWT.NONE); lblAvailable.setText(Messages.UpdateDepenciesDialog_availableCodebasesLabel); lblAvailable.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1)); codebaseViewer = new CheckboxTreeViewer(container, SWT.BORDER); codebaseViewer.setContentProvider(new ITreeContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object element) { if (element instanceof Collection) { return ((Collection) element).toArray(); } return null; } public Object[] getChildren(Object parentElement) { if (parentElement instanceof IProject) { String elePath = getElePath(parentElement); String prevPath = null; List<IProject> children = new ArrayList<IProject>(); for (String path : projectPaths.keySet()) { if (path.length() != elePath.length() && path.startsWith(elePath)) { if (prevPath == null || !path.startsWith(prevPath)) { prevPath = path; children.add(getProject(path)); } } } return children.toArray(); } else if (parentElement instanceof Collection) { return ((Collection) parentElement).toArray(); } return null; } public Object getParent(Object element) { String elePath = getElePath(element); String prevPath = null; for (String path : projectPaths.keySet()) { if (elePath.length() != path.length() && elePath.startsWith(path) && (prevPath == null || prevPath.length() < path.length())) { prevPath = path; } } return prevPath == null ? projects : getProject(prevPath); } public boolean hasChildren(Object element) { if (element instanceof IProject) { String elePath = getElePath(element); for (String path : projectPaths.keySet()) { if (elePath.length() != path.length() && path.startsWith(elePath)) { return true; } } } else if (element instanceof Collection) { return !((Collection) element).isEmpty(); } return false; } }); codebaseViewer.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return MavenImages.createOverlayImage(MavenImages.MVN_PROJECT, PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT), MavenImages.MAVEN_OVERLAY, IDecoration.TOP_LEFT); } public String getText(Object element) { return element instanceof IProject ? ((IProject) element).getName() : ""; //$NON-NLS-1$ } }); projects = getMavenCodebases(); codebaseViewer.setInput(projects); codebaseViewer.expandAll(); for (IProject project : initialSelection) { codebaseViewer.setSubtreeChecked(project, true); } // Reveal the first element if (initialSelection.length > 0) { codebaseViewer.reveal(initialSelection[0]); } Tree tree = codebaseViewer.getTree(); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd.heightHint = 300; gd.widthHint = 300; tree.setLayoutData(gd); Composite selectionActionComposite = new Composite(container, SWT.NONE); selectionActionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); GridLayout gl_selectionActionComposite = new GridLayout(1, false); gl_selectionActionComposite.marginWidth = 0; gl_selectionActionComposite.marginHeight = 0; selectionActionComposite.setLayout(gl_selectionActionComposite); Button selectAllBtn = new Button(selectionActionComposite, SWT.NONE); selectAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); selectAllBtn.setText(Messages.UpdateDepenciesDialog_selectAll); selectAllBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { for (IProject project : projects) { codebaseViewer.setSubtreeChecked(project, true); } } public void widgetDefaultSelected(SelectionEvent e) { } }); Button deselectAllBtn = new Button(selectionActionComposite, SWT.NONE); deselectAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1)); deselectAllBtn.setText(Messages.UpdateDepenciesDialog_deselectAll); deselectAllBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { for (IProject project : projects) { codebaseViewer.setSubtreeChecked(project, false); } } public void widgetDefaultSelected(SelectionEvent e) { } }); Button expandAllBtn = new Button(selectionActionComposite, SWT.NONE); expandAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1)); expandAllBtn.setText(Messages.UpdateDepenciesDialog_expandAll); expandAllBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { codebaseViewer.expandAll(); } public void widgetDefaultSelected(SelectionEvent e) { } }); Button collapseAllBtn = new Button(selectionActionComposite, SWT.NONE); collapseAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1)); collapseAllBtn.setText(Messages.UpdateDepenciesDialog_collapseAll); collapseAllBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { codebaseViewer.collapseAll(); } public void widgetDefaultSelected(SelectionEvent e) { } }); Composite optionsComposite = new Composite(container, SWT.NONE); optionsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1)); GridLayout gl_optionsComposite = new GridLayout(1, false); gl_optionsComposite.marginHeight = 0; gl_optionsComposite.marginWidth = 0; optionsComposite.setLayout(gl_optionsComposite); offlineModeBtn = new Button(optionsComposite, SWT.CHECK); offlineModeBtn.setText(Messages.UpdateDepenciesDialog_offline); offlineModeBtn.setSelection(offlineMode); Button btnCheckButton = new Button(optionsComposite, SWT.CHECK); btnCheckButton.setEnabled(false); btnCheckButton.setSelection(true); btnCheckButton.setText(Messages.UpdateMavenProjectDialog_btnCheckButton_text); forceUpdateBtn = new Button(optionsComposite, SWT.CHECK); GridData gd_forceUpdateBtn = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_forceUpdateBtn.horizontalIndent = 15; forceUpdateBtn.setLayoutData(gd_forceUpdateBtn); forceUpdateBtn.setText(Messages.UpdateDepenciesDialog_forceUpdate); btnUpdateProjectConfiguration = new Button(optionsComposite, SWT.CHECK); btnUpdateProjectConfiguration.setSelection(true); btnUpdateProjectConfiguration.setText(Messages.UpdateMavenProjectDialog_btnUpdateProjectConfiguration_text); btnRefreshFromLocal = new Button(optionsComposite, SWT.CHECK); btnRefreshFromLocal.setSelection(true); btnRefreshFromLocal.setText(Messages.UpdateMavenProjectsDialog_btnRefreshFromLocal_text); btnCleanProjects = new Button(optionsComposite, SWT.CHECK); btnCleanProjects.setSelection(true); btnCleanProjects.setText(Messages.UpdateMavenProjectDialog_btnCleanProjects_text); setTitle(getDialogTitle()); setMessage(getDialogMessage()); createMenu(); return area; }