xml saving and loading is complete
This commit is contained in:
parent
87f9b8786c
commit
4e902415d7
|
@ -11,6 +11,7 @@ import javafx.fxml.FXMLLoader;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import com.jFxKasse.controller.MainWindowController;
|
import com.jFxKasse.controller.MainWindowController;
|
||||||
|
import com.jFxKasse.controller.PrinterController;
|
||||||
import com.jFxKasse.controller.XMLController;
|
import com.jFxKasse.controller.XMLController;
|
||||||
import com.jFxKasse.controller.DBController;
|
import com.jFxKasse.controller.DBController;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
@ -27,6 +28,8 @@ public class Main extends Application
|
||||||
private XMLController xmlc = new XMLController(filepathXMLLinux);
|
private XMLController xmlc = new XMLController(filepathXMLLinux);
|
||||||
|
|
||||||
private DBController dbc = new DBController(this);
|
private DBController dbc = new DBController(this);
|
||||||
|
|
||||||
|
private PrinterController pc = new PrinterController();
|
||||||
|
|
||||||
private Stage primaryStage;
|
private Stage primaryStage;
|
||||||
|
|
||||||
|
@ -50,7 +53,8 @@ public class Main extends Application
|
||||||
primaryStage.setTitle("jFxKasse"); // Title of window
|
primaryStage.setTitle("jFxKasse"); // Title of window
|
||||||
|
|
||||||
mwc = loader.getController();
|
mwc = loader.getController();
|
||||||
mwc.setMain(this, dbc, xmlc);
|
pc.searchPrinters();
|
||||||
|
mwc.setMain(this, dbc, xmlc, pc);
|
||||||
|
|
||||||
firstStart();
|
firstStart();
|
||||||
|
|
||||||
|
@ -91,6 +95,7 @@ public class Main extends Application
|
||||||
dbc.connectDatabase(); // estabishing DB conection
|
dbc.connectDatabase(); // estabishing DB conection
|
||||||
mwc.fillTablePositionen(); // fill TreeTable 'Positionen'
|
mwc.fillTablePositionen(); // fill TreeTable 'Positionen'
|
||||||
mwc.fillCategory();
|
mwc.fillCategory();
|
||||||
|
mwc.fillPrinterSettings();
|
||||||
mwc.fillTableJobs();
|
mwc.fillTableJobs();
|
||||||
mwc.loadGridButtons();
|
mwc.loadGridButtons();
|
||||||
mwc.getSelectedCat(); // Load DB entries in Chois Box
|
mwc.getSelectedCat(); // Load DB entries in Chois Box
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.swing.plaf.synth.SynthSpinnerUI;
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXTextField;
|
import com.jfoenix.controls.JFXTextField;
|
||||||
import com.jfoenix.controls.JFXToggleButton;
|
import com.jfoenix.controls.JFXToggleButton;
|
||||||
|
@ -34,6 +35,8 @@ import javafx.collections.ObservableList;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.Spinner;
|
import javafx.scene.control.Spinner;
|
||||||
|
import javafx.scene.control.SpinnerValueFactory;
|
||||||
|
import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory;
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
@ -349,14 +352,14 @@ public class MainWindowController
|
||||||
|
|
||||||
private XMLController xmlc;
|
private XMLController xmlc;
|
||||||
|
|
||||||
|
private PrinterController pc;
|
||||||
|
|
||||||
private int idPositionen = 0;
|
private int idPositionen = 0;
|
||||||
|
|
||||||
private String selectedColorName;
|
private String selectedColorName;
|
||||||
|
|
||||||
private String selectedCatName;
|
private String selectedCatName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean lockState = false;
|
private boolean lockState = false;
|
||||||
|
|
||||||
private boolean isPrintBtnDisabled = true;
|
private boolean isPrintBtnDisabled = true;
|
||||||
|
@ -379,8 +382,6 @@ public class MainWindowController
|
||||||
TreeItem<tableDataPositionen> rootPositionen = new TreeItem<>(
|
TreeItem<tableDataPositionen> rootPositionen = new TreeItem<>(
|
||||||
new tableDataPositionen(0, "0", "0", "0", "0"));
|
new tableDataPositionen(0, "0", "0", "0", "0"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void ueberbtnAction(ActionEvent event)
|
public void ueberbtnAction(ActionEvent event)
|
||||||
{ // opens the 'Über' dialog
|
{ // opens the 'Über' dialog
|
||||||
|
@ -429,14 +430,14 @@ public class MainWindowController
|
||||||
if (!(tftNewDBName.getText().equals(""))) {
|
if (!(tftNewDBName.getText().equals(""))) {
|
||||||
|
|
||||||
xmlc.setDatabaseName(tftNewDBName.getText());
|
xmlc.setDatabaseName(tftNewDBName.getText());
|
||||||
|
|
||||||
dbc.setDbname(xmlc.getDatabaseName());
|
dbc.setDbname(xmlc.getDatabaseName());
|
||||||
dbc.connectDatabase(); // establish DB connection
|
dbc.connectDatabase(); // establish DB connection
|
||||||
dbc.createTablePositionen(); // Create new table
|
dbc.createTablePositionen(); // Create new table
|
||||||
dbc.erstelleTabelleJobs(); // Create new table
|
dbc.erstelleTabelleJobs(); // Create new table
|
||||||
dbc.createTableCategory(); // Create new table
|
dbc.createTableCategory(); // Create new table
|
||||||
try {
|
try {
|
||||||
//saveSettings(getDatabaseName());
|
// saveSettings(getDatabaseName());
|
||||||
xmlc.saveSettings();
|
xmlc.saveSettings();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
|
@ -446,6 +447,7 @@ public class MainWindowController
|
||||||
blockUI(false); // unlock UI elements that need DB
|
blockUI(false); // unlock UI elements that need DB
|
||||||
fillTablePositionen(); // fill TreeTable 'Positionen'
|
fillTablePositionen(); // fill TreeTable 'Positionen'
|
||||||
fillCategory();
|
fillCategory();
|
||||||
|
fillPrinterSettings();
|
||||||
initUI(); // Starting the UI elements
|
initUI(); // Starting the UI elements
|
||||||
getSelectedCat();
|
getSelectedCat();
|
||||||
createNewJob();
|
createNewJob();
|
||||||
|
@ -503,16 +505,30 @@ public class MainWindowController
|
||||||
titlePaneStats.setVisible(true);
|
titlePaneStats.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void btnReprintJobAction(ActionEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void btnSavePrinterAction(ActionEvent event)
|
public void btnSavePrinterAction(ActionEvent event)
|
||||||
{
|
{
|
||||||
System.out.println("btnSavePrinterAction");
|
System.out.println("btnSavePrinterAction");
|
||||||
|
|
||||||
|
xmlc.setPrintername(
|
||||||
|
printerChoise.getSelectionModel().getSelectedItem().toString());
|
||||||
|
xmlc.setLinebreak(linesSpinner.getValue());
|
||||||
|
xmlc.setOffsetHeader(offsetHeaderSpinner.getValue());
|
||||||
|
xmlc.setOffsetFooter(offsetFooterSpinner.getValue());
|
||||||
|
xmlc.setHeader(tftheader.getText());
|
||||||
|
xmlc.setFooter(tftfooter.getText());
|
||||||
|
xmlc.setCategorySplitted(switchSeparate.isSelected());
|
||||||
|
|
||||||
|
try {
|
||||||
|
xmlc.saveSettings();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
fillPrinterSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -580,6 +596,13 @@ public class MainWindowController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void btnReprintJobAction(ActionEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void btnPrintBillAction(ActionEvent event)
|
public void btnPrintBillAction(ActionEvent event)
|
||||||
{
|
{
|
||||||
|
@ -605,11 +628,10 @@ public class MainWindowController
|
||||||
System.out.println(currentJob.getJobnumber());
|
System.out.println(currentJob.getJobnumber());
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
PrinterController pc = new PrinterController();
|
|
||||||
|
|
||||||
pc.searchPrinters();
|
// pc.searchPrinters();
|
||||||
|
|
||||||
pc.selectPrinter("CUPS-PDF");
|
// pc.selectPrinter("CUPS-PDF");
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
|
||||||
PrintDataSimple pds = new PrintDataSimple(28, 1, 2,
|
PrintDataSimple pds = new PrintDataSimple(28, 1, 2,
|
||||||
|
@ -880,6 +902,61 @@ public class MainWindowController
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fillPrinterSettings()
|
||||||
|
{
|
||||||
|
System.out.println("Fill printer Settings");
|
||||||
|
|
||||||
|
// System.out.println(pc.getAvailablePrinters()[0]);
|
||||||
|
|
||||||
|
ObservableList<String> printers = FXCollections
|
||||||
|
.observableArrayList(pc.getAvailablePrinters());
|
||||||
|
printers.add("Drucker auswählen");
|
||||||
|
printerChoise.setItems(printers);
|
||||||
|
|
||||||
|
boolean printerFound = false;
|
||||||
|
int index = 0;
|
||||||
|
for (String currentPrinter : printers) {
|
||||||
|
if (xmlc.getPrintername().equals(currentPrinter)) {
|
||||||
|
// saved printer is available
|
||||||
|
printerFound = true;
|
||||||
|
// select saved printer in UI
|
||||||
|
printerChoise.getSelectionModel().select(index);
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!printerFound) {
|
||||||
|
// saved printer is not available
|
||||||
|
printerChoise.getSelectionModel().select(printers.size() - 1);
|
||||||
|
System.out.println("kein drucker");
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinnerValueFactory<Integer> valueFactoryLines = //
|
||||||
|
new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 99,
|
||||||
|
xmlc.getLinebreak());
|
||||||
|
|
||||||
|
linesSpinner.setValueFactory(valueFactoryLines);
|
||||||
|
|
||||||
|
SpinnerValueFactory<Integer> valueFactoryHeader = //
|
||||||
|
new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 99,
|
||||||
|
xmlc.getOffsetHeader());
|
||||||
|
|
||||||
|
offsetHeaderSpinner.setValueFactory(valueFactoryHeader);
|
||||||
|
|
||||||
|
SpinnerValueFactory<Integer> valueFactoryFooter = //
|
||||||
|
new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 99,
|
||||||
|
xmlc.getOffsetFooter());
|
||||||
|
|
||||||
|
offsetFooterSpinner.setValueFactory(valueFactoryFooter);
|
||||||
|
|
||||||
|
tftheader.setText(xmlc.getHeader());
|
||||||
|
|
||||||
|
tftfooter.setText(xmlc.getFooter());
|
||||||
|
|
||||||
|
switchSeparate.setSelected(xmlc.getCategorySplitted());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void fillCategory()
|
public void fillCategory()
|
||||||
{
|
{
|
||||||
tftKat01.setText(dbc.getName_Category(1));
|
tftKat01.setText(dbc.getName_Category(1));
|
||||||
|
@ -990,11 +1067,13 @@ public class MainWindowController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMain(Main main, DBController dbc, XMLController xmlc)
|
public void setMain(Main main, DBController dbc, XMLController xmlc,
|
||||||
|
PrinterController pc)
|
||||||
{
|
{
|
||||||
this.main = main;
|
this.main = main;
|
||||||
this.dbc = dbc;
|
this.dbc = dbc;
|
||||||
this.xmlc = xmlc;
|
this.xmlc = xmlc;
|
||||||
|
this.pc = pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSystemTime()
|
public String getSystemTime()
|
||||||
|
@ -1013,27 +1092,11 @@ public class MainWindowController
|
||||||
return dateStr;
|
return dateStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
public String getDatabaseName()
|
|
||||||
{
|
|
||||||
return xmlc.getDatabaseName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setDatabaseName(String NewDatabaseName)
|
|
||||||
{
|
|
||||||
databaseName = NewDatabaseName;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void setDBLabel() throws Exception
|
public void setDBLabel() throws Exception
|
||||||
{
|
{
|
||||||
if (xmlc.loadSettings() == true) {
|
if (xmlc.loadSettings() == true) {
|
||||||
labelDBStatus
|
labelDBStatus.setText(
|
||||||
.setText("Geladene Datenbank: " + xmlc.getDatabaseName() + ".db");
|
"Geladene Datenbank: " + xmlc.getDatabaseName() + ".db");
|
||||||
btnCreateNewDatabase.setDisable(true);
|
btnCreateNewDatabase.setDisable(true);
|
||||||
tftNewDBName.setDisable(true);
|
tftNewDBName.setDisable(true);
|
||||||
labelDBName.setTooltip(new Tooltip(
|
labelDBName.setTooltip(new Tooltip(
|
||||||
|
|
|
@ -124,8 +124,7 @@ public class XMLController
|
||||||
|
|
||||||
public void initXML()
|
public void initXML()
|
||||||
{
|
{
|
||||||
|
this.printername = "Drucker auswählen";
|
||||||
this.printername = "CUPS-PDF";
|
|
||||||
|
|
||||||
this.offsetHeader = 1;
|
this.offsetHeader = 1;
|
||||||
this.offsetFooter = 2;
|
this.offsetFooter = 2;
|
||||||
|
@ -136,7 +135,6 @@ public class XMLController
|
||||||
|
|
||||||
this.header = "XYZ GmbH";
|
this.header = "XYZ GmbH";
|
||||||
this.footer = "Vielen Dank für den Einkauf";
|
this.footer = "Vielen Dank für den Einkauf";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDatabaseName()
|
public String getDatabaseName()
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
<children>
|
<children>
|
||||||
<ChoiceBox fx:id="printerChoise" layoutX="298.0" layoutY="10.0" prefWidth="150.0" />
|
<ChoiceBox fx:id="printerChoise" layoutX="298.0" layoutY="10.0" prefWidth="150.0" />
|
||||||
<Spinner fx:id="linesSpinner" layoutX="35.0" layoutY="10.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
|
<Spinner fx:id="linesSpinner" layoutX="35.0" layoutY="10.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
|
||||||
<JFXTextField fx:id="tftheader" layoutX="65.0" layoutY="90.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="377.0" />
|
<JFXTextField fx:id="tftheader" alignment="CENTER" layoutX="65.0" layoutY="90.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="377.0" />
|
||||||
<JFXToggleButton fx:id="switchSeparate" layoutX="270.0" layoutY="170.0" text="Kategorien separat drucken">
|
<JFXToggleButton fx:id="switchSeparate" layoutX="270.0" layoutY="170.0" text="Kategorien separat drucken">
|
||||||
<font>
|
<font>
|
||||||
<Font name="Cantarell Regular" size="18.0" />
|
<Font name="Cantarell Regular" size="18.0" />
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
<Spinner fx:id="offsetHeaderSpinner" layoutX="324.0" layoutY="48.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
|
<Spinner fx:id="offsetHeaderSpinner" layoutX="324.0" layoutY="48.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
|
||||||
<Spinner fx:id="offsetFooterSpinner" layoutX="35.0" layoutY="48.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
|
<Spinner fx:id="offsetFooterSpinner" layoutX="35.0" layoutY="48.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="92.0" />
|
||||||
<JFXTextField fx:id="tftfooter" layoutX="65.0" layoutY="130.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="377.0" />
|
<JFXTextField fx:id="tftfooter" alignment="CENTER" layoutX="65.0" layoutY="130.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="377.0" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
|
|
Loading…
Reference in New Issue