Commit 8f458606 authored by edmundszagars's avatar edmundszagars
Browse files

Implementing removals of items if sorting type is un-selected

parent f17b5e57
......@@ -55,9 +55,10 @@ public class MainWindow extends Application {
if (bubbleSortCheckBox.isSelected()) {
System.out.println("Bubble selected");
sortables.add(new BubbleSort());
}else if (!bubbleSortCheckBox.isSelected()){
//TODO: Rremove item from sortables"
System.out.println("BS unselected");
System.out.println("Sortable size now: " + sortables.size());
} else if (!bubbleSortCheckBox.isSelected()) {
sortables.removeIf(p -> p.getSortTypeName().equals("Bubble sort"));
System.out.println("Sortable size now: " + sortables.size());
}
});
......@@ -66,8 +67,12 @@ public class MainWindow extends Application {
selectionSortCheckBox.setSelected(false);
selectionSortCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (selectionSortCheckBox.isSelected()) {
System.out.println("Selection sort selected");
System.out.println("Selection selected");
sortables.add(new SelectionSort());
System.out.println("Sortable size now: " + sortables.size());
} else if (!selectionSortCheckBox.isSelected()) {
sortables.removeIf(p -> p.getSortTypeName().equals("Selection sort"));
System.out.println("Sortable size now: " + sortables.size());
}
});
......@@ -76,8 +81,13 @@ public class MainWindow extends Application {
insertionSortCheckBox.setSelected(false);
insertionSortCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (insertionSortCheckBox.isSelected()) {
System.out.println("Insertion sort selected");
System.out.println("Insertion selected");
sortables.add(new InsertionSort());
System.out.println("Sortable size now: " + sortables.size());
} else if (!insertionSortCheckBox.isSelected()) {
sortables.removeIf(p -> p.getSortTypeName().equals("Insertion sort"));
System.out.println("Sortable size now: " + sortables.size());
}
});
......@@ -86,8 +96,13 @@ public class MainWindow extends Application {
quickSortCheckBox.setSelected(false);
quickSortCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (quickSortCheckBox.isSelected()) {
System.out.println("Quick sort selected");
System.out.println("Quick selected");
sortables.add(new QuickSort());
System.out.println("Sortable size now: " + sortables.size());
} else if (!quickSortCheckBox.isSelected()) {
sortables.removeIf(p -> p.getSortTypeName().equals("Quick sort"));
System.out.println("Sortable size now: " + sortables.size());
}
});
......@@ -96,8 +111,13 @@ public class MainWindow extends Application {
mergeSortCheckBox.setSelected(false);
mergeSortCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (mergeSortCheckBox.isSelected()) {
System.out.println("Merge sort selected");
System.out.println("Merge selected");
sortables.add(new MergeSort());
System.out.println("Sortable size now: " + sortables.size());
} else if (!mergeSortCheckBox.isSelected()) {
sortables.removeIf(p -> p.getSortTypeName().equals("Merge sort"));
System.out.println("Sortable size now: " + sortables.size());
}
});
......@@ -120,14 +140,14 @@ public class MainWindow extends Application {
Button startButton = new Button("Run tests");
startButton.setOnAction(event -> {
if(fileLocation.getText().equals("")){
if (fileLocation.getText().equals("")) {
new ErrorBox("No file selected!",
"Please select CSV file to run sorting algorithms");
"Please select CSV file to run sorting algorithms");
return;
}
if(sortables.isEmpty()){
if (sortables.isEmpty()) {
new ErrorBox("No sort algorithm selected",
"Please select sorting algorithm to execute test");
"Please select sorting algorithm to execute test");
return;
}
......@@ -135,11 +155,11 @@ public class MainWindow extends Application {
dataFromCSV.setnFileLocation(filePath);
try {
list = new ArrayList<>(dataFromCSV.getDataFromCSV());
} catch (FileNotFoundException e){
new ErrorBox("File not found","");
} catch (FileNotFoundException e) {
new ErrorBox("File not found", "");
e.printStackTrace();
}catch (NullPointerException npe){
new ErrorBox("Oops something went wrong","Error something happened");
} catch (NullPointerException npe) {
new ErrorBox("Oops something went wrong", "Error something happened");
return;
}
for (Object aList : list) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment