use of org.eclipse.jface.text.TextAttribute in project cubrid-manager by CUBRID.
the class XMLConfiguration method getXMLTagScanner.
/**
* Retrieves the XML Tag Scanner.
*
* @return tagScanner
*/
protected RuleBasedScanner getXMLTagScanner() {
if (tagScanner == null) {
tagScanner = new XMLTagDamageRepairScanner(colorManager);
tagScanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.ATTR))));
}
return tagScanner;
}
use of org.eclipse.jface.text.TextAttribute in project cubrid-manager by CUBRID.
the class XMLConfiguration method getPresentationReconciler.
/**
* Retrieves the Presentation Reconciler
*
* @param sourceViewer ISourceViewer
* @return object of IPresentationReconciler
*/
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = new PresentationReconciler();
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getXMLTagScanner());
reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
dr = new DefaultDamagerRepairer(getXMLScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(IXMLColorConstants.XML_COMMENT)));
reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
return reconciler;
}
use of org.eclipse.jface.text.TextAttribute in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonScanner method tokenAttribute.
private TextAttribute tokenAttribute(String colorPrefs, String boldPrefs, String italicPrefs, String underlinePrefs) {
int style = SWT.NORMAL;
boolean isBold = store.getBoolean(boldPrefs);
if (isBold) {
style = style | SWT.BOLD;
}
boolean isItalic = store.getBoolean(italicPrefs);
if (isItalic) {
style = style | SWT.ITALIC;
}
boolean isUnderline = store.getBoolean(underlinePrefs);
if (isUnderline) {
style = style | TextAttribute.UNDERLINE;
}
RGB color = PreferenceConverter.getColor(store, colorPrefs);
TextAttribute attr = new TextAttribute(colorManager.getColor(color), null, style);
return attr;
}
use of org.eclipse.jface.text.TextAttribute in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonScanner method init.
protected void init() {
TextAttribute keyAttr = tokenAttribute(PreferenceConstants.COLOR_KEY, PreferenceConstants.BOLD_KEY, PreferenceConstants.ITALIC_KEY, PreferenceConstants.UNDERLINE_KEY);
IToken keyToken = new YAMLToken(keyAttr, YAMLToken.KEY);
TextAttribute scalarAttr = tokenAttribute(PreferenceConstants.COLOR_SCALAR, PreferenceConstants.BOLD_SCALAR, PreferenceConstants.ITALIC_SCALAR, PreferenceConstants.UNDERLINE_SCALAR);
IToken scalarToken = new YAMLToken(scalarAttr, YAMLToken.SCALAR);
TextAttribute commentAttr = tokenAttribute(PreferenceConstants.COLOR_COMMENT, PreferenceConstants.BOLD_COMMENT, PreferenceConstants.ITALIC_COMMENT, PreferenceConstants.UNDERLINE_COMMENT);
IToken commentToken = new YAMLToken(commentAttr, YAMLToken.COMMENT);
TextAttribute documentAttr = tokenAttribute(PreferenceConstants.COLOR_DOCUMENT, PreferenceConstants.BOLD_DOCUMENT, PreferenceConstants.ITALIC_DOCUMENT, PreferenceConstants.UNDERLINE_DOCUMENT);
IToken documentStartToken = new YAMLToken(documentAttr, YAMLToken.DOCUMENT_START);
IToken documentEndToken = new YAMLToken(documentAttr, YAMLToken.DOCUMENT_END);
TextAttribute anchorAttr = tokenAttribute(PreferenceConstants.COLOR_ANCHOR, PreferenceConstants.BOLD_ANCHOR, PreferenceConstants.ITALIC_ANCHOR, PreferenceConstants.UNDERLINE_ANCHOR);
IToken anchorToken = new YAMLToken(anchorAttr, YAMLToken.ANCHOR);
TextAttribute aliasAttr = tokenAttribute(PreferenceConstants.COLOR_ALIAS, PreferenceConstants.BOLD_ALIAS, PreferenceConstants.ITALIC_ALIAS, PreferenceConstants.UNDERLINE_ALIAS);
IToken aliasToken = new YAMLToken(aliasAttr, YAMLToken.ALIAS);
IToken indicatorCharToken = new YAMLToken(new TextAttribute(null), YAMLToken.INDICATOR_CHARACTER);
TextAttribute tagAttr = tokenAttribute(PreferenceConstants.COLOR_TAG_PROPERTY, PreferenceConstants.BOLD_TAG_PROPERTY, PreferenceConstants.ITALIC_TAG_PROPERTY, PreferenceConstants.UNDERLINE_TAG_PROPERTY);
IToken tagPropToken = new YAMLToken(tagAttr, YAMLToken.TAG_PROPERTY);
TextAttribute constantAttr = tokenAttribute(PreferenceConstants.COLOR_CONSTANT, PreferenceConstants.BOLD_CONSTANT, PreferenceConstants.ITALIC_CONSTANT, PreferenceConstants.UNDERLINE_CONSTANT);
IToken predefinedValToken = new YAMLToken(constantAttr, YAMLToken.CONSTANT);
IToken whitespaceToken = new YAMLToken(new TextAttribute(null), YAMLToken.WHITESPACE);
IToken directiveToken = new YAMLToken(new TextAttribute(null), YAMLToken.DIRECTIVE);
ArrayList<IRule> rules = new ArrayList<IRule>();
rules.add(new KeyRule(keyToken));
rules.add(new SingleQuotedKeyRule(keyToken));
rules.add(new DoubleQuotedKeyRule(keyToken));
rules.add(new MultiLineRule("\"", "\"", scalarToken, '\\'));
rules.add(new MultiLineRule("'", "'", scalarToken));
rules.add(new EndOfLineRule("#", commentToken));
rules.add(new EndOfLineRule("%TAG", directiveToken));
rules.add(new EndOfLineRule("%YAML", directiveToken));
rules.add(new DocumentStartAndEndRule("---", documentStartToken));
rules.add(new DocumentStartAndEndRule("...", documentEndToken));
rules.add(new IndicatorCharacterRule(indicatorCharToken));
rules.add(new WhitespaceRule(whitespaceToken));
rules.add(new WordPatternRule(new AnchorWordDetector(), "&", "", anchorToken));
rules.add(new WordPatternRule(new AnchorWordDetector(), "*", "", aliasToken));
rules.add(new WordPatternRule(new TagWordDetector(), "!", "", tagPropToken));
rules.add(new PredefinedValueRule(predefinedValToken));
rules.add(new ScalarRule(scalarToken));
IRule[] rulesArray = new IRule[rules.size()];
rules.toArray(rulesArray);
setRules(rulesArray);
setDefaultReturnToken(scalarToken);
}
use of org.eclipse.jface.text.TextAttribute in project eclipse.platform.text by eclipse.
the class JavaSourceViewerConfiguration method getPresentationReconciler.
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
JavaColorProvider provider = JavaEditorExamplePlugin.getDefault().getJavaColorProvider();
PresentationReconciler reconciler = new PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(JavaEditorExamplePlugin.getDefault().getJavaCodeScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
dr = new DefaultDamagerRepairer(JavaEditorExamplePlugin.getDefault().getJavaDocScanner());
reconciler.setDamager(dr, JavaPartitionScanner.JAVA_DOC);
reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_DOC);
dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(JavaColorProvider.MULTI_LINE_COMMENT))));
reconciler.setDamager(dr, JavaPartitionScanner.JAVA_MULTILINE_COMMENT);
reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_MULTILINE_COMMENT);
return reconciler;
}
Aggregations