Skip to content
Snippets Groups Projects
Commit c1d5a757 authored by Syed OMAR's avatar Syed OMAR
Browse files

Added a new controller class for the view all services button

parent d1075f9d
No related branches found
No related tags found
No related merge requests found
Pipeline #8284 canceled
......@@ -53,7 +53,7 @@ public class MainPage {
@FXML
public void viewAllServices(ActionEvent event) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("ViewAllServicesScene.fxml"));
Parent root = FXMLLoader.load(getClass().getResource("StoredServices.fxml"));
stage = (Stage)((Node)event.getSource()).getScene().getWindow();
scene = new Scene(root);
stage.setScene(scene);
......
......@@ -86,7 +86,7 @@ public class MainPageController {
Stage currentStage = (Stage) ((Node) event.getSource()).getScene().getWindow();
// Load DeleteServiceScene.fxml
FXMLLoader loader = new FXMLLoader(getClass().getResource("ViewServicesScene.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("StoredServices.fxml"));
Parent root = loader.load();
// Create a new stage
......
package com.cpsc329pm;
import com.cpsc329pm.DataStorage;
import com.cpsc329pm.Data;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import java.util.List;
public class StoredServicesController {
@FXML private TableView<Data> tableView;
@FXML private TableColumn<Data, String> colService;
@FXML private TableColumn<Data, String> colUsername;
@FXML private TableColumn<Data, String> colPassword;
private final DataStorage dataStorage = new DataStorage(); // Assuming you have this class
@FXML
public void initialize() {
colService.setCellValueFactory(new PropertyValueFactory<>("platform"));
colUsername.setCellValueFactory(new PropertyValueFactory<>("username"));
colPassword.setCellValueFactory(new PropertyValueFactory<>("password"));
loadDataIntoTable();
}
private void loadDataIntoTable() {
dataStorage.loadFromJSON(); // Load data from file
List<Data> dataList = dataStorage.getAllData(); // Get list of data
ObservableList<Data> observableList = FXCollections.observableArrayList(dataList);
tableView.setItems(observableList);
}
}
......@@ -20,7 +20,7 @@
<Button fx:id="addServiceButton" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#handleAddService" prefHeight="51.0" prefWidth="136.0" style="-fx-border-color: black; -fx-border-width: 0px 0px 2px 0px;" styleClass="backgroundColor" stylesheets="@LoginScene-Pane.css" text="Add New Service" />
<Button fx:id="deleteServiceButton" layoutX="10.0" layoutY="61.0" mnemonicParsing="false" onAction="#handleDeleteService" prefHeight="51.0" prefWidth="136.0" style="-fx-border-color: black; -fx-border-width: 0px 0px 2px 0px;" styleClass="backgroundColor" stylesheets="@LoginScene-Pane.css" text="Delete Service" />
<Button layoutX="10.0" layoutY="112.0" mnemonicParsing="false" prefHeight="51.0" prefWidth="136.0" style="-fx-border-color: black; -fx-border-width: 0px 0px 2px 0px;" styleClass="backgroundColor" stylesheets="@LoginScene-Pane.css" text="Delete All Service" />
<Button layoutX="10.0" layoutY="163.0" mnemonicParsing="false" prefHeight="51.0" prefWidth="136.0" style="-fx-border-color: black; -fx-border-width: 0px 0px 2px 0px;" styleClass="backgroundColor" stylesheets="@LoginScene-Pane.css" text="View All services" />
<Button fx:id="viewServiceButton" layoutX="10.0" layoutY="163.0" mnemonicParsing="false" onAction="#viewAllServices" prefHeight="51.0" prefWidth="136.0" style="-fx-border-color: black; -fx-border-width: 0px 0px 2px 0px;" styleClass="backgroundColor" stylesheets="@LoginScene-Pane.css" text="View All services" />
<Button fx:id="editServiceButton" mnemonicParsing="false" onAction="#handleEditService" prefHeight="51.0" prefWidth="136.0" style="-fx-border-color: black; -fx-border-width: 0px 0px 2px 0px;" styleClass="backgroundColor" stylesheets="@LoginScene-Pane.css" text="Edit Info" />
</children>
</VBox>
......
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1">
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
<top>
<Label text="Stored Services" BorderPane.alignment="CENTER" />
<Label prefHeight="36.0" prefWidth="86.0" text="Stored Services" BorderPane.alignment="CENTER" />
</top>
<center>
<TableView prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<TableView fx:id="tableView" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<columns>
<TableColumn prefWidth="75.0" text="Service" />
<TableColumn prefWidth="75.0" text="Username" />
<TableColumn prefWidth="75.0" text="Password" />
<TableColumn prefWidth="75.0" text="Actions" />
<TableColumn fx:id="colNumber" prefWidth="60.0" text="Number" />
<TableColumn fx:id="colService" prefWidth="110.0" text="Service" />
<TableColumn fx:id="colUsername" prefWidth="101.0" text="Username" />
<TableColumn fx:id="colPassword" minWidth="0.0" prefWidth="327.0" text="Password" />
</columns>
</TableView>
</center>
<bottom>
<HBox prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<TextField text="Username" />
<PasswordField text="Password" />
<Button mnemonicParsing="false" prefHeight="26.0" prefWidth="140.0" text="Add New Service" />
<Button mnemonicParsing="false" prefHeight="26.0" prefWidth="189.0" text="Delete Service" />
</children>
</HBox>
</bottom>
</BorderPane>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment