diff options
author | Dirk Fauth | 2014-10-20 18:34:40 +0000 |
---|---|---|
committer | Dirk Fauth | 2014-10-20 18:34:40 +0000 |
commit | ad26c6f7d89fdbe09ee9905cb538c160abb69996 (patch) | |
tree | ac72b728e9da25e58a0cab051fe4ee72dd2e74b0 | |
parent | 74f81ecce46550da4c5ae282250f5f930c1b2000 (diff) | |
download | org.eclipse.nebula.widgets.nattable-ad26c6f7d89fdbe09ee9905cb538c160abb69996.tar.gz org.eclipse.nebula.widgets.nattable-ad26c6f7d89fdbe09ee9905cb538c160abb69996.tar.xz org.eclipse.nebula.widgets.nattable-ad26c6f7d89fdbe09ee9905cb538c160abb69996.zip |
Bug 447974 - corrected RenderErrorHandling to update the error text on the decoration provider
-rw-r--r-- | org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/RenderErrorHandling.java | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/RenderErrorHandling.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/RenderErrorHandling.java index 88b95475..dca61f1b 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/RenderErrorHandling.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/RenderErrorHandling.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Original authors and others. + * Copyright (c) 2012, 2013, 2014 Original authors and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Original authors and others - initial API and implementation ******************************************************************************/ @@ -82,7 +82,7 @@ public class RenderErrorHandling extends AbstractEditErrorHandler { /** * Create a {@link RenderErrorHandling} with no underlying error handler and * the specified decoration provider. - * + * * @param decorationProvider * The decoration provider that should be used for decorating the * editor control on error. @@ -96,15 +96,15 @@ public class RenderErrorHandling extends AbstractEditErrorHandler { * and the specified decoration provider. By default the error style is set * to render the value in the editor control with red foreground color. You * can override that style by calling setErrorStyle(IStyle) - * + * * @param underlyingErrorHandler * The underlying error handler. * @param decorationProvider * The decoration provider that should be used for decorating the * editor control on error. */ - public RenderErrorHandling(IEditErrorHandler underlyingErrorHandler, - ControlDecorationProvider decorationProvider) { + public RenderErrorHandling( + IEditErrorHandler underlyingErrorHandler, ControlDecorationProvider decorationProvider) { super(underlyingErrorHandler); this.decorationProvider = decorationProvider; this.errorStyle = this.defaultErrorStyle; @@ -123,18 +123,19 @@ public class RenderErrorHandling extends AbstractEditErrorHandler { Control editorControl = cellEditor.getEditorControl(); // reset the rendering information to normal - editorControl.setBackground(originalBgColor); - editorControl.setForeground(originalFgColor); - editorControl.setFont(originalFont); + editorControl.setBackground(this.originalBgColor); + editorControl.setForeground(this.originalFgColor); + editorControl.setFont(this.originalFont); // ensure to reset the stored original values so possible // dynamic rendering aspects are also covered - originalBgColor = null; - originalFgColor = null; - originalFont = null; + this.originalBgColor = null; + this.originalFgColor = null; + this.originalFont = null; - if (decorationProvider != null) { - decorationProvider.hideDecoration(); + if (this.decorationProvider != null) { + this.decorationProvider.setErrorDecorationText(null); + this.decorationProvider.hideDecoration(); } this.errorStylingActive = false; @@ -154,24 +155,26 @@ public class RenderErrorHandling extends AbstractEditErrorHandler { Control editorControl = cellEditor.getEditorControl(); // store the current rendering information to be able to reset again - originalBgColor = editorControl.getBackground(); - originalFgColor = editorControl.getForeground(); - originalFont = editorControl.getFont(); + this.originalBgColor = editorControl.getBackground(); + this.originalFgColor = editorControl.getForeground(); + this.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(); - } + editorControl.setBackground( + this.errorStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR)); + editorControl.setForeground( + this.errorStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR)); + editorControl.setFont( + this.errorStyle.getAttributeValue(CellStyleAttributes.FONT)); this.errorStylingActive = true; } + + // we should always update the error decoration text + if (this.decorationProvider != null) { + this.decorationProvider.setErrorDecorationText(e.getLocalizedMessage()); + this.decorationProvider.showDecoration(); + } } /** @@ -181,8 +184,7 @@ public class RenderErrorHandling extends AbstractEditErrorHandler { * font. */ public void setErrorStyle(IStyle errorStyle) { - this.errorStyle = errorStyle != null ? errorStyle - : this.defaultErrorStyle; + this.errorStyle = errorStyle != null ? errorStyle : this.defaultErrorStyle; } } |