List of usage examples for org.eclipse.jface.viewers IDecoration addOverlay
void addOverlay(ImageDescriptor overlay);
From source file:org.tigris.subversion.subclipse.ui.decorator.SVNLightweightDecorator.java
License:Open Source License
/** * This method should only be called by the decorator thread. * /*from w w w . jav a 2s. com*/ * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) */ public void decorate(Object element, IDecoration decoration) { IResource resource = null; try { resource = getResource(element); if (resource != null && resource.getType() == IResource.ROOT) return; boolean isIgnored = false; SVNTeamProvider svnProvider = null; ISVNLocalResource svnResource = null; if (resource != null) { // get the team provider svnProvider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId()); if (svnProvider == null) return; // if the resource is ignored return an empty decoration. This will // force a decoration update event and clear the existing SVN decoration. svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource); try { if (svnResource.isIgnored()) { isIgnored = true; // return; } } catch (SVNException e) { // The was an exception in isIgnored. Don't decorate //todo should log this error return; } } // determine a if resource has outgoing changes (e.g. is dirty). boolean isDirty = false; boolean isUnversioned = false; if (resource == null) { if (element instanceof ResourceMapping) { IProject[] projects = ((ResourceMapping) element).getProjects(); if (projects != null) { for (IProject project : projects) { ISVNLocalResource svnProjectResource = SVNWorkspaceRoot.getSVNResourceFor(project); if (svnProjectResource != null) { try { if (svnProjectResource.isDirty()) { decoration.addOverlay(dirty); return; } } catch (SVNException e) { return; } } } } } return; } else { LocalResourceStatus status = null; if (!isIgnored) { try { status = svnResource.getStatusFromCache(); isDirty = SVNLightweightDecorator.isDirty(svnResource, status); } catch (SVNException e) { if (!e.operationInterrupted()) { SVNUIPlugin.log(e.getStatus()); isDirty = true; } } if (status != null) { isUnversioned = status.isUnversioned(); } // if (resource.getType() == IResource.FILE || computeDeepDirtyCheck) { //// isDirty = SVNLightweightDecorator.isDirty(svnResource); // isDirty = SVNLightweightDecorator.isDirty(svnResource, status); // } // try { // status = svnResource.getStatusFromCache(); // isUnversioned = status.isUnversioned(); // } catch (SVNException e1) { // if (!e1.operationInterrupted()) { // SVNUIPlugin.log(e1.getStatus()); // } // } decorateTextLabel(svnResource, status, decoration, isDirty); } computeColorsAndFonts(isIgnored, isDirty || isUnversioned, decoration); if (!isIgnored) { ImageDescriptor overlay = getOverlay(svnResource, status, isDirty, svnProvider); if (overlay != null) { //actually sending null arg would work but this makes logic clearer decoration.addOverlay(overlay); } } } } catch (Exception e) { SVNUIPlugin.log(IStatus.ERROR, "Error Decorating " + resource, e); } }
From source file:org.wso2.developerstudio.eclipse.greg.manager.local.decorators.RegistryResourceDecorator.java
License:Open Source License
/** * decorate checked out files and folders with images according to the state * whether the file or folder is in-sync with remote registry etc *//* ww w.j ava 2 s . c o m*/ public void decorate(Object element, IDecoration decoration) { if (element instanceof IFolder || element instanceof IFile) { IResource resource = (IResource) element; if (distinctFiles.contains(resource.getName())) { if (resource.getParent() instanceof IProject) return; } ImageDescriptor imageDescriptor = getImageDescriptor(resource); if (imageDescriptor != null) { decoration.addOverlay(imageDescriptor); } if (resource.getLocation() != null) { if (RegistryCheckInClientUtils.isRegistryResource(resource.getLocation().toOSString())) { try { RemoteRegistryInfo r = RegistryCheckInClientUtils .getResourceRemoteRegistryUrlInfo(resource.getLocation().toOSString()); Date date = new Date(r.getResourceLastUpdateTime()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("M/d/yyyy, h:mm a "); String suffix = " [" + simpleDateFormat.format(date) + " " + r.getResourceLastUpdateUser() + "] "; decoration.addSuffix(suffix); } catch (Exception e) { decoration.addSuffix(" Error"); } } } } }
From source file:sernet.verinice.iso27k.rcp.GroupDecorator.java
License:Open Source License
@Override public void decorate(Object o, IDecoration decoration) { if (o instanceof IISO27kGroup && !(o instanceof IISO27Scope) && !(o instanceof Asset)) { decoration.addOverlay(ImageCache.getInstance().getImageDescriptor(IMAGE_PATH)); }/*from w ww .j a va 2 s . c om*/ }
From source file:sernet.verinice.rcp.GsmIsmDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { Activator.inheritVeriniceContextState(); if (element instanceof CnATreeElement && prefEnabled() && isApplicable((CnATreeElement) element)) { decoration.addOverlay(ImageCache.getInstance() .getImageDescriptor(getImagePath(getGsmIsmLevel((CnATreeElement) element)))); }/*from ww w . j a v a2 s .c om*/ }
From source file:sernet.verinice.rcp.ImportDecorator.java
License:Open Source License
@Override public void decorate(Object o, IDecoration decoration) { if (o instanceof CnATreeElement) { CnATreeElement element = (CnATreeElement) o; if (element.getSourceId() != null && Activator.getDefault().getPluginPreferences() .getBoolean(PreferenceConstants.SHOW_ALIEN_DECORATOR)) { decoration.addOverlay(ImageCache.getInstance().getImageDescriptor(IMAGE_PATH)); decoration.addSuffix(new StringBuilder().append(" [").append(((CnATreeElement) o).getSourceId()) .append("]").toString()); }//from w w w.j ava2 s. co m } }
From source file:sernet.verinice.rcp.OwnControlDecorator.java
License:Open Source License
public void decorate(Object o, IDecoration decoration) { if (o instanceof MassnahmenUmsetzung) { ServerInitializer.inheritVeriniceContextState(); MassnahmenUmsetzung massnahme = (MassnahmenUmsetzung) o; if (massnahme.getUrl() == null || massnahme.getUrl().isEmpty() || massnahme.getUrl().equals("null")) { decoration.addOverlay(ImageCache.getInstance().getImageDescriptor(IMAGE_PATH)); }/*from www . j a v a 2 s . c o m*/ } }
From source file:sernet.verinice.rcp.RiskAnalysisDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { Activator.inheritVeriniceContextState(); CnATreeElement treeElement = null;/*w w w .j a va 2s. c o m*/ if (element instanceof CnATreeElement) { treeElement = (CnATreeElement) element; if (prefEnabled() && isApplicable(treeElement)) { int riskLevel = getRiskLevel(treeElement); if (riskLevel != NO_RISK_VALUE) { decoration.addOverlay(ImageCache.getInstance().getImageDescriptor(getImagePath(riskLevel))); } } } }
From source file:sernet.verinice.rcp.SiegelDecorator.java
License:Open Source License
@Override public void decorate(Object o, IDecoration decoration) { if (o instanceof BausteinUmsetzung) { Activator.inheritVeriniceContextState(); BausteinUmsetzung baustein = (BausteinUmsetzung) o; baustein = (BausteinUmsetzung) Retriever.retrieveElement(baustein, RetrieveInfo.getChildrenInstance().setChildrenProperties(true)); switch (baustein.getErreichteSiegelStufe()) { case 'A': decoration.addOverlay(ImageCache.getInstance().getImageDescriptor(IMAGE_A)); break; case 'B': decoration.addOverlay(ImageCache.getInstance().getImageDescriptor(IMAGE_B)); break; case 'C': decoration.addOverlay(ImageCache.getInstance().getImageDescriptor(IMAGE_C)); break; default:/*from ww w .ja v a2s.c o m*/ break; } } }
From source file:uk.ac.diamond.sda.navigator.decorator.LightweightMetadataDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IFile) { IFile ifile = (IFile) element;//from ww w.j a va2 s . com IPath path = ifile.getLocation(); if (path != null) { File file = path.toFile(); String lastModified = new SimpleDateFormat("dd/MM/yy hh:mm aaa") .format(new Date(file.lastModified())); String filePermission = getFilePermission(file); // file size - date of last modification - file permissions decoration.addSuffix(" " + readableFileSize(file.length()) + " " + lastModified);// +" "+filePermission); // Image overlay decoration according to file permission: if (filePermission.equals("- - -")) { ImageDescriptor lockOverlay = ImageDescriptor.createFromFile(this.getClass(), "/icons/decorators/unconfigured_co.gif"); decoration.addOverlay(lockOverlay); } } } }
From source file:_org.eclipse.jdt.ui.ProblemsLabelDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { ImageDescriptor imageDescriptor = computeAdornmentFlags(element); if (imageDescriptor != null) { decoration.addOverlay(imageDescriptor); }//w w w . j a v a 2 s .c o m }