Examples of LToken


Examples of cbg.editor.rules.LToken

 
  private void adaptToColorChange(PropertyChangeEvent event) {
    RGB rgb= null;
    Token token = (Token) tokenMap.get(event.getProperty());
    LToken lToken = (LToken) tokenMap.get(event.getProperty() + MARK_SUFFIX);
    if(token == null && lToken == null) {
      return;
    }
    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();
      Object data= token.getData();
      if (data instanceof TextAttribute) {
        TextAttribute oldAttr= (TextAttribute) data;
        TextAttribute newAttr = new TextAttribute(colorManager.getColor(property), oldAttr.getBackground(), oldAttr.getStyle());
        if(token != null) token.setData(newAttr);
        if(lToken != null) lToken.setData(newAttr);
      }
    }
  }
View Full Code Here

Examples of cbg.editor.rules.LToken

    boolean bold = false;
    // bold properties need to be converted to colors for the map
    String colorPlusStyle = event.getProperty();
    String colorName = colorPlusStyle.substring(0, colorPlusStyle.length() - ColorsPreferencePage.BOLD_SUFFIX.length());
    Token token = (Token)tokenMap.get(colorName);
    LToken lToken = (LToken) tokenMap.get(colorName + MARK_SUFFIX);
    if(token == null && lToken == null) return;
    Object value = event.getNewValue();
    bold = ((Boolean) value).booleanValue();
   
    Object data= token.getData();
    if (data instanceof TextAttribute) {
      TextAttribute oldAttr= (TextAttribute) data;
      TextAttribute newAttr= new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), bold ? SWT.BOLD : SWT.NORMAL);
      boolean isBold = (oldAttr.getStyle() == SWT.BOLD);
      if (isBold != bold) {
        token.setData(newAttr);
        if(lToken != null) lToken.setData(newAttr);
      }
    }
  }
View Full Code Here

Examples of cbg.editor.rules.LToken

    for (int i = 0; i < contentTypes.length; i++) {
      String contentType = contentTypes[i];
      if(contentType.startsWith(Type.MARK_PREVIOUS) || contentType.startsWith(Type.MARK_FOLLOWING)) {
        RuleBasedScanner scanner = new RuleBasedScanner();     
        String colorType = contentType.substring(contentType.lastIndexOf('.') + 1);
        LToken defaultToken = (LToken) newToken(colorManager.colorForType(colorType), true);
        defaultToken.setLength(getLength(contentType));
        defaultToken.isPrevious(contentType.startsWith(Type.MARK_PREVIOUS));
        scanner.setDefaultReturnToken(defaultToken);
        DefaultDamagerRepairer dr = new MarkDamagerRepairer(scanner);
        reconciler.setDamager(dr, contentType);
        reconciler.setRepairer(dr, contentType);
      }
View Full Code Here

Examples of cbg.editor.rules.LToken

    String suffix = isMark ? MARK_SUFFIX : "";
    IToken token = (IToken) tokenMap.get(colorName + suffix);
    if(token != null) return token;
    int style = colorManager.getStyleFor(colorName);
    TextAttribute ta = new TextAttribute(colorManager.getColor(colorName), null, style)
    token = isMark ? new LToken(ta) : new Token(ta);
    tokenMap.put(colorName + suffix, token);
    return token;
  }
View Full Code Here

Examples of cbg.editor.rules.LToken

      }
    }
    int delta = 0;
    int offset = 0;
    if(lastToken instanceof LToken) {
      LToken token = (LToken)lastToken;
      delta = token.isPrevious() ? token.getLength() : 0;
      offset = token.isPrevious() ? 0 : token.getLength();
    }
    addRange(presentation, lastStart + offset, length - delta - offset, lastAttribute);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.