From cb95c40ad690aa38095abd003fb80319790c0f1f Mon Sep 17 00:00:00 2001 From: DieGurke Date: Thu, 20 Aug 2020 11:02:51 +0200 Subject: [PATCH 01/23] Initial commit --- .../src/main/java/envoy/client/ui/controller/ChatScene.java | 4 ++++ client/src/main/resources/fxml/ChatScene.fxml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/envoy/client/ui/controller/ChatScene.java b/client/src/main/java/envoy/client/ui/controller/ChatScene.java index 173784f..707803c 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -27,6 +27,7 @@ import javafx.scene.image.ImageView; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.layout.GridPane; +import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.FileChooser; @@ -119,6 +120,9 @@ public final class ChatScene implements Restorable { @FXML private TextArea contactSearch; + + @FXML + private VBox contactOperations; private LocalDB localDB; private Client client; diff --git a/client/src/main/resources/fxml/ChatScene.fxml b/client/src/main/resources/fxml/ChatScene.fxml index 5bf8cd1..99afa30 100644 --- a/client/src/main/resources/fxml/ChatScene.fxml +++ b/client/src/main/resources/fxml/ChatScene.fxml @@ -30,7 +30,7 @@ - + From 1fe83dbcc05942fd3000d25800d3aa33827d5280 Mon Sep 17 00:00:00 2001 From: DieGurke Date: Sat, 22 Aug 2020 21:02:49 +0200 Subject: [PATCH 02/23] Implemented TabPane and done preparation for internal file loading --- .../java/envoy/client/ui/SceneContext.java | 17 +-- .../envoy/client/ui/controller/ChatScene.java | 18 ++- client/src/main/resources/fxml/ChatScene.fxml | 141 ++++++++++-------- client/src/main/resources/fxml/Test.fxml | 10 ++ 4 files changed, 109 insertions(+), 77 deletions(-) create mode 100644 client/src/main/resources/fxml/Test.fxml diff --git a/client/src/main/java/envoy/client/ui/SceneContext.java b/client/src/main/java/envoy/client/ui/SceneContext.java index a7ab403..c221d36 100644 --- a/client/src/main/java/envoy/client/ui/SceneContext.java +++ b/client/src/main/java/envoy/client/ui/SceneContext.java @@ -1,6 +1,7 @@ package envoy.client.ui; import java.io.IOException; +import java.net.URL; import java.util.Stack; import java.util.logging.Level; @@ -54,13 +55,6 @@ public final class SceneContext { */ SETTINGS_SCENE("/fxml/SettingsScene.fxml"), - /** - * The scene in which the contact search screen is displayed. - * - * @since Envoy Client v0.1-beta - */ - CONTACT_SEARCH_SCENE("/fxml/ContactSearchScene.fxml"), - /** * The scene in which the group creation screen is displayed. * @@ -73,14 +67,7 @@ public final class SceneContext { * * @since Envoy Client v0.1-beta */ - LOGIN_SCENE("/fxml/LoginScene.fxml"), - - /** - * The scene in which the info screen is displayed. - * - * @since Envoy Client v0.1-beta - */ - MESSAGE_INFO_SCENE("/fxml/MessageInfoScene.fxml"); + LOGIN_SCENE("/fxml/LoginScene.fxml"); /** * The path to the FXML resource. diff --git a/client/src/main/java/envoy/client/ui/controller/ChatScene.java b/client/src/main/java/envoy/client/ui/controller/ChatScene.java index 707803c..62bd6bf 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -7,6 +7,7 @@ import java.awt.datatransfer.StringSelection; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; +import java.net.URL; import java.nio.file.Files; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -20,6 +21,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; import javafx.scene.control.*; import javafx.scene.control.Alert.AlertType; import javafx.scene.image.Image; @@ -123,6 +125,9 @@ public final class ChatScene implements Restorable { @FXML private VBox contactOperations; + + @FXML + private TabPane tabPane; private LocalDB localDB; private Client client; @@ -171,6 +176,15 @@ public final class ChatScene implements Restorable { clip.setArcHeight(43); clip.setArcWidth(43); clientProfilePic.setClip(clip); + +// FXMLLoader loader = new FXMLLoader(); +// +// try { +// URL url = new File("src/main/resources/fxml/Test.fxml").toURI().toURL(); +// contactOperations.getChildren().add(0, loader.load(url)); +// } catch (Exception e2) { +// e2.printStackTrace(); +// } // Listen to received messages eventBus.register(MessageCreationEvent.class, e -> { @@ -377,8 +391,8 @@ public final class ChatScene implements Restorable { */ @FXML private void addContactButtonClicked() { - sceneContext.load(SceneContext.SceneInfo.CONTACT_SEARCH_SCENE); - sceneContext.getController().initializeData(sceneContext, localDB); +// sceneContext.load(SceneContext.SceneInfo.CONTACT_SEARCH_SCENE); +// sceneContext.getController().initializeData(sceneContext, localDB); } @FXML diff --git a/client/src/main/resources/fxml/ChatScene.fxml b/client/src/main/resources/fxml/ChatScene.fxml index 99afa30..cae6396 100644 --- a/client/src/main/resources/fxml/ChatScene.fxml +++ b/client/src/main/resources/fxml/ChatScene.fxml @@ -7,9 +7,12 @@ + + + @@ -30,69 +33,87 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/client/src/main/resources/fxml/Test.fxml b/client/src/main/resources/fxml/Test.fxml new file mode 100644 index 0000000..6ad0119 --- /dev/null +++ b/client/src/main/resources/fxml/Test.fxml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file From b4397fe2f23da397c4c9de9bac40b49cdb80fdbd Mon Sep 17 00:00:00 2001 From: DieGurke Date: Sat, 22 Aug 2020 21:50:05 +0200 Subject: [PATCH 03/23] contactSearchTab --- .../envoy/client/ui/controller/ChatScene.java | 18 ++++++++++-------- client/src/main/resources/css/base.css | 8 ++++++++ client/src/main/resources/fxml/ChatScene.fxml | 3 +-- .../main/resources/fxml/ContactSearchTab.fxml | 11 +++++++++++ client/src/main/resources/fxml/Test.fxml | 10 ---------- 5 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 client/src/main/resources/fxml/ContactSearchTab.fxml delete mode 100644 client/src/main/resources/fxml/Test.fxml diff --git a/client/src/main/java/envoy/client/ui/controller/ChatScene.java b/client/src/main/java/envoy/client/ui/controller/ChatScene.java index 62bd6bf..3536603 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -28,6 +28,7 @@ import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; +import javafx.scene.layout.AnchorPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; @@ -128,6 +129,9 @@ public final class ChatScene implements Restorable { @FXML private TabPane tabPane; + + @FXML + private Tab contactSearchTab; private LocalDB localDB; private Client client; @@ -177,14 +181,11 @@ public final class ChatScene implements Restorable { clip.setArcWidth(43); clientProfilePic.setClip(clip); -// FXMLLoader loader = new FXMLLoader(); -// -// try { -// URL url = new File("src/main/resources/fxml/Test.fxml").toURI().toURL(); -// contactOperations.getChildren().add(0, loader.load(url)); -// } catch (Exception e2) { -// e2.printStackTrace(); -// } + try { + contactSearchTab.setContent(FXMLLoader.load(new File("src/main/resources/fxml/ContactSearchTab.fxml").toURI().toURL())); + } catch (Exception e2) { + e2.printStackTrace(); + } // Listen to received messages eventBus.register(MessageCreationEvent.class, e -> { @@ -393,6 +394,7 @@ public final class ChatScene implements Restorable { private void addContactButtonClicked() { // sceneContext.load(SceneContext.SceneInfo.CONTACT_SEARCH_SCENE); // sceneContext.getController().initializeData(sceneContext, localDB); + tabPane.getSelectionModel().select(1); } @FXML diff --git a/client/src/main/resources/css/base.css b/client/src/main/resources/css/base.css index 4c289bb..9495823 100644 --- a/client/src/main/resources/css/base.css +++ b/client/src/main/resources/css/base.css @@ -134,3 +134,11 @@ .listElement { -fx-background-color: transparent; } + +.tab-pane { + -fx-tab-max-height: 0 ; +} +.tab-pane .tab-header-area { + visibility: hidden ; + -fx-padding: -20 0 0 0; +} diff --git a/client/src/main/resources/fxml/ChatScene.fxml b/client/src/main/resources/fxml/ChatScene.fxml index cae6396..eb4e80e 100644 --- a/client/src/main/resources/fxml/ChatScene.fxml +++ b/client/src/main/resources/fxml/ChatScene.fxml @@ -104,9 +104,8 @@ - + - diff --git a/client/src/main/resources/fxml/ContactSearchTab.fxml b/client/src/main/resources/fxml/ContactSearchTab.fxml new file mode 100644 index 0000000..f4c0730 --- /dev/null +++ b/client/src/main/resources/fxml/ContactSearchTab.fxml @@ -0,0 +1,11 @@ + + + + + + + + + + - - - - - - - - - - - - - - diff --git a/client/src/main/resources/fxml/GroupCreationScene.fxml b/client/src/main/resources/fxml/GroupCreationScene.fxml index a8c7472..8b2f286 100644 --- a/client/src/main/resources/fxml/GroupCreationScene.fxml +++ b/client/src/main/resources/fxml/GroupCreationScene.fxml @@ -15,7 +15,7 @@ minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" - fx:controller="envoy.client.ui.controller.GroupCreationScene"> + fx:controller="envoy.client.ui.controller.GroupCreationTab diff --git a/client/src/main/resources/fxml/GroupCreationTab.fxml b/client/src/main/resources/fxml/GroupCreationTab.fxml new file mode 100644 index 0000000..5b56bee --- /dev/null +++ b/client/src/main/resources/fxml/GroupCreationTab.fxml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + - - - - - - - From 46a883dda98c3eb9f053bea5a93f1d1e1ea881ee Mon Sep 17 00:00:00 2001 From: DieGurke Date: Sun, 23 Aug 2020 22:29:13 +0200 Subject: [PATCH 11/23] Added nice error handling when creating groups insted of alert --- .../ui/controller/GroupCreationTab.java | 90 +++++++++++++++++-- client/src/main/resources/css/dark.css | 5 ++ .../main/resources/fxml/GroupCreationTab.fxml | 15 +++- 3 files changed, 98 insertions(+), 12 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java b/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java index f8d7259..f4ae707 100644 --- a/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java +++ b/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java @@ -8,6 +8,7 @@ import javafx.application.Platform; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.control.Alert.AlertType; +import javafx.scene.layout.HBox; import envoy.client.data.Chat; import envoy.client.data.LocalDB; @@ -44,15 +45,31 @@ public class GroupCreationTab { @FXML private Button createButton; + + @FXML + private Button cancelButton; @FXML private TextArea groupNameField; @FXML private ListView userList; + + @FXML + private Label errorMessageLabel; + + @FXML + private Button proceedDupButton; + + @FXML + private Button cancelDupButton; + + @FXML + private HBox errorProceedBox; private LocalDB localDB; + private String name; private static final EventBus eventBus = EventBus.getInstance(); @FXML @@ -103,20 +120,37 @@ public class GroupCreationTab { */ @FXML private void createButtonClicked() { - final var name = groupNameField.getText(); + name = groupNameField.getText(); if (!Bounds.isValidContactName(name)) { - new Alert(AlertType.ERROR, "The entered group name is not valid (" + Bounds.CONTACT_NAME_PATTERN + ")").showAndWait(); + errorMessageLabel.setPrefHeight(30); + errorMessageLabel.setMinHeight(30); + errorMessageLabel.setMaxHeight(30); + errorMessageLabel.setText("The group name is not valid!"); groupNameField.clear(); } else if (groupNameAlreadyPresent(name)) { - final var alert = new Alert(AlertType.WARNING, "You already have a group with that name.", ButtonType.OK, ButtonType.CANCEL); - alert.setTitle("Create Group?"); - alert.setHeaderText("Proceed?"); - alert.showAndWait().filter(btn -> btn == ButtonType.OK).ifPresent(btn -> createGroup(name)); + errorMessageLabel.setPrefHeight(30); + errorMessageLabel.setMinHeight(30); + errorMessageLabel.setMaxHeight(30); + errorMessageLabel.setText("Name does already exist! Proceed anyways?"); + proceedDupButton.setPrefHeight(30); + proceedDupButton.setMinHeight(30); + proceedDupButton.setMaxHeight(30); + cancelDupButton.setPrefHeight(30); + cancelDupButton.setMinHeight(30); + cancelDupButton.setMaxHeight(30); + errorProceedBox.setPrefHeight(30); + errorProceedBox.setMinHeight(30); + errorProceedBox.setMaxHeight(30); + createButton.setDisable(true); + cancelButton.setDisable(true); } else { - new Alert(AlertType.INFORMATION, String.format("Group '%s' successfully created.", name)).showAndWait(); createGroup(name); + eventBus.dispatch(new BackEvent()); + errorMessageLabel.setPrefHeight(0); + errorMessageLabel.setMinHeight(0); + errorMessageLabel.setMaxHeight(0); + groupNameField.clear(); } - eventBus.dispatch(new BackEvent()); } /** @@ -150,4 +184,44 @@ public class GroupCreationTab { @FXML private void backButtonClicked() { eventBus.dispatch(new BackEvent()); } + + @FXML + private void proceedOnNameDuplication() { + createButton.setDisable(false); + cancelButton.setDisable(false); + createGroup(name); + eventBus.dispatch(new BackEvent()); + errorMessageLabel.setPrefHeight(0); + errorMessageLabel.setMinHeight(0); + errorMessageLabel.setMaxHeight(0); + proceedDupButton.setPrefHeight(0); + proceedDupButton.setMinHeight(0); + proceedDupButton.setMaxHeight(0); + cancelDupButton.setPrefHeight(0); + cancelDupButton.setMinHeight(0); + cancelDupButton.setMaxHeight(0); + errorProceedBox.setPrefHeight(0); + errorProceedBox.setMinHeight(0); + errorProceedBox.setMaxHeight(0); + groupNameField.clear(); + } + + @FXML + private void cancelOnNameDuplication() { + createButton.setDisable(false); + cancelButton.setDisable(false); + errorMessageLabel.setPrefHeight(0); + errorMessageLabel.setMinHeight(0); + errorMessageLabel.setMaxHeight(0); + proceedDupButton.setPrefHeight(0); + proceedDupButton.setMinHeight(0); + proceedDupButton.setMaxHeight(0); + cancelDupButton.setPrefHeight(0); + cancelDupButton.setMinHeight(0); + cancelDupButton.setMaxHeight(0); + errorProceedBox.setPrefHeight(0); + errorProceedBox.setMinHeight(0); + errorProceedBox.setMaxHeight(0); + groupNameField.clear(); + } } diff --git a/client/src/main/resources/css/dark.css b/client/src/main/resources/css/dark.css index ca98909..de35c5a 100644 --- a/client/src/main/resources/css/dark.css +++ b/client/src/main/resources/css/dark.css @@ -82,3 +82,8 @@ -fx-background-insets : 4.0, 0.0, 0.0; -fx-background-radius : 2.0em; } + +#proceedButton { + -fx-text-fill: white; + -fx-background-color: transparent; +} diff --git a/client/src/main/resources/fxml/GroupCreationTab.fxml b/client/src/main/resources/fxml/GroupCreationTab.fxml index 68da2dd..bd7839b 100644 --- a/client/src/main/resources/fxml/GroupCreationTab.fxml +++ b/client/src/main/resources/fxml/GroupCreationTab.fxml @@ -37,16 +37,23 @@ +