Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 25 additions & 31 deletions src/main/java/bigfilecreator/BigFileCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -134,7 +133,7 @@ public void start(Stage primaryStage)
tf.focusedProperty().addListener
(
(ObservableValue<? extends Boolean> 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-----------------------------
Expand Down Expand Up @@ -174,7 +173,7 @@ public void start(Stage primaryStage)
tf.focusedProperty().addListener
(
(ObservableValue<? extends Boolean> 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-----------------------------
Expand Down Expand Up @@ -203,11 +202,11 @@ public void start(Stage primaryStage)
(ObservableValue<? extends Boolean> 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); }
}
);

Expand All @@ -234,7 +233,7 @@ public void start(Stage primaryStage)
tf.focusedProperty().addListener
(
(ObservableValue<? extends Boolean> 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-----------------------------
Expand Down Expand Up @@ -262,7 +261,7 @@ public void start(Stage primaryStage)
(ObservableValue<? extends Boolean> 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); }
}
);

Expand All @@ -274,29 +273,24 @@ public void start(Stage primaryStage)
btn.setDisable(true);
btn.setMaxWidth(minWidthMainCol);

btn.setOnAction(new EventHandler<ActionEvent>()
{
@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();
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/bigfilecreator/GridBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<colspan-1 ; i++) { pc.nextPosition(); }
if(child != null) { grid.add(child, p.c, p.v, colSpan, 1); }
for(int i=0 ; i<colSpan-1 ; i++) { pc.nextPosition(); }
}

public GridPane getGrid() { return grid; }
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/bigfilecreator/Validate/ValidateSettings.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package bigfilecreator.Validate;

import bigfilecreator.FileSettings;
import java.io.File;
import java.util.Scanner;
import java.util.regex.Matcher;
Expand All @@ -9,7 +8,6 @@
public class ValidateSettings
{
public static final int maxNameLength = 35;
private static Scanner scan;

private static final String namePtrnStr = "(.+)[.](.+)";

Expand Down Expand Up @@ -116,7 +114,7 @@ public static double checkDouble(String value)
{
try
{
scan = new Scanner(value);
Scanner scan = new Scanner(value);
size = scan.nextDouble();
}
catch(Exception ex2) { return Double.NEGATIVE_INFINITY; }
Expand Down Expand Up @@ -149,7 +147,6 @@ public static boolean checkState(String value)
if(value == null) { return false; }
value = value.trim();
Matcher m = statePtrn.matcher(value);
if(!m.find()) { return false; }
return true;
return m.find();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import java.sql.Timestamp;
import java.util.ArrayList;

public class Writter extends Thread
public class Writer extends Thread
{
final FileSettings fs;
private final FileSettings fs;

public Writter(FileSettings settings) { this.fs = settings; }
public Writer(FileSettings settings) { this.fs = settings; }

@Override
public void run()
Expand All @@ -30,7 +30,7 @@ public void run()
delimiter = "\t";
structure = structure.replace(" t ", " \t ");
}
String[] splittedArray = structure.split(delimiter);
String[] splitArray = structure.split(delimiter);

String type, toWrite = fs.getHeader().replace(" t ", " \t ");
if(toWrite.length() > 0) { writer.println(toWrite); }
Expand All @@ -42,59 +42,50 @@ public void run()
while(currentSize < size)
{
toWrite = "";
for(int i=0 ; i<splittedArray.length ; i++)
{
type = splittedArray[i].trim();
switch(type)
{
for (String aSplitArray : splitArray) {
type = aSplitArray.trim();
switch (type) {
case "boolean":
toWrite += rand.nextBoolean() + delimiter;
break;

case "int":
toWrite += rand.nextInt() + delimiter;
break;

case "long":
toWrite += rand.nextLong() + delimiter;
break;

case "float":
{
float f=1;
case "float": {
float f = 1;
long pow = rand.nextInt(38);
for(int j=0 ; j<pow ; j++) { f *= 10L; }
for (int j = 0; j < pow; j++) {
f *= 10L;
}
f *= rand.nextFloat();
toWrite += f + delimiter;
break;
}

case "double":
{
double d=1;
case "double": {
double d = 1;
long pow = rand.nextInt(308);
for(int j=0 ; j<pow ; j++) { d *= 10L; }
for (int j = 0; j < pow; j++) {
d *= 10L;
}
d *= rand.nextDouble();
toWrite += d + delimiter;
break;
}

case "string":
case "String":
{
case "String": {
String s = "";
int len = rand.nextInt(20) + 1;
char c;
int k;
String alpha = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if(false) for(int j=0 ; j<len ; j++)
{
do { c = (char)rand.nextInt(65525); }
while(c == fs.getDelimiter());
s += c;
}
else for(int j=0 ; j<len ; j++)
{
for (int j = 0; j < len; j++) {
c = alpha.charAt(rand.nextInt(52));
s += c;
}
Expand All @@ -103,25 +94,25 @@ public void run()
}

case "timestamp":
case "Timestamp":
{
//1900-01-01 00:00:00.0 -> 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<String> temp = states.get(stateIt);
toWrite += temp.get(rand.nextInt(temp.size())) + delimiter;
stateIt++;
stateIt %= states.size();
break;
}

default: { break; }
default: {
break;
}
}
}
writer.println(toWrite.substring(0, toWrite.length()-1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Node> btnList;
private final ObservableList<Node> tfList;
private final FileSettings fs;

public WritterGUI(FileSettings settings, Text status, ObservableList<Node> btnList, ObservableList<Node> tfList)
public WriterGUI(FileSettings settings, Text status, ObservableList<Node> btnList, ObservableList<Node> tfList)
{
this.fs = settings;
this.status = status;
Expand All @@ -24,7 +24,7 @@ public WritterGUI(FileSettings settings, Text status, ObservableList<Node> btnLi
public void run()
{
ObservableList<Node> 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));

Expand Down