mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Merge adjustments
This commit is contained in:
parent
8731708cf6
commit
fd29d31197
23 changed files with 75 additions and 60 deletions
|
@ -39,7 +39,7 @@ public class BrowserSavedStateImpl implements BrowserSavedState {
|
|||
}
|
||||
|
||||
private static BrowserSavedStateImpl load() {
|
||||
return AppCache.get("browser-state", BrowserSavedStateImpl.class, () -> {
|
||||
return AppCache.getNonNull("browser-state", BrowserSavedStateImpl.class, () -> {
|
||||
return new BrowserSavedStateImpl(FXCollections.observableArrayList());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class OpenFileSystemSavedState {
|
|||
}
|
||||
|
||||
static OpenFileSystemSavedState loadForStore(OpenFileSystemModel model) {
|
||||
var state = AppCache.get("fs-state-" + model.getEntry().get().getUuid(), OpenFileSystemSavedState.class, () -> {
|
||||
var state = AppCache.getNonNull("fs-state-" + model.getEntry().get().getUuid(), OpenFileSystemSavedState.class, () -> {
|
||||
return new OpenFileSystemSavedState();
|
||||
});
|
||||
state.setModel(model);
|
||||
|
|
|
@ -141,29 +141,6 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
|
|||
vbox.getChildren().add(b.createRegion());
|
||||
}
|
||||
|
||||
{
|
||||
var zone = ZoneId.of(ZoneId.SHORT_IDS.get("PST"));
|
||||
var now = Instant.now();
|
||||
var phStart = ZonedDateTime.of(2024, 10, 22, 0, 1, 0, 0, zone).toInstant();
|
||||
var phEnd = ZonedDateTime.of(2024, 10, 23, 0, 1, 0, 0, zone).toInstant();
|
||||
var clicked = AppCache.get("phClicked", Boolean.class, () -> false);
|
||||
var phShow = now.isAfter(phStart) && now.isBefore(phEnd) && !clicked;
|
||||
if (phShow) {
|
||||
var hide = new SimpleBooleanProperty(false);
|
||||
var b = new IconButtonComp(new LabelGraphic.ImageGraphic("app:producthunt-color.png", 24), () -> {
|
||||
AppCache.update("phClicked", true);
|
||||
Hyperlinks.open(Hyperlinks.PRODUCT_HUNT);
|
||||
hide.set(true);
|
||||
})
|
||||
.tooltip(new SimpleStringProperty("Product Hunt"));
|
||||
b.apply(struc -> {
|
||||
AppFont.setSize(struc.get(), 1);
|
||||
});
|
||||
b.hide(hide);
|
||||
vbox.getChildren().add(b.createRegion());
|
||||
}
|
||||
}
|
||||
|
||||
var filler = new Button();
|
||||
filler.setDisable(true);
|
||||
filler.setMaxHeight(3000);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class StoreEntryListComp extends SimpleComp {
|
|||
@Override
|
||||
protected Region createSimple() {
|
||||
var scriptsIntroShowing =
|
||||
new SimpleBooleanProperty(!AppCache.get("scriptsIntroCompleted", Boolean.class, () -> false));
|
||||
new SimpleBooleanProperty(!AppCache.getBoolean("scriptsIntroCompleted", false));
|
||||
var initialCount = 1;
|
||||
var showIntro = Bindings.createBooleanBinding(
|
||||
() -> {
|
||||
|
|
|
@ -126,7 +126,7 @@ public class StoreViewState {
|
|||
activeCategory.addListener((observable, oldValue, newValue) -> {
|
||||
DataStorage.get().setSelectedCategory(newValue.getCategory());
|
||||
});
|
||||
var selected = AppCache.get("selectedCategory", UUID.class, () -> DataStorage.DEFAULT_CATEGORY_UUID);
|
||||
var selected = AppCache.getNonNull("selectedCategory", UUID.class, () -> DataStorage.DEFAULT_CATEGORY_UUID);
|
||||
activeCategory.setValue(categories.getList().stream()
|
||||
.filter(storeCategoryWrapper ->
|
||||
storeCategoryWrapper.getCategory().getUuid().equals(selected))
|
||||
|
|
|
@ -3,21 +3,15 @@ package io.xpipe.app.core;
|
|||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.util.JsonConfigHelper;
|
||||
import io.xpipe.core.util.JacksonMapper;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class AppCache {
|
||||
|
||||
public static <T> Optional<T> getIfPresent(String key, Class<T> type) {
|
||||
return Optional.ofNullable(get(key, type, () -> null));
|
||||
}
|
||||
|
||||
private static Path getBasePath() {
|
||||
return AppProperties.get().getDataDir().resolve("cache");
|
||||
}
|
||||
|
@ -47,7 +41,33 @@ public class AppCache {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T get(String key, Class<?> type, Supplier<T> notPresent) {
|
||||
public static <T> T getNonNull(String key, Class<?> type, Supplier<T> notPresent) {
|
||||
var path = getPath(key);
|
||||
if (Files.exists(path)) {
|
||||
try {
|
||||
var tree = JsonConfigHelper.readRaw(path);
|
||||
if (tree.isMissingNode() || tree.isNull()) {
|
||||
FileUtils.deleteQuietly(path.toFile());
|
||||
return notPresent.get();
|
||||
}
|
||||
|
||||
var r = (T) JacksonMapper.getDefault().treeToValue(tree, type);
|
||||
if (r == null || !type.isAssignableFrom(r.getClass())) {
|
||||
FileUtils.deleteQuietly(path.toFile());
|
||||
return notPresent.get();
|
||||
} else {
|
||||
return r;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ErrorEvent.fromThrowable(ex).omit().handle();
|
||||
FileUtils.deleteQuietly(path.toFile());
|
||||
}
|
||||
}
|
||||
return notPresent != null ? notPresent.get() : null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getNullable(String key, Class<?> type, Supplier<T> notPresent) {
|
||||
var path = getPath(key);
|
||||
if (Files.exists(path)) {
|
||||
try {
|
||||
|
@ -65,6 +85,25 @@ public class AppCache {
|
|||
return notPresent != null ? notPresent.get() : null;
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key, boolean notPresent) {
|
||||
var path = getPath(key);
|
||||
if (Files.exists(path)) {
|
||||
try {
|
||||
var tree = JsonConfigHelper.readRaw(path);
|
||||
if (!tree.isBoolean()) {
|
||||
FileUtils.deleteQuietly(path.toFile());
|
||||
return notPresent;
|
||||
}
|
||||
|
||||
return tree.asBoolean();
|
||||
} catch (Exception ex) {
|
||||
ErrorEvent.fromThrowable(ex).omit().handle();
|
||||
FileUtils.deleteQuietly(path.toFile());
|
||||
}
|
||||
}
|
||||
return notPresent;
|
||||
}
|
||||
|
||||
public static <T> void update(String key, T val) {
|
||||
var path = getPath(key);
|
||||
|
||||
|
@ -79,12 +118,4 @@ public class AppCache {
|
|||
.handle();
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getValue(String key, Class<?> type, Supplier<T> notPresent) {
|
||||
return get(key, type, notPresent);
|
||||
}
|
||||
|
||||
public <T> void updateValue(String key, T val) {
|
||||
update(key, val);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AppGreetings {
|
|||
}
|
||||
|
||||
public static void showIfNeeded() {
|
||||
boolean set = AppCache.get("legalAccepted", Boolean.class, () -> false);
|
||||
boolean set = AppCache.getBoolean("legalAccepted", false);
|
||||
if (set || AppProperties.get().isDevelopmentEnvironment()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class AppLayoutModel {
|
|||
}
|
||||
|
||||
public static void init() {
|
||||
var state = AppCache.get("layoutState", SavedState.class, () -> new SavedState(260, 300));
|
||||
var state = AppCache.getNonNull("layoutState", SavedState.class, () -> new SavedState(260, 300));
|
||||
INSTANCE = new AppLayoutModel(state);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ public class AppState {
|
|||
String userEmail;
|
||||
|
||||
public AppState() {
|
||||
UUID id = AppCache.get("userId", UUID.class, null);
|
||||
UUID id = AppCache.getNonNull("userId", UUID.class, null);
|
||||
if (id == null) {
|
||||
initialLaunch = AppCache.getIfPresent("lastBuild", String.class).isEmpty();
|
||||
initialLaunch = AppCache.getNonNull("lastBuild", String.class, () -> null) == null;
|
||||
userId = UUID.randomUUID();
|
||||
AppCache.update("userId", userId);
|
||||
} else {
|
||||
|
|
|
@ -97,7 +97,7 @@ public class AppTheme {
|
|||
}
|
||||
|
||||
try {
|
||||
var lastSystemDark = AppCache.get("lastTheme", Boolean.class, () -> false);
|
||||
var lastSystemDark = AppCache.getBoolean("lastTheme", false);
|
||||
var nowDark = Platform.getPreferences().getColorScheme() == ColorScheme.DARK;
|
||||
AppCache.update("lastTheme", nowDark);
|
||||
if (AppPrefs.get().theme.getValue() == null || lastSystemDark != nowDark) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import io.xpipe.app.issue.ErrorEvent;
|
|||
public class AppJavaOptionsCheck {
|
||||
|
||||
public static void check() {
|
||||
if (AppCache.get("javaOptionsWarningShown", Boolean.class, () -> false)) {
|
||||
if (AppCache.getBoolean("javaOptionsWarningShown", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import io.xpipe.app.prefs.CloseBehaviourAlert;
|
|||
import io.xpipe.app.resources.AppImages;
|
||||
import io.xpipe.app.util.ThreadHelper;
|
||||
import io.xpipe.core.process.OsType;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
|
@ -25,18 +24,17 @@ import javafx.scene.layout.Region;
|
|||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Value;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class AppMainWindow {
|
||||
|
||||
|
@ -231,7 +229,7 @@ public class AppMainWindow {
|
|||
return null;
|
||||
}
|
||||
|
||||
WindowState state = AppCache.get("windowState", WindowState.class, () -> null);
|
||||
WindowState state = AppCache.getNonNull("windowState", WindowState.class, () -> null);
|
||||
if (state == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ public class AppPrefs {
|
|||
new DeveloperCategory())
|
||||
.filter(appPrefsCategory -> appPrefsCategory.show())
|
||||
.toList();
|
||||
var selected = AppCache.get("selectedPrefsCategory", Integer.class, () -> 0);
|
||||
var selected = AppCache.getNonNull("selectedPrefsCategory", Integer.class, () -> 0);
|
||||
if (selected == null) {
|
||||
selected = 0;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class CloseBehaviourAlert {
|
|||
return true;
|
||||
}
|
||||
|
||||
boolean set = AppCache.get("closeBehaviourSet", Boolean.class, () -> false);
|
||||
boolean set = AppCache.getBoolean("closeBehaviourSet", false);
|
||||
if (set) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
|
||||
private boolean showInfo() {
|
||||
boolean set = AppCache.get("xshellSetup", Boolean.class, () -> false);
|
||||
boolean set = AppCache.getBoolean("xshellSetup", false);
|
||||
if (set) {
|
||||
return true;
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
|
||||
private boolean showInfo() throws IOException {
|
||||
boolean set = AppCache.get("termiusSetup", Boolean.class, () -> false);
|
||||
boolean set = AppCache.getBoolean("termiusSetup", false);
|
||||
if (set) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class UpdateHandler {
|
|||
protected final boolean updateSucceeded;
|
||||
|
||||
protected UpdateHandler(boolean startBackgroundThread) {
|
||||
performedUpdate = AppCache.get("performedUpdate", PerformedUpdate.class, () -> null);
|
||||
performedUpdate = AppCache.getNonNull("performedUpdate", PerformedUpdate.class, () -> null);
|
||||
var hasUpdated = performedUpdate != null;
|
||||
event("Was updated is " + hasUpdated);
|
||||
if (hasUpdated) {
|
||||
|
@ -48,7 +48,7 @@ public abstract class UpdateHandler {
|
|||
updateSucceeded = false;
|
||||
}
|
||||
|
||||
preparedUpdate.setValue(AppCache.get("preparedUpdate", PreparedUpdate.class, () -> null));
|
||||
preparedUpdate.setValue(AppCache.getNonNull("preparedUpdate", PreparedUpdate.class, () -> null));
|
||||
|
||||
// Check if the original version this was downloaded from is still the same
|
||||
if (preparedUpdate.getValue() != null
|
||||
|
|
|
@ -54,7 +54,7 @@ public enum XPipeDistributionType {
|
|||
}
|
||||
|
||||
if (!XPipeSession.get().isNewBuildSession()) {
|
||||
var cached = AppCache.get("dist", String.class, () -> null);
|
||||
var cached = AppCache.getNonNull("dist", String.class, () -> null);
|
||||
var cachedType = Arrays.stream(values())
|
||||
.filter(xPipeDistributionType ->
|
||||
xPipeDistributionType.getId().equals(cached))
|
||||
|
|
|
@ -25,7 +25,7 @@ public class XPipeSession {
|
|||
return;
|
||||
}
|
||||
|
||||
var s = AppCache.get("lastBuildId", String.class, () -> null);
|
||||
var s = AppCache.getNonNull("lastBuildId", String.class, () -> null);
|
||||
var isBuildChanged = !buildSessionId.toString().equals(s);
|
||||
AppCache.update("lastBuildId", buildSessionId.toString());
|
||||
INSTANCE = new XPipeSession(isBuildChanged, UUID.randomUUID(), buildSessionId);
|
||||
|
|
BIN
img/proc/virsh_icon-16.png
Normal file
BIN
img/proc/virsh_icon-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
img/proc/virsh_icon-24.png
Normal file
BIN
img/proc/virsh_icon-24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
img/proc/virsh_icon-40.png
Normal file
BIN
img/proc/virsh_icon-40.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
BIN
img/proc/virsh_icon-80.png
Normal file
BIN
img/proc/virsh_icon-80.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -391,3 +391,12 @@ vmPort=Port
|
|||
vmPortDescription=The port to connect to via SSH
|
||||
forwardAgent=Forward agent
|
||||
forwardAgentDescription=Make SSH agent identities available on the remote system
|
||||
virshUri=URI
|
||||
virshUriDescription=The hypervisor URI, aliases are also supported
|
||||
virshDomain.displayName=libvirt domain
|
||||
virshDomain.displayDescription=Connect to a libvirt domain
|
||||
virshHypervisor.displayName=libvirt hypervisor
|
||||
virshHypervisor.displayDescription=Connect to a libvirt supported hypervisor driver
|
||||
virshInstall.displayName=libvirt command-line client
|
||||
virshInstall.displayDescription=Connect to all available libvirt hypervisors via virsh
|
||||
addHypervisor=Add hypervisor
|
||||
|
|
Loading…
Reference in a new issue