Commit 0af5dbd6 authored by Lulu Luong's avatar Lulu Luong

variable assigment button moved to SequentOptionsMenu

Bug: model.getSelectedGoalNodeToShow().getAssignment() in SequentOptionsMenu is always empty
parent 00595db7
...@@ -148,6 +148,7 @@ public class InteractiveModeController { ...@@ -148,6 +148,7 @@ public class InteractiveModeController {
public void stop() { public void stop() {
Events.unregister(this); Events.unregister(this);
//TODO: casesstatement visiten
String c = getCasesAsString(); String c = getCasesAsString();
scriptController.getDockNode(scriptArea).undock(); scriptController.getDockNode(scriptArea).undock();
......
...@@ -2,6 +2,7 @@ package edu.kit.iti.formal.psdbg.gui.controls; ...@@ -2,6 +2,7 @@ package edu.kit.iti.formal.psdbg.gui.controls;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import edu.kit.iti.formal.psdbg.gui.model.InspectionModel;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData; import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment; import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
...@@ -12,6 +13,7 @@ import javafx.fxml.FXML; ...@@ -12,6 +13,7 @@ import javafx.fxml.FXML;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.stage.Stage; import javafx.stage.Stage;
import lombok.Setter;
import java.util.function.Function; import java.util.function.Function;
...@@ -22,13 +24,12 @@ public class GoalOptionsMenu extends ContextMenu { ...@@ -22,13 +24,12 @@ public class GoalOptionsMenu extends ContextMenu {
@FXML @FXML
private RadioMenuItem rmiShowSequent, rmiCFL, rmiCFS, rmiBranchLabels, rmiNodeNames, rmiRuleNames; private RadioMenuItem rmiShowSequent, rmiCFL, rmiCFS, rmiBranchLabels, rmiNodeNames, rmiRuleNames;
@FXML
private MenuItem showVarAssignment;
private ObjectProperty<ViewOption> selectedViewOption = new SimpleObjectProperty<>(); private ObjectProperty<ViewOption> selectedViewOption = new SimpleObjectProperty<>();
private BiMap<Toggle, ViewOption> optionMap = HashBiMap.create(6); private BiMap<Toggle, ViewOption> optionMap = HashBiMap.create(6);
public GoalOptionsMenu() { public GoalOptionsMenu() {
Utils.createWithFXML(this); Utils.createWithFXML(this);
...@@ -50,23 +51,7 @@ public class GoalOptionsMenu extends ContextMenu { ...@@ -50,23 +51,7 @@ public class GoalOptionsMenu extends ContextMenu {
selectedViewOption.setValue(ViewOption.SEQUENT); selectedViewOption.setValue(ViewOption.SEQUENT);
showVarAssignment.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Show Variable Assignment pressed");
//TODO: get var assign info
VariableAssignment varAssign = null;
Stage stage = new Stage();
stage.setTitle("Variable Assignment");
VariableAssignmentWindow vaw = new VariableAssignmentWindow(varAssign);
Scene scene = new Scene(vaw);
stage.setScene(scene);
stage.show();
}
});
} }
...@@ -78,9 +63,6 @@ public class GoalOptionsMenu extends ContextMenu { ...@@ -78,9 +63,6 @@ public class GoalOptionsMenu extends ContextMenu {
return selectedViewOption; return selectedViewOption;
} }
public void setSelectedViewOption(ViewOption selectedViewOption) {
this.selectedViewOption.set(selectedViewOption);
}
public enum ViewOption { public enum ViewOption {
BRANCHING(KeyData::getBranchingLabel), BRANCHING(KeyData::getBranchingLabel),
......
...@@ -2,6 +2,7 @@ package edu.kit.iti.formal.psdbg.gui.controls; ...@@ -2,6 +2,7 @@ package edu.kit.iti.formal.psdbg.gui.controls;
import edu.kit.iti.formal.psdbg.gui.model.InspectionModel; import edu.kit.iti.formal.psdbg.gui.model.InspectionModel;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData; import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
...@@ -16,6 +17,9 @@ public class SequentOptionsMenu extends ContextMenu { ...@@ -16,6 +17,9 @@ public class SequentOptionsMenu extends ContextMenu {
private final InspectionModel model; private final InspectionModel model;
@FXML @FXML
private MenuItem openSequentMatcher; private MenuItem openSequentMatcher;
@FXML
private MenuItem showVarAssignment;
public SequentOptionsMenu(InspectionModel model) { public SequentOptionsMenu(InspectionModel model) {
...@@ -58,6 +62,28 @@ public class SequentOptionsMenu extends ContextMenu { ...@@ -58,6 +62,28 @@ public class SequentOptionsMenu extends ContextMenu {
} }
}); });
showVarAssignment.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if(model == null || model.getSelectedGoalNodeToShow() == null) {
Utils.showInfoDialog("Select a goal", "Select a goal", "Please select a goal first.");
return;
}
VariableAssignment var_assignm = model.getSelectedGoalNodeToShow().getAssignments();
Stage stage = new Stage();
stage.setTitle("Variable Assignment");
VariableAssignmentWindow vaw = new VariableAssignmentWindow(var_assignm);
Scene scene = new Scene(vaw);
stage.setScene(scene);
stage.show();
}
});
} }
......
package edu.kit.iti.formal.psdbg.gui.controls; package edu.kit.iti.formal.psdbg.gui.controls;
import alice.tuprolog.Var;
import edu.kit.iti.formal.psdbg.gui.controls.Utils; import edu.kit.iti.formal.psdbg.gui.controls.Utils;
import edu.kit.iti.formal.psdbg.gui.model.InspectionModel;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment; import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView; import javafx.scene.control.TableView;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import lombok.Setter;
public class VariableAssignmentWindow extends BorderPane { public class VariableAssignmentWindow extends BorderPane {
@FXML @FXML
TableView tableView; TableView tableView;
@Setter
private InspectionModel model;
public VariableAssignmentWindow(VariableAssignment assignment) { public VariableAssignmentWindow(VariableAssignment assignment) {
Utils.createWithFXML(this); Utils.createWithFXML(this);
...@@ -23,14 +28,16 @@ public class VariableAssignmentWindow extends BorderPane { ...@@ -23,14 +28,16 @@ public class VariableAssignmentWindow extends BorderPane {
TableColumn valCol = new TableColumn("Value"); TableColumn valCol = new TableColumn("Value");
tableView.getColumns().addAll(varCol, typeCol, valCol); tableView.getColumns().addAll(varCol, typeCol, valCol);
if(assignment != null) {
//iterate over types map if (assignment != null) {
assignment.getTypes().forEach((k,v) -> { //iterate over types map
varCol.getColumns().add(k); assignment.getTypes().forEach((k, v) -> {
typeCol.getColumns().add(v); varCol.getColumns().add(k);
valCol.getColumns().add(assignment.getValue(k)); typeCol.getColumns().add(v);
}); valCol.getColumns().add(assignment.getValue(k));
} });
}
} }
} }
...@@ -52,4 +52,10 @@ cases{ ...@@ -52,4 +52,10 @@ cases{
impRight; impRight;
} }
auto; auto;
}
script varDecl(){
var1 : INT := 1;
var2 : INT := 2;
var3 : INT := 3;
} }
\ No newline at end of file
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
prefHeight="400.0" prefWidth="600.0" type="javafx.scene.control.ContextMenu"> prefHeight="400.0" prefWidth="600.0" type="javafx.scene.control.ContextMenu">
<items> <items>
<MenuItem fx:id="openSequentMatcher" text="Open Sequent Matcher"/> <MenuItem fx:id="openSequentMatcher" text="Open Sequent Matcher"/>
<MenuItem fx:id="showVarAssignment" text="Show Variable Assignment"/>
</items> </items>
</fx:root> </fx:root>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment