Exemplo n.º 1
0
  public static void buildXLogData(final String date, StyledText text, XLogPack p, int serverId) {

    final int servId = serverId;

    String error = TextProxy.error.getLoadText(date, p.error, servId);
    String objName = TextProxy.object.getLoadText(date, p.objHash, servId);

    int slen = 0;
    java.util.List<StyleRange> sr = new ArrayList<StyleRange>();

    Color red = text.getDisplay().getSystemColor(SWT.COLOR_RED);

    final StringBuffer sb = new StringBuffer();
    sb.append("► txid    = ").append(Hexa32.toString32(p.txid)).append("\n");
    sb.append("► objName = ").append(objName).append("\n");
    sb.append("► endtime = ").append(DateUtil.timestamp(p.endTime)).append("\n");
    sb.append("► elapsed = ").append(FormatUtil.print(p.elapsed, "#,##0")).append(" ms\n");
    sb.append("► service = ").append(TextProxy.service.getText(p.service)).append("\n");
    if (error != null) {
      sb.append("► error   = ");
      slen = sb.length();
      sb.append(error).append("\n");
      sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL));
    }

    sb.append("► ipaddr=" + IPUtil.toString(p.ipaddr) + ", ");
    sb.append("userid=" + p.userid);
    sb.append("\n► cpu=" + FormatUtil.print(p.cpu, "#,##0") + " ms, ");
    sb.append("bytes=" + p.bytes + ", ");
    sb.append("status=" + p.status);
    if (p.sqlCount > 0) {
      sb.append("\n► sqlCount=" + p.sqlCount + ", ");
      sb.append("sqlTime=" + FormatUtil.print(p.sqlTime, "#,##0") + " ms");
    }
    if (p.apicallCount > 0) {
      sb.append("\n► ApiCallCount=" + p.apicallCount + ", ");
      sb.append("ApiCallTime=" + FormatUtil.print(p.apicallTime, "#,##0") + " ms");
    }

    String t = TextProxy.userAgent.getLoadText(date, p.userAgent, serverId);
    if (StringUtil.isNotEmpty(t)) {
      sb.append("\n► userAgent=" + t);
    }

    t = TextProxy.referer.getLoadText(date, p.referer, serverId);
    if (StringUtil.isNotEmpty(t)) {
      sb.append("\n► referer=" + t);
    }

    t = TextProxy.group.getLoadText(date, p.group, serverId);
    if (StringUtil.isNotEmpty(t)) {
      sb.append("\n► group=" + t);
    }

    sb.append("\n");

    text.setText(sb.toString());
    text.setStyleRanges(sr.toArray(new StyleRange[sr.size()]));
  }
Exemplo n.º 2
0
 private void changeTemplateText(int index) {
   if (index != -1) {
     templateCode.setText(tempText[index].getText());
     tempText[index].setShowWarning(isShowWarning);
     tempText[index].setTemplateStyle(mainPageComposite.getDisplay(), 0);
     templateCode.setStyleRanges(
         tempText[index].getLocationArray(), tempText[index].getStyleArrray());
   }
 }
Exemplo n.º 3
0
  private void drawCurrentLine(LineBackgroundEvent event, final IRegion lineRegion) {
    final StyledText textWidget = fViewer.getTextWidget();
    final int offset = event.lineOffset;
    final RGBa lineHighlight = getCurrentTheme().getLineHighlight();
    event.lineBackground = getColorManager().getColor(lineHighlight.toRGB());

    // In this case, we should be overriding the bg of the style ranges for the line too!
    if (textWidget.isDisposed()) {
      return;
    }
    // FIXME Only change bg colors of visible ranges!
    int replaceLength = 160;
    if (lineRegion != null) {
      replaceLength = Math.min(replaceLength, lineRegion.getLength());
    }

    // be safe about offsets
    int charCount = textWidget.getCharCount();
    if (offset + replaceLength > charCount) {
      replaceLength = charCount - offset;
      if (replaceLength < 0) {
        // Just playing safe here
        replaceLength = 0;
      }
    }
    final StyleRange[] ranges = textWidget.getStyleRanges(offset, replaceLength, true);
    if (ranges == null || ranges.length == 0) {
      return;
    }
    Color background = textWidget.getBackground();
    final int[] positions = new int[ranges.length << 1];
    int x = 0;
    boolean apply = false;
    for (StyleRange range : ranges) {
      if (range.background != null) {
        if (!range.background.equals(background)) {
          positions[x] = range.start;
          positions[x + 1] = range.length;
          x += 2;
          continue;
        }
        apply = true;
      }
      range.background = null;
      positions[x] = range.start;
      positions[x + 1] = range.length;
      x += 2;
    }

    if (apply) {
      textWidget.setStyleRanges(offset, replaceLength, positions, ranges);
    }
  }
