Java 类org.eclipse.jface.text.TextAttribute 实例源码

项目:eclipse-batch-editor    文件:BatchSourceViewerConfiguration.java   
/**
 * Creates configuration by given adaptable
 * 
 * @param adaptable
 *            must provide {@link ColorManager} and {@link IFile}
 */
public BatchSourceViewerConfiguration(IAdaptable adaptable) {
    IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
    this.fPreferenceStore = new ChainedPreferenceStore(
            new IPreferenceStore[] { getPreferences().getPreferenceStore(), generalTextStore });

    Assert.isNotNull(adaptable, "adaptable may not be null!");
    this.annotationHoover = new BatchEditorAnnotationHoover();

    this.contentAssistant = new ContentAssistant();
    contentAssistProcessor = new BatchEditorSimpleWordContentAssistProcessor();
    contentAssistant.enableColoredLabels(true);

    contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
    for (BatchDocumentIdentifier identifier: BatchDocumentIdentifiers.values()){
        contentAssistant.setContentAssistProcessor(contentAssistProcessor, identifier.getId());
    }

    contentAssistant.addCompletionListener(contentAssistProcessor.getCompletionListener());

    this.colorManager = adaptable.getAdapter(ColorManager.class);
    Assert.isNotNull(colorManager, " adaptable must support color manager");
    this.defaultTextAttribute = new TextAttribute(
            colorManager.getColor(getPreferences().getColor(COLOR_NORMAL_TEXT)));
    this.adaptable=adaptable;
}
项目:eclipse-bash-editor    文件:BashSourceViewerConfiguration.java   
/**
 * Creates configuration by given adaptable
 * 
 * @param adaptable
 *            must provide {@link ColorManager} and {@link IFile}
 */
public BashSourceViewerConfiguration(IAdaptable adaptable) {
    IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
    this.fPreferenceStore = new ChainedPreferenceStore(
            new IPreferenceStore[] { getPreferences().getPreferenceStore(), generalTextStore });

    Assert.isNotNull(adaptable, "adaptable may not be null!");
    this.annotationHoover = new BashEditorAnnotationHoover();

    this.contentAssistant = new ContentAssistant();
    contentAssistProcessor = new BashEditorSimpleWordContentAssistProcessor();
    contentAssistant.enableColoredLabels(true);

    contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
    for (BashDocumentIdentifier identifier: BashDocumentIdentifiers.values()){
        contentAssistant.setContentAssistProcessor(contentAssistProcessor, identifier.getId());
    }

    contentAssistant.addCompletionListener(contentAssistProcessor.getCompletionListener());

    this.colorManager = adaptable.getAdapter(ColorManager.class);
    Assert.isNotNull(colorManager, " adaptable must support color manager");
    this.defaultTextAttribute = new TextAttribute(
            colorManager.getColor(getPreferences().getColor(COLOR_NORMAL_TEXT)));
    this.adaptable=adaptable;
}
项目:Tarski    文件:ModelScanner.java   
public ModelScanner(final ColorManager colorManager) {

    final IToken bracketsToken =
        new Token(new TextAttribute(colorManager.getColor(IValidationColorConstants.BRACKETS)));
    final IToken commToken =
        new Token(new TextAttribute(colorManager.getColor(IValidationColorConstants.COMMENT)));

    final List<IRule> rules = new ArrayList<>();

    rules.add(new WhitespaceRule(new ValidationWhitespaceDetector()));
    rules.add(new BracketsRule(bracketsToken));
    rules.add(new MultiLineRule("/**", "**/", commToken));
    rules.add(new EndOfLineRule("--", commToken));

    final IRule[] result = new IRule[rules.size()];
    rules.toArray(result);
    this.setRules(result);
  }
