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

Edit Info window has all of its textfields connected to its respective controller

parent 1bf929ea
No related branches found
No related tags found
No related merge requests found
Pipeline #8361 canceled
......@@ -24,6 +24,9 @@ public class EditInfoSceneController {
@FXML
private TextField serviceNameField;
@FXML
private TextField usernameField;
@FXML
private TextField editUsernameField;
......@@ -33,14 +36,15 @@ public class EditInfoSceneController {
@FXML
private void handleEdit(ActionEvent event) {
String platform = serviceNameField.getText();
String username = editUsernameField.getText();
String username = usernameField.getText();
String newUsername = editUsernameField.getText();
String newPassword = editPasswordField.getText();
try {
DataStorage ds = new DataStorage("master_login.json");
// Check if the service exists in the JSON file
Data existingData = ds.getData(platform, username);
Data existingData = ds.getData(platform, newUsername);
if (existingData == null) {
// If the service doesn't exist, show error alert
Alert alert = new Alert(Alert.AlertType.ERROR);
......@@ -52,7 +56,7 @@ public class EditInfoSceneController {
}
// If the service exists, proceed with updating the data
ds.updateData(platform, username, newPassword);
ds.updateData(platform, newUsername, newPassword);
ds.saveToJSON();
Alert alert = new Alert(Alert.AlertType.INFORMATION);
......
......@@ -12,7 +12,7 @@
<?import javafx.scene.paint.Stop?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="600.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.cpsc329pm.EditInfoSceneController">
<AnchorPane prefHeight="600.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.cpsc329pm.EditInfoSceneController">
<children>
<AnchorPane prefHeight="140.0" prefWidth="600.0" styleClass="backgroundColor" stylesheets="@EditInfo.css">
<children>
......@@ -100,7 +100,7 @@
</LinearGradient>
</textFill>
</Button>
<TextField layoutX="55.0" layoutY="312.0" prefHeight="26.0" prefWidth="477.0" promptText="Username for Credential Changes" />
<TextField fx:id="usernameField" layoutX="55.0" layoutY="312.0" prefHeight="26.0" prefWidth="477.0" promptText="Username for Credential Changes" />
<Label layoutX="81.0" layoutY="292.0" prefHeight="17.0" prefWidth="194.0" text="Username for Credential Changes" />
<ImageView fitHeight="26.0" fitWidth="30.0" layoutX="59.0" layoutY="286.0" pickOnBounds="true" preserveRatio="true">
<image>
......
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