Exemplo n.º 4
0
 private void updateInput() {
   if (fInfoText == null || !fInputChanged) {
     return;
   }
   if (fLabelProvider == null) {
     fLabelProvider =
         new RLabelProvider(
             RLabelProvider.LONG | RLabelProvider.HEADER | RLabelProvider.NAMESPACE);
   }
   if (fInput != null) {
     final Image image = fLabelProvider.getImage(fInput.element);
     fTitleImage.setImage(
         (image != null)
             ? image
             : SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID));
     final StyledString styleString =
         fLabelProvider.getStyledText(
             fInput.element, fInput.element.getElementName(), fInput.elementAttr);
     fTitleText.setText(styleString.getString());
     fTitleText.setStyleRanges(styleString.getStyleRanges());
     if (fInput.detailTitle != null) {
       fInfoText.setText(
           fInput.detailTitle
               + '\n'
               + ((fInput.detailInfo != null) ? fInput.detailInfo : "")); // $NON-NLS-1$
       final StyleRange title = new StyleRange(0, fInput.detailTitle.length(), null, null);
       title.underline = true;
       fInfoText.setStyleRange(title);
     } else {
       fInfoText.setText(""); // $NON-NLS-1$
     }
   } else {
     fTitleImage.setImage(
         SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID));
     fTitleText.setText(""); // $NON-NLS-1$
     fInfoText.setText(""); // $NON-NLS-1$
   }
   if (fMode == MODE_SIMPLE) {
     setStatusText(
         (fInput.control != null && fInput.control.isFocusControl())
             ? InformationDispatchHandler.getTooltipAffordanceString()
             : ""); //$NON-NLS-1$
   }
   fInputChanged = false;
 }
Exemplo n.º 5
0
 public void show(String title, final String message, List<StyleRange> srList) {
   final Shell dialog = new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE);
   UIUtil.setDialogDefaultFunctions(dialog);
   dialog.setText(title);
   dialog.setLayout(new GridLayout(1, true));
   final StyledText text =
       new StyledText(dialog, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
   GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
   gd.widthHint = 400;
   gd.heightHint = 300;
   text.setLayoutData(gd);
   text.setText(message);
   text.addKeyListener(
       new KeyAdapter() {
         public void keyPressed(KeyEvent e) {
           if (e.stateMask == SWT.CTRL) {
             if (e.keyCode == 'a' || e.keyCode == 'A') {
               text.selectAll();
             }
           }
         }
       });
   if (srList != null && srList.size() > 0) {
     text.setStyleRanges(srList.toArray(new StyleRange[srList.size()]));
   }
   Button btn = new Button(dialog, SWT.PUSH);
   gd = new GridData(SWT.RIGHT, SWT.FILL, false, false);
   gd.widthHint = 100;
   btn.setLayoutData(gd);
   btn.setText("&Close");
   btn.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           dialog.close();
         }
       });
   dialog.pack();
   dialog.open();
 }
