Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.TextAttribute


   * @param token
   *            the token whose text attribute is to be determined
   * @return the token's text attribute
   */
  private TextAttribute getTokenTextAttribute(IToken token) {
    TextAttribute ta = null;

    Object data = token.getData();
    if (data instanceof TextAttribute)
      ta = (TextAttribute) data;
    else {
View Full Code Here


      fItalic.setSelection(false);
      fStrike.setSelection(false);
      fUnderline.setSelection(false);
    }
    else {
      TextAttribute attribute = getAttributeFor(namedStyle);
      fClearStyle.setEnabled(true);
      boolean enableBackgroundOnly = IStyleConstantsJSP.JSP_CONTENT.equals(namedStyle);
      fBold.setEnabled(!enableBackgroundOnly);
      fItalic.setEnabled(!enableBackgroundOnly);
      fStrike.setEnabled(!enableBackgroundOnly);
      fUnderline.setEnabled(!enableBackgroundOnly);
      fForegroundLabel.setEnabled(!enableBackgroundOnly);
      fForegroundColorEditor.setEnabled(!enableBackgroundOnly);
      fBackgroundLabel.setEnabled(true);
      fBackgroundColorEditor.setEnabled(true);
      fBold.setSelection((attribute.getStyle() & SWT.BOLD) != 0);
      fItalic.setSelection((attribute.getStyle() & SWT.ITALIC) != 0);
      fStrike.setSelection((attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0);
      fUnderline.setSelection((attribute.getStyle() & TextAttribute.UNDERLINE) != 0);
      if (attribute.getForeground() != null) {
        foreground = attribute.getForeground();
      }
      if (attribute.getBackground() != null) {
        background = attribute.getBackground();
      }
    }

    fForegroundColorEditor.setColorValue(foreground.getRGB());
    fBackgroundColorEditor.setColorValue(background.getRGB());
View Full Code Here

        ITextRegion currentRegion = regions.get(i);
        // lookup the local coloring type and apply it
        String namedStyle = (String) fContextToStyleMap.get(currentRegion.getType());
        if (namedStyle == null)
          continue;
        TextAttribute attribute = getAttributeFor(namedStyle);
        if (attribute == null)
          continue;
        StyleRange style = new StyleRange(documentRegion.getStartOffset(currentRegion), currentRegion.getTextLength(), attribute.getForeground(), attribute.getBackground(), attribute.getStyle());
        style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
        style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0;
        fText.setStyleRange(style);
      }
      documentRegion = documentRegion.getNext();
    }
  }
View Full Code Here

  protected IPreferenceStore doGetPreferenceStore() {
    return JSPUIPlugin.getDefault().getPreferenceStore();
  }

  private TextAttribute getAttributeFor(String namedStyle) {
    TextAttribute ta = new TextAttribute(fDefaultForeground, fDefaultBackground, SWT.NORMAL);

    if (namedStyle != null && fOverlayStore != null) {
      // note: "namedStyle" *is* the preference key
      String prefString = getOverlayStore().getString(namedStyle);
      String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
      if (stylePrefs != null) {
        RGB foreground = ColorHelper.toRGB(stylePrefs[0]);
        RGB background = ColorHelper.toRGB(stylePrefs[1]);

        int fontModifier = SWT.NORMAL;

        if (stylePrefs.length > 2) {
          boolean on = Boolean.valueOf(stylePrefs[2]).booleanValue();
          if (on)
            fontModifier = fontModifier | SWT.BOLD;
        }
        if (stylePrefs.length > 3) {
          boolean on = Boolean.valueOf(stylePrefs[3]).booleanValue();
          if (on)
            fontModifier = fontModifier | SWT.ITALIC;
        }
        if (stylePrefs.length > 4) {
          boolean on = Boolean.valueOf(stylePrefs[4]).booleanValue();
          if (on)
            fontModifier = fontModifier | TextAttribute.STRIKETHROUGH;
        }
        if (stylePrefs.length > 5) {
          boolean on = Boolean.valueOf(stylePrefs[5]).booleanValue();
          if (on)
            fontModifier = fontModifier | TextAttribute.UNDERLINE;
        }

        ta = new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, fontModifier);
      }
    }
    return ta;
  }
View Full Code Here

   * @param length the length of the range to be styled
   * @param attr the attribute describing the style of the range to be styled
   */
  private void addRange(Collection presentation, int offset, int length, TextAttribute attr) {
    // support for user defined backgroud for JSP scriptlet regions
    TextAttribute ta = (TextAttribute)getTextAttributes().get(IStyleConstantsJSP.JSP_CONTENT);
    Color bgColor = ta.getBackground();
    if (bgColor == null)
      bgColor = attr.getBackground();
    StyleRange result = new StyleRange(offset, length, attr.getForeground(), bgColor, attr.getStyle());
    if((attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0) {
      result.strikeout = true;
View Full Code Here

   * @param colorKey
   */
  private void addJavaTextAttribute(String colorKey) {
    IPreferenceStore store = getJavaColorPreferences();
    if (store != null && colorKey != null) {
      TextAttribute ta = null;
      if (colorKey == IStyleConstantsJSPJava.JAVA_KEYWORD) {
        // keyword
        RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR);
        boolean bold = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD);
        boolean italics = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC);
View Full Code Here

   *
   * @param token the token whose text attribute is to be determined
   * @return the token's text attribute
   */
  private TextAttribute getTokenTextAttribute(IToken token) {
    TextAttribute ta = null;
   
    Object data = token.getData();
    if (data instanceof TextAttribute)
      ta = (TextAttribute)data;
    else {
View Full Code Here

   */
  private HighlightingStyle createHighlightingStyle(ISemanticHighlighting highlighting, String styleKey) {
    IPreferenceStore store = highlighting.getPreferenceStore();
    HighlightingStyle highlightingStyle = null;
    if (store != null) {
      TextAttribute attribute = null;
      // A style string is used instead of separate attribute keys
      if (styleKey != null) {
        attribute = createTextAttribute(store.getString(styleKey));
      }
      else {
        int style = getBoolean(store, highlighting.getBoldPreferenceKey()) ? SWT.BOLD : SWT.NORMAL;
       
        if (getBoolean(store, highlighting.getItalicPreferenceKey()))
          style |= SWT.ITALIC;
        if (getBoolean(store, highlighting.getStrikethroughPreferenceKey()))
          style |= TextAttribute.STRIKETHROUGH;
        if (getBoolean(store, highlighting.getUnderlinePreferenceKey()))
          style |= TextAttribute.UNDERLINE;

        String rgbString = getString(store, highlighting.getColorPreferenceKey());
        Color color = null;
       
        if (rgbString != null)
          color = EditorUtility.getColor(ColorHelper.toRGB(rgbString));
        attribute = new TextAttribute(color, null, style);
      }

      store.addPropertyChangeListener(fHighlightingChangeListener);
      boolean isEnabled = getBoolean(store, highlighting.getEnabledPreferenceKey());
      highlightingStyle = new HighlightingStyle(attribute, isEnabled);
View Full Code Here

    return createTextAttribute(foreground, background, style);
  }

  private TextAttribute createTextAttribute(RGB foreground, RGB background, int style) {
    return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, style);
  }
View Full Code Here

    else if (value instanceof String)
      rgb= ColorHelper.toRGB( (String) value);

    if (rgb != null) {
      Color color= EditorUtility.getColor(rgb);
      TextAttribute oldAttr= highlighting.getTextAttribute();
      highlighting.setTextAttribute(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.TextAttribute

Copyright © 2018 www.massapicom. 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.