ContactSearchTab UI finished and reimplemented controller

This commit is contained in:
Maximilian P. Käfer 2020-08-23 12:36:43 +02:00
parent b4397fe2f2
commit d0f125f058
3 changed files with 74 additions and 24 deletions

View File

@ -6,10 +6,8 @@ import java.util.logging.Logger;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Alert; import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ListView;
import envoy.client.data.LocalDB; import envoy.client.data.LocalDB;
import envoy.client.event.SendEvent; import envoy.client.event.SendEvent;
@ -40,12 +38,13 @@ import envoy.util.EnvoyLog;
* Created: <strong>07.06.2020</strong><br> * Created: <strong>07.06.2020</strong><br>
* *
* @author Leon Hofmeister * @author Leon Hofmeister
* @author Maximilian K&auml;fer
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
public class ContactSearchScene { public class ContactSearchTab {
@FXML @FXML
private ClearableTextField searchBar; private TextArea searchBar;
@FXML @FXML
private ListView<User> userList; private ListView<User> userList;
@ -82,7 +81,6 @@ public class ContactSearchScene {
@FXML @FXML
private void initialize() { private void initialize() {
userList.setCellFactory(new ListCellFactory<>(ContactControl::new)); userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
searchBar.setClearButtonListener(e -> { searchBar.getTextField().clear(); userList.getItems().clear(); });
eventBus.register(UserSearchResult.class, eventBus.register(UserSearchResult.class,
response -> Platform.runLater(() -> { userList.getItems().clear(); userList.getItems().addAll(response.get()); })); response -> Platform.runLater(() -> { userList.getItems().clear(); userList.getItems().addAll(response.get()); }));
eventBus.register(ContactOperation.class, handler); eventBus.register(ContactOperation.class, handler);
@ -95,7 +93,7 @@ public class ContactSearchScene {
*/ */
@FXML @FXML
private void sendRequest() { private void sendRequest() {
final var text = searchBar.getTextField().getText().strip(); final var text = searchBar.getText().strip();
if (!text.isBlank()) eventBus.dispatch(new SendEvent(new UserSearchRequest(text))); if (!text.isBlank()) eventBus.dispatch(new SendEvent(new UserSearchRequest(text)));
else userList.getItems().clear(); else userList.getItems().clear();
} }
@ -108,7 +106,7 @@ public class ContactSearchScene {
*/ */
@FXML @FXML
private void clear() { private void clear() {
searchBar.getTextField().setText(null); searchBar.setText(null);
userList.getItems().clear(); userList.getItems().clear();
} }
@ -141,12 +139,12 @@ public class ContactSearchScene {
} }
} }
@FXML // @FXML
private void newGroupButtonClicked() { // private void newGroupButtonClicked() {
sceneContext.load(SceneContext.SceneInfo.GROUP_CREATION_SCENE); // sceneContext.load(SceneContext.SceneInfo.GROUP_CREATION_SCENE);
sceneContext.<GroupCreationScene>getController().initializeData(sceneContext, localDB); // sceneContext.<GroupCreationScene>getController().initializeData(sceneContext, localDB);
} // }
@FXML // @FXML
private void backButtonClicked() { sceneContext.pop(); } // private void backButtonClicked() { sceneContext.pop(); }
} }

View File

@ -12,7 +12,7 @@
minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="envoy.client.ui.controller.ContactSearchScene"> fx:controller="envoy.client.ui.controller.ContactSearchTab">
<children> <children>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0"> <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children> <children>

View File

@ -1,11 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?> <?import javafx.geometry.Insets?>
<?import java.util.*?> <?import javafx.scene.control.Button?>
<?import javafx.scene.*?> <?import javafx.scene.control.ContextMenu?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.Label?>
<?import javafx.scene.layout.*?> <?import javafx.scene.control.ListView?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"> <AnchorPane xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.ContactSearchTab">
<Button text="This is a test!" /> <VBox id="search-panel" alignment="TOP_CENTER" prefHeight="3000.0" prefWidth="316.0">
</AnchorPane> <children>
<Label alignment="CENTER" text="Find User" textAlignment="CENTER" textFill="WHITE">
<font>
<Font size="18.0" />
</font>
<VBox.margin>
<Insets top="8.0" />
</VBox.margin>
</Label>
<HBox id="underline" prefWidth="200.0" spacing="5.0">
<children>
<Label id="contact-search-enter-container" maxHeight="30.0" minHeight="30.0" prefHeight="30.0" prefWidth="325.0">
<graphic>
<TextArea id="contactSearchInput" fx:id="searchBar" focusTraversable="false" maxHeight="30.0" minHeight="30.0" onInputMethodTextChanged="#sendRequest" onKeyTyped="#sendRequest" prefHeight="30.0" prefWidth="200.0" promptText="Search Envoy Users">
<font>
<Font size="14.0" />
</font>
<padding>
<Insets left="12.0" right="12.0" />
</padding>
</TextArea>
</graphic>
</Label>
<Button fx:id="backButton" maxHeight="30.0" maxWidth="30.0" minHeight="30.0" minWidth="30.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="30.0" text="X" />
</children>
<VBox.margin>
<Insets left="10.0" right="10.0" />
</VBox.margin>
<padding>
<Insets bottom="10.0" top="5.0" />
</padding>
</HBox>
<ListView id="chatList" fx:id="userList" focusTraversable="false" onMouseClicked="#userListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS">
<contextMenu>
<ContextMenu anchorLocation="CONTENT_TOP_LEFT">
<items>
<MenuItem fx:id="deleteContactMenuItem" mnemonicParsing="false" text="Delete" />
</items>
</ContextMenu>
</contextMenu>
<padding>
<Insets bottom="5.0" left="5.0" right="2.0" top="5.0" />
</padding>
</ListView>
</children>
</VBox>
</AnchorPane>