Skip to content

Commit

Permalink
Merge pull request #13187 from danielb987/FixLogixNGBug
Browse files Browse the repository at this point in the history
Proper validation when editing LogixNG actions and expressions
  • Loading branch information
bobjacobsen committed Jun 19, 2024
2 parents 7bc2892 + d7316a8 commit 405f996
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean validate(@Nonnull List<String> errorMessages) {
// Create a temporary action to test formula
ActionPower action = new ActionPower("IQDA1", null);
_selectEnumSwing.validate(action.getSelectEnum(), errorMessages);
return true;
return errorMessages.isEmpty();
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ public boolean validate(@Nonnull List<String> errorMessages) {
errorMessages.add("Cannot parse formula: " + e.getMessage());
return false;
}
return true;

return errorMessages.isEmpty();
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ protected void createPanel(@CheckForNull Base object, @Nonnull JPanel buttonPane
public boolean validate(@Nonnull List<String> errorMessages) {
_beginMinutes = validateTime(errorMessages, _beginTextField);
_endMinutes = validateTime(errorMessages, _endTextField);

if (!errorMessages.isEmpty()) return false;
return true;
return errorMessages.isEmpty();
}

private int validateTime(List<String> errorMessages, JTextField timeField) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ public boolean validate(@Nonnull List<String> errorMessages) {
try {
if (_tabbedPaneLightState.getSelectedComponent() == _panelLightStateReference) {
expression.setStateReference(_lightStateReferenceTextField.getText());
} else if (_tabbedPaneLightState.getSelectedComponent() == _panelLightStateFormula) {
expression.setStateAddressing(NamedBeanAddressing.Formula);
expression.setStateFormula(_lightStateFormulaTextField.getText());
}
} catch (IllegalArgumentException e) {
} catch (IllegalArgumentException | ParserException e) {
errorMessages.add(e.getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ public boolean validate(@Nonnull List<String> errorMessages) {
try {
if (_tabbedPaneTurnoutState.getSelectedComponent() == _panelTurnoutStateReference) {
expression.setStateReference(_turnoutStateReferenceTextField.getText());
} else if (_tabbedPaneTurnoutState.getSelectedComponent() == _panelTurnoutStateFormula) {
expression.setStateAddressing(NamedBeanAddressing.Formula);
expression.setStateFormula(_turnoutStateFormulaTextField.getText());
}
} catch (IllegalArgumentException e) {
} catch (IllegalArgumentException | ParserException e) {
errorMessages.add(e.getMessage());
}

Expand Down

0 comments on commit 405f996

Please sign in to comment.