-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#95 Made UI for adding sleepdata. Also made a Add Sleepdata button in…
… the menu.
- Loading branch information
Frikk Hald Andersen
committed
Apr 7, 2018
1 parent
31dac00
commit 1f2d0c3
Showing
18 changed files
with
292 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
tdt4140-gr1802/app.ui/src/main/java/tdt4140/gr1802/app/ui/AddSleepdataController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package tdt4140.gr1802.app.ui; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
|
||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.fxml.LoadException; | ||
import javafx.scene.Node; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.CheckBox; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextField; | ||
import javafx.stage.Stage; | ||
import tdt4140.gr1802.app.core.App; | ||
import tdt4140.gr1802.app.core.Athlete; | ||
import tdt4140.gr1802.app.core.Database; | ||
import tdt4140.gr1802.app.core.Workout; | ||
|
||
public class AddSleepdataController { | ||
|
||
// Making variables for every element in the fxml-file | ||
|
||
@FXML | ||
private Button btAddSleepdata ; | ||
|
||
@FXML | ||
private Button btAddWorkout; | ||
|
||
@FXML | ||
private Button btSeeWorkouts; | ||
|
||
@FXML | ||
private Button btSeeCoaches; | ||
|
||
@FXML | ||
private Button btCoachRequests; | ||
|
||
@FXML | ||
private TextField filepathTextField; | ||
|
||
@FXML | ||
private Button addButton; | ||
|
||
@FXML | ||
private Label txtLabelUsername; | ||
|
||
@FXML | ||
private CheckBox checkBox; | ||
|
||
@FXML | ||
private TextField gpxField; | ||
|
||
private Button homeScreenButton; | ||
|
||
private Database db; | ||
|
||
private static App app; | ||
|
||
private static Athlete athlete; | ||
|
||
private boolean visibility; | ||
|
||
|
||
|
||
// Initialization method | ||
public void initialize() { | ||
athlete = app.getAthlete(); | ||
this.db = app.getDb(); | ||
|
||
// Set username label | ||
this.txtLabelUsername.setText(athlete.getUsername()); | ||
} | ||
|
||
|
||
// Method called when "Add" button clicked | ||
public void clickAddButton (ActionEvent event) throws IOException { | ||
// The text in the application is used as a filepath, adds workout to the DB | ||
String path = filepathTextField.getText(); | ||
URL filePath = new File(path).toURI().toURL(); | ||
athlete.addSleepData(filePath); | ||
db.addSleepData(athlete); | ||
} | ||
|
||
|
||
// Side-menu buttons | ||
public void clickAddWorkout (ActionEvent event) throws IOException, LoadException{ | ||
// Open new window | ||
Parent root = FXMLLoader.load(getClass().getResource("AddWorkout.fxml")); | ||
Scene scene = new Scene(root,1280,720); | ||
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow(); | ||
|
||
window.setScene(scene); | ||
window.show(); | ||
|
||
} | ||
|
||
public void clickSeeWorkouts (ActionEvent event) throws IOException{ | ||
Parent root = FXMLLoader.load(getClass().getResource("SeeWorkouts.fxml")); | ||
Scene scene = new Scene(root,1280,720); | ||
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow(); | ||
window.setScene(scene); | ||
window.show(); | ||
} | ||
|
||
public void clickSeeCoaches (ActionEvent event) throws IOException{ | ||
Parent root = FXMLLoader.load(getClass().getResource("SeeCoaches.fxml")); | ||
Scene scene = new Scene(root,1280,720); | ||
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow(); | ||
|
||
window.setScene(scene); | ||
window.show(); | ||
} | ||
|
||
public void clickCoachRequest (ActionEvent event) throws IOException{ | ||
Parent root = FXMLLoader.load(getClass().getResource("CoachRequests.fxml")); | ||
Scene scene = new Scene(root,1280,720); | ||
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow(); | ||
|
||
window.setScene(scene); | ||
window.show(); | ||
} | ||
|
||
|
||
public void backToHomeScreen(ActionEvent event) throws IOException{ | ||
Parent root = FXMLLoader.load(getClass().getResource("HomeScreenAthlete.fxml")); | ||
Scene scene = new Scene(root,1280,720); | ||
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow(); | ||
|
||
window.setScene(scene); | ||
window.show(); | ||
} | ||
|
||
public void clickAddSleepdata (ActionEvent event) throws IOException, LoadException{ | ||
// Open new window | ||
Parent root = FXMLLoader.load(getClass().getResource("AddSleepdata.fxml")); | ||
Scene scene = new Scene(root,1280,720); | ||
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow(); | ||
|
||
window.setScene(scene); | ||
window.show(); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tdt4140-gr1802/app.ui/src/main/java/tdt4140/gr1802/app/ui/Styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.button { | ||
-fx-font-weight: bold; | ||
} |
66 changes: 66 additions & 0 deletions
66
tdt4140-gr1802/app.ui/src/main/resources/tdt4140/gr1802/app/ui/AddSleepdata.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.CheckBox?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.SplitPane?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.effect.DropShadow?> | ||
<?import javafx.scene.image.Image?> | ||
<?import javafx.scene.image.ImageView?> | ||
<?import javafx.scene.layout.AnchorPane?> | ||
<?import javafx.scene.layout.Pane?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.shape.Line?> | ||
<?import javafx.scene.text.Font?> | ||
|
||
<AnchorPane prefHeight="720.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="tdt4140.gr1802.app.ui.AddSleepdataController"> | ||
<children> | ||
<ImageView fitHeight="75.0" fitWidth="181.0" layoutY="3.0" pickOnBounds="true" preserveRatio="true"> | ||
<image> | ||
<Image url="@Images/homescreen_pink.png" /> | ||
</image> | ||
<effect> | ||
<DropShadow /> | ||
</effect> | ||
</ImageView> | ||
<AnchorPane fx:id="logo" prefHeight="720.0" prefWidth="1280.0"> | ||
<children> | ||
<SplitPane layoutY="71.0" prefHeight="655.0" prefWidth="1280.0"> | ||
<items> | ||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="575.0" prefWidth="1280.0"> | ||
<children> | ||
<VBox layoutX="22.0" layoutY="64.0" prefHeight="104.0" prefWidth="107.0"> | ||
<children> | ||
<Button fx:id="btAddWorkout" mnemonicParsing="false" onAction="#clickAddWorkout" prefHeight="25.0" prefWidth="106.0" text="Add Workout" /> | ||
<Button fx:id="btSeeWorkouts" mnemonicParsing="false" onAction="#clickSeeWorkouts" prefHeight="25.0" prefWidth="106.0" text="See Workouts" /> | ||
<Button fx:id="btSeeCoaches" mnemonicParsing="false" onAction="#clickSeeCoaches" prefHeight="25.0" prefWidth="106.0" text="See Coaches" /> | ||
<Button fx:id="btCoachRequests" mnemonicParsing="false" onAction="#clickCoachRequest" prefHeight="25.0" prefWidth="106.0" text="Coach Requests" /> | ||
<Button fx:id="btAddSleepdata" mnemonicParsing="false" onAction="#clickAddSleepdata" prefHeight="25.0" prefWidth="106.0" text="Add Sleepdata" /> | ||
</children> | ||
</VBox> | ||
<Pane layoutX="159.0" prefHeight="655.0" prefWidth="1127.0"> | ||
<children> | ||
<TextField fx:id="filepathTextField" layoutX="29.0" layoutY="65.0" prefHeight="27.0" prefWidth="501.0" promptText="Enter CSV Filepath" /> | ||
<Button fx:id="addButton" layoutX="29.0" layoutY="188.0" mnemonicParsing="false" onAction="#clickAddButton" prefHeight="27.0" prefWidth="107.0" text="Add" /> | ||
</children></Pane> | ||
</children> | ||
</AnchorPane> | ||
</items> | ||
</SplitPane> | ||
<Label fx:id="txtLabelUsername" alignment="CENTER_RIGHT" contentDisplay="RIGHT" layoutX="1050.0" layoutY="30.0" prefHeight="18.0" prefWidth="175.0" textAlignment="RIGHT"> | ||
<font> | ||
<Font size="14.0" /> | ||
</font> | ||
</Label> | ||
</children></AnchorPane> | ||
<Line endX="1183.0" layoutX="97.0" layoutY="71.0" startX="-100.0" /> | ||
<Line endX="751.0" layoutX="-261.0" layoutY="402.0" rotate="270.0" startX="89.0" /> | ||
<Label layoutX="26.0" layoutY="17.0" prefHeight="42.0" prefWidth="143.0" text="It's Training" textFill="WHITE"> | ||
<font> | ||
<Font name="Century Gothic" size="23.0" /> | ||
</font> | ||
</Label> | ||
<Button fx:id="homeScreenButton" layoutX="23.0" layoutY="25.0" mnemonicParsing="false" onAction="#backToHomeScreen" opacity="0.0" prefHeight="27.0" prefWidth="136.0" text="Button" /> | ||
</children> | ||
</AnchorPane> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.