code cleanup

This commit is contained in:
Jan-Peter Klein
2024-11-14 18:09:23 +01:00
parent 1b522fe9a0
commit af667b10cf
6 changed files with 73 additions and 79 deletions

View File

@@ -149,20 +149,19 @@ public class FxApplicationWindows {
public void showDokanySupportEndWindow() {
CompletableFuture.runAsync(() -> {
customDialog.setOwner(mainWindow.get().window())
.setTitleKey("dokanySupportEnd.title")
.setMessageKey("dokanySupportEnd.message")
.setDescriptionKey("dokanySupportEnd.description")
.setIcon(FontAwesome5Icon.QUESTION)
.setOkButtonKey("generic.button.close")
.setCancelButtonKey("dokanySupportEnd.preferencesBtn")
.setOkAction(Stage::close) //
.setCancelAction(v -> {
showPreferencesWindow(SelectedPreferencesTab.VOLUME);
v.close();
}) //
.build()
.showAndWait();
customDialog.setOwner(mainWindow.get().window()) //
.setTitleKey("dokanySupportEnd.title") //
.setMessageKey("dokanySupportEnd.message") //
.setDescriptionKey("dokanySupportEnd.description") //
.setIcon(FontAwesome5Icon.QUESTION) //
.setOkButtonKey("generic.button.close") //
.setCancelButtonKey("dokanySupportEnd.preferencesBtn") //
.setOkAction(Stage::close) //
.setCancelAction(v -> {
showPreferencesWindow(SelectedPreferencesTab.VOLUME);
v.close();
}) //
.build().showAndWait();
}, Platform::runLater);
}

View File

@@ -51,26 +51,23 @@ public class VaultDetailMissingVaultController implements FxController {
@FXML
void didClickRemoveVault() {
customDialog
.setOwner(window)
.setTitleKey("removeVault.title", vault.get().getDisplayName())
.setMessageKey("removeVault.message")
.setDescriptionKey("removeVault.description")
.setIcon(FontAwesome5Icon.QUESTION)
.setOkButtonKey("removeVault.confirmBtn")
.setCancelButtonKey("generic.button.cancel")
.setOkAction(v -> {
LOG.debug("Removing vault {}.", vault.get().getDisplayName());
vaults.remove(vault.get());
v.close();
}) //
.setCancelAction(Stage::close) //
.build()
.showAndWait();
customDialog.setOwner(window) //
.setTitleKey("removeVault.title", vault.get().getDisplayName()) //
.setMessageKey("removeVault.message") //
.setDescriptionKey("removeVault.description") //
.setIcon(FontAwesome5Icon.QUESTION) //
.setOkButtonKey("removeVault.confirmBtn") //
.setCancelButtonKey("generic.button.cancel") //
.setOkAction(v -> {
LOG.debug("Removing vault {}.", vault.get().getDisplayName());
vaults.remove(vault.get());
v.close();
}) //
.setCancelAction(Stage::close) //
.build().showAndWait();
;
}
@FXML
void changeLocation() {
// copied from ChooseExistingVaultController class

View File

@@ -29,8 +29,9 @@ public class VaultDetailUnknownErrorController implements FxController {
private final CustomDialog.Builder customDialog;
@Inject
public VaultDetailUnknownErrorController(@MainWindow Stage mainWindow,
ObjectProperty<Vault> vault, ObservableList<Vault> vaults, //
public VaultDetailUnknownErrorController(@MainWindow Stage mainWindow, //
ObjectProperty<Vault> vault, //
ObservableList<Vault> vaults, //
FxApplicationWindows appWindows, //
@Named("errorWindow") Stage errorWindow, //
CustomDialog.Builder customDialog) {
@@ -54,22 +55,19 @@ public class VaultDetailUnknownErrorController implements FxController {
@FXML
void didClickRemoveVault() {
customDialog
.setOwner(mainWindow)
.setTitleKey("removeVault.title", vault.get().getDisplayName())
.setMessageKey("removeVault.message")
.setDescriptionKey("removeVault.description")
.setIcon(FontAwesome5Icon.QUESTION)
.setOkButtonKey("removeVault.confirmBtn")
.setCancelButtonKey("generic.button.cancel")
customDialog.setOwner(mainWindow) //
.setTitleKey("removeVault.title", vault.get().getDisplayName()) //
.setMessageKey("removeVault.message") //
.setDescriptionKey("removeVault.description") //
.setIcon(FontAwesome5Icon.QUESTION) //
.setOkButtonKey("removeVault.confirmBtn") //
.setCancelButtonKey("generic.button.cancel") //
.setOkAction(v -> {
LOG.debug("Removing vault {}.", vault.get().getDisplayName());
vaults.remove(vault.get());
v.close();
}) //
.setCancelAction(Stage::close) //
.build()
.showAndWait();
.build().showAndWait();
}
}

View File

@@ -82,20 +82,19 @@ public class VaultListContextMenuController implements FxController {
@FXML
public void didClickRemoveVault() {
var vault = Objects.requireNonNull(selectedVault.get());
customDialog.setOwner(mainWindow)
.setTitleKey("removeVault.title", vault.getDisplayName())
.setMessageKey("removeVault.message")
.setDescriptionKey("removeVault.description")
.setIcon(FontAwesome5Icon.QUESTION)
.setOkButtonKey("removeVault.confirmBtn")
.setCancelButtonKey("generic.button.cancel")
customDialog.setOwner(mainWindow) //
.setTitleKey("removeVault.title", vault.getDisplayName()) //
.setMessageKey("removeVault.message") //
.setDescriptionKey("removeVault.description") //
.setIcon(FontAwesome5Icon.QUESTION) //
.setOkButtonKey("removeVault.confirmBtn") //
.setCancelButtonKey("generic.button.cancel") //
.setOkAction(v -> {
LOG.debug("Removing vault {}.", vault.getDisplayName());
vaults.remove(vault);
v.close();
}) //
.build()
.showAndWait();
.build().showAndWait();
}
@FXML

View File

@@ -91,7 +91,7 @@ public class VaultListController implements FxController {
VaultListManager vaultListManager, //
ResourceBundle resourceBundle, //
FxApplicationWindows appWindows, //
Settings settings,
Settings settings, //
CustomDialog.Builder customDialog) {
this.mainWindow = mainWindow;
this.vaults = vaults;
@@ -210,21 +210,20 @@ public class VaultListController implements FxController {
private void pressedShortcutToRemoveVault() {
final var vault = selectedVault.get();
if (vault != null && EnumSet.of(LOCKED, MISSING, ERROR, NEEDS_MIGRATION).contains(vault.getState())) {
customDialog.setOwner(mainWindow)
.setTitleKey("removeVault.title", vault.getDisplayName())
.setMessageKey("removeVault.message")
.setDescriptionKey("removeVault.description")
.setIcon(FontAwesome5Icon.QUESTION)
.setOkButtonKey("removeVault.confirmBtn")
.setCancelButtonKey("generic.button.cancel")
.setOkAction(v -> {
LOG.debug("Removing vault {}.", vault.getDisplayName());
vaults.remove(vault);
v.close();
}) //
.setCancelAction(Stage::close) //
.build()
.showAndWait();
customDialog.setOwner(mainWindow) //
.setTitleKey("removeVault.title", vault.getDisplayName()) //
.setMessageKey("removeVault.message") //
.setDescriptionKey("removeVault.description") //
.setIcon(FontAwesome5Icon.QUESTION) //
.setOkButtonKey("removeVault.confirmBtn") //
.setCancelButtonKey("generic.button.cancel") //
.setOkAction(v -> {
LOG.debug("Removing vault {}.", vault.getDisplayName());
vaults.remove(vault);
v.close();
}) //
.setCancelAction(Stage::close) //
.build().showAndWait();
}
}

View File

@@ -33,7 +33,11 @@ public class SupporterCertificateController implements FxController {
private TextArea supporterCertificateField;
@Inject
SupporterCertificateController(Application application, @PreferencesWindow Stage window, LicenseHolder licenseHolder, Settings settings, CustomDialog.Builder customDialog) {
SupporterCertificateController(Application application, //
@PreferencesWindow Stage window, //
LicenseHolder licenseHolder, //
Settings settings, //
CustomDialog.Builder customDialog) {
this.application = application;
this.window = window;
this.licenseHolder = licenseHolder;
@@ -85,21 +89,19 @@ public class SupporterCertificateController implements FxController {
@FXML
void didClickRemoveCert() {
customDialog.setOwner(window)
.setTitleKey("removeCert.title")
.setMessageKey("removeCert.message")
.setDescriptionKey("removeCert.description")
.setIcon(FontAwesome5Icon.QUESTION)
.setOkButtonKey("removeCert.confirmBtn")
customDialog.setOwner(window) //
.setTitleKey("removeCert.title") //
.setMessageKey("removeCert.message") //
.setDescriptionKey("removeCert.description") //
.setIcon(FontAwesome5Icon.QUESTION) //
.setOkButtonKey("removeCert.confirmBtn") //
.setCancelButtonKey("generic.button.cancel")
.setOkAction(v -> {
settings.licenseKey.set(null);
v.close();
}) //
.setCancelAction(Stage::close) //
.build()
.showAndWait();
.build().showAndWait();
}
public LicenseHolder getLicenseHolder() {