WidgetUtils.addToGridBag(_expressionNameField, formPanel, 1, row);
row++;
WidgetUtils.addToGridBag(DCLabel.bright("Expression:"), formPanel, 0, row);
_expressionField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
checkInputFields();
}
public void insertUpdate(DocumentEvent e) {
checkInputFields();
}
public void removeUpdate(DocumentEvent e) {
checkInputFields();
}
});
WidgetUtils.addToGridBag(_expressionField, formPanel, 1, row);
_resetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
_expressionField.setText(_expressionString);
}
});
WidgetUtils.addToGridBag(_resetButton, formPanel, 2, row);
row++;
_saveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String expressionName = _expressionNameField.getText();
if (StringUtils.isNullOrEmpty(expressionName)) {
JOptionPane.showMessageDialog(RegexStringPatternDialog.this,
"Please fill out the name of the regular expression");
return;
}
String expression = _expressionField.getText();
if (StringUtils.isNullOrEmpty(expression)) {
JOptionPane.showMessageDialog(RegexStringPatternDialog.this, "Please fill out the regular expression");
return;
}
if (_regexStringPattern != null && _catalog.containsStringPattern(_regexStringPattern.getName())) {
_catalog.removeStringPattern(_catalog.getStringPattern(_regexStringPattern.getName()));
}
RegexStringPattern regexStringPattern = new RegexStringPattern(expressionName, expression, true);
_regexStringPattern = regexStringPattern;
_catalog.addStringPattern(regexStringPattern);
RegexStringPatternDialog.this.dispose();
}
});
final DCPanel buttonPanel = new DCPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
buttonPanel.add(_saveButton);
WidgetUtils.addToGridBag(buttonPanel, formPanel, 0, row, 2, 1);
final DCPanel testitPanel = new DCPanel();
testitPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
_errorLabel = DCLabel.bright("");
WidgetUtils.addToGridBag(_errorLabel, testitPanel, 0, row);
row++;
JLabel testInputLabel = DCLabel.bright("Test input");
testInputLabel.setIcon(imageManager.getImageIcon("images/actions/test-pattern.png"));
testInputLabel.setFont(WidgetUtils.FONT_HEADER1);
WidgetUtils.addToGridBag(testInputLabel, testitPanel, 0, row);
_inputFields = new ArrayList<JTextField>(NUM_TEST_FIELDS);
_statusLabels = new ArrayList<JLabel>(NUM_TEST_FIELDS);
for (int i = 0; i < NUM_TEST_FIELDS; i++) {
final int index = i;
JTextField inputField = WidgetFactory.createTextField("Test Input");
inputField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
checkInputField(index);
}
public void insertUpdate(DocumentEvent e) {