Preference API test

-Added a Preference API for preferences
main
Kaabp 5 years ago
parent 9b5e43ea51
commit d83cd2c427

@ -121,7 +121,7 @@
</font>
</Text>
<VBox id="menuslide" fx:id="menuslideV" prefHeight="622.0" prefWidth="200.0" stylesheets="@../css/home.css" visible="false">
<Label prefHeight="20.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" />
<Label fx:id="usernameMenuLabel" prefHeight="20.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" />
<JFXListCell id="buttonStammbaum" fx:id="buttonStammbaum" onMouseClicked="#buttonStammbaumClicked" prefHeight="40.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" text="Stammbaum" textFill="WHITE" />
<JFXListCell id="buttonPeople" fx:id="buttonPeople" onMouseClicked="#buttonPeopleClicked" prefHeight="40.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" text="People" textFill="WHITE" />
<JFXListCell id="buttonPictrues" fx:id="buttonPictures" onMouseClicked="#buttonPicturesClicked" prefHeight="40.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" text="Pictures" textFill="WHITE" />
@ -133,7 +133,7 @@
<BorderPane id="optionPane" fx:id="optionsmenu" layoutX="91.0" onMouseEntered="#optionPaneEntered" onMouseExited="#optionPaneExited" prefHeight="245.0" prefWidth="148.0" visible="false">
<center>
<VBox id="VboxOption0" prefHeight="250.0" prefWidth="150.0" stylesheets="@../css/home.css" BorderPane.alignment="CENTER">
<JFXListCell id="prefreceButtonOptionsMenu" prefHeight="30.0" prefWidth="152.0" styleClass="buttonTopBarMenus" stylesheets="@../css/home.css" text="Prefrences" />
<JFXListCell id="prefreceButtonOptionsMenu" prefHeight="30.0" prefWidth="152.0" styleClass="buttonTopBarMenus" stylesheets="@../css/home.css" text="Preferences" />
</VBox>
</center>
<bottom>

