Skip to content

Commit 6267db3

Browse files
committed
removed not needed call to setDisabled + formatter
1 parent 7817774 commit 6267db3

File tree

1 file changed

+47
-39
lines changed

1 file changed

+47
-39
lines changed

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

Lines changed: 47 additions & 39 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

@@ -198,16 +204,15 @@ private void initialize() {
198204
hideProjectsOnMouseExitCheckBox.setDisable(true);
199205
}
200206

201-
202207
double requiredWidth = 15.0;
203208
double requiredHeight = 15.0;
204209

205-
setRegionSvg(colorIcon,requiredWidth, requiredHeight,RESOURCE.SVG_COLOR_ICON);
206-
setRegionSvg(layoutIcon,requiredWidth, requiredHeight,RESOURCE.SVG_LAYOUT_ICON);
207-
setRegionSvg(generalIcon,requiredWidth,requiredHeight,RESOURCE.SVG_SETTINGS_ICON);
208-
setRegionSvg(aboutIcon,requiredWidth,requiredHeight,RESOURCE.SVG_ABOUT_ICON);
209-
setRegionSvg(importExportIcon,requiredWidth,requiredHeight,RESOURCE.SVG_IMPORT_EXPORT_ICON);
210-
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);
211216

212217
initExportButton();
213218
initImportButton();
@@ -243,9 +248,8 @@ private void initialize() {
243248

244249
alert.showAndWait();
245250
}
246-
if(hideProjectsOnMouseExitCheckBox.isSelected()){
251+
if (hideProjectsOnMouseExitCheckBox.isSelected()) {
247252
hideProjectsOnMouseExitCheckBox.setSelected(false);
248-
hideProjectsOnMouseExitCheckBox.setDisable(true);
249253
}
250254
}
251255

@@ -288,7 +292,7 @@ private void initialize() {
288292

289293
private static void setRegionSvg(Region region, double requiredWidth, double requiredHeight, RESOURCE resource) {
290294

291-
region.setShape(SvgNodeProvider.getSvgNodeWithScale(resource,1.0,1.0));
295+
region.setShape(SvgNodeProvider.getSvgNodeWithScale(resource, 1.0, 1.0));
292296
region.setMinSize(requiredWidth, requiredHeight);
293297
region.setPrefSize(requiredWidth, requiredHeight);
294298
region.setMaxSize(requiredWidth, requiredHeight);
@@ -310,8 +314,8 @@ public void initializeAbout() {
310314

311315
nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
312316

313-
//set SvgPath content
314-
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);
315319

316320
// licenseColumn
317321
final TableColumn<LicenseTableRow, String> licenseColumn = new TableColumn<>("License");
@@ -361,22 +365,24 @@ protected void updateItem(final String item, final boolean empty) {
361365
BrowserHelper.openURL(GITHUB_ISSUE_PAGE);
362366
});
363367
}
364-
private void initImportButton(){
368+
369+
private void initImportButton() {
365370
LOG.debug("Initialize importButton.");
366-
importButton.setOnAction(event ->{
371+
importButton.setOnAction(event -> {
367372

368373
try {
369-
Alert confirmationAlert = new Alert(AlertType.CONFIRMATION , "", ButtonType.YES, ButtonType.NO);
374+
Alert confirmationAlert = new Alert(AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
370375
confirmationAlert.setTitle("Import");
371376
confirmationAlert.setHeaderText("Do you want to Override current Data ?");
372-
confirmationAlert.setContentText("Import previously exported .sql file. This will overwrite the currently used database contents - all current data will be lost!\n" +
373-
"\n" +
374-
"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" +
375-
"\n" +
376-
"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.");
377383
confirmationAlert.showAndWait();
378384

379-
if(confirmationAlert.getResult()==ButtonType.NO){
385+
if (confirmationAlert.getResult() == ButtonType.NO) {
380386
LOG.info("User canceled import");
381387
return;
382388
}
@@ -393,17 +399,19 @@ private void initImportButton(){
393399
final String url = applicationProperties.getSpringDataSourceUrl();
394400
final String username = applicationProperties.getSpringDataSourceUserName();
395401
final String password = applicationProperties.getSpringDataSourcePassword();
396-
//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".
397-
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");
398406

399407
Alert informationDialog = new Alert(AlertType.INFORMATION);
400408
informationDialog.setTitle("Import done");
401409
informationDialog.setHeaderText("The data was imported.");
402-
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");
403412
informationDialog.showAndWait();
404413
Platform.exit();
405414

406-
407415
} catch (SQLException e) {
408416
LOG.error("Could not import script file to db.", e);
409417

@@ -481,7 +489,8 @@ void update() {
481489
hideProjectsOnMouseExitCheckBox.setSelected(model.hideProjectsOnMouseExit.get());
482490
saveWindowPositionCheckBox.setSelected(model.screenSettings.saveWindowPosition.get());
483491
emptyNoteReminderCheckBox.setSelected(model.remindIfNotesAreEmpty.get());
484-
emptyNoteReminderOnlyForWorkEntryCheckBox.disableProperty().bind(emptyNoteReminderCheckBox.selectedProperty().not());
492+
emptyNoteReminderOnlyForWorkEntryCheckBox.disableProperty()
493+
.bind(emptyNoteReminderCheckBox.selectedProperty().not());
485494
emptyNoteReminderOnlyForWorkEntryCheckBox.setSelected(model.remindIfNotesAreEmptyOnlyForWorkEntry.get());
486495
confirmCloseCheckBox.setSelected(model.confirmClose.get());
487496
}
@@ -490,11 +499,10 @@ public void setStage(final Stage thisStage) {
490499
this.thisStage = thisStage;
491500
}
492501

493-
494-
495502
private FXMLLoader createFXMLLoader(final RESOURCE fxmlLayout) {
496503
return new FXMLLoader(Resources.getResource(fxmlLayout));
497504
}
505+
498506
public ObservableList<LicenseTableRow> loadLicenseRows() {
499507
final ObservableList<LicenseTableRow> licenseRows = FXCollections.observableArrayList();
500508
licenseRows.add(new LicenseTableRow("Open Sans", Licenses.APACHEV2));
@@ -518,8 +526,8 @@ private void showLicense(final Licenses license) {
518526
alert.setTitle("Ooops");
519527
alert.setHeaderText("Could not find the license file");
520528
alert.setContentText(String.format(
521-
"We could not find the license file at \"%s\". Did you remove it?%nPlease redownload or visit \"%s\".",
522-
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()));
523531

524532
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
525533

0 commit comments

Comments
 (0)