Browse Source

code cleanup and ui fixes

master FlaschePommes
Hendrik Schutter 3 years ago
parent
commit
96d5968fef
  1. 2
      pom.xml
  2. 19
      src/main/java/com/jFxKasse/application/PrintJob.java
  3. 2
      src/main/java/com/jFxKasse/application/TimeDate.java
  4. 2
      src/main/java/com/jFxKasse/controller/MainWindowController.java
  5. 1
      src/main/java/com/jFxKasse/controller/PrinterController.java
  6. 1
      src/main/java/com/jFxKasse/controller/XMLController.java
  7. 18
      src/main/java/com/jFxKasse/datatypes/Category.java
  8. 22
      src/main/java/com/jFxKasse/datatypes/Job.java
  9. 1
      src/main/java/com/jFxKasse/datatypes/PrintData.java
  10. 6
      src/main/java/com/jFxKasse/datatypes/PrintDataSimple.java
  11. 10
      src/main/java/com/jFxKasse/datatypes/PrintDataSplitted.java
  12. 1
      src/main/java/com/jFxKasse/datatypes/tableDataCurrentOrder.java
  13. 89
      src/main/resources/fxml/MainWindow.fxml

2
pom.xml

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>jFxKasse</artifactId>
<version>0.2.0</version>
<version>0.3.0</version>
<name>jFxKasse</name>
<dependencies>

19
src/main/java/com/jFxKasse/application/PrintJob.java

