From 5f410e5d65b7b59384a78627d1e8156afd6f3073 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sun, 12 Jul 2020 17:10:22 +0200 Subject: [PATCH] Did some renaming --- .../envoy/client/ui/controller/ChatScene.java | 32 +++++++++---------- .../ui/controller/ContactSearchScene.java | 18 +++++------ .../ui/controller/GroupCreationScene.java | 14 ++++---- src/main/resources/fxml/ChatScene.fxml | 2 +- .../resources/fxml/ContactSearchScene.fxml | 4 +-- .../resources/fxml/GroupCreationScene.fxml | 4 +-- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index a91436b..3d789ef 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -8,7 +8,6 @@ import java.io.IOException; import java.nio.file.Files; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; import javafx.application.Platform; import javafx.collections.FXCollections; @@ -57,7 +56,7 @@ public final class ChatScene implements Restorable { private ListView messageList; @FXML - private ListView userList; + private ListView chatList; @FXML private Button postButton; @@ -115,7 +114,7 @@ public final class ChatScene implements Restorable { // Initialize message and user rendering messageList.setCellFactory(MessageListCellFactory::new); - userList.setCellFactory(ContactListCellFactory::new); + chatList.setCellFactory(ContactListCellFactory::new); settingsButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("settings", DEFAULT_ICON_SIZE))); voiceButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("microphone", DEFAULT_ICON_SIZE))); @@ -137,9 +136,9 @@ public final class ChatScene implements Restorable { } else chat.incrementUnreadAmount(); // Moving chat with most recent unreadMessages to the top Platform.runLater(() -> { - userList.getItems().remove(chat); - userList.getItems().add(0, chat); - if (chat.equals(currentChat)) userList.getSelectionModel().select(0); + chatList.getItems().remove(chat); + chatList.getItems().add(0, chat); + if (chat.equals(currentChat)) chatList.getSelectionModel().select(0); localDB.getChats().remove(chat); localDB.getChats().add(0, chat); }); @@ -162,12 +161,12 @@ public final class ChatScene implements Restorable { // Listen to user status changes eventBus.register(UserStatusChange.class, - e -> userList.getItems() + e -> chatList.getItems() .stream() .filter(c -> c.getRecipient().getID() == e.getID()) .findAny() .map(Chat::getRecipient) - .ifPresent(u -> { ((User) u).setStatus(e.get()); Platform.runLater(userList::refresh); })); + .ifPresent(u -> { ((User) u).setStatus(e.get()); Platform.runLater(chatList::refresh); })); // Listen to contacts changes eventBus.register(ContactOperation.class, e -> { @@ -177,12 +176,12 @@ public final class ChatScene implements Restorable { localDB.getUsers().put(contact.getName(), contact); Chat chat = contact instanceof User ? new Chat(contact) : new GroupChat(client.getSender(), contact); localDB.getChats().add(chat); - Platform.runLater(() -> userList.getItems().add(chat)); + Platform.runLater(() -> chatList.getItems().add(chat)); break; case REMOVE: localDB.getUsers().remove(contact.getName()); localDB.getChats().removeIf(c -> c.getRecipient().getID() == contact.getID()); - Platform.runLater(() -> userList.getItems().removeIf(c -> c.getRecipient().getID() == contact.getID())); + Platform.runLater(() -> chatList.getItems().removeIf(c -> c.getRecipient().getID() == contact.getID())); break; } }); @@ -204,7 +203,7 @@ public final class ChatScene implements Restorable { this.client = client; this.writeProxy = writeProxy; - userList.setItems(FXCollections.observableList(localDB.getChats())); + chatList.setItems(FXCollections.observableList(localDB.getChats())); contactLabel.setText(localDB.getUser().getName()); MessageControl.setUser(localDB.getUser()); if (!client.isOnline()) updateInfoLabel("You are offline", "infoLabel-info"); @@ -221,8 +220,8 @@ public final class ChatScene implements Restorable { * @since Envoy Client v0.1-beta */ @FXML - private void userListClicked() { - final Contact user = userList.getSelectionModel().getSelectedItem().getRecipient(); + private void chatListClicked() { + final Contact user = chatList.getSelectionModel().getSelectedItem().getRecipient(); if (user != null && (currentChat == null || !user.equals(currentChat.getRecipient()))) { // LEON: JFC <===> JAVA FRIED CHICKEN <=/=> Java Foundation Classes @@ -258,7 +257,7 @@ public final class ChatScene implements Restorable { messageTextArea.setDisable(currentChat == null || postingPermanentlyDisabled); voiceButton.setDisable(!recorder.isSupported()); attachmentButton.setDisable(false); - userList.refresh(); + chatList.refresh(); } /** @@ -462,8 +461,9 @@ public final class ChatScene implements Restorable { currentChat.insert(message); // Moving currentChat to the top Platform.runLater(() -> { - userList.getItems().add(0, userList.getItems().remove(currentChat)); - userList.getSelectionModel().select(0); + chatList.getItems().remove(currentChat); + chatList.getItems().add(0, currentChat); + chatList.getSelectionModel().select(0); localDB.getChats().remove(currentChat); localDB.getChats().add(0, currentChat); }); diff --git a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java index d440ee4..a86d79d 100644 --- a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java +++ b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java @@ -38,7 +38,7 @@ public class ContactSearchScene { private ClearableTextField searchBar; @FXML - private ListView contactList; + private ListView chatList; private SceneContext sceneContext; @@ -59,12 +59,12 @@ public class ContactSearchScene { @FXML private void initialize() { - contactList.setCellFactory(ContactListCellFactory::new); - searchBar.setClearButtonListener(e -> { searchBar.getTextField().clear(); contactList.getItems().clear(); }); + chatList.setCellFactory(ContactListCellFactory::new); + searchBar.setClearButtonListener(e -> { searchBar.getTextField().clear(); chatList.getItems().clear(); }); eventBus.register(ContactSearchResult.class, response -> Platform.runLater(() -> { - contactList.getItems().clear(); - contactList.getItems().addAll(response.get().stream().map(Chat::new).collect(Collectors.toList())); + chatList.getItems().clear(); + chatList.getItems().addAll(response.get().stream().map(Chat::new).collect(Collectors.toList())); })); } @@ -77,7 +77,7 @@ public class ContactSearchScene { private void sendRequest() { final var text = searchBar.getTextField().getText().strip(); if (!text.isBlank()) eventBus.dispatch(new SendEvent(new ContactSearchRequest(text))); - else contactList.getItems().clear(); + else chatList.getItems().clear(); } /** @@ -89,7 +89,7 @@ public class ContactSearchScene { @FXML private void clear() { searchBar.getTextField().setText(null); - contactList.getItems().clear(); + chatList.getItems().clear(); } /** @@ -99,8 +99,8 @@ public class ContactSearchScene { * @since Envoy Client v0.1-beta */ @FXML - private void contactListClicked() { - final var chat = contactList.getSelectionModel().getSelectedItem(); + private void chatListClicked() { + final var chat = chatList.getSelectionModel().getSelectedItem(); if (chat != null) { final var alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Add Contact to Contact List"); diff --git a/src/main/java/envoy/client/ui/controller/GroupCreationScene.java b/src/main/java/envoy/client/ui/controller/GroupCreationScene.java index da88370..e7bbf93 100644 --- a/src/main/java/envoy/client/ui/controller/GroupCreationScene.java +++ b/src/main/java/envoy/client/ui/controller/GroupCreationScene.java @@ -35,7 +35,7 @@ public class GroupCreationScene { private ClearableTextField groupNameField; @FXML - private ListView contactList; + private ListView chatList; private SceneContext sceneContext; @@ -43,8 +43,8 @@ public class GroupCreationScene { @FXML private void initialize() { - contactList.setCellFactory(ContactListCellFactory::new); - contactList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); + chatList.setCellFactory(ContactListCellFactory::new); + chatList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); groupNameField.setClearButtonListener(e -> { groupNameField.getTextField().clear(); createButton.setDisable(true); }); } @@ -56,7 +56,7 @@ public class GroupCreationScene { */ public void initializeData(SceneContext sceneContext, LocalDB localDB) { this.sceneContext = sceneContext; - Platform.runLater(() -> contactList.getItems() + Platform.runLater(() -> chatList.getItems() .addAll(localDB.getChats() .stream() .filter(c -> !(c.getRecipient() instanceof Group)) @@ -70,8 +70,8 @@ public class GroupCreationScene { * @since Envoy Client v0.1-beta */ @FXML - private void contactListClicked() { - createButton.setDisable(contactList.getSelectionModel().isEmpty() || groupNameField.getTextField().getText().isBlank()); + private void chatListClicked() { + createButton.setDisable(chatList.getSelectionModel().isEmpty() || groupNameField.getTextField().getText().isBlank()); } /** @@ -98,7 +98,7 @@ public class GroupCreationScene { groupNameField.getTextField().clear(); } else { eventBus.dispatch(new SendEvent(new GroupCreation(name, - contactList.getSelectionModel().getSelectedItems().stream().map(c -> c.getRecipient().getID()).collect(Collectors.toSet())))); + chatList.getSelectionModel().getSelectedItems().stream().map(c -> c.getRecipient().getID()).collect(Collectors.toSet())))); new Alert(AlertType.INFORMATION, String.format("Group '%s' successfully created.", name)).showAndWait(); sceneContext.pop(); } diff --git a/src/main/resources/fxml/ChatScene.fxml b/src/main/resources/fxml/ChatScene.fxml index fd48b75..ad8e3f2 100644 --- a/src/main/resources/fxml/ChatScene.fxml +++ b/src/main/resources/fxml/ChatScene.fxml @@ -44,7 +44,7 @@ minHeight="-Infinity" prefHeight="40.0" vgrow="NEVER" /> - diff --git a/src/main/resources/fxml/ContactSearchScene.fxml b/src/main/resources/fxml/ContactSearchScene.fxml index b69d15c..a88430c 100644 --- a/src/main/resources/fxml/ContactSearchScene.fxml +++ b/src/main/resources/fxml/ContactSearchScene.fxml @@ -46,8 +46,8 @@ - diff --git a/src/main/resources/fxml/GroupCreationScene.fxml b/src/main/resources/fxml/GroupCreationScene.fxml index 90a8516..0085b03 100644 --- a/src/main/resources/fxml/GroupCreationScene.fxml +++ b/src/main/resources/fxml/GroupCreationScene.fxml @@ -45,8 +45,8 @@ -