From 91daf95990bbbbccf3db75ff97be8e5411ccf1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20K=C3=BChn?= Date: Wed, 26 Jan 2022 15:04:32 +0100 Subject: [PATCH] Tried adding comboBox content --- .../src/main/java/main/OptionController.java | 25 +++++++++++++++++++ .../src/main/resources/main/option-view.fxml | 11 ++------ .../src/main/java/res/DataController.java | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/client/app/src/main/java/main/OptionController.java b/client/app/src/main/java/main/OptionController.java index 8601856..9059203 100644 --- a/client/app/src/main/java/main/OptionController.java +++ b/client/app/src/main/java/main/OptionController.java @@ -1,16 +1,24 @@ package main; import com.jfoenix.controls.*; +import helper.HttpRequestException; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Label; +import javafx.scene.layout.GridPane; import javafx.stage.Modality; import javafx.stage.Stage; +import res.DataController; +import res.User; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; public class OptionController { @@ -27,9 +35,26 @@ public class OptionController { public Label labelError; @FXML public JFXComboBox userCmb; + @FXML + public GridPane mainGrid; @FXML public void initialize(){ + DataController dataController = new DataController(); + List users; + try{ + users = dataController.getAllUser(); + } catch (HttpRequestException e){ + users = new ArrayList<>(); + } + + ObservableList observableUserList = FXCollections.observableArrayList(); + for (User user: users) { + observableUserList.add(user.getLogin()); + } + JFXComboBox comboBox = new JFXComboBox(observableUserList); + comboBox.getStyleClass().add("comboBox"); + mainGrid.add(comboBox, 2,2); } diff --git a/client/app/src/main/resources/main/option-view.fxml b/client/app/src/main/resources/main/option-view.fxml index 7e3edef..e54f1fc 100644 --- a/client/app/src/main/resources/main/option-view.fxml +++ b/client/app/src/main/resources/main/option-view.fxml @@ -3,12 +3,12 @@ - + prefHeight="400.0" prefWidth="600.0" +fx:id="mainGrid"> @@ -33,13 +33,6 @@ - - - - - - - User bearbeiten diff --git a/client/data/src/main/java/res/DataController.java b/client/data/src/main/java/res/DataController.java index 84d4076..181227e 100644 --- a/client/data/src/main/java/res/DataController.java +++ b/client/data/src/main/java/res/DataController.java @@ -138,7 +138,7 @@ public class DataController { * User * ********/ - public List getUser() throws HttpRequestException { + public List getAllUser() throws HttpRequestException { String userJSON = sendBasicHttpRequest( ALL_USER_ENDPOINT, "",