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;
}
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));
}
}
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;
}
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);
}
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;
}
Aggregations