1818
1919import java .io .IOException ;
2020import java .time .LocalDate ;
21- import java .util .Comparator ;
22- import java .util .List ;
23- import java .util .Optional ;
24- import java .util .SortedSet ;
25- import java .util .TreeSet ;
21+ import java .util .*;
2622import java .util .stream .Collectors ;
2723
28- import javafx .scene .control .skin .DatePickerSkin ;
2924import org .slf4j .Logger ;
3025import org .slf4j .LoggerFactory ;
3126import org .springframework .beans .factory .annotation .Autowired ;
3227import org .springframework .stereotype .Component ;
3328
34-
3529import de .doubleslash .keeptime .common .DateFormatter ;
3630import de .doubleslash .keeptime .common .Resources ;
3731import de .doubleslash .keeptime .common .Resources .RESOURCE ;
5145import javafx .fxml .FXMLLoader ;
5246import javafx .scene .Node ;
5347import javafx .scene .canvas .Canvas ;
54- import javafx .scene .control .Alert ;
48+ import javafx .scene .control .* ;
5549import javafx .scene .control .Alert .AlertType ;
56- import javafx .scene .control .Button ;
57- import javafx .scene .control .ButtonType ;
58- import javafx .scene .control .ContentDisplay ;
59- import javafx .scene .control .DateCell ;
60- import javafx .scene .control .DatePicker ;
61- import javafx .scene .control .Dialog ;
62- import javafx .scene .control .Label ;
63- import javafx .scene .control .Tooltip ;
64- import javafx .scene .control .TreeItem ;
65- import javafx .scene .control .TreeTableCell ;
66- import javafx .scene .control .TreeTableColumn ;
67- import javafx .scene .control .TreeTableView ;
6850import javafx .scene .control .cell .TreeItemPropertyValueFactory ;
51+ import javafx .scene .control .skin .DatePickerSkin ;
6952import javafx .scene .input .Clipboard ;
7053import javafx .scene .input .ClipboardContent ;
7154import javafx .scene .layout .AnchorPane ;
@@ -152,10 +135,14 @@ protected void updateItem(final TableRow item, final boolean empty) {
152135 setText (null );
153136 } else {
154137 final String notes = item .getNotes ();
155- final Label label = new Label (notes .isEmpty () ? EMPTY_NOTE : notes );
156- label .setUnderline (item .isUnderlined ());
157- label .setTooltip (new Tooltip (notes ));
158- this .setGraphic (label );
138+ final String text = notes .isEmpty () ? EMPTY_NOTE : notes ;
139+ this .setText (text );
140+ if (item .getProjectColor () != null ) {
141+ final Circle circle = new Circle (6 , item .getProjectColor ());
142+ this .setGraphic (circle );
143+ } else {
144+ this .setGraphic (null );
145+ }
159146 }
160147 }
161148 };
@@ -175,8 +162,34 @@ protected void updateItem(final TableRow item, final boolean empty) {
175162 timeRangeColumn .setReorderable (false );
176163 this .workTableTreeView .getColumns ().add (timeRangeColumn );
177164
178- final TreeTableColumn <TableRow , String > timeSumColumn = new TreeTableColumn <>("Duration" );
179- timeSumColumn .setCellValueFactory (new TreeItemPropertyValueFactory <TableRow , String >("timeSum" ));
165+ final TreeTableColumn <TableRow , TableRow > timeSumColumn = new TreeTableColumn <>("Duration" );
166+ timeSumColumn .setCellFactory (new Callback <>() {
167+ @ Override
168+ public TreeTableCell <TableRow , TableRow > call (
169+ TreeTableColumn <TableRow , TableRow > tableRowStringTreeTableColumn ) {
170+
171+ return new TreeTableCell <>() {
172+
173+ @ Override
174+ protected void updateItem (TableRow workItem , boolean empty ) {
175+ super .updateItem (workItem , empty );
176+
177+ if (workItem == null || empty ) {
178+ this .setGraphic (null );
179+ this .setText (null );
180+ } else {
181+ Label workLabel = new Label (workItem .getTimeSum ());
182+ workLabel .setUnderline (workItem .isUnderlined ());
183+ this .setGraphic (workLabel );
184+ this .setText (null );
185+ }
186+ }
187+ };
188+ }
189+ });
190+ timeSumColumn .setCellValueFactory (
191+ (final TreeTableColumn .CellDataFeatures <TableRow , TableRow > entry ) -> new ReadOnlyObjectWrapper <>(
192+ entry .getValue ().getValue ()));
180193 timeSumColumn .setMinWidth (60 );
181194 timeSumColumn .setReorderable (false );
182195 this .workTableTreeView .getColumns ().add (timeSumColumn );
@@ -228,10 +241,8 @@ private void updateReport(final LocalDate dateToShow) {
228241 final HBox projectButtonBox = new HBox ();
229242 projectButtonBox .getChildren ().add (createCopyProjectButton (onlyCurrentProjectWork ));
230243
231- final Circle circle = new Circle (6 , project .getColor ());
232-
233244 final TreeItem <TableRow > projectRow = new TreeItem <>(
234- new ProjectTableRow (project , projectWorkSeconds , projectButtonBox ), circle );
245+ new ProjectTableRow (project , projectWorkSeconds , projectButtonBox ));
235246
236247 for (final Work w : onlyCurrentProjectWork ) {
237248 final HBox workButtonBox = new HBox (5.0 );
0 commit comments