예제 #1
0
  /**
   * {@inheritDoc} After the error is handled by its underlying {@link IEditErrorHandler}, the
   * configured error style will be applied to the editor control.
   */
  @Override
  public void displayError(ICellEditor cellEditor, Exception e) {
    super.displayError(cellEditor, e);

    if (!this.errorStylingActive) {
      Control editorControl = cellEditor.getEditorControl();

      // store the current rendering information to be able to reset again
      originalBgColor = editorControl.getBackground();
      originalFgColor = editorControl.getForeground();
      originalFont = editorControl.getFont();

      // set the rendering information out of the error style
      editorControl.setBackground(
          this.errorStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
      editorControl.setForeground(
          this.errorStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
      editorControl.setFont(this.errorStyle.getAttributeValue(CellStyleAttributes.FONT));

      if (decorationProvider != null) {
        decorationProvider.showDecoration();
      }

      this.errorStylingActive = true;
    }
  }
예제 #2
0
  /**
   * {@inheritDoc} After the error remove is handled by its underlying {@link IEditErrorHandler},
   * the original style will be applied to the editor control.
   */
  @Override
  public void removeError(ICellEditor cellEditor) {
    super.removeError(cellEditor);

    if (this.errorStylingActive) {
      Control editorControl = cellEditor.getEditorControl();

      // reset the rendering information to normal
      editorControl.setBackground(originalBgColor);
      editorControl.setForeground(originalFgColor);
      editorControl.setFont(originalFont);

      // ensure to reset the stored original values so possible
      // dynamic rendering aspects are also covered
      originalBgColor = null;
      originalFgColor = null;
      originalFont = null;

      if (decorationProvider != null) {
        decorationProvider.hideDecoration();
      }

      this.errorStylingActive = false;
    }
  }