|
16 | 16 |
|
17 | 17 | package de.doubleslash.keeptime.view; |
18 | 18 |
|
19 | | -import java.io.IOException; |
20 | | -import 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; |
26 | | -import java.util.stream.Collectors; |
27 | | - |
28 | | -import javafx.scene.control.skin.DatePickerSkin; |
29 | | -import javafx.scene.paint.Color; |
30 | | -import javafx.scene.text.Text; |
31 | | -import org.slf4j.Logger; |
32 | | -import org.slf4j.LoggerFactory; |
33 | | -import org.springframework.beans.factory.annotation.Autowired; |
34 | | -import org.springframework.stereotype.Component; |
35 | | - |
36 | | - |
37 | 19 | import de.doubleslash.keeptime.common.DateFormatter; |
38 | 20 | import de.doubleslash.keeptime.common.Resources; |
39 | 21 | import de.doubleslash.keeptime.common.Resources.RESOURCE; |
|
53 | 35 | import javafx.fxml.FXMLLoader; |
54 | 36 | import javafx.scene.Node; |
55 | 37 | import javafx.scene.canvas.Canvas; |
56 | | -import javafx.scene.control.Alert; |
| 38 | +import javafx.scene.control.*; |
57 | 39 | import javafx.scene.control.Alert.AlertType; |
58 | | -import javafx.scene.control.Button; |
59 | | -import javafx.scene.control.ButtonType; |
60 | | -import javafx.scene.control.ContentDisplay; |
61 | | -import javafx.scene.control.DateCell; |
62 | | -import javafx.scene.control.DatePicker; |
63 | | -import javafx.scene.control.Dialog; |
64 | | -import javafx.scene.control.Label; |
65 | | -import javafx.scene.control.Tooltip; |
66 | | -import javafx.scene.control.TreeItem; |
67 | | -import javafx.scene.control.TreeTableCell; |
68 | | -import javafx.scene.control.TreeTableColumn; |
69 | | -import javafx.scene.control.TreeTableView; |
70 | 40 | import javafx.scene.control.cell.TreeItemPropertyValueFactory; |
| 41 | +import javafx.scene.control.skin.DatePickerSkin; |
71 | 42 | import javafx.scene.input.Clipboard; |
72 | 43 | import javafx.scene.input.ClipboardContent; |
73 | 44 | import javafx.scene.layout.AnchorPane; |
|
77 | 48 | import javafx.scene.shape.Circle; |
78 | 49 | import javafx.stage.Stage; |
79 | 50 | import javafx.util.Callback; |
| 51 | +import org.slf4j.Logger; |
| 52 | +import org.slf4j.LoggerFactory; |
| 53 | +import org.springframework.beans.factory.annotation.Autowired; |
| 54 | +import org.springframework.stereotype.Component; |
| 55 | + |
| 56 | +import java.io.IOException; |
| 57 | +import java.time.LocalDate; |
| 58 | +import java.util.*; |
| 59 | +import java.util.stream.Collectors; |
80 | 60 |
|
81 | 61 | @Component |
82 | 62 | public class ReportController { |
@@ -124,6 +104,8 @@ public class ReportController { |
124 | 104 |
|
125 | 105 | private final TreeItem<TableRow> rootItem = new TreeItem<>(); |
126 | 106 |
|
| 107 | + private static List<String> workTime = new ArrayList<>(); |
| 108 | + |
127 | 109 | @Autowired |
128 | 110 | public ReportController(final Model model, final Controller controller) { |
129 | 111 | this.model = model; |
@@ -182,28 +164,32 @@ protected void updateItem(final TableRow item, final boolean empty) { |
182 | 164 | this.workTableTreeView.getColumns().add(timeRangeColumn); |
183 | 165 |
|
184 | 166 | final TreeTableColumn<TableRow, String> timeSumColumn = new TreeTableColumn<>("Duration"); |
185 | | - timeSumColumn.setCellFactory(new Callback<TreeTableColumn<TableRow, String>, TreeTableCell<TableRow, String>>() { |
| 167 | + timeSumColumn.setCellFactory(new Callback<>() { |
186 | 168 | @Override |
187 | 169 | public TreeTableCell<TableRow, String> call(TreeTableColumn<TableRow, String> tableRowStringTreeTableColumn) { |
188 | 170 |
|
189 | | - return new TreeTableCell<TableRow,String>(){ |
| 171 | + return new TreeTableCell<>() { |
190 | 172 |
|
191 | 173 | @Override |
192 | | - protected void updateItem(String s, boolean b) { |
193 | | - super.updateItem(s, b); |
194 | | - Label l1 = new Label(s); |
195 | | - if(b){ |
| 174 | + protected void updateItem(String timeString, boolean empty) { |
| 175 | + super.updateItem(timeString, empty); |
| 176 | + |
| 177 | + if (timeString == null || empty) { |
196 | 178 | this.setGraphic(null); |
197 | | - }else if (l1.getText()!=null) { |
| 179 | + this.setText(null); |
| 180 | + |
| 181 | + } else { |
| 182 | + this.setGraphic(new Label(timeString)); |
198 | 183 |
|
199 | | - if (l1.getText().equals(currentDayWorkTimeLabel.getText())) { |
200 | | - l1.setUnderline(true); |
201 | | - this.setGraphic(l1); |
| 184 | + for (String workTime : workTime) { |
202 | 185 |
|
203 | | - } else { |
204 | | - Label label = new Label(s); |
205 | | - this.setGraphic(label); |
| 186 | + if (timeString.equals(workTime)) { |
| 187 | + Label workLabel = new Label(timeString); |
| 188 | + workLabel.setUnderline(true); |
| 189 | + this.setGraphic(workLabel); |
206 | 190 | } |
| 191 | + |
| 192 | + } |
207 | 193 | } |
208 | 194 | } |
209 | 195 | }; |
@@ -254,6 +240,10 @@ private void updateReport(final LocalDate dateToShow) { |
254 | 240 |
|
255 | 241 | final long projectWorkSeconds = controller.calcSeconds(onlyCurrentProjectWork); |
256 | 242 |
|
| 243 | + if(project.isWork()){ |
| 244 | + workTime.add(DateFormatter.secondsToHHMMSS(projectWorkSeconds)); |
| 245 | + } |
| 246 | + |
257 | 247 | currentSeconds += projectWorkSeconds; |
258 | 248 | if (project.isWork()) { |
259 | 249 | currentWorkSeconds += projectWorkSeconds; |
|
0 commit comments