项目:http4e    文件:XMLTextScanner.java   
public XMLTextScanner( ColorManager colorManager) {

      ESCAPED_CHAR = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.ESCAPED_CHAR)));
      CDATA_START = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
      CDATA_END = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
      CDATA_TEXT = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA_TEXT)));
      IRule[] rules = new IRule[2];

      // Add rule to pick up escaped chars
      // Add rule to pick up start of CDATA section
      rules[0] = new CDataRule(CDATA_START, true);
      // Add a rule to pick up end of CDATA sections
      rules[1] = new CDataRule(CDATA_END, false);
      setRules(rules);

   }
项目:texlipse    文件:TexArgScanner.java   
/**
 * A default constructor.
 * @param manager
 */
public TexArgScanner(ColorManager manager) {
    IToken commentToken = new Token(new TextAttribute(manager
            .getColor(ColorManager.COMMENT),
            null,
            manager.getStyle(ColorManager.COMMENT_STYLE)));

    //Commands are colored in argument color with command styles 
    IToken commandToken = new Token(
            new TextAttribute(
                    manager.getColor(ColorManager.CURLY_BRACKETS),
                    null,
                    manager.getStyle(ColorManager.COMMAND_STYLE)));

    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new EndOfLineRule("%", commentToken, '\\'));
    rules.add(new WhitespaceRule(new WhitespaceDetector()));
    rules.add(new WordRule(new TexWord(), commandToken));

    IRule[] result = new IRule[rules.size()];
    rules.toArray(result);
    setRules(result);
}
项目:texlipse    文件:TexOptArgScanner.java   
/**
 * A default constructor.
 * @param manager
 */
public TexOptArgScanner(ColorManager manager) {
    IToken commentToken = new Token(new TextAttribute(manager
            .getColor(ColorManager.COMMENT),
            null,
            manager.getStyle(ColorManager.COMMENT_STYLE)));

    //Commands are colored in argument color with command styles 
    IToken commandToken = new Token(
            new TextAttribute(
                    manager.getColor(ColorManager.SQUARE_BRACKETS),
                    null,
                    manager.getStyle(ColorManager.COMMAND_STYLE)));

    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new EndOfLineRule("%", commentToken, '\\'));
    rules.add(new WhitespaceRule(new WhitespaceDetector()));
    rules.add(new WordRule(new TexWord(), commandToken));

    IRule[] result = new IRule[rules.size()];
    rules.toArray(result);
    setRules(result);
}
项目:ncl30-eclipse    文件:XMLTextScanner.java   
public XMLTextScanner(ColorManager colorManager) {

        ESCAPED_CHAR = new Token(new TextAttribute(colorManager
                .getColor(IXMLColorConstants.ESCAPED_CHAR)));
        CDATA_START = new Token(new TextAttribute(colorManager
                .getColor(IXMLColorConstants.CDATA)));
        CDATA_END = new Token(new TextAttribute(colorManager
                .getColor(IXMLColorConstants.CDATA)));
        CDATA_TEXT = new Token(new TextAttribute(colorManager
                .getColor(IXMLColorConstants.CDATA_TEXT)));
        IRule[] rules = new IRule[2];

        // Add rule to pick up escaped chars
        // Add rule to pick up start of CDATA section
        //rules[0] = new CDataRule(CDATA_START, true);
        // Add a rule to pick up end of CDATA sections
        //rules[1] = new CDataRule(CDATA_END, false);
        setRules(rules);

    }