@ -21,7 +21,7 @@
<opaqueInsets>
<Insets />
</opaqueInsets>
<Label text="Prefrences" textFill="WHITE">
<Label text="Preferences" textFill="WHITE">
<padding>
<Insets left="10.0" top="4.0" />
</padding>
@ -36,7 +36,12 @@
<padding>
<Insets bottom="2.0" left="5.0" right="5.0" top="2.0" />
</padding>
<FontAwesomeIcon fill="#f20000" iconName="CLOSE" onMousePressed="#closeButtonClicked" scaleX="1.1" scaleY="1.1" scaleZ="1.1" selectionEnd="0" selectionFill="#f20000" />
<FontAwesomeIcon fill="#bf9728" iconName="SAVE" onMouseClicked="#saveButtonClicked" scaleX="0.8" scaleY="0.8" selectionFill="#b09515" text="">
<HBox.margin>
<Insets bottom="2.0" left="2.0" right="6.0" top="3.0" />
</HBox.margin>
</FontAwesomeIcon>
<FontAwesomeIcon fill="#f20000" iconName="CLOSE" onMousePressed="#closeButtonClicked" scaleX="1.2" scaleY="1.2" scaleZ="1.2" selectionEnd="0" selectionFill="#f20000" />
</HBox>
</right>
</BorderPane>
@ -45,55 +50,46 @@
<BorderPane prefHeight="380.0" prefWidth="800.0" BorderPane.alignment="CENTER">
<top>
<VBox prefHeight="376.0" prefWidth="800.0" BorderPane.alignment="CENTER">
<Pane prefHeight="10.0" prefWidth="800.0"/>
<Pane prefHeight="10.0" prefWidth="800.0" />
<Pane id="menuName1Pane" prefHeight="23.0" prefWidth="800.0" stylesheets="@../css/prefrence.css">
<styleClass>
<String fx:value="background"/>
<String fx:value="menu"/>
<String fx:value="background" />
<String fx:value="menu" />
</styleClass>
<Label alignment="CENTER" layoutX="354.0" layoutY="1.0" stylesheets="@../css/prefrence.css"
text="Personalisieren" textFill="WHITE">
<Label alignment="CENTER" layoutX="354.0" layoutY="1.0" stylesheets="@../css/prefrence.css" text="Personalisieren" textFill="WHITE">
<font>
<Font size="14.0"/>
<Font size="14.0" />
</font>
</Label>
</Pane>
<Pane id="menu1MainPane" prefHeight="150.0" prefWidth="800.0" styleClass="background"
stylesheets="@../css/prefrence.css">
<Pane id="menu1MainPane" prefHeight="150.0" prefWidth="800.0" styleClass="background" stylesheets="@../css/prefrence.css">
<HBox prefHeight="150.0" prefWidth="800.0" stylesheets="@../css/prefrence.css">
<Pane prefHeight="150.0" prefWidth="270.0" styleClass="background"
stylesheets="@../css/prefrence.css">
<Label layoutX="104.0" layoutY="14.0" text="Nickname" textFill="WHITE"/>
<TextField id="nicknameField" layoutX="34.0" layoutY="32.0" prefHeight="26.0"
prefWidth="200.0" stylesheets="@../css/prefrence.css"/>
<Label layoutX="84.0" layoutY="90.0" text="Vor &amp; Nachname" textFill="WHITE"/>
<TextField id="nicknameField" layoutX="34.0" layoutY="109.0" prefHeight="26.0"
prefWidth="200.0" stylesheets="@../css/prefrence.css"/>
<Pane prefHeight="150.0" prefWidth="270.0" styleClass="background" stylesheets="@../css/prefrence.css">
<Label layoutX="104.0" layoutY="14.0" text="Nickname" textFill="WHITE" />
<TextField id="nicknameField" fx:id="usernameInputField" layoutX="34.0" layoutY="32.0" prefHeight="26.0" prefWidth="200.0" stylesheets="@../css/prefrence.css" />
<Label layoutX="84.0" layoutY="90.0" text="Vor &amp; Nachname" textFill="WHITE" />
<TextField id="nicknameField" fx:id="nameInputField" layoutX="34.0" layoutY="109.0" prefHeight="26.0" prefWidth="200.0" stylesheets="@../css/prefrence.css" />
</Pane>
<Pane prefHeight="150.0" prefWidth="270.0" styleClass="background"
stylesheets="@../css/prefrence.css">
<Label layoutX="114.0" layoutY="14.0" text="Design" textFill="WHITE"/>
<Pane prefHeight="150.0" prefWidth="270.0" styleClass="background" stylesheets="@../css/prefrence.css">
<Label layoutX="114.0" layoutY="14.0" text="Design" textFill="WHITE" />
</Pane>
<Pane prefHeight="150.0" prefWidth="270.0" styleClass="background"
stylesheets="@../css/prefrence.css"/>
<Pane prefHeight="150.0" prefWidth="270.0" styleClass="background" stylesheets="@../css/prefrence.css" />
</HBox>
</Pane>
<Pane prefHeight="13.0" prefWidth="800.0"/>
<Pane prefHeight="13.0" prefWidth="800.0" />
<Pane id="menuName1Pane" prefHeight="23.0" prefWidth="800.0" stylesheets="@../css/prefrence.css">
<styleClass>
<String fx:value="background"/>
<String fx:value="menu"/>
<String fx:value="background" />
<String fx:value="menu" />
</styleClass>
<Label alignment="CENTER" layoutX="382.0" layoutY="2.0" stylesheets="@../css/prefrence.css"
text="Other" textFill="WHITE">
<Label alignment="CENTER" layoutX="382.0" layoutY="2.0" stylesheets="@../css/prefrence.css" text="Other" textFill="WHITE">
<font>
<Font size="14.0"/>
<Font size="14.0" />
</font>
</Label>
</Pane>
<Pane prefHeight="159.0" prefWidth="800.0">
<HBox prefHeight="162.0" prefWidth="800.0" styleClass="background"
stylesheets="@../css/prefrence.css"/>
<HBox prefHeight="162.0" prefWidth="800.0" styleClass="background" stylesheets="@../css/prefrence.css" />
</Pane>
</VBox>
</top>

