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 {
public void stop() {
Events.unregister(this);
//TODO: casesstatement visiten
String c = getCasesAsString();
scriptController.getDockNode(scriptArea).undock();
......
......@@ -2,6 +2,7 @@ package edu.kit.iti.formal.psdbg.gui.controls;
import com.google.common.collect.BiMap;
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.VariableAssignment;
import javafx.beans.property.ObjectProperty;
......@@ -12,6 +13,7 @@ import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;
import lombok.Setter;
import java.util.function.Function;
......@@ -22,13 +24,12 @@ public class GoalOptionsMenu extends ContextMenu {
@FXML
private RadioMenuItem rmiShowSequent, rmiCFL, rmiCFS, rmiBranchLabels, rmiNodeNames, rmiRuleNames;
@FXML
private MenuItem showVarAssignment;
private ObjectProperty<ViewOption> selectedViewOption = new SimpleObjectProperty<>();
private BiMap<Toggle, ViewOption> optionMap = HashBiMap.create(6);
public GoalOptionsMenu() {
Utils.createWithFXML(this);
......@@ -50,23 +51,7 @@ public class GoalOptionsMenu extends ContextMenu {
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 {
return selectedViewOption;
}
public void setSelectedViewOption(ViewOption selectedViewOption) {
this.selectedViewOption.set(selectedViewOption);
}
public enum ViewOption {
BRANCHING(KeyData::getBranchingLabel),
......
......@@ -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.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
......@@ -16,6 +17,9 @@ public class SequentOptionsMenu extends ContextMenu {
private final InspectionModel model;
@FXML
private MenuItem openSequentMatcher;
@FXML
private MenuItem showVarAssignment;
public SequentOptionsMenu(InspectionModel model) {
......@@ -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;
import alice.tuprolog.Var;
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 javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.BorderPane;
import lombok.Setter;
public class VariableAssignmentWindow extends BorderPane {
@FXML
TableView tableView;
@Setter
private InspectionModel model;
public VariableAssignmentWindow(VariableAssignment assignment) {
Utils.createWithFXML(this);
......@@ -23,14 +28,16 @@ public class VariableAssignmentWindow extends BorderPane {
TableColumn valCol = new TableColumn("Value");
tableView.getColumns().addAll(varCol, typeCol, valCol);
if(assignment != null) {
//iterate over types map
assignment.getTypes().forEach((k,v) -> {
varCol.getColumns().add(k);
typeCol.getColumns().add(v);
valCol.getColumns().add(assignment.getValue(k));
});
}
if (assignment != null) {
//iterate over types map
assignment.getTypes().forEach((k, v) -> {
varCol.getColumns().add(k);
typeCol.getColumns().add(v);
valCol.getColumns().add(assignment.getValue(k));
});
}
}
}
......@@ -52,4 +52,10 @@ cases{
impRight;
}
auto;
}
script varDecl(){
var1 : INT := 1;
var2 : INT := 2;
var3 : INT := 3;
}
\ No newline at end of file
......@@ -6,5 +6,6 @@
prefHeight="400.0" prefWidth="600.0" type="javafx.scene.control.ContextMenu">
<items>
<MenuItem fx:id="openSequentMatcher" text="Open Sequent Matcher"/>
<MenuItem fx:id="showVarAssignment" text="Show Variable Assignment"/>
</items>
</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