Skip to content

Commit 569103c

Browse files
authored
Merge pull request #113 from DavidDamke/bug/Hide_Projects_not_Supported_on_linux_disable_option
Bug/hide projects not supported on linux
2 parents 46abbe7 + 6267db3 commit 569103c

File tree

1 file changed

+48
-45
lines changed

1 file changed

+48
-45
lines changed

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

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@
2121
import java.sql.SQLException;
2222
import java.util.Comparator;
2323

24-
import de.doubleslash.keeptime.common.*;
25-
import de.doubleslash.keeptime.view.license.LicenseTableRow;
26-
import javafx.collections.FXCollections;
27-
import javafx.collections.ObservableList;
28-
import javafx.application.Platform;
29-
import javafx.scene.control.*;
30-
import javafx.scene.control.cell.PropertyValueFactory;
31-
import javafx.scene.input.MouseButton;
3224
import org.h2.tools.RunScript;
3325
import org.h2.tools.Script;
3426
import org.slf4j.Logger;
@@ -37,20 +29,35 @@
3729
import org.springframework.stereotype.Component;
3830

3931
import de.doubleslash.keeptime.ApplicationProperties;
32+
import de.doubleslash.keeptime.common.BrowserHelper;
33+
import de.doubleslash.keeptime.common.FileOpenHelper;
34+
import de.doubleslash.keeptime.common.Licenses;
4035
import de.doubleslash.keeptime.common.OS;
4136
import de.doubleslash.keeptime.common.Resources;
4237
import de.doubleslash.keeptime.common.Resources.RESOURCE;
38+
import de.doubleslash.keeptime.common.SvgNodeProvider;
4339
import de.doubleslash.keeptime.controller.Controller;
4440
import de.doubleslash.keeptime.model.Model;
4541
import de.doubleslash.keeptime.model.Settings;
42+
import de.doubleslash.keeptime.view.license.LicenseTableRow;
43+
import javafx.application.Platform;
44+
import javafx.collections.FXCollections;
45+
import javafx.collections.ObservableList;
4646
import javafx.fxml.FXML;
4747
import javafx.fxml.FXMLLoader;
4848
import javafx.scene.control.Alert;
4949
import javafx.scene.control.Alert.AlertType;
5050
import javafx.scene.control.Button;
51+
import javafx.scene.control.ButtonType;
5152
import javafx.scene.control.CheckBox;
5253
import javafx.scene.control.ColorPicker;
54+
import javafx.scene.control.Hyperlink;
5355
import javafx.scene.control.Label;
56+
import javafx.scene.control.TableCell;
57+
import javafx.scene.control.TableColumn;
58+
import javafx.scene.control.TableView;
59+
import javafx.scene.control.cell.PropertyValueFactory;
60+
import javafx.scene.input.MouseButton;
5461
import javafx.scene.layout.AnchorPane;
5562
import javafx.scene.layout.Region;
5663
import javafx.scene.paint.Color;
@@ -170,7 +177,6 @@ public class SettingsController {
170177

171178
private Stage thisStage;
172179

173-
174180
@Autowired
175181
ViewController mainscreen;
176182

@@ -195,18 +201,18 @@ private void initialize() {
195201
useHotkeyCheckBox.setDisable(true);
196202
hotkeyLabel.setDisable(true);
197203
globalKeyloggerLabel.setDisable(true);
204+
hideProjectsOnMouseExitCheckBox.setDisable(true);
198205
}
199206

200-
201207
double requiredWidth = 15.0;
202208
double requiredHeight = 15.0;
203209

204-
setRegionSvg(colorIcon,requiredWidth, requiredHeight,RESOURCE.SVG_COLOR_ICON);
205-
setRegionSvg(layoutIcon,requiredWidth, requiredHeight,RESOURCE.SVG_LAYOUT_ICON);
206-
setRegionSvg(generalIcon,requiredWidth,requiredHeight,RESOURCE.SVG_SETTINGS_ICON);
207-
setRegionSvg(aboutIcon,requiredWidth,requiredHeight,RESOURCE.SVG_ABOUT_ICON);
208-
setRegionSvg(importExportIcon,requiredWidth,requiredHeight,RESOURCE.SVG_IMPORT_EXPORT_ICON);
209-
setRegionSvg(licensesIcon,requiredWidth,requiredHeight,RESOURCE.SVG_LICENSES_ICON);
210+
setRegionSvg(colorIcon, requiredWidth, requiredHeight, RESOURCE.SVG_COLOR_ICON);
211+
setRegionSvg(layoutIcon, requiredWidth, requiredHeight, RESOURCE.SVG_LAYOUT_ICON);
212+
setRegionSvg(generalIcon, requiredWidth, requiredHeight, RESOURCE.SVG_SETTINGS_ICON);
213+
setRegionSvg(aboutIcon, requiredWidth, requiredHeight, RESOURCE.SVG_ABOUT_ICON);
214+
setRegionSvg(importExportIcon, requiredWidth, requiredHeight, RESOURCE.SVG_IMPORT_EXPORT_ICON);
215+
setRegionSvg(licensesIcon, requiredWidth, requiredHeight, RESOURCE.SVG_LICENSES_ICON);
210216

211217
initExportButton();
212218
initImportButton();
@@ -242,15 +248,8 @@ private void initialize() {
242248

243249
alert.showAndWait();
244250
}
245-
if (!displayProjectsRightCheckBox.isSelected() && hideProjectsOnMouseExitCheckBox.isSelected()) {
251+
if (hideProjectsOnMouseExitCheckBox.isSelected()) {
246252
hideProjectsOnMouseExitCheckBox.setSelected(false);
247-
final Alert warning = new Alert(AlertType.WARNING);
248-
warning.setTitle("Warning!");
249-
warning.setHeaderText("No Linux Support");
250-
warning.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
251-
warning.setContentText(
252-
"The project list on the left side has no Linux support if projects should be hidden. Disabling hiding of project list.");
253-
warning.showAndWait();
254253
}
255254
}
256255

@@ -293,7 +292,7 @@ private void initialize() {
293292

294293
private static void setRegionSvg(Region region, double requiredWidth, double requiredHeight, RESOURCE resource) {
295294

296-
region.setShape(SvgNodeProvider.getSvgNodeWithScale(resource,1.0,1.0));
295+
region.setShape(SvgNodeProvider.getSvgNodeWithScale(resource, 1.0, 1.0));
297296
region.setMinSize(requiredWidth, requiredHeight);
298297
region.setPrefSize(requiredWidth, requiredHeight);
299298
region.setMaxSize(requiredWidth, requiredHeight);
@@ -315,8 +314,8 @@ public void initializeAbout() {
315314

316315
nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
317316

318-
//set SvgPath content
319-
setRegionSvg(bugIcon,20.0 ,20.0 , RESOURCE.SVG_BUG_ICON);
317+
// set SvgPath content
318+
setRegionSvg(bugIcon, 20.0, 20.0, RESOURCE.SVG_BUG_ICON);
320319

321320
// licenseColumn
322321
final TableColumn<LicenseTableRow, String> licenseColumn = new TableColumn<>("License");
@@ -366,22 +365,24 @@ protected void updateItem(final String item, final boolean empty) {
366365
BrowserHelper.openURL(GITHUB_ISSUE_PAGE);
367366
});
368367
}
369-
private void initImportButton(){
368+
369+
private void initImportButton() {
370370
LOG.debug("Initialize importButton.");
371-
importButton.setOnAction(event ->{
371+
importButton.setOnAction(event -> {
372372

373373
try {
374-
Alert confirmationAlert = new Alert(AlertType.CONFIRMATION , "", ButtonType.YES, ButtonType.NO);
374+
Alert confirmationAlert = new Alert(AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
375375
confirmationAlert.setTitle("Import");
376376
confirmationAlert.setHeaderText("Do you want to Override current Data ?");
377-
confirmationAlert.setContentText("Import previously exported .sql file. This will overwrite the currently used database contents - all current data will be lost!\n" +
378-
"\n" +
379-
"If you do not have a .sql file yet you need to open the previous version of KeepTime and in the settings dialog press \"Export\".\n" +
380-
"\n" +
381-
"You will need to restart the application after this action. If you proceed you need to select the previouls exported .sql file.");
377+
confirmationAlert.setContentText(
378+
"Import previously exported .sql file. This will overwrite the currently used database contents - all current data will be lost!\n"
379+
+ "\n"
380+
+ "If you do not have a .sql file yet you need to open the previous version of KeepTime and in the settings dialog press \"Export\".\n"
381+
+ "\n"
382+
+ "You will need to restart the application after this action. If you proceed you need to select the previouls exported .sql file.");
382383
confirmationAlert.showAndWait();
383384

384-
if(confirmationAlert.getResult()==ButtonType.NO){
385+
if (confirmationAlert.getResult() == ButtonType.NO) {
385386
LOG.info("User canceled import");
386387
return;
387388
}
@@ -398,17 +399,19 @@ private void initImportButton(){
398399
final String url = applicationProperties.getSpringDataSourceUrl();
399400
final String username = applicationProperties.getSpringDataSourceUserName();
400401
final String password = applicationProperties.getSpringDataSourcePassword();
401-
//TODO: add an option at the next release to make the "FROM_1X flag" configurable. E.g. if we upgrade (in the release after) from H2 version 2.x to 2.x we must not set the "FROM_1X flag".
402-
new RunScript().runTool("-url", url, "-user",username,"-password",password,"-script",file.toString(),"-options", "FROM_1X");
402+
// TODO: add an option at the next release to make the "FROM_1X flag" configurable. E.g. if we upgrade (in
403+
// the release after) from H2 version 2.x to 2.x we must not set the "FROM_1X flag".
404+
new RunScript().runTool("-url", url, "-user", username, "-password", password, "-script", file.toString(),
405+
"-options", "FROM_1X");
403406

404407
Alert informationDialog = new Alert(AlertType.INFORMATION);
405408
informationDialog.setTitle("Import done");
406409
informationDialog.setHeaderText("The data was imported.");
407-
informationDialog.setContentText("KeepTime will now be CLOSED! You have to RESTART it again to see the changes");
410+
informationDialog.setContentText(
411+
"KeepTime will now be CLOSED! You have to RESTART it again to see the changes");
408412
informationDialog.showAndWait();
409413
Platform.exit();
410414

411-
412415
} catch (SQLException e) {
413416
LOG.error("Could not import script file to db.", e);
414417

@@ -486,7 +489,8 @@ void update() {
486489
hideProjectsOnMouseExitCheckBox.setSelected(model.hideProjectsOnMouseExit.get());
487490
saveWindowPositionCheckBox.setSelected(model.screenSettings.saveWindowPosition.get());
488491
emptyNoteReminderCheckBox.setSelected(model.remindIfNotesAreEmpty.get());
489-
emptyNoteReminderOnlyForWorkEntryCheckBox.disableProperty().bind(emptyNoteReminderCheckBox.selectedProperty().not());
492+
emptyNoteReminderOnlyForWorkEntryCheckBox.disableProperty()
493+
.bind(emptyNoteReminderCheckBox.selectedProperty().not());
490494
emptyNoteReminderOnlyForWorkEntryCheckBox.setSelected(model.remindIfNotesAreEmptyOnlyForWorkEntry.get());
491495
confirmCloseCheckBox.setSelected(model.confirmClose.get());
492496
}
@@ -495,11 +499,10 @@ public void setStage(final Stage thisStage) {
495499
this.thisStage = thisStage;
496500
}
497501

498-
499-
500502
private FXMLLoader createFXMLLoader(final RESOURCE fxmlLayout) {
501503
return new FXMLLoader(Resources.getResource(fxmlLayout));
502504
}
505+
503506
public ObservableList<LicenseTableRow> loadLicenseRows() {
504507
final ObservableList<LicenseTableRow> licenseRows = FXCollections.observableArrayList();
505508
licenseRows.add(new LicenseTableRow("Open Sans", Licenses.APACHEV2));
@@ -523,8 +526,8 @@ private void showLicense(final Licenses license) {
523526
alert.setTitle("Ooops");
524527
alert.setHeaderText("Could not find the license file");
525528
alert.setContentText(String.format(
526-
"We could not find the license file at \"%s\". Did you remove it?%nPlease redownload or visit \"%s\".",
527-
license.getPath(), license.getUrl()));
529+
"We could not find the license file at \"%s\". Did you remove it?%nPlease redownload or visit \"%s\".",
530+
license.getPath(), license.getUrl()));
528531

529532
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
530533

0 commit comments

Comments
 (0)