added categories
This commit is contained in:
parent
281c51fe22
commit
e130401126
|
@ -75,8 +75,7 @@ class DBController
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// table Position section
|
||||
public void createTablePositionen()
|
||||
{ // create table position
|
||||
|
@ -85,7 +84,7 @@ class DBController
|
|||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("DROP TABLE IF EXISTS positionen;");
|
||||
stmt.executeUpdate(
|
||||
"CREATE TABLE positionen (id, name, value, color);");
|
||||
"CREATE TABLE positionen (posid, name, value, cat, color);");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
|
@ -93,21 +92,91 @@ class DBController
|
|||
|
||||
// create 25 demo/default data entries
|
||||
for (int i = 0; i < 25; i++) {
|
||||
fillPositionen(i + 1, "Noch frei", (float) 0.00, "#ad0000");
|
||||
fillPositionen_Positionen(i + 1, "Noch frei", (float) 0.00,
|
||||
((int) (i / 5)) + 1, "#ad0000");
|
||||
}
|
||||
}
|
||||
|
||||
public void fillPositionen(int pID, String pName, float pValue,
|
||||
String pColor)
|
||||
public void createTableCategory()
|
||||
{ // create table position
|
||||
System.out.println("Erstelle Tabelle Kategorie");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("DROP TABLE IF EXISTS category;");
|
||||
stmt.executeUpdate("CREATE TABLE category (catid, catname);");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (int i = 1; i < 6; i++) {
|
||||
fillCategory_Category(i, "Cat: " + (i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getCategoryNameFromPositionen(int pID)
|
||||
{
|
||||
//System.out.println("getCategoryName: " + pID);
|
||||
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT posid, cat, catid, catname FROM positionen, category "
|
||||
+ "WHERE posid = " + pID + " AND cat = catid;");
|
||||
return rs.getString("catname");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "Error 404";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setName_Category(int pID, String pName)
|
||||
{ // Setzte den Namen
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE category SET catname = '" + pName
|
||||
+ "'WHERE catid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void fillCategory_Category(int pID, String pName)
|
||||
{
|
||||
|
||||
System.out.println("Erstelle neuen Kategorie Eintrag");
|
||||
try {
|
||||
PreparedStatement ps = connection
|
||||
.prepareStatement("INSERT INTO category VALUES (?, ?);");
|
||||
ps.setInt(1, pID); // primary
|
||||
ps.setString(2, pName);
|
||||
ps.addBatch();
|
||||
connection.setAutoCommit(false);
|
||||
ps.executeBatch(); // SQL execution
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void fillPositionen_Positionen(int pID, String pName, float pValue,
|
||||
int pCat, String pColor)
|
||||
{ // create new data in table
|
||||
System.out.println("Erstelle neuen positionen eintrag");
|
||||
try {
|
||||
PreparedStatement ps = connection
|
||||
.prepareStatement("INSERT INTO positionen VALUES (?, ?, ?, ?);");
|
||||
PreparedStatement ps = connection.prepareStatement(
|
||||
"INSERT INTO positionen VALUES (?, ?, ?, ?, ?);");
|
||||
ps.setInt(1, pID); // primary
|
||||
ps.setString(2, pName);
|
||||
ps.setFloat(3, pValue);
|
||||
ps.setString(4, pColor);
|
||||
ps.setInt(4, pCat);
|
||||
ps.setString(5, pColor);
|
||||
|
||||
ps.addBatch();
|
||||
connection.setAutoCommit(false);
|
||||
|
@ -119,12 +188,12 @@ class DBController
|
|||
}
|
||||
}
|
||||
|
||||
public String getName(int pID)
|
||||
public String getName_Positionen(int pID)
|
||||
{ // Gibt das Datum zurück
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT id, name FROM positionen WHERE id = " + pID + ";");
|
||||
"SELECT posid, name FROM positionen WHERE posid = " + pID + ";");
|
||||
return rs.getString("name");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
|
@ -133,12 +202,28 @@ class DBController
|
|||
}
|
||||
}
|
||||
|
||||
public String getValue(int pID)
|
||||
public String getName_Category(int pID)
|
||||
{ // Gibt das Datum zurück
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT catid, catname FROM category WHERE catid = " + pID
|
||||
+ ";");
|
||||
return rs.getString("catname");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "Error 404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue_Positionen(int pID)
|
||||
{ // Gibt das Konto zurück
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT id, value FROM positionen WHERE id = " + pID + ";");
|
||||
"SELECT posid, value FROM positionen WHERE posid = " + pID
|
||||
+ ";");
|
||||
return rs.getString("value");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
|
@ -147,12 +232,28 @@ class DBController
|
|||
}
|
||||
}
|
||||
|
||||
public String getColor(int pID)
|
||||
public int getCat_Positionen(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT id, color FROM positionen WHERE id = " + pID + ";");
|
||||
"SELECT catid, cat FROM positionen WHERE catid = " + pID + ";");
|
||||
System.out.println("getCarTet: " + rs.getInt("cat"));
|
||||
return rs.getInt("cat");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public String getColor_Positionen(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT posid, color FROM positionen WHERE posid = " + pID
|
||||
+ ";");
|
||||
return rs.getString("color");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
|
@ -161,36 +262,48 @@ class DBController
|
|||
}
|
||||
}
|
||||
|
||||
public void setName(int pID, String pName)
|
||||
public void setName_Positionen(int pID, String pName)
|
||||
{ // Setzt das Datum
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET name = '" + pName
|
||||
+ "'WHERE id =" + pID + ";");
|
||||
+ "'WHERE posid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(int pID, String pValue)
|
||||
public void setValue_Positionen(int pID, String pValue)
|
||||
{ // Setzt das Konto
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET value = '" + pValue
|
||||
+ "'WHERE id =" + pID + ";");
|
||||
+ "'WHERE posid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor(int pID, String pColor)
|
||||
public void setCat_Positionen(int pID, int pCat)
|
||||
{ // Setzt den Nutzername
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET cat = '" + pCat
|
||||
+ "'WHERE catid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor_Positionen(int pID, String pColor)
|
||||
{ // Setzt den Nutzername
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET color = '" + pColor
|
||||
+ "'WHERE id =" + pID + ";");
|
||||
+ "'WHERE posid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
|
@ -206,9 +319,9 @@ class DBController
|
|||
while (rs.next()) {
|
||||
try {
|
||||
// Entschlüsselte Daten werden als Datenobjekt gespeichert
|
||||
daten.add(new tableDataPositionen(rs.getInt("id"),
|
||||
daten.add(new tableDataPositionen(rs.getInt("posid"),
|
||||
rs.getString("name"), rs.getString("value"),
|
||||
rs.getString("color")));
|
||||
rs.getString("cat"), rs.getString("color")));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -220,7 +333,7 @@ class DBController
|
|||
}
|
||||
return daten;
|
||||
}
|
||||
|
||||
|
||||
public void ausgebenSysoPositionen()
|
||||
{ // Debugging Ausgabe der kompletten Tabelle
|
||||
System.out.println("Print positionen");
|
||||
|
@ -228,7 +341,7 @@ class DBController
|
|||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM positionen;");
|
||||
while (rs.next()) {
|
||||
System.out.println("id = " + rs.getString("id"));
|
||||
System.out.println("posid = " + rs.getString("posid"));
|
||||
System.out.println("name = " + rs.getString("name"));
|
||||
System.out.println("vale = " + rs.getString("value"));
|
||||
System.out.println("color = " + rs.getString("color"));
|
||||
|
@ -241,7 +354,6 @@ class DBController
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// table Jobs section
|
||||
public void erstelleTabelleJobs()
|
||||
{ // Erstelle Tabelle mit Reihen
|
||||
|
@ -257,7 +369,4 @@ class DBController
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class Main extends Application
|
|||
FXMLLoader loader = new FXMLLoader(
|
||||
getClass().getResource("MainWindow.fxml"));
|
||||
AnchorPane pane = loader.load();
|
||||
primaryStage.setTitle("jFxKasse - devVersion"); // Title of window
|
||||
primaryStage.setTitle("jFxKasse"); // Title of window
|
||||
|
||||
mwc = loader.getController();
|
||||
mwc.setMain(this, dbc);
|
||||
|
@ -76,7 +76,9 @@ public class Main extends Application
|
|||
dbc.dbname = mwc.getDatabaseName(); // handover database name
|
||||
dbc.connectDatabase(); // estabishing DB conection
|
||||
mwc.fillTablePositionen(); // fill TreeTable 'Positionen'
|
||||
mwc.fillCategory();
|
||||
mwc.loadGridButtons();
|
||||
mwc.getSelectedCat(); //Load DB entries in Chois Box
|
||||
} else {
|
||||
// config.xml NOT found, first start of app
|
||||
System.out.println("keine XML gefunden!");
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
<content>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||
<children>
|
||||
<Button fx:id="ueberbtn" layoutX="664.0" layoutY="325.0" mnemonicParsing="false" onAction="#ueberbtnAction" text="Über" />
|
||||
<TitledPane alignment="CENTER" animated="false" collapsible="false" contentDisplay="CENTER" layoutX="790.0" layoutY="10.0" prefHeight="163.0" prefWidth="566.0" text="Datenbank">
|
||||
<Button fx:id="ueberbtn" layoutX="84.0" layoutY="79.0" mnemonicParsing="false" onAction="#ueberbtnAction" prefHeight="0.0" prefWidth="46.0" text="Über" />
|
||||
<TitledPane alignment="CENTER" animated="false" collapsible="false" contentDisplay="CENTER" layoutX="790.0" layoutY="10.0" prefHeight="270.0" prefWidth="566.0" text="Datenbank Einstellungen">
|
||||
<content>
|
||||
<AnchorPane fx:id="paneDB" minHeight="0.0" minWidth="0.0" prefHeight="135.0" prefWidth="547.0">
|
||||
<AnchorPane fx:id="paneDB" minHeight="0.0" minWidth="0.0" prefHeight="238.0" prefWidth="564.0">
|
||||
<children>
|
||||
<Label fx:id="labelDBName" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="329.0" layoutY="10.0" prefHeight="34.0" prefWidth="229.0" text="Datenbankname:">
|
||||
<font>
|
||||
|
@ -36,17 +36,17 @@
|
|||
</font>
|
||||
</Label>
|
||||
<JFXTextField fx:id="tftNewDBName" alignment="CENTER" layoutX="25.0" layoutY="10.0" prefHeight="25.0" prefWidth="376.0" />
|
||||
<Label fx:id="labelDBStatus" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="7.0" layoutY="50.0" prefHeight="34.0" prefWidth="551.0" text="Keine Datenbank gefunden!">
|
||||
<Label fx:id="labelDBStatus" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="1.0" layoutY="75.0" prefHeight="34.0" prefWidth="551.0" text="Keine Datenbank gefunden!">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button fx:id="btnCreateNewDatabase" layoutX="297.0" layoutY="90.0" mnemonicParsing="false" onAction="#btnCreateNewDatabaseAction" text="Neue Datenbank anlegen">
|
||||
<Button fx:id="btnCreateNewDatabase" layoutX="317.0" layoutY="126.0" mnemonicParsing="false" onAction="#btnCreateNewDatabaseAction" text="Neue Datenbank anlegen">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="13.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<Button fx:id="btnOpenFolder" layoutX="39.0" layoutY="90.0" mnemonicParsing="false" onAction="#btnOpenFolderAction" text="Speicherort öffnen">
|
||||
<Button fx:id="btnOpenFolder" layoutX="99.0" layoutY="126.0" mnemonicParsing="false" onAction="#btnOpenFolderAction" text="Speicherort öffnen">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="13.0" />
|
||||
</font>
|
||||
|
@ -57,6 +57,52 @@
|
|||
<font>
|
||||
<Font name="Cantarell Regular" size="13.0" />
|
||||
</font>
|
||||
</TitledPane>
|
||||
<TitledPane fx:id="titlePaneCat" alignment="CENTER" animated="false" collapsible="false" contentDisplay="CENTER" layoutX="170.0" layoutY="10.0" prefHeight="270.0" prefWidth="566.0" text="Kategorien (z.B. Getränke, Essen oder Kuchen)" textAlignment="CENTER">
|
||||
<content>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="260.0" prefWidth="564.0">
|
||||
<children>
|
||||
<Label fx:id="labelCat01" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="434.0" layoutY="10.0" prefHeight="34.0" prefWidth="124.0" text="Kategorie 1:">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="labelCat02" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="442.0" layoutY="50.0" prefHeight="34.0" prefWidth="116.0" text="Kategorie 2:">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="labelCat05" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="448.0" layoutY="170.0" prefHeight="34.0" prefWidth="110.0" text="Kategorie 5:">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="labelCat04" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="454.0" layoutY="130.0" prefHeight="34.0" prefWidth="104.0" text="Kategorie 4:">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="labelCat03" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="451.0" layoutY="90.0" prefHeight="34.0" prefWidth="107.0" text="Kategorie 3:">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<JFXTextField fx:id="tftKat01" alignment="CENTER" layoutX="50.0" layoutY="5.0" prefHeight="25.0" prefWidth="376.0" />
|
||||
<JFXTextField fx:id="tftKat02" alignment="CENTER" layoutX="50.0" layoutY="45.0" prefHeight="25.0" prefWidth="376.0" />
|
||||
<JFXTextField fx:id="tftKat03" alignment="CENTER" layoutX="50.0" layoutY="85.0" prefHeight="25.0" prefWidth="376.0" />
|
||||
<JFXTextField fx:id="tftKat04" alignment="CENTER" layoutX="50.0" layoutY="125.0" prefHeight="25.0" prefWidth="376.0" />
|
||||
<JFXTextField fx:id="tftKat05" alignment="CENTER" layoutX="50.0" layoutY="165.0" prefHeight="25.0" prefWidth="376.0" />
|
||||
<Button fx:id="btnSaveCat" layoutX="200.0" layoutY="204.0" mnemonicParsing="false" onAction="#btnSaveCatAction" text="Kategorien speichern">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="13.0" />
|
||||
</font>
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="13.0" />
|
||||
</font>
|
||||
</TitledPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
@ -68,10 +114,11 @@
|
|||
<children>
|
||||
<TreeTableView fx:id="entryTreeTable" layoutX="11.0" layoutY="10.0" prefHeight="502.0" prefWidth="1346.0">
|
||||
<columns>
|
||||
<TreeTableColumn fx:id="columnColor" editable="false" maxWidth="200.0" minWidth="200.0" prefWidth="200.0" resizable="false" sortable="false" text="Farbe" />
|
||||
<TreeTableColumn fx:id="columnPrize" editable="false" maxWidth="200.0" minWidth="200.0" prefWidth="200.0" resizable="false" sortable="false" text="Preis" />
|
||||
<TreeTableColumn fx:id="columnPositionsEdit" editable="false" maxWidth="800.0" minWidth="800.0" prefWidth="800.0" resizable="false" sortable="false" text="Positionen" />
|
||||
<TreeTableColumn fx:id="columnPosnumber" editable="false" maxWidth="120.0" minWidth="120.0" prefWidth="120.0" resizable="false" sortable="false" text="Nummer" />
|
||||
<TreeTableColumn fx:id="columnColor" editable="false" maxWidth="237.3333740234375" minWidth="164.0" prefWidth="164.0" resizable="false" sortable="false" text="Farbe" />
|
||||
<TreeTableColumn fx:id="columnCat" editable="false" maxWidth="800.0" minWidth="176.33331298828125" prefWidth="370.0" resizable="false" sortable="false" text="Kategorie" />
|
||||
<TreeTableColumn fx:id="columnPrize" editable="false" maxWidth="693.3333129882812" minWidth="44.33331298828125" prefWidth="126.66668701171875" resizable="false" sortable="false" text="Preis" />
|
||||
<TreeTableColumn fx:id="columnPositionsEdit" editable="false" maxWidth="1581.6666870117188" minWidth="38.0" prefWidth="543.3333129882812" resizable="false" sortable="false" text="Positionen" />
|
||||
<TreeTableColumn fx:id="columnPosnumber" editable="false" maxWidth="1218.0" minWidth="60.666748046875" prefWidth="148.6666259765625" resizable="false" sortable="false" text="Nummer" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TreeTableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
|
@ -114,7 +161,13 @@
|
|||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<ChoiceBox fx:id="colorChoise" layoutX="292.0" layoutY="95.0" prefWidth="150.0" />
|
||||
<ChoiceBox fx:id="colorChoise" layoutX="346.0" layoutY="90.0" prefHeight="25.0" prefWidth="96.0" />
|
||||
<Label fx:id="lableSelectCat" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="204.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Kategorie:">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<ChoiceBox fx:id="catChoise" layoutX="25.0" layoutY="90.0" prefHeight="25.0" prefWidth="180.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
|
|
|
@ -23,6 +23,9 @@ import java.text.DateFormat;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
|
@ -87,6 +90,9 @@ public class MainWindowController
|
|||
@FXML
|
||||
private TreeTableColumn<tableDataPositionen, String> columnColor;
|
||||
|
||||
@FXML
|
||||
private TreeTableColumn<tableDataPositionen, String> columnCat;
|
||||
|
||||
@FXML
|
||||
private TreeTableColumn<tableDataPositionen, String> columnPrize;
|
||||
|
||||
|
@ -99,6 +105,9 @@ public class MainWindowController
|
|||
@FXML
|
||||
private ChoiceBox<String> colorChoise;
|
||||
|
||||
@FXML
|
||||
private ChoiceBox<String> catChoise;
|
||||
|
||||
@FXML
|
||||
private Button ueberbtn;
|
||||
|
||||
|
@ -207,6 +216,39 @@ public class MainWindowController
|
|||
@FXML
|
||||
private Button btnOpenFolder;
|
||||
|
||||
@FXML
|
||||
private Label labelCat01;
|
||||
|
||||
@FXML
|
||||
private Label labelCat02;
|
||||
|
||||
@FXML
|
||||
private Label labelCat05;
|
||||
|
||||
@FXML
|
||||
private Label labelCat04;
|
||||
|
||||
@FXML
|
||||
private Label labelCat03;
|
||||
|
||||
@FXML
|
||||
private JFXTextField tftKat01;
|
||||
|
||||
@FXML
|
||||
private JFXTextField tftKat02;
|
||||
|
||||
@FXML
|
||||
private JFXTextField tftKat03;
|
||||
|
||||
@FXML
|
||||
private JFXTextField tftKat04;
|
||||
|
||||
@FXML
|
||||
private JFXTextField tftKat05;
|
||||
|
||||
@FXML
|
||||
private Button btnSaveCat;
|
||||
|
||||
@FXML
|
||||
private Label labelAllPrize;
|
||||
|
||||
|
@ -225,6 +267,9 @@ public class MainWindowController
|
|||
@FXML
|
||||
private Label lableAllValue;
|
||||
|
||||
@FXML
|
||||
private Label lableSelectCat;
|
||||
|
||||
@FXML
|
||||
private Label lableNewPosition;
|
||||
|
||||
|
@ -243,6 +288,9 @@ public class MainWindowController
|
|||
@FXML
|
||||
private TitledPane titlePaneStats;
|
||||
|
||||
@FXML
|
||||
private TitledPane titlePaneCat;
|
||||
|
||||
@FXML
|
||||
private TextField tftNewPosition;
|
||||
|
||||
|
@ -264,6 +312,8 @@ public class MainWindowController
|
|||
|
||||
private String selectedColorName;
|
||||
|
||||
private String selectedCatName;
|
||||
|
||||
private String databaseName;
|
||||
|
||||
private boolean lockState = false;
|
||||
|
@ -277,7 +327,7 @@ public class MainWindowController
|
|||
|
||||
@FXML
|
||||
TreeItem<tableDataPositionen> rootPositionen = new TreeItem<>(
|
||||
new tableDataPositionen(0, "0", "0", "0"));
|
||||
new tableDataPositionen(0, "0", "0", "0", "0"));
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
|
@ -330,6 +380,7 @@ public class MainWindowController
|
|||
dbc.connectDatabase(); // establish DB connection
|
||||
dbc.createTablePositionen(); // Create new table
|
||||
dbc.erstelleTabelleJobs(); // Create new table
|
||||
dbc.createTableCategory(); // Create new table
|
||||
try {
|
||||
saveSettings(getDatabaseName());
|
||||
} catch (Exception e) {
|
||||
|
@ -339,6 +390,7 @@ public class MainWindowController
|
|||
setDBLabel(); // Set new databese labels
|
||||
blockUI(false); // unlock UI elements that need DB
|
||||
fillTablePositionen(); // fill TreeTable 'Positionen'
|
||||
fillCategory();
|
||||
initUI(); // Starting the UI elements
|
||||
|
||||
}
|
||||
|
@ -348,10 +400,11 @@ public class MainWindowController
|
|||
{
|
||||
System.out.println("Speichere Eintrag!");
|
||||
|
||||
dbc.setName(idPositionen, tftNewPosition.getText());
|
||||
dbc.setValue(idPositionen, tftNewValue.getText());
|
||||
dbc.setColor(idPositionen, getColorCodes(selectedColorName));
|
||||
dbc.setName_Positionen(idPositionen, tftNewPosition.getText());
|
||||
dbc.setValue_Positionen(idPositionen, tftNewValue.getText());
|
||||
dbc.setColor_Positionen(idPositionen, getColorCodes(selectedColorName));
|
||||
|
||||
System.out.println("refill pos");
|
||||
fillTablePositionen(); // fill TreeTable 'Positionen'
|
||||
loadGridButtons();
|
||||
|
||||
|
@ -361,9 +414,9 @@ public class MainWindowController
|
|||
public void btnClearEntryAction(ActionEvent event)
|
||||
{
|
||||
// set default values
|
||||
dbc.setName(idPositionen, "Noch frei");
|
||||
dbc.setValue(idPositionen, "0.00");
|
||||
dbc.setColor(idPositionen, "#FAF0E6");
|
||||
dbc.setName_Positionen(idPositionen, "Noch frei");
|
||||
dbc.setValue_Positionen(idPositionen, "0.00");
|
||||
dbc.setColor_Positionen(idPositionen, "#FAF0E6");
|
||||
|
||||
fillTablePositionen(); // fill TreeTable 'Positionen'
|
||||
}
|
||||
|
@ -401,6 +454,23 @@ public class MainWindowController
|
|||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void btnSaveCatAction(ActionEvent event)
|
||||
{
|
||||
System.out.println("Cat´s speichern");
|
||||
|
||||
dbc.setName_Category(1, tftKat01.getText());
|
||||
dbc.setName_Category(2, tftKat02.getText());
|
||||
dbc.setName_Category(3, tftKat03.getText());
|
||||
dbc.setName_Category(4, tftKat04.getText());
|
||||
dbc.setName_Category(5, tftKat05.getText());
|
||||
|
||||
fillCategory();
|
||||
fillTablePositionen();
|
||||
getSelectedCat();
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void btnDeleteSelectedPositionAction(ActionEvent event)
|
||||
{
|
||||
|
@ -567,6 +637,7 @@ public class MainWindowController
|
|||
@FXML
|
||||
public void fillTablePositionen()
|
||||
{ // loads the table in the TreeTableView
|
||||
|
||||
rootPositionen.getChildren().remove(0,
|
||||
rootPositionen.getChildren().size());
|
||||
|
||||
|
@ -575,11 +646,17 @@ public class MainWindowController
|
|||
dbc.ladeTabellePositionen().get(i).getID(),
|
||||
dbc.ladeTabellePositionen().get(i).getName(),
|
||||
dbc.ladeTabellePositionen().get(i).getValue() + " €",
|
||||
|
||||
// dbc.ladeTabellePositionen().get(i).getCat(),
|
||||
// dbc.getCategoryName(dbc.ladeTabellePositionen().get(i).getCat()))
|
||||
dbc.getCategoryNameFromPositionen(i + 1),
|
||||
|
||||
getColorNames(dbc.ladeTabellePositionen().get(i).getColor()));
|
||||
|
||||
rootPositionen.getChildren()
|
||||
.add(new TreeItem<tableDataPositionen>(helpTableData));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void initUI()
|
||||
|
@ -587,6 +664,50 @@ public class MainWindowController
|
|||
System.out.println("initUI");
|
||||
tftNewDBName.setText(getDatabaseName());
|
||||
initPositionen();
|
||||
|
||||
}
|
||||
|
||||
public int getSelectedCat()
|
||||
{
|
||||
|
||||
ObservableList<String> cats = FXCollections.observableArrayList();
|
||||
|
||||
cats.add(dbc.getName_Category(1));
|
||||
cats.add(dbc.getName_Category(2));
|
||||
cats.add(dbc.getName_Category(3));
|
||||
cats.add(dbc.getName_Category(4));
|
||||
cats.add(dbc.getName_Category(5));
|
||||
|
||||
catChoise.setItems(cats);
|
||||
catChoise.getSelectionModel().selectedIndexProperty()
|
||||
.addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> ov,
|
||||
Number value, Number new_value)
|
||||
{
|
||||
selectedCatName = catChoise.getItems().get((int) new_value)
|
||||
.toString();
|
||||
|
||||
System.out.println("Ausgewählte Cat: " + selectedCatName);
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 1; i < 5; i++) {
|
||||
if (selectedCatName == dbc.getName_Category(i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void fillCategory()
|
||||
{
|
||||
tftKat01.setText(dbc.getName_Category(1));
|
||||
tftKat02.setText(dbc.getName_Category(2));
|
||||
tftKat03.setText(dbc.getName_Category(3));
|
||||
tftKat04.setText(dbc.getName_Category(4));
|
||||
tftKat05.setText(dbc.getName_Category(5));
|
||||
}
|
||||
|
||||
private void initPositionen()
|
||||
|
@ -619,6 +740,9 @@ public class MainWindowController
|
|||
columnPrize.setCellValueFactory(
|
||||
cellData -> cellData.getValue().getValue().valueProperty());
|
||||
|
||||
columnCat.setCellValueFactory(
|
||||
cellData -> cellData.getValue().getValue().catProperty());
|
||||
|
||||
columnColor.setCellValueFactory(
|
||||
cellData -> cellData.getValue().getValue().colorProperty());
|
||||
|
||||
|
@ -631,18 +755,20 @@ public class MainWindowController
|
|||
// last = selected; //for auto-play
|
||||
int selected = entryTreeTable.getSelectionModel()
|
||||
.getSelectedIndex(); // get selected item
|
||||
|
||||
idPositionen = columnPosnumber.getCellData(selected); // Ausgewählte
|
||||
// Spalte
|
||||
// Spalte
|
||||
|
||||
System.out.println(
|
||||
"Positionen - Ausgewaehlte Spalte: " + idPositionen);
|
||||
|
||||
try { // Setzt den Inhalt in die Textfelder
|
||||
|
||||
tftNewPosition.setText(dbc.getName(idPositionen));
|
||||
tftNewValue.setText(dbc.getValue(idPositionen));
|
||||
colorChoise.getSelectionModel()
|
||||
.select(getColorID(dbc.getColor(idPositionen)));
|
||||
tftNewPosition
|
||||
.setText(dbc.getName_Positionen(idPositionen));
|
||||
tftNewValue.setText(dbc.getValue_Positionen(idPositionen));
|
||||
colorChoise.getSelectionModel().select(
|
||||
getColorID(dbc.getColor_Positionen(idPositionen)));
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
@ -654,6 +780,7 @@ public class MainWindowController
|
|||
columnPosnumber.setStyle("-fx-alignment: CENTER;");
|
||||
columnPositionsEdit.setStyle("-fx-alignment: CENTER;");
|
||||
columnPrize.setStyle("-fx-alignment: CENTER;");
|
||||
columnCat.setStyle("-fx-alignment: CENTER;");
|
||||
columnColor.setStyle("-fx-alignment: CENTER;");
|
||||
|
||||
tftNewValue.textProperty().addListener(new ChangeListener<String>() {
|
||||
|
@ -855,6 +982,9 @@ public class MainWindowController
|
|||
labelJobCounter.setVisible(!pState);
|
||||
|
||||
titlePaneStats.setVisible(!pState);
|
||||
|
||||
titlePaneCat.setDisable(pState);
|
||||
|
||||
}
|
||||
|
||||
public void loadGridButtons()
|
||||
|
@ -862,22 +992,22 @@ public class MainWindowController
|
|||
|
||||
for (int i = 0; i < 25; i++) {
|
||||
|
||||
getButtonByID(i).setText(dbc.getName(i + 1));
|
||||
getButtonByID(i).setText(dbc.getName_Positionen(i + 1));
|
||||
|
||||
if ((getColorID(dbc.getColor(i + 1)) == 0)
|
||||
|| (getColorID(dbc.getColor(i + 1)) == 7)) {
|
||||
if ((getColorID(dbc.getColor_Positionen(i + 1)) == 0)
|
||||
|| (getColorID(dbc.getColor_Positionen(i + 1)) == 7)) {
|
||||
getButtonByID(i).setStyle("-fx-background-color: "
|
||||
+ dbc.getColor(i + 1) + "; -fx-text-fill: white;");
|
||||
+ dbc.getColor_Positionen(i + 1) + "; -fx-text-fill: white;");
|
||||
} else {
|
||||
getButtonByID(i).setStyle("-fx-background-color: "
|
||||
+ dbc.getColor(i + 1) + "; -fx-text-fill: black;");
|
||||
+ dbc.getColor_Positionen(i + 1) + "; -fx-text-fill: black;");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < 25; i++) {
|
||||
|
||||
if (dbc.getName(i + 1).equals("Noch frei")) {
|
||||
if (dbc.getName_Positionen(i + 1).equals("Noch frei")) {
|
||||
getButtonByID(i).setVisible(false);
|
||||
} else {
|
||||
getButtonByID(i).setVisible(true);
|
||||
|
|
|
@ -14,13 +14,16 @@ public class tableDataPositionen
|
|||
|
||||
private final StringProperty value = new SimpleStringProperty();
|
||||
|
||||
private final StringProperty cat = new SimpleStringProperty();
|
||||
|
||||
private final StringProperty color = new SimpleStringProperty();
|
||||
|
||||
public tableDataPositionen(final int id, final String name, final String value, final String color)
|
||||
public tableDataPositionen(final int id, final String name, final String value, final String cat, final String color)
|
||||
{
|
||||
this.id.set(id);
|
||||
this.name.set(name);
|
||||
this.value.set(value);
|
||||
this.cat.set(cat);
|
||||
this.color.set(color);
|
||||
}
|
||||
|
||||
|
@ -39,6 +42,10 @@ public class tableDataPositionen
|
|||
return value;
|
||||
}
|
||||
|
||||
public StringProperty catProperty() {
|
||||
return cat;
|
||||
}
|
||||
|
||||
public StringProperty colorProperty()
|
||||
{
|
||||
return color;
|
||||
|
@ -59,6 +66,10 @@ public class tableDataPositionen
|
|||
return valueProperty().get();
|
||||
}
|
||||
|
||||
public String getCat() {
|
||||
return catProperty().get();
|
||||
}
|
||||
|
||||
public String getColor()
|
||||
{
|
||||
return colorProperty().get();
|
||||
|
@ -79,6 +90,10 @@ public class tableDataPositionen
|
|||
valueProperty().set(value);
|
||||
}
|
||||
|
||||
public final void setCat(String cat) {
|
||||
catProperty().set(cat);
|
||||
}
|
||||
|
||||
public final void setColor(String color)
|
||||
{
|
||||
colorProperty().set(color);
|
||||
|
|
Loading…
Reference in New Issue