Skip to content

Commit cc4926a

Browse files
committed
Merge branch 'feature/dependency_injection' into feature/optional_note_reminder
2 parents 842540f + ce66a79 commit cc4926a

File tree

21 files changed

+632
-72
lines changed

21 files changed

+632
-72
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ If you want to contribute please follow this guideline.
66

77
For editing fxml files, use the "JavaFX Scene Builder" in version 8.5.0.
88
Layouting is generally done with fxml files.
9+
10+
For fontawesome support add Libraries
11+
`de.jensd:fontawsomefx-commons:8.15`
12+
`de.jensd:fontawsomefx-fontawsome:4.7.0-5`
13+
to the "JavaFX Scene Builder"
14+
15+
Scene Builder may sometimes delete unicode Charakters when fxml file is changed.
16+
reset Glyph Name to reset uniocode Charakter.

pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@
9393
<version>3.1.1</version>
9494
<type>maven-plugin</type>
9595
</dependency>
96+
97+
<dependency>
98+
<groupId>de.jensd</groupId>
99+
<artifactId>fontawesomefx-commons</artifactId>
100+
<version>8.15</version>
101+
</dependency>
102+
103+
<dependency>
104+
<groupId>de.jensd</groupId>
105+
<artifactId>fontawesomefx-fontawesome</artifactId>
106+
<version>4.7.0-5</version>
107+
</dependency>
96108
</dependencies>
97109

98110
<build>

