Added functionality
This commit is contained in:
parent
434d577c15
commit
ab77c98a36
@ -16,7 +16,10 @@ import envoy.data.User;
|
||||
*/
|
||||
public class QuickSelectControl extends VBox {
|
||||
|
||||
User user;
|
||||
|
||||
public QuickSelectControl(User user, GroupCreationTab tab) {
|
||||
this.user = user;
|
||||
setPrefWidth(37);
|
||||
setMaxWidth(37);
|
||||
setMinWidth(37);
|
||||
@ -70,4 +73,6 @@ public class QuickSelectControl extends VBox {
|
||||
|
||||
getStyleClass().add("quick-select");
|
||||
}
|
||||
|
||||
public User getUser() { return user; }
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class GroupCreationTab implements EventListener {
|
||||
@FXML
|
||||
private void initialize() {
|
||||
userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
|
||||
userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
userList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||
createButton.setDisable(true);
|
||||
eventBus.registerListener(this);
|
||||
userList.getItems()
|
||||
@ -81,9 +81,7 @@ public class GroupCreationTab implements EventListener {
|
||||
.filter(not(localDB.getUser()::equals))
|
||||
.map(User.class::cast)
|
||||
.collect(Collectors.toList()));
|
||||
quickSelectList.setPrefHeight(0);
|
||||
quickSelectList.setMaxHeight(0);
|
||||
quickSelectList.setMinHeight(0);
|
||||
resizeQuickSelectSpace(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,9 +93,9 @@ public class GroupCreationTab implements EventListener {
|
||||
private void userListClicked() {
|
||||
createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank());
|
||||
quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem(), this));
|
||||
quickSelectList.setPrefHeight(60);
|
||||
quickSelectList.setMaxHeight(60);
|
||||
quickSelectList.setMinHeight(60);
|
||||
resizeQuickSelectSpace(60);
|
||||
userList.getItems().remove(userList.getSelectionModel().getSelectedItem());
|
||||
userList.getSelectionModel().clearSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +105,7 @@ public class GroupCreationTab implements EventListener {
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@FXML
|
||||
private void textUpdated() { createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank()); }
|
||||
private void textUpdated() { createButton.setDisable(quickSelectList.getItems().size() == 0 || groupNameField.getText().isBlank()); }
|
||||
|
||||
/**
|
||||
* Sends a {@link GroupCreation} to the server and closes this scene.
|
||||
@ -135,6 +133,9 @@ public class GroupCreationTab implements EventListener {
|
||||
// Restoring the original design as tabs will always be reused
|
||||
setErrorMessageLabelSize(0);
|
||||
groupNameField.clear();
|
||||
quickSelectList.getItems().forEach(q -> userList.getItems().add(q.getUser()));
|
||||
quickSelectList.getItems().clear();
|
||||
resizeQuickSelectSpace(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +149,7 @@ public class GroupCreationTab implements EventListener {
|
||||
private void createGroup(String name) {
|
||||
Context.getInstance()
|
||||
.getClient()
|
||||
.send(new GroupCreation(name, userList.getSelectionModel().getSelectedItems().stream().map(User::getID).collect(Collectors.toSet())));
|
||||
.send(new GroupCreation(name, quickSelectList.getItems().stream().map(q -> q.getUser().getID()).collect(Collectors.toSet())));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,13 +166,19 @@ public class GroupCreationTab implements EventListener {
|
||||
|
||||
public void removeFromQuickSelection(QuickSelectControl element) {
|
||||
quickSelectList.getItems().remove(element);
|
||||
userList.getItems().add(element.getUser());
|
||||
if (quickSelectList.getItems().size() == 0) {
|
||||
quickSelectList.setPrefHeight(0);
|
||||
quickSelectList.setMaxHeight(0);
|
||||
quickSelectList.setMinHeight(0);
|
||||
resizeQuickSelectSpace(0);
|
||||
createButton.setDisable(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void resizeQuickSelectSpace(int value) {
|
||||
quickSelectList.setPrefHeight(value);
|
||||
quickSelectList.setMaxHeight(value);
|
||||
quickSelectList.setMinHeight(value);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void backButtonClicked() {
|
||||
eventBus.dispatch(new BackEvent());
|
||||
|
Reference in New Issue
Block a user