@Override public void decorate(final Object element, final IDecoration decoration) { try { if (element instanceof IProject) { final URI uri = createPlatformResourceURI(((IProject) element).getName(), true); final IN4JSProject project = core.findProject(uri).orNull(); if (null != project) { final ImageRef imageRef = IMAGE_REF_CACHE.get(project.getProjectType()); if (null != imageRef) { final ImageDescriptor descriptor = imageRef.asImageDescriptor().orNull(); if (null != descriptor) { decoration.addOverlay(descriptor); } } } } } catch (final Exception e) { // Exception should not propagate from here, otherwise the lightweight decorator stops working once till // next application startup. LOGGER.error("Error while trying to get decorator for " + element, e); } }
@Override public void decorate ( final Object element, final IDecoration decoration ) { try { final IFile resource = (IFile)element; final String timeframe = getTimeframe ( resource ); if ( timeframe != null ) { decoration.addSuffix ( " " + timeframe ); } } catch ( final Exception e ) { } }
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IResource) { IResource res = (IResource) element; IProject proj = res.getProject(); try { if (proj != null && proj.isAccessible() && proj.hasNature(NATURE.ID)) { IMarker[] markers = res.findMarkers(MARKER.ERROR, false, IResource.DEPTH_INFINITE); if (markers.length > 0) { decoration.addOverlay(PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR)); } } } catch (CoreException e) { Log.log(e); } } }
@Override public Image getTitleImage() { Image image = super.getTitleImage(); try { IEditorInput input = getEditorInput(); IResource file = ResourceUtil.getResource(input); if (input.exists() && file != null && file.findMarkers(MARKER.ERROR, false, IResource.DEPTH_ZERO).length > 0) { if (errorTitleImage == null) { errorTitleImage = new DecorationOverlayIcon(image, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_DEC_FIELD_ERROR), IDecoration.BOTTOM_LEFT) .createImage(); } return errorTitleImage; } } catch (CoreException e) { Log.log(e); } return image; }
public void decorate(Object element, IDecoration decoration) { IProject proj=null; if(element instanceof IJavaProject){ proj = ((IJavaProject)element).getProject(); }else{ proj=(IProject)element; } try { if (DerbyServerUtils.getDefault().getRunning(proj)) { decoration.addOverlay(derbyRunningImageDesc); } } catch (CoreException ce) { Logger.log(SelectionUtil.getStatusMessages(ce),IStatus.ERROR); } }
/** * This is a fallback decorator for when the ItemCache is not available * (hasn't yet completed refreshing.) This is very similar to the 2.x * LabelDecorator. * * @param resource * The IResource to decorate * @param decoration * The IDecoration which will be deecorated */ private void decorateFromFilesystem( final IResource resource, final IDecoration decoration, final TFSRepository repository) { // repository does not exist, we are offline if (repository == null) { decoration.addOverlay(imageHelper.getImageDescriptor(TFS_OFFLINE_ICON)); } else if (resource.getType() == IResource.FILE && resource.isReadOnly()) { decoration.addOverlay(imageHelper.getImageDescriptor(TFS_ICON)); } else if (resource.getType() == IResource.FILE) { decoration.addOverlay(imageHelper.getImageDescriptor(UNKNOWN_ICON)); } else { decoration.addOverlay(imageHelper.getImageDescriptor(TFS_ICON)); } }
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IFolder) { IFolder folder = (IFolder) element; try { for (IResource resource : folder.members()) { if (resource instanceof IFile) { IFile file = (IFile) resource; String ext = file.getFileExtension(); if (ext.contains(TurnusExtensions.TRACE) || ext.contains(TurnusExtensions.TRACE)) { decoration.addOverlay(Icon.getDescriptor(Icon.ACORN)); } } } } catch (CoreException e) { } } }
@Override public ImageDescriptor getImageDescriptor(Context context, Bookmark shortcutBookmark) { BookmarkId bookmarkId = new BookmarkId( shortcutBookmark.getPropertyValue(ShortcutBookmarkProperties.PROP_BOOKMARK_ID)); if (bookmarkId.equals(shortcutBookmark.getId())) { return null; } Bookmark bookmark = getBookmarksTree(context).getBookmark(bookmarkId); ImageDescriptor imageDescriptor = null; if (bookmark != null) { imageDescriptor = bookmarkLabelProvider.getImageDescriptor(context, bookmark); } else { imageDescriptor = super.getImageDescriptor(context, bookmark); } ImageDescriptor overlayImageDescriptor = BookmarksPlugin.getImageDescriptor(IUIConstants.IMG_BOOKMARK_LINK); ImageDescriptor[] overlayImages = new ImageDescriptor[5]; overlayImages[IDecoration.BOTTOM_LEFT] = overlayImageDescriptor; return new OverlayIconImageDescriptor(imageDescriptor, overlayImages); }
@Override public void decorate(Object element, IDecoration decoration) { // TODO Auto-generated method stub if(element instanceof IFolder) { try{ IFolder folder = (IFolder)element; IProjectNature nature = folder.getProject().getNature(WTNewProjectNature.ID); if(nature!=null){ //Search XMI IFile file = folder.getFile(folder.getName().concat(".xmi")); if(file.exists()){ XMI_File file_xmi = new XMI_File(URI.createFileURI(file.getFullPath().toString())); EObject root = file_xmi.Get_Root(); } } }catch(Throwable th){/*Ignore if file is not found*/ } } }
@Override public Image decorateImage(Image image, Object element) { OutlineNode node = (OutlineNode) element; Image result = null; switch (node.getType()) { case CATEGORY: DecorationOverlayIcon icon = new DecorationOverlayIcon(image, m_categoryImage, IDecoration.BOTTOM_RIGHT); result = icon.createImage(); break; default: break; } return result; }
private Image getInstalledBreakpointImage(BfBreakpoint breakpoint) { ImageDescriptor defaultImageDescriptor = DebugUITools.getDefaultImageDescriptor(breakpoint); if (this.overlayedImages.containsKey(defaultImageDescriptor)) { return this.overlayedImages.get(defaultImageDescriptor); } try { ImageDescriptor overlay = ImageDescriptor.createFromURL(new URL("platform:/plugin/org.eclipse.ui.ide/icons/full/obj16/header_complete.png")); Image defaultImage = defaultImageDescriptor.createImage(); this.disposeImages.add(defaultImage); ImageDescriptor overlayedDescriptor = new DecorationOverlayIcon(defaultImage, overlay, IDecoration.BOTTOM_LEFT); Image overlayedImage = overlayedDescriptor.createImage(); this.disposeImages.add(overlayedImage); this.overlayedImages.put(defaultImageDescriptor, overlayedImage); return overlayedImage; } catch (MalformedURLException ex) { DbgActivator.getDefault().logError("URL malformed", ex); return null; } }
@Override protected void updateEditorImage(final XtextEditor editor) { Severity severity = null; // // try { severity = getSeverity(editor); // // } catch (ResourceException e) { // // do nothing, emitted when a marker cannot be found // } ImageDescriptor descriptor = null; if (severity == null || severity == Severity.INFO) { descriptor = GamaIcons.create(IGamaIcons.OVERLAY_OK).descriptor(); } else if (severity == Severity.ERROR) { descriptor = GamaIcons.create("overlay.error2").descriptor(); } else if (severity == Severity.WARNING) { descriptor = GamaIcons.create("overlay.warning2").descriptor(); } else { super.updateEditorImage(editor); return; } final DecorationOverlayIcon decorationOverlayIcon = new DecorationOverlayIcon(editor.getDefaultImage(), descriptor, IDecoration.BOTTOM_LEFT); scheduleUpdateEditor(decorationOverlayIcon); }
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof DocumentWrapper) { decorateWrapper((DocumentWrapper) element, decoration); } if (element instanceof CommandWrapper) { decorateWrapper((CommandWrapper) element, decoration); } if (element instanceof GroupWrapper) { decorateWrapper((GroupWrapper) element, decoration); } }
private void decorateInOut(IDecoration decoration, boolean in, boolean out, int quadrant) { if (in && out) { decoration.addOverlay(TWO_WAY_ARROW, quadrant); } else if (out) { decoration.addOverlay(LEFT_ARROW, quadrant); } else if (in) { decoration.addOverlay(RIGHT_ARROW, quadrant); } }
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IProject) { IProject project = (IProject) element; if (!project.isOpen()) { try { IProjectDescription pd = ResourcesPlugin.getWorkspace() .loadProjectDescription(project.getLocation().append("/.project")); for (String nature : pd.getNatureIds()) { if (nature.contentEquals(CooperateProjectNature.NATURE_ID)) { decoration.addSuffix(" [Disconnected]"); } } } catch (CoreException e) { LOGGER.error(project.getLocation().append("/.project") + " can't be accessed.", e); } } } }
public Image decorateImage(Image image, Object element) { Image result = null; if (image != null && element instanceof PropertyElement) { PropertyElement property = (PropertyElement) element; if (property.isClassProperty()) { DecorationOverlayIcon decorator = new DecorationOverlayIcon(image, STATIC_OVERLAY, IDecoration.TOP_RIGHT); result = decorator.createImage(); } } return result; }
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IResource) { IResource resource = (IResource)element; if(resource.isAccessible()) { try { int severity = resource.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); switch (severity) { case IMarker.SEVERITY_ERROR: decoration.addOverlay(ERROR_OVERLAY); break; case IMarker.SEVERITY_WARNING: decoration.addOverlay(WARNING_OVERLAY); break; } } catch (CoreException e) { LogUtil.error("deteriming severity", e); } } } }
public void decorate(Object element, IDecoration decoration) { int adornmentFlags= computeAdornmentFlags(element); if ((adornmentFlags & JavaElementImageDescriptor.IMPLEMENTS) != 0) { if ((adornmentFlags & JavaElementImageDescriptor.SYNCHRONIZED) != 0) { decoration.addOverlay(JavaPluginImages.DESC_OVR_SYNCH_AND_IMPLEMENTS); } else { decoration.addOverlay(JavaPluginImages.DESC_OVR_IMPLEMENTS); } } else if ((adornmentFlags & JavaElementImageDescriptor.OVERRIDES) != 0) { if ((adornmentFlags & JavaElementImageDescriptor.SYNCHRONIZED) != 0) { decoration.addOverlay(JavaPluginImages.DESC_OVR_SYNCH_AND_OVERRIDES); } else { decoration.addOverlay(JavaPluginImages.DESC_OVR_OVERRIDES); } } }
/** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang .Object, * org.eclipse.jface.viewers.IDecoration) * @param element element * @param decoration decoration */ public void decorate(Object element, IDecoration decoration) { /** * Checks that the element is an IResource with the 'Read-only' attribute and adds the decorator based on the * specified image description and the integer representation of the placement option. */ if (element instanceof ProjectSpace) { ProjectSpace ps = (ProjectSpace) element; if (ps.isDirty()) { URL url = FileLocator.find(Platform.getBundle("org.eclipse.emf.ecp.common"), new Path(dirtyPath), null); descriptor = ImageDescriptor.createFromURL(url); decoration.addOverlay(descriptor, IDecoration.BOTTOM_LEFT); } } }
/** * . {@inheritDoc} */ public void decorate(Object element, IDecoration decoration) { if (element instanceof ProjectSpace) { ProjectSpace projectSpace = (ProjectSpace) element; StringBuilder stringBuilder = new StringBuilder(); if (projectSpace.getBaseVersion() != null) { stringBuilder.append("@"); stringBuilder.append(projectSpace.getBaseVersion().getIdentifier()); stringBuilder.append(" [" + projectSpace.getBaseVersion().getBranch() + "]"); } else { stringBuilder.append("(Not shared)"); } String string = stringBuilder.toString(); decoration.addSuffix(string); } }
@Override public void decorate(Object element, IDecoration decoration) { if (!(element instanceof IFolder)) { return; } IFolder folder = (IFolder)element; try { if (folder.getProject().hasNature("org.eclipse.thym.core.HybridAppNature") && folder.getProjectRelativePath().toPortableString().equals("www")) { decoration.addOverlay(wwwOverlay); } } catch (CoreException e) { HybridUI.log(IStatus.WARNING, "Could not determine Nature of project", e); } }
@Override public void decorate(Object element, IDecoration decoration) { final IResource resource = ResourceUtil.getResource(element); if (resource != null && resource.getType() != ROOT) { final CodenvyProvider provider = (CodenvyProvider)getProvider(resource.getProject(), CodenvyProvider.PROVIDER_ID); if (provider != null) { final CodenvyMetaResource metaResource = (CodenvyMetaResource)getAdapter(resource, CodenvyMetaResource.class, true); if (metaResource != null && metaResource.isTracked()) { decoration.addOverlay(trackedImageDescriptor); if (resource.getType() == PROJECT) { decoration.addSuffix(" [codenvy: " + provider.getProjectMetadata().url + "]"); } } } } }
public void decorate(Object element, IDecoration decoration) { if (image == null) { image = Activator.getDefault(). getImageRegistry().getDescriptor(Activator.PROJECT_DECORATOR); } IProject p = (IProject) element; try { if (p.isOpen() && p.hasNature(ProcessingProjectNature.class.getName())) { decoration.addOverlay(image, POS); } } catch (CoreException e) { e.printStackTrace(); } }
public void decorate(Object element, final IDecoration decoration) { IRepositoryResource resource = (IRepositoryResource) element; CompareResult compare = SubversiveSVNProviderImpl.getLastDiffBetweenBuilds(); if (compare != null && compare.hasDifference() && compare.hasDetectedRemovalOfProject(resource)) { decoration.addPrefix(" X "); Display.getDefault().syncExec(new Runnable() { @Override public void run() { decoration.setForegroundColor(Display.getDefault().getSystemColor(SWT.COLOR_GRAY)); } }); decoration.addSuffix(" NA in "+compare.to.getLabel()); decoration.addOverlay(ProjectDecorator.DEPRECATED, 1); return; } }
@Override public void decorate(Object element, IDecoration decoration){ IContact contact = (IContact) element; if (contact.isDeleted()) { ImageDescriptor deleted = Images.IMG_DELETE.getImageDescriptor(); decoration.addOverlay(deleted, IDecoration.TOP_LEFT); } if (contact.isMandator()) { ImageDescriptor vip = Images.IMG_VIP_OVERLAY.getImageDescriptor(); decoration.addOverlay(vip, IDecoration.BOTTOM_RIGHT); } if (contact.isUser()) { FieldDecoration info = FieldDecorationRegistry.getDefault().getFieldDecoration( FieldDecorationRegistry.DEC_INFORMATION); ImageDescriptor infoD = ImageDescriptor.createFromImage(info.getImage()); decoration.addOverlay(infoD, IDecoration.BOTTOM_LEFT); } }
@Override public void decorate(Object element, IDecoration decoration){ ArtikelstammItem item = (ArtikelstammItem) element; if (item.getExFactoryPrice() == 0.0 && item.getPublicPrice() == 0.0) { decoration.addOverlay(warning, IDecoration.TOP_LEFT); } if (item.isBlackBoxed()) { decoration.setForegroundColor(UiDesk.getColor(UiDesk.COL_WHITE)); decoration.setBackgroundColor(UiDesk.getColor(UiDesk.COL_BLACK)); } String genericType = item.getGenericType(); if (genericType.startsWith("G")) { decoration.addOverlay(ol_gGruen, IDecoration.BOTTOM_LEFT); } else if (genericType.startsWith("O")) { decoration.addOverlay(ol_oBlue, IDecoration.BOTTOM_LEFT); } }
@SuppressWarnings("javadoc") public N4JSDecoratorRow(ImageDescriptor main, int quadrant, List<ImageDescriptor> decos) { Objects.requireNonNull(main); if ((quadrant < IDecoration.TOP_LEFT) || (quadrant > IDecoration.BOTTOM_RIGHT)) { throw new IllegalArgumentException(); } Objects.requireNonNull(decos); this.main = main; this.quadrant = quadrant; this.decos = decos.toArray(new ImageDescriptor[decos.size()]); }
/** * Are the decorators aligned vertically on top? */ private boolean isDecoTop() { switch (quadrant) { case IDecoration.TOP_LEFT: case IDecoration.TOP_RIGHT: return true; default: return false; } }
/** * Do the decorators start on the left border? */ private boolean isDecoLeft() { switch (quadrant) { case IDecoration.TOP_LEFT: case IDecoration.BOTTOM_LEFT: return true; default: return false; } }
@Override public Image decorateImage(Image image, Object element) { if (image!=null) { if (element instanceof IProject) { IProject project = (IProject) element; boolean b = GW4ENature.hasGW4ENature(project); if (b) { DecorationOverlayIcon icon = new DecorationOverlayIcon(image, GW_DESCRIPTOR, IDecoration.TOP_LEFT); Image ret = (Image)resourceManager.get(icon); return ret; } } } return image; }
@Override public void decorate(Object resource, IDecoration decoration) { int markers = MarkerFactory.findMarkers((IResource) resource).size(); if (markers > 0) { decoration.addOverlay(ImageDescriptor.createFromFile(FileDecorator.class, ICON), IDecoration.TOP_RIGHT); decoration.setForegroundColor(color); } else { decoration.addOverlay(null); decoration.setForegroundColor(new Color(null, 0, 0, 0, 0)); } }
/** * This decorator allows us to paint based on the pending changes cache. (it * will decorate adds, checkouts, locks, etc.) * * @param resource * The IResource to decorate * @param decoration * The IDecoration which will be decorated * @param repository * The TFSRepository for this item * @param resourcePath * The local path to the resource for querying the pending changes * cache */ private void decorateFromFilePendingChanges( final IResource resource, final IDecoration decoration, final TFSRepository repository, final String resourcePath) { final PendingChange pendingChange = repository.getPendingChangeCache().getPendingChangeByLocalPath(resourcePath); // no pending changes, don't alter any decorations if (pendingChange == null || pendingChange.getChangeType() == null) { return; } final ChangeType pendingChangeType = pendingChange.getChangeType(); // handle adds if (pendingChangeType.contains(ChangeType.ADD)) { decoration.addOverlay(imageHelper.getImageDescriptor(ADD_ICON)); decoration.addPrefix("+"); //$NON-NLS-1$ } // edits else if (pendingChangeType.contains(ChangeType.EDIT)) { decoration.addOverlay(imageHelper.getImageDescriptor(EDIT_ICON)); decoration.addPrefix(">"); //$NON-NLS-1$ } // non-edit locks else if (pendingChangeType.contains(ChangeType.LOCK)) { decoration.addOverlay(imageHelper.getImageDescriptor(LOCK_ICON)); } // arbitrary pending changes just get a something else if (!pendingChangeType.isEmpty()) { decoration.addOverlay(imageHelper.getImageDescriptor(CHANGE_ICON)); } }
public void decorate(Object element, IDecoration decoration) { final ICoverageNode coverage = CoverageTools.getCoverageInfo(element); if (coverage == null) { // no coverage data return; } // TODO obtain counter from preferences ICounter counter = coverage.getInstructionCounter(); ImageDescriptor overlay = EclEmmaUIPlugin.getCoverageOverlay(counter .getCoveredRatio()); decoration.addOverlay(overlay, IDecoration.TOP_LEFT); decoration.addSuffix(SUFFIX_FORMAT.format(Double.valueOf(counter .getCoveredRatio()))); }
/** * add a prefix and a suffix depending on format string and the bindings * @param decoration * @param format * @param bindings */ public static void decorate(IDecoration decoration, IDecoratorComponent[][] format, Map bindings) { String[] prefixSuffix = decorate(format, bindings); decoration.addPrefix(prefixSuffix[0]); decoration.addSuffix(prefixSuffix[1]); }
private void computeColorsAndFonts(boolean isIgnored, boolean isDirty, IDecoration decoration) { if (!SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_USE_FONT_DECORATORS)) return; ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); if(isIgnored) { decoration.setBackgroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.IGNORED_BACKGROUND_COLOR)); decoration.setForegroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.IGNORED_FOREGROUND_COLOR)); decoration.setFont(current.getFontRegistry().get(SVNDecoratorConfiguration.IGNORED_FONT)); } else if(isDirty) { decoration.setBackgroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR)); decoration.setForegroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR)); decoration.setFont(current.getFontRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_FONT)); } }
private ImageDescriptor[] getOverlayImages(final Object element) { Bookmark bookmark = (Bookmark) Adapters.adapt(element, Bookmark.class); ImageDescriptor[] overlayImages = new ImageDescriptor[5]; RemoteBookmarkFolder remoteBookmarkFolder = remoteBookmarksStoreManager .getRemoteBookmarkFolderContaining(bookmarkDatabase.getBookmarksTree(), bookmark.getId()); if (remoteBookmarkFolder != null) { IRemoteBookmarksStore remoteBookmarksStore = remoteBookmarksStoreManager .getRemoteBookmarksStore(remoteBookmarkFolder.getRemoteBookmarkStoreId()); overlayImages[IDecoration.TOP_RIGHT] = remoteBookmarksStore.getDescriptor().getImageOverlayDescriptor(); } return overlayImages; }
private Image getImage(BookmarkNumber bookmarkNumber, Optional<BookmarkId> bookmarkId) { ImageDescriptor numberImageDescriptor = NumberedBookmarksImageDescriptors.getImageDescriptor(bookmarkNumber); if (!bookmarkId.isPresent()) { return (Image) this.resourceManager.get(numberImageDescriptor); } Bookmark bookmark = bookmarksService.getBookmarksTree().getBookmark(bookmarkId.get()); if (bookmark == null) { return (Image) this.resourceManager.get(numberImageDescriptor); } ImageDescriptor imageDescriptor = bookmarkLabelProvider.getImageDescriptor(context, bookmark); ImageDescriptor[] overlayImages = new ImageDescriptor[5]; overlayImages[IDecoration.TOP_LEFT] = numberImageDescriptor; OverlayIconImageDescriptor decorated = new OverlayIconImageDescriptor(imageDescriptor, overlayImages); return (Image) this.resourceManager.get(decorated); }