Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Edmunds Žagars
Java_course_final
Commits
8f458606
Commit
8f458606
authored
Apr 14, 2018
by
edmundszagars
Browse files
Implementing removals of items if sorting type is un-selected
parent
f17b5e57
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
15 deletions
+35
-15
src/gui/MainWindow.java
src/gui/MainWindow.java
+35
-15
No files found.
src/gui/MainWindow.java
View file @
8f458606
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment