Skip to content

Commit

Permalink
Use action handler (#4726)
Browse files Browse the repository at this point in the history
* Use actionHandler to update fields

* Add actionHandler

* Add imports

* Final fixes
  • Loading branch information
abepolk authored and tobiasdiez committed Mar 8, 2019
1 parent c16f733 commit 0a0f4f9
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/main/java/org/jabref/gui/groups/GroupDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Node;
Expand Down Expand Up @@ -329,21 +330,16 @@ groupName, getContext(),
return null;
});

ChangeListener<String> caretListener = (ObservableValue<? extends String> ov, String oldValue,
String newValue) -> updateComponents();
ChangeListener<Boolean> itemListener = (ObservableValue<? extends Boolean> ov, Boolean oldBoolean,
Boolean newBoolean) -> updateComponents();

nameField.textProperty().addListener(caretListener);
descriptionField.textProperty().addListener(caretListener);
iconField.textProperty().addListener(caretListener);
keywordGroupSearchField.textProperty().addListener(caretListener);
keywordGroupSearchTerm.textProperty().addListener(caretListener);
keywordGroupCaseSensitive.selectedProperty().addListener(itemListener);
keywordGroupRegExp.selectedProperty().addListener(itemListener);
searchGroupSearchExpression.textProperty().addListener(caretListener);
searchGroupRegExp.selectedProperty().addListener(itemListener);
searchGroupRegExp.selectedProperty().addListener(itemListener);
EventHandler<ActionEvent> actionHandler = (ActionEvent e) -> updateComponents();
nameField.setOnAction(actionHandler);
descriptionField.setOnAction(actionHandler);
iconField.setOnAction(actionHandler);
keywordGroupSearchField.setOnAction(actionHandler);
keywordGroupSearchTerm.setOnAction(actionHandler);
keywordGroupCaseSensitive.setOnAction(actionHandler);
keywordGroupRegExp.setOnAction(actionHandler);
searchGroupSearchExpression.setOnAction(actionHandler);
searchGroupRegExp.setOnAction(actionHandler);

// configure for current type
if (editedGroup == null) {
Expand Down

0 comments on commit 0a0f4f9

Please sign in to comment.