Esempio n. 1
0
  /** Draw the item {@inheritDoc} */
  @Override
  public void paintControl(final PaintEvent e) {
    final Display display = getDisplay();
    final GC gc = e.gc;
    final Rectangle bounds = getBounds();

    last_alarm_state = item.getSeverity();
    gc.setBackground(color_provider.getColor(last_alarm_state));
    gc.fillRoundRectangle(0, 0, bounds.width, bounds.height, 10, 10);

    gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BORDER));
    gc.drawRoundRectangle(0, 0, bounds.width - 1, bounds.height - 1, 10, 10);

    // Draw Text
    gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
    final String label = item.getName();
    final Point extend = gc.textExtent(label);
    gc.drawString(label, (bounds.width - extend.x) / 2, (bounds.height - extend.y) / 2, true);
  }
Esempio n. 2
0
 /** If the alarm tree item has changed since the last redraw, refresh the display. */
 public void updateAlarmState() {
   if (item.getSeverity().equals(last_alarm_state)) return;
   redraw();
 }