From 07cdbab097e503ff1b7676dbb5bb7a2a209e79d6 Mon Sep 17 00:00:00 2001 From: delvh Date: Tue, 30 Jun 2020 21:20:54 +0200 Subject: [PATCH] Added (currently useless) message-info menuItem additionally: - moved MessageListCell and ContactListCell into envoy.client.ui.listcell - edited editable property of ClearableTextField --- .../java/envoy/client/ui/ClearableTextField.java | 8 ++++++++ src/main/java/envoy/client/ui/SceneContext.java | 15 +++++++++++---- .../envoy/client/ui/controller/ChatScene.java | 8 +++++++- .../client/ui/controller/ContactSearchScene.java | 2 +- .../client/ui/controller/GroupCreationScene.java | 2 +- .../client/ui/{ => listcell}/ContactListCell.java | 4 ++-- .../client/ui/{ => listcell}/MessageListCell.java | 5 +++-- .../envoy/client/ui/listcell/package-info.java | 12 ++++++++++++ src/main/resources/fxml/ChatScene.fxml | 6 ++++-- 9 files changed, 49 insertions(+), 13 deletions(-) rename src/main/java/envoy/client/ui/{ => listcell}/ContactListCell.java (93%) rename src/main/java/envoy/client/ui/{ => listcell}/MessageListCell.java (94%) create mode 100644 src/main/java/envoy/client/ui/listcell/package-info.java diff --git a/src/main/java/envoy/client/ui/ClearableTextField.java b/src/main/java/envoy/client/ui/ClearableTextField.java index 2a4dcfb..81b3f86 100644 --- a/src/main/java/envoy/client/ui/ClearableTextField.java +++ b/src/main/java/envoy/client/ui/ClearableTextField.java @@ -1,5 +1,6 @@ package envoy.client.ui; +import javafx.beans.property.BooleanProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.StringProperty; import javafx.event.ActionEvent; @@ -156,4 +157,11 @@ public class ClearableTextField extends GridPane { * @since Envoy Client v0.1-beta */ public final void setEditable(boolean value) { textField.setEditable(value); } + + /** + * @return the current property whether this ClearableTextField is editable + * @see javafx.scene.control.TextInputControl#editableProperty() + * @since Envoy Client v0.1-beta + */ + public final BooleanProperty editableProperty() { return textField.editableProperty(); } } diff --git a/src/main/java/envoy/client/ui/SceneContext.java b/src/main/java/envoy/client/ui/SceneContext.java index 52c847b..6b6757e 100644 --- a/src/main/java/envoy/client/ui/SceneContext.java +++ b/src/main/java/envoy/client/ui/SceneContext.java @@ -40,21 +40,21 @@ public final class SceneContext { public enum SceneInfo { /** - * The main scene in which chats are displayed. + * The main scene in which the chat screen is displayed. * * @since Envoy Client v0.1-beta */ CHAT_SCENE("/fxml/ChatScene.fxml"), /** - * The scene in which settings are displayed. + * The scene in which the settings screen is displayed. * * @since Envoy Client v0.1-beta */ SETTINGS_SCENE("/fxml/SettingsScene.fxml"), /** - * The scene in which the contact search is displayed. + * The scene in which the contact search screen is displayed. * * @since Envoy Client v0.1-beta */ @@ -72,7 +72,14 @@ public final class SceneContext { * * @since Envoy Client v0.1-beta */ - LOGIN_SCENE("/fxml/LoginScene.fxml"); + 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"); /** * The path to the FXML resource. diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index c27a857..f53a8cb 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -24,7 +24,10 @@ import envoy.client.data.Settings; import envoy.client.event.MessageCreationEvent; import envoy.client.net.Client; import envoy.client.net.WriteProxy; -import envoy.client.ui.*; +import envoy.client.ui.IconUtil; +import envoy.client.ui.SceneContext; +import envoy.client.ui.listcell.ContactListCell; +import envoy.client.ui.listcell.MessageListCell; import envoy.data.*; import envoy.event.EventBus; import envoy.event.MessageStatusChange; @@ -386,4 +389,7 @@ public final class ChatScene { updateRemainingCharsLabel(); postButton.setDisable(messageText.isBlank()); } + + @FXML + private void loadMessageInfoScene() { try {} catch (final NullPointerException e) {} } } diff --git a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java index 9a438dc..a215f44 100644 --- a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java +++ b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java @@ -13,8 +13,8 @@ import javafx.scene.control.ListView; import envoy.client.data.LocalDB; import envoy.client.event.SendEvent; import envoy.client.ui.ClearableTextField; -import envoy.client.ui.ContactListCell; import envoy.client.ui.SceneContext; +import envoy.client.ui.listcell.ContactListCell; import envoy.data.Contact; import envoy.event.ElementOperation; import envoy.event.EventBus; diff --git a/src/main/java/envoy/client/ui/controller/GroupCreationScene.java b/src/main/java/envoy/client/ui/controller/GroupCreationScene.java index 37b5c17..e6594f5 100644 --- a/src/main/java/envoy/client/ui/controller/GroupCreationScene.java +++ b/src/main/java/envoy/client/ui/controller/GroupCreationScene.java @@ -10,8 +10,8 @@ import javafx.scene.control.Alert.AlertType; import envoy.client.data.LocalDB; import envoy.client.event.SendEvent; import envoy.client.ui.ClearableTextField; -import envoy.client.ui.ContactListCell; import envoy.client.ui.SceneContext; +import envoy.client.ui.listcell.ContactListCell; import envoy.data.Contact; import envoy.event.EventBus; import envoy.event.GroupCreation; diff --git a/src/main/java/envoy/client/ui/ContactListCell.java b/src/main/java/envoy/client/ui/listcell/ContactListCell.java similarity index 93% rename from src/main/java/envoy/client/ui/ContactListCell.java rename to src/main/java/envoy/client/ui/listcell/ContactListCell.java index b13543b..526e2b8 100644 --- a/src/main/java/envoy/client/ui/ContactListCell.java +++ b/src/main/java/envoy/client/ui/listcell/ContactListCell.java @@ -1,4 +1,4 @@ -package envoy.client.ui; +package envoy.client.ui.listcell; import javafx.scene.control.Label; import javafx.scene.control.ListCell; @@ -52,7 +52,7 @@ public class ContactListCell extends ListCell { vbox.getChildren().add(statusLabel); } else // Member count vbox.getChildren().add(new Label(((Group) contact).getContacts().size() + " members")); - prefWidthProperty().bind(listView.widthProperty().subtract(40)); + if (listView != null) prefWidthProperty().bind(listView.widthProperty().subtract(40)); setGraphic(vbox); } } diff --git a/src/main/java/envoy/client/ui/MessageListCell.java b/src/main/java/envoy/client/ui/listcell/MessageListCell.java similarity index 94% rename from src/main/java/envoy/client/ui/MessageListCell.java rename to src/main/java/envoy/client/ui/listcell/MessageListCell.java index e33c502..be66259 100644 --- a/src/main/java/envoy/client/ui/MessageListCell.java +++ b/src/main/java/envoy/client/ui/listcell/MessageListCell.java @@ -1,4 +1,4 @@ -package envoy.client.ui; +package envoy.client.ui.listcell; import java.time.format.DateTimeFormatter; import java.util.Map; @@ -10,6 +10,7 @@ import javafx.scene.image.ImageView; import javafx.scene.layout.VBox; import javafx.stage.PopupWindow.AnchorLocation; +import envoy.client.ui.IconUtil; import envoy.data.Message; import envoy.data.Message.MessageStatus; import envoy.data.User; @@ -64,7 +65,7 @@ public class MessageListCell extends ListCell { } else cell.getStyleClass().add("received-message"); // Adjusting height and weight of the cell to the corresponding ListView cell.paddingProperty().setValue(new Insets(5, 20, 5, 20)); - cell.prefWidthProperty().bind(listView.widthProperty().subtract(40)); + if (listView != null) cell.prefWidthProperty().bind(listView.widthProperty().subtract(40)); // Creating the Tooltip to deselect a message final var tooltip = new Tooltip("You can select a message by clicking on it \nand deselect it by pressing \"ctrl\" and clicking on it"); tooltip.setWrapText(true); diff --git a/src/main/java/envoy/client/ui/listcell/package-info.java b/src/main/java/envoy/client/ui/listcell/package-info.java new file mode 100644 index 0000000..ab0788e --- /dev/null +++ b/src/main/java/envoy/client/ui/listcell/package-info.java @@ -0,0 +1,12 @@ +/** + * This package contains custom list cells that are used to display certain + * things. + *

+ * Project: envoy-client
+ * File: package-info.java
+ * Created: 30.06.2020
+ * + * @author Leon Hofmeister + * @since Envoy Client v0.1-beta + */ +package envoy.client.ui.listcell; diff --git a/src/main/resources/fxml/ChatScene.fxml b/src/main/resources/fxml/ChatScene.fxml index 666a148..8ed1185 100644 --- a/src/main/resources/fxml/ChatScene.fxml +++ b/src/main/resources/fxml/ChatScene.fxml @@ -102,6 +102,8 @@ onAction="#forwardMessage" text="Forward" /> + @@ -176,8 +178,8 @@