Example usage for org.eclipse.jface.viewers IDecoration addPrefix

List of usage examples for org.eclipse.jface.viewers IDecoration addPrefix

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IDecoration addPrefix.

Prototype

void addPrefix(String prefix);

Source Link

Document

Adds a prefix to the element's label.

Usage

From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java

License:Open Source License

/**
 * Adds decoration for edited state.//from  www .j  a  va2 s.  c  o m
 * 
 * @param decoration
 */
private static void decorateEdited(IDecoration decoration) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateEdited"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateClearCaseElements())
        decoration.addOverlay(IMG_DESC_ELEMENT_BG, IDecoration.TOP_LEFT + IDecoration.UNDERLAY);
    if (ClearCaseUIPreferences.decorateEditedElements()) {
        decoration.addOverlay(IMG_DESC_EDITED);
    }
    if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) {
        decoration.addPrefix(ClearCaseUI.getTextPrefixEdited());
    }
}

From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java

License:Open Source License

/**
 * Adds decoration for hijaced state.//from  ww  w  .  j a  v a 2  s  .c  o  m
 * 
 * @param decoration
 */
private static void decorateHijacked(IDecoration decoration, String version) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateHijacked"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateClearCaseElements())
        decoration.addOverlay(IMG_DESC_ELEMENT_BG, IDecoration.TOP_LEFT + IDecoration.UNDERLAY);
    if (ClearCaseUIPreferences.decorateHijackedElements()) {
        decoration.addOverlay(IMG_DESC_HIJACKED);
    }
    if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) {
        decoration.addPrefix(ClearCaseUI.getTextPrefixHijacked());
    }
    if (ClearCaseUIPreferences.decorateElementsWithVersionInfo() && null != version) {
        decoration.addSuffix("  " + version); //$NON-NLS-1$
    }
}

From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java

License:Open Source License

/**
 * Adds decoration for new state.//ww w .  j a  v  a2 s .  com
 * 
 * @param decoration
 */
private static void decorateNew(IDecoration decoration) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateNew"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateViewPrivateElements()) {
        decoration.addOverlay(IMG_DESC_NEW_RESOURCE);
    }
    if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) {
        decoration.addPrefix(ClearCaseUI.getTextPrefixNew());
    }
}

From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java

License:Open Source License

/**
 * Adds decoration for unknown state.//from ww w. j a  v  a 2 s  .  c o  m
 * 
 * @param decoration
 */
private static void decorateUnknown(IDecoration decoration) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateUnknown"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateUnknownElements()) {
        decoration.addOverlay(IMG_DESC_UNKNOWN_STATE);
    }
    if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) {
        decoration.addPrefix(ClearCaseUI.getTextPrefixUnknown());
    }
}

From source file:org.eclipse.jubula.client.teststyle.gui.decoration.DecoratorHandler.java

License:Open Source License

/**
 * Checks in the ProblemCont if the INodePO contains Elements which must be
 * decorated for violating a Checkstyle rule.
 * /*from   ww w. j a  va 2  s.  c  o  m*/
 * {@inheritDoc}
 */
public void decorate(Object element, IDecoration decoration) {
    if (element == null || !TeststyleHandler.getInstance().isEnabled()) {
        return; // Cancel the method, an null element can't be decorated.
    }

    Severity severity = getWorstSeverity(getViolatingBaseChecks(element));

    if (element instanceof INodePO && severity != null) {
        INodePO node = (INodePO) element;
        IProblem worstProblem = ProblemFactory.getWorstProblem(node.getProblems());
        if (worstProblem != null && severity.ordinal() * 2 <= worstProblem.getStatus().getSeverity()) {
            severity = null;
        }
    }

    if (severity != null) {
        switch (severity) {
        case WARNING:
            decoration.addOverlay(IconConstants.WARNING_IMAGE_DESCRIPTOR, IDecoration.BOTTOM_RIGHT);
            break;
        case ERROR:
            decoration.addOverlay(IconConstants.ERROR_IMAGE_DESCRIPTOR, IDecoration.BOTTOM_RIGHT);
            break;
        default:
            break;
        }
    }
    for (BaseCheck chk : getViolatingBaseChecks(element)) {
        decoration.addPrefix(chk.getPrefix(element));
        decoration.addSuffix(chk.getSuffix(element));
    }
    BaseContext cont = BaseContext.getFor(element.getClass());
    for (DecoratingCheck chk : CheckCont.getDecChecksFor(cont)) {
        if (chk.isActive(cont) && chk.decorate(element)) {
            // FIXME mbs decorating icons
            decoration.addPrefix(chk.getPrefix(element));
            decoration.addSuffix(chk.getSuffix(element));
        }
    }
}

