Skip to content

Commit

Permalink
Merge branch 'quickCursorFix' into 'master'
Browse files Browse the repository at this point in the history
UI fixes

See merge request tdt4140-2018/02!45
  • Loading branch information
Eirik Dahlen committed Apr 16, 2018
2 parents 51534e3 + bd41066 commit 5583e47
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 156 deletions.
Original file line number Diff line number Diff line change
@@ -1,151 +1,162 @@
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();
}

}

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.Cursor;
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;

@FXML
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());
}

@FXML
public void homeScreenButtonCursorHand() {
homeScreenButton.setCursor(Cursor.HAND);
}
@FXML
public void homeScreenButtonCursorDefault() {
homeScreenButton.setCursor(Cursor.DEFAULT);
}


// 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();
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class AddWorkoutController {
@FXML
private TextField gpxField;

@FXML
private Button homeScreenButton;

private Database db;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
Expand Down Expand Up @@ -69,6 +70,9 @@ public String getUsername() {
@FXML
private Button btShowAthlete;

@FXML
private Button homeScreenButton;

private ObservableList<BarChart.Data<String, Number>> barChartSleepdata= FXCollections.observableArrayList();

@FXML
Expand Down Expand Up @@ -102,6 +106,16 @@ public void initialize(URL location, ResourceBundle resources) {
updateSleepdata(choosenAthlete) ;

}

@FXML
public void homeScreenButtonCursorHand() {
homeScreenButton.setCursor(Cursor.HAND);
}
@FXML
public void homeScreenButtonCursorDefault() {
homeScreenButton.setCursor(Cursor.DEFAULT);
}

/*
public void searchAthlete(ActionEvent event) {
choosenAthlete = db.getAthlete(cboxChooseAthlete.getValue().getUsername());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class FxAppController {
private Button btbSignUp;
@FXML
private Label txtLabelFeedback;
@FXML
private Label txtLoadingText;

private LoginScreenController loginScreenController = new LoginScreenController();
private SignUpScreenController signUpScreenController = new SignUpScreenController();
Expand Down Expand Up @@ -65,6 +67,11 @@ void loginButton(ActionEvent event) throws Exception {

// Check valid login and set TextAreaFeedback text
boolean validLogin = false;
System.out.println("shjfkldbv");
if (true) {
txtLoadingText.setText("Loading...");
}


// If-statements checking username and password
if (!loginScreenController.getLogin().checkUserNameExits(typedUsername)) {
Expand Down
Loading

0 comments on commit 5583e47

Please sign in to comment.