Exemplo n.º 6
0
  public static void buildProfile(
      final String date,
      StyledText text,
      XLogPack pack,
      StepWrapper[] orgProfiles,
      int pageNum,
      int rowPerPage,
      Button prevBtn,
      Button nextBtn,
      Button startBtn,
      Button endBtn,
      int length,
      int serverId,
      int searchLineIndex,
      boolean isSummary) {

    String spaceStr = "";
    String astarStr = "";
    for (int j = 0; j < length; j++) {
      spaceStr += " ";
      astarStr += "*";
    }

    if (orgProfiles == null) {
      orgProfiles = new StepWrapper[0];
    }

    boolean lastPage = false;
    int startIdx = pageNum * rowPerPage;
    int lastIdx = (pageNum * rowPerPage) + rowPerPage;
    if (lastIdx >= orgProfiles.length) {
      lastIdx = orgProfiles.length;
      lastPage = true;
    }

    int ix = 0;
    StepWrapper[] profiles = new StepWrapper[lastIdx - startIdx];
    for (int inx = startIdx; inx < lastIdx; inx++) {
      profiles[ix] = orgProfiles[inx];
      ix++;
    }

    int slen = 0;
    java.util.List<StyleRange> sr = new ArrayList<StyleRange>();

    Color blue = text.getDisplay().getSystemColor(SWT.COLOR_BLUE);
    Color dmagenta = text.getDisplay().getSystemColor(SWT.COLOR_DARK_MAGENTA);
    Color red = text.getDisplay().getSystemColor(SWT.COLOR_RED);
    Color yellow = text.getDisplay().getSystemColor(SWT.COLOR_YELLOW);

    Color dgreen = text.getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN);

    final StringBuffer sb = new StringBuffer();

    sb.append(
        "------------------------------------------------------------------------------------------\n");
    sb.append(
        "  p# " + spaceStr + "# " + spaceStr + " TIME         T-GAP   CPU          CONTENTS\n");
    sb.append(
        "------------------------------------------------------------------------------------------\n");

    if (profiles.length == 0) {
      sb.append("\n                     ( No xlog profile collected ) ");
      text.setText(sb.toString());
      text.setStyleRanges(sr.toArray(new StyleRange[sr.size()]));
      return;
    }
    long stime = pack.endTime - pack.elapsed;
    long prev_tm = stime;
    if (pageNum > 0) {
      prev_tm = orgProfiles[startIdx - 1].time;
    }
    long prev_cpu = 0;
    if (pageNum > 0) {
      prev_cpu = orgProfiles[startIdx - 1].cpu;
    }

    if (pageNum == 0) {
      sb.append(" " + spaceStr + " ");
      sb.append(" ");
      sb.append("[" + astarStr + "]");
      sb.append(" ");
      sb.append(DateUtil.getLogTime(stime));
      sb.append("   ");
      sb.append(String.format("%6s", "0"));
      sb.append(" ");
      sb.append(String.format("%6s", "0"));
      sb.append("  start transaction \n");
    }

    long tm = pack.endTime;
    long cpu = pack.cpu;

    for (int i = 0; i < profiles.length; i++) {

      if (profiles[i].step instanceof StepSummary) {
        int p1 = sb.length();
        sb.append(spaceStr).append("   ");
        sb.append(String.format("[%0" + length + "d]", profiles[i].sSummaryIdx));
        sb.append(" ");
        int lineHead = sb.length() - p1;

        StepSummary sum = (StepSummary) profiles[i].step;
        switch (sum.getStepType()) {
          case StepEnum.METHOD_SUM:
            MethodSum p = (MethodSum) sum;
            slen = sb.length();

            String m = TextProxy.method.getText(p.hash);
            if (m == null) m = Hexa32.toString32(p.hash);
            sb.append(m).append(" ");

            if (searchLineIndex == profiles[i].sSummaryIdx) {
              sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
            } else {
              sr.add(ProfileText.style(slen, sb.length() - slen, blue, SWT.NORMAL));
            }

            sb.append(" count=").append(FormatUtil.print(p.count, "#,##0"));
            sb.append(" time=").append(FormatUtil.print(p.elapsed, "#,##0")).append(" ms");
            sb.append(" cpu=").append(FormatUtil.print(p.cputime, "#,##0"));

            sb.append("\n");
            break;
          case StepEnum.SQL_SUM:
            SqlSum sql = (SqlSum) sum;
            slen = sb.length();
            ProfileText.toString(sb, sql, serverId);
            if (searchLineIndex == profiles[i].sSummaryIdx) {
              sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
            } else {
              sr.add(ProfileText.style(slen, sb.length() - slen, blue, SWT.NORMAL));
            }
            sb.append("\n");
            break;
          case StepEnum.APICALL_SUM:
            ApiCallSum apicall = (ApiCallSum) sum;
            slen = sb.length();
            ProfileText.toString(sb, apicall);
            if (searchLineIndex == profiles[i].sSummaryIdx) {
              sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
            } else {
              sr.add(ProfileText.style(slen, sb.length() - slen, dmagenta, SWT.NORMAL));
            }
            sb.append("\n");
            break;
          case StepEnum.SOCKET_SUM:
            XLogProfileView.isSummary = true;
            SocketSum socketSum = (SocketSum) sum;
            slen = sb.length();
            ProfileText.toString(sb, socketSum);
            sr.add(ProfileText.style(slen, sb.length() - slen, dmagenta, SWT.NORMAL));
            sb.append("\n");
            break;
        }
        continue;
      }

      StepSingle stepSingle = (StepSingle) profiles[i].step;
      tm = profiles[i].time;
      cpu = profiles[i].cpu;

      int p1 = sb.length();
      String pid = String.format("[%0" + length + "d]", stepSingle.parent);
      sb.append((stepSingle.parent == -1) ? spaceStr + "  " : pid);
      sb.append(" ");
      sb.append(String.format("[%0" + length + "d]", stepSingle.index));
      sb.append(" ");
      sb.append(DateUtil.getLogTime(tm));
      sb.append("   ");
      sb.append(String.format("%6s", FormatUtil.print(tm - prev_tm, "#,##0")));
      sb.append(" ");
      sb.append(String.format("%6s", FormatUtil.print(cpu - prev_cpu, "#,##0")));
      sb.append("  ");
      int lineHead = sb.length() - p1;

      int space = profiles[i].indent;
      while (space > 0) {
        sb.append(" ");
        space--;
      }

      switch (stepSingle.getStepType()) {
        case StepEnum.METHOD:
          slen = sb.length();
          ProfileText.toString(sb, (MethodStep) stepSingle);
          if (searchLineIndex == stepSingle.index) {
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
          }
          break;
        case StepEnum.METHOD2:
          slen = sb.length();
          ProfileText.toString(sb, (MethodStep) stepSingle);
          if (searchLineIndex == stepSingle.index) {
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
          }
          MethodStep2 m2 = (MethodStep2) stepSingle;
          if (m2.error != 0) {
            slen = sb.length();
            sb.append("\n").append(TextProxy.error.getText(m2.error));
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL));
          }
          break;
        case StepEnum.SQL:
        case StepEnum.SQL2:
        case StepEnum.SQL3:
          SqlStep sql = (SqlStep) stepSingle;
          slen = sb.length();
          ProfileText.toString(sb, sql, serverId, lineHead, false);
          if (searchLineIndex == stepSingle.index) {
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
          } else {
            sr.add(ProfileText.style(slen, sb.length() - slen, blue, SWT.NORMAL));
          }
          if (sql.error != 0) {
            slen = sb.length();
            sb.append("\n").append(TextProxy.error.getText(sql.error));
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL));
          }
          break;
        case StepEnum.MESSAGE:
          slen = sb.length();
          ProfileText.toString(sb, (MessageStep) stepSingle);
          if (searchLineIndex == stepSingle.index) {
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
          } else {
            sr.add(ProfileText.style(slen, sb.length() - slen, dgreen, SWT.NORMAL));
          }
          break;
        case StepEnum.HASHED_MESSAGE:
          slen = sb.length();
          ProfileText.toString(sb, (HashedMessageStep) stepSingle);
          if (searchLineIndex == stepSingle.index) {
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
          } else {
            sr.add(ProfileText.style(slen, sb.length() - slen, dgreen, SWT.NORMAL));
          }
          break;
        case StepEnum.APICALL:
          ApiCallStep apicall = (ApiCallStep) stepSingle;
          slen = sb.length();
          ProfileText.toString(sb, apicall);
          if (searchLineIndex == stepSingle.index) {
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.BOLD, yellow));
          } else {
            sr.add(ProfileText.style(slen, sb.length() - slen, dmagenta, SWT.NORMAL));
          }
          if (apicall.error != 0) {
            slen = sb.length();
            sb.append("\n").append(TextProxy.error.getText(apicall.error));
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL));
          }
          break;
        case StepEnum.SOCKET:
          SocketStep socket = (SocketStep) stepSingle;
          slen = sb.length();
          ProfileText.toString(sb, socket);
          sr.add(ProfileText.style(slen, sb.length() - slen, dmagenta, SWT.NORMAL));
          if (socket.error != 0) {
            slen = sb.length();
            sb.append("\n").append(TextProxy.error.getText(socket.error));
            sr.add(ProfileText.style(slen, sb.length() - slen, red, SWT.NORMAL));
          }
          break;
      }
      sb.append("\n");
      prev_cpu = cpu;
      prev_tm = tm;
    }

    if (lastPage) {

      nextBtn.setEnabled(false);
      endBtn.setEnabled(false);

      tm = pack.endTime;
      cpu = pack.cpu;
      // slen = sb.length();
      sb.append(" " + spaceStr + " ");
      sb.append(" ");
      sb.append("[" + astarStr + "]");
      sb.append(" ");
      sb.append(DateUtil.getLogTime(tm));
      sb.append("   ");
      if (!isSummary) {
        sb.append(String.format("%6s", FormatUtil.print(tm - prev_tm, "#,##0")));
      } else {
        sb.append(String.format("%6s", FormatUtil.print(pack.elapsed, "#,##0")));
      }
      sb.append(" ");
      sb.append(String.format("%6s", FormatUtil.print(cpu - prev_cpu, "#,##0")));
      sb.append("  end of transaction \n");

      // sr.add(ProfileText.style(slen, sb.length() - slen, dblue, SWT.NORMAL));
      sb.append(
          "------------------------------------------------------------------------------------------\n");
    } else {
      nextBtn.setEnabled(true);
      endBtn.setEnabled(true);
    }

    if (pageNum == 0) {
      prevBtn.setEnabled(false);
      startBtn.setEnabled(false);
    } else {
      prevBtn.setEnabled(true);
      startBtn.setEnabled(true);
    }
    text.setText(sb.toString());
    text.setStyleRanges(sr.toArray(new StyleRange[sr.size()]));
  }
  // This method formats an easily readable string describing the
  // backup specification.  An example message would be:
  //
  // "Backup c:/foo.txt, c:/bar.xls, and all files under c:/tom.  Also backup
  // c:/garrick except for c:/garrick/bigfiles."
  public void updateText() {
    ArrayList includedFiles = backupSpec.includedFiles();
    ArrayList excludedFiles = backupSpec.excludedFiles();

    if (includedFiles.isEmpty()) {
      text.setText(
          "No files are selected for backup.  Select the check box to the left of a file to mark it for backup.");
      return;
    }

    Color red = text.getDisplay().getSystemColor(SWT.COLOR_RED);
    Color blue = text.getDisplay().getSystemColor(SWT.COLOR_BLUE);

    ArrayList styles = new ArrayList();
    StringBuffer buffer = new StringBuffer();

    buffer.append("Backup ");

    // The first sentence includes all included files (not directories).  This is
    // the "Backup c:/foo.txt. c:/bar.xls..." portion of the example message.
    int numFiles = 0;
    for (int i = 0, count = includedFiles.size(); i < count; i++) {

      File file = (File) includedFiles.get(i);

      if (file.isFile()) {
        numFiles++;

        if (numFiles > 1) {
          if (numFiles == includedFiles.size()) {
            buffer.append(", and ");
          } else {
            buffer.append(", ");
          }
        }

        appendFile(file, buffer, styles, blue);
      }
    }

    if (numFiles == includedFiles.size()) {
      // We only had individual files, so put a period on it, we are done!
      // Otherwise we leave the sentence hanging so that directories can
      // be added on.
      buffer.append(".");
    } else {

      // We've got directories.
      if (numFiles > 0) {
        // If we had some files, then we need to append the
        // directories to an already existing sentence.
        buffer.append(", and ");
      }

      // Find all top level directories that have no exclusions under
      // them.  A "top level" directory is one which was not included
      // in response to an exclusion.  For instance if
      //		includedFiles = [c:/tom, c:/garrick, c:/garrick/Documents/Work]
      //  and excludedFiles = [c:/garrick/Documents]
      //
      // Then c:/tom and c:/garrick are "top level" directories, although
      // since c:/garrick has exclusions then only c:/tom will end up in
      // the list.

      ArrayList topLevelDirectoriesWithoutExclusions = new ArrayList();
      for (int i = 0, count = includedFiles.size(); i < count; i++) {
        File file = (File) includedFiles.get(i);

        if (file.isFile()) {
          continue;
        }

        backupSpec.findFilesExplicitlyExcludedFrom(file, excluded);
        File parent = file.getParentFile();
        if (excluded.isEmpty()
            && (parent == null
                || BackupSpecification.nearestAncestor(parent, includedFiles) == null)) {
          topLevelDirectoriesWithoutExclusions.add(file);
        }
      }

      // If we have any topLevelDirectoriesWithoutExclusions, then pack
      // them into one sentence (potentially along with the lone files).
      boolean appendedDirectory = false;
      if (topLevelDirectoriesWithoutExclusions.size() > 0) {
        buffer.append("all files under ");

        for (int i = 0, count = topLevelDirectoriesWithoutExclusions.size(); i < count; i++) {
          File file = (File) topLevelDirectoriesWithoutExclusions.get(i);

          if (i > 0 && i == topLevelDirectoriesWithoutExclusions.size() - 1) {
            buffer.append(", and ");
          } else if (i > 0) {
            buffer.append(", ");
          }

          appendFile(file, buffer, styles, blue);
        }

        appendedDirectory = true;
        buffer.append(".");
      }

      // Now do all other directories, one sentence each.
      for (int i = 0, count = includedFiles.size(); i < count; i++) {
        File file = (File) includedFiles.get(i);

        if (file.isFile() || topLevelDirectoriesWithoutExclusions.contains(file)) {
          continue;
        }

        if (appendedDirectory == true) {
          // We are starting a new sentence, rather than joining
          // the initial sentence containing files.
          buffer.append("  Also backup ");
        }
        appendedDirectory = true;

        buffer.append("all files under ");

        appendFile(file, buffer, styles, blue);

        backupSpec.findFilesExplicitlyExcludedFrom(file, excluded);

        if (excluded.size() > 0) {
          buffer.append(" except for ");

          for (int j = 0, jcount = excluded.size(); j < jcount; j++) {
            File excludedFile = (File) excluded.get(j);

            if (j > 0 && j == excluded.size() - 1) {
              buffer.append(", and ");
            } else if (j > 0) {
              buffer.append(", ");
            }

            appendFile(excludedFile, buffer, styles, red);
          }
        }
        buffer.append(".");
      }
    }

    text.setText(buffer.toString());
    text.setStyleRanges((StyleRange[]) styles.toArray(new StyleRange[styles.size()]));
  }
Exemplo n.º 8
0
 /**
  * Sets styles to be used for rendering the widget content. All styles in the widget will be
  * replaced with the given set of styles.
  *
  * @param inRanges StyleRange[]
  * @see StyledText#setStyleRanges(StyleRange[])
  */
 public void setStyleRanges(final StyleRange[] inRanges) {
   textWidget.setStyleRanges(inRanges);
 }
 public void setColor() {
   centerDescription.setStyleRanges(styleRanges.toArray(new StyleRange[styleRanges.size()]));
 }
 public void setCenterDescriptionStyle(StyleRange[] styleRanges) {
   centerDescription.setStyleRanges(styleRanges);
 }