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
4 changed files with 34 additions and 2 deletions
Showing only changes of commit 7fffa0da83 - Show all commits

View File

@ -0,0 +1,21 @@
package envoy.client.ui.control;
import javafx.scene.control.Label;
import envoy.data.User;
/**
* @author Maximilian Käfer
* @since Envoy Client v0.3-beta
*/
public class QuickSelectControl extends Label {
public QuickSelectControl(User user) {
setPrefSize(35, 35);
mpk marked this conversation as resolved Outdated
Outdated
Review
... a {@link User} as ...
``` ... a {@link User} as ... ```
Outdated
Review

We don't use camelCase is Javadoc.

We don't use camelCase is Javadoc.
setMaxSize(35, 35);
setMinSize(35, 35);
setText(user.getName());
getStyleClass().add("quick-select");
}
}
mpk marked this conversation as resolved Outdated
Outdated
Review

Please make this private.

Please make this `private`.

View File

@ -11,7 +11,7 @@ import javafx.scene.layout.HBox;
import envoy.client.data.*;
import envoy.client.event.BackEvent;
import envoy.client.ui.control.ContactControl;
import envoy.client.ui.control.*;
import envoy.client.ui.listcell.ListCellFactory;
import envoy.data.*;
import envoy.event.GroupCreation;
@ -58,6 +58,9 @@ public class GroupCreationTab implements EventListener {
@FXML
private HBox errorProceedBox;
@FXML
private ListView<QuickSelectControl> quickSelectList;
private String name;
private final LocalDB localDB = Context.getInstance().getLocalDB();
@ -86,7 +89,10 @@ public class GroupCreationTab implements EventListener {
* @since Envoy Client v0.1-beta
*/
@FXML
private void userListClicked() { createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank()); }
private void userListClicked() {
createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank());
quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem()));
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.
/**
* Checks, whether the {@code createButton} can be enabled because text is

View File

@ -83,3 +83,7 @@
-fx-text-fill: white;
-fx-background-color: transparent;
}
.quick-select {
-fx-background-color: black;
}

View File

@ -64,6 +64,7 @@
<Insets bottom="5.0" top="5" />
</VBox.margin>
</Label>
<ListView fx:id="quickSelectList" orientation="HORIZONTAL" prefHeight="80.0" />
<ListView id="chat-list" fx:id="userList" focusTraversable="false" onMouseClicked="#userListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS">
<contextMenu>
<ContextMenu anchorLocation="CONTENT_TOP_LEFT" />