コード例 #1
0
ファイル: TextSearchPage.java プロジェクト: ermh/Dart
 private void statusMessage(boolean error, String message) {
   fStatusLabel.setText(message);
   if (error) {
     fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay()));
   } else {
     fStatusLabel.setForeground(null);
   }
 }
コード例 #2
0
  public TagLabel(Composite parent, int style, String tagName) {
    super(parent, style);
    if (tagName == null || tagName.length() == 0) {
      throw new IllegalArgumentException("tag name is empty");
    }
    this.tagName = tagName;
    GridLayout gl = new GridLayout(2, false);
    GUIUtil.resetGridLayout(gl);
    super.setLayout(gl);

    final CLabel cross = new CLabel(this, 0);
    cross.setText("×");
    GridData data = new GridData(SWT.LEFT, SWT.TOP, false, true);
    cross.setLayoutData(data);
    data = new GridData(SWT.RIGHT, SWT.TOP, true, true);
    CLabel tagText = new CLabel(this, 0);
    tagText.setText(tagName);

    plainFont = cross.getFont();
    FontData fd = plainFont.getFontData()[0];
    boldFont = new Font(cross.getDisplay(), fd.getName(), fd.getHeight(), SWT.BOLD);
    cross.addListener(
        SWT.MouseEnter,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            cross.setFont(boldFont);
            cross.setCursor(handCursor);
          }
        });
    cross.addListener(
        SWT.MouseExit,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            cross.setFont(plainFont);
            cross.setCursor(defaultCursor);
          }
        });
    cross.addListener(
        SWT.MouseDown,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            if (delegate != null) {
              delegate.tagLabelClicked(TagLabel.this);
            }
          }
        });
  }
コード例 #3
0
  /**
   * Updates the message label widget.
   *
   * @since 3.0
   */
  private void updateMessageLabel() {
    if (fLabel != null && !fLabel.isDisposed()) {
      Display display = fLabel.getDisplay();
      if ((fErrorText != null && fErrorText.length() > 0) || fErrorImage != null) {
        String escapedErrorText = escape(fErrorText);
        fLabel.setForeground(JFaceColors.getErrorText(display));
        fLabel.setText(escapedErrorText);
        fLabel.setImage(fErrorImage);
        if (fToolTipText != null) fLabel.setToolTipText(escape(fToolTipText));
        else if (fErrorText.length() > fWidthInChars) fLabel.setToolTipText(escapedErrorText);
        else fLabel.setToolTipText(null);

      } else {
        String escapedText = escape(fText);
        fLabel.setForeground(fLabel.getParent().getForeground());
        fLabel.setText(escapedText);
        fLabel.setImage(fImage);
        if (fToolTipText != null) fLabel.setToolTipText(escape(fToolTipText));
        else if (fText != null && fText.length() > fWidthInChars)
          fLabel.setToolTipText(escapedText);
        else fLabel.setToolTipText(null);
      }
    }
  }