Example #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()]));
  }
Example #2
0
 /** Sets the font related data to be applied to the text in page 2. */
 void setFont() {
   FontDialog fontDialog = new FontDialog(getSite().getShell());
   fontDialog.setFontList(text.getFont().getFontData());
   FontData fontData = fontDialog.open();
   if (fontData != null) {
     if (font != null) font.dispose();
     font = new Font(text.getDisplay(), fontData);
     text.setFont(font);
   }
 }
 public void setEnabled(boolean enabled) {
   if (enabled != fEnabled) {
     fEnabled = enabled;
     StyledText c = getSourceViewer().getTextWidget();
     if (c != null) {
       c.setEnabled(enabled);
       Display d = c.getDisplay();
       c.setBackground(enabled ? d.getSystemColor(SWT.COLOR_LIST_BACKGROUND) : null);
     }
   }
 }
Example #4
0
 void open(java.lang.String name) {
   final java.lang.String textString;
   if (name == null || name.length() == 0) {
     return;
   }
   java.io.File file = new java.io.File(name);
   if (!file.exists()) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_file_no_exist"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   try {
     java.io.FileInputStream stream = new java.io.FileInputStream(file.getPath());
     try {
       java.io.Reader in = new java.io.BufferedReader(new java.io.InputStreamReader(stream));
       char[] readBuffer = new char[2048];
       java.lang.StringBuffer buffer = new java.lang.StringBuffer((int) file.length());
       int n;
       while ((n = in.read(readBuffer)) > 0) {
         buffer.append(readBuffer, 0, (-n));
       }
       textString = buffer.toString();
       stream.close();
     } catch (java.io.IOException e) {
       java.lang.String message =
           MessageFormat.format(
               resources.getString("Err_file_io"), new java.lang.String[] {file.getName()});
       displayError(message);
       return;
     }
   } catch (java.io.FileNotFoundException e) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_not_found"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   org.eclipse.swt.widgets.Display display = text.getDisplay();
   display.asyncExec(
       new java.lang.Runnable() {
         public void run() {
           text.setText(textString);
         }
       });
   lineStyler.parseBlockComments(textString);
 }
  protected void initializeViewerColors() {
    if (fPreferenceStore != null) {

      StyledText styledText = getTextWidget();

      // ----------- foreground color --------------------
      Color color =
          fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
              ? null
              : createColor(
                  fPreferenceStore,
                  AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
                  styledText.getDisplay());
      styledText.setForeground(color);

      if (fForegroundColor != null) fForegroundColor.dispose();

      fForegroundColor = color;

      // ---------- background color ----------------------
      color =
          fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
              ? null
              : createColor(
                  fPreferenceStore,
                  AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
                  styledText.getDisplay());
      styledText.setBackground(color);

      if (fBackgroundColor != null) fBackgroundColor.dispose();

      fBackgroundColor = color;

      // ----------- selection foreground color --------------------
      color =
          fPreferenceStore.getBoolean(
                  AbstractDecoratedTextEditorPreferenceConstants
                      .EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR)
              ? null
              : createColor(
                  fPreferenceStore,
                  AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR,
                  styledText.getDisplay());
      styledText.setSelectionForeground(color);

      if (fSelectionForegroundColor != null) fSelectionForegroundColor.dispose();

      fSelectionForegroundColor = color;

      // ---------- selection background color ----------------------
      color =
          fPreferenceStore.getBoolean(
                  AbstractDecoratedTextEditorPreferenceConstants
                      .EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR)
              ? null
              : createColor(
                  fPreferenceStore,
                  AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR,
                  styledText.getDisplay());
      styledText.setSelectionBackground(color);

      if (fSelectionBackgroundColor != null) fSelectionBackgroundColor.dispose();

      fSelectionBackgroundColor = color;
    }
  }
Example #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()]));
  }
Example #8
0
  private static void createStyledText(final Group group) {
    group.setLayout(new GridLayout(2, false));
    group.setText("StyledText widget");

    final Label lbl0 = new Label(group, SWT.NONE);
    lbl0.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl0.setText("No prompt :");

    final StyledText txt0 = new StyledText(group, SWT.BORDER);
    txt0.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

    final Label lbl1 = new Label(group, SWT.NONE);
    lbl1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl1.setText("Simple text prompt :");

    final StyledText txt1 = new StyledText(group, SWT.BORDER);
    txt1.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt1);

    final Label lbl2 = new Label(group, SWT.NONE);
    lbl2.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl2.setText("Other style (bold) :");

    final StyledText txt2 = new StyledText(group, SWT.BORDER);
    txt2.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want in bold", txt2);
    PromptSupport.setFontStyle(SWT.BOLD, txt2);

    final Label lbl3 = new Label(group, SWT.NONE);
    lbl3.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl3.setText("Behaviour highlight :");

    final StyledText txt3 = new StyledText(group, SWT.BORDER);
    txt3.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt3);
    PromptSupport.setFocusBehavior(FocusBehavior.HIGHLIGHT_PROMPT, txt3);

    final Label lbl4 = new Label(group, SWT.NONE);
    lbl4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl4.setText("Change colors :");

    final StyledText txt4 = new StyledText(group, SWT.BORDER);
    txt4.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    PromptSupport.setPrompt("Type anything you want", txt4);
    PromptSupport.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_YELLOW), txt4);
    PromptSupport.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_BLACK), txt4);

    final Label lbl5 = new Label(group, SWT.NONE);
    lbl5.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    lbl5.setText("Change when widget is initialized :");

    final StyledText txt5 = new StyledText(group, SWT.BORDER);
    txt5.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    txt5.setText("Remove what is typed...");
    txt5.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    txt5.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_YELLOW));

    PromptSupport.setPrompt("Type anything you want", txt5);
    PromptSupport.setForeground(txt4.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE), txt5);
    PromptSupport.setBackground(txt4.getDisplay().getSystemColor(SWT.COLOR_WHITE), txt5);
  }