项目:ncl30-eclipse    文件:XMLTagScanner.java   
public XMLTagScanner(ColorManager manager) {
    IToken string = new Token(new TextAttribute(manager
            .getColor(IXMLColorConstants.STRING)));

    IToken attrValue = new Token(XML_ATTR_VALUE);

    IRule[] rules = new IRule[3];

    // Add rule for double quotes
    rules[0] = new SingleLineRule("\"", "\"", string, '\\');
    // Add a rule for single quotes
    rules[1] = new SingleLineRule("'", "'", string, '\\');
    // Add generic whitespace rule.
    rules[2] = new WhitespaceRule(new NCLWhitespaceDetector());

    setRules(rules);
}
项目:fluentmark    文件:AbstractBufferedRuleBasedScanner.java   
private void adaptToColorChange(Token token, PropertyChangeEvent event) {
    RGB rgb = null;

    Object value = event.getNewValue();
    if (value instanceof RGB) {
        rgb = (RGB) value;
    } else if (value instanceof String) {
        rgb = StringConverter.asRGB((String) value);
    }

    if (rgb != null) {

        String property = event.getProperty();
        Color color = colorMgr.getColor(property);
        if (!rgb.equals(color.getRGB())) {
            colorMgr.setValue(property, rgb);
            color = colorMgr.getColor(property);
        }

        Object data = token.getData();
        if (data instanceof TextAttribute) {
            TextAttribute oldAttr = (TextAttribute) data;
            token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
        }
    }
}
项目:fluentmark    文件:AbstractBufferedRuleBasedScanner.java   
private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) {
    boolean eventValue = false;
    Object value = event.getNewValue();
    if (value instanceof Boolean)
        eventValue = ((Boolean) value).booleanValue();
    else if (IPreferenceStore.TRUE.equals(value)) eventValue = true;

    Object data = token.getData();
    if (data instanceof TextAttribute) {
        TextAttribute oldAttr = (TextAttribute) data;
        boolean activeValue = (oldAttr.getStyle() & styleAttribute) == styleAttribute;
        if (activeValue != eventValue)
            token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(),
                    eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
    }
}
项目:bts    文件:TextAttributeProvider.java   
public TextAttribute getMergedAttributes(String[] ids) {
    if (ids.length < 2)
        throw new IllegalStateException();
    String mergedIds = getMergedIds(ids);
    TextAttribute result = getAttribute(mergedIds);
    if (result == null) {
        for(String id: ids) {
            result = merge(result, getAttribute(id));
        }
        if (result != null)
            attributes.put(mergedIds, result);
        else
            attributes.remove(mergedIds);
    }
    return result;
}
项目:bts    文件:TextAttributeProvider.java   
private TextAttribute merge(TextAttribute first, TextAttribute second) {
    if (first == null)
        return second;
    if (second == null)
        return first;
    int style = first.getStyle() | second.getStyle();
    Color fgColor = second.getForeground();
    if (fgColor == null)
        fgColor = first.getForeground();
    Color bgColor = second.getBackground();
    if (bgColor == null)
        bgColor = first.getBackground();
    Font font = second.getFont();
    if (font == null)
        font = first.getFont();
    return new TextAttribute(fgColor, bgColor, style, font);
}
项目:LogViewer    文件:DamageRepairer.java   
public void createPresentation(TextPresentation presentation, ITypedRegion region) {
    int start= region.getOffset();
    int length= 0;
    boolean firstToken= true;
    TextAttribute attribute = getTokenTextAttribute(Token.UNDEFINED);

    scanner.setRange(document,start,region.getLength());

    while (true) {
        IToken resultToken = scanner.nextToken();
        if (resultToken.isEOF()) {
            break;
        }
        if(resultToken.equals(Token.UNDEFINED)) {
            continue;
        }
        if (!firstToken) {
            addRange(presentation,start,length,attribute,true);
        }
        firstToken = false;
        attribute = getTokenTextAttribute(resultToken);
        start = scanner.getTokenOffset();
        length = scanner.getTokenLength();
    }
    addRange(presentation,start,length,attribute,true);
}
项目:LogViewer    文件:DamageRepairer.java   
/**
 * Adds style information to the given text presentation.
 *
 * @param presentation the text presentation to be extended
 * @param offset the offset of the range to be styled
 * @param length the length of the range to be styled
 * @param attr the attribute describing the style of the range to be styled
 * @param wholeLine the boolean switch to declare that the whole line should be colored
 */
