Class DialogErrorHandling
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.edit.editor.AbstractEditErrorHandler
-
- 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.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allowCommit
Flag to configure if this dialog allows to commit invalid data.protected ICellEditor
editor
TheICellEditor
for which thisDialogErrorHandling
is activated.-
Fields inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractEditErrorHandler
underlyingErrorHandler
-
-
Constructor Summary
Constructors Constructor Description DialogErrorHandling()
Create a newDialogErrorHandling
with no underlyingIEditErrorHandler
that does not support cross validation.DialogErrorHandling(boolean allowCommit)
Create a newDialogErrorHandling
with no underlyingIEditErrorHandler
that gives the opportunity to configure the error handling for cross validation.DialogErrorHandling(IEditErrorHandler underlyingErrorHandler)
Create a newDialogErrorHandling
using the givenIEditErrorHandler
as the underlying to allow chaining of error handling.DialogErrorHandling(IEditErrorHandler underlyingErrorHandler, boolean allowCommit)
Create a newDialogErrorHandling
using the givenIEditErrorHandler
as the underlying to allow chaining of error handling.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
getCommitButtonLabel()
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
setCommitButtonLabel(String commitButtonLabel)
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
displayError, removeError
-
-
-
-
Field Detail
-
editor
protected ICellEditor editor
TheICellEditor
for which thisDialogErrorHandling
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 tofalse
as cross validation is not the default validation use case.
-
-
Constructor Detail
-
DialogErrorHandling
public DialogErrorHandling()
Create a newDialogErrorHandling
with no underlyingIEditErrorHandler
that does not support cross validation.
-
DialogErrorHandling
public DialogErrorHandling(boolean allowCommit)
Create a newDialogErrorHandling
with no underlyingIEditErrorHandler
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 totrue
, an additional button for committing the invalid data will be provided within the dialog.
-
DialogErrorHandling
public DialogErrorHandling(IEditErrorHandler underlyingErrorHandler)
Create a newDialogErrorHandling
using the givenIEditErrorHandler
as the underlying to allow chaining of error handling. Using this constructor there is no cross validation support.- Parameters:
underlyingErrorHandler
- The underlyingIEditErrorHandler
-
DialogErrorHandling
public DialogErrorHandling(IEditErrorHandler underlyingErrorHandler, boolean allowCommit)
Create a newDialogErrorHandling
using the givenIEditErrorHandler
as the underlying to allow chaining of error handling.- Parameters:
underlyingErrorHandler
- The underlyingIEditErrorHandler
allowCommit
- Flag to configure if this dialog allows to commit invalid data. If this parameter is set totrue
, 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 givenException
will be shown to the user.This implementation will call its underlying
IEditErrorHandler
. After the error is handled by its underlyingIEditErrorHandler
, 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 interfaceIEditErrorHandler
- Overrides:
displayError
in classAbstractEditErrorHandler
- Parameters:
cellEditor
- TheICellEditor
on which the conversion/validation error occurred. Needed to add error styling or special handling.e
- TheException
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.- Parameters:
dialogMessage
- the dialog messagedialogTitle
- the dialog title
-
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 aConversionFailedException
.
-
setConversionFailureShellTitle
public void setConversionFailureShellTitle(String conversionFailureShellTitle)
- Parameters:
conversionFailureShellTitle
- The shell title that should be used in case thisDialogErrorHandling
is called to handle aConversionFailedException
.
-
getValidationFailureShellTitle
public String getValidationFailureShellTitle()
- Returns:
- The shell title that will be used in case this
DialogErrorHandling
is called to handle aValidationFailedException
.
-
setValidationFailureShellTitle
public void setValidationFailureShellTitle(String validationFailureShellTitle)
- Parameters:
validationFailureShellTitle
- The shell title that should be used in case thisDialogErrorHandling
is called to handle aValidationFailedException
.
-
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.
-
getCommitButtonLabel
public String getCommitButtonLabel()
- Returns:
- The text on the button to commit the entered value.
- Since:
- 1.4
-
setCommitButtonLabel
public void setCommitButtonLabel(String commitButtonLabel)
- Parameters:
commitButtonLabel
- The text on the button to commit the entered value.- Since:
- 1.4
-
-