Erweiterungen

This commit is contained in:
2025-07-08 20:35:58 +02:00
parent aaf4e45f9d
commit 953b7782bd
25 changed files with 665 additions and 425 deletions

View File

@@ -0,0 +1,20 @@
package util;
import org.springframework.stereotype.Service;
import java.util.Optional;
import java.util.prefs.Preferences;
@Service
public class PreferencesKeyValueStore {
private final Preferences prefs = Preferences.userRoot().node("emulatorstation");
public void put(String key, String value) {
prefs.put(key, value);
}
public Optional<String> get(String key) {
return Optional.ofNullable(prefs.get(key, null));
}
}

View File

@@ -0,0 +1,19 @@
package util;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.applayout.AppLayout;
import com.vaadin.flow.server.VaadinSession;
import com.vaadin.flow.server.WrappedSession;
public class Util {
public static String getSessionAttributeWithDefault(WrappedSession currentSession, String key, String defaultValue) {
var result = defaultValue;
try {
result = currentSession.getAttribute(key).toString();
} catch (Exception e) {}
return result;
}
}