private void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr, boolean wholeLine) {
    if (attr != null) {
        int style= attr.getStyle();
        int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
        if(wholeLine) {
            try {
                int line = document.getLineOfOffset(offset);
                int start = document.getLineOffset(line);
                length = document.getLineLength(line);
                offset = start;
            } catch (BadLocationException e) {
            }
        }
        StyleRange styleRange = new StyleRange(offset,length,attr.getForeground(),attr.getBackground(),fontStyle);
        styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
        styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
        presentation.addStyleRange(styleRange);
    }
}
项目:umple    文件:UmpleTagScanner.java   
public UmpleTagScanner(ColorManager manager) {
    IToken string =
        new Token(
            new TextAttribute(manager.getColor(IUmpleColorConstants.STRING)));

    IRule[] rules = new IRule[3];

    // Add rule for double quotes
    rules[0] = new SingleLineRule("\"", "\"", string, '\\');
    // Add a rule for single quotes
    rules[1] = new SingleLineRule("'", "'", string, '\\');
    // Add generic whitespace rule.
    rules[2] = new WhitespaceRule(new UmpleWhitespaceDetector());

    setRules(rules);
}
项目:APICloud-Studio    文件:ConsoleThemer.java   
/**
 * applyTheme
 * 
 * @param name
 * @param stream
 * @param defaultColor
 * @return
 */
private void applyTheme(String name, IOConsoleOutputStream stream, Color defaultColor)
{
    Theme theme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme();
    Color color = defaultColor;
    int style = SWT.NONE;

    // grab theme values, if they exist
    if (theme.hasEntry(name))
    {
        TextAttribute attr = theme.getTextAttribute(name);

        color = theme.getForeground(name);
        style = attr.getStyle();
    }

    // apply new values
    stream.setColor(color);
    stream.setFontStyle(style);
}
项目:velocity-edit    文件:VelocityColorProvider.java   
/**
 * DOCUMENT ME!
 * 
 * @param prefKey
 *            DOCUMENT ME!
 * 
 * @return DOCUMENT ME!
 */
public IToken getToken(String prefKey)
{
    IPreferenceStore store = Plugin.getDefault().getPreferenceStore();
    Token token = (Token) tokenTable.get(prefKey);
    boolean bold = store.getBoolean(prefKey + IPreferencesConstants.EDITOR_BOLD_SUFFIX);
    if (token == null)
    {
        if (bold)
        {
            token = new Token(new TextAttribute(getColor(prefKey), null, SWT.BOLD));
        } else
        {
            token = new Token(new TextAttribute(getColor(prefKey)));
        }
        tokenTable.put(prefKey, token);
    }
    return token;
}
项目:velocity-edit    文件:VelocityColorProvider.java   
/**
 * DOCUMENT ME!
 * 
 * @param prefKey
 *            DOCUMENT ME!
 * @param textonly
 *            DOCUMENT ME!
 * 
 * @return DOCUMENT ME!
 */
