List of usage examples for org.eclipse.jface.viewers IDecoration setBackgroundColor
void setBackgroundColor(Color color);
From source file:com.aptana.git.ui.internal.GitLightweightDecorator.java
License:Open Source License
private void decorateFile(IDecoration decoration, final IResource resource) { IFile file = (IFile) resource;//from ww w .j a va2s . c om GitRepository repo = getRepo(resource); if (repo == null) return; ChangedFile changed = repo.getChangedFileForResource(file); if (changed == null) { return; } ImageDescriptor overlay = null; // Unstaged trumps staged when decorating. One file may have both staged and unstaged changes. if (changed.hasUnstagedChanges()) { decoration.setForegroundColor(GitColors.redFG()); decoration.setBackgroundColor(GitColors.redBG()); if (changed.getStatus() == ChangedFile.Status.NEW) { overlay = untrackedImage(); } else if (changed.getStatus() == ChangedFile.Status.UNMERGED) { overlay = conflictImage(); } } else if (changed.hasStagedChanges()) { decoration.setForegroundColor(GitColors.greenFG()); decoration.setBackgroundColor(GitColors.greenBG()); if (changed.getStatus() == ChangedFile.Status.DELETED) { overlay = stagedRemovedImage(); } else if (changed.getStatus() == ChangedFile.Status.NEW) { overlay = stagedAddedImage(); } } decoration.addPrefix(DIRTY_PREFIX); if (overlay != null) decoration.addOverlay(overlay); }
From source file:com.ibm.research.tagging.resource.decorators.ResourceWaypointDecorator.java
License:Open Source License
private void applyDecoration(Object element, IDecoration decoration) { if (fResources == null) decoration.setBackgroundColor(null); else if (isWaypointedObject(element)) decoration.setBackgroundColor(fColor); else/*from ww w . j a va 2 s . c o m*/ decoration.setBackgroundColor(null); }
From source file:com.vectrace.MercurialEclipse.team.ResourceDecorator.java
License:Open Source License
private void setBackground(IDecoration d, String id) { d.setBackgroundColor(theme.getColorRegistry().get(id)); }
From source file:cz.modry.eclipse.coloredtabs.decorators.ProjectColorDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { RGB projectRGBColor = ColoredTabsPropertyPage.getProjectColor(element); Color projectColor;//from w ww . j a v a2s.c o m if (allocatedColors.containsKey(element)) { projectColor = allocatedColors.get(element); if (!projectColor.getRGB().equals(projectRGBColor)) { projectColor.dispose(); projectColor = new Color(null, projectRGBColor); allocatedColors.put(element, projectColor); } } else { projectColor = new Color(null, projectRGBColor); allocatedColors.put(element, projectColor); } decoration.setBackgroundColor(projectColor); }
From source file:nl.hostnet.deadfiles.decorators.DeadFileDecorator.java
License:Open Source License
/** * Perform the decoration of an element. Eclipse will call this function on the registered element * types. {@inheritDoc}/*from ww w. j a v a 2 s. co m*/ * * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang .Object, * org.eclipse.jface.viewers.IDecoration) */ 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. */ IResource resource = (IResource) element; if (foreground) { decoration.setForegroundColor(getColor(resource)); } else if (background) { decoration.setBackgroundColor(getColor(resource)); } }
From source file:org.eclipse.team.internal.ccvs.ui.CVSDecoration.java
License:Open Source License
public void apply(IDecoration decoration) { compute();//w w w.j ava 2 s.com // apply changes String suffix = getSuffix(); if (suffix != null) decoration.addSuffix(suffix); String prefix = getPrefix(); if (prefix != null) decoration.addPrefix(prefix); ImageDescriptor overlay = getOverlay(); if (overlay != null) decoration.addOverlay(overlay); Color bc = getBackgroundColor(); if (bc != null) decoration.setBackgroundColor(bc); Color fc = getForegroundColor(); if (fc != null) decoration.setForegroundColor(fc); Font f = getFont(); if (f != null) decoration.setFont(f); }
From source file:org.eclipse.team.svn.ui.decorator.SVNLightweightDecorator.java
License:Open Source License
protected void decorateResourceImpl(final IRepositoryResource remote, final ILocalResource local, final IResource resource, final String state, final int mask, IDecoration decoration) { if (IStateFilter.SF_TREE_CONFLICTING.accept(resource, state, mask) && this.indicateConflicted) { decoration.addOverlay(SVNLightweightDecorator.OVR_CONFLICTED); } else if (local.isLocked() && this.indicateLocked) { decoration.addOverlay(SVNLightweightDecorator.OVR_LOCKED); } else if (IStateFilter.SF_IGNORED.accept(resource, state, mask)) { if (this.useFonts) { decoration.setBackgroundColor(this.ignoredBackgroundColor); decoration.setForegroundColor(this.ignoredForegroundColor); decoration.setFont(this.ignoredFont); }/*from w w w. j a v a2 s . com*/ } else if (IStateFilter.SF_NEW.accept(resource, state, mask)) { if (this.indicateNew) { decoration.addOverlay(SVNLightweightDecorator.OVR_NEW); } } else if (this.indicateNeedsLock && IStateFilter.SF_NEEDS_LOCK.accept(resource, state, mask)) { decoration.addOverlay(SVNLightweightDecorator.OVR_NEEDS_LOCK); } else if (IStateFilter.SF_ADDED.accept(resource, state, mask)) { //new state also recognized as added, then it should be before added if (this.indicateAdded) { decoration.addOverlay(SVNLightweightDecorator.OVR_ADDED); } } else if (this.indicateDeleted(resource) && IStateFilter.SF_DELETED.accept(resource, state, mask)) { decoration.addOverlay(SVNLightweightDecorator.OVR_DELETED); } else if (IStateFilter.SF_CONFLICTING.accept(resource, state, mask)) { if (this.indicateConflicted) { decoration.addOverlay(SVNLightweightDecorator.OVR_CONFLICTED); } else if (this.indicateModified) { decoration.addOverlay(SVNLightweightDecorator.OVR_MODIFIED); } else if (this.indicateSwitched && (local.getChangeMask() & ILocalResource.IS_SWITCHED) != 0) { decoration.addOverlay(SVNLightweightDecorator.OVR_SWITCHED); } else if (this.indicateRemote) { decoration.addOverlay(SVNLightweightDecorator.OVR_VERSIONED); } } else if (IStateFilter.SF_MODIFIED.accept(resource, state, mask)) { if (this.indicateModified) { decoration.addOverlay(SVNLightweightDecorator.OVR_MODIFIED); } else if (this.indicateSwitched && (local.getChangeMask() & ILocalResource.IS_SWITCHED) != 0) { decoration.addOverlay(SVNLightweightDecorator.OVR_SWITCHED); } else if (this.indicateRemote) { decoration.addOverlay(SVNLightweightDecorator.OVR_VERSIONED); } } else if (IStateFilter.SF_OBSTRUCTED.accept(resource, state, mask)) { decoration.addOverlay(SVNLightweightDecorator.OVR_OBSTRUCTED); } else if (IStateFilter.SF_VERSIONED.accept(resource, state, mask)) { if (this.indicateSwitched && (local.getChangeMask() & ILocalResource.IS_SWITCHED) != 0) { decoration.addOverlay(SVNLightweightDecorator.OVR_SWITCHED); } else if (this.indicateRemote) { decoration.addOverlay(SVNLightweightDecorator.OVR_VERSIONED); } } if (this.useFonts && IStateFilter.SF_ANY_CHANGE.accept(resource, state, mask)) { decoration.setBackgroundColor(this.changedBackgroundColor); decoration.setForegroundColor(this.changedForegroundColor); decoration.setFont(this.changedFont); } this.decorator.decorateText(decoration, this.getFormat(resource), new IVariableContentProvider() { public String getValue(IVariable var) { if (var.equals(TextVariableSetProvider.VAR_ADDED_FLAG)) { return IStateFilter.SF_ADDED.accept(resource, state, mask) ? SVNLightweightDecorator.this.addedChars : ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_OUTGOING_FLAG)) { return (IStateFilter.SF_COMMITABLE.accept(resource, state, mask) || IStateFilter.SF_CONFLICTING.accept(resource, state, mask) || IStateFilter.SF_TREE_CONFLICTING.accept(resource, state, mask)) ? SVNLightweightDecorator.this.outgoingChars : ""; //$NON-NLS-1$ } if (var.equals(TextVariableSetProvider.VAR_REVISION)) { return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask) && !IStateFilter.SF_PREREPLACEDREPLACED.accept(resource, state, mask) ? String.valueOf(local.getRevision()) : ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_AUTHOR)) { String author = local.getAuthor() == null ? "[no author]" : local.getAuthor(); //$NON-NLS-1$ return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask) ? author : ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_DATE)) { if (!IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) { return ""; //$NON-NLS-1$ } long date = local.getLastCommitDate(); if (date == 0) { return SVNMessages.SVNInfo_NoDate; } return DateFormatter.formatDate(date); } else if (var.equals(TextVariableSetProvider.VAR_RESOURCE_URL)) { return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask) ? SVNUtility.decodeURL(remote.getUrl()) : ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_SHORT_RESOURCE_URL)) { if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) { String shortURL = SVNUtility.decodeURL(remote.getUrl()) .substring(remote.getRepositoryLocation().getRepositoryRootUrl().length()); return shortURL.startsWith("/") ? shortURL.substring(1) : shortURL; //$NON-NLS-1$ } return ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_LOCATION_URL)) { return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask) ? remote.getRepositoryLocation().getUrlAsIs() : ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_LOCATION_LABEL)) { if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) { IRepositoryLocation location = remote.getRepositoryLocation(); String label = location.getLabel(); return label == null || label.length() == 0 ? location.getUrlAsIs() : label; } return ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_ROOT_PREFIX)) { if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) { int kind = ((IRepositoryRoot) remote.getRoot()).getKind(); return kind == IRepositoryRoot.KIND_TAGS ? SVNLightweightDecorator.this.tagPrefix : (kind == IRepositoryRoot.KIND_BRANCHES ? SVNLightweightDecorator.this.branchPrefix : (kind == IRepositoryRoot.KIND_TRUNK ? SVNLightweightDecorator.this.trunkPrefix : "" //$NON-NLS-1$ )); } return ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_ASCENDANT)) { if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) { return SVNUtility.getAscendant(remote); } return ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_DESCENDANT)) { if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) { return SVNUtility.getDescendant(remote); } return ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_FULLNAME)) { if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) { return SVNUtility.getPathUpToRoot(remote); } return ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_FULLPATH)) { if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) { String retVal = SVNUtility.getPathUpToRoot(remote); int pos = retVal.lastIndexOf('/'); if (pos != -1) { retVal = retVal.substring(0, pos); } return retVal; } return ""; //$NON-NLS-1$ } else if (var.equals(TextVariableSetProvider.VAR_REMOTE_NAME)) { return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask) ? remote.getName() : ""; //$NON-NLS-1$ } if (var.equals(TextVariableSetProvider.VAR_NAME)) { return local.getName(); } return var.toString(); } }); }
From source file:org.eclipse.ui.tests.decorators.BackgroundColorDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (color == null) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { /*/* w w w. jav a 2 s . com*/ * (non-Javadoc) * * @see java.lang.Runnable#run() */ public void run() { setUpColor(); } }); } decoration.setBackgroundColor(color); }
From source file:org.eclipsetrader.ui.internal.trading.WatchlistAlertDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IAdaptable) { element = ((IAdaptable) element).getAdapter(ISecurity.class); }/* ww w.ja v a2 s . c om*/ if (element == null || !(element instanceof ISecurity)) { return; } decoration.addPrefix("*"); //$NON-NLS-1$ if (alertService.hasTriggeredAlerts((ISecurity) element)) { if (foreground == null) { foreground = new Color(Display.getDefault(), 255, 0, 0); } decoration.setBackgroundColor(foreground); } }
From source file:org.tigris.subversion.subclipse.ui.decorator.SVNLightweightDecorator.java
License:Open Source License
private void computeColorsAndFonts(boolean isIgnored, boolean isDirty, IDecoration decoration) { if (!SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_USE_FONT_DECORATORS)) return;//from www . j a v a 2s . c o m 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)); } }