Added SettingsScene selection infrastructure

This commit is contained in:
Kai S. K. Engelbart 2020-04-18 11:03:06 +02:00
parent 225fa0de2e
commit 7023562add
3 changed files with 60 additions and 18 deletions

View File

@ -0,0 +1,19 @@
package envoy.client.ui;
import javafx.scene.Node;
/**
* Project: <strong>envoy-client</strong><br>
* File: <strong>SettingsPane.java</strong><br>
* Created: <strong>18.04.2020</strong><br>
*
* @author Kai S. K. Engelbart
* @since Envoy Client v0.1-beta
*/
public abstract class SettingsPane extends Node {
protected String title;
public abstract String getTitle();
}

View File

@ -1,5 +1,10 @@
package envoy.client.ui; package envoy.client.ui;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import envoy.client.data.Settings;
/** /**
* Project: <strong>envoy-client</strong><br> * Project: <strong>envoy-client</strong><br>
* File: <strong>SettingsSceneController.java</strong><br> * File: <strong>SettingsSceneController.java</strong><br>
@ -10,4 +15,27 @@ package envoy.client.ui;
*/ */
public class SettingsSceneController { public class SettingsSceneController {
@FXML
private ListView<SettingsPane> settingsList;
@FXML
private TitledPane titledPane;
private static final Settings settings = Settings.getInstance();
@FXML
private void initialize() {
settingsList.setCellFactory(listView -> new ListCell<>() {
@Override
protected void updateItem(SettingsPane item, boolean empty) { if (!empty && item != null) setGraphic(new Label(item.getTitle())); };
});
}
@FXML
private void settingsListClicked() {
final var pane = settingsList.getSelectionModel().getSelectedItem();
titledPane.setText(pane.getTitle());
titledPane.setContent(pane);
}
} }

View File

@ -1,29 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?> <?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TreeView?> <?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" <VBox alignment="TOP_RIGHT" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.SettingsSceneController">
minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.SettingsSceneController">
<children> <children>
<HBox prefHeight="100.0" prefWidth="200.0"> <HBox prefHeight="100.0" prefWidth="200.0">
<children> <children>
<TreeView prefHeight="200.0" prefWidth="200.0" /> <ListView fx:id="settingsList" onMouseClicked="#settingsListClicked" prefHeight="200.0" prefWidth="200.0" />
</children> <TitledPane fx:id="titledPane" collapsible="false" prefHeight="200.0" prefWidth="200.0" />
</children>
</HBox> </HBox>
<ButtonBar prefHeight="40.0" prefWidth="200.0"> <Button defaultButton="true" mnemonicParsing="false" onMouseClicked="#backButtonClicked" text="Back">
<buttons> <opaqueInsets>
<Button cancelButton="true" mnemonicParsing="false" <Insets />
text="Cancel" /> </opaqueInsets>
<Button mnemonicParsing="false" text="Apply" /> </Button>
<Button defaultButton="true" mnemonicParsing="false"
text="Apply &amp; Close" />
</buttons>
</ButtonBar>
</children> </children>
</VBox> </VBox>