public IToken getToken(String prefKey, boolean textonly)
{
    Token token = (Token) tokenTable.get(prefKey);
    if (token == null)
    {
        if (!textonly)
        {
            token = new Token(new TextAttribute(getColor(prefKey)));
        } else
        {
            token = new Token(prefKey);
        }
        tokenTable.put(prefKey, token);
    }
    return token;
}
项目:APICloud-Studio    文件:ThemeGetTextAttribute.java   
public ThemeGetTextAttribute(Theme theme)
{
    this.theme = theme;
    this.colorManager = theme.getColorManager();
    this.defaultFG = theme.getForeground();
    this.defaultBG = theme.getBackground();
    this.cacheGetTextAttribute = new HashMap<String, TextAttribute>();
    this.cacheDelayedGetTextAttribute = new HashMap<String, DelayedTextAttribute>();

    List<ThemeRule> tokens = theme.getTokens();
    selectors = new ArrayList<IScopeSelector>(tokens.size());

    for (ThemeRule rule : tokens)
    {
        if (rule.isSeparator())
        {
            continue;
        }
        selectors.add(rule.getScopeSelector());
    }
}
项目:velocity-edit    文件:XMLTagScanner.java   
public XMLTagScanner(ColorManager manager) {
    IToken string =
        new Token(
            new TextAttribute(manager.getColor(ColorManager.COLOR_STRING)));

    IRule[] rules = new IRule[3];

    // Add rule for double quotes
    rules[0] = new SingleLineRule("\"", "\"", string, '\\');
    // Add a rule for single quotes
    rules[1] = new SingleLineRule("'", "'", string, '\\');
    // Add generic whitespace rule.
    rules[2] = new WhitespaceRule(new WhitespaceDetector());

    setRules(rules);
}
项目:KaiZen-OpenAPI-Editor    文件:JsonScanner.java   
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;
}
项目:APICloud-Studio    文件:InvasiveThemeHijacker.java   
protected void setSemanticToken(IEclipsePreferences prefs, Theme theme, String ourTokenType, String jdtToken,
        boolean revertToDefaults)
{
    String prefix = "semanticHighlighting."; //$NON-NLS-1$
    jdtToken = prefix + jdtToken;
    if (revertToDefaults)
    {
        prefs.remove(jdtToken + ".color"); //$NON-NLS-1$
        prefs.remove(jdtToken + ".bold"); //$NON-NLS-1$
        prefs.remove(jdtToken + ".italic"); //$NON-NLS-1$
        prefs.remove(jdtToken + ".underline"); //$NON-NLS-1$
        prefs.remove(jdtToken + ".strikethrough"); //$NON-NLS-1$
        prefs.remove(jdtToken + ".enabled"); //$NON-NLS-1$
    }
    else
    {
        TextAttribute attr = theme.getTextAttribute(ourTokenType);
        prefs.put(jdtToken + ".color", StringConverter.asString(attr.getForeground().getRGB())); //$NON-NLS-1$
        prefs.putBoolean(jdtToken + ".bold", (attr.getStyle() & SWT.BOLD) != 0); //$NON-NLS-1$
        prefs.putBoolean(jdtToken + ".italic", (attr.getStyle() & SWT.ITALIC) != 0); //$NON-NLS-1$
        prefs.putBoolean(jdtToken + ".underline", (attr.getStyle() & TextAttribute.UNDERLINE) != 0); //$NON-NLS-1$
        prefs.putBoolean(jdtToken + ".strikethrough", (attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0); //$NON-NLS-1$
        prefs.putBoolean(jdtToken + ".enabled", true); //$NON-NLS-1$
    }
}
项目:BYONDclipse    文件:DMScanner.java   
public DMScanner(final ColorManager manager)
{
    final IToken dmPreprocessor                     = new Token(new TextAttribute(manager.getColor(IDMColorConstants.DM_PREPROCESSOR)));
    final IToken keyword                            = new Token(new TextAttribute(manager.getColor(IDMColorConstants.KEYWORD)));
    final IToken defaultToken                       = new Token(new TextAttribute(manager.getColor(IDMColorConstants.DEFAULT)));
    final IToken numberToken                        = new Token(new TextAttribute(manager.getColor(IDMColorConstants.NUMBER)));

    final IRule[] rules                             = new IRule[4];
    //Add rule for processing instructions
    rules[0]                                        = new EndOfLineRule("#", dmPreprocessor);
    // Add generic whitespace rule.
    rules[1]                                        = new WhitespaceRule(new DMWhitespaceDetector());
    // Add keyword detection
    rules[2]                                        = new DMKeywordRule(keyword, defaultToken, false);
    // Add number detection
    rules[3]                                        = new FloatRule(numberToken);

    this.setRules(rules);
}
项目:PDFReporter-Studio    文件:XMLTextScanner.java   
public XMLTextScanner(ColorManager colorManager) {

        ESCAPED_CHAR = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.ESCAPED_CHAR)));
        CDATA_START = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
        CDATA_END = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA)));
        CDATA_TEXT = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA_TEXT)));
        IRule[] rules = new IRule[2];

        // Add rule to pick up escaped chars
        // Add rule to pick up start of CDATA section
        rules[0] = new CDataRule(CDATA_START, true);
        // Add a rule to pick up end of CDATA sections
        rules[1] = new CDataRule(CDATA_END, false);
        setRules(rules);

    }
