mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-06 13:03:29 +13:00
More rework
This commit is contained in:
parent
7ebb25cf80
commit
7b26984773
6 changed files with 42 additions and 3 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -41,6 +41,7 @@ public class LocalShell {
|
|||
localPowershell = ProcessControlProvider.get()
|
||||
.createLocalProcessControl(false)
|
||||
.subShell(ShellDialects.POWERSHELL)
|
||||
.withoutLicenseCheck()
|
||||
.start();
|
||||
}
|
||||
return localPowershell.start();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue