Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.TextAttribute


   */
  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;
        Color bgColor = null;
       
        if (rgbString != null)
          color = EditorUtility.getColor(ColorHelper.toRGB(rgbString));
        if (highlighting instanceof ISemanticHighlightingExtension2) {
          rgbString = getString(store, ((ISemanticHighlightingExtension2) highlighting).getBackgroundColorPreferenceKey());
          if (rgbString != null) {
            bgColor = EditorUtility.getColor(ColorHelper.toRGB(rgbString));
          }
        }
        attribute = new TextAttribute(color, bgColor, 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

    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(oldAttr.getForeground(), color, oldAttr.getStyle()));
    }
  }
View Full Code Here

    if (value instanceof Boolean)
      eventValue = ((Boolean) value).booleanValue();
    else if (IPreferenceStore.TRUE.equals(value))
      eventValue = true;

    TextAttribute oldAttr = highlighting.getTextAttribute();
    boolean activeValue = (oldAttr.getStyle() & styleAttribute) == styleAttribute;

    if (activeValue != eventValue)
      highlighting.setTextAttribute(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
  }
View Full Code Here

   * @param event the event that triggered the change
   */
  private void adaptToStyleChange(HighlightingStyle highlighting, PropertyChangeEvent event) {
    Object value = event.getNewValue();
    if (value instanceof String) {
      TextAttribute attr = createTextAttribute((String) value);
      if (attr != null)
        highlighting.setTextAttribute(attr);
    }
  }
View Full Code Here

        }
        if (underline) {
          style = style | TextAttribute.UNDERLINE;
        }

        TextAttribute createTextAttribute = createTextAttribute(foreground, background, style);
        getTextAttributes().put(colorKey, createTextAttribute);
      }
    }
  }
View Full Code Here

    return result;

  }

  protected TextAttribute createTextAttribute(RGB foreground, RGB background, boolean bold) {
    return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, bold ? SWT.BOLD : SWT.NORMAL);
  }
View Full Code Here

  protected TextAttribute createTextAttribute(RGB foreground, RGB background, boolean bold) {
    return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, bold ? SWT.BOLD : SWT.NORMAL);
  }

  protected 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

    ITextRegionList regions = blockedRegion.getRegions();
    int nRegions = regions.size();
    StyleRange styleRange = null;
    for (int i = 0; i < nRegions; i++) {
      region = regions.get(i);
      TextAttribute attr = null;
      TextAttribute previousAttr = null;
      if (blockedRegion.getStartOffset(region) > partitionEndOffset)
        break;
      if (blockedRegion.getEndOffset(region) <= partitionStartOffset)
        continue;

      if (region instanceof ITextRegionCollection) {
        handled = prepareTextRegion((ITextRegionCollection) region, partitionStartOffset, partitionLength, holdResults);
      } else {

        attr = getAttributeFor(blockedRegion, region);
        if (attr != null) {
          handled = true;
          // if this region's attr is the same as previous one, then
          // just adjust the previous style range
          // instead of creating a new instance of one
          // note: to use 'equals' in this case is important, since
          // sometimes
          // different instances of attributes are associated with a
          // region, even the
          // the attribute has the same values.
          // TODO: this needs to be improved to handle readonly
          // regions correctly
          if ((styleRange != null) && (previousAttr != null) && (previousAttr.equals(attr))) {
            styleRange.length += region.getLength();
          } else {
            styleRange = createStyleRange(blockedRegion, region, attr, partitionStartOffset, partitionLength);
            holdResults.add(styleRange);
            // technically speaking, we don't need to update
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.