Quick Select Support for the GroupCreationTab #77

Merged
mpk merged 9 commits from f/quick-group-select into develop 2020-10-04 21:28:57 +02:00
3 changed files with 21 additions and 4 deletions
Showing only changes of commit 8543e94040 - Show all commits

View File

@ -1,11 +1,12 @@
package envoy.client.ui.control;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle;
import envoy.client.ui.controller.GroupCreationTab;
import envoy.client.util.IconUtil;
import envoy.data.User;
@ -15,7 +16,17 @@ import envoy.data.User;
*/
public class QuickSelectControl extends VBox {
public QuickSelectControl(User user) {
public QuickSelectControl(User user, GroupCreationTab tab) {
Button removeBtn = new Button();
removeBtn.setPrefSize(10, 10);
mpk marked this conversation as resolved Outdated
Outdated
Review

Please make this private.

Please make this `private`.
removeBtn.setMaxSize(10, 10);
removeBtn.setMinSize(10, 10);
removeBtn.setAlignment(Pos.TOP_RIGHT);
mpk marked this conversation as resolved Outdated
Outdated
Review

As I've already been conditioned by a certain member of the Envoy team (the coffee machine guy) to not use @link in constructors for the own component, I've since swapped to using @code, so maybe you should too.

It might be beneficial to create a convention for such cases from here on.

As I've already been conditioned by a certain member of the Envoy team (the coffee machine guy) to not use `@link` in constructors for the own component, I've since swapped to using `@code`, so maybe you should too. It might be beneficial to create a convention for such cases from here on.
removeBtn.setOnMouseClicked(evt -> {
tab.removeFromQuickSelection(this);
});
removeBtn.setId("remove-button");
getChildren().add(removeBtn);
// Profile picture
ImageView contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("user_icon", 32));
mpk marked this conversation as resolved Outdated
Outdated
Review

?

?
Outdated
Review

This centers the component (it is just 1 pixel but very noticable)

This centers the component (it is just 1 pixel but very noticable)
@ -38,5 +49,4 @@ public class QuickSelectControl extends VBox {
getStyleClass().add("quick-select");
}
}
mpk marked this conversation as resolved
Review

This is, as far as I can see, unnecessary.
Have tested it, it is.

This is, as far as I can see, unnecessary. Have tested it, it is.

View File

@ -91,7 +91,7 @@ public class GroupCreationTab implements EventListener {
@FXML
private void userListClicked() {
createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank());
quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem()));
quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem(), this));
delvh marked this conversation as resolved Outdated
Outdated
Review

Isn't that the wrong check here? Shouldn't it be

setDisable(quickSelectList.getItems().isEmpty() && userList.getSelectionModel().isEmpty() || ...);
Isn't that the wrong check here? Shouldn't it be ``` setDisable(quickSelectList.getItems().isEmpty() && userList.getSelectionModel().isEmpty() || ...); ```
Outdated
Review

Yes there was an issue but it was not the one you suggested.

Yes there was an issue but it was not the one you suggested.
}
mpk marked this conversation as resolved Outdated
Outdated
Review

You need to insert a null check for userList.getSelectionModel().getSelectedItem() as it can also happen that no element has been selected. This is especially the case if you click on the userList after every user has been removed from it.

You need to insert a null check for `userList.getSelectionModel().getSelectedItem()` as it can also happen that no element has been selected. This is especially the case if you click on the userList after every user has been removed from it.
/**
@ -157,6 +157,8 @@ public class GroupCreationTab implements EventListener {
return localDB.getChats().stream().map(Chat::getRecipient).filter(Group.class::isInstance).map(Contact::getName).anyMatch(newName::equals);
}
public void removeFromQuickSelection(QuickSelectControl element) { quickSelectList.getItems().remove(element); }
@FXML
private void backButtonClicked() {
eventBus.dispatch(new BackEvent());

View File

@ -83,3 +83,8 @@
-fx-text-fill: white;
-fx-background-color: transparent;
}
#remove-button {
-fx-background-color: red;
-fx-background-radius: 1em;
}