Skip to content

Commit 37cd8c4

Browse files
ddamkeddamke
authored andcommitted
code review changes
1 parent b5ca8f6 commit 37cd8c4

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private void readSettings() {
209209
model.screenSettings.screenHash.set(settings.getScreenHash());
210210
model.screenSettings.saveWindowPosition.set(settings.isSaveWindowPosition());
211211
model.remindIfNotesAreEmpty.set(settings.isRemindIfNotesAreEmpty());
212-
model.remindIfNotesAreEmptyOnlyForWorkEntry.set(settings.isEmptyNoteReminderIsWork());
212+
model.remindIfNotesAreEmptyOnlyForWorkEntry.set(settings.isRemindIfNotesAreEmptyOnlyForWorkEntry());
213213

214214
}
215215

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void updateSettings(final Settings newValuedSettings) {
131131
settings.setWindowYProportion(newValuedSettings.getWindowYProportion());
132132
settings.setScreenHash(newValuedSettings.getScreenHash());
133133
settings.setRemindIfNotesAreEmpty(newValuedSettings.isRemindIfNotesAreEmpty());
134-
settings.setEmptyNoteReminderIsWork(newValuedSettings.isEmptyNoteReminderIsWork());
134+
settings.setRemindIfNotesAreEmptyOnlyForWorkEntry(newValuedSettings.isRemindIfNotesAreEmptyOnlyForWorkEntry());
135135

136136
settings = model.getSettingsRepository().save(settings);
137137

@@ -148,7 +148,7 @@ public void updateSettings(final Settings newValuedSettings) {
148148
model.screenSettings.proportionalY.set(settings.getWindowYProportion());
149149
model.screenSettings.screenHash.set(settings.getScreenHash());
150150
model.remindIfNotesAreEmpty.set(settings.isRemindIfNotesAreEmpty());
151-
model.remindIfNotesAreEmptyOnlyForWorkEntry.set(settings.isEmptyNoteReminderIsWork());
151+
model.remindIfNotesAreEmptyOnlyForWorkEntry.set(settings.isRemindIfNotesAreEmptyOnlyForWorkEntry());
152152
}
153153

154154
@PreDestroy

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ public class Settings {
6969

7070
private boolean remindIfNotesAreEmpty;
7171

72-
private boolean emptyNoteReminderIsWork;
72+
private boolean remindIfNotesAreEmptyOnlyForWorkEntry;
7373
public Settings() {
7474
}
7575

7676
public Settings(final Color hoverBackgroundColor, final Color hoverFontColor, final Color defaultBackgroundColor,
7777
final Color defaultFontColor, final Color taskBarColor, final boolean useHotkey,
7878
final boolean displayProjectsRight, final boolean hideProjectsOnMouseExit, final double windowPositionX,
7979
final double windowPositionY, final int screenHash, final boolean saveWindowPosition,
80-
final boolean remindIfNotesAreEmpty, final boolean emptyNoteReminderIsWork) {
80+
final boolean remindIfNotesAreEmpty, final boolean remindIfNotesAreEmptyOnlyForWorkEntry) {
8181
this.hoverBackgroundColor = hoverBackgroundColor;
8282
this.hoverFontColor = hoverFontColor;
8383
this.defaultBackgroundColor = defaultBackgroundColor;
@@ -91,16 +91,16 @@ public Settings(final Color hoverBackgroundColor, final Color hoverFontColor, fi
9191
this.windowScreenhash = screenHash;
9292
this.saveWindowPosition = saveWindowPosition;
9393
this.remindIfNotesAreEmpty = remindIfNotesAreEmpty;
94-
this.emptyNoteReminderIsWork = emptyNoteReminderIsWork;
94+
this.remindIfNotesAreEmptyOnlyForWorkEntry = remindIfNotesAreEmptyOnlyForWorkEntry;
9595

9696
}
9797

98-
public boolean isEmptyNoteReminderIsWork() {
99-
return emptyNoteReminderIsWork;
98+
public boolean isRemindIfNotesAreEmptyOnlyForWorkEntry() {
99+
return remindIfNotesAreEmptyOnlyForWorkEntry;
100100
}
101101

102-
public void setEmptyNoteReminderIsWork(boolean emptyNoteReminderCheckBoxIsWork) {
103-
this.emptyNoteReminderIsWork = emptyNoteReminderCheckBoxIsWork;
102+
public void setRemindIfNotesAreEmptyOnlyForWorkEntry(boolean emptyNoteReminderCheckBoxIsWork) {
103+
this.remindIfNotesAreEmptyOnlyForWorkEntry = emptyNoteReminderCheckBoxIsWork;
104104
}
105105

106106
public long getId() {

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,31 +168,32 @@ private void changeProject(final Project newProject, final long minusSeconds) {
168168
mainStage.hide();
169169
}
170170
final Work currentWork = model.activeWorkItem.get();
171-
if (model.remindIfNotesAreEmpty.get() && currentWork.getNotes().isEmpty()) {
171+
if (model.remindIfNotesAreEmpty.get() && currentWork != null && currentWork.getNotes().isEmpty()) {
172172

173-
if (currentWork != null && (!model.remindIfNotesAreEmptyOnlyForWorkEntry.get() || currentWork.getProject().isWork())) {
174-
if (showDialogNoNoteSelected(currentWork)) return;
173+
if ( !model.remindIfNotesAreEmptyOnlyForWorkEntry.get() || currentWork.getProject().isWork()) {
174+
Optional<String> result = showDialogNoNoteSelected(currentWork);
175+
if (result.isPresent()){
176+
currentWork.setNotes(result.get());
177+
}
178+
else{
179+
//cancel pressed
180+
return;
181+
}
175182
}
176183
}
177184
controller.changeProject(newProject, minusSeconds);
178185
}
179186

180-
private boolean showDialogNoNoteSelected(Work currentWork) {
187+
private Optional showDialogNoNoteSelected(Work currentWork) {
181188
final TextInputDialog noteDialog = new TextInputDialog();
182189
noteDialog.setTitle("Empty Notes");
183190
noteDialog.setHeaderText("Switch projects without notes?");
184191
noteDialog.setContentText(
185-
"What did you do for project '" + model.activeWorkItem.get().getProject().getName() + "' ?");
192+
"What did you do for project '" + currentWork.getProject().getName() + "' ?");
186193
noteDialog.initOwner(mainStage);
187194

188195
final Optional<String> result = noteDialog.showAndWait();
189-
if (result.isPresent()) {
190-
currentWork.setNotes(result.get());
191-
} else {
192-
// cancel pressed
193-
return true;
194-
}
195-
return false;
196+
return result;
196197
}
197198

198199
private void addProjectToProjectSelectionNodeMap(final Project project) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ALTER TABLE settings
2-
ADD COLUMN empty_note_reminder_is_work BOOLEAN NOT NULL DEFAULT(false)
2+
ADD COLUMN remind_if_notes_are_empty_only_for_work_entry BOOLEAN NOT NULL DEFAULT(false)

0 commit comments

Comments
 (0)