Did some renaming

This commit is contained in:
DieGurke 2020-07-12 17:10:22 +02:00
parent 7d47c9247d
commit 64f7ae4071
6 changed files with 37 additions and 37 deletions

View File

@ -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<Message> messageList;
@FXML
private ListView<Chat> userList;
private ListView<Chat> 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);
});

View File

@ -38,7 +38,7 @@ public class ContactSearchScene {
private ClearableTextField searchBar;
@FXML
private ListView<Chat> contactList;
private ListView<Chat> 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");

View File

@ -35,7 +35,7 @@ public class GroupCreationScene {
private ClearableTextField groupNameField;
@FXML
private ListView<Chat> contactList;
private ListView<Chat> 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();
}

View File

@ -44,7 +44,7 @@
minHeight="-Infinity" prefHeight="40.0" vgrow="NEVER" />
</rowConstraints>
<children>
<ListView fx:id="userList" onMouseClicked="#userListClicked"
<ListView fx:id="chatList" onMouseClicked="#chatListClicked"
prefHeight="211.0" prefWidth="300.0" GridPane.rowIndex="1"
GridPane.rowSpan="2147483647">
<GridPane.margin>

View File

@ -46,8 +46,8 @@
</Button>
</children>
</HBox>
<ListView fx:id="contactList"
onMouseClicked="#contactListClicked" prefHeight="314.0"
<ListView fx:id="chatList"
onMouseClicked="#chatListClicked" prefHeight="314.0"
prefWidth="600.0">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />

View File

@ -45,8 +45,8 @@
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</Label>
<ListView fx:id="contactList"
onMouseClicked="#contactListClicked" prefHeight="314.0"
<ListView fx:id="chatList"
onMouseClicked="#chatListClicked" prefHeight="314.0"
prefWidth="600.0">
<VBox.margin>
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />