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.
This commit is contained in:
delvh 2020-06-23 23:32:31 +02:00
parent 4ad61e3152
commit a823029c07
6 changed files with 39 additions and 34 deletions

View File

@ -35,14 +35,11 @@ public class ContactListCell extends ListCell<Contact> {
final var vbox = new VBox(new Label(contact.getName())); final var vbox = new VBox(new Label(contact.getName()));
if (contact instanceof User) { if (contact instanceof User) {
// Online status // Online status
final var user = (User) contact; final var user = (User) contact;
final var statusLabel = new Label(user.getStatus().toString()); final var statusLabel = new Label(user.getStatus().toString());
statusLabel.getStyleClass().add(user.getStatus().toString().toLowerCase()); statusLabel.getStyleClass().add(user.getStatus().toString().toLowerCase());
vbox.getChildren().add(statusLabel); vbox.getChildren().add(statusLabel);
} else { } else vbox.getChildren().add(new Label(((Group) contact).getContacts().size() + " members"));
// Member count
vbox.getChildren().add(new Label(((Group) contact).getContacts().size() + " members"));
}
setGraphic(vbox); setGraphic(vbox);
} }
} }

View File

@ -35,7 +35,7 @@ public class MessageListCell extends ListCell<Message> {
static { static {
try { try {
statusImages = IconUtil.loadByEnum(MessageStatus.class, 32); statusImages = IconUtil.loadByEnum(MessageStatus.class, 16);
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
EnvoyLog.getLogger(MessageListCell.class).log(Level.WARNING, "could not load status icons: ", e); EnvoyLog.getLogger(MessageListCell.class).log(Level.WARNING, "could not load status icons: ", e);
@ -54,9 +54,11 @@ public class MessageListCell extends ListCell<Message> {
setText(null); setText(null);
setGraphic(null); setGraphic(null);
} else { } else {
final var cell = new VBox(new Label(dateFormat.format(message.getCreationDate())), new Label(message.getText()), final var cell = new VBox(new Label(dateFormat.format(message.getCreationDate())), new Label(message.getText()));
new Label("", new ImageView(statusImages.get(message.getStatus())))); if (message.getRecipientID() == user.getID()) {
cell.getStyleClass().add(message.getRecipientID() == user.getID() ? "received-message" : "own-message"); 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)); cell.paddingProperty().setValue(new Insets(5, 20, 5, 20));
setGraphic(cell); setGraphic(cell);
} }

View File

@ -321,34 +321,35 @@ public final class ChatScene {
@FXML @FXML
private void copyMessage() { private void copyMessage() {
Toolkit.getDefaultToolkit() try {
.getSystemClipboard() Toolkit.getDefaultToolkit()
.setContents(new StringSelection(messageList.getSelectionModel().getSelectedItem().getText()), null); .getSystemClipboard()
.setContents(new StringSelection(messageList.getSelectionModel().getSelectedItem().getText()), null);
} catch (final NullPointerException e) {}
} }
@FXML @FXML
private void deleteMessage() {} private void deleteMessage() { try {} catch (final NullPointerException e) {} }
@FXML @FXML
private void forwardMessage() {} private void forwardMessage() { try {} catch (final NullPointerException e) {} }
@FXML @FXML
private void quoteMessage() {} private void quoteMessage() { try {} catch (final NullPointerException e) {} }
@FXML @FXML
private void deleteContact() { private void deleteContact() { try {} catch (final NullPointerException e) {} }
// TODO: Fill with content
userList.getSelectionModel().getSelectedItem();
}
@FXML @FXML
private void copyAndPostMessage() { private void copyAndPostMessage() {
final var messageText = messageTextArea.getText(); try {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null); final var messageText = messageTextArea.getText();
postMessage(); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null);
messageTextArea.setText(messageText); postMessage();
updateRemainingCharsLabel(); messageTextArea.setText(messageText);
postButton.setDisable(messageText.isBlank()); updateRemainingCharsLabel();
postButton.setDisable(messageText.isBlank());
} catch (final NullPointerException e) {}
} }
} }

View File

@ -26,6 +26,11 @@
-fx-background-color: transparent; -fx-background-color: transparent;
} }
.scroll-bar:horizontal, .scroll-bar *, .scroll-bar:horizontal > *{
-fx-background-color: transparent;
-fx-text-fill: transparent;
}
.online { .online {
-fx-text-fill: limegreen; -fx-text-fill: limegreen;
} }

View File

@ -7,7 +7,7 @@
} }
.button { .button {
-fx-background-color: darkviolet; -fx-background-color: rgb(105.0,0.0,153.0);
} }
.button:pressed { .button:pressed {
@ -23,15 +23,15 @@
} }
.list-cell:selected, .list-cell:selected > *, .menu-item:hover { .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 { .received-message {
-fx-background-color: seagreen; -fx-background-color: gray;
} }
.own-message { .own-message {
-fx-background-color: gray; -fx-background-color: #8fa88f;
} }
.alert.information.dialog-pane, .alert.warning.dialog-pane, .alert.error.dialog-pane { .alert.information.dialog-pane, .alert.warning.dialog-pane, .alert.error.dialog-pane {

View File

@ -7,10 +7,10 @@
-fx-text-fill: black; -fx-text-fill: black;
} }
.received-message { .received-message, .menu-item {
-fx-background-color: lightgreen;
}
.own-message , .menu-item {
-fx-background-color: lightgray; -fx-background-color: lightgray;
} }
.own-message {
-fx-background-color: lightgreen;
}