|
12 | 12 |
|
13 | 13 | import com.sun.javafx.scene.control.skin.DatePickerSkin; |
14 | 14 |
|
| 15 | +import antlr.debug.Event; |
15 | 16 | import de.doubleslash.keeptime.common.DateFormatter; |
16 | 17 | import de.doubleslash.keeptime.controller.Controller; |
17 | 18 | import de.doubleslash.keeptime.model.Model; |
18 | 19 | import de.doubleslash.keeptime.model.Project; |
19 | 20 | import de.doubleslash.keeptime.model.Work; |
| 21 | +import javafx.event.ActionEvent; |
| 22 | +import javafx.event.EventHandler; |
20 | 23 | import javafx.fxml.FXML; |
21 | 24 | import javafx.scene.Node; |
22 | 25 | import javafx.scene.control.Button; |
23 | 26 | import javafx.scene.control.DateCell; |
24 | 27 | import javafx.scene.control.DatePicker; |
25 | 28 | import javafx.scene.control.Label; |
26 | 29 | import javafx.scene.control.TextArea; |
| 30 | +import javafx.scene.input.Clipboard; |
| 31 | +import javafx.scene.input.ClipboardContent; |
| 32 | +import javafx.scene.input.MouseEvent; |
27 | 33 | import javafx.scene.control.ScrollPane; |
28 | 34 | import javafx.scene.layout.BorderPane; |
29 | 35 | import javafx.scene.layout.GridPane; |
@@ -109,11 +115,15 @@ private void updateReport(final LocalDate newvalue) { |
109 | 115 | this.gridPane.add(workedTimeLabel, 2, rowIndex); |
110 | 116 |
|
111 | 117 | // text will be set later |
| 118 | + /* |
112 | 119 | final TextArea textArea = new TextArea(); |
113 | 120 | textArea.setMaxHeight(20); |
114 | 121 | textArea.setFont(Font.font("System", FontWeight.NORMAL, 15)); |
115 | 122 | textArea.setWrapText(true); |
116 | 123 | this.gridPane.add(textArea, 1, rowIndex); |
| 124 | + */ |
| 125 | + final Button bProjectReport = createProjectReport(); |
| 126 | + this.gridPane.add(bProjectReport, 1, rowIndex); |
117 | 127 |
|
118 | 128 | rowIndex++; |
119 | 129 |
|
@@ -142,14 +152,37 @@ private void updateReport(final LocalDate newvalue) { |
142 | 152 |
|
143 | 153 | rowIndex++; |
144 | 154 | } |
145 | | - textArea.setText(pr.getNotes(true)); |
| 155 | + // textArea.setText(pr.getNotes(true)); |
| 156 | + bProjectReport.setUserData(pr.getNotes(true)); |
146 | 157 | } |
147 | 158 | this.scrollPane.setVvalue(0); // scroll to the top |
148 | 159 |
|
149 | 160 | this.currentDayTimeLabel.setText(DateFormatter.secondsToHHMMSS(currentSeconds)); |
150 | 161 | this.currentDayWorkTimeLabel.setText(DateFormatter.secondsToHHMMSS(currentWorkSeconds)); |
151 | 162 | } |
152 | 163 |
|
| 164 | + private Button createProjectReport() { |
| 165 | + final Button bProjectReport = new Button("Copy to clipboard"); |
| 166 | + final EventHandler<ActionEvent> eventListener = new EventHandler<ActionEvent>() { |
| 167 | + |
| 168 | + @Override |
| 169 | + public void handle(final ActionEvent event) { |
| 170 | + final Object source = event.getSource(); |
| 171 | + final Button btn = (Button) source; |
| 172 | + final Object userData = btn.getUserData(); |
| 173 | + final String notes = (String) userData; |
| 174 | + |
| 175 | + final Clipboard clipboard = Clipboard.getSystemClipboard(); |
| 176 | + final ClipboardContent content = new ClipboardContent(); |
| 177 | + content.putString(notes); |
| 178 | + clipboard.setContent(content); |
| 179 | + } |
| 180 | + |
| 181 | + }; |
| 182 | + bProjectReport.setOnAction(eventListener); |
| 183 | + return bProjectReport; |
| 184 | + } |
| 185 | + |
153 | 186 | public void setModelAndController(final Model model, final Controller controller) { |
154 | 187 | this.model = model; |
155 | 188 | this.controller = controller; |
|
0 commit comments