Quick Select Support for the GroupCreationTab #77
@ -1,11 +1,12 @@
|
|||||||
package envoy.client.ui.control;
|
package envoy.client.ui.control;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
|
|
||||||
|
import envoy.client.ui.controller.GroupCreationTab;
|
||||||
import envoy.client.util.IconUtil;
|
import envoy.client.util.IconUtil;
|
||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
|
|
||||||
@ -15,7 +16,17 @@ import envoy.data.User;
|
|||||||
*/
|
*/
|
||||||
public class QuickSelectControl extends VBox {
|
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
|
|||||||
|
removeBtn.setMaxSize(10, 10);
|
||||||
|
removeBtn.setMinSize(10, 10);
|
||||||
|
removeBtn.setAlignment(Pos.TOP_RIGHT);
|
||||||
mpk marked this conversation as resolved
Outdated
delvh
commented
As I've already been conditioned by a certain member of the Envoy team (the coffee machine guy) to not use 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
|
// Profile picture
|
||||||
ImageView contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("user_icon", 32));
|
ImageView contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("user_icon", 32));
|
||||||
mpk marked this conversation as resolved
Outdated
delvh
commented
? ?
mpk
commented
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");
|
getStyleClass().add("quick-select");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
mpk marked this conversation as resolved
delvh
commented
This is, as far as I can see, unnecessary. This is, as far as I can see, unnecessary.
Have tested it, it is.
|
|||||||
|
@ -91,7 +91,7 @@ public class GroupCreationTab implements EventListener {
|
|||||||
@FXML
|
@FXML
|
||||||
private void userListClicked() {
|
private void userListClicked() {
|
||||||
createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank());
|
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
delvh
commented
Isn't that the wrong check here? Shouldn't it be
Isn't that the wrong check here? Shouldn't it be
```
setDisable(quickSelectList.getItems().isEmpty() && userList.getSelectionModel().isEmpty() || ...);
```
mpk
commented
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
delvh
commented
You need to insert a null check for 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);
|
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
|
@FXML
|
||||||
private void backButtonClicked() {
|
private void backButtonClicked() {
|
||||||
eventBus.dispatch(new BackEvent());
|
eventBus.dispatch(new BackEvent());
|
||||||
|
@ -83,3 +83,8 @@
|
|||||||
-fx-text-fill: white;
|
-fx-text-fill: white;
|
||||||
-fx-background-color: transparent;
|
-fx-background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#remove-button {
|
||||||
|
-fx-background-color: red;
|
||||||
|
-fx-background-radius: 1em;
|
||||||
|
}
|
||||||
|
Please make this
private
.