Implemented TabPane and done preparation for internal file loading

This commit is contained in:
Maximilian P. Käfer 2020-08-22 21:02:49 +02:00
parent cb95c40ad6
commit 1fe83dbcc0
4 changed files with 109 additions and 77 deletions

View File

@ -1,6 +1,7 @@
package envoy.client.ui;
import java.io.IOException;
import java.net.URL;
import java.util.Stack;
import java.util.logging.Level;
@ -54,13 +55,6 @@ public final class SceneContext {
*/
SETTINGS_SCENE("/fxml/SettingsScene.fxml"),
/**
* The scene in which the contact search screen is displayed.
*
* @since Envoy Client v0.1-beta
*/
CONTACT_SEARCH_SCENE("/fxml/ContactSearchScene.fxml"),
/**
* The scene in which the group creation screen is displayed.
*
@ -73,14 +67,7 @@ public final class SceneContext {
*
* @since Envoy Client v0.1-beta
*/
LOGIN_SCENE("/fxml/LoginScene.fxml"),
/**
* The scene in which the info screen is displayed.
*
* @since Envoy Client v0.1-beta
*/
MESSAGE_INFO_SCENE("/fxml/MessageInfoScene.fxml");
LOGIN_SCENE("/fxml/LoginScene.fxml");
/**
* The path to the FXML resource.

View File

@ -7,6 +7,7 @@ import java.awt.datatransfer.StringSelection;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -20,6 +21,7 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.Image;
@ -124,6 +126,9 @@ public final class ChatScene implements Restorable {
@FXML
private VBox contactOperations;
@FXML
private TabPane tabPane;
private LocalDB localDB;
private Client client;
private WriteProxy writeProxy;
@ -172,6 +177,15 @@ public final class ChatScene implements Restorable {
clip.setArcWidth(43);
clientProfilePic.setClip(clip);
// FXMLLoader loader = new FXMLLoader();
//
// try {
// URL url = new File("src/main/resources/fxml/Test.fxml").toURI().toURL();
// contactOperations.getChildren().add(0, loader.load(url));
// } catch (Exception e2) {
// e2.printStackTrace();
// }
// Listen to received messages
eventBus.register(MessageCreationEvent.class, e -> {
final var message = e.get();
@ -377,8 +391,8 @@ public final class ChatScene implements Restorable {
*/
@FXML
private void addContactButtonClicked() {
sceneContext.load(SceneContext.SceneInfo.CONTACT_SEARCH_SCENE);
sceneContext.<ContactSearchScene>getController().initializeData(sceneContext, localDB);
// sceneContext.load(SceneContext.SceneInfo.CONTACT_SEARCH_SCENE);
// sceneContext.<ContactSearchScene>getController().initializeData(sceneContext, localDB);
}
@FXML

View File

@ -7,9 +7,12 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
@ -30,10 +33,13 @@
<RowConstraints maxHeight="120.0" minHeight="-Infinity" prefHeight="83.333251953125" vgrow="NEVER" />
</rowConstraints>
<children>
<VBox fx:id="contactOperations" prefWidth="316.0" GridPane.rowIndex="1" GridPane.rowSpan="2147483647">
<GridPane.margin>
<Insets right="1.0" />
</GridPane.margin>
<TabPane fx:id="tabPane" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" GridPane.rowIndex="1" GridPane.rowSpan="2147483647">
<tabs>
<Tab text="">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0">
<children>
<VBox fx:id="contactOperations" prefHeight="3000.0" prefWidth="316.0">
<children>
<VBox id="search-panel" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="80.0" prefWidth="316.0">
<children>
@ -68,7 +74,8 @@
</HBox.margin>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding></Button>
</padding>
</Button>
</children>
<VBox.margin>
<Insets left="10.0" right="10.0" top="5.0" />
@ -93,6 +100,20 @@
</ListView>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="Untitled Tab 2">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
<GridPane.margin>
<Insets right="1.0" />
</GridPane.margin>
</TabPane>
<HBox id="topBar" alignment="CENTER_LEFT" prefHeight="100.0">
<children>
<ImageView id="profilePic" fx:id="clientProfilePic" fitHeight="43.0" fitWidth="43.0" pickOnBounds="true" preserveRatio="true">

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.layout.*?>
<StackPane prefHeight="200" prefWidth="200" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Text text="test" />
</children>
</StackPane>