Removed headers on Dictionary and PracticeList.
This commit is contained in:
parent
277278377f
commit
0bcd37a860
2 changed files with 85 additions and 53 deletions
|
@ -7,6 +7,8 @@
|
||||||
package uk.ac.aber.cs221.group20.javafx;
|
package uk.ac.aber.cs221.group20.javafx;
|
||||||
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.collections.transformation.FilteredList;
|
import javafx.collections.transformation.FilteredList;
|
||||||
|
@ -18,6 +20,8 @@ import javafx.scene.control.TableView;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.BorderPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
|
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
|
||||||
|
|
||||||
|
@ -128,7 +132,19 @@ public class DictionaryController extends SharedCodeController {
|
||||||
*/
|
*/
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
setup();
|
setup();
|
||||||
|
table.widthProperty().addListener(new ChangeListener<Number>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Number> observableValue, Number number, Number t1) {
|
||||||
|
Pane tableHeader = (Pane) table.lookup("TableHeaderRow");
|
||||||
|
if (tableHeader != null && tableHeader.isVisible()) {
|
||||||
|
tableHeader.setMaxHeight(0);
|
||||||
|
tableHeader.setMinHeight(0);
|
||||||
|
tableHeader.setPrefHeight(0);
|
||||||
|
tableHeader.setVisible(false);
|
||||||
|
tableHeader.setManaged(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
english.setComparator(new Comparator<String>() {
|
english.setComparator(new Comparator<String>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(String s, String t1) {
|
public int compare(String s, String t1) {
|
||||||
|
@ -191,6 +207,7 @@ public class DictionaryController extends SharedCodeController {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
welsh.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> {
|
welsh.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> {
|
||||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nm)) {
|
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nm)) {
|
||||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nm}");
|
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nm}");
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
package uk.ac.aber.cs221.group20.javafx;
|
package uk.ac.aber.cs221.group20.javafx;
|
||||||
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.collections.transformation.FilteredList;
|
import javafx.collections.transformation.FilteredList;
|
||||||
|
@ -15,6 +17,7 @@ import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
|
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
|
||||||
|
|
||||||
|
@ -62,19 +65,16 @@ public class PracticeListController extends SharedCodeController {
|
||||||
if (isSortedByEnglish) {
|
if (isSortedByEnglish) {
|
||||||
if (welsh.getSortType().equals(TableColumn.SortType.ASCENDING)) {
|
if (welsh.getSortType().equals(TableColumn.SortType.ASCENDING)) {
|
||||||
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png"));
|
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png"));
|
||||||
}
|
} else if (welsh.getSortType().equals(TableColumn.SortType.DESCENDING)) {
|
||||||
else if (welsh.getSortType().equals(TableColumn.SortType.DESCENDING)) {
|
|
||||||
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-reversed-50.png"));
|
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-reversed-50.png"));
|
||||||
}
|
}
|
||||||
table.getSortOrder().clear();
|
table.getSortOrder().clear();
|
||||||
table.getSortOrder().add(welsh);
|
table.getSortOrder().add(welsh);
|
||||||
isSortedByEnglish = false;
|
isSortedByEnglish = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (english.getSortType().equals(TableColumn.SortType.ASCENDING)) {
|
if (english.getSortType().equals(TableColumn.SortType.ASCENDING)) {
|
||||||
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png"));
|
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png"));
|
||||||
}
|
} else if (english.getSortType().equals(TableColumn.SortType.DESCENDING)) {
|
||||||
else if (english.getSortType().equals(TableColumn.SortType.DESCENDING)) {
|
|
||||||
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-reversed-50.png"));
|
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-reversed-50.png"));
|
||||||
}
|
}
|
||||||
table.getSortOrder().clear();
|
table.getSortOrder().clear();
|
||||||
|
@ -83,7 +83,7 @@ public class PracticeListController extends SharedCodeController {
|
||||||
}
|
}
|
||||||
table.sort();
|
table.sort();
|
||||||
searchBox.textProperty().setValue(searchBox.textProperty().getValue() + " ");
|
searchBox.textProperty().setValue(searchBox.textProperty().getValue() + " ");
|
||||||
searchBox.textProperty().setValue(searchBox.textProperty().getValue().substring(0, searchBox.textProperty().getValue().length()-1));
|
searchBox.textProperty().setValue(searchBox.textProperty().getValue().substring(0, searchBox.textProperty().getValue().length() - 1));
|
||||||
searchBox.positionCaret(searchBox.textProperty().getValue().length());
|
searchBox.positionCaret(searchBox.textProperty().getValue().length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,31 +117,45 @@ public class PracticeListController extends SharedCodeController {
|
||||||
* <p>
|
* <p>
|
||||||
* An observable list of DictionaryEntries is loaded from the Application class into a local instance of ObservableList.
|
* An observable list of DictionaryEntries is loaded from the Application class into a local instance of ObservableList.
|
||||||
* It also sets up Lambda expressions related to live searching functionality and the display of DictionaryEntries.
|
* It also sets up Lambda expressions related to live searching functionality and the display of DictionaryEntries.
|
||||||
|
* <p>
|
||||||
|
* // * @param url
|
||||||
|
* // * @param resourceBundle
|
||||||
*
|
*
|
||||||
// * @param url
|
|
||||||
// * @param resourceBundle
|
|
||||||
* @see Application
|
* @see Application
|
||||||
* @see DictionaryEntry
|
* @see DictionaryEntry
|
||||||
*/
|
*/
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
setup();
|
setup();
|
||||||
|
table.widthProperty().addListener(new ChangeListener<Number>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Number> observableValue, Number number, Number t1) {
|
||||||
|
Pane tableHeader = (Pane) table.lookup("TableHeaderRow");
|
||||||
|
if (tableHeader != null && tableHeader.isVisible()) {
|
||||||
|
tableHeader.setMaxHeight(0);
|
||||||
|
tableHeader.setMinHeight(0);
|
||||||
|
tableHeader.setPrefHeight(0);
|
||||||
|
tableHeader.setVisible(false);
|
||||||
|
tableHeader.setManaged(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
english.setComparator(new Comparator<String>() {
|
english.setComparator(new Comparator<String>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(String s, String t1) {
|
public int compare(String s, String t1) {
|
||||||
s = s.toLowerCase();
|
s = s.toLowerCase();
|
||||||
t1 = t1.toLowerCase();
|
t1 = t1.toLowerCase();
|
||||||
if (s.startsWith("to ")) {
|
if (s.startsWith("to ")) {
|
||||||
return s.substring(3).compareTo(t1);
|
return s.substring(3).compareTo(t1);
|
||||||
}
|
}
|
||||||
if (t1.startsWith("to ")) {
|
if (t1.startsWith("to ")) {
|
||||||
return s.compareTo(t1.substring(3));
|
return s.compareTo(t1.substring(3));
|
||||||
}
|
}
|
||||||
return s.compareTo(t1);
|
return s.compareTo(t1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
currentPageIcon.setImage(new Image(getClass().getResourceAsStream("/assets/icons/white_icons/50px/rating-50.png")));
|
currentPageIcon.setImage(new Image(getClass().getResourceAsStream("/assets/icons/white_icons/50px/rating-50.png")));
|
||||||
currentPageText.setText("Practice List");
|
currentPageText.setText("Practice List");
|
||||||
|
|
||||||
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png"));
|
alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png"));
|
||||||
|
@ -161,32 +175,35 @@ public class PracticeListController extends SharedCodeController {
|
||||||
// if (dictionaryEntry.isPracticeWord()) {
|
// if (dictionaryEntry.isPracticeWord()) {
|
||||||
// setStyle("-fx-background-color: gray;");
|
// setStyle("-fx-background-color: gray;");
|
||||||
// } else {
|
// } else {
|
||||||
setStyle(" ");
|
setStyle(" ");
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
row.setOnMouseClicked(mouseEvent -> {
|
row.setOnMouseClicked(mouseEvent -> {
|
||||||
if (mouseEvent.getClickCount() == 1 && (!row.isEmpty())) {
|
if (mouseEvent.getClickCount() == 1 && (!row.isEmpty())) {
|
||||||
if (row.getItem().isPracticeWord()) {
|
for (DictionaryEntry entry : Application.dictionary) {
|
||||||
Application.dictionary.get(list.indexOf(row.getItem())).setPracticeWord(false);
|
if (entry.equals(row.getItem())) {
|
||||||
ArrayList<DictionaryEntry> toRemove = new ArrayList<DictionaryEntry>();
|
entry.setPracticeWord(false);
|
||||||
for (DictionaryEntry entry : Application.practiceList) {
|
list.remove(row.getItem());
|
||||||
if (entry.equals(row.getItem())) {
|
table.refresh();
|
||||||
toRemove.add(entry);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Application.practiceList.removeAll(toRemove);
|
|
||||||
// row.getItem().setPracticeWord(false);
|
ArrayList<DictionaryEntry> toRemove = new ArrayList<DictionaryEntry>();
|
||||||
} else if (!row.getItem().isPracticeWord()) {
|
for (DictionaryEntry entry : Application.practiceList) {
|
||||||
Application.dictionary.get(list.indexOf(row.getItem())).setPracticeWord(true);
|
if (entry.equals(row.getItem())) {
|
||||||
Application.practiceList.add(row.getItem());
|
toRemove.add(entry);
|
||||||
// row.getItem().setPracticeWord(true);
|
list.remove(row.getItem());
|
||||||
}
|
}
|
||||||
table.getSelectionModel().clearSelection();
|
}
|
||||||
}
|
Application.practiceList.removeAll(toRemove);
|
||||||
});
|
table.getSelectionModel().clearSelection();
|
||||||
return row;
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return row;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
welsh.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> {
|
welsh.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> {
|
||||||
|
@ -222,15 +239,13 @@ public class PracticeListController extends SharedCodeController {
|
||||||
if (isSortedByEnglish) {
|
if (isSortedByEnglish) {
|
||||||
if (dictionaryEntry.getEnglish().toLowerCase().startsWith(lowerCaseSearchFilter)) {
|
if (dictionaryEntry.getEnglish().toLowerCase().startsWith(lowerCaseSearchFilter)) {
|
||||||
result = true; // Filter matches English
|
result = true; // Filter matches English
|
||||||
}
|
} else if (lowerCaseSearchFilter.startsWith("to ")) {
|
||||||
else if(lowerCaseSearchFilter.startsWith("to ")){
|
|
||||||
if (dictionaryEntry.getWordType().equals(DictionaryEntry.wordTypeEnum.verb) && ("to " + dictionaryEntry.getEnglish()).toLowerCase().startsWith(lowerCaseSearchFilter)) {
|
if (dictionaryEntry.getWordType().equals(DictionaryEntry.wordTypeEnum.verb) && ("to " + dictionaryEntry.getEnglish()).toLowerCase().startsWith(lowerCaseSearchFilter)) {
|
||||||
result = true; // Filter matches ['to' + a word] or [a word] if word is a verb
|
result = true; // Filter matches ['to' + a word] or [a word] if word is a verb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
if (dictionaryEntry.getWelsh().toLowerCase().startsWith(lowerCaseSearchFilter)) {
|
||||||
if (dictionaryEntry.getWelsh().toLowerCase().startsWith(lowerCaseSearchFilter)) {
|
|
||||||
result = true; // Filter matches Welsh
|
result = true; // Filter matches Welsh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,9 +259,9 @@ public class PracticeListController extends SharedCodeController {
|
||||||
|
|
||||||
table.setItems(sortedList);
|
table.setItems(sortedList);
|
||||||
|
|
||||||
if(isSortedByEnglish){
|
if (isSortedByEnglish) {
|
||||||
table.getSortOrder().add(english);
|
table.getSortOrder().add(english);
|
||||||
} else{
|
} else {
|
||||||
table.getSortOrder().add(welsh);
|
table.getSortOrder().add(welsh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue