Quick Select Support for the GroupCreationTab #77
@ -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
|
|||||||
|
setMaxSize(35, 35);
|
||||||
|
setMinSize(35, 35);
|
||||||
|
setText(user.getName());
|
||||||
|
getStyleClass().add("quick-select");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
mpk marked this conversation as resolved
Outdated
kske
commented
Please make this Please make this `private`.
|
@ -11,7 +11,7 @@ import javafx.scene.layout.HBox;
|
|||||||
|
|
||||||
import envoy.client.data.*;
|
import envoy.client.data.*;
|
||||||
import envoy.client.event.BackEvent;
|
import envoy.client.event.BackEvent;
|
||||||
import envoy.client.ui.control.ContactControl;
|
import envoy.client.ui.control.*;
|
||||||
import envoy.client.ui.listcell.ListCellFactory;
|
import envoy.client.ui.listcell.ListCellFactory;
|
||||||
import envoy.data.*;
|
import envoy.data.*;
|
||||||
import envoy.event.GroupCreation;
|
import envoy.event.GroupCreation;
|
||||||
@ -58,6 +58,9 @@ public class GroupCreationTab implements EventListener {
|
|||||||
@FXML
|
@FXML
|
||||||
private HBox errorProceedBox;
|
private HBox errorProceedBox;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ListView<QuickSelectControl> quickSelectList;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private final LocalDB localDB = Context.getInstance().getLocalDB();
|
private final LocalDB localDB = Context.getInstance().getLocalDB();
|
||||||
@ -86,7 +89,10 @@ public class GroupCreationTab implements EventListener {
|
|||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
*/
|
*/
|
||||||
@FXML
|
@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
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.
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks, whether the {@code createButton} can be enabled because text is
|
* Checks, whether the {@code createButton} can be enabled because text is
|
||||||
|
@ -83,3 +83,7 @@
|
|||||||
-fx-text-fill: white;
|
-fx-text-fill: white;
|
||||||
-fx-background-color: transparent;
|
-fx-background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quick-select {
|
||||||
|
-fx-background-color: black;
|
||||||
|
}
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
<Insets bottom="5.0" top="5" />
|
<Insets bottom="5.0" top="5" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</Label>
|
</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">
|
<ListView id="chat-list" fx:id="userList" focusTraversable="false" onMouseClicked="#userListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS">
|
||||||
<contextMenu>
|
<contextMenu>
|
||||||
<ContextMenu anchorLocation="CONTENT_TOP_LEFT" />
|
<ContextMenu anchorLocation="CONTENT_TOP_LEFT" />
|
||||||
|
Reference in New Issue
Block a user
We don't use camelCase is Javadoc.