Skip to content

Commit aeac24e

Browse files
committed
added Reminder Alert if no notes are present
1 parent eb5f80d commit aeac24e

File tree

7 files changed

+72
-4
lines changed

7 files changed

+72
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ private void readSettings() {
198198
model.useHotkey.set(settings.isUseHotkey());
199199
model.displayProjectsRight.set(settings.isDisplayProjectsRight());
200200
model.hideProjectsOnMouseExit.set(settings.isHideProjectsOnMouseExit());
201+
model.emptyNoteReminder.set(settings.isEmptyNoteReminder());
201202
}
202203

203204
private void initialisePopupUI(final Stage primaryStage) throws IOException {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public void addNewProject(final Project project) {
104104

105105
public void updateSettings(final Color hoverBackgroundColor, final Color hoverFontColor,
106106
final Color defaultBackgroundColor, final Color defaultFontColor, final Color taskBarColor,
107-
final boolean useHotkey, final boolean displayProjectsRight, final boolean hideProjectsOnMouseExit) {
107+
final boolean useHotkey, final boolean displayProjectsRight, final boolean hideProjectsOnMouseExit,
108+
final boolean emptyNoteReminder) {
108109
// TODO create holder for all the properties (or reuse Settings.class?)
109110
final Settings settings = model.getSettingsRepository().findAll().get(0);
110111
settings.setTaskBarColor(taskBarColor);
@@ -117,6 +118,7 @@ public void updateSettings(final Color hoverBackgroundColor, final Color hoverFo
117118
settings.setUseHotkey(useHotkey);
118119
settings.setDisplayProjectsRight(displayProjectsRight);
119120
settings.setHideProjectsOnMouseExit(hideProjectsOnMouseExit);
121+
settings.setEmptyNoteReminder(emptyNoteReminder);
120122

121123
model.getSettingsRepository().save(settings);
122124

@@ -128,6 +130,7 @@ public void updateSettings(final Color hoverBackgroundColor, final Color hoverFo
128130
model.useHotkey.set(settings.isUseHotkey());
129131
model.displayProjectsRight.set(settings.isDisplayProjectsRight());
130132
model.hideProjectsOnMouseExit.set(settings.isHideProjectsOnMouseExit());
133+
model.emptyNoteReminder.set(settings.isEmptyNoteReminder());
131134
}
132135

133136
@PreDestroy

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public Model(final ProjectRepository projectRepository, final WorkRepository wor
7777
public final ObjectProperty<Boolean> useHotkey = new SimpleObjectProperty<>(false);
7878
public final ObjectProperty<Boolean> displayProjectsRight = new SimpleObjectProperty<>(false);
7979
public final ObjectProperty<Boolean> hideProjectsOnMouseExit = new SimpleObjectProperty<>(true);
80+
public final ObjectProperty<Boolean> emptyNoteReminder = new SimpleObjectProperty<>(false);
8081

8182
private ConfigurableApplicationContext springContext;
8283

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public class Settings {
5959

6060
private boolean hideProjectsOnMouseExit;
6161

62+
private boolean emptyNoteReminder;
63+
6264
public long getId() {
6365
return id;
6466
}
@@ -127,4 +129,12 @@ public void setHideProjectsOnMouseExit(final boolean hideProjectsOnMouseExit) {
127129
this.hideProjectsOnMouseExit = hideProjectsOnMouseExit;
128130
}
129131

132+
public boolean isEmptyNoteReminder() {
133+
return emptyNoteReminder;
134+
}
135+
136+
public void setEmptyNoteReminder(final boolean emptyNoteReminder) {
137+
this.emptyNoteReminder = emptyNoteReminder;
138+
}
139+
130140
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import de.doubleslash.keeptime.exceptions.FXMLLoaderException;
3535
import de.doubleslash.keeptime.model.Model;
3636
import de.doubleslash.keeptime.model.Project;
37+
import de.doubleslash.keeptime.model.Work;
3738
import javafx.collections.transformation.FilteredList;
3839
import javafx.fxml.FXMLLoader;
3940
import javafx.scene.Node;
@@ -165,7 +166,25 @@ private void changeProject(final Project newProject, final long minusSeconds) {
165166
if (hideable) {
166167
mainStage.hide();
167168
}
169+
if (model.emptyNoteReminder.get()) {
170+
final Work currentWork = model.activeWorkItem.get();
171+
if (currentWork != null && currentWork.getNotes().isEmpty()) {
172+
final Alert alert = new Alert(AlertType.CONFIRMATION);
173+
alert.setTitle("Empty Notes");
174+
alert.setHeaderText(
175+
"You are About to switch Projects but your current work has no Notes associated with it.");
176+
alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO);
177+
alert.setContentText("Do you want to switch nevertheless?");
178+
alert.initOwner(mainStage);
179+
180+
final Optional<ButtonType> result = alert.showAndWait();
181+
if (result.get() == ButtonType.NO) {
182+
return;
183+
}
184+
}
185+
}
168186
controller.changeProject(newProject, minusSeconds);
187+
169188
}
170189

171190
private void addProjectToProjectSelectionNodeMap(final Project project) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public class SettingsController {
7979
@FXML
8080
private CheckBox hideProjectsOnMouseExitCheckBox;
8181

82+
@FXML
83+
private CheckBox emptyNoteReminderCheeckBox;
84+
8285
@FXML
8386
private Button saveButton;
8487

@@ -173,7 +176,7 @@ private void initialize() {
173176
controller.updateSettings(hoverBackgroundColor.getValue(), hoverFontColor.getValue(),
174177
defaultBackgroundColor.getValue(), defaultFontColor.getValue(), taskBarColor.getValue(),
175178
useHotkeyCheckBox.isSelected(), displayProjectsRightCheckBox.isSelected(),
176-
hideProjectsOnMouseExitCheckBox.isSelected());
179+
hideProjectsOnMouseExitCheckBox.isSelected(), emptyNoteReminderCheeckBox.isSelected());
177180
thisStage.close();
178181

179182
});
@@ -193,7 +196,7 @@ private void initialize() {
193196
resetDefaultFontButton.setOnAction(ae -> defaultFontColor.setValue(Model.ORIGINAL_DEFAULT_FONT_COLOR));
194197
resetTaskBarFontButton.setOnAction(ae -> taskBarColor.setValue(Model.ORIGINAL_TASK_BAR_FONT_COLOR));
195198

196-
LOG.debug("reportBugButton.setOnAction");
199+
LOG.debug("aboutButton.setOnAction");
197200
aboutButton.setOnAction(ae -> {
198201
LOG.info("About clicked");
199202
aboutStage.show();
@@ -215,6 +218,7 @@ void update() {
215218
useHotkeyCheckBox.setSelected(model.useHotkey.get());
216219
displayProjectsRightCheckBox.setSelected(model.displayProjectsRight.get());
217220
hideProjectsOnMouseExitCheckBox.setSelected(model.hideProjectsOnMouseExit.get());
221+
emptyNoteReminderCheeckBox.setSelected(model.emptyNoteReminder.get());
218222
}
219223

220224
public void setStage(final Stage thisStage) {

src/main/resources/layouts/settings.fxml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<?import javafx.scene.layout.VBox?>
2929
<?import javafx.scene.text.Font?>
3030

31-
<AnchorPane fx:id="settingsRoot" focusTraversable="true" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.SettingsController">
31+
<AnchorPane fx:id="settingsRoot" focusTraversable="true" xmlns="http://javafx.com/javafx/8.0.202-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.SettingsController">
3232
<children>
3333
<VBox spacing="10.0" stylesheets="@../css/menu.css">
3434
<children>
@@ -224,6 +224,36 @@
224224
</Group>
225225
</children>
226226
</VBox>
227+
<VBox styleClass="menuBorder">
228+
<children>
229+
<Group>
230+
<children>
231+
<VBox>
232+
<children>
233+
<HBox spacing="10.0">
234+
<children>
235+
<Label fx:id="hotkeyLabel1" text="Note Reminder">
236+
<font>
237+
<Font name="Open Sans Bold" size="12.0" />
238+
</font>
239+
</Label>
240+
</children>
241+
</HBox>
242+
<HBox spacing="10.0">
243+
<children>
244+
<CheckBox fx:id="emptyNoteReminderCheeckBox" mnemonicParsing="false" text="remind me when switching Projects without Notes" wrapText="true" HBox.hgrow="NEVER">
245+
<font>
246+
<Font name="Open Sans Regular" size="12.0" />
247+
</font>
248+
</CheckBox>
249+
</children>
250+
</HBox>
251+
</children>
252+
</VBox>
253+
</children>
254+
</Group>
255+
</children>
256+
</VBox>
227257
<HBox spacing="10.0">
228258
<children>
229259
<Button fx:id="saveButton" mnemonicParsing="false" text="Save">

0 commit comments

Comments
 (0)