diff --git a/bin/application/DBController$1.class b/bin/application/DBController$1.class
index 7674412..0df6e18 100644
Binary files a/bin/application/DBController$1.class and b/bin/application/DBController$1.class differ
diff --git a/bin/application/DBController.class b/bin/application/DBController.class
index f8dc481..9046e42 100644
Binary files a/bin/application/DBController.class and b/bin/application/DBController.class differ
diff --git a/bin/application/Main.class b/bin/application/Main.class
index 74c0752..47df276 100644
Binary files a/bin/application/Main.class and b/bin/application/Main.class differ
diff --git a/bin/application/MainWindow.fxml b/bin/application/MainWindow.fxml
index 4639820..386de26 100644
--- a/bin/application/MainWindow.fxml
+++ b/bin/application/MainWindow.fxml
@@ -26,6 +26,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class
index d81d294..0f36ac7 100644
Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ
diff --git a/src/application/DBController.java b/src/application/DBController.java
index da9ec20..a9e30e3 100644
--- a/src/application/DBController.java
+++ b/src/application/DBController.java
@@ -15,26 +15,24 @@ class DBController
private Connection connection;
- private String DB_PATH_Win = "C:/ProgramData/PWMaster/datenbank.db";
-
private String DB_PATH_Linux = System.getProperty("user.home")
- + "/bin/PWMaster/datenbank.db";
+ + "/bin/jFxKasse/";
+ public String dbname;
+
private Main main;
// private Cryption crypo = new Cryption();
private String schluessel; // Für Ver-/Entschlüsselung
+
+ boolean databasepresent = false;
public void main()
{
try {
- if (System.getProperty("os.name").equals("Linux")) {
connection = DriverManager
- .getConnection("jdbc:sqlite:" + DB_PATH_Linux);
- } else {
- connection = DriverManager
- .getConnection("jdbc:sqlite:" + DB_PATH_Win);
- }
+ .getConnection("jdbc:sqlite:" + DB_PATH_Linux + dbname + ".db");
+
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -48,18 +46,16 @@ class DBController
public void verbindeDatenbank()
{ // Verbinde mit der Datenbank-Datei
+ System.out.println("Verbinde ... DB name: " + dbname);
try {
if (connection != null)
return;
- if (System.getProperty("os.name").equals("Linux")) {
- connection = DriverManager
- .getConnection("jdbc:sqlite:" + DB_PATH_Linux);
- } else {
- connection = DriverManager
- .getConnection("jdbc:sqlite:" + DB_PATH_Win);
- }
+
+ connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_Linux + dbname + ".db");
+
+
if (!connection.isClosed())
- System.out.println();
+ System.out.println("DB Datei-Verbindung erstellt");
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -103,13 +99,29 @@ class DBController
}
}
- public void erstelleDatenbank()
+ public void erstelleTabellePositionen()
{ // Erstelle Tabelle mit Reihen
+ System.out.println("Erstelle Tabelle Positionen");
try {
Statement stmt = connection.createStatement();
- stmt.executeUpdate("DROP TABLE IF EXISTS konten;");
+ stmt.executeUpdate("DROP TABLE IF EXISTS positionen;");
stmt.executeUpdate(
- "CREATE TABLE konten (id, datum, konto, nutzername, email, passwort);");
+ "CREATE TABLE positionen (id, name, value, color);");
+ } catch (SQLException e) {
+ System.err.println("Couldn't handle DB-Query");
+ e.printStackTrace();
+ }
+ }
+
+
+ public void erstelleTabelleJobs()
+ { // Erstelle Tabelle mit Reihen
+ System.out.println("Erstelle Tabelle Jobs");
+ try {
+ Statement stmt = connection.createStatement();
+ stmt.executeUpdate("DROP TABLE IF EXISTS jobs;");
+ stmt.executeUpdate(
+ "CREATE TABLE jobs (id, time, positionen, state, value);");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
@@ -366,5 +378,13 @@ class DBController
{ // Setzt den Schlüssel für die Ver-/Entschlüsslung
schluessel = pSchluessel;
}
+
+ public boolean getDatabasePresent() {
+ return databasepresent;
+ }
+
+ public void setDatabasePresent(boolean status) {
+ databasepresent = status;
+ }
}
diff --git a/src/application/Main.java b/src/application/Main.java
index a3143c6..33f325b 100644
--- a/src/application/Main.java
+++ b/src/application/Main.java
@@ -61,10 +61,12 @@ public class Main extends Application
mwc.setMain(this, dbc);
firstStart(); // Prüft ob das Programm zuvor gestartet wurde
-
- dbc.main(); // Startet die Datenbank
- mwc.initUI(); // Startet die UI
- mwc.fuelleTablle(); // Ladt die Einträge in die Tabelle
+
+
+
+ // dbc.main(); // Startet die Datenbank
+
+ //mwc.fuelleTablle(); // Ladt die Einträge in die Tabelle
Scene scene = new Scene(pane);
scene.getStylesheets()
@@ -85,30 +87,35 @@ public class Main extends Application
{
if (mwc.loadSettings()) { // Wenn XML gefunden
+ System.out.println("XML gefunden!");
+ mwc.initUI(); // Startet die UI
+ mwc.setDBLabel();
+ dbc.dbname = mwc.getDatabaseName();
dbc.verbindeDatenbank(); // Verbindet mit der Datenbank-Datei
-
+
+
} else { // Wenn keine XML gefunden --> erster Start
System.out.println("keine XML gefunden!");
if (System.getProperty("os.name").equals("Linux")) {
File dir = new File(
- System.getProperty("user.home") + "/bin/PWMaster"); // Erstellt
+ System.getProperty("user.home") + "/bin/jFxKasse"); // Erstellt
// den
// Unterordner
dir.mkdir(); // Erstellt den Unterordner
} else {
- File dir = new File("C:/ProgramData/PWMaster/"); // Erstellt den
+ File dir = new File("C:/ProgramData/jFxKasse/"); // Erstellt den
// Unterordner
dir.mkdir(); // Erstellt den Unterordner
}
- mwc.saveSettings(schluesselNutzer, "dd"); // speichert das Passwort und
+ // mwc.saveSettings(mwc.getDatabaseName(), "dd"); // speichert das Passwort und
// den Individueller
// Schlüssel für die API in
// der XML
- dbc.verbindeDatenbank(); // Verbindet mit der Datenbank-Datei
- dbc.erstelleDatenbank(); // Neue Datenbank-Datei wird erstellt
- System.exit(0); // Programm wird beendet
+ //dbc.verbindeDatenbank(); // Verbindet mit der Datenbank-Datei
+ //dbc.erstelleDatenbank(); // Neue Datenbank-Datei wird erstellt
+ //System.exit(0); // Programm wird beendet
}
}
diff --git a/src/application/MainWindow.fxml b/src/application/MainWindow.fxml
index 4639820..386de26 100644
--- a/src/application/MainWindow.fxml
+++ b/src/application/MainWindow.fxml
@@ -26,6 +26,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java
index f185b20..2cc5d6f 100644
--- a/src/application/MainWindowController.java
+++ b/src/application/MainWindowController.java
@@ -14,7 +14,11 @@ import javafx.scene.control.TreeTableView;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TitledPane;
+import javafx.scene.control.Tooltip;
+
import com.jfoenix.controls.JFXColorPicker;
+//import com.sun.java.swing.action.NewAction;
+
import java.awt.Desktop;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
@@ -51,6 +55,9 @@ public class MainWindowController
@FXML
private AnchorPane mainAnchorpane;
+ @FXML
+ private AnchorPane paneDB;
+
@FXML
private TreeTableView tableCurrentOrder;
@@ -207,6 +214,12 @@ public class MainWindowController
@FXML
private Button btnClearEntry;
+ @FXML
+ private Button btnCreateNewDatabase;
+
+ @FXML
+ private Button btnOpenFolder;
+
@FXML
private Label labelAllPrize;
@@ -234,6 +247,12 @@ public class MainWindowController
@FXML
private Label lableNewColor;
+ @FXML
+ private Label labelDBStatus;
+
+ @FXML
+ private Label labelDBName;
+
@FXML
private TitledPane titlePaneStats;
@@ -243,6 +262,9 @@ public class MainWindowController
@FXML
private TextField tftNewValue;
+ @FXML
+ private TextField tftNewDBName;
+
@FXML
private JFXColorPicker colorChooser;
@@ -250,14 +272,13 @@ public class MainWindowController
private DBController dbc;
- // Pfad wo die XML liegt
- private String filepathXMLWin = "C:/ProgramData/PWMaster/config.xml";
-
private String filepathXMLLinux = System.getProperty("user.home")
- + "/bin/PWMaster/config.xml"; // Pfad wo die XML liegt
+ + "/bin/jFxKasse/config.xml"; // Pfad wo die XML liegt
private int id;
+ private String databaseName;
+
@FXML
TreeItem root = new TreeItem<>(new tableData(0, "0", "0"));
@@ -270,7 +291,8 @@ public class MainWindowController
// Erstellt einen Dialog
Dialog> dialog = new Dialog<>();
dialog.setTitle("Über jFxKasse");
- dialog.setHeaderText("Informationen und Lizenzen - Version 0.7 - UI Techdemo");
+ dialog.setHeaderText(
+ "Informationen und Lizenzen - Version 0.7 - UI Techdemo");
// Erzeugt den Button
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
@@ -288,10 +310,42 @@ public class MainWindowController
+ " \n(c) 2018 Hendrik Schutter"), 0, 0);
dialog.getDialogPane().setContent(grid); // Setzt die GridPane auf die
- dialog.setResizable(true); // DialogPane
+ dialog.setResizable(true); // DialogPane
dialog.showAndWait();
}
+ @FXML
+ public void btnOpenFolderAction(ActionEvent event) throws IOException
+ {
+ Runtime.getRuntime().exec("xdg-open " + System.getProperty("user.home") + "/bin/jFxKasse" );
+
+ }
+
+ @FXML
+ public void btnCreateNewDatabaseAction(ActionEvent event) throws Exception
+ {
+ System.out.println("Button!");
+
+ System.out.println(tftNewDBName.getText());
+
+ setDatabaseName(tftNewDBName.getText());
+ dbc.dbname = getDatabaseName();
+ dbc.verbindeDatenbank(); // Verbindet mit der Datenbank-Datei
+ dbc.erstelleTabellePositionen();
+ dbc.erstelleTabelleJobs();
+
+ try {
+ saveSettings(getDatabaseName());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ setDBLabel();
+ initUI(); // Startet die UI
+
+ }
+
@FXML
public void btnSaveEntryAction(ActionEvent event)
{
@@ -507,11 +561,16 @@ public class MainWindowController
public void initUI()
{
+ System.out.println("initUI");
+
+ tftNewDBName.setText(getDatabaseName());
+
tableCurrentOrder.setRoot(root);
tableCurrentOrder.setShowRoot(false);
tableCurrentOrder.setEditable(false);
// Setzt die Textfelder
+ /*
idSpalte01.setCellValueFactory(
cellData -> cellData.getValue().getValue().idProperty().asObject());
columnQuantity.setCellValueFactory(
@@ -547,6 +606,8 @@ public class MainWindowController
}
}
});
+
+ */
}
public void setMain(Main main, DBController dbc)
@@ -564,21 +625,16 @@ public class MainWindowController
return heutigesDatum;
}
- public void saveSettings(String schluessel, String base32Secret)
- throws Exception
+ public void saveSettings(String databasename) throws Exception
{
OutputStream outputStream; // new output-stream
try {
- // props.setProperty("key", crypo.verschluesseln(schluessel,
- // crypo.getProgrammSchluessel())); //writes path into property
- // props.setProperty("TOTPkey", crypo.verschluesseln(base32Secret,
- // crypo.getProgrammSchluessel())); //writes path into property
- if (System.getProperty("os.name").equals("Linux")) {
+ props.setProperty("databasename", databasename); // writes dbname into
+ // property
+
outputStream = new FileOutputStream(filepathXMLLinux);
- } else {
- outputStream = new FileOutputStream(filepathXMLWin);
- }
- props.storeToXML(outputStream, "PWMaster settings"); // writes new .xml
+
+ props.storeToXML(outputStream, "jFxKasse settings"); // writes new .xml
outputStream.close();
} catch (IOException e) {
}
@@ -588,13 +644,12 @@ public class MainWindowController
{ // Ladt die Daten aus der XML
InputStream inputStream;
try {
- if (System.getProperty("os.name").equals("Linux")) {
+
inputStream = new FileInputStream(filepathXMLLinux);
- } else {
- inputStream = new FileInputStream(filepathXMLWin);
- }
+
props.loadFromXML(inputStream);
- // schluessel = crypo.entschluesseln(props.getProperty("key"),
+ setDatabaseName(props.getProperty("databasename"));
+ // = crypo.entschluesseln(props.getProperty("key"),
// crypo.getProgrammSchluessel()); //liest schluessel von property
// base32Secret = crypo.entschluesseln(props.getProperty("TOTPkey"),
// crypo.getProgrammSchluessel()); //liest schluessel von property
@@ -611,10 +666,35 @@ public class MainWindowController
dbc.verbindeDatenbank();
}
- public void erzeugeDB()
- { // Erzeuge die Datenbank
- dbc.erstelleDatenbank();
- dbc.verbindeDatenbank();
+
+
+ public String getDatabaseName()
+ {
+ return databaseName;
+ }
+
+ public void setDatabaseName(String NewDatabaseName)
+ {
+ databaseName = NewDatabaseName;
+ }
+
+ public void setDBLabel() throws Exception
+ {
+ if (loadSettings() == true) {
+ labelDBStatus
+ .setText("Geladene Datenbank: " + getDatabaseName() + ".db");
+ btnCreateNewDatabase.setDisable(true);
+ tftNewDBName.setDisable(true);
+ labelDBName.setTooltip(new Tooltip(
+ "Um eine neue Datenbank zu erzeugen muss die vorherige config.xml und "
+ + getDatabaseName() + ".db gelöscht werden! Anwendung danach neustarten!"));
+ labelDBStatus.setTooltip(new Tooltip(
+ "Um eine neue Datenbank zu erzeugen muss die vorherige config.xml und "
+ + getDatabaseName() + ".db gelöscht werden! Anwendung danach neustarten!"));
+ } else {
+ labelDBStatus.setText("Keine Datenbank gefunden!");
+ }
+
}
}