src/main/java/de/doubleslash/keeptime/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ private void initialiseApplication(final Stage primaryStage) throws Exception {
135135
FontProvider.loadFonts();
136136
readSettings();
137137

138-
final List<Work> todaysWorkItems = model.getWorkRepository().findByCreationDate(LocalDate.now());
138+
final List<Work> todaysWorkItems = model.getWorkRepository()
139+
.findByCreationDateOrderByStartTimeAsc(LocalDate.now());
139140
LOG.info("Found {} past work items", todaysWorkItems.size());
140141
model.getPastWorkItems().addAll(todaysWorkItems);
141142

@@ -245,7 +246,6 @@ private void initialiseUI(final Stage primaryStage) throws IOException {
245246

246247
registerMinimizeEventlistener(mainScene, primaryStage);
247248
registerMaximizeEventlistener(mainScene, primaryStage);
248-
// Image(Resources.getResource(RESOURCE.ICON_MAIN).toString())); // TODO use an app icon
249249

250250
primaryStage.setTitle("KeepTime");
251251
primaryStage.setScene(mainScene);

src/main/java/de/doubleslash/keeptime/common/Resources.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ public enum RESOURCE {
3939
FXML_REPORT("/layouts/report.fxml"),
4040
FXML_ABOUT("/layouts/about.fxml"),
4141
FXML_MANAGE_PROJECT("/layouts/manage-project.fxml"),
42-
43-
// icon
44-
ICON_MAIN("/icons/icon.png"),
42+
FXML_MANAGE_WORK("/layouts/manage-work.fxml"),
4543

4644
;
45+
4746
String resourceLocation;
4847

4948
private RESOURCE(final String resourceLocation) {

src/main/java/de/doubleslash/keeptime/controller/Controller.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,27 @@ public void editProject(final Project projectToBeUpdated, final Project newValue
187187
model.getProjectRepository().saveAll(changedProjects);
188188
}
189189

190+
public void editWork(final Work workToBeEdited, final Work newValuedWork) {
191+
LOG.info("Changing work '{}' to '{}'.", workToBeEdited, newValuedWork);
192+
193+
workToBeEdited.setCreationDate(newValuedWork.getCreationDate());
194+
workToBeEdited.setStartTime(newValuedWork.getStartTime());
195+
workToBeEdited.setEndTime(newValuedWork.getEndTime());
196+
workToBeEdited.setNotes(newValuedWork.getNotes());
197+
workToBeEdited.setProject(newValuedWork.getProject());
198+
199+
final Work editedWork = model.getWorkRepository().save(workToBeEdited);
200+
201+
// remove old
202+
model.getPastWorkItems().removeIf(w -> (w.getId() == workToBeEdited.getId()));
203+
// add if started today
204+
final LocalDate dateNow = dateProvider.dateTimeNow().toLocalDate();
205+
if (dateNow.equals(editedWork.getCreationDate())) {
206+
model.getPastWorkItems().add(editedWork);
207+
}
208+
209+
}
210+
190211
/**
191212
* Changes the indexes of the originalList parameter to have a consistent order.
192213
*
@@ -301,4 +322,5 @@ public long calcSeconds(final List<Work> workItems) {
301322

302323
return seconds;
303324
}
325+
304326
}

src/main/java/de/doubleslash/keeptime/model/Model.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public Model(final ProjectRepository projectRepository, final WorkRepository wor
6464
private ObservableList<Project> allProjects = FXCollections.observableArrayList();
6565

6666
protected final ObservableList<Work> pastWorkItems = FXCollections.observableArrayList();
67+
private final SortedList<Work> sortedPastWorkItems = new SortedList<>(pastWorkItems,
68+
Comparator.comparing(Work::getStartTime));
6769
public final ObjectProperty<Work> activeWorkItem = new SimpleObjectProperty<>();
6870

6971
public final ObjectProperty<Color> taskBarColor = new SimpleObjectProperty<>(ORIGINAL_TASK_BAR_FONT_COLOR);
@@ -77,6 +79,7 @@ public Model(final ProjectRepository projectRepository, final WorkRepository wor
7779
public final ObjectProperty<Boolean> useHotkey = new SimpleObjectProperty<>(false);
7880
public final ObjectProperty<Boolean> displayProjectsRight = new SimpleObjectProperty<>(false);
7981
public final ObjectProperty<Boolean> hideProjectsOnMouseExit = new SimpleObjectProperty<>(true);
82+
8083
public final ObjectProperty<Boolean> remindIfNotesAreEmpty = new SimpleObjectProperty<>(false);
8184

8285
private ConfigurableApplicationContext springContext;
@@ -140,4 +143,9 @@ public void setSpringContext(final ConfigurableApplicationContext springContext)
140143
public ConfigurableApplicationContext getSpringContext() {
141144
return this.springContext;
142145
}
146+
147+
public SortedList<Work> getSortedPastWorkItems() {
148+
return sortedPastWorkItems;
149+
}
150+
143151
}

src/main/java/de/doubleslash/keeptime/model/Work.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class Work {
3636
@Column(name = "id", updatable = false, nullable = false)
3737
private long id;
3838

39+
// TODO revise CreationDate Logic to use Date of StartTime
3940
private LocalDate creationDate;
4041
private LocalDateTime startTime;
4142
private LocalDateTime endTime;
@@ -45,7 +46,8 @@ public class Work {
4546
@Lob
4647
private String notes;
4748

48-
public Work() {}
49+
public Work() {
50+
}
4951

5052
public Work(final LocalDate creationDate, final LocalDateTime startTime, final LocalDateTime endTime,
5153
final Project project, final String notes) {
@@ -89,6 +91,10 @@ public Project getProject() {
8991
return project;
9092
}
9193

94+
public void setProject(final Project project) {
95+
this.project = project;
96+
}
97+
9298
public String getNotes() {
9399
return notes;
94100
}
@@ -97,4 +103,10 @@ public void setNotes(final String notes) {
97103
this.notes = notes;
98104
}
99105

106+
@Override
107+
public String toString() {
108+
return "Work [id=" + id + ", creationDate=" + creationDate + ", startTime=" + startTime + ", endTime=" + endTime
109+
+ ", projectName=" + project.getName() + ", notes=" + notes + "]";
110+
}
111+
100112
}

src/main/java/de/doubleslash/keeptime/model/repos/WorkRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
@Repository
2828
public interface WorkRepository extends JpaRepository<Work, Long> {
2929

30-
List<Work> findByCreationDate(LocalDate creationDate);
30+
List<Work> findByCreationDateOrderByStartTimeAsc(LocalDate creationDate);
3131
}

src/main/java/de/doubleslash/keeptime/view/AboutController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public ObservableList<LicenseTableRow> loadLicenseRows() {
142142
licenseRows.add(new LicenseTableRow("spring-boot-starter-data-jpa", Licenses.APACHEV2));
143143
licenseRows.add(new LicenseTableRow("mockito-core", Licenses.MIT));
144144
licenseRows.add(new LicenseTableRow("h2", Licenses.EPLV1));
145+
licenseRows.add(new LicenseTableRow("fontawesomefx", Licenses.APACHEV2));
145146

146147
licenseRows.sort(Comparator.comparing(LicenseTableRow::getName));
147148

0 commit comments

Comments
 (0)