Data initialization in GroupCreationTab works at the right time
This commit is contained in:
parent
bd75da1ab9
commit
14ccf4ce58
@ -0,0 +1,24 @@
|
|||||||
|
package envoy.client.event;
|
||||||
|
|
||||||
|
import envoy.client.data.LocalDB;
|
||||||
|
import envoy.event.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>client</strong><br>
|
||||||
|
* File: <strong>LoadGroupCreationEvent.java</strong><br>
|
||||||
|
* Created: <strong>Aug 23, 2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Client v0.2-beta
|
||||||
|
*/
|
||||||
|
public class LoadGroupCreationEvent extends Event<LocalDB>{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 0L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param value the localDB
|
||||||
|
* @since Envoy Client v0.2-beta
|
||||||
|
*/
|
||||||
|
public LoadGroupCreationEvent(LocalDB value) { super(value); }
|
||||||
|
|
||||||
|
}
|
@ -40,9 +40,7 @@ import envoy.client.data.*;
|
|||||||
import envoy.client.data.audio.AudioRecorder;
|
import envoy.client.data.audio.AudioRecorder;
|
||||||
import envoy.client.data.commands.SystemCommandBuilder;
|
import envoy.client.data.commands.SystemCommandBuilder;
|
||||||
import envoy.client.data.commands.SystemCommandsMap;
|
import envoy.client.data.commands.SystemCommandsMap;
|
||||||
import envoy.client.event.BackEvent;
|
import envoy.client.event.*;
|
||||||
import envoy.client.event.MessageCreationEvent;
|
|
||||||
import envoy.client.event.SendEvent;
|
|
||||||
import envoy.client.net.Client;
|
import envoy.client.net.Client;
|
||||||
import envoy.client.net.WriteProxy;
|
import envoy.client.net.WriteProxy;
|
||||||
import envoy.client.ui.*;
|
import envoy.client.ui.*;
|
||||||
@ -407,7 +405,7 @@ public final class ChatScene implements Restorable {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void groupCreationButtonClicked() {
|
private void groupCreationButtonClicked() {
|
||||||
//TODO: initialize Data
|
eventBus.dispatch(new LoadGroupCreationEvent(localDB));
|
||||||
tabPane.getSelectionModel().select(2);
|
tabPane.getSelectionModel().select(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import javafx.scene.control.Alert.AlertType;
|
|||||||
import envoy.client.data.Chat;
|
import envoy.client.data.Chat;
|
||||||
import envoy.client.data.LocalDB;
|
import envoy.client.data.LocalDB;
|
||||||
import envoy.client.event.BackEvent;
|
import envoy.client.event.BackEvent;
|
||||||
|
import envoy.client.event.LoadGroupCreationEvent;
|
||||||
import envoy.client.event.SendEvent;
|
import envoy.client.event.SendEvent;
|
||||||
import envoy.client.ui.SceneContext;
|
import envoy.client.ui.SceneContext;
|
||||||
import envoy.client.ui.listcell.ContactControl;
|
import envoy.client.ui.listcell.ContactControl;
|
||||||
@ -58,23 +59,18 @@ public class GroupCreationTab {
|
|||||||
private void initialize() {
|
private void initialize() {
|
||||||
userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
|
userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
|
||||||
userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
eventBus.register(LoadGroupCreationEvent.class, e -> {
|
||||||
* @param localDB the local database from which potential group members can
|
this.localDB = e.get();
|
||||||
* be selected
|
Platform.runLater(() -> userList.getItems()
|
||||||
* @since Envoy Client v0.1-beta
|
.addAll(localDB.getChats()
|
||||||
*/
|
.stream()
|
||||||
public void initializeData(LocalDB localDB) {
|
.map(Chat::getRecipient)
|
||||||
this.localDB = localDB;
|
.filter(User.class::isInstance)
|
||||||
Platform.runLater(() -> userList.getItems()
|
.filter(not(localDB.getUser()::equals))
|
||||||
.addAll(localDB.getChats()
|
.map(User.class::cast)
|
||||||
.stream()
|
.collect(Collectors.toList())));
|
||||||
.map(Chat::getRecipient)
|
});
|
||||||
.filter(User.class::isInstance)
|
|
||||||
.filter(not(localDB.getUser()::equals))
|
|
||||||
.map(User.class::cast)
|
|
||||||
.collect(Collectors.toList())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user