ADD:: logout button
This commit is contained in:
@@ -26,6 +26,7 @@ import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import javafx.util.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.stereotype.Controller;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Class that controls the dashboard fxml file (the GUI Screen).
|
||||
@@ -70,6 +72,8 @@ public class DashBoardController {
|
||||
@FXML
|
||||
private Button friendsButton;
|
||||
@FXML
|
||||
private Button logOutButton;
|
||||
@FXML
|
||||
private Line pathLine;
|
||||
@FXML
|
||||
private AnchorPane menuBar;
|
||||
@@ -197,7 +201,7 @@ public class DashBoardController {
|
||||
activitiesButton.setSkin(new MyButtonSkin(activitiesButton));
|
||||
userButton.setSkin(new MyButtonSkin(userButton));
|
||||
friendsButton.setSkin(new MyButtonSkin(friendsButton));
|
||||
|
||||
logOutButton.setSkin(new MyButtonSkin(logOutButton));
|
||||
friendsColumn.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
scoreColumn.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
globalUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
@@ -403,6 +407,33 @@ public class DashBoardController {
|
||||
updateFriends();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the user
|
||||
* @param event the event (clicking the button)
|
||||
* @throws IOException if the Application doesn't load.
|
||||
*/
|
||||
public void logOut(ActionEvent event) throws IOException {
|
||||
//get the current window
|
||||
Window owner = logOutButton.getScene().getWindow();
|
||||
Stage current = (Stage) owner;
|
||||
//close current window (log out)
|
||||
current.close();
|
||||
System.out.println("User is logged out");
|
||||
|
||||
//load the fxml file
|
||||
Parent dash = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/LoginWindow.fxml"));
|
||||
Scene scene = new Scene(dash);
|
||||
//add the stylesheet for the CSS
|
||||
scene.getStylesheets().add(Objects.requireNonNull(getClass().getClassLoader()
|
||||
.getResource("stylesheets/LoginWindowStyle.css")).toExternalForm());
|
||||
Stage appStage = new Stage();
|
||||
appStage.setScene(scene);
|
||||
//set the title
|
||||
appStage.setTitle("Greenify");
|
||||
appStage.show();
|
||||
}
|
||||
|
||||
//sets the slide in transition for startup
|
||||
public void addSlideTransition(Node node, Line path1) {
|
||||
PathTransition pathTrans = new PathTransition(Duration.millis(1100), path1, node);
|
||||
|
||||
@@ -44,6 +44,11 @@
|
||||
<Font size="21.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<Button fx:id="logOutButton" layoutY="270.0" mnemonicParsing="false" onAction="#logOut" prefHeight="45.0" prefWidth="216.0" text="log out ">
|
||||
<font>
|
||||
<Font size="21.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<Line endX="104.0" layoutX="102.0" layoutY="133.0" scaleY="0.7" startX="-100.0" stroke="#e3ffe8" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" />
|
||||
<Line endX="104.0" layoutX="105.0" layoutY="178.0" scaleY="0.7" startX="-100.0" stroke="#e3ffe8" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" />
|
||||
<Line endX="104.0" layoutX="109.0" layoutY="223.0" startX="-100.0" stroke="#e3ffe8" strokeWidth="0.7" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" />
|
||||
|
||||
@@ -47,6 +47,15 @@
|
||||
#friendsButton:pressed {
|
||||
-fx-background-color: #b7e2c2;
|
||||
}
|
||||
#logOutButton {
|
||||
-fx-background-color: #5a635c;
|
||||
}
|
||||
#logOutButton:hover {
|
||||
-fx-background-color: #677069;
|
||||
}
|
||||
#logOutButton:pressed {
|
||||
-fx-background-color: #b7e2c2;
|
||||
}
|
||||
|
||||
|
||||
#addNewActivityButton:pressed {
|
||||
|
||||
Reference in New Issue
Block a user