Search in sources :

Example 96 with StyledString

use of org.eclipse.jface.viewers.StyledString in project xtext-eclipse by eclipse.

the class XtextOutlineTreeProvider method _text.

protected Object _text(AbstractRule rule) {
    StyledString ruleText = null;
    if (!calledRules.isEmpty() && !calledRules.contains(rule))
        ruleText = new StyledString(safeName(rule.getName()), StyledString.createColorRegistryStyler("128,128,128", null));
    else if (GrammarUtil.isDatatypeRule(rule))
        ruleText = new StyledString(safeName(rule.getName()), StyledString.createColorRegistryStyler("0,0,192", null));
    else
        ruleText = new StyledString(safeName(rule.getName()));
    return ruleText;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString)

Example 97 with StyledString

use of org.eclipse.jface.viewers.StyledString in project xtext-eclipse by eclipse.

the class XtextOutlineTreeProvider method createRuleNode.

protected void createRuleNode(IOutlineNode parentNode, AbstractRule rule, boolean isShowGrammar, boolean isLocalRule) {
    StyledString text = (StyledString) textDispatcher.invoke(rule);
    if (isShowGrammar) {
        EObject grammar = rule.eContainer();
        if (grammar instanceof Grammar)
            text.append(new StyledString(" (" + ((Grammar) grammar).getName() + ")", StyledString.COUNTER_STYLER));
    }
    Image image = imageDispatcher.invoke(rule);
    RuleNode ruleNode = new RuleNode(rule, parentNode, image, text, isLeafDispatcher.invoke(rule));
    ruleNode.setFullText(new StyledString().append(text).append(getReturnTypeText(rule)));
    if (isLocalRule) {
        ICompositeNode parserNode = NodeModelUtils.getNode(rule);
        if (parserNode != null)
            ruleNode.setTextRegion(parserNode.getTextRegion());
        ruleNode.setShortTextRegion(locationInFileProvider.getSignificantTextRegion(rule));
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) StyledString(org.eclipse.jface.viewers.StyledString) Grammar(org.eclipse.xtext.Grammar) Image(org.eclipse.swt.graphics.Image)

Example 98 with StyledString

use of org.eclipse.jface.viewers.StyledString in project xtext-eclipse by eclipse.

the class XtextOutlineTreeProvider method getReturnTypeText.

protected StyledString getReturnTypeText(AbstractRule rule) {
    StringBuilder typeName = new StringBuilder(NAME_TYPE_SEPARATOR);
    if (rule.getType() != null && rule.getType().getClassifier() != null && rule.getType().getMetamodel() != null) {
        String alias = rule.getType().getMetamodel().getAlias();
        if (alias != null) {
            typeName.append(alias);
            typeName.append(ALIAS_TYPE_SEPARATOR);
        }
        typeName.append(safeName(rule.getType().getClassifier().getName()));
    } else {
        typeName.append(safeName(rule.getName()));
    }
    StyledString styledType = new StyledString(typeName.toString(), StyledString.DECORATIONS_STYLER);
    return styledType;
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 99 with StyledString

use of org.eclipse.jface.viewers.StyledString in project che by eclipse.

the class JavaElementLabels method getStyledElementLabel.

/**
	 * Returns the styled label for a Java element with the flags as defined by this class.
	 *
	 * @param element the element to render
	 * @param flags the rendering flags
	 * @return the label of the Java element
	 *
	 * @since 3.4
	 */
public static StyledString getStyledElementLabel(IJavaElement element, long flags) {
    StyledString result = new StyledString();
    getElementLabel(element, flags, result);
    return Strings.markJavaElementLabelLTR(result);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString)

Example 100 with StyledString

use of org.eclipse.jface.viewers.StyledString in project che by eclipse.

the class CompletionProposalCollector method createAnnotationAttributeReferenceProposal.

private IJavaCompletionProposal createAnnotationAttributeReferenceProposal(CompletionProposal proposal) {
    StyledString displayString = fLabelProvider.createLabelWithTypeAndDeclaration(proposal);
    ImageDescriptor descriptor = fLabelProvider.createMethodImageDescriptor(proposal);
    String completion = String.valueOf(proposal.getCompletion());
    JavaCompletionProposal javaProposal = new JavaCompletionProposal(completion, proposal.getReplaceStart(), getLength(proposal), getImage(descriptor), displayString, computeRelevance(proposal));
    if (fJavaProject != null)
        javaProposal.setProposalInfo(new AnnotationAtttributeProposalInfo(fJavaProject, proposal));
    return javaProposal;
}
Also used : AnnotationAtttributeProposalInfo(org.eclipse.jdt.internal.ui.text.java.AnnotationAtttributeProposalInfo) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) JavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal) LazyJavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal)

Aggregations

StyledString (org.eclipse.jface.viewers.StyledString)204 Image (org.eclipse.swt.graphics.Image)22 ViewerCell (org.eclipse.jface.viewers.ViewerCell)10 ConfigurableCompletionProposal (org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal)10 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)9 StyledCellLabelProvider (org.eclipse.jface.viewers.StyledCellLabelProvider)9 Composite (org.eclipse.swt.widgets.Composite)9 JavaCompletionProposal (org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal)8 LazyJavaCompletionProposal (org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal)8 GridData (org.eclipse.swt.layout.GridData)8 Entry (java.util.Map.Entry)7 Styler (org.eclipse.jface.viewers.StyledString.Styler)7 TableViewer (org.eclipse.jface.viewers.TableViewer)7 Label (org.eclipse.swt.widgets.Label)7 Table (org.eclipse.swt.widgets.Table)7 Test (org.junit.Test)7 EObject (org.eclipse.emf.ecore.EObject)6 StyleRange (org.eclipse.swt.custom.StyleRange)5 ParserRule (org.eclipse.xtext.ParserRule)5 IOException (java.io.IOException)4