Skip to content

Commit ce66a79

Browse files
committed
Merge branch 'develop' into feature/dependency_injection
2 parents eb5f80d + 69a4679 commit ce66a79

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

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

245246
registerMinimizeEventlistener(mainScene, primaryStage);
246247
registerMaximizeEventlistener(mainScene, primaryStage);
247-
// Image(Resources.getResource(RESOURCE.ICON_MAIN).toString())); // TODO use an app icon
248248

249249
primaryStage.setTitle("KeepTime");
250250
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
@@ -184,6 +184,27 @@ public void editProject(final Project projectToBeUpdated, final Project newValue
184184
model.getProjectRepository().saveAll(changedProjects);
185185
}
186186

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

299320
return seconds;
300321
}
322+
301323
}

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+
public final ObjectProperty<Boolean> emptyNoteReminder = new SimpleObjectProperty<>(false);
8083

8184
private ConfigurableApplicationContext springContext;
8285

@@ -139,4 +142,9 @@ public void setSpringContext(final ConfigurableApplicationContext springContext)
139142
public ConfigurableApplicationContext getSpringContext() {
140143
return this.springContext;
141144
}
145+
146+
public SortedList<Work> getSortedPastWorkItems() {
147+
return sortedPastWorkItems;
148+
}
149+
142150
}

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)