Bug fix: select entries on startup

Fixed debug output
main
Thomas Battermann 10 years ago committed by thomasba
parent 45cd818c2f
commit a5e02b95d0

@ -253,6 +253,7 @@ public class Controller {
ListView<TodoList> lv = (ListView<TodoList>) n; ListView<TodoList> lv = (ListView<TodoList>) n;
lv.setItems(this.todoLists); lv.setItems(this.todoLists);
lv.scrollTo(currentUser.getTodoList("Default")); lv.scrollTo(currentUser.getTodoList("Default"));
lv.getSelectionModel().select(currentUser.getTodoList("Default"));
lv.getSelectionModel().selectedIndexProperty().addListener(event -> { lv.getSelectionModel().selectedIndexProperty().addListener(event -> {
this.updateSelectedTodoList(); this.updateSelectedTodoList();
}); });
@ -264,6 +265,9 @@ public class Controller {
if (n != null && n instanceof ListView) { if (n != null && n instanceof ListView) {
ListView<Todo> lv = (ListView<Todo>) n; ListView<Todo> lv = (ListView<Todo>) n;
lv.setItems(this.todos); lv.setItems(this.todos);
if (!this.todos.isEmpty()) {
lv.getSelectionModel().select(0);
}
lv.getSelectionModel().selectedIndexProperty().addListener(event -> { lv.getSelectionModel().selectedIndexProperty().addListener(event -> {
this.updateSelectedTodo(); this.updateSelectedTodo();
}); });
@ -1009,7 +1013,7 @@ public class Controller {
// get current TodoList // get current TodoList
n = primaryStage.getScene().lookup("#todoLists"); n = primaryStage.getScene().lookup("#todoLists");
if (n == null || !(n instanceof ListView)) { if (n == null || !(n instanceof ListView)) {
ErrorPrinter.printWarning("showDeleteList > Didnt find element #todoLists!"); ErrorPrinter.printWarning("showMoveTodoItem > Didnt find element #todoLists!");
return; return;
} }
ListView l = (ListView) n; ListView l = (ListView) n;
@ -1017,19 +1021,19 @@ public class Controller {
if (l.getSelectionModel().getSelectedItem() != null && l.getSelectionModel().getSelectedItem() instanceof TodoList) { if (l.getSelectionModel().getSelectedItem() != null && l.getSelectionModel().getSelectedItem() instanceof TodoList) {
t = (TodoList) l.getSelectionModel().getSelectedItem(); t = (TodoList) l.getSelectionModel().getSelectedItem();
} else { } else {
ErrorPrinter.printWarning("showDeleteList > Didnt find selected item!"); ErrorPrinter.printWarning("showMoveTodoItem > Didnt find selected item!");
return; return;
} }
n = move.getScene().lookup("#source"); n = move.getScene().lookup("#source");
if (n == null || !(n instanceof TextField)) { if (n == null || !(n instanceof TextField)) {
ErrorPrinter.printWarning("showDeleteList > Didnt find element #source"); ErrorPrinter.printWarning("showMoveTodoItem > Didnt find element #source");
return; return;
} }
((TextField) n).setText(t.getName()); ((TextField) n).setText(t.getName());
// populate dropdown // populate dropdown
n = move.getScene().lookup("#destination"); n = move.getScene().lookup("#destination");
if (n == null || !(n instanceof ChoiceBox)) { if (n == null || !(n instanceof ChoiceBox)) {
ErrorPrinter.printWarning("showDeleteList > Didnt find element #destination"); ErrorPrinter.printWarning("showMoveTodoItem > Didnt find element #destination");
return; return;
} }
ChoiceBox<TodoList> c = (ChoiceBox) n; ChoiceBox<TodoList> c = (ChoiceBox) n;
@ -1037,14 +1041,14 @@ public class Controller {
// event handlers // event handlers
n = move.getScene().lookup("#abort"); n = move.getScene().lookup("#abort");
if (n == null || !(n instanceof Button)) { if (n == null || !(n instanceof Button)) {
ErrorPrinter.printWarning("showDeleteList > Didnt find element #abort"); ErrorPrinter.printWarning("showMoveTodoItem > Didnt find element #abort");
move.close(); move.close();
return; return;
} }
((Button) n).setOnAction(event -> move.close()); ((Button) n).setOnAction(event -> move.close());
n = move.getScene().lookup("#move"); n = move.getScene().lookup("#move");
if (n == null || !(n instanceof Button)) { if (n == null || !(n instanceof Button)) {
ErrorPrinter.printWarning("showDeleteList > Didnt find element #move"); ErrorPrinter.printWarning("showMoveTodoItem > Didnt find element #move");
move.close(); move.close();
return; return;
} }
@ -1052,7 +1056,7 @@ public class Controller {
// first add the item to the destination // first add the item to the destination
TodoList list = c.getSelectionModel().getSelectedItem(); TodoList list = c.getSelectionModel().getSelectedItem();
if (list == null) { if (list == null) {
ErrorPrinter.printWarning("showDeleteList > Invalid selection!"); ErrorPrinter.printWarning("showMoveTodoItem > Invalid selection!");
this.updateStatusLine("Invalid selection!"); this.updateStatusLine("Invalid selection!");
return; return;
} }
@ -1088,7 +1092,7 @@ public class Controller {
super.updateItem(item, empty); super.updateItem(item, empty);
if (!empty && item != null) { if (!empty && item != null) {
if (item.isPrio() && !item.isDone()) { if (item.isPrio() && !item.isDone()) {
this.setStyle("-fx-graphic:url(/de/t_battermann/dhbw/todolist/star.png);"); this.setStyle("-fx-graphic:url(/de/t_battermann/dhbw/todolist/images/rating.png);");
} else { } else {
this.setStyle("-fx-graphic:null;"); this.setStyle("-fx-graphic:null;");
} }

Loading…
Cancel
Save