try {
Locale locale = getSelectedLocale();
DBDateFormat dateFormat = getSelectedDateFormat();
DBNumberFormat numberFormat = getSelectedNumberFormat();
boolean customSettings = customPatternsRadioButton.isSelected();
Formatter formatter = null;
if (customSettings) {
try {
formatter = new Formatter(
locale,
customDateFormatTextField.getText(),
customTimeFormatTextField.getText(),
customNumberFormatTextField.getText());
errorLabel.setVisible(false);
} catch (Exception e) {
errorLabel.setText("Invalid pattern: " + e.getMessage());
errorLabel.setIcon(Icons.STMT_EXECUTION_ERROR);
errorLabel.setVisible(true);
}
} else {
formatter = new Formatter(locale, dateFormat, numberFormat);
customNumberFormatTextField.setText(formatter.getNumberFormatPattern());
customDateFormatTextField.setText(formatter.getDateFormatPattern());
customTimeFormatTextField.setText(formatter.getTimeFormatPattern());
}
if (formatter != null) {
datePreviewLabel.setText(formatter.formatDate(previewDate));
timePreviewLabel.setText(formatter.formatTime(previewDate));
numberPreviewLabel.setText(formatter.formatNumber(previewNumber));
integerPreviewLabel.setText(formatter.formatInteger(previewNumber));
}
shortRadioButton.setEnabled(!customSettings);
mediumRadioButton.setEnabled(!customSettings);
longRadioButton.setEnabled(!customSettings);