More rework

This commit is contained in:
crschnick 2024-06-13 13:07:06 +00:00
parent 7ebb25cf80
commit 7b26984773
6 changed files with 42 additions and 3 deletions

View file

@ -1,6 +1,7 @@
package io.xpipe.app.storage;
import io.xpipe.app.comp.store.StoreSortMode;
import io.xpipe.app.ext.DataStorageExtensionProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.FixedHierarchyStore;
@ -552,7 +553,6 @@ public abstract class DataStorage {
for (DataStoreEntry e : toAdd) {
var syntheticParent = getSyntheticParent(e);
if (syntheticParent.isPresent()) {
var exists =
addStoreEntryIfNotPresent(syntheticParent.get());
}

View file

@ -0,0 +1,32 @@
package io.xpipe.app.util;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.core.store.DataStore;
public abstract class LicenseConnectionLimit {
private final int limit;
private final LicensedFeature feature;
public LicenseConnectionLimit(int limit, LicensedFeature feature) {
this.limit = limit;
this.feature = feature;
}
protected abstract boolean matches(DataStore store);
public void checkLimit() {
if (feature.isSupported()) {
return;
}
var found = DataStorage.get()
.getStoreEntries()
.stream()
.filter(entry -> entry.getValidity().isUsable() && matches(entry.getStore()))
.toList();
if (found.size() > limit) {
throw new LicenseRequiredException(feature, limit);
}
}
}

View file

@ -1,7 +1,6 @@
package io.xpipe.app.util;
import io.xpipe.app.core.AppI18n;
import lombok.Getter;
@Getter
@ -15,6 +14,12 @@ public class LicenseRequiredException extends RuntimeException {
this.feature = feature;
}
public LicenseRequiredException(LicensedFeature feature, int limit) {
super(feature.getDisplayName() + " "
+ (feature.isPlural() ? AppI18n.get("areOnlySupportedLimit", limit) : AppI18n.get("isOnlySupportedLimit", limit)));
this.feature = feature;
}
public LicenseRequiredException(String featureName, boolean plural, LicensedFeature feature) {
super(featureName + " " + (plural ? AppI18n.get("areOnlySupported") : AppI18n.get("isOnlySupported")));
this.feature = feature;

View file

@ -41,6 +41,7 @@ public class LocalShell {
localPowershell = ProcessControlProvider.get()
.createLocalProcessControl(false)
.subShell(ShellDialects.POWERSHELL)
.withoutLicenseCheck()
.start();
}
return localPowershell.start();

View file

@ -32,7 +32,6 @@ open module io.xpipe.ext.base {
requires static io.xpipe.app;
requires org.kordamp.ikonli.javafx;
requires atlantafx.base;
requires jdk.jfr;
provides BrowserAction with RunScriptAction,
FollowLinkAction,

View file

@ -475,3 +475,5 @@ importConnections=Sync connections
importConnectionsTitle=Import Connections
showAllChildren=Show all children
httpApi=HTTP API
isOnlySupportedLimit=is only supported with a professional license when having more than $COUNT$ active connections
areOnlySupportedLimit=are only supported with a professional license when having more than $COUNT$ active connections