parent
51b189e8f5
commit
994cbbcd72
@ -1,18 +1,19 @@
|
|||||||
package envoy.client.ui.control;
|
package envoy.client.ui.control;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javafx.geometry.*;
|
import javafx.geometry.*;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
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.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays an {@link User} as a quickSelectControl which is used in the
|
* Displays an {@link User} as a quick select control which is used in the
|
||||||
* quickSelectList.
|
* quick select list.
|
||||||
*
|
*
|
||||||
* @author Maximilian Käfer
|
* @author Maximilian Käfer
|
||||||
* @since Envoy Client v0.3-beta
|
* @since Envoy Client v0.3-beta
|
||||||
@ -24,11 +25,11 @@ public class QuickSelectControl extends VBox {
|
|||||||
/**
|
/**
|
||||||
* Creates an instance of the {@code QuickSelectControl}.
|
* Creates an instance of the {@code QuickSelectControl}.
|
||||||
*
|
*
|
||||||
* @param user the user whose data is used to create this instance.
|
* @param user the contact whose data is used to create this instance.
|
||||||
* @param tab the parent tab ({@link GroupCreationTab}).
|
* @param action the action to perform when a contact is removed with this control as a parameter
|
||||||
* @since Envoy Client v0.3-beta
|
* @since Envoy Client v0.3-beta
|
||||||
*/
|
*/
|
||||||
public QuickSelectControl(User user, GroupCreationTab tab) {
|
public QuickSelectControl(User user, Consumer<QuickSelectControl> action) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
setPadding(new Insets(1, 0, 0, 0));
|
setPadding(new Insets(1, 0, 0, 0));
|
||||||
setPrefWidth(37);
|
setPrefWidth(37);
|
||||||
@ -65,13 +66,12 @@ public class QuickSelectControl extends VBox {
|
|||||||
removeBtn.setPrefSize(12, 12);
|
removeBtn.setPrefSize(12, 12);
|
||||||
removeBtn.setMaxSize(12, 12);
|
removeBtn.setMaxSize(12, 12);
|
||||||
removeBtn.setMinSize(12, 12);
|
removeBtn.setMinSize(12, 12);
|
||||||
removeBtn.setOnMouseClicked(evt -> tab.removeFromQuickSelection(this));
|
removeBtn.setOnMouseClicked(evt -> action.accept(this));
|
||||||
removeBtn.setId("remove-button");
|
removeBtn.setId("remove-button");
|
||||||
hBox.getChildren().add(removeBtn);
|
hBox.getChildren().add(removeBtn);
|
||||||
stackPane.getChildren().add(hBox);
|
stackPane.getChildren().add(hBox);
|
||||||
getChildren().add(stackPane);
|
getChildren().add(stackPane);
|
||||||
|
|
||||||
|
|
||||||
var nameLabel = new Label();
|
var nameLabel = new Label();
|
||||||
nameLabel.setPrefSize(35, 20);
|
nameLabel.setPrefSize(35, 20);
|
||||||
nameLabel.setMaxSize(35, 20);
|
nameLabel.setMaxSize(35, 20);
|
||||||
|
@ -71,7 +71,6 @@ public class GroupCreationTab implements EventListener {
|
|||||||
@FXML
|
@FXML
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
|
userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
|
||||||
userList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
|
||||||
createButton.setDisable(true);
|
createButton.setDisable(true);
|
||||||
eventBus.registerListener(this);
|
eventBus.registerListener(this);
|
||||||
userList.getItems()
|
userList.getItems()
|
||||||
@ -94,7 +93,7 @@ public class GroupCreationTab implements EventListener {
|
|||||||
@FXML
|
@FXML
|
||||||
private void userListClicked() {
|
private void userListClicked() {
|
||||||
if (userList.getSelectionModel().getSelectedItem() != null) {
|
if (userList.getSelectionModel().getSelectedItem() != null) {
|
||||||
quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem(), this));
|
quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem(), this::removeFromQuickSelection));
|
||||||
createButton.setDisable(quickSelectList.getItems().isEmpty() || groupNameField.getText().isBlank());
|
createButton.setDisable(quickSelectList.getItems().isEmpty() || groupNameField.getText().isBlank());
|
||||||
resizeQuickSelectSpace(60);
|
resizeQuickSelectSpace(60);
|
||||||
userList.getItems().remove(userList.getSelectionModel().getSelectedItem());
|
userList.getItems().remove(userList.getSelectionModel().getSelectedItem());
|
||||||
|
Reference in New Issue
Block a user