From a823029c079dad6153860d089dc69d031c956cdd Mon Sep 17 00:00:00 2001 From: delvh Date: Tue, 23 Jun 2020 23:32:31 +0200 Subject: [PATCH] Improved message coloring, messageStatus display only for own messages additionally loaded the message status icons smaller and (visually) hid the vertical scrollbars (they can still be used, but cannot be seen). Lastly checked all context menu functions for a NullPointerException, as also no element can be selected when the context menu is created. --- .../java/envoy/client/ui/ContactListCell.java | 7 ++-- .../java/envoy/client/ui/MessageListCell.java | 10 +++--- .../envoy/client/ui/controller/ChatScene.java | 33 ++++++++++--------- src/main/resources/css/base.css | 5 +++ src/main/resources/css/dark.css | 8 ++--- src/main/resources/css/light.css | 10 +++--- 6 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/main/java/envoy/client/ui/ContactListCell.java b/src/main/java/envoy/client/ui/ContactListCell.java index e52197d..0160885 100644 --- a/src/main/java/envoy/client/ui/ContactListCell.java +++ b/src/main/java/envoy/client/ui/ContactListCell.java @@ -35,14 +35,11 @@ public class ContactListCell extends ListCell { final var vbox = new VBox(new Label(contact.getName())); if (contact instanceof User) { // Online status - final var user = (User) contact; + final var user = (User) contact; final var statusLabel = new Label(user.getStatus().toString()); statusLabel.getStyleClass().add(user.getStatus().toString().toLowerCase()); vbox.getChildren().add(statusLabel); - } else { - // Member count - vbox.getChildren().add(new Label(((Group) contact).getContacts().size() + " members")); - } + } else vbox.getChildren().add(new Label(((Group) contact).getContacts().size() + " members")); setGraphic(vbox); } } diff --git a/src/main/java/envoy/client/ui/MessageListCell.java b/src/main/java/envoy/client/ui/MessageListCell.java index a66a6f1..721224c 100644 --- a/src/main/java/envoy/client/ui/MessageListCell.java +++ b/src/main/java/envoy/client/ui/MessageListCell.java @@ -35,7 +35,7 @@ public class MessageListCell extends ListCell { static { try { - statusImages = IconUtil.loadByEnum(MessageStatus.class, 32); + statusImages = IconUtil.loadByEnum(MessageStatus.class, 16); } catch (final IOException e) { e.printStackTrace(); EnvoyLog.getLogger(MessageListCell.class).log(Level.WARNING, "could not load status icons: ", e); @@ -54,9 +54,11 @@ public class MessageListCell extends ListCell { setText(null); setGraphic(null); } else { - final var cell = new VBox(new Label(dateFormat.format(message.getCreationDate())), new Label(message.getText()), - new Label("", new ImageView(statusImages.get(message.getStatus())))); - cell.getStyleClass().add(message.getRecipientID() == user.getID() ? "received-message" : "own-message"); + final var cell = new VBox(new Label(dateFormat.format(message.getCreationDate())), new Label(message.getText())); + if (message.getRecipientID() == user.getID()) { + cell.getChildren().add(new Label("", new ImageView(statusImages.get(message.getStatus())))); + cell.getStyleClass().add("own-message"); + } else cell.getStyleClass().add("received-message"); cell.paddingProperty().setValue(new Insets(5, 20, 5, 20)); setGraphic(cell); } diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index 4cee655..c1fb678 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -321,34 +321,35 @@ public final class ChatScene { @FXML private void copyMessage() { - Toolkit.getDefaultToolkit() - .getSystemClipboard() - .setContents(new StringSelection(messageList.getSelectionModel().getSelectedItem().getText()), null); + try { + Toolkit.getDefaultToolkit() + .getSystemClipboard() + .setContents(new StringSelection(messageList.getSelectionModel().getSelectedItem().getText()), null); + } catch (final NullPointerException e) {} } @FXML - private void deleteMessage() {} + private void deleteMessage() { try {} catch (final NullPointerException e) {} } @FXML - private void forwardMessage() {} + private void forwardMessage() { try {} catch (final NullPointerException e) {} } @FXML - private void quoteMessage() {} + private void quoteMessage() { try {} catch (final NullPointerException e) {} } @FXML - private void deleteContact() { - // TODO: Fill with content - userList.getSelectionModel().getSelectedItem(); - } + private void deleteContact() { try {} catch (final NullPointerException e) {} } @FXML private void copyAndPostMessage() { - final var messageText = messageTextArea.getText(); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null); - postMessage(); - messageTextArea.setText(messageText); - updateRemainingCharsLabel(); - postButton.setDisable(messageText.isBlank()); + try { + final var messageText = messageTextArea.getText(); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null); + postMessage(); + messageTextArea.setText(messageText); + updateRemainingCharsLabel(); + postButton.setDisable(messageText.isBlank()); + } catch (final NullPointerException e) {} } } diff --git a/src/main/resources/css/base.css b/src/main/resources/css/base.css index 35094f4..469b753 100644 --- a/src/main/resources/css/base.css +++ b/src/main/resources/css/base.css @@ -26,6 +26,11 @@ -fx-background-color: transparent; } +.scroll-bar:horizontal, .scroll-bar *, .scroll-bar:horizontal > *{ + -fx-background-color: transparent; + -fx-text-fill: transparent; +} + .online { -fx-text-fill: limegreen; } diff --git a/src/main/resources/css/dark.css b/src/main/resources/css/dark.css index 75e3bc0..967732b 100644 --- a/src/main/resources/css/dark.css +++ b/src/main/resources/css/dark.css @@ -7,7 +7,7 @@ } .button { - -fx-background-color: darkviolet; + -fx-background-color: rgb(105.0,0.0,153.0); } .button:pressed { @@ -23,15 +23,15 @@ } .list-cell:selected, .list-cell:selected > *, .menu-item:hover { - -fx-background-color: darkviolet; + -fx-background-color: rgb(105.0,0.0,153.0); } .received-message { - -fx-background-color: seagreen; + -fx-background-color: gray; } .own-message { - -fx-background-color: gray; + -fx-background-color: #8fa88f; } .alert.information.dialog-pane, .alert.warning.dialog-pane, .alert.error.dialog-pane { diff --git a/src/main/resources/css/light.css b/src/main/resources/css/light.css index 96942fd..066de55 100644 --- a/src/main/resources/css/light.css +++ b/src/main/resources/css/light.css @@ -7,10 +7,10 @@ -fx-text-fill: black; } -.received-message { - -fx-background-color: lightgreen; -} - -.own-message , .menu-item { +.received-message, .menu-item { -fx-background-color: lightgray; } + +.own-message { + -fx-background-color: lightgreen; +}