Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.StyleRange


      String userString = message.getUser() == null ? "server" : message //$NON-NLS-1$
          .getUser().getName();

      userString += " (" + message.getTimeStamp() + ")"; //$NON-NLS-1$ //$NON-NLS-2$

      StyleRange userStyle = new StyleRange();
      userStyle.start = buffer.toString().length();
      userStyle.length = userString.length();
      userStyle.fontStyle = SWT.BOLD;
      userStyle.foreground = getSite()
          .getShell()
View Full Code Here


    StyledText text = sourceViewer.getTextWidget();

    if (mCurrentStyleRange != null) {
      // reset current style range
      StyleRange resetedStyleRange = new StyleRange(mCurrentStyleRange.start,
              mCurrentStyleRange.length, null, null);

      text.setStyleRange(resetedStyleRange);
      mCurrentStyleRange = null;
    }

    if (length != 0) {
      mCurrentStyleRange = new StyleRange(start, length, text.getSelectionForeground(), text
              .getSelectionBackground());

      text.setStyleRange(mCurrentStyleRange);
    }
  }
View Full Code Here

        for( int i = 0; i < reservedWords.size(); i++ ) {
            String reservedWord = reservedWords.get(i);

            int index = 0;
            while( (index = text.indexOf(reservedWord, index)) != -1 ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = index;
                int length = reservedWord.length();
                styleRange.length = length;
                styleRange.foreground = darkRedColor;
                styleRange.fontStyle = SWT.BOLD | SWT.ITALIC;
                functionAreaText.setStyleRange(styleRange);
                index = index + length;
            }
        }

        // color important words
        for( int i = 0; i < operationsWords.size(); i++ ) {
            String opWord = operationsWords.get(i);

            int index = 0;
            while( (index = text.indexOf(opWord, index)) != -1 ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = index;
                int length = opWord.length();
                styleRange.length = length;
                styleRange.foreground = darkCyanColor;
                styleRange.fontStyle = SWT.BOLD | SWT.ITALIC;
                functionAreaText.setStyleRange(styleRange);
                index = index + length;
            }
        }

        // brackets
        String[] textSplit = text.split("\\(|\\)|\\{|\\}"); //$NON-NLS-1$
        if (textSplit.length > 1) {
            List<Integer> bracketPositions = new ArrayList<Integer>();
            int position = 0;
            for( int i = 0; i < textSplit.length - 1; i++ ) {
                position = position + textSplit[i].length() + 1;
                bracketPositions.add(position - 1);
            }

            for( Integer pos : bracketPositions ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = pos;
                styleRange.length = 1;
                styleRange.foreground = darkBlueColor;
                styleRange.fontStyle = SWT.BOLD;
                functionAreaText.setStyleRange(styleRange);
            }
        }

        // ;
        textSplit = text.split(";"); //$NON-NLS-1$
        if (textSplit.length > 1) {

            List<Integer> bracketPositions = new ArrayList<Integer>();
            int position = 0;
            for( int i = 0; i < textSplit.length - 1; i++ ) {
                position = position + textSplit[i].length() + 1;
                bracketPositions.add(position - 1);
            }

            for( Integer pos : bracketPositions ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = pos;
                styleRange.length = 1;
                styleRange.foreground = darkGreenColor;
                styleRange.fontStyle = SWT.BOLD;
                functionAreaText.setStyleRange(styleRange);
            }
        }

        textSplit = text.split("\\?"); //$NON-NLS-1$
        if (textSplit.length > 1) {
            List<Integer> bracketPositions = new ArrayList<Integer>();
            int position = 0;
            for( int i = 0; i < textSplit.length - 1; i++ ) {
                position = position + textSplit[i].length() + 1;
                bracketPositions.add(position - 1);
            }

            for( Integer pos : bracketPositions ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = pos;
                styleRange.length = 1;
                styleRange.foreground = redColor;
                styleRange.fontStyle = SWT.BOLD;
                functionAreaText.setStyleRange(styleRange);
View Full Code Here

        while (converterPropertiesKeys.hasMoreElements()) {
            Object key = converterPropertiesKeys.nextElement();
            Object value = converterProperties.get(key);
 
            StyleRange styleRange = new StyleRange();
            styleRange.start = detailPane.getText().length();
            detailPane.append(key + ":\n");
            styleRange.length = key.toString().length() + 1;
            styleRange.fontStyle = SWT.BOLD;
            detailPane.setStyleRange(styleRange);
View Full Code Here

         
        String messageWithFirstUrlDetagged =
          message.replaceFirst(Pattern.quote(urlWithTags), url);
       
        String messageBeforeUrl = messageWithFirstUrlDetagged.substring(0, startTagIndex);
          StyleRange preURLStyle = syncedStyledPrint(
              textField, messageBeforeUrl, normalColor, SWT.NORMAL);
          urlListener.addURL(textField.getText().length(), url);
          urlCursorListener.addURL(textField.getText().length(), url);
          StyleRange urlStyle =
            syncedStyledPrint(textField, url, urlColor, SWT.BOLD);
          String messageBeyondFirstUrl =
            messageWithFirstUrlDetagged.substring(startTagIndex + url.length());
          Collection<StyleRange> postURLStyles = urlifyUrls(
            textField,
            urlListener,
            urlCursorListener,
            messageBeyondFirstUrl,
            normalColor,
            urlColor);
 
          Collection<StyleRange> finalStyles = new HashSet<StyleRange>();
 
          if (preURLStyle != null) {
            finalStyles.add(preURLStyle);
          }
 
          if (urlStyle != null) {
            finalStyles.add(urlStyle);
          }
 
          finalStyles.addAll(postURLStyles);
 
          return finalStyles;
      } else {
        StyleRange style = syncedStyledPrint(textField, message, normalColor, SWT.NORMAL);
 
          if (style != null) {
            Collection<StyleRange> finalStyles = new HashSet<StyleRange>();
            finalStyles.add(style);
 
View Full Code Here

    public static StyleRange styledPrint(
        StyledText textField, String message, Color color, int style) {
      if (!textField.isDisposed()) {
            textField.append(message);

            StyleRange styleRange = new StyleRange();
            styleRange.start = textField.getText().length() - message.length();
            styleRange.length = message.length();
            styleRange.foreground = color;
            styleRange.fontStyle = style;
            textField.setStyleRange(styleRange);
View Full Code Here

        while (converterPropertiesKeys.hasMoreElements()) {
            Object key = converterPropertiesKeys.nextElement();
            Object value = converterProperties.get(key);
 
            StyleRange styleRange = new StyleRange();
            styleRange.start = detailPane.getText().length();
            detailPane.append(key + ":\n");
            styleRange.length = key.toString().length() + 1;
            styleRange.fontStyle = SWT.BOLD;
            detailPane.setStyleRange(styleRange);
View Full Code Here

          if (LogView.this.boundsByServiceReference.containsKey(serviceReference)) {
            Collection<Bounds> highlightBounds =
              LogView.this.boundsByServiceReference.get(serviceReference);

            for (Bounds highlightBound : highlightBounds) {
              StyleRange highlightStyle = new StyleRange();
              highlightStyle.start = highlightBound.start;
              highlightStyle.length = highlightBound.length;
              highlightStyle.background = HIGHLIGHTED_BACKGROUND_COLOR;
              highlights.add(highlightStyle);
            }
          }
        }
      }

      final Collection<StyleRange> nonHighlightStyles = new ArrayList<StyleRange>();

      for (StyleRange nonHighlightStyle : this.nonHighlightStyleRanges) {
        StyleRange newStyle = nonHighlightStyle;

        for (StyleRange highlightStyle : highlights) {
          int start = nonHighlightStyle.start;

          if ((start >= highlightStyle.start)
              && (start < (highlightStyle.start + highlightStyle.length))) {
            newStyle = (StyleRange) newStyle.clone();
            newStyle.background = HIGHLIGHTED_BACKGROUND_COLOR;
          }
        }

        nonHighlightStyles.add(newStyle);
View Full Code Here

        int pos = explanationText.getCharCount();
        explanationText.append((String) marker.getAttribute(IMarker.MESSAGE) +"\n");
       
        int severity = ((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue();
       
        StyleRange styleRange = new StyleRange();
            styleRange.start = pos;
            styleRange.length = ((String) marker.getAttribute(IMarker.MESSAGE)).length();
            styleRange.fontStyle = SWT.BOLD;
            styleRange.foreground = severity == IMarker.SEVERITY_WARNING ? yellow : red;
            explanationText.setStyleRange(styleRange);
           
           
            String expStr = (String) marker.getAttribute(Constants.MARKER_ATTR_PERL_ERROR_EXPLANATION);
           
            String levelStr = null;
           
            if(expStr.length() > 0) {
              levelStr = (String) levels.get(expStr.substring(0,expStr.indexOf(")")+1));
            }
           
            if(levelStr != null) {
              pos = explanationText.getCharCount();
              explanationText.append(levelStr +"\n");
             
              styleRange = new StyleRange();
              styleRange.start = pos;
              styleRange.length = levelStr.length();
              styleRange.fontStyle = SWT.ITALIC;
              styleRange.foreground = black;
              explanationText.setStyleRange(styleRange);
View Full Code Here

   
    Time time = new Time(System.currentTimeMillis());
   
    styledText.append(nickName + " [" + time + "]\n  " + message + "\n");
   
    StyleRange sr = new StyleRange(
        contentLength,
        nickName.length(),
        null,
        null,
        SWT.BOLD);
View Full Code Here

TOP

Related Classes of org.eclipse.swt.custom.StyleRange

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.