jFxKasse/src/application/MainWindowController.java

1105 lines
24 KiB
Java
Raw Normal View History

2018-03-29 19:45:41 +02:00
package application;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
2018-03-31 00:35:45 +02:00
import javafx.scene.control.TitledPane;
import javafx.scene.control.Tooltip;
2018-04-02 15:07:58 +02:00
import javafx.scene.control.ChoiceBox;
2018-03-29 19:45:41 +02:00
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
2018-04-05 11:08:50 +02:00
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
2018-03-29 19:45:41 +02:00
import java.util.Properties;
2018-10-01 11:31:05 +02:00
import com.jfoenix.controls.JFXTextField;
2018-03-29 19:45:41 +02:00
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
2018-04-02 15:07:58 +02:00
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
2018-03-29 19:45:41 +02:00
import javafx.event.ActionEvent;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.util.Pair;
2018-10-03 21:53:26 +02:00
import sun.jvm.hotspot.tools.SysPropsDumper;
2018-03-29 19:45:41 +02:00
2018-03-29 19:51:34 +02:00
public class MainWindowController
{
2018-03-29 19:45:41 +02:00
Toolkit toolkit = Toolkit.getDefaultToolkit();
2018-03-29 19:51:34 +02:00
2018-03-29 19:45:41 +02:00
Clipboard clipboard = toolkit.getSystemClipboard();
2018-03-29 19:51:34 +02:00
2018-03-29 19:45:41 +02:00
@FXML
private AnchorPane mainAnchorpane;
2018-03-29 19:51:34 +02:00
@FXML
private AnchorPane paneDB;
2018-03-29 19:45:41 +02:00
@FXML
2018-03-30 00:19:35 +02:00
private TreeTableView<tableData> tableCurrentOrder;
2018-03-29 19:51:34 +02:00
2018-03-29 19:45:41 +02:00
@FXML
2018-03-30 00:19:35 +02:00
private TreeTableColumn<tableData, String> columnQuantity;
2018-03-29 19:51:34 +02:00
2018-03-29 19:45:41 +02:00
@FXML
2018-03-30 00:19:35 +02:00
private TreeTableColumn<tableData, String> columnPosition;
2018-03-29 19:51:34 +02:00
2018-03-29 19:45:41 +02:00
@FXML
2018-03-31 00:35:45 +02:00
private TreeTableColumn<tableData, Integer> idSpalte01 = new TreeTableColumn<>(
2018-04-02 15:07:58 +02:00
"tableCurrentOrder");
2018-03-31 00:35:45 +02:00
@FXML
private TreeTableView<tableData> jobsTreeTable;
@FXML
2018-04-02 15:07:58 +02:00
private TreeTableColumn<tableData, String> columnJobValue;
2018-03-31 00:35:45 +02:00
@FXML
private TreeTableColumn<tableData, String> columnState;
@FXML
private TreeTableColumn<tableData, String> columnPositions;
@FXML
private TreeTableColumn<tableData, String> columnTime;
@FXML
2018-04-02 15:07:58 +02:00
private TreeTableColumn<tableData, String> columnJobNumber;
2018-03-31 00:35:45 +02:00
@FXML
private TreeTableColumn<tableData, Integer> idSpalte02 = new TreeTableColumn<>(
2018-04-02 15:07:58 +02:00
"jobsTreeTable");
2018-03-29 19:51:34 +02:00
2018-03-31 02:00:12 +02:00
@FXML
2018-04-02 15:07:58 +02:00
private TreeTableView<tableDataPositionen> entryTreeTable;
2018-03-31 02:00:12 +02:00
@FXML
2018-04-02 15:07:58 +02:00
private TreeTableColumn<tableDataPositionen, String> columnColor;
2018-03-31 02:00:12 +02:00
2018-10-01 11:31:05 +02:00
@FXML
private TreeTableColumn<tableDataPositionen, String> columnCat;
2018-03-31 02:00:12 +02:00
@FXML
2018-04-02 15:07:58 +02:00
private TreeTableColumn<tableDataPositionen, String> columnPrize;
2018-03-31 02:00:12 +02:00
@FXML
2018-04-02 15:07:58 +02:00
private TreeTableColumn<tableDataPositionen, String> columnPositionsEdit;
2018-03-31 02:00:12 +02:00
@FXML
2018-04-02 15:07:58 +02:00
private TreeTableColumn<tableDataPositionen, Integer> columnPosnumber;
2018-03-31 02:00:12 +02:00
@FXML
2018-04-02 15:07:58 +02:00
private ChoiceBox<String> colorChoise;
2018-03-31 02:00:12 +02:00
2018-10-01 11:31:05 +02:00
@FXML
private ChoiceBox<String> catChoise;
2018-03-29 19:45:41 +02:00
@FXML
private Button ueberbtn;
2018-03-29 19:51:34 +02:00
2018-03-29 22:48:11 +02:00
@FXML
private Button gridButton01;
@FXML
private Button gridButton02;
@FXML
private Button gridButton03;
@FXML
private Button gridButton04;
@FXML
private Button gridButton05;
@FXML
private Button gridButton06;
@FXML
private Button gridButton07;
@FXML
private Button gridButton08;
@FXML
private Button gridButton09;
@FXML
private Button gridButton10;
@FXML
private Button gridButton11;
@FXML
private Button gridButton12;
@FXML
private Button gridButton13;
@FXML
private Button gridButton14;
@FXML
private Button gridButton15;
@FXML
private Button gridButton16;
@FXML
private Button gridButton17;
@FXML
private Button gridButton18;
@FXML
private Button gridButton19;
@FXML
private Button gridButton20;
@FXML
private Button gridButton21;
@FXML
private Button gridButton22;
@FXML
private Button gridButton23;
@FXML
private Button gridButton24;
@FXML
private Button gridButton25;
2018-03-30 00:19:35 +02:00
@FXML
private Button btnDeleteSelectedPosition;
@FXML
private Button btnPrintBill;
@FXML
private Button btnLock;
2018-03-31 00:35:45 +02:00
@FXML
private Button btnReprintJob;
@FXML
2018-04-02 15:07:58 +02:00
private Button btnCancelJob;
2018-03-31 00:35:45 +02:00
@FXML
private Button btnCalcStats;
2018-03-31 02:00:12 +02:00
@FXML
private Button btnSaveEntry;
@FXML
private Button btnClearEntry;
@FXML
private Button btnCreateNewDatabase;
@FXML
private Button btnOpenFolder;
2018-10-01 11:31:05 +02:00
@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;
2018-03-30 00:19:35 +02:00
@FXML
private Label labelAllPrize;
@FXML
private Label labelJobCounter;
@FXML
private Label labelTime;
2018-03-31 00:35:45 +02:00
@FXML
private Label lableJobCount;
@FXML
private Label labelAvgJob;
@FXML
private Label lableAllValue;
2018-10-01 11:31:05 +02:00
@FXML
private Label lableSelectCat;
2018-03-31 02:00:12 +02:00
@FXML
private Label lableNewPosition;
@FXML
private Label labelNewValue;
@FXML
private Label lableNewColor;
@FXML
private Label labelDBStatus;
@FXML
private Label labelDBName;
2018-03-31 00:35:45 +02:00
@FXML
private TitledPane titlePaneStats;
2018-10-01 11:31:05 +02:00
@FXML
private TitledPane titlePaneCat;
2018-10-02 22:03:52 +02:00
@FXML
private TitledPane titledPaneEntry;
2018-03-31 02:00:12 +02:00
@FXML
private TextField tftNewPosition;
@FXML
private TextField tftNewValue;
@FXML
private TextField tftNewDBName;
@SuppressWarnings("unused")
2018-03-29 19:45:41 +02:00
private Main main;
2018-03-29 19:51:34 +02:00
2018-03-29 19:45:41 +02:00
private DBController dbc;
2018-03-29 19:51:34 +02:00
private String filepathXMLLinux = System.getProperty("user.home")
+ "/bin/jFxKasse/config.xml"; // Pfad wo die XML liegt
2018-03-29 19:51:34 +02:00
2018-04-02 15:07:58 +02:00
private int idPositionen = 0;
private String selectedColorName;
2018-03-29 19:51:34 +02:00
2018-10-01 11:31:05 +02:00
private String selectedCatName;
private String databaseName;
2018-04-05 11:08:50 +02:00
private boolean lockState = false;
2018-03-29 19:45:41 +02:00
@FXML
2018-04-02 15:07:58 +02:00
TreeItem<tableData> rootCurrentJob = new TreeItem<>(
new tableData(0, "0", "0"));
@FXML
TreeItem<tableData> rootJobs = new TreeItem<>(new tableData(0, "0", "0"));
@FXML
TreeItem<tableDataPositionen> rootPositionen = new TreeItem<>(
2018-10-01 11:31:05 +02:00
new tableDataPositionen(0, "0", "0", "0", "0"));
2018-03-29 19:51:34 +02:00
2018-03-29 19:45:41 +02:00
Properties props = new Properties();
@FXML
2018-03-29 19:51:34 +02:00
public void ueberbtnAction(ActionEvent event)
{ // opens the 'Über' dialog
2018-03-29 19:45:41 +02:00
// creates a dialog
2018-03-29 19:45:41 +02:00
Dialog<Pair<String, String>> dialog = new Dialog<>();
2018-03-31 02:00:12 +02:00
dialog.setTitle("Über jFxKasse");
dialog.setHeaderText(
2018-10-03 21:53:26 +02:00
"Informationen und Lizenzen - Version 0.9.4 - Techdemo");
2018-03-29 19:45:41 +02:00
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
grid.add(new Label(
"Einfaches Kassensystem für kleine bis mittel große Veranstaltungen mit Bon-Drucker\n"
+ "\nUnter Lizenz GPL-3.0 abrufbar auf https://github.com/Windoofs/jFxKasse\n"
+ "\nDatenbank: sqlite.org - Public Domain"
+ " \nUI Design01: eclipse.org/efxclipse/install.html - Eclipse Public License 1.0"
+ " \nUI Design02: http://www.jfoenix.com/ - Apache License 2.0"
+ " \nUI - Datenbank Integration: basierend auf Project-HomeFlix - github.com/Seil0/Project-HomeFlix - GPLv3 \n"
+ " \nMaintainer: hendrik.schutter@coptersicht.de"
+ " \n(c) 2018 Hendrik Schutter"),
0, 0);
2018-03-29 19:45:41 +02:00
2018-03-29 19:51:34 +02:00
dialog.getDialogPane().setContent(grid); // Setzt die GridPane auf die
dialog.setResizable(true); // DialogPane
2018-03-29 19:45:41 +02:00
dialog.showAndWait();
}
2018-03-29 19:51:34 +02:00
@FXML
public void btnOpenFolderAction(ActionEvent event) throws IOException
{
2018-04-02 15:07:58 +02:00
Runtime.getRuntime().exec(
"xdg-open " + System.getProperty("user.home") + "/bin/jFxKasse");
}
@FXML
public void btnCreateNewDatabaseAction(ActionEvent event) throws Exception
{
setDatabaseName(tftNewDBName.getText());
dbc.dbname = getDatabaseName();
dbc.connectDatabase(); // establish DB connection
dbc.createTablePositionen(); // Create new table
dbc.erstelleTabelleJobs(); // Create new table
2018-10-01 11:31:05 +02:00
dbc.createTableCategory(); // Create new table
try {
saveSettings(getDatabaseName());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setDBLabel(); // Set new databese labels
blockUI(false); // unlock UI elements that need DB
fillTablePositionen(); // fill TreeTable 'Positionen'
2018-10-01 11:31:05 +02:00
fillCategory();
initUI(); // Starting the UI elements
2018-10-03 21:53:26 +02:00
getSelectedCat();
}
2018-03-31 02:00:12 +02:00
@FXML
public void btnSaveEntryAction(ActionEvent event)
{
2018-04-02 15:07:58 +02:00
System.out.println("Speichere Eintrag!");
2018-10-01 11:31:05 +02:00
dbc.setName_Positionen(idPositionen, tftNewPosition.getText());
dbc.setValue_Positionen(idPositionen, tftNewValue.getText());
dbc.setColor_Positionen(idPositionen, getColorCodes(selectedColorName));
2018-04-02 15:07:58 +02:00
2018-10-03 21:53:26 +02:00
dbc.setCat_Positionen(idPositionen, getSelectedCat());
fillTablePositionen(); // fill TreeTable 'Positionen'
loadGridButtons();
2018-04-02 15:07:58 +02:00
2018-03-31 02:00:12 +02:00
}
@FXML
public void btnClearEntryAction(ActionEvent event)
{
// set default values
2018-10-01 11:31:05 +02:00
dbc.setName_Positionen(idPositionen, "Noch frei");
dbc.setValue_Positionen(idPositionen, "0.00");
dbc.setColor_Positionen(idPositionen, "#FAF0E6");
2018-10-03 22:19:29 +02:00
dbc.setCat_Positionen(idPositionen, 6);
fillTablePositionen(); // fill TreeTable 'Positionen'
2018-03-31 02:00:12 +02:00
}
2018-03-31 00:35:45 +02:00
@FXML
public void btnCalcStatsAction(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void btnReprintJobAction(ActionEvent event)
{
2018-03-31 00:35:45 +02:00
}
@FXML
2018-04-02 15:07:58 +02:00
public void btnCancelJobAction(ActionEvent event)
2018-03-31 00:35:45 +02:00
{
System.out.println("Button!");
}
2018-03-30 00:19:35 +02:00
@FXML
public void btnLockAction(ActionEvent event)
{
lockState = !lockState;
blockUI(lockState);
if (lockState) {
btnLock.setText("Kasse entsperren");
} else {
btnLock.setText("Kasse sperren");
}
2018-03-30 00:19:35 +02:00
}
2018-10-01 11:31:05 +02:00
@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();
}
2018-03-30 00:19:35 +02:00
@FXML
public void btnDeleteSelectedPositionAction(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void btnPrintBillAction(ActionEvent event)
{
System.out.println("Button!");
}
2018-03-29 22:48:11 +02:00
@FXML
public void gridButton01Action(ActionEvent event)
{
2018-04-05 11:08:50 +02:00
System.out.println("Test Button!");
2018-03-29 22:48:11 +02:00
}
@FXML
public void gridButton02Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton03Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton04Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton05Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton06Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton07Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton08Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton09Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton10Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton11Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton12Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton13Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton14Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton15Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton16Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton17Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton18Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton19Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton20Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton21Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton22Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton23Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton24Action(ActionEvent event)
{
System.out.println("Button!");
}
@FXML
public void gridButton25Action(ActionEvent event)
{
System.out.println("Button!");
}
2018-03-29 19:45:41 +02:00
@FXML
public void fillTablePositionen()
{ // loads the table in the TreeTableView
2018-10-01 11:31:05 +02:00
2018-04-02 15:07:58 +02:00
rootPositionen.getChildren().remove(0,
rootPositionen.getChildren().size());
for (int i = 0; i < dbc.ladeTabellePositionen().size(); i++) {
tableDataPositionen helpTableData = new tableDataPositionen(
dbc.ladeTabellePositionen().get(i).getID(),
dbc.ladeTabellePositionen().get(i).getName(),
dbc.ladeTabellePositionen().get(i).getValue() + "",
2018-10-01 11:31:05 +02:00
dbc.getCategoryNameFromPositionen(i + 1),
2018-04-02 15:07:58 +02:00
getColorNames(dbc.ladeTabellePositionen().get(i).getColor()));
rootPositionen.getChildren()
.add(new TreeItem<tableDataPositionen>(helpTableData));
2018-03-29 19:45:41 +02:00
}
}
2018-03-29 19:51:34 +02:00
public void initUI()
{
System.out.println("initUI");
tftNewDBName.setText(getDatabaseName());
2018-10-03 21:53:26 +02:00
tftKat05.setDisable(true);
2018-04-02 15:07:58 +02:00
initPositionen();
2018-10-01 11:31:05 +02:00
}
public int getSelectedCat()
{
ObservableList<String> cats = FXCollections.observableArrayList();
2018-10-03 22:19:29 +02:00
for (int i = 1; i < 5; i++) {
if (dbc.getName_Category(i).equals("Standard")) {
} else {
cats.add(dbc.getName_Category(i));
}
}
2018-10-03 21:53:26 +02:00
/*
2018-10-03 22:19:29 +02:00
* cats.add(dbc.getName_Category(1));
2018-10-03 21:53:26 +02:00
*
2018-10-03 22:19:29 +02:00
* cats.add(dbc.getName_Category(2)); cats.add(dbc.getName_Category(3));
* cats.add(dbc.getName_Category(4));
2018-10-03 21:53:26 +02:00
*/
2018-10-01 11:31:05 +02:00
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();
2018-10-03 21:53:26 +02:00
// System.out.println("Ausgewählte Cat: " + selectedCatName);
2018-10-01 11:31:05 +02:00
}
});
2018-10-03 21:53:26 +02:00
for (int i = 1; i < 6; i++) {
if (dbc.getName_Category(i).equals(selectedCatName)) {
2018-10-01 11:31:05 +02:00
return i;
}
}
2018-10-03 21:53:26 +02:00
return 5;
2018-10-01 11:31:05 +02:00
}
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));
2018-04-02 15:07:58 +02:00
}
private void initPositionen()
{
entryTreeTable.setRoot(rootPositionen);
entryTreeTable.setShowRoot(false);
entryTreeTable.setEditable(false);
ObservableList<String> color = FXCollections.observableArrayList("Rot",
"Orange", "Braun", "Weiß", "Gelb", "Gr\u00fcn", "Blau", "Indigo");
colorChoise.setItems(color);
colorChoise.getSelectionModel().selectedIndexProperty()
.addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov,
Number value, Number new_value)
{
selectedColorName = colorChoise.getItems()
.get((int) new_value).toString();
2018-10-03 21:53:26 +02:00
// System.out.println("Ausgewählte Farbe: " +
// selectedColorName);
2018-04-02 15:07:58 +02:00
}
});
2018-03-29 19:45:41 +02:00
2018-04-02 15:07:58 +02:00
columnPosnumber.setCellValueFactory(
2018-03-29 19:51:34 +02:00
cellData -> cellData.getValue().getValue().idProperty().asObject());
2018-04-02 15:07:58 +02:00
columnPositionsEdit.setCellValueFactory(
cellData -> cellData.getValue().getValue().nameProperty());
columnPrize.setCellValueFactory(
cellData -> cellData.getValue().getValue().valueProperty());
2018-10-01 11:31:05 +02:00
columnCat.setCellValueFactory(
cellData -> cellData.getValue().getValue().catProperty());
2018-04-02 15:07:58 +02:00
columnColor.setCellValueFactory(
cellData -> cellData.getValue().getValue().colorProperty());
entryTreeTable.getSelectionModel().selectedItemProperty()
2018-03-29 19:51:34 +02:00
.addListener(new ChangeListener<Object>() {
@Override
public void changed(ObservableValue<?> observable, Object oldVal,
Object newVal)
{
// last = selected; //for auto-play
2018-04-02 15:07:58 +02:00
int selected = entryTreeTable.getSelectionModel()
2018-03-29 19:51:34 +02:00
.getSelectedIndex(); // get selected item
2018-10-01 11:31:05 +02:00
2018-04-02 15:07:58 +02:00
idPositionen = columnPosnumber.getCellData(selected); // Ausgewählte
2018-10-01 11:31:05 +02:00
// Spalte
2018-04-02 15:07:58 +02:00
System.out.println(
"Positionen - Ausgewaehlte Spalte: " + idPositionen);
try { // Setzt den Inhalt in die Textfelder
2018-10-01 11:31:05 +02:00
tftNewPosition
.setText(dbc.getName_Positionen(idPositionen));
tftNewValue.setText(dbc.getValue_Positionen(idPositionen));
colorChoise.getSelectionModel().select(
getColorID(dbc.getColor_Positionen(idPositionen)));
2018-04-02 15:07:58 +02:00
2018-10-03 21:53:26 +02:00
catChoise.getSelectionModel().select(
dbc.getCategoryNameFromPositionen(idPositionen));
2018-03-29 19:51:34 +02:00
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
2018-04-02 15:07:58 +02:00
columnPosnumber.setStyle("-fx-alignment: CENTER;");
columnPositionsEdit.setStyle("-fx-alignment: CENTER;");
columnPrize.setStyle("-fx-alignment: CENTER;");
2018-10-01 11:31:05 +02:00
columnCat.setStyle("-fx-alignment: CENTER;");
columnColor.setStyle("-fx-alignment: CENTER;");
tftNewValue.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue)
{
if (!newValue.matches("\\d{0,7}([\\.]\\d{0,2})?")) {
tftNewValue.setText(oldValue);
}
}
});
final Tooltip tooltipName = new Tooltip();
tooltipName.setText("Name der neuen Position");
tooltipName.setStyle("-fx-font: normal bold 20 Cantarell; "
+ "-fx-base: #AE3522; " + "-fx-text-fill: orange;");
tftNewPosition.setTooltip(tooltipName);
final Tooltip tooltipValue = new Tooltip();
tooltipValue
.setText("Preis der neuen Position.\nPunkt als Trennzeichen!");
tooltipValue.setStyle("-fx-font: normal bold 20 Cantarell; "
+ "-fx-base: #AE3522; " + "-fx-text-fill: orange;");
tftNewValue.setTooltip(tooltipValue);
labelNewValue.setTooltip(tooltipValue);
2018-03-29 19:45:41 +02:00
}
2018-03-29 19:51:34 +02:00
public void setMain(Main main, DBController dbc)
{
2018-03-29 19:45:41 +02:00
this.main = main;
this.dbc = dbc;
}
2018-03-29 19:51:34 +02:00
2018-04-05 11:08:50 +02:00
public String getSystemTime()
{
2018-04-05 11:08:50 +02:00
DateFormat dateFormat = new SimpleDateFormat("HH:mm");
Date date = new Date();
String heutigesDatum = dateFormat.format(date);
2018-03-29 19:45:41 +02:00
return heutigesDatum;
}
2018-03-29 19:51:34 +02:00
public void saveSettings(String databasename) throws Exception
{ // Save settings to config.xml
OutputStream outputStream;
2018-03-29 19:45:41 +02:00
try {
props.setProperty("databasename", databasename);
2018-04-02 15:07:58 +02:00
outputStream = new FileOutputStream(filepathXMLLinux);
props.storeToXML(outputStream, "jFxKasse settings");
2018-03-29 19:45:41 +02:00
outputStream.close();
} catch (IOException e) {
}
}
2018-03-29 19:51:34 +02:00
public boolean loadSettings() throws Exception
{ // reads the settings from config.xml
2018-03-29 19:45:41 +02:00
InputStream inputStream;
try {
2018-04-02 15:07:58 +02:00
inputStream = new FileInputStream(filepathXMLLinux);
2018-03-29 19:45:41 +02:00
props.loadFromXML(inputStream);
setDatabaseName(props.getProperty("databasename"));
2018-03-29 19:45:41 +02:00
inputStream.close();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
2018-03-29 19:51:34 +02:00
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 "
2018-04-02 15:07:58 +02:00
+ getDatabaseName()
+ ".db gelöscht werden! Anwendung danach neustarten!"));
labelDBStatus.setTooltip(new Tooltip(
"Um eine neue Datenbank zu erzeugen muss die vorherige config.xml und "
2018-04-02 15:07:58 +02:00
+ getDatabaseName()
+ ".db gelöscht werden! Anwendung danach neustarten!"));
} else {
labelDBStatus.setText("Keine Datenbank gefunden!");
}
2018-03-29 19:45:41 +02:00
}
2018-03-29 19:51:34 +02:00
2018-04-02 15:07:58 +02:00
private String getColorCodes(String pColorName)
{
switch (pColorName) {
case "Rot":
return "#ad0000";
2018-04-02 15:07:58 +02:00
case "Orange":
return "#FF4500";
case "Braun":
return "#8B4513";
case "Weiß":
return "#FAF0E6";
case "Gelb":
return "#FFD700";
case "Gr\u00fcn":
return "#556B2F";
case "Blau":
return "#00BFFF";
case "Indigo":
return "#4B0082";
default:
return "#FFFFFF";
}
}
private String getColorNames(String pColorCode)
{
switch (pColorCode) {
case "#ad0000":
2018-04-02 15:07:58 +02:00
return "Rot";
case "#FF4500":
return "Orange";
case "#8B4513":
return "Braun";
case "#FAF0E6":
return "Weiß";
case "#FFD700":
2018-04-02 15:07:58 +02:00
return "Gelb";
case "#556B2F":
return "Gr\u00fcn";
case "#00BFFF":
return "Blau";
case "#4B0082":
return "Indigo";
default:
return "Farbe";
}
}
private Integer getColorID(String pColorCode)
{
switch (pColorCode) {
case "#ad0000":
2018-04-02 15:07:58 +02:00
return 0;
case "#FF4500":
return 1;
case "#8B4513":
return 2;
case "#FAF0E6":
return 3;
case "#FFD700":
2018-04-02 15:07:58 +02:00
return 4;
case "#556B2F":
return 5;
case "#00BFFF":
return 6;
case "#4B0082":
return 7;
default:
return 0;
}
}
public void blockUI(boolean pState)
{
btnCalcStats.setDisable(pState);
btnClearEntry.setDisable(pState);
btnDeleteSelectedPosition.setDisable(pState);
btnPrintBill.setDisable(pState);
btnReprintJob.setDisable(pState);
btnSaveEntry.setDisable(pState);
btnCancelJob.setDisable(pState);
for (int i = 0; i < 25; i++) {
getButtonByID(i).setDisable(pState);
}
2018-04-02 15:07:58 +02:00
tftNewPosition.setDisable(pState);
tftNewValue.setDisable(pState);
colorChoise.setDisable(pState);
2018-10-01 13:53:44 +02:00
catChoise.setDisable(pState);
2018-04-02 15:07:58 +02:00
tableCurrentOrder.setDisable(pState);
jobsTreeTable.setDisable(pState);
entryTreeTable.setDisable(pState);
labelAllPrize.setVisible(!pState);
labelJobCounter.setVisible(!pState);
titlePaneStats.setVisible(!pState);
2018-10-02 22:03:52 +02:00
titledPaneEntry.setDisable(pState);
2018-10-01 11:31:05 +02:00
titlePaneCat.setDisable(pState);
2018-04-02 15:07:58 +02:00
}
public void loadGridButtons()
{
for (int i = 0; i < 25; i++) {
2018-10-01 11:31:05 +02:00
getButtonByID(i).setText(dbc.getName_Positionen(i + 1));
2018-10-01 11:31:05 +02:00
if ((getColorID(dbc.getColor_Positionen(i + 1)) == 0)
|| (getColorID(dbc.getColor_Positionen(i + 1)) == 7)) {
getButtonByID(i).setStyle("-fx-background-color: "
2018-10-01 11:31:05 +02:00
+ dbc.getColor_Positionen(i + 1) + "; -fx-text-fill: white;");
} else {
getButtonByID(i).setStyle("-fx-background-color: "
2018-10-01 11:31:05 +02:00
+ dbc.getColor_Positionen(i + 1) + "; -fx-text-fill: black;");
}
}
for (int i = 0; i < 25; i++) {
2018-10-01 11:31:05 +02:00
if (dbc.getName_Positionen(i + 1).equals("Noch frei")) {
getButtonByID(i).setVisible(false);
} else {
getButtonByID(i).setVisible(true);
}
}
}
public Button getButtonByID(int pID)
{
switch (pID) {
case 0:
return gridButton01;
case 1:
return gridButton02;
case 2:
return gridButton03;
case 3:
return gridButton04;
case 4:
return gridButton05;
case 5:
return gridButton06;
case 6:
return gridButton07;
case 7:
return gridButton08;
case 8:
return gridButton09;
case 9:
return gridButton10;
case 10:
return gridButton11;
case 11:
return gridButton12;
case 12:
return gridButton13;
case 13:
return gridButton14;
case 14:
return gridButton15;
case 15:
return gridButton16;
case 16:
return gridButton17;
case 17:
return gridButton18;
case 18:
return gridButton19;
case 19:
return gridButton20;
case 20:
return gridButton21;
case 21:
return gridButton22;
case 22:
return gridButton23;
case 23:
return gridButton24;
case 24:
return gridButton25;
default:
return gridButton01;
}
}
public void updateTimeLabel()
{
// System.out.println(getSystemTime());
2018-04-05 11:08:50 +02:00
labelTime.setText("Uhrzeit: " + getSystemTime());
}
2018-03-29 19:45:41 +02:00
}