diff --git a/src/main/java/bigfilecreator/BigFileCreator.java b/src/main/java/bigfilecreator/BigFileCreator.java index 9da8231..9dae244 100644 --- a/src/main/java/bigfilecreator/BigFileCreator.java +++ b/src/main/java/bigfilecreator/BigFileCreator.java @@ -10,7 +10,6 @@ import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; import javafx.event.ActionEvent; -import javafx.event.EventHandler; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Button; @@ -93,7 +92,7 @@ public void start(Stage primaryStage) //Line 14. gb.add(null, 2); - gb.add(new Button("Buduj Plik")); + gb.add(new Button("Buduj plik")); gb.add(new Text()); gb.add(new Text(), 4); @@ -134,7 +133,7 @@ public void start(Stage primaryStage) tf.focusedProperty().addListener ( (ObservableValue observable, Boolean oldValue, Boolean newValue) -> - { NameValidator.isWrong((boolean)newValue, (TextField)tfList.get(0), (Text)tList.get(1), (Text)tList.get(2), (TextField)tfList.get(1), fs); } + NameValidator.isWrong(newValue, (TextField)tfList.get(0), (Text)tList.get(1), (Text)tList.get(2), (TextField)tfList.get(1), fs) ); //Path----------------------------- @@ -174,7 +173,7 @@ public void start(Stage primaryStage) tf.focusedProperty().addListener ( (ObservableValue observable, Boolean oldValue, Boolean newValue) -> - { SizeValidator.isWrong((boolean)newValue, (TextField)tfList.get(2), (Text)tList.get(7)); } + SizeValidator.isWrong(newValue, (TextField)tfList.get(2), (Text)tList.get(7)) ); //Structure----------------------------- @@ -203,11 +202,11 @@ public void start(Stage primaryStage) (ObservableValue observable, Boolean oldValue, Boolean newValue) -> { TextField temp; - StructureValidator.isWrong((boolean)newValue, (TextField)tfList.get(3), (Text)tList.get(8), (Text)tList.get(10), (Text)tList.get(9), fs); + StructureValidator.isWrong(newValue, (TextField)tfList.get(3), (Text)tList.get(8), (Text)tList.get(10), (Text)tList.get(9), fs); temp = (TextField)tfList.get(4); - if(fs.getStatesCount() > 0 && !temp.getText().equals("")) { StateValidator.isWrong((boolean)newValue, temp, (Text)tList.get(11), (Text)tList.get(13), (Text)tList.get(12), fs); } + if(fs.getStatesCount() > 0 && !temp.getText().equals("")) { StateValidator.isWrong(newValue, temp, (Text)tList.get(11), (Text)tList.get(13), (Text)tList.get(12), fs); } temp = (TextField)tfList.get(5); - if(!temp.getText().equals("")) { HeaderValidator.isWrong((boolean)newValue, temp, (Text)tList.get(14), (Text)tList.get(16), (Text)tList.get(15), fs); } + if(!temp.getText().equals("")) { HeaderValidator.isWrong(newValue, temp, (Text)tList.get(14), (Text)tList.get(16), (Text)tList.get(15), fs); } } ); @@ -234,7 +233,7 @@ public void start(Stage primaryStage) tf.focusedProperty().addListener ( (ObservableValue observable, Boolean oldValue, Boolean newValue) -> - { StateValidator.isWrong((boolean)newValue, (TextField)tfList.get(4), (Text)tList.get(11), (Text)tList.get(13), (Text)tList.get(12), fs); } + StateValidator.isWrong(newValue, (TextField)tfList.get(4), (Text)tList.get(11), (Text)tList.get(13), (Text)tList.get(12), fs) ); //Header----------------------------- @@ -262,7 +261,7 @@ public void start(Stage primaryStage) (ObservableValue observable, Boolean oldValue, Boolean newValue) -> { TextField temp = (TextField)tfList.get(5); - if(!temp.getText().equals("")) { HeaderValidator.isWrong((boolean)newValue, temp, (Text)tList.get(14), (Text)tList.get(16), (Text)tList.get(15), fs); } + if(!temp.getText().equals("")) { HeaderValidator.isWrong(newValue, temp, (Text)tList.get(14), (Text)tList.get(16), (Text)tList.get(15), fs); } } ); @@ -274,29 +273,24 @@ public void start(Stage primaryStage) btn.setDisable(true); btn.setMaxWidth(minWidthMainCol); - btn.setOnAction(new EventHandler() - { - @Override - public void handle(ActionEvent e) + btn.setOnAction(e -> { + if(!fs.isReady()) { - if(!fs.isReady()) - { - ((Text)tList.get(17)).setText(""); - ((Text)tList.get(18)).setText("Nie można zbudować pliku, wypełnij poprawnie wszystkie pola."); - } - else - { - ((Text)tList.get(17)).setText(""); - ((Text)tList.get(18)).setText(""); - - String path = fs.getAllName(); - File file = new File(path); - if(file.exists()) { file.delete(); } - Writter t1 = new Writter(fs); - WritterGUI t2 = new WritterGUI(fs, (Text)tList.get(17), btnList, tfList); - t1.start(); - t2.start(); - } + ((Text)tList.get(17)).setText(""); + ((Text)tList.get(18)).setText("Nie można zbudować pliku, wypełnij poprawnie wszystkie pola."); + } + else + { + ((Text)tList.get(17)).setText(""); + ((Text)tList.get(18)).setText(""); + + String path = fs.getAllName(); + File file = new File(path); + if(file.exists()) { file.delete(); } + Writer t1 = new Writer(fs); + WriterGUI t2 = new WriterGUI(fs, (Text)tList.get(17), btnList, tfList); + t1.start(); + t2.start(); } }); diff --git a/src/main/java/bigfilecreator/GridBuilder.java b/src/main/java/bigfilecreator/GridBuilder.java index b5cc0e2..0224e5f 100644 --- a/src/main/java/bigfilecreator/GridBuilder.java +++ b/src/main/java/bigfilecreator/GridBuilder.java @@ -25,12 +25,12 @@ public void add(Node child) if(child != null) { grid.add(child, p.c, p.v); } } - public void add(Node child, int colspan) + public void add(Node child, int colSpan) { Position p = pc.nextPosition(); - if(child != null) { grid.add(child, p.c, p.v, colspan, 1); } - for(int i=0 ; i 0) { writer.println(toWrite); } @@ -42,11 +42,9 @@ public void run() while(currentSize < size) { toWrite = ""; - for(int i=0 ; i 2100-12-31 23:59:59.999999999 + case "Timestamp": { + //1900-01-01 00:00:00.0 -> 2100-12-31 23:59:59.999999999 Timestamp tmp = new Timestamp(rand.nextInt(201), rand.nextInt(12), rand.nextInt(29), rand.nextInt(24), rand.nextInt(60), rand.nextInt(60), rand.nextInt(1000000000)); - Timestamp t = new Timestamp(tmp.getTime() + rand.nextInt(4)*86400000); + Timestamp t = new Timestamp(tmp.getTime() + rand.nextInt(4) * 86400000); toWrite += t.toString().substring(0, 16) + delimiter; break; } - - case "state": - { + + case "state": { ArrayList temp = states.get(stateIt); toWrite += temp.get(rand.nextInt(temp.size())) + delimiter; stateIt++; @@ -121,7 +110,9 @@ public void run() break; } - default: { break; } + default: { + break; + } } } writer.println(toWrite.substring(0, toWrite.length()-1)); diff --git a/src/main/java/bigfilecreator/WritterGUI.java b/src/main/java/bigfilecreator/WriterGUI.java similarity index 83% rename from src/main/java/bigfilecreator/WritterGUI.java rename to src/main/java/bigfilecreator/WriterGUI.java index 1ac4574..66a904f 100644 --- a/src/main/java/bigfilecreator/WritterGUI.java +++ b/src/main/java/bigfilecreator/WriterGUI.java @@ -5,14 +5,14 @@ import javafx.scene.Node; import javafx.scene.text.Text; -public class WritterGUI extends Thread +public class WriterGUI extends Thread { private final Text status; private final ObservableList btnList; private final ObservableList tfList; private final FileSettings fs; - public WritterGUI(FileSettings settings, Text status, ObservableList btnList, ObservableList tfList) + public WriterGUI(FileSettings settings, Text status, ObservableList btnList, ObservableList tfList) { this.fs = settings; this.status = status; @@ -24,7 +24,7 @@ public WritterGUI(FileSettings settings, Text status, ObservableList btnLi public void run() { ObservableList temp; - temp = tfList.filtered(tf -> tf.isDisabled() == false); + temp = tfList.filtered(tf -> !tf.isDisabled()); temp.forEach(tf -> tf.setDisable(true)); btnList.forEach(b -> b.setDisable(true));