From source file:org.eclipse.mdht.uml.ui.navigator.internal.StereotypeLightweightDecorator.java

License:Open Source License

public void decorate(Object object, IDecoration decoration) {
    Element element = null;// w w  w . jav  a  2 s  .co m
    if (object instanceof Element) {
        element = (Element) object;
    } else if (object instanceof IAdaptable) {
        element = ((IAdaptable) object).getAdapter(Element.class);
    }
    if (element != null && !element.getAppliedStereotypes().isEmpty()) {
        StringBuilder decorator = new StringBuilder();
        for (Iterator iterator = element.getAppliedStereotypes().iterator(); iterator.hasNext();) {
            Stereotype stereotype = (Stereotype) iterator.next();
            EAnnotation extensions = stereotype.getEAnnotation("uml2.extensions");
            boolean suppressed = extensions != null && extensions.getDetails() != null
                    && "true".equals(extensions.getDetails().get("suppressed"));
            if (!suppressed) {
                if (decorator.length() == 0) {
                    decorator.append("<<");
                } else {
                    decorator.append(", ");
                }
                // keyword gets localized name, or lowerCamelCase of Stereotype name
                decorator.append(stereotype.getKeyword());
            }
        }
        if (decorator.length() > 0) {
            decorator.append(">> ");
            decoration.addPrefix(decorator.toString());
        }
    }
}

From source file:org.eclipse.team.internal.ccvs.ui.CVSDecoration.java

License:Open Source License

public void apply(IDecoration decoration) {
    compute();/*www . j  a  v a 2s  . c o  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.DecoratorVariables.java

License:Open Source License

public void decorateText(IDecoration decoration, IVariable[] format, IVariableContentProvider provider) {
    int centerPoint = Arrays.asList(format).indexOf(this.variableSetProvider.getCenterVariable());
    String prefix = ""; //$NON-NLS-1$
    String suffix = ""; //$NON-NLS-1$
    for (int i = 0; i < format.length; i++) {
        if (!format[i].equals(this.variableSetProvider.getCenterVariable())) {
            if (centerPoint != -1 && i < centerPoint) {
                prefix += getValue(format[i], provider);
            } else {
                suffix += getValue(format[i], provider);
            }//from  w w  w .  j  a v a 2  s .co  m
        }
    }
    // trim left/trim right
    int i = 0;
    for (; i < prefix.length() && Character.isWhitespace(prefix.charAt(i)); i++)
        ;
    prefix = prefix.substring(i);
    i = suffix.length() - 1;
    for (; i >= 0 && Character.isWhitespace(suffix.charAt(i)); i--)
        ;
    suffix = suffix.substring(0, i + 1);

    decoration.addPrefix(prefix);
    decoration.addSuffix(suffix);
}

From source file:org.eclipse.team.svn.ui.decorator.SVNLightweightDecorator.java

License:Open Source License

protected void decorateModel(Object element, IDecoration decoration, SynchronizationStateTester tester)
        throws CoreException {
    //TODO how to limit depth according to "Compute deep outgoing state" properties ?
    int stateFlags = tester.getState(element, IDiff.ADD | IDiff.REMOVE | IDiff.CHANGE | IThreeWayDiff.OUTGOING,
            new NullProgressMonitor());
    if (this.indicateRemote) {
        decoration.addOverlay(SVNLightweightDecorator.OVR_VERSIONED);
    }//  w  ww.  j  a  va  2  s.co m
    if ((stateFlags & IThreeWayDiff.OUTGOING) != 0) {
        decoration.addPrefix(this.outgoingChars != null ? (this.outgoingChars + " ") : ""); //$NON-NLS-1$ //$NON-NLS-2$
    }
    tester.elementDecorated(element, new TeamStateDescription(stateFlags));
}

From source file:org.eclipse.ui.tests.decorators.TestLightweightDecoratorContributor.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
 *///from  w w  w  . ja va2s  .  c om
public void decorate(Object element, IDecoration decoration) {
    decoration.addOverlay(getOverlay(element));
    decoration.addPrefix(DECORATOR_PREFIX);
    decoration.addSuffix(DECORATOR_SUFFIX);
}