Skip to content

Commit

Permalink
Add functional GUI (#129)
Browse files Browse the repository at this point in the history
* Set up virtual tabs for modules

* Add files and tasks view on GUI
  • Loading branch information
rssujay authored Oct 24, 2019
1 parent 7cfeb5e commit 96d95a7
Show file tree
Hide file tree
Showing 14 changed files with 541 additions and 121 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ javafx {

application {
// Change this to your main class.
mainClassName = "spinbox.SpinBox"
mainClassName = "spinbox.gui.Launcher"
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion src/main/Resources/view/MainWindow.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-fx-pref-width: 250
}
.tab-header-background {
-fx-background-color:transparent
-fx-background-color:#25274D
}

.tab-pane > .tab-header-area > .headers-region > .tab > .tab-container > .tab-label {
Expand Down
117 changes: 66 additions & 51 deletions src/main/Resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,80 @@
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<?import javafx.scene.layout.HBox?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="spinbox.gui.MainWindow">
<children>
<GridPane prefHeight="750.0" prefWidth="1000.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="spinbox.gui.MainWindow" hgap="10.0" style="-fx-background-color: #464866">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="10.0" prefWidth="100.0"/>
</columnConstraints>

<TextField fx:id="userInput" layoutY="558.0" onAction="#handleUserInput" prefHeight="41.0" prefWidth="724.0" AnchorPane.bottomAnchor="1.0" />
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" percentHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>

<Button fx:id="sendButton" layoutX="724.0" layoutY="558.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="41.0" prefWidth="76.0" text="Send" />
<TabPane fx:id="tabPane" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE"
GridPane.columnSpan="3" GridPane.rowSpan="3">

<TabPane fx:id="tabPane" prefHeight="558.0" prefWidth="800.0" stylesheets="@MainWindow.css" tabClosingPolicy="UNAVAILABLE">
<tabs>
<!--Start of Main tab-->
<Tab text="Main">
<SplitPane dividerPositions="0.6525" prefHeight="492.0" prefWidth="800.0">
<ScrollPane fitToWidth="true" fitToHeight="true">
<VBox fx:id="overallTasksView" minHeight="0.0" minWidth="0.0" prefHeight="528.0"
prefWidth="515.0" style="-fx-background-color: #25274D">
<children>

<!--Start of Main tab-->
<Tab text="Main">
<content>
<SplitPane dividerPositions="0.6525" orientation="HORIZONTAL" prefHeight="492.0" prefWidth="800.0">
<items>
<ScrollPane>
<content>
<VBox fx:id="urgentTasks" minHeight="0.0" minWidth="0.0" prefHeight="528.0" prefWidth="515.0">
<children>
</children>
</VBox>
</ScrollPane>
<ScrollPane>
<VBox fx:id="examsList" minHeight="0.0" minWidth="0.0" prefHeight="511.0"
prefWidth="270.0">
<children>

</children>
</VBox>
</content>
</ScrollPane>
<ScrollPane>
<content>
<VBox fx:id="exams" minHeight="0.0" minWidth="0.0" prefHeight="511.0" prefWidth="270.0">
<children>
</children>
</VBox>
</content>
</ScrollPane>
</items>
</SplitPane>
</content>
</Tab>
<!--End of Main tab-->
</children>
</VBox>
</ScrollPane>
</SplitPane>
</Tab>
<!--End of Main tab-->

<!--Start of Calendar tab-->
<Tab text="Calendar">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<!--End of Calendar tab-->
<!--Start of Calendar tab-->
<Tab text="Calendar">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"/>
</Tab>
<!--End of Calendar tab-->

<!--Start of Modules tab-->
<Tab text="Modules">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
</content>
</Tab>
<!--End of Modules tab-->
<!--Start of Modules tab-->
<Tab text="Modules">
<GridPane fx:id="modulesTabContainer" style="-fx-background-color: #464866" >

</tabs>
</TabPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" percentWidth="25.0" />
<ColumnConstraints hgrow="SOMETIMES" percentWidth="75.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" percentHeight="10.0" />
<RowConstraints vgrow="SOMETIMES" percentHeight="90.0" />
</rowConstraints>
</GridPane>
</Tab>
<!--End of Modules tab-->

</children>
</AnchorPane>
</TabPane>

<Button fx:id="submitButton" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="41.0"
prefWidth="76.0" text="Send" GridPane.columnIndex="2" GridPane.rowIndex="3"/>

<TextField fx:id="userInput" onAction="#handleUserInput" prefHeight="41.0" prefWidth="724.0"
GridPane.columnSpan="2" GridPane.rowIndex="3"/>
</GridPane>
8 changes: 8 additions & 0 deletions src/main/Resources/view/ModuleListBox/ModuleListBox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#vBox-pane {
-fx-background-color: #2E9CCA;
}

#vBox-pane:hover {
-fx-background-color: #29648A;
-fx-cursor: hand;
}
15 changes: 15 additions & 0 deletions src/main/Resources/view/ModuleListBox/ModuleListBox.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>

<?import javafx.scene.text.Font?>

<fx:root xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml" type="javafx.scene.layout.VBox" stylesheets="@ModuleListBox.css"
id="vBox-pane">

<Label fx:id="moduleCodeLabel" />

<Label fx:id="moduleNameLabel" />

</fx:root>
12 changes: 12 additions & 0 deletions src/main/Resources/view/itemBoxes/FileBox.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.shape.Line?>

<fx:root maxHeight="-Infinity" maxWidth="1.7976931348623157E308" prefHeight="110.0" prefWidth="403.0" type="javafx.scene.layout.VBox" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="fileDetails" layoutX="16.0" layoutY="70.0" prefHeight="34.0" prefWidth="73.0" textAlignment="CENTER" wrapText="true" />
<Line endX="302.0" layoutX="101.0" layoutY="110.0" startX="-100.0" />
</children>
</fx:root>
File renamed without changes.
23 changes: 6 additions & 17 deletions src/main/java/spinbox/Main.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
package spinbox;

import spinbox.exceptions.DataReadWriteException;
import spinbox.exceptions.FileCreationException;
import spinbox.exceptions.InvalidIndexException;
import javafx.scene.layout.GridPane;
import spinbox.exceptions.SpinBoxException;
import spinbox.gui.MainWindow;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import java.io.IOException;

/**
* A GUI for SpinBox using FXML.
*/
public class Main extends Application {

private SpinBox spinBox = new SpinBox();

@Override
public void start(Stage stage) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml"));
AnchorPane ap = fxmlLoader.load();
Scene scene = new Scene(ap);
GridPane gridPane = fxmlLoader.load();
Scene scene = new Scene(gridPane);
stage.setScene(scene);
fxmlLoader.<MainWindow>getController().setUpMain(spinBox);
fxmlLoader.<MainWindow>getController().initializeGui();
stage.show();

} catch (IOException e) {
e.printStackTrace();
} catch (DataReadWriteException e) {
e.printStackTrace();
} catch (FileCreationException e) {
e.printStackTrace();
} catch (InvalidIndexException e) {
} catch (SpinBoxException | IOException e) {
e.printStackTrace();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/spinbox/commands/ViewCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public String execute(ModuleContainer moduleContainer, ArrayDeque<String> pageTr

if (guiMode) {
outputList.set(0, newTrace.toString());
return outputList.get(0);
} else {
outputList.set(0, "Changed from page "
+ oldTrace.toString() + " to " + newTrace.toString());
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/spinbox/containers/ModuleContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ public boolean checkModuleExists(String moduleCode) {
return this.getModules().containsKey(moduleCode);
}

/**
* Gets a specific module from within the container.
* @param moduleCode A string containing the module code to be used as the key.
* @return a Module object, or null if no such module exists.
*/
public Module getModule(String moduleCode) {
if (this.checkModuleExists(moduleCode)) {
return this.getModules().get(moduleCode);
} else {
return null;
}
}

/**
* Loads data using the localStorage instance from the relevant .txt file.
* @throws DataReadWriteException I/O error.
Expand Down
Loading

0 comments on commit 96d95a7

Please sign in to comment.