List of usage examples for org.eclipse.jface.viewers IDecoration addSuffix
void addSuffix(String suffix);
From source file:com.microsoft.tfs.client.eclipse.ui.decorators.TFSLabelDecorator.java
License:Open Source License
/** * This allows us to decorate either the label or the icon used for an * IResource./*www. ja v a 2 s . co m*/ * * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, * org.eclipse.jface.viewers.IDecoration) */ @Override public void decorate(final Object element, final IDecoration decoration) { tryHookListeners(); // should never happen if (element == null || !(element instanceof IResource)) { return; } final IResource resource = (IResource) element; // if the resource is not in an open project, we don't decorate if (resource.getProject() == null || resource.getProject().isOpen() == false) { return; } // make sure that TFS is the repository provider for this resource if (!TeamUtils.isConfiguredWith(resource, TFSRepositoryProvider.PROVIDER_ID)) { return; } // ignore linked, private, team ignored resources if (eclipseIgnoreFilter.filter(resource).isReject()) { // add ignored suffix if enabled if (TFSCommonUIClientPlugin.getDefault().getPreferenceStore() .getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_IGNORED_STATUS)) { decoration.addSuffix(Messages.getString("TFSLabelDecorator.IgnoredDecorationSuffix")); //$NON-NLS-1$ } return; } // try to get the repository for this resource final TFSRepositoryProvider repositoryProvider = (TFSRepositoryProvider) TeamUtils .getRepositoryProvider(resource); final TFSRepository repository = repositoryProvider.getRepository(); // hook up any listeners, etc, if necessary if (repository != null) { addRepositoryListener(repository); } // try to get the full path for this resource final String resourcePath = Resources.getLocation(resource, LocationUnavailablePolicy.IGNORE_RESOURCE); final ResourceDataManager resourceDataManager = TFSEclipseClientPlugin.getDefault() .getResourceDataManager(); final ResourceData resourceData = resourceDataManager.getResourceData(resource); // decorate ignored resources with the ignored iconography if (PluginResourceFilters.TPIGNORE_FILTER.filter(resource).isReject() || PluginResourceFilters.TFS_IGNORE_FILTER.filter(resource).isReject()) { // add ignored suffix if enabled if (TFSCommonUIClientPlugin.getDefault().getPreferenceStore() .getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_IGNORED_STATUS)) { decoration.addSuffix(Messages.getString("TFSLabelDecorator.IgnoredDecorationSuffix")); //$NON-NLS-1$ } // if this is in TFS, paint this as in-tfs but ignored if (resourceData != null) { decoration.addOverlay(imageHelper.getImageDescriptor(IGNORED_ICON)); } // not in tfs, draw no iconography return; } // repository is offline if (repository == null) { decorateFromFilesystem(resource, decoration, repository); return; } // there are two passes here: first we update any information in the // pending changes cache, then we try to update information from the // itemcache. (if that fails, we use the readonly/writable hackery // from 2.0.) we draw high-priority overlays first, since the first // one wins.) /* * Add conflicts once conflict cache is considered reliable. */ // decorateFromConflicts(resource, decoration, repository, // resourcePath); // add decorations from pending changes decorateFromPendingChanges(resource, decoration, repository, resourcePath); resource.getProject().getLocation().toOSString(); if (resourceData != null) { decorateFromResourceData(resource, decoration, resourceData); } else if (!resourceDataManager.hasCompletedRefresh(resource.getProject())) { decorateFromFilesystem(resource, decoration, repository); } else if (resource instanceof IProject) { decoration.addOverlay(imageHelper.getImageDescriptor(TFS_ICON)); } }
From source file:com.microsoft.tfs.client.eclipse.ui.decorators.TFSLabelDecorator.java
License:Open Source License
/** * Decorate a resource based on data in the ResourceDataManager. (This * includes knowledge of whether the resource is actually in TFS, local * version, changeset date, etc.)/*from ww w .j a va2s .c o m*/ * * @param resource * The IResource to decorate * @param decoration * The IDecoration which will be decorated * @param resourceData * The {@link ResourceData} for this local resource */ private void decorateFromResourceData(final IResource resource, final IDecoration decoration, final ResourceData resourceData) { final List<String> suffixList = new ArrayList<String>(); // there's no item cache data (but the item cache was updated, above) // so there's nothing to decorate if (resourceData == null) { return; } // indicate that this file is in tfs decoration.addOverlay(imageHelper.getImageDescriptor(TFS_ICON)); // These preferences affect the decoration string final IPreferenceStore preferenceStore = TFSCommonUIClientPlugin.getDefault().getPreferenceStore(); // only show enhanced decorations for files, unless otherwise configured if (resource.getType() == IResource.FILE || preferenceStore.getBoolean(UIPreferenceConstants.LABEL_DECORATION_DECORATE_FOLDERS)) { // optionally show local changeset if (preferenceStore.getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_CHANGESET) && resourceData.getChangesetID() != 0) { suffixList.add(Integer.toString(resourceData.getChangesetID())); } if (preferenceStore.getBoolean(UIPreferenceConstants.LABEL_DECORATION_SHOW_SERVER_ITEM)) { suffixList.add(resourceData.getServerItem()); } // pretty up any suffix decorations if (suffixList.size() > 0) { final StringBuffer suffix = new StringBuffer(); suffix.append(" ["); //$NON-NLS-1$ for (int i = 0; i < suffixList.size(); i++) { if (i > 0) { suffix.append(", "); //$NON-NLS-1$ } suffix.append(suffixList.get(i)); } suffix.append("]"); //$NON-NLS-1$ decoration.addSuffix(suffix.toString()); } } }
From source file:com.midrange.rse_enhancements.decorator.DescriptionDecorator.java
License:Open Source License
/** * Add text decoration to QSYS Remote Objects * //from w w w . j a va2s. c o m * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) */ public void decorate(Object element, IDecoration decoration) { if (element instanceof ISeriesHostObjectBrief) { ISeriesHostObjectBrief object = (ISeriesHostObjectBrief) element; String description = object.getDescription(); if (description != null && description.length() > 0) { decoration.addSuffix(" (" + description + ")"); } } }
From source file:com.mountainminds.eclemma.internal.ui.decorators.CoverageDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { final ICoverageNode coverage = CoverageTools.getCoverageInfo(element); if (coverage == null) { // no coverage data return;/* www . j a v a2s .c o m*/ } // 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()))); }
From source file:com.nokia.tools.vct.navigator.sign.SignatureDecorator.java
License:Open Source License
void decorate2(Object element, IDecoration decoration) { if (element instanceof IResource && !(element instanceof IWorkspaceRoot)) { IResource resource = (IResource) element; URI resourceURI = URI.createPlatformResourceURI(resource.getFullPath().toString(), true); if (resource instanceof IContainer) { resourceURI = resourceURI.appendSegment(""); }// ww w. jav a 2 s.co m EConfigurationProject cpf = ConfMLCore.getProjectModel(resource.getProject()); EConfMLLayer layer = ConfMLCore.getLayer((IResource) element); if (cpf == null) { return; } if (resource instanceof IProject) { SigningStatus status = CPFSigningUtils.getRootStatus(cpf); if (!status.signatureFound) { decoration.addSuffix(" [unsigned]"); } else if (status.contentOK) { decoration.addSuffix(" [signed: " + SigningUtils.getShortName(status.certificate) + "]"); } else { decoration.addSuffix(" [signature error]"); } return; } else if (layer != null) { if (resourceURI.equals(layer.getLayerURI())) { SigningStatus status = CPFSigningUtils.getLayerStatus(layer); if (!status.signatureFound) { decoration.addSuffix(" [unsigned]"); } else if (status.contentOK) { decoration.addSuffix(" [signed: " + SigningUtils.getShortName(status.certificate) + "]"); } else { decoration.addSuffix(" [signature error]"); } } } } else if (element instanceof EConfMLLayer) { } }
From source file:com.vectrace.MercurialEclipse.team.ResourceDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration d) { IResource resource = (IResource) element; IProject project = resource.getProject(); if (project == null || !project.isAccessible()) { return;// www. j a v a 2 s .com } try { if (!MercurialTeamProvider.isHgTeamProviderFor(project)) { return; } if (!STATUS_CACHE.isStatusKnown(project)) { // simply wait until the cache sends us an event d.addOverlay(DecoratorImages.NOT_TRACKED); if (resource == project) { d.addSuffix(" [Hg status pending...]"); } return; } ImageDescriptor overlay = null; StringBuilder prefix = new StringBuilder(2); Integer output = STATUS_CACHE.getStatus(resource); if (output != null) { overlay = decorate(output.intValue(), prefix, d, colorise); } else { if (resource.getType() == IResource.FILE) { overlay = decorate(MercurialStatusCache.BIT_IGNORE, prefix, d, colorise); } // empty folder, do nothing } if (overlay != null) { d.addOverlay(overlay); } if (!showChangeset) { if (resource.getType() == IResource.PROJECT || shouldCheckSubrepo(resource)) { d.addSuffix(getSuffixForContainer((IContainer) resource)); } } else { addChangesetInfo(d, resource, project, prefix); } // we want a prefix, even if no changeset is displayed if (prefix.length() > 0) { d.addPrefix(prefix.toString()); } } catch (Exception e) { MercurialEclipsePlugin.logError(e); } }
From source file:com.vectrace.MercurialEclipse.team.ResourceDecorator.java
License:Open Source License
private void addChangesetInfo(IDecoration d, IResource resource, IProject project, StringBuilder prefix) throws CoreException { // label info for incoming changesets ChangeSet newestIncomingChangeSet = null; if (showIncomingChangeset) { try {// w w w . j ava2 s . c o m newestIncomingChangeSet = INCOMING_CACHE.getNewestChangeSet(resource); } catch (HgException e) { // if an error occurs we want the rest of the decoration to succeed nonetheless MercurialEclipsePlugin.logError(e); } } if (newestIncomingChangeSet != null) { if (prefix.length() == 0) { prefix.append('<').append(' '); } else { prefix.insert(0, '<'); } } // local changeset info try { // init suffix with project changeset information, or for folders that contain a subrepos String suffix = ""; //$NON-NLS-1$ if (resource.getType() == IResource.PROJECT || shouldCheckSubrepo(resource)) { suffix = getSuffixForContainer((IContainer) resource); } // overwrite suffix for files if (resource.getType() == IResource.FILE) { suffix = getSuffixForFiles(resource, newestIncomingChangeSet); } // only decorate files and project with suffix if ((resource.getType() != IResource.FOLDER || enableSubrepos) && suffix != null && suffix.length() > 0) { d.addSuffix(suffix); } } catch (HgException e) { MercurialEclipsePlugin .logWarning(Messages.getString("ResourceDecorator.couldntGetVersionOfResource") + resource, e); } }
From source file:de.fuberlin.agcsw.heraclitus.svont.client.ui.SVoNtLightweightDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof TreeNode) { SVoNtProject sp = SVoNtManager.getSVoNtProjectByID(ConceptTree.ontologyStore.getId()); if (sp != null) { TreeNode td = (TreeNode) element; ConceptTreeNode ctn = (ConceptTreeNode) td.getValue(); OWLClass cl = ctn.getConcept(); String suffix = " "; RevisionInfo ri;/*from ww w. ja va 2 s . com*/ ri = (RevisionInfo) ((sp.getRevisionMap().get(cl) != null) ? sp.getRevisionInformationMap().get(sp.getRevisionMap().get(cl)) : sp.getRevisionInformationMap().get(sp.getHeadRev())); suffix += "[" + String.valueOf(ri.getRevision() + " " + ri.getDate() + " " + ri.getAuthor() + "]"); // System.out.println("Decorating a TreeNode"); decoration.addSuffix(suffix); // decoration. // ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); // decoration. // // Color c = new Color(Display.getDefault(),149,125,71); // decoration. // decoration.setForegroundColor(c); } } }
From source file:de.fu_berlin.inf.dpp.ui.decorators.SharedProjectDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { // make a copy as this value might change while decorating ISarosSession currentSession = session; if (currentSession == null) return;/*from www.j ava2 s. c o m*/ IResource resource = (IResource) element; if (!currentSession.isShared(ResourceAdapterFactory.create(resource))) return; decoration.addOverlay(SharedProjectDecorator.PROJECT_DESCRIPTOR, IDecoration.TOP_LEFT); if (resource.getType() == IResource.PROJECT) { boolean isCompletelyShared = currentSession .isCompletelyShared(ResourceAdapterFactory.create(resource.getProject())); decoration.addSuffix(isCompletelyShared ? Messages.SharedProjectDecorator_shared : Messages.SharedProjectDecorator_shared_partial); } }
From source file:de.jcup.egradle.eclipse.decorators.EGradleProjectDecorator.java
License:Apache License
@Override public void decorate(Object element, IDecoration decoration) { /* no decoration when plugin is not running */ if (Activator.getDefault() == null) { return;//from ww w . j a v a 2 s .c om } /* no decoration when workbench is not running */ if (!PlatformUI.isWorkbenchRunning()) { return; } /* do not decoratore if its not a project */ if (!(element instanceof IProject)) { return; } IProject p = (IProject) element; File rootFolder = EGradleUtil.getRootProjectFolderWithoutErrorHandling(); if (rootFolder == null) { return; } if (EGradleUtil.hasVirtualRootProjectNature(p)) { decoration.addPrefix("EGradle "); decoration.addSuffix(" (" + rootFolder.getName() + ")"); decorateImage(decoration); /* Because the virtual root project is not hosted in SCM - at least with GIT, there is always an * ugly question icon at IDecoration.BOTTOM_RIGHT . To avoid this * we simply render an empty deocorator here. This is okay, because diff * changes in project are rendered as usual */ decoration.addOverlay(emptyDecoratorDescriptor, IDecoration.BOTTOM_RIGHT); return; } /* we simply check if the project is inside root project */ try { if (!isSubprojectOfCurrentRootProject(p)) { return; } if (EGradleUtil.getPreferences().isSubProjectIconDecorationEnabled()) { decorateImage(decoration); } } catch (CoreException e) { EGradleUtil.log(e); } }