diff --git a/README.md b/README.md index 52e760a..aebe1c6 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,7 @@ A project for class "programming 2" at Baden-Wuerttemberg Cooperative State Univ ## Todo -- Highlight items with priority -- Highlight items past due (and TodoList!) +- Highlight TodoLists with items past due - filter items (include/exclude done items) ## Dependencies diff --git a/src/de/t_battermann/dhbw/todolist/Controller.java b/src/de/t_battermann/dhbw/todolist/Controller.java index 5eda88e..db33cf7 100644 --- a/src/de/t_battermann/dhbw/todolist/Controller.java +++ b/src/de/t_battermann/dhbw/todolist/Controller.java @@ -8,6 +8,7 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.*; +import javafx.scene.paint.Paint; import javafx.stage.Stage; import java.io.File; @@ -32,6 +33,26 @@ public class Controller { showLoadFileDialog(); } + static class TodoListCell extends ListCell { + @Override + public void updateItem(Todo item, boolean empty) { + super.updateItem(item, empty); + if ( !empty && item != null ) { + if ( item.isPrio() && !item.isDone() ) { + this.setStyle("-fx-graphic:url(/de/t_battermann/dhbw/todolist/star.png);"); + }else{ + this.setStyle("-fx-graphic:null;"); + } + this.setTextFill(Paint.valueOf(item.isDone() ? "#999999" : (item.pastDue() ? "#aa0000" :"#000000") )); + this.setText(item.getTitle() + (item.getDueDate() != null ? " (due: "+item.getDateTime()+")" : "")); + }else{ + this.setStyle("-fx-graphic:null;"); + this.setTextFill(Paint.valueOf("#000000")); + this.setText(""); + } + } + } + /** * Initialize new empty */ @@ -264,6 +285,7 @@ public class Controller { lv.getSelectionModel().selectedIndexProperty().addListener(event -> { this.updateSelectedTodo(); }); + lv.setCellFactory(param -> new TodoListCell()); }else{ ErrorPrinter.printWarning("showMainWindow > Couldn’t find element '#todos'"); } @@ -720,6 +742,7 @@ public class Controller { } this.currentTodo.setDone(!this.currentTodo.isDone()); ((ToggleButton) n).setSelected(this.currentTodo.isDone()); + this.notifyList(todos,currentTodo); } private void toggleStar() { @@ -732,6 +755,7 @@ public class Controller { } this.currentTodo.setPrio(!this.currentTodo.isPrio()); ((ToggleButton) n).setSelected(this.currentTodo.isPrio()); + this.notifyList(todos,currentTodo); } private void newTodoItem() { diff --git a/src/de/t_battermann/dhbw/todolist/Todo.java b/src/de/t_battermann/dhbw/todolist/Todo.java index 2b7ce9a..5bed469 100644 --- a/src/de/t_battermann/dhbw/todolist/Todo.java +++ b/src/de/t_battermann/dhbw/todolist/Todo.java @@ -160,6 +160,12 @@ public class Todo { return this.getDueDate() != null ? format.format(this.getDueDate().getTime()) : "00:00"; } + public String getDateTime() { + SimpleDateFormat format = new SimpleDateFormat(); + format.applyPattern("yyyy-MM-dd HH:mm"); + return this.getDueDate() != null ? format.format(this.getDueDate().getTime()) : "0000-00-00 00:00"; + } + public boolean validateTime(String time) { return time.matches("([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2})?|[0-9]{1,4})"); } @@ -184,6 +190,13 @@ public class Todo { this.dueDate = nd; } + public boolean pastDue() { + if ( this.dueDate == null ) + return false; + Calendar today = new GregorianCalendar(); + return today.after(this.dueDate); + } + @Override public String toString() { return this.getTitle(); diff --git a/src/de/t_battermann/dhbw/todolist/star.png b/src/de/t_battermann/dhbw/todolist/star.png new file mode 100644 index 0000000..65c0a06 Binary files /dev/null and b/src/de/t_battermann/dhbw/todolist/star.png differ diff --git a/src/de/t_battermann/dhbw/todolist/star.svg b/src/de/t_battermann/dhbw/todolist/star.svg new file mode 100644 index 0000000..cb276a0 --- /dev/null +++ b/src/de/t_battermann/dhbw/todolist/star.svg @@ -0,0 +1,76 @@ + + + + + + + + + + image/svg+xml + + + + + + + + +