Skip to content

Commit

Permalink
Merge 4927adf into 2e9051c
Browse files Browse the repository at this point in the history
  • Loading branch information
alxkohh committed Oct 15, 2019
2 parents 2e9051c + 4927adf commit 2f5b37e
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 5 deletions.
17 changes: 17 additions & 0 deletions src/main/java/com/dukeacademy/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.dukeacademy.logic.commands.CommandResult;
import com.dukeacademy.logic.commands.exceptions.CommandException;
import com.dukeacademy.logic.parser.exceptions.ParseException;
import com.dukeacademy.model.solution.TestCase;
import com.dukeacademy.model.solution.TestCaseResult;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -37,6 +39,7 @@ public class MainWindow extends UiPart<Stage> {
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;
private Editor editorPanel;
private RunCodeResult runCodeResultPanel;

@FXML
private StackPane commandBoxPlaceholder;
Expand All @@ -56,6 +59,9 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private AnchorPane editorPlaceholder;

@FXML
private AnchorPane runCodeResultPlaceholder;

public MainWindow(Stage primaryStage, Logic logic) {
super(FXML, primaryStage);

Expand Down Expand Up @@ -128,6 +134,13 @@ void fillInnerParts() {

editorPanel = new Editor();
editorPlaceholder.getChildren().add(editorPanel.getRoot());

// Passing in sample test case and sample test case result into the constructor of RunCodeResult.
// The sample problem in this context is an adder function.
// Test case given is 1, 1. Expected result is 2, from 1 + 1.
runCodeResultPanel = new RunCodeResult(new TestCase("1, 1", "2"),
new TestCaseResult(false, "2", "3"));
runCodeResultPlaceholder.getChildren().add(runCodeResultPanel.getRoot());
}

/**
Expand Down Expand Up @@ -178,6 +191,10 @@ public Editor getEditorPanel() {
return editorPanel;
}

public RunCodeResult getRunCodeResultPanel() {
return runCodeResultPanel;
}

/**
* Executes the command and returns the result.
*
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/com/dukeacademy/ui/RunCodeResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.dukeacademy.ui;

import com.dukeacademy.model.solution.TestCase;
import com.dukeacademy.model.solution.TestCaseResult;

import javafx.fxml.FXML;
import javafx.scene.control.Label;

import javafx.scene.control.TitledPane;
import javafx.scene.layout.Region;


/**
* Controller class for run code result, an evaluation of user's code submission against the test cases specified by
* the question.
*/
public class RunCodeResult extends UiPart<Region> {
private static final String FXML = "RunCodeResult.fxml";

@FXML
private Label input;

@FXML
private Label expectedOutput;

@FXML
private Label userOutput;

@FXML
private TitledPane testCasePane;

public RunCodeResult(TestCase testCase, TestCaseResult testCaseResult) {
super(FXML);

String inputString = testCase.getInput();
input.setText(inputString);
String expectedOutputString = testCaseResult.getExpectedOutput();
expectedOutput.setText(expectedOutputString);
String actualOutputString = testCaseResult.getActualOutput();
userOutput.setText(actualOutputString);

String title = "title of test case pane";

if (testCaseResult.isSuccessful()) {
title = testCasePane.getText() + " (PASSED)";
} else {
title = testCasePane.getText() + " (FAILED)";
}

testCasePane.setText(title);
}
}
11 changes: 6 additions & 5 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@
<Insets left="10.0" />
</HBox.margin>
</StackPane>
<AnchorPane fx:id="editorPlaceholder" minHeight="-Infinity" minWidth="-Infinity" prefHeight="210.0" prefWidth="410.0" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets right="10.0" />
</HBox.margin>
</AnchorPane>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<AnchorPane fx:id="editorPlaceholder" minHeight="-Infinity" minWidth="-Infinity" prefHeight="210.0" prefWidth="410.0" />
<AnchorPane fx:id="runCodeResultPlaceholder" minHeight="-Infinity" minWidth="-Infinity" prefHeight="210.0" prefWidth="410.0" />
</children>
</VBox>
</children>
<VBox.margin>
<Insets left="5.0" />
Expand Down
126 changes: 126 additions & 0 deletions src/main/resources/view/RunCodeResult.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Accordion?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<Accordion fx:id="runCodeResultAccordion" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="410.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<panes>
<TitledPane fx:id="testCasePane" animated="false" text="Test Case 1">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox layoutX="14.0" layoutY="12.0" prefHeight="224.0" prefWidth="408.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane fx:id="input1" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="6.0" text="Input" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Consolas" size="12.0" />
</font>
</Label>
<Label fx:id="input" layoutY="34.0" prefHeight="17.0" prefWidth="387.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="14.0" prefHeight="17.0" prefWidth="164.0" text="Expected Output" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<Label fx:id="expectedOutput" layoutX="-3.0" layoutY="29.0" prefHeight="17.0" prefWidth="389.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="10.0" layoutY="112.0" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="59.0" layoutY="5.0" prefHeight="17.0" prefWidth="143.0" text="Your Output" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Consolas" size="12.0" />
</font>
</Label>
<Label fx:id="userOutput" layoutX="-7.0" layoutY="29.0" prefHeight="17.0" prefWidth="387.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
</children>
</VBox>
</children></AnchorPane>
</content>
</TitledPane>
<TitledPane fx:id="testCasePane1" animated="false" layoutX="10.0" layoutY="10.0" text="Test Case 2">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox layoutX="14.0" layoutY="12.0" prefHeight="224.0" prefWidth="408.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane fx:id="input11" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="6.0" text="Input" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Consolas" size="12.0" />
</font>
</Label>
<Label fx:id="input1" layoutY="34.0" prefHeight="17.0" prefWidth="387.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="14.0" prefHeight="17.0" prefWidth="164.0" text="Expected Output" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<Label fx:id="expectedOutput1" layoutX="-3.0" layoutY="29.0" prefHeight="17.0" prefWidth="389.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="10.0" layoutY="112.0" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="59.0" layoutY="5.0" prefHeight="17.0" prefWidth="143.0" text="Your Output" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Consolas" size="12.0" />
</font>
</Label>
<Label fx:id="userOutput1" layoutX="-7.0" layoutY="29.0" prefHeight="17.0" prefWidth="387.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane fx:id="testCasePane11" animated="false" layoutX="10.0" layoutY="35.0" text="Test Case 3">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox layoutX="14.0" layoutY="12.0" prefHeight="224.0" prefWidth="408.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane fx:id="input111" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="6.0" text="Input" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Consolas" size="12.0" />
</font>
</Label>
<Label fx:id="input11" layoutY="34.0" prefHeight="17.0" prefWidth="387.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="14.0" prefHeight="17.0" prefWidth="164.0" text="Expected Output" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<Label fx:id="expectedOutput11" layoutX="-3.0" layoutY="29.0" prefHeight="17.0" prefWidth="389.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="10.0" layoutY="112.0" prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="59.0" layoutY="5.0" prefHeight="17.0" prefWidth="143.0" text="Your Output" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Consolas" size="12.0" />
</font>
</Label>
<Label fx:id="userOutput11" layoutX="-7.0" layoutY="29.0" prefHeight="17.0" prefWidth="387.0" text=" " AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="34.0" />
</children>
</AnchorPane>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>

0 comments on commit 2f5b37e

Please sign in to comment.