org.eclipse.nebula.widgets.nattable.edit.config
Class DialogErrorHandling

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.edit.editor.AbstractEditErrorHandler
      extended by org.eclipse.nebula.widgets.nattable.edit.config.DialogErrorHandling
All Implemented Interfaces:
IEditErrorHandler

public class DialogErrorHandling
extends AbstractEditErrorHandler

Strategy class for conversion/validation failures. If the entered value is not valid, a warning dialog with the corresponding error message will show up. The warning dialog gives the opportunity to discard the invalid input or change it, which will cause the editor to stay open. Only handles errors on commit.

Author:
Dirk Fauth

Field Summary
protected  boolean allowCommit
          Flag to configure if this dialog allows to commit invalid data.
protected  ICellEditor editor
          The ICellEditor for which this DialogErrorHandling is activated.
 
Fields inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractEditErrorHandler
underlyingErrorHandler
 
Constructor Summary
DialogErrorHandling()
          Create a new DialogErrorHandling with no underlying IEditErrorHandler that does not support cross validation.
DialogErrorHandling(boolean allowCommit)
          Create a new DialogErrorHandling with no underlying IEditErrorHandler that gives the opportunity to configure the error handling for cross validation.
DialogErrorHandling(IEditErrorHandler underlyingErrorHandler)
          Create a new DialogErrorHandling using the given IEditErrorHandler as the underlying to allow chaining of error handling.
DialogErrorHandling(IEditErrorHandler underlyingErrorHandler, boolean allowCommit)
          Create a new DialogErrorHandling using the given IEditErrorHandler as the underlying to allow chaining of error handling.
 
Method Summary
 void displayError(ICellEditor cellEditor, Exception e)
          If an error occurs on conversion/validation of data, this method will be called for showing that error to the user.
 String getChangeButtonLabel()
           
 String getConversionFailureShellTitle()
           
 String getDiscardButtonLabel()
           
 String getFailureShellTitle()
           
 String getValidationFailureShellTitle()
           
protected  boolean isWarningDialogActive()
          Checks if the current active Shell is a conversion/validation failure warning dialog.
 void setChangeButtonLabel(String changeButtonLabel)
           
 void setConversionFailureShellTitle(String conversionFailureShellTitle)
           
 void setDiscardButtonLabel(String discardButtonLabel)
           
 void setFailureShellTitle(String failureShellTitle)
           
 void setValidationFailureShellTitle(String validationFailureShellTitle)
           
protected  void showWarningDialog(String dialogMessage, String dialogTitle)
          Shows a warning dialog if the conversion or the validation returned an error message.
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractEditErrorHandler
removeError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

editor

protected ICellEditor editor
The ICellEditor for which this DialogErrorHandling is activated. Needed so it is possible to operate on it dependent on the users choice.


allowCommit

protected boolean allowCommit
Flag to configure if this dialog allows to commit invalid data. This is necessary to implement cross validation in NatTable by using dialogs to tell the user what is wrong. By default this value is set to false as cross validation is not the default validation use case.

Constructor Detail

DialogErrorHandling

public DialogErrorHandling()
Create a new DialogErrorHandling with no underlying IEditErrorHandler that does not support cross validation.


DialogErrorHandling

public DialogErrorHandling(boolean allowCommit)
Create a new DialogErrorHandling with no underlying IEditErrorHandler that gives the opportunity to configure the error handling for cross validation.

Parameters:
allowCommit - Flag to configure if this dialog allows to commit invalid data. If this parameter is set to true, an additional button for committing the invalid data will be provided within the dialog.

DialogErrorHandling

public DialogErrorHandling(IEditErrorHandler underlyingErrorHandler)
Create a new DialogErrorHandling using the given IEditErrorHandler as the underlying to allow chaining of error handling. Using this constructor there is no cross validation support.

Parameters:
underlyingErrorHandler - The underlying IEditErrorHandler

DialogErrorHandling

public DialogErrorHandling(IEditErrorHandler underlyingErrorHandler,
                           boolean allowCommit)
Create a new DialogErrorHandling using the given IEditErrorHandler as the underlying to allow chaining of error handling.

Parameters:
underlyingErrorHandler - The underlying IEditErrorHandler
allowCommit - Flag to configure if this dialog allows to commit invalid data. If this parameter is set to true, an additional button for committing the invalid data will be provided within the dialog.
Method Detail

displayError

public void displayError(ICellEditor cellEditor,
                         Exception e)
If an error occurs on conversion/validation of data, this method will be called for showing that error to the user. Usually the message contained within the given Exception will be shown to the user.

This implementation will call its underlying IEditErrorHandler. After the error is handled by its underlying IEditErrorHandler, a dialog will be opened showing the error message to the user, giving the opportunity to decide if the entered value should be discarded or if the editor should stay open so the value can be modified.

Specified by:
displayError in interface IEditErrorHandler
Overrides:
displayError in class AbstractEditErrorHandler
Parameters:
cellEditor - The ICellEditor on which the conversion/validation error occurred. Needed to add error styling or special handling.
e - The Exception that contains information about the conversion/validation error. Used to show a more detailed description on the error to the user.

showWarningDialog

protected void showWarningDialog(String dialogMessage,
                                 String dialogTitle)
Shows a warning dialog if the conversion or the validation returned an error message. Otherwise nothing happens.


isWarningDialogActive

protected boolean isWarningDialogActive()
Checks if the current active Shell is a conversion/validation failure warning dialog. As a Shell has not id it is checked if the Shell title is for conversion or validation failure in localized format.

Returns:
true if a warning dialog is active

getFailureShellTitle

public String getFailureShellTitle()
Returns:
The shell title that will be used if there is no conversion or validation shell title configured.

setFailureShellTitle

public void setFailureShellTitle(String failureShellTitle)
Parameters:
failureShellTitle - The shell title that should be used if there is no conversion or validation shell title configured.

getConversionFailureShellTitle

public String getConversionFailureShellTitle()
Returns:
The shell title that will be used in case this DialogErrorHandling is called to handle a ConversionFailedException.

setConversionFailureShellTitle

public void setConversionFailureShellTitle(String conversionFailureShellTitle)
Parameters:
conversionFailureShellTitle - The shell title that should be used in case this DialogErrorHandling is called to handle a ConversionFailedException.

getValidationFailureShellTitle

public String getValidationFailureShellTitle()
Returns:
The shell title that will be used in case this DialogErrorHandling is called to handle a ValidationFailedException.

setValidationFailureShellTitle

public void setValidationFailureShellTitle(String validationFailureShellTitle)
Parameters:
validationFailureShellTitle - The shell title that should be used in case this DialogErrorHandling is called to handle a ValidationFailedException.

getChangeButtonLabel

public String getChangeButtonLabel()
Returns:
The text on the button for changing the entered value.

setChangeButtonLabel

public void setChangeButtonLabel(String changeButtonLabel)
Parameters:
changeButtonLabel - The text on the button for changing the entered value.

getDiscardButtonLabel

public String getDiscardButtonLabel()
Returns:
The text on the button to discard the entered value.

setDiscardButtonLabel

public void setDiscardButtonLabel(String discardButtonLabel)
Parameters:
discardButtonLabel - The text on the button to discard the entered value.


Copyright © 2014. All rights reserved.