List of usage examples for org.eclipse.jface.viewers IDecoration setFont
void setFont(Font font);
From source file:br.ufmg.dcc.tabuleta.decorators.LightWeightDecorator.java
License:Open Source License
/** * Decorates elements belonging to the concern model in the JDT views. * @param pElement The element being decorated * @param pDecoration The decoration to add to the element's label * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) *//*www . j a v a 2s. co m*/ public void decorate(Object pElement, IDecoration pDecoration) { boolean lDoDecorateSuffix = false; boolean lDoDecorateFont = false; List<String> lConcerns = new ArrayList<String>(); //Get the names of the concerns from the concern model String[] lConcernNames = Tabuleta.getDefault().getConcernModel().getConcernNames(); //For each concern, get the elements it contains for (String lConcernName : lConcernNames) { Set<Object> lCurrentConcernElements = Tabuleta.getDefault().getConcernModel().getElements(lConcernName); //if pElement is an element of the current concern //add the name of the concern to the list of concerns pElement belongs to if (lCurrentConcernElements.contains(pElement)) { int lDegree = Tabuleta.getDefault().getConcernModel().getDegree(lConcernName, pElement); int lThreshold = Tabuleta.getDefault().getPreferenceStore() .getInt(ConcernMapperPreferencePage.P_FILTER_THRESHOLD); boolean lFilter = Tabuleta.getDefault().getPreferenceStore() .getBoolean(ConcernMapperPreferencePage.P_FILTER_ENABLED); if ((lDegree >= lThreshold) || !lFilter) { lConcerns.add(lConcernName); lDoDecorateSuffix = true; lDoDecorateFont = true; } } else { if (getAllParents(lCurrentConcernElements, lConcernName).contains(pElement)) { lDoDecorateFont = true; } } } //sort the concerns in alphabetical order Collections.sort(lConcerns); //add the decorations if (lDoDecorateSuffix && Tabuleta.getDefault().getPreferenceStore() .getBoolean(ConcernMapperPreferencePage.P_SUFFIX_ENABLED)) { pDecoration.addSuffix(" " + lConcerns.toString()); } if (lDoDecorateFont && Tabuleta.getDefault().getPreferenceStore() .getBoolean(ConcernMapperPreferencePage.P_BOLD_ENABLED)) { pDecoration.setFont(PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry() .getBold("Text Font")); } }
From source file:com.nokia.tools.vct.confml.editor.view.viewers.ViewTreeViewerLabelDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (element instanceof ESetting) { if (((ESetting) element).isReadOnly()) { decoration.addOverlay(readOnlyDescriptor, IDecoration.TOP_RIGHT); }// w ww. j a v a 2 s. c o m } else if (element instanceof ESettingEntryImpl) { if (((ESettingEntryImpl) element).getValue().isReadOnly()) { decoration.addOverlay(readOnlyDescriptor, IDecoration.TOP_RIGHT); decoration.addOverlay(warningDescriptor, IDecoration.BOTTOM_LEFT); } } else if (hasMarker(element, ERROR, null)) { decoration.addOverlay(errorDescriptor, IDecoration.BOTTOM_LEFT); } else if (hasMarker(element, WARNING, null)) { decoration.addOverlay(warningDescriptor, IDecoration.BOTTOM_LEFT); } if (element instanceof ESettingRef) { ESettingRef ref = (ESettingRef) element; if (ref.getTarget() instanceof ESetting) { if (((ESetting) ref.getTarget()).isReadOnly()) { decoration.addOverlay(readOnlyDescriptor, IDecoration.TOP_RIGHT); } } } if (element instanceof EAppFeature) { EAppFeature feature = (EAppFeature) element; if (isDefaultValue(feature)) { decoration.setFont(DEFAULT_FONT); } else { decoration.setFont(BOLD_FONT); } } }
From source file:com.vectrace.MercurialEclipse.team.ResourceDecorator.java
License:Open Source License
private void setFont(IDecoration d, String id) { d.setFont(theme.getFontRegistry().get(id)); }
From source file:org.eclipse.jdt.ui.examples.JavaElementLightweightDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { IPath path = null;//ww w .java 2 s.c om if (element instanceof IResource) { path = ((IResource) element).getFullPath(); } else if (element instanceof IClassFile || element instanceof ICompilationUnit) { path = ((IJavaElement) element).getPath(); } if (path != null) { if (FileBuffers.getTextFileBufferManager().getFileBuffer(path, LocationKind.NORMALIZE) != null) { decoration.setFont(fBold); } } }
From source file:org.eclipse.mylyn.internal.context.ui.InterestDecoratorLightweight.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (ContextCore.getContextManager() != null && !ContextCore.getContextManager().isContextActive()) { return;//from www.j a va 2 s . c o m } AbstractContextStructureBridge bridge = null; try { if (ContextCorePlugin.getDefault() == null) { return; } bridge = ContextCore.getStructureBridge(element); } catch (ConcurrentModificationException cme) { // ignored, because we can add structure bridges during decoration } try { // NOTE: awkward coupling and special rule to deal with tasks, see bug 212639 if (!"org.eclipse.mylyn.internal.tasks.core.TaskTask".equals(element.getClass().getName())) { //$NON-NLS-1$ IInteractionElement node = null; if (element instanceof InteractionContextRelation) { decoration.setForegroundColor(ColorMap.RELATIONSHIP); } else if (element instanceof IInteractionElement) { node = (IInteractionElement) element; } else { if (bridge != null && bridge.getContentType() != null) { node = ContextCore.getContextManager().getElement(bridge.getHandleIdentifier(element)); } } if (node != null) { decoration.setForegroundColor(ContextUi.getForeground(node)); if (bridge != null && bridge.canBeLandmark(node.getHandleIdentifier()) && node.getInterest().isLandmark() && !node.getInterest().isPropagated() && !node.getInterest().isPredicted()) { decoration.setFont(CommonFonts.BOLD); } } } } catch (Exception e) { StatusHandler.log(new Status(IStatus.ERROR, ContextUiPlugin.ID_PLUGIN, "Decoration failed", e)); //$NON-NLS-1$ } }
From source file:org.eclipse.mylyn.internal.team.ui.ContextChangeSetDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (element instanceof IContextChangeSet) { IContextChangeSet changeSet = (IContextChangeSet) element; if (changeSet.getTask().isActive()) { decoration.setFont(CommonFonts.BOLD); }/*w w w . ja v a2 s. c o m*/ } }
From source file:org.eclipse.team.internal.ccvs.ui.CVSDecoration.java
License:Open Source License
public void apply(IDecoration decoration) { compute();//from ww w.ja va 2 s. co m // 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 va2s .c om } 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.FontDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (font == null) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { /*/* ww w .j a v a 2 s .c o m*/ * (non-Javadoc) * * @see java.lang.Runnable#run() */ public void run() { setUpFont(); } }); } decoration.setFont(font); }
From source file:org.polymap.core.project.ui.layer.LayerStatusDecorator.java
License:Open Source License
public void decorate(Object elm, IDecoration decoration) { if (elm instanceof ILayer) { ILayer layer = (ILayer) elm;// w w w. j av a 2 s.co m try { layer.id(); } catch (NoSuchEntityException e) { // handled by EntityModificationDecorator return; } // visible if (layer.isVisible()) { ImageDescriptor image = ProjectPlugin.getDefault().imageDescriptor(visible); decoration.setFont(bold); DecorationContext context = (DecorationContext) decoration.getDecorationContext(); context.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); decoration.addOverlay(image, IDecoration.REPLACE); ImageDescriptor ovr = ProjectPlugin.getDefault().imageDescriptor(visible_ovr); decoration.addOverlay(ovr, TOP_LEFT); } // inactive == not visible if (!layer.isVisible()) { decoration.setForegroundColor(INACTIVE_COLOR); } LayerStatus layerStatus = layer.getLayerStatus(); if (layerStatus.getCode() == LayerStatus.MISSING) { decoration.setForegroundColor(MISSING_COLOR); decoration.addSuffix(Messages.get("LayerStatusDecorator_missing")); } else if (layerStatus.getCode() == LayerStatus.WAITING) { ImageDescriptor ovr = ProjectPlugin.getDefault().imageDescriptor(waiting); decoration.setFont(italic); decoration.addOverlay(ovr, TOP_RIGHT); decoration.addSuffix(Messages.get("LayerStatusDecorator_checking")); } else if (layerStatus.getSeverity() == LayerStatus.OK) { // } // register listener decorated.put(layer.id(), layer); } }