项目:PDFReporter-Studio    文件:XMLTagScanner.java   
public XMLTagScanner(ColorManager manager) {
    IToken string =
        new Token(
            new TextAttribute(manager.getColor(IXMLColorConstants.STRING)));

    IRule[] rules = new IRule[3];

    // Add rule for double quotes
    rules[0] = new SingleLineRule("\"", "\"", string, '\\');
    // Add a rule for single quotes
    rules[1] = new SingleLineRule("'", "'", string, '\\');
    // Add generic whitespace rule.
    rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());

    setRules(rules);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangC.java   
public void attachWordRule(List<IRule> rules) {
IToken tokenDefault = new Token(new TextAttribute(KSC_DEFAULT));
IToken tokenKeyword = new Token(new TextAttribute(KSC_KEYWORD));
IToken tokenNumber = new Token(new TextAttribute(KSC_NUMBER));
IToken tokenOperator = new Token(new TextAttribute(KSC_OPERATOR));

WordRule wordRule = new WordRule(new KernelSyntaxWordDetector(), tokenDefault, true);
for (String keyword : KSL_KEYWORD) {
    wordRule.addWord(keyword, tokenKeyword);
}
rules.add(wordRule);

KernelSyntaxNumberRule numberRule = new KernelSyntaxNumberRule(tokenNumber);
rules.add(numberRule);

KernelSyntaxOperatorRule opRule = new KernelSyntaxOperatorRule(tokenOperator);
rules.add(opRule);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangShell.java   
public void attachDamagerRepairer(PresentationReconciler pr) {
    KernelSyntaxDamagerRepairer ndr;

    ndr = new KernelSyntaxDamagerRepairer(new TextAttribute(KSC_COMMENT));
    pr.setDamager(ndr, IDocument.DEFAULT_CONTENT_TYPE);
    pr.setRepairer(ndr, IDocument.DEFAULT_CONTENT_TYPE);

    ndr = new KernelSyntaxDamagerRepairer(new TextAttribute(KSC_COMMENT));
    pr.setDamager(ndr, KSP_COMMENT);
    pr.setRepairer(ndr, KSP_COMMENT);

    ndr = new KernelSyntaxDamagerRepairer(new TextAttribute(KSC_STRING));
    pr.setDamager(ndr, KSP_STRING);
    pr.setRepairer(ndr, KSP_STRING);

    ndr = new KernelSyntaxDamagerRepairer(new TextAttribute(KSC_METADATA));
    pr.setDamager(ndr, KSP_METADATA);
    pr.setRepairer(ndr, KSP_METADATA);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangPython.java   
public void attachDamagerRepairer(PresentationReconciler pr) {
    System.out.println("pyth");

    KernelSyntaxDamagerRepairer ndr;

    ndr = new KernelSyntaxDamagerRepairer(new TextAttribute(KSC_COMMENT));
    pr.setDamager(ndr, KSP_COMMENT);
    pr.setRepairer(ndr, KSP_COMMENT);

    ndr = new KernelSyntaxDamagerRepairer(new TextAttribute(KSC_STRING));
    pr.setDamager(ndr, KSP_STRING);
    pr.setRepairer(ndr, KSP_STRING);

    ndr = new KernelSyntaxDamagerRepairer(new TextAttribute(KSC_METADATA));
    pr.setDamager(ndr, KSP_METADATA);
    pr.setRepairer(ndr, KSP_METADATA);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLangPython.java   
public void attachWordRule(List<IRule> rules) {
IToken tokenDefault = new Token(new TextAttribute(KSC_DEFAULT));
IToken tokenKeyword = new Token(new TextAttribute(KSC_KEYWORD));
IToken tokenNumber = new Token(new TextAttribute(KSC_NUMBER));
IToken tokenOperator = new Token(new TextAttribute(KSC_OPERATOR));

WordRule wordRule = new WordRule(new KernelSyntaxWordDetector(), tokenDefault, true);
for (String keyword : KSL_KEYWORD) {
    wordRule.addWord(keyword, tokenKeyword);
}
rules.add(wordRule);

KernelSyntaxNumberRule numberRule = new KernelSyntaxNumberRule(tokenNumber);
rules.add(numberRule);

KernelSyntaxOperatorRule opRule = new KernelSyntaxOperatorRule(tokenOperator);
rules.add(opRule);
}
项目:eclipse-kernelsyntax    文件:KernelSyntaxLang.java   
public void attachWordRule(List<IRule> rules) {
IToken tokenDefault = new Token(new TextAttribute(KSC_DEFAULT));
IToken tokenKeyword = new Token(new TextAttribute(KSC_KEYWORD));
IToken tokenNumber = new Token(new TextAttribute(KSC_NUMBER));
IToken tokenOperator = new Token(new TextAttribute(KSC_OPERATOR));

WordRule wordRule = new WordRule(new KernelSyntaxWordDetector(), tokenDefault, true);
for (String keyword : KSL_KEYWORD) {
    wordRule.addWord(keyword, tokenKeyword);
}
rules.add(wordRule);

KernelSyntaxNumberRule numberRule = new KernelSyntaxNumberRule(tokenNumber);
rules.add(numberRule);

KernelSyntaxOperatorRule opRule = new KernelSyntaxOperatorRule(tokenOperator);
rules.add(opRule);
}
项目:APICloud-Studio    文件:InvasiveThemeHijacker.java   
protected void setToken(IEclipsePreferences prefs, Theme theme, String ourTokenType, String jdtToken,
        boolean revertToDefaults)
{
    if (revertToDefaults)
    {
        prefs.remove(jdtToken);
        prefs.remove(jdtToken + "_bold"); //$NON-NLS-1$
        prefs.remove(jdtToken + "_italic"); //$NON-NLS-1$
        prefs.remove(jdtToken + "_underline"); //$NON-NLS-1$
        prefs.remove(jdtToken + "_strikethrough"); //$NON-NLS-1$
    }
    else
    {
        TextAttribute attr = theme.getTextAttribute(ourTokenType);
        prefs.put(jdtToken, StringConverter.asString(attr.getForeground().getRGB()));
        prefs.putBoolean(jdtToken + "_bold", (attr.getStyle() & SWT.BOLD) != 0); //$NON-NLS-1$
        prefs.putBoolean(jdtToken + "_italic", (attr.getStyle() & SWT.ITALIC) != 0); //$NON-NLS-1$
        prefs.putBoolean(jdtToken + "_underline", (attr.getStyle() & TextAttribute.UNDERLINE) != 0); //$NON-NLS-1$
        prefs.putBoolean(jdtToken + "_strikethrough", (attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0); //$NON-NLS-1$
    }
}
项目:eclipse-batch-editor    文件:BatchSourceViewerConfiguration.java   
private void addPresentation(PresentationReconciler reconciler, String id, RGB rgb, int style) {
    TextAttribute textAttribute = new TextAttribute(colorManager.getColor(rgb),
            defaultTextAttribute.getBackground(), style);
    PresentationSupport presentation = new PresentationSupport(textAttribute);
    reconciler.setDamager(presentation, id);
    reconciler.setRepairer(presentation, id);
}
项目:convertigo-eclipse    文件:XMLConfiguration.java   
protected XMLScanner getXMLScanner() {
    if (scanner == null) {
        scanner = new XMLScanner(colorManager);
        scanner.setDefaultReturnToken(new Token(new TextAttribute(
                colorManager.getColor(IXMLColorConstants.DEFAULT))));
    }
    return scanner;
}
项目:convertigo-eclipse    文件:XMLConfiguration.java   
protected XMLTagScanner getXMLTagScanner() {
    if (tagScanner == null) {
        tagScanner = new XMLTagScanner(colorManager);
        tagScanner.setDefaultReturnToken(new Token(new TextAttribute(
                colorManager.getColor(IXMLColorConstants.TAG))));
    }
    return tagScanner;
}
项目:convertigo-eclipse    文件:NonRuleBasedDamagerRepairer.java   
/**
 * Adds style information to the given text presentation.
 *
 * @param presentation the text presentation to be extended
 * @param offset the offset of the range to be styled
 * @param length the length of the range to be styled
 * @param attr the attribute describing the style of the range to be styled
 */
protected void addRange(
    TextPresentation presentation,
    int offset,
    int length,
    TextAttribute attr) {
    if (attr != null)
        presentation.addStyleRange(
            new StyleRange(
                offset,
                length,
                attr.getForeground(),
                attr.getBackground(),
                attr.getStyle()));
}
项目:convertigo-eclipse    文件:XMLTagScanner.java   
public XMLTagScanner(ColorManager manager) {
    IToken string = new Token(new TextAttribute(manager.getColor(IXMLColorConstants.STRING)));

    IRule[] rules = new IRule[3];

    // Add rule for double quotes
    rules[0] = new SingleLineRule("\"", "\"", string, '\\');
    // Add a rule for single quotes
    rules[1] = new SingleLineRule("'", "'", string, '\\');
    // Add generic whitespace rule.
    rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());

    setRules(rules);
}
项目:eclipse-bash-editor    文件:BashSourceViewerConfiguration.java   
private void addPresentation(PresentationReconciler reconciler, String id, RGB rgb, int style) {
    TextAttribute textAttribute = new TextAttribute(colorManager.getColor(rgb),
            defaultTextAttribute.getBackground(), style);
    PresentationSupport presentation = new PresentationSupport(textAttribute);
    reconciler.setDamager(presentation, id);
    reconciler.setRepairer(presentation, id);
}
项目:pgcodekeeper    文件:SQLEditorSourceViewerConfiguration.java   
private TextAttribute getTextAttribute(IPreferenceStore prefs, SQLEditorStatementTypes type) {
    SQLEditorSyntaxModel sm = new SQLEditorSyntaxModel(type, prefs).load();
    int style = 0 | (sm.isBold() ? SWT.BOLD : 0)
            | (sm.isItalic() ? SWT.ITALIC: 0)
            | (sm.isUnderline() ? SWT.UNDERLINE_SINGLE: 0)
            | (sm.isUnderline() ? TextAttribute.UNDERLINE: 0)
            | (sm.isStrikethrough() ? TextAttribute.STRIKETHROUGH: 0);
    return new TextAttribute(fSharedColors.getColor(sm.getColor()), null, style);
}
项目:vertigo-chroma-kspplugin    文件:KspCommentScanner.java   
private IRule[] extractRules() {
    IToken comment = new Token(new TextAttribute(new Color(Display.getCurrent(), commentColor), null, SWT.NORMAL));
    return new IRule[] {
    /* Commentaire multi-ligne */
    new PatternRule("/*", "*/", comment, NO_ESCAPE_CHAR, false),
    /* Commentaire à la fin d'une ligne */
    new EndOfLineRule("//", comment) };
}
项目:Tarski    文件:RelBoundScanner.java   
public RelBoundScanner(final ColorManager manager) {
  final IToken token = new Token(new TextAttribute(manager.getColor(IColorConstants.REL_BOUND)));
  final IToken bracketsToken =
      new Token(new TextAttribute(manager.getColor(IColorConstants.REL_BOUND_BRACKETS)));
  final IToken commentToken =
      new Token(new TextAttribute(manager.getColor(IColorConstants.COMMENT)));

  final List<IRule> rules = new ArrayList<IRule>();

  rules.add(new MultiLineRule("/**", "**/", commentToken));
  rules.add(new EndOfLineRule("--", commentToken));
  // rules.add(new EndOfLineRule("//", commentToken));
  rules.add(new BracketsRule(bracketsToken));

  rules.add(new WhitespaceRule(new IWhitespaceDetector() {

    @Override
    public boolean isWhitespace(final char c) {
      return Character.isWhitespace(c);
    }
  }));
  this.setDefaultReturnToken(token);

  final IRule[] result = new IRule[rules.size()];
  rules.toArray(result);
  this.setRules(result);
}