@ -6,6 +6,7 @@ import helper.windowOpener;
import javafx.fxml.FXML;
import javafx.geometry.Rectangle2D;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
@ -16,12 +17,14 @@ import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.io.IOException;
import java.util.prefs.Preferences;
/**
* @author <a href="http://lukasmartin.eu">Lukas Martin</a>
*/
public class homeController {
//Helper
menuCloser mCloser = new menuCloser(); //menu closer
Boolean sliderClicked = false; //Menu slider activated
@ -39,10 +42,12 @@ public class homeController {
@FXML private BorderPane hboxmen; //Unused
@FXML private BorderPane optionsmenu; //Options Menu Button
@FXML private VBox menuslideV; //Menu slider
@FXML private Label usernameMenuLabel; //Menu Slider Username Label
//coordinates
//const
double x,y; //x and y coordinates from monitor
Preferences pref0 = Preferences.userRoot().node("genealogieresearchtool/Test"); //Gets the user preferences
//top menu
@ -115,6 +120,7 @@ public class homeController {
mCloser.openMenu(menuslideV, filesmenu, optionsmenu, true); //Opens first given menu and closes the others
Stage stage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow(); //Gets the current windows
menuslideV.prefHeightProperty().bind(stage.heightProperty()); //Bind the menu height to the current window height.
usernameMenuLabel.setText(pref0.get("username", "Max Mustermann"));
}

@ -1,9 +1,16 @@
package controller;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
/**
* @author <a href="http://lukasmartin.eu">Lukas Martin</a>
*/
@ -11,8 +18,14 @@ import javafx.stage.Stage;
public class preferenceController {
//FXML
@FXML private TextField usernameInputField;
@FXML private TextField nameInputField;
//Const
double x,y;
Preferences pref0 = Preferences.userRoot().node("genealogieresearchtool/Test"); //Gets the user preferences
//Menu Top Bar pressed
@ -33,8 +46,23 @@ public class preferenceController {
//Close Button
public void closeButtonClicked(MouseEvent mouseEvent) {
public void closeButtonClicked(MouseEvent mouseEvent) throws IOException, BackingStoreException {
Stage stage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow(); //Gets the current window
FileOutputStream fos = new FileOutputStream("./pref0.xml"); //Gets xml file
pref0.put("username", usernameInputField.getText()); //Saves username in preferences
pref0.put("name", nameInputField.getText()); //Saves name in preferences
pref0.exportNode(fos); //Export the preferences to xml file
fos.close(); //Closes xml file
stage.close(); //Closes the window
}
//Save Button
public void saveButtonClicked(MouseEvent mouseEvent) throws IOException, BackingStoreException {
FileOutputStream fos = new FileOutputStream("/.pref0.xml"); //Gets xml file
pref0.put("username", usernameInputField.getText()); //Saves username in preferences
pref0.put("name", nameInputField.getText()); //Saves name in preferences
pref0.exportNode(fos); //Export the preferences to xml file
fos.close(); //Closes xml file
}
}

@ -9,6 +9,7 @@ module Genologie {
requires javafx.swt;
requires FX.BorderlessScene;
requires com.jfoenix;
requires java.prefs;
opens genologie_app;
opens controller;

@ -121,7 +121,7 @@
</font>
</Text>
<VBox id="menuslide" fx:id="menuslideV" prefHeight="622.0" prefWidth="200.0" stylesheets="@../css/home.css" visible="false">
<Label prefHeight="20.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" />
<Label fx:id="usernameMenuLabel" prefHeight="20.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" />
<JFXListCell id="buttonStammbaum" fx:id="buttonStammbaum" onMouseClicked="#buttonStammbaumClicked" prefHeight="40.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" text="Stammbaum" textFill="WHITE" />
<JFXListCell id="buttonPeople" fx:id="buttonPeople" onMouseClicked="#buttonPeopleClicked" prefHeight="40.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" text="People" textFill="WHITE" />
<JFXListCell id="buttonPictrues" fx:id="buttonPictures" onMouseClicked="#buttonPicturesClicked" prefHeight="40.0" prefWidth="198.0" styleClass="buttonMenu" stylesheets="@../css/home.css" text="Pictures" textFill="WHITE" />

@ -36,7 +36,12 @@
<padding>
<Insets bottom="2.0" left="5.0" right="5.0" top="2.0" />
</padding>
<FontAwesomeIcon fill="#f20000" iconName="CLOSE" onMousePressed="#closeButtonClicked" scaleX="1.1" scaleY="1.1" scaleZ="1.1" selectionEnd="0" selectionFill="#f20000" />
<FontAwesomeIcon fill="#bf9728" iconName="SAVE" onMouseClicked="#saveButtonClicked" scaleX="0.8" scaleY="0.8" selectionFill="#b09515" text="">
<HBox.margin>
<Insets bottom="2.0" left="2.0" right="6.0" top="3.0" />
</HBox.margin>
</FontAwesomeIcon>
<FontAwesomeIcon fill="#f20000" iconName="CLOSE" onMousePressed="#closeButtonClicked" scaleX="1.2" scaleY="1.2" scaleZ="1.2" selectionEnd="0" selectionFill="#f20000" />
</HBox>
</right>
</BorderPane>
@ -61,9 +66,9 @@
<HBox prefHeight="150.0" prefWidth="800.0" stylesheets="@../css/prefrence.css">
<Pane prefHeight="150.0" prefWidth="270.0" styleClass="background" stylesheets="@../css/prefrence.css">
<Label layoutX="104.0" layoutY="14.0" text="Nickname" textFill="WHITE" />
<TextField id="nicknameField" layoutX="34.0" layoutY="32.0" prefHeight="26.0" prefWidth="200.0" stylesheets="@../css/prefrence.css" />
<TextField id="nicknameField" fx:id="usernameInputField" layoutX="34.0" layoutY="32.0" prefHeight="26.0" prefWidth="200.0" stylesheets="@../css/prefrence.css" />
<Label layoutX="84.0" layoutY="90.0" text="Vor &amp; Nachname" textFill="WHITE" />
<TextField id="nicknameField" layoutX="34.0" layoutY="109.0" prefHeight="26.0" prefWidth="200.0" stylesheets="@../css/prefrence.css" />
<TextField id="nicknameField" fx:id="nameInputField" layoutX="34.0" layoutY="109.0" prefHeight="26.0" prefWidth="200.0" stylesheets="@../css/prefrence.css" />
</Pane>
<Pane prefHeight="150.0" prefWidth="270.0" styleClass="background" stylesheets="@../css/prefrence.css">
<Label layoutX="114.0" layoutY="14.0" text="Design" textFill="WHITE" />

Loading…
Cancel
Save