upgrade to jdk20

* use pattern matching preview feature
* bump fuse-nio-adapter
This commit is contained in:
Armin Schrenk
2023-05-08 19:12:35 +02:00
parent 532ffb1202
commit 151ef6c7b2
6 changed files with 40 additions and 35 deletions

View File

@@ -5,10 +5,10 @@ import java.util.List;
public interface IpcMessageListener {
default void handleMessage(IpcMessage message) {
if (message instanceof RevealRunningAppMessage) {
revealRunningApp();
} else if (message instanceof HandleLaunchArgsMessage m) {
handleLaunchArgs(m.args());
switch (message) {
case RevealRunningAppMessage x -> revealRunningApp();
case HandleLaunchArgsMessage hlam -> handleLaunchArgs(hlam.args());
default -> {}
}
}

View File

@@ -102,14 +102,16 @@ public class StartController implements FxController {
}
private void loadingKeyFailed(Throwable e) {
if (e instanceof UnlockCancelledException) {
// ok
} else if (e instanceof VaultKeyInvalidException) {
LOG.error("Invalid key"); //TODO: specific error screen
appWindows.showErrorWindow(e, window, null);
} else {
LOG.error("Failed to load key.", e);
appWindows.showErrorWindow(e, window, null);
switch (e) {
case UnlockCancelledException uce -> {} //ok
case VaultKeyInvalidException vkie -> {
LOG.error("Invalid key"); //TODO: specific error screen
appWindows.showErrorWindow(e, window, null);
}
default -> {
LOG.error("Failed to load key.", e);
appWindows.showErrorWindow(e, window, null);
}
}
}

View File

@@ -84,18 +84,19 @@ public class AwtTrayMenuController implements TrayMenuController {
private void addChildren(Menu menu, List<TrayMenuItem> items) {
for (var item : items) {
// TODO: use Pattern Matching for switch, once available
if (item instanceof ActionItem a) {
var menuItem = new MenuItem(a.title());
menuItem.addActionListener(evt -> a.action().run());
menuItem.setEnabled(a.enabled());
menu.add(menuItem);
} else if (item instanceof SeparatorItem) {
menu.addSeparator();
} else if (item instanceof SubMenuItem s) {
var submenu = new Menu(s.title());
addChildren(submenu, s.items());
menu.add(submenu);
switch (item) {
case ActionItem a -> {
var menuItem = new MenuItem(a.title());
menuItem.addActionListener(evt -> a.action().run());
menuItem.setEnabled(a.enabled());
menu.add(menuItem);
}
case SeparatorItem si -> menu.addSeparator();
case SubMenuItem smi -> {
var submenu = new Menu(smi.title());
addChildren(submenu, smi.items());
menu.add(submenu);
}
}
}
}

View File

@@ -38,13 +38,12 @@ public class UnlockInvalidMountPointController implements FxController {
@FXML
public void initialize() {
var e = unlockException.get();
String translationKey = "unlock.error.customPath.description.generic";
if (e instanceof MountPointNotSupportedException) {
translationKey = "unlock.error.customPath.description.notSupported";
} else if (e instanceof MountPointNotExistsException) {
translationKey = "unlock.error.customPath.description.notExists";
}
dialogDescription.setFormat(resourceBundle.getString(translationKey));
var translationKeySuffix = switch (e) {
case MountPointNotSupportedException x -> "notSupported";
case MountPointNotExistsException x -> "notExists";
default -> "generic";
};
dialogDescription.setFormat(resourceBundle.getString("unlock.error.customPath.description." + translationKeySuffix));
dialogDescription.setArg1(e.getMessage());
}