@ -54,11 +54,13 @@ public class PrintJob
} else {
// printer selected
pc.selectPrinter(xmlc.getPrintername());
/* Single bill or splitted */
if (xmlc.getCategorySplitted()) {
// split the bills
PrintDataSplitted pdsplitted = new PrintDataSplitted(xmlc.getLinebreak(),
xmlc.getOffsetHeader(), xmlc.getOffsetFooter(),
PrintDataSplitted pdsplitted = new PrintDataSplitted(
xmlc.getLinebreak(), xmlc.getOffsetHeader(),
xmlc.getOffsetFooter(),
timedate.getSystemTime() + " " + timedate.getSystemDate(),
xmlc.getHeader(), xmlc.getFooter());
@ -66,16 +68,15 @@ public class PrintJob
dbc.getQuantity_Job(jobID), dbc.getName_Job(jobID),
dbc.getValue_Job(jobID), dbc.getCategory_Job(jobID),
dbc.getJobValue_Job(jobID));
System.out.println("Printing job ...");
ArrayList<String> printString = pdsplitted.getPrintStrings();
for(int i = 0; i < printString.size(); i++) {
for (int i = 0; i < printString.size(); i++) {
pc.printString(printString.get(i));
}
} else {
// one single bills
PrintDataSimple pds = new PrintDataSimple(xmlc.getLinebreak(),

2
src/main/java/com/jFxKasse/application/TimeDate.java

@ -6,7 +6,6 @@ import java.util.Date;
public class TimeDate
{
public String getSystemTime()
{
DateFormat dateFormat = new SimpleDateFormat("HH:mm");
@ -22,5 +21,4 @@ public class TimeDate
String dateStr = dateFormat.format(date);
return dateStr;
}
}

2
src/main/java/com/jFxKasse/controller/MainWindowController.java

@ -378,7 +378,7 @@ public class MainWindowController
// creates a dialog
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Über jFxKasse");
dialog.setHeaderText("Informationen und Lizenzen - Version 0.2");
dialog.setHeaderText("Informationen und Lizenzen - Version 0.3.0");
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);

1
src/main/java/com/jFxKasse/controller/PrinterController.java

@ -89,7 +89,6 @@ public class PrinterController implements Printable
*/
public void printString(String text)
{
PrintService service = selectedPrinter;
DocPrintJob job = service.createPrintJob();

1
src/main/java/com/jFxKasse/controller/XMLController.java

@ -9,7 +9,6 @@ import java.util.Properties;
public class XMLController
{
private String databaseName = null;
private String printername = null;

18
src/main/java/com/jFxKasse/datatypes/Category.java

@ -2,7 +2,6 @@ package com.jFxKasse.datatypes;
public class Category
{
private String categoryName;
private String positionsString = "\n";
@ -11,28 +10,23 @@ public class Category
{
this.categoryName = categoryName;
}
// public void setCategoryName(String categoryName) {
// this.categoryName = categoryName;
// }
public String getCategoryName()
{
return categoryName;
}
public void addPosition(int quantity, String name, String value, PrintData pd)
public void addPosition(int quantity, String name, String value,
PrintData pd)
{
//positionenString = pd.setRight(pd.breakLines(name), value + " €") + "\n";
for (int i = 0; i < quantity; i++) {
positionsString = positionsString
+ pd.setRight(pd.breakLines(name), value + " €") + "\n";
}
}
}
public String getPositionsString() {
public String getPositionsString()
{
return positionsString;
}
}

22
src/main/java/com/jFxKasse/datatypes/Job.java

@ -4,7 +4,6 @@ import java.util.ArrayList;
public class Job
{
private int jobnumber;
private float jobvalue;
@ -55,13 +54,10 @@ public class Job
public void addPosition(String pPositionenName, float pPositionenValue,
String pPositionenCat)
{
// System.out.println("addName");
for (int i = 0; i < positionenName.size(); i++) {
if (positionenName.get(i).equals(pPositionenName)) {
// Item is already in list, increase quantity
positionenQuantity.set(i, positionenQuantity.get(i) + 1);
// System.out.println("Item exists, increasing quantity");
return;
}
}
@ -76,24 +72,15 @@ public class Job
public void printJobOnConsole()
{
System.out.println("---------------------------------------------");
System.out.println("JobNummer: " + jobnumber);
System.out.println("---------------------------------------------");
// System.out.println("Größe: " + positionenName.size());
for (int i = 0; i < positionenName.size(); i++) {
System.out.println(
positionenQuantity.get(i) + " " + positionenName.get(i) + " "
+ positionenValue.get(i) + " " + positionenCat.get(i));
/*
* System.out.println("i is: " + i);
* System.out.println(positionenName.get(i));
* System.out.println(positionenQuantity.get(i));
*/
}
System.out.println("---------------------------------------------");
@ -102,33 +89,26 @@ public class Job
public ArrayList<tableDataCurrentOrder> getCurrentJobPositionen()
{
ArrayList<tableDataCurrentOrder> jobitems = new ArrayList<tableDataCurrentOrder>();
for (int i = 0; i < positionenName.size(); i++) {
tableDataCurrentOrder tmp = new tableDataCurrentOrder(
positionenName.get(i), positionenQuantity.get(i));
jobitems.add(tmp);
}
return jobitems;
}
private void calcJobValue()
{
jobvalue = 0;
for (int i = 0; i < positionenValue.size(); i++) {
jobvalue = jobvalue
+ (positionenQuantity.get(i) * positionenValue.get(i));
}
}
public String createPosQuantityDBString()

1
src/main/java/com/jFxKasse/datatypes/PrintData.java

@ -103,7 +103,6 @@ public abstract class PrintData
// data string not long enough
next = false;
}
}
// add the last part
return tmp + "\n" + data.substring(count);

6
src/main/java/com/jFxKasse/datatypes/PrintDataSimple.java

@ -6,7 +6,7 @@ public class PrintDataSimple extends PrintData
private String printString;
/**
* Constructor with all data that is not in the DB
* Constructor with all data that is not in the DB
* @param lineBreak
* @param headerSpace
* @param footerSpace
@ -62,9 +62,9 @@ public class PrintDataSimple extends PrintData
String[] positionValue = positionsValue.split(";");
for (int i = 0; i < posCount; i++) { //All different posNames
for (int i = 0; i < posCount; i++) { // All different posNames
int quantity = Integer.parseInt(positionQuantity[i]);
for (int j = 0; j < quantity; j++) { //quantities
for (int j = 0; j < quantity; j++) { // quantities
positionen = positionen + setRight(breakLines(positionName[i]),
positionValue[i] + " €") + "\n";
}

10
src/main/java/com/jFxKasse/datatypes/PrintDataSplitted.java

@ -83,7 +83,7 @@ public class PrintDataSplitted extends PrintData
/* first bill ends here */
/* Categories in extra bills*/
/* Categories in extra bills */
String positions = null;
@ -127,9 +127,9 @@ public class PrintDataSplitted extends PrintData
/* Footer */
footer = setCenter(this.footer);
footer = "\n";
for (int o = 1; o < footerSpace; o++) {
for (int o = 2; o < footerSpace; o++) {
footer = footer + "\n";
}
footer = footer + "_";
@ -137,8 +137,8 @@ public class PrintDataSplitted extends PrintData
thisBill = header + "\n" + getSeparator() + "\n" + info + "\n"
+ getSeparator() + "\n"
+ setCenter(categories.get(i).getCategoryName()) + "\n"
+ getSeparator() +
positions + "\n" + getSeparator();
+ getSeparator() + positions + "\n" + getSeparator() + "\n"
+ footer;
printString.add(thisBill);

1
src/main/java/com/jFxKasse/datatypes/tableDataCurrentOrder.java

@ -16,7 +16,6 @@ public class tableDataCurrentOrder
{
this.position.set(pPosition);
this.quantity.set(pQuantity);
}
public StringProperty positionProperty()

89
src/main/resources/fxml/MainWindow.fxml

@ -27,7 +27,10 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Button fx:id="ueberbtn" layoutX="84.0" layoutY="79.0" mnemonicParsing="false" onAction="#ueberbtnAction" prefHeight="0.0" prefWidth="46.0" text="Über" />
<Button fx:id="ueberbtn" layoutX="273.0" layoutY="448.0" mnemonicParsing="false" onAction="#ueberbtnAction" prefHeight="35.0" prefWidth="324.0" text="Informationen über jFxKasse">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></Button>
<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="238.0" prefWidth="564.0">
@ -37,7 +40,10 @@
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<JFXTextField fx:id="tftNewDBName" alignment="CENTER" layoutX="25.0" layoutY="10.0" prefHeight="25.0" prefWidth="376.0" />
<JFXTextField fx:id="tftNewDBName" alignment="CENTER" layoutX="25.0" layoutY="10.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<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" />
@ -89,11 +95,26 @@
<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" />
<JFXTextField fx:id="tftKat01" alignment="CENTER" layoutX="50.0" layoutY="5.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXTextField fx:id="tftKat02" alignment="CENTER" layoutX="50.0" layoutY="45.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXTextField fx:id="tftKat03" alignment="CENTER" layoutX="50.0" layoutY="85.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXTextField fx:id="tftKat04" alignment="CENTER" layoutX="50.0" layoutY="125.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXTextField fx:id="tftKat05" alignment="CENTER" layoutX="50.0" layoutY="165.0" prefHeight="25.0" prefWidth="376.0">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<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" />
@ -110,9 +131,12 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="327.0" prefWidth="564.0">
<children>
<ChoiceBox fx:id="printerChoise" layoutX="298.0" layoutY="10.0" prefWidth="150.0" />
<ChoiceBox fx:id="printerChoise" layoutX="270.0" layoutY="10.0" prefHeight="25.0" prefWidth="178.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" alignment="CENTER" 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">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
<JFXToggleButton fx:id="switchSeparate" layoutX="270.0" layoutY="170.0" text="Kategorien separat drucken">
<font>
<Font name="Cantarell Regular" size="18.0" />
@ -155,7 +179,10 @@
</Button>
<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" />
<JFXTextField fx:id="tftfooter" alignment="CENTER" 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">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font></JFXTextField>
</children>
</AnchorPane>
</content>
@ -186,52 +213,52 @@
<TreeTableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
</TreeTableView>
<Button fx:id="btnSaveEntry" layoutX="494.0" layoutY="631.0" mnemonicParsing="false" onAction="#btnSaveEntryAction" text="Ausgewählten Eintrag speichern">
<Button fx:id="btnClearEntry" layoutX="232.0" layoutY="590.0" mnemonicParsing="false" onAction="#btnClearEntryAction" text="Ausgewählten Eintrag zurücksetzten">
<font>
<Font name="Cantarell Regular" size="17.0" />
</font>
</Button>
<Button fx:id="btnClearEntry" layoutX="462.0" layoutY="525.0" mnemonicParsing="false" onAction="#btnClearEntryAction" text="Ausgewählten Eintrag zurücksetzten">
<font>
<Font name="Cantarell Regular" size="17.0" />
</font>
</Button>
<TitledPane fx:id="titledPaneEntry" alignment="CENTER" animated="false" collapsible="false" contentDisplay="CENTER" layoutX="792.0" layoutY="525.0" prefHeight="163.0" prefWidth="565.0" text="Eintrag editieren">
<TitledPane fx:id="titledPaneEntry" alignment="CENTER" animated="false" collapsible="false" contentDisplay="CENTER" layoutX="724.0" layoutY="525.0" prefHeight="163.0" prefWidth="633.0" text="Eintrag editieren">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="135.0" prefWidth="640.0">
<children>
<Label fx:id="labelNewPosition" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="455.0" layoutY="10.0" prefHeight="34.0" prefWidth="105.0" text="Position:">
<Label fx:id="labelNewPosition" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="516.0" layoutY="10.0" prefHeight="34.0" prefWidth="105.0" text="Position:">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<JFXTextField fx:id="tftNewPosition" alignment="CENTER" layoutX="160.0" layoutY="10.0" prefHeight="25.0" prefWidth="279.0">
<JFXTextField fx:id="tftNewPosition" alignment="CENTER" layoutX="307.0" layoutY="8.0" prefHeight="27.0" prefWidth="203.0">
<font>
<Font name="Cantarell Regular" size="13.0" />
</font>
</JFXTextField>
<Label fx:id="labelNewValue" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="442.0" layoutY="50.0" prefHeight="34.0" prefWidth="118.0" text="Preis in Euro:">
<Label fx:id="labelNewValue" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="504.0" layoutY="50.0" prefHeight="34.0" prefWidth="118.0" text="Preis in Euro:">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<JFXTextField fx:id="tftNewValue" alignment="CENTER" labelFloat="true" layoutX="380.0" layoutY="50.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="25.0" prefWidth="58.0">
<JFXTextField fx:id="tftNewValue" alignment="CENTER" labelFloat="true" layoutX="442.0" layoutY="42.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="27.0" prefWidth="66.0">
<font>
<Font name="Cantarell Regular" size="13.0" />
<Font name="Cantarell Regular" size="18.0" />
</font>
</JFXTextField>
<Label fx:id="labelNewColor" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="455.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Farbe:">
<Label fx:id="labelNewColor" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="517.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Farbe:">
<font>
<Font name="Cantarell Regular" size="18.0" />
</font>
</Label>
<ChoiceBox fx:id="colorChoise" layoutX="346.0" layoutY="90.0" prefHeight="25.0" prefWidth="96.0" />
<Label fx:id="labelSelectCat" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="204.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Kategorie:">
<ChoiceBox fx:id="colorChoise" layoutX="340.0" layoutY="90.0" prefHeight="25.0" prefWidth="169.0" />
<Label fx:id="labelSelectCat" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="185.0" layoutY="10.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" />
<ChoiceBox fx:id="catChoise" layoutX="16.0" layoutY="10.0" prefHeight="25.0" prefWidth="180.0" />
<Button fx:id="btnSaveEntry" layoutX="23.0" layoutY="86.0" mnemonicParsing="false" onAction="#btnSaveEntryAction" text="Ausgewählten Eintrag speichern">
<font>
<Font name="Cantarell Regular" size="17.0" />
</font>
</Button>
</children>
</AnchorPane>
</content>
@ -305,7 +332,7 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="850.0" prefWidth="1536.0">
<children>
<TreeTableView fx:id="tableCurrentOrder" layoutX="15.0" layoutY="85.0" prefHeight="379.0" prefWidth="382.0">
<TreeTableView fx:id="tableCurrentOrder" layoutX="15.0" layoutY="85.0" prefHeight="358.0" prefWidth="382.0">
<placeholder>
<Label text="" />
</placeholder>
@ -460,17 +487,17 @@
</JFXButton>
</children>
</GridPane>
<Button fx:id="btnPrintBill" contentDisplay="CENTER" defaultButton="true" graphicTextGap="1.0" layoutX="75.0" layoutY="599.0" maxHeight="88.0" minHeight="75.0" mnemonicParsing="false" onAction="#btnPrintBillAction" prefHeight="88.0" prefWidth="258.0" text="Drucken" textAlignment="CENTER" wrapText="true">
<Button fx:id="btnPrintBill" contentDisplay="CENTER" defaultButton="true" graphicTextGap="1.0" layoutX="75.0" layoutY="588.0" maxHeight="88.0" minHeight="75.0" mnemonicParsing="false" onAction="#btnPrintBillAction" prefHeight="88.0" prefWidth="258.0" text="Drucken" textAlignment="CENTER" wrapText="true">
<font>
<Font name="Cantarell Bold" size="48.0" />
</font>
</Button>
<Button fx:id="btnDeleteSelectedPosition" layoutX="43.0" layoutY="475.0" mnemonicParsing="false" onAction="#btnDeleteSelectedPositionAction" prefHeight="17.0" prefWidth="332.0" text="Ausgewählte Position löschen" textAlignment="CENTER">
<Button fx:id="btnDeleteSelectedPosition" layoutX="43.0" layoutY="458.0" mnemonicParsing="false" onAction="#btnDeleteSelectedPositionAction" prefHeight="17.0" prefWidth="332.0" text="Ausgewählte Position löschen" textAlignment="CENTER">
<font>
<Font name="Cantarell Regular" size="20.0" />
</font>
</Button>
<Label fx:id="labelAllPrize" alignment="CENTER" contentDisplay="CENTER" layoutX="10.0" layoutY="511.0" prefHeight="15.0" prefWidth="386.0" text="0,00 €" textAlignment="CENTER">
<Label fx:id="labelAllPrize" alignment="CENTER" contentDisplay="CENTER" layoutX="10.0" layoutY="496.0" prefHeight="15.0" prefWidth="386.0" text="0,00 €" textAlignment="CENTER">
<font>
<Font name="Cantarell Regular" size="70.0" />
</font>

Loading…
Cancel
Save