Commit a7bc41b8 authored by Alexander Weigl's avatar Alexander Weigl
Browse files

Diffing and UI improvements

parent 90894510
Pipeline #15062 failed with stage
in 1 minute and 49 seconds
......@@ -16,6 +16,8 @@ import edu.kit.iti.formal.psdbg.interpreter.exceptions.ScriptCommandNotApplicabl
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.key_project.util.collection.ImmutableList;
import java.util.HashMap;
......@@ -27,6 +29,8 @@ import java.util.Map;
*/
@RequiredArgsConstructor
public class RuleCommandHandler implements CommandHandler<KeyData> {
private static final Logger LOGGER = LogManager.getLogger(RuleCommandHandler.class);
@Getter
private final Map<String, Rule> rules;
......@@ -53,7 +57,7 @@ public class RuleCommandHandler implements CommandHandler<KeyData> {
KeyData kd = expandedNode.getData();
Map<String, String> map = new HashMap<>();
params.asMap().forEach((k, v) -> map.put(k.getIdentifier(), v.getData().toString()));
System.out.println(map);
LOGGER.info("Execute {} with {}", call, map);
try {
map.put("#2", call.getCommand());
EngineState estate = new EngineState(kd.getProof());
......
......@@ -19,10 +19,12 @@ import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.dbg.*;
import edu.kit.iti.formal.psdbg.parser.ast.ProofScript;
import javafx.application.Platform;
import javafx.beans.binding.BooleanBinding;
import javafx.collections.FXCollections;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
......@@ -76,6 +78,36 @@ public class DebuggerMain implements Initializable {
@FXML
private DockPane dockStation;
@FXML
private ToggleButton togBtnCommandHelp;
@FXML
private ToggleButton togBtnProofTree;
@FXML
private ToggleButton togBtnActiveInspector;
@FXML
private ToggleButton togBtnWelcome;
@FXML
private ToggleButton togBtnCodeDock;
@FXML
private CheckMenuItem miCommandHelp;
@FXML
private CheckMenuItem miCodeDock;
@FXML
private CheckMenuItem miWelcomeDock;
@FXML
private CheckMenuItem miActiveInspector;
@FXML
private CheckMenuItem miProofTree;
private JavaArea javaArea = new JavaArea();
private DockNode javaAreaDock = new DockNode(javaArea, "Java Source",
......@@ -135,6 +167,33 @@ public class DebuggerMain implements Initializable {
Utils.addDebugListener(model.executeNotPossibleProperty(), "executeNotPossible");
scriptController.mainScriptProperty().bindBidirectional(statusBar.mainScriptIdentifierProperty());
initializeExamples();
dockingNodeHandling(togBtnActiveInspector,
miActiveInspector,
activeInspectorDock,
DockPos.CENTER);
dockingNodeHandling(togBtnCodeDock,
miCodeDock,
javaAreaDock,
DockPos.RIGHT);
dockingNodeHandling(togBtnCommandHelp,
miCommandHelp,
commandHelpDock,
DockPos.RIGHT);
dockingNodeHandling(togBtnWelcome,
miWelcomeDock,
welcomePaneDock,
DockPos.CENTER);
dockingNodeHandling(togBtnProofTree,
miProofTree,
proofTreeDock,
DockPos.LEFT);
}
......@@ -254,6 +313,27 @@ public class DebuggerMain implements Initializable {
}
}
public void dockingNodeHandling(ToggleButton btn, CheckMenuItem cmi, DockNode dn, DockPos defaultPosition) {
BooleanBinding prop = dn.dockedProperty().or(dn.floatingProperty());
prop.addListener((p, o, n) -> {
btn.setSelected(n);
cmi.setSelected(n);
});
EventHandler<ActionEvent> handler = event -> {
if (!prop.get()) {
if (dn.getLastDockPos() != null)
dn.dock(dockStation, dn.getLastDockPos());
else
dn.dock(dockStation, defaultPosition);
} else {
dn.undock();
}
};
btn.setOnAction(handler);
cmi.setOnAction(handler);
}
@FXML
public void executeScript() {
executeScript(false);
......@@ -304,9 +384,9 @@ public class DebuggerMain implements Initializable {
if (FACADE.getProofState() == KeYProofFacade.ProofState.DIRTY) {
try {
FACADE.reload();
FACADE.reload(model.getKeyFile());
} catch (ProofInputException | ProblemLoaderException e) {
//TODO
LOGGER.error(e);
Utils.showExceptionDialog("Loading Error", "Could not clear Environment", "There was an error when clearing old environment",
e
);
......@@ -356,6 +436,7 @@ public class DebuggerMain implements Initializable {
model.setDebuggerFramework(df);
} catch (RecognitionException e) {
LOGGER.error(e);
Utils.showExceptionDialog("Antlr Exception", "", "Could not parse scripts.", e);
}
}
......@@ -389,6 +470,7 @@ public class DebuggerMain implements Initializable {
task.setOnFailed(event -> {
statusBar.stopProgress();
event.getSource().exceptionProperty().get();
Utils.showExceptionDialog("Could not load sourceName", "Key sourceName loading error", "",
(Throwable) event.getSource().exceptionProperty().get()
);
......@@ -490,6 +572,7 @@ public class DebuggerMain implements Initializable {
String code = FileUtils.readFileToString(scriptFile, Charset.defaultCharset());
ScriptArea area = scriptController.createNewTab(scriptFile);
} catch (IOException e) {
LOGGER.error(e);
Utils.showExceptionDialog("Exception occured", "",
"Could not load sourceName " + scriptFile, e);
}
......@@ -500,6 +583,7 @@ public class DebuggerMain implements Initializable {
try {
scriptController.saveCurrentScript();
} catch (IOException e) {
LOGGER.error(e);
Utils.showExceptionDialog("Could not save file", "Saving File Error", "Could not save current script", e);
}
......@@ -537,6 +621,7 @@ public class DebuggerMain implements Initializable {
try {
scriptController.saveCurrentScriptAs(scriptFile);
} catch (IOException e) {
LOGGER.error(e);
Utils.showExceptionDialog("Could not save file", "Saving File Error", "Could not save to file " + scriptFile.getName(), e);
}
}
......@@ -561,6 +646,7 @@ public class DebuggerMain implements Initializable {
public void stepOver(ActionEvent actionEvent) {
LOGGER.debug("DebuggerMain.stepOver");
try {
assert model.getDebuggerFramework() != null : "You should have started the prove";
model.getDebuggerFramework().execute(new StepOverCommand<>());
} catch (DebuggerException e) {
Utils.showExceptionDialog("", "", "", e);
......@@ -571,6 +657,7 @@ public class DebuggerMain implements Initializable {
/**
* Perform a step into
*
* @param actionEvent
*/
public void stepInto(ActionEvent actionEvent) {
......@@ -610,7 +697,7 @@ public class DebuggerMain implements Initializable {
@FXML
public void showWelcomeDock(ActionEvent actionEvent) {
if (!welcomePaneDock.isDocked()) {
if (!welcomePaneDock.isDocked() && !welcomePaneDock.isFloating()) {
welcomePaneDock.dock(dockStation, DockPos.CENTER);
}
}
......@@ -690,6 +777,7 @@ public class DebuggerMain implements Initializable {
FACADE.activateContract(result);
getInspectionViewsController().getActiveInspectionViewTab().getModel().getGoals().setAll(FACADE.getPseudoGoals());
} catch (ProofInputException e) {
LOGGER.error(e);
Utils.showExceptionDialog("", "", "", e);
}
});
......@@ -697,6 +785,7 @@ public class DebuggerMain implements Initializable {
@Override
protected void failed() {
LOGGER.error(exceptionProperty().get());
Utils.showExceptionDialog("", "", "", exceptionProperty().get());
}
......
......@@ -73,6 +73,7 @@ public class SequentView extends CodeArea {
hightlightRange(0, 0);
}
} catch (NullPointerException npe) {
npe.printStackTrace();
}
mouseEvent.consume();
}
......@@ -130,6 +131,7 @@ public class SequentView extends CodeArea {
Sequent sequent = node.get().sequent();
filter = new IdentitySequentPrintFilter();
filter.setSequent(sequent);
ProgramPrinter prgPrinter = new ProgramPrinter(new StringWriter());
this.backend = new LogicPrinter.PosTableStringBackend(80);
......
......@@ -3,8 +3,6 @@ script agascript() {
andLeft;
notLeft;
repeat { andLeft; }
andLeft;
andLeft;
andLeft;
......
......@@ -65,31 +65,31 @@
</Menu>
<Menu text="View">
<items>
<MenuItem onAction="#showCodeDock" text="Show Java Code window">
<CheckMenuItem fx:id="miCodeDock" onAction="#showCodeDock" text="Show Java Code window">
<graphic>
<MaterialDesignIconView glyphName="CODE_TAGS" size="24.0"/>
</graphic>
</MenuItem>
<MenuItem onAction="#showWelcomeDock" text="Show Welcome window">
</CheckMenuItem>
<CheckMenuItem fx:id="miWelcomeDock" onAction="#showWelcomeDock" text="Show Welcome window">
<graphic>
<MaterialDesignIconView glyphName="HELP_CIRCLE" size="24.0"/>
</graphic>
</MenuItem>
<MenuItem onAction="#showActiveInspector" text="Show Active Inspector window">
</CheckMenuItem>
<CheckMenuItem fx:id="miActiveInspector" onAction="#showActiveInspector" text="Show Active Inspector window">
<graphic>
<MaterialDesignIconView glyphName="MAGNIFY" size="24.0"/>
</graphic>
</MenuItem>
<MenuItem onAction="#showProofTree" text="Show Proof Tree">
</CheckMenuItem>
<CheckMenuItem fx:id="miProofTree" onAction="#showProofTree" text="Show Proof Tree">
<graphic>
<MaterialDesignIconView glyphName="TREE" size="24.0"/>
</graphic>
</MenuItem>
<MenuItem onAction="#showCommandHelp" text="Show Command Help">
</CheckMenuItem>
<CheckMenuItem fx:id="miCommandHelp" onAction="#showCommandHelp" text="Show Command Help">
<graphic>
<MaterialDesignIconView glyphName="STACKEXCHANGE" size="24.0"/>
</graphic>
</MenuItem>
</CheckMenuItem>
</items>
</Menu>
<Menu fx:id="examplesMenu" text="Examples">
......@@ -194,7 +194,7 @@
<Pane HBox.hgrow="ALWAYS"/>
<Label text="Windows:"/>
<ToggleButton onAction="#showCodeDock">
<ToggleButton fx:id="togBtnCodeDock" onAction="#showCodeDock">
<graphic>
<MaterialDesignIconView glyphName="CODE_TAGS" size="24.0"/>
</graphic>
......@@ -202,7 +202,7 @@
<Tooltip text="Shows the Java Source Code"/>
</tooltip>
</ToggleButton>
<ToggleButton onAction="#showWelcomeDock">
<ToggleButton fx:id="togBtnWelcome" onAction="#showWelcomeDock">
<graphic>
<MaterialDesignIconView glyphName="HELP_CIRCLE" size="24.0"/>
</graphic>
......@@ -210,7 +210,7 @@
<Tooltip text="Show Welcome window"/>
</tooltip>
</ToggleButton>
<ToggleButton onAction="#showActiveInspector">
<ToggleButton fx:id="togBtnActiveInspector" onAction="#showActiveInspector">
<graphic>
<MaterialDesignIconView glyphName="MAGNIFY" size="24.0"/>
</graphic>
......@@ -218,7 +218,7 @@
<Tooltip text="Show Active Inspector window"/>
</tooltip>
</ToggleButton>
<ToggleButton onAction="#showProofTree">
<ToggleButton fx:id="togBtnProofTree" onAction="#showProofTree">
<graphic>
<!-- FILE-TREE-->
<MaterialDesignIconView glyphName="TREE" size="24.0"/>
......@@ -227,7 +227,7 @@
<Tooltip text="Show Proof Tree"/>
</tooltip>
</ToggleButton>
<ToggleButton onAction="#showCommandHelp">
<ToggleButton fx:id="togBtnCommandHelp" onAction="#showCommandHelp">
<graphic>
<MaterialDesignIconView glyphName="STACKEXCHANGE" size="24.0"/>
</graphic>
......
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