code cleanup and cross platform
This commit is contained in:
parent
dd9ff0d410
commit
a7b2753aa3
|
@ -1,12 +1,10 @@
|
|||
package com.jFxKasse.application;
|
||||
|
||||
import javafx.application.Application;
|
||||
|
||||
import java.io.File;
|
||||
import javafx.animation.Animation;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
@ -19,15 +17,18 @@ import javafx.scene.layout.AnchorPane;
|
|||
|
||||
public class Main extends Application
|
||||
{
|
||||
// path to config.xml and the database
|
||||
public static String filepath;
|
||||
|
||||
private String filepathXMLLinux = System.getProperty("user.home")
|
||||
+ "/bin/jFxKasse/config.xml"; // Pfad wo die XML liegt
|
||||
private static String osName = System.getProperty("os.name");
|
||||
|
||||
private static String userHome = System.getProperty("user.home");
|
||||
|
||||
private MainWindowController mwc;
|
||||
|
||||
private XMLController xmlc = new XMLController(filepathXMLLinux);
|
||||
private XMLController xmlc = new XMLController(filepath);
|
||||
|
||||
private DBController dbc = new DBController(this);
|
||||
private DBController dbc = new DBController(filepath);
|
||||
|
||||
private PrinterController pc = new PrinterController();
|
||||
|
||||
|
@ -37,26 +38,26 @@ public class Main extends Application
|
|||
public void start(Stage primaryStage)
|
||||
{
|
||||
this.primaryStage = primaryStage;
|
||||
|
||||
System.out.println("Hallo Welt");
|
||||
System.out.println("\nstarting jFxKasse\n");
|
||||
mainWindow();
|
||||
}
|
||||
|
||||
private void mainWindow()
|
||||
{
|
||||
try {
|
||||
|
||||
FXMLLoader loader = new FXMLLoader(
|
||||
getClass().getResource("/fxml/MainWindow.fxml"));
|
||||
|
||||
AnchorPane pane = loader.load();
|
||||
primaryStage.setTitle("jFxKasse"); // Title of window
|
||||
|
||||
mwc = loader.getController();
|
||||
pc.searchPrinters();
|
||||
mwc.setMain(this, dbc, xmlc, pc);
|
||||
mwc = loader.getController(); // set the mwc as the JavaFx
|
||||
// MainWindowController
|
||||
pc.searchPrinters(); // search for available printers
|
||||
mwc.setMain(this, dbc, xmlc, pc); // set the created instances to the
|
||||
// mwc
|
||||
|
||||
firstStart();
|
||||
firstStart(); // test if this is the first run
|
||||
|
||||
Scene scene = new Scene(pane);
|
||||
scene.getStylesheets().add(
|
||||
|
@ -66,7 +67,7 @@ public class Main extends Application
|
|||
|
||||
Timeline timeline = new Timeline(
|
||||
new KeyFrame(Duration.seconds(1), ev -> {
|
||||
mwc.updateTimeLabel(); // update time
|
||||
mwc.updateTimeLabel(); // update time label on UI
|
||||
}));
|
||||
timeline.setCycleCount(Animation.INDEFINITE);
|
||||
timeline.play();
|
||||
|
@ -77,18 +78,23 @@ public class Main extends Application
|
|||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
if (osName.contains("Windows")) {
|
||||
System.out.println("FCK Windows");
|
||||
filepath = userHome + "/Documents/jFxKasse/";
|
||||
} else {
|
||||
filepath = userHome + "/jFxKasse/";
|
||||
}
|
||||
launch(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the config.xml is preset.
|
||||
* @author hendrik
|
||||
*/
|
||||
private void firstStart() throws Exception
|
||||
{
|
||||
if (xmlc.loadSettings()) {
|
||||
// config.xml found, app starting normal
|
||||
System.out.println("XML gefunden!");
|
||||
System.out.println("XML found!");
|
||||
mwc.initUI(); // Starting the UI elements
|
||||
mwc.setDBLabel(); // Set databese labels
|
||||
dbc.setDbname(xmlc.getDatabaseName()); // handover database name
|
||||
|
@ -102,13 +108,12 @@ public class Main extends Application
|
|||
mwc.createNewJob();
|
||||
} else {
|
||||
// config.xml NOT found, first start of app
|
||||
System.out.println("keine XML gefunden!");
|
||||
System.out.println("no XML found!");
|
||||
xmlc.initXML(); // set default values
|
||||
mwc.blockUI(true); // disable UI elements that need DB
|
||||
mwc.blockUnlock();
|
||||
File dir = new File(System.getProperty("user.home") + "/bin/jFxKasse");
|
||||
File dir = new File(filepath);
|
||||
dir.mkdir(); // Create new Subfolder
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,41 +7,32 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.jFxKasse.application.Main;
|
||||
import com.jFxKasse.datatypes.tableDataJob;
|
||||
import com.jFxKasse.datatypes.tableDataPositionen;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DBController
|
||||
{
|
||||
private Connection connection;
|
||||
|
||||
private String DB_PATH_Linux = System.getProperty("user.home")
|
||||
+ "/bin/jFxKasse/";
|
||||
private String DB_PATH;
|
||||
|
||||
private String dbname;
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Main main;
|
||||
|
||||
public void main()
|
||||
{
|
||||
try {
|
||||
connection = DriverManager
|
||||
.getConnection("jdbc:sqlite:" + DB_PATH_Linux + dbname + ".db");
|
||||
.getConnection("jdbc:sqlite:" + DB_PATH + dbname + ".db");
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public DBController(Main main)
|
||||
public DBController(String path)
|
||||
{
|
||||
this.main = main;
|
||||
this.DB_PATH = path;
|
||||
}
|
||||
|
||||
public void setDbname(String dbname)
|
||||
|
@ -51,14 +42,14 @@ public class DBController
|
|||
|
||||
public void connectDatabase()
|
||||
{ // connect to database
|
||||
System.out.println("Verbinde ... DB name: " + dbname);
|
||||
System.out.println("Connecting... DB name: " + dbname);
|
||||
try {
|
||||
if (connection != null)
|
||||
return;
|
||||
connection = DriverManager
|
||||
.getConnection("jdbc:sqlite:" + DB_PATH_Linux + dbname + ".db");
|
||||
.getConnection("jdbc:sqlite:" + DB_PATH + dbname + ".db");
|
||||
if (!connection.isClosed())
|
||||
System.out.println("DB Datei-Verbindung erstellt");
|
||||
System.out.println("DB connection established");
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -78,8 +69,8 @@ public class DBController
|
|||
});
|
||||
}
|
||||
|
||||
public boolean existiertDatenbank(String pPfad)
|
||||
{ // Prüft ob die Datenbank existiert
|
||||
public boolean existDB(String pPfad)
|
||||
{ // does the DB exists?
|
||||
File varTmpDir = new File(pPfad);
|
||||
if (!varTmpDir.exists()) {
|
||||
return false;
|
||||
|
@ -90,10 +81,7 @@ public class DBController
|
|||
|
||||
public String getCategoryNameFromPositionen(int pID)
|
||||
{
|
||||
// System.out.println("getCategoryName: " + pID);
|
||||
|
||||
int catInPos = 0;
|
||||
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT posid, cat FROM positionen "
|
||||
|
@ -104,11 +92,9 @@ public class DBController
|
|||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
if (catInPos == 6) {
|
||||
return "Standard";
|
||||
}
|
||||
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT catid, catname FROM category "
|
||||
|
@ -125,7 +111,7 @@ public class DBController
|
|||
// table Position section //
|
||||
public void createTablePositionen()
|
||||
{ // create table position
|
||||
System.out.println("Erstelle Tabelle Positionen");
|
||||
System.out.println("Creating table Positionen");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("DROP TABLE IF EXISTS positionen;");
|
||||
|
@ -146,7 +132,7 @@ public class DBController
|
|||
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");
|
||||
System.out.println("Creating new positionen entry");
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(
|
||||
"INSERT INTO positionen VALUES (?, ?, ?, ?, ?);");
|
||||
|
@ -167,7 +153,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getName_Positionen(int pID)
|
||||
{ // Gibt das Datum zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -181,7 +167,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getValue_Positionen(int pID)
|
||||
{ // Gibt das Konto zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -196,7 +182,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public int getCat_Positionen(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -211,7 +197,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getColor_Positionen(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -226,7 +212,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public void setName_Positionen(int pID, String pName)
|
||||
{ // Setzt das Datum
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET name = '" + pName
|
||||
|
@ -238,7 +224,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public void setValue_Positionen(int pID, String pValue)
|
||||
{ // Setzt das Konto
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET value = '" + pValue
|
||||
|
@ -250,7 +236,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public void setCat_Positionen(int pID, int pCat)
|
||||
{ // Setzt den Nutzername
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET cat = '" + pCat
|
||||
|
@ -262,7 +248,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public void setColor_Positionen(int pID, String pColor)
|
||||
{ // Setzt den Nutzername
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET color = '" + pColor
|
||||
|
@ -274,14 +260,13 @@ public class DBController
|
|||
}
|
||||
|
||||
public ArrayList<tableDataPositionen> ladeTabellePositionen()
|
||||
{ // Gibt ein Objekt daten mit allen Einträgen der DB zurück
|
||||
{
|
||||
ArrayList<tableDataPositionen> daten = new ArrayList<>();
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM positionen;");
|
||||
while (rs.next()) {
|
||||
try {
|
||||
// Entschlüsselte Daten werden als Datenobjekt gespeichert
|
||||
daten.add(new tableDataPositionen(rs.getInt("posid"),
|
||||
rs.getString("name"), rs.getString("value"),
|
||||
rs.getString("cat"), rs.getString("color")));
|
||||
|
@ -298,7 +283,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public void ausgebenSysoPositionen()
|
||||
{ // Debugging Ausgabe der kompletten Tabelle
|
||||
{
|
||||
System.out.println("Print positionen");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
|
@ -339,7 +324,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public void setName_Category(int pID, String pName)
|
||||
{ // Setzte den Namen
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE category SET catname = '" + pName
|
||||
|
@ -371,7 +356,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getName_Category(int pID)
|
||||
{ // Gibt das Datum zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -387,8 +372,8 @@ public class DBController
|
|||
|
||||
// table Jobs section //
|
||||
public void erstelleTabelleJobs()
|
||||
{ // Erstelle Tabelle mit Reihen
|
||||
System.out.println("Erstelle Tabelle Jobs");
|
||||
{ // create table jobs
|
||||
System.out.println("Creating table Jobs");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("DROP TABLE IF EXISTS jobs;");
|
||||
|
@ -402,7 +387,6 @@ public class DBController
|
|||
|
||||
public int getLatestJobNumber_Job()
|
||||
{
|
||||
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -414,11 +398,10 @@ public class DBController
|
|||
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public String getTime_Job(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -432,7 +415,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getQuantity_Job(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -447,7 +430,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getName_Job(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -462,7 +445,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getValue_Job(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -477,7 +460,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getCategory_Job(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -492,7 +475,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getState_Job(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -506,7 +489,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getJobValue_Job(int pID)
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -520,7 +503,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getAllJobValue_Job()
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
|
@ -535,12 +518,12 @@ public class DBController
|
|||
}
|
||||
|
||||
public String getJobCount()
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT count(*) AS JOBCOUNT FROM jobs WHERE state = "
|
||||
+ '"' + "verbucht" + '"' + ";");
|
||||
"SELECT count(*) AS JOBCOUNT FROM jobs WHERE state = " + '"'
|
||||
+ "verbucht" + '"' + ";");
|
||||
return rs.getString("JOBCOUNT");
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
|
@ -549,11 +532,8 @@ public class DBController
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setStatus_Jobs(int pID, String pStatus)
|
||||
{ // Setzt das Konto
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE jobs SET state = '" + pStatus
|
||||
|
@ -565,7 +545,7 @@ public class DBController
|
|||
}
|
||||
|
||||
public ArrayList<tableDataJob> loadTableJobs_Job()
|
||||
{ // Gibt den Nutzernamen zurück
|
||||
{
|
||||
|
||||
ArrayList<tableDataJob> tmp = new ArrayList<tableDataJob>();
|
||||
try {
|
||||
|
@ -575,8 +555,6 @@ public class DBController
|
|||
while (rs.next()) {
|
||||
try {
|
||||
|
||||
// return rs.getString("jobvalue");
|
||||
|
||||
String tablePosition = rs.getString("positionen_name");
|
||||
|
||||
tableDataJob data = new tableDataJob(rs.getInt("jobid"),
|
||||
|
@ -600,7 +578,6 @@ public class DBController
|
|||
String pPositionen_name, String pPositionen_value,
|
||||
String pPositionen_cat, String pState, String pJobvalue)
|
||||
{
|
||||
|
||||
System.out.println("Create new Job Entry");
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(
|
||||
|
@ -621,7 +598,5 @@ public class DBController
|
|||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.jFxKasse.controller;
|
|||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Dialog;
|
||||
|
@ -14,22 +12,12 @@ import javafx.scene.control.TreeItem;
|
|||
import javafx.scene.control.TitledPane;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.plaf.synth.SynthSpinnerUI;
|
||||
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import com.jfoenix.controls.JFXToggleButton;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
|
@ -38,7 +26,6 @@ import javafx.event.ActionEvent;
|
|||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.SpinnerValueFactory;
|
||||
import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
@ -50,15 +37,9 @@ import com.jFxKasse.datatypes.Job;
|
|||
import com.jFxKasse.datatypes.tableDataCurrentOrder;
|
||||
import com.jFxKasse.datatypes.tableDataJob;
|
||||
import com.jFxKasse.datatypes.tableDataPositionen;
|
||||
import com.jFxKasse.datatypes.PrintDataSimple;
|
||||
|
||||
public class MainWindowController
|
||||
{
|
||||
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
|
||||
Clipboard clipboard = toolkit.getSystemClipboard();
|
||||
|
||||
@FXML
|
||||
private AnchorPane mainAnchorpane;
|
||||
|
||||
|
@ -425,9 +406,15 @@ public class MainWindowController
|
|||
@FXML
|
||||
public void btnOpenFolderAction(ActionEvent event) throws IOException
|
||||
{
|
||||
Runtime.getRuntime().exec(
|
||||
"xdg-open " + System.getProperty("user.home") + "/bin/jFxKasse");
|
||||
|
||||
if (System.getProperty("os.name").contains("Windows")) {
|
||||
System.out.println("FCK Windows");
|
||||
File file = new File(Main.filepath);
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
desktop.open(file);
|
||||
} else {
|
||||
Runtime.getRuntime().exec("xdg-open " + Main.filepath);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -492,8 +479,6 @@ public class MainWindowController
|
|||
@FXML
|
||||
public void btnCalcStatsAction(ActionEvent event)
|
||||
{
|
||||
// System.out.println(dbc.getAllJobValue_Job());
|
||||
|
||||
int allActiveJobs = Integer.valueOf(dbc.getJobCount());
|
||||
|
||||
if (dbc.getAllJobValue_Job() != null) {
|
||||
|
@ -532,9 +517,7 @@ public class MainWindowController
|
|||
// TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
fillPrinterSettings();
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -548,7 +531,6 @@ public class MainWindowController
|
|||
public void btnLockAction(ActionEvent event)
|
||||
{
|
||||
lockState = !lockState;
|
||||
|
||||
blockUI(lockState);
|
||||
|
||||
if (lockState) {
|
||||
|
@ -556,7 +538,6 @@ public class MainWindowController
|
|||
} else {
|
||||
btnLock.setText("Kasse sperren");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -571,7 +552,6 @@ public class MainWindowController
|
|||
fillCategory();
|
||||
fillTablePositionen();
|
||||
getSelectedCat();
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -587,7 +567,6 @@ public class MainWindowController
|
|||
|
||||
}
|
||||
setJobPrizeLabel(currentJob.getJobValue());
|
||||
// currentJob.printJobOnConsole();
|
||||
|
||||
if (rootCurrentJob.getChildren().size() == 0) {
|
||||
btnPrintBill.setDisable(true);
|
||||
|
@ -599,13 +578,11 @@ public class MainWindowController
|
|||
if (!currentJob.existsPosName(currentOrderPosName)) {
|
||||
btnDeleteSelectedPosition.setDisable(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void btnPrintBillAction(ActionEvent event)
|
||||
{
|
||||
// currentJob.printJobOnConsole();
|
||||
|
||||
btnPrintBill.setDisable(true);
|
||||
tapPosEdit.setDisable(false);
|
||||
|
@ -624,8 +601,6 @@ public class MainWindowController
|
|||
currentJob.createPosCatDBString(), "verbucht",
|
||||
String.valueOf(currentJob.getJobValue()));
|
||||
|
||||
System.out.println(currentJob.getJobnumber());
|
||||
|
||||
pj.printJob(currentJob.getJobnumber(), xmlc, dbc, pc);
|
||||
|
||||
fillTableJobs();
|
||||
|
@ -643,7 +618,6 @@ public class MainWindowController
|
|||
pj.printJob((selectedJobId + 1), xmlc, dbc, pc);
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
public void gridButton01Action(ActionEvent event)
|
||||
{
|
||||
|
@ -812,12 +786,7 @@ public class MainWindowController
|
|||
|
||||
tableDataPositionen helpTableData = new tableDataPositionen(
|
||||
dbc.ladeTabellePositionen().get(i).getID(),
|
||||
dbc.ladeTabellePositionen().get(i).getName(),
|
||||
|
||||
(strValue + "€")
|
||||
|
||||
,
|
||||
|
||||
dbc.ladeTabellePositionen().get(i).getName(), (strValue + "€"),
|
||||
dbc.getCategoryNameFromPositionen(i + 1),
|
||||
getColorNames(dbc.ladeTabellePositionen().get(i).getColor()));
|
||||
rootPositionen.getChildren()
|
||||
|
@ -840,22 +809,17 @@ public class MainWindowController
|
|||
initPositionen();
|
||||
initCurrentOrderTreeTableView();
|
||||
initJobTreeTableView();
|
||||
|
||||
}
|
||||
|
||||
public int getSelectedCat()
|
||||
{
|
||||
|
||||
ObservableList<String> cats = FXCollections.observableArrayList();
|
||||
|
||||
for (int i = 1; i < 5; i++) {
|
||||
|
||||
if (dbc.getName_Category(i).equals("Standard")) {
|
||||
|
||||
} else {
|
||||
cats.add(dbc.getName_Category(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cats.add(dbc.getName_Category(5));
|
||||
|
@ -869,17 +833,14 @@ public class MainWindowController
|
|||
{
|
||||
selectedCatName = catChoise.getItems().get((int) new_value)
|
||||
.toString();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 1; i < 6; i++) {
|
||||
|
||||
if (dbc.getName_Category(i).equals(selectedCatName)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
@ -887,8 +848,6 @@ public class MainWindowController
|
|||
{
|
||||
System.out.println("Fill printer Settings");
|
||||
|
||||
// System.out.println(pc.getAvailablePrinters()[0]);
|
||||
|
||||
ObservableList<String> printers = FXCollections
|
||||
.observableArrayList(pc.getAvailablePrinters());
|
||||
printers.add("Drucker auswählen");
|
||||
|
@ -909,7 +868,7 @@ public class MainWindowController
|
|||
if (!printerFound) {
|
||||
// saved printer is not available
|
||||
printerChoise.getSelectionModel().select(printers.size() - 1);
|
||||
System.out.println("kein drucker");
|
||||
System.out.println("no printer found");
|
||||
}
|
||||
|
||||
SpinnerValueFactory<Integer> valueFactoryLines = //
|
||||
|
@ -996,7 +955,6 @@ public class MainWindowController
|
|||
public void changed(ObservableValue<?> observable, Object oldVal,
|
||||
Object newVal)
|
||||
{
|
||||
// last = selected; //for auto-play
|
||||
int selected = entryTreeTable.getSelectionModel()
|
||||
.getSelectedIndex(); // get selected item
|
||||
|
||||
|
@ -1024,11 +982,9 @@ public class MainWindowController
|
|||
public void changed(ObservableValue<? extends String> observable,
|
||||
String oldValue, String newValue)
|
||||
{
|
||||
|
||||
if (!newValue.matches("\\d{0,4}([\\.]\\d{0,2})?")) {
|
||||
tftNewValue.setText(oldValue);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1161,7 +1117,6 @@ public class MainWindowController
|
|||
// print was not disabled and will be enabled again
|
||||
btnPrintBill.setDisable(pState);
|
||||
btnDeleteSelectedPosition.setDisable(pState);
|
||||
|
||||
}
|
||||
|
||||
if (pState) {
|
||||
|
@ -1202,11 +1157,8 @@ public class MainWindowController
|
|||
|
||||
public void loadGridButtons()
|
||||
{
|
||||
|
||||
for (int i = 0; i < 25; i++) {
|
||||
|
||||
getButtonByID(i).setText(dbc.getName_Positionen(i + 1));
|
||||
|
||||
if ((getColorID(dbc.getColor_Positionen(i + 1)) == 0)
|
||||
|| (getColorID(dbc.getColor_Positionen(i + 1)) == 7)) {
|
||||
getButtonByID(i).setStyle("-fx-background-color: "
|
||||
|
@ -1215,19 +1167,14 @@ public class MainWindowController
|
|||
getButtonByID(i).setStyle("-fx-background-color: "
|
||||
+ dbc.getColor_Positionen(i + 1) + "; -fx-text-fill: black;");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < 25; i++) {
|
||||
|
||||
if (dbc.getName_Positionen(i + 1).equals("Noch frei")) {
|
||||
getButtonByID(i).setVisible(false);
|
||||
} else {
|
||||
getButtonByID(i).setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Button getButtonByID(int pID)
|
||||
|
@ -1290,7 +1237,6 @@ public class MainWindowController
|
|||
|
||||
private void handelGridButtons(int pID)
|
||||
{
|
||||
|
||||
currentJob.addPosition(dbc.getName_Positionen(pID),
|
||||
Float.parseFloat(dbc.getValue_Positionen(pID)),
|
||||
dbc.getCategoryNameFromPositionen(pID));
|
||||
|
@ -1308,12 +1254,10 @@ public class MainWindowController
|
|||
}
|
||||
|
||||
setJobPrizeLabel(currentJob.getJobValue());
|
||||
|
||||
}
|
||||
|
||||
private void initCurrentOrderTreeTableView()
|
||||
{
|
||||
|
||||
columnQuantity
|
||||
.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
||||
columnPosition
|
||||
|
@ -1335,7 +1279,6 @@ public class MainWindowController
|
|||
public void changed(ObservableValue<?> observable, Object oldVal,
|
||||
Object newVal)
|
||||
{
|
||||
// last = selected; //for auto-play
|
||||
int selected = tableCurrentOrder.getSelectionModel()
|
||||
.getSelectedIndex(); // get selected item
|
||||
|
||||
|
@ -1350,7 +1293,6 @@ public class MainWindowController
|
|||
|
||||
private void initJobTreeTableView()
|
||||
{
|
||||
|
||||
columnJobNumber
|
||||
.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
||||
|
||||
|
@ -1401,7 +1343,6 @@ public class MainWindowController
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -1464,9 +1405,7 @@ public class MainWindowController
|
|||
private void setJobPrizeLabel(float pPrize)
|
||||
{
|
||||
String str = String.format("%.02f", pPrize);
|
||||
|
||||
str.replace('.', ',');
|
||||
|
||||
labelAllPrize.setText(str + "€");
|
||||
}
|
||||
|
||||
|
@ -1488,7 +1427,6 @@ public class MainWindowController
|
|||
|
||||
titlePaneStats.setText("Statistik - " + timedate.getSystemTime() + " "
|
||||
+ timedate.getSystemDate());
|
||||
|
||||
}
|
||||
|
||||
public void updateTimeLabel()
|
||||
|
|
|
@ -32,7 +32,7 @@ public class XMLController
|
|||
|
||||
public XMLController(String filePath)
|
||||
{
|
||||
this.filePath = filePath;
|
||||
this.filePath = filePath + "config.xml";
|
||||
props = new Properties();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue