mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-21 01:56:55 -04:00
Merge pull request #2897 from cryptomator/feature/jdk20
Upgrade to jdk20 and jfx20
This commit is contained in:
@@ -9,8 +9,8 @@ import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.util.function.Function;
|
||||
|
||||
// TODO make sealed, remove enum
|
||||
interface IpcMessage {
|
||||
//TODO can the enum be removed?
|
||||
sealed interface IpcMessage permits HandleLaunchArgsMessage, RevealRunningAppMessage {
|
||||
|
||||
enum MessageType {
|
||||
REVEAL_RUNNING_APP(RevealRunningAppMessage::decode),
|
||||
|
||||
@@ -5,10 +5,9 @@ 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 m -> revealRunningApp(); // TODO: rename to _ with JEP 443
|
||||
case HandleLaunchArgsMessage m -> handleLaunchArgs(m.args());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 s -> menu.addSeparator(); // TODO: rename to _ with JEP 443
|
||||
case SubMenuItem s -> {
|
||||
var submenu = new Menu(s.title());
|
||||
addChildren(submenu, s.items());
|
||||
menu.add(submenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +38,11 @@ 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";
|
||||
}
|
||||
var translationKey = switch (e) {
|
||||
case MountPointNotSupportedException x -> "unlock.error.customPath.description.notSupported";
|
||||
case MountPointNotExistsException x -> "unlock.error.customPath.description.notExists";
|
||||
default -> "unlock.error.customPath.description.generic";
|
||||
};
|
||||
dialogDescription.setFormat(resourceBundle.getString(translationKey));
|
||||
dialogDescription.setArg1(e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user