From 1d505095d8d3cd227a28ac6d2b1fec06380f632c Mon Sep 17 00:00:00 2001 From: "LULUDBR\\Lulu" Date: Wed, 20 Dec 2017 23:11:09 +0100 Subject: [PATCH] goal wrench added --- .../psdbg/gui/controls/SequentMatcher.java | 46 +++++++++++++++++-- .../psdbg/gui/controls/SequentMatcher.fxml | 22 ++++++--- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.java b/ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.java index 3d1a984f..6b1e7447 100644 --- a/ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.java +++ b/ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.java @@ -8,15 +8,16 @@ import edu.kit.iti.formal.psdbg.interpreter.data.KeyData; import edu.kit.iti.formal.psdbg.termmatcher.MatcherFacade; import edu.kit.iti.formal.psdbg.termmatcher.Matchings; import edu.kit.iti.formal.psdbg.termmatcher.mp.MatchPath; -import javafx.beans.property.ListProperty; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleListProperty; -import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.Observable; +import javafx.beans.property.*; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.control.TextArea; +import javafx.scene.input.MouseEvent; import javafx.scene.layout.BorderPane; import java.util.Collections; @@ -26,6 +27,8 @@ import java.util.Map; public class SequentMatcher extends BorderPane { + public GoalOptionsMenu goalOptionsMenu = new GoalOptionsMenu(); + @FXML private SequentView sequentView; @@ -43,6 +46,7 @@ public class SequentMatcher extends BorderPane { public SequentMatcher() { Utils.createWithFXML(this); + selectedGoalNodeToShow.addListener((observable, oldValue, newValue) -> { sequentView.setGoal(newValue.getData().getGoal()); sequentView.setNode(newValue.getData().getNode()); @@ -55,6 +59,9 @@ public class SequentMatcher extends BorderPane { selectedGoalNodeToShow.setValue(nnew) ); + goalView.setCellFactory(GoalNodeListCell::new); + + goals.addListener((observable, oldValue, newValue) -> goalView.setItems(newValue)); matchingsView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { @@ -90,6 +97,11 @@ public class SequentMatcher extends BorderPane { } } + public void showGoalOptions(MouseEvent actionEvent) { + Node n = (Node) actionEvent.getTarget(); + goalOptionsMenu.show(n, actionEvent.getScreenX(), actionEvent.getScreenY()); + } + public void startMatch() { Matchings matchings = MatcherFacade.matches(matchpattern.getText(), getSelectedGoalNodeToShow().getData().getNode().sequent(), true); ObservableList> resultlist = FXCollections.observableArrayList(matchings); @@ -152,6 +164,7 @@ public class SequentMatcher extends BorderPane { } + public void setSelectedGoalNodeToShow(GoalNode selectedGoalNodeToShow) { this.selectedGoalNodeToShow.set(selectedGoalNodeToShow); } @@ -172,4 +185,29 @@ public class SequentMatcher extends BorderPane { public void setMatchingresults(ObservableList> matchingresults) { this.matchingresults.set(matchingresults); } + + /** + * Cells for GoalView + */ + private class GoalNodeListCell extends ListCell> { + + public GoalNodeListCell(ListView> goalNodeListView) { + itemProperty().addListener(this::update); + goalOptionsMenu.selectedViewOptionProperty().addListener(this::update); + } + + private void update(Observable observable) { + if (getItem() == null) { + setText(""); + return; + } + KeyData item = getItem().getData(); + String text = "n/a"; + if (goalOptionsMenu.getSelectedViewOption() != null) { + text = goalOptionsMenu.getSelectedViewOption().getText(item); + } + //setStyle("-fx-font-size: 12pt;"); + setText(text); + } + } } diff --git a/ui/src/main/resources/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.fxml b/ui/src/main/resources/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.fxml index b51a0ad0..d2e68b0a 100644 --- a/ui/src/main/resources/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.fxml +++ b/ui/src/main/resources/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.fxml @@ -9,17 +9,27 @@ + +
- - + + + + +
+ + + +
+
-- GitLab