mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 09:00:26 +00:00
Rework connection sharing
This commit is contained in:
parent
42f83e331a
commit
6df9169e38
5 changed files with 35 additions and 12 deletions
|
@ -122,8 +122,8 @@ public interface DataStoreProvider {
|
||||||
|
|
||||||
default void storageInit() throws Exception {}
|
default void storageInit() throws Exception {}
|
||||||
|
|
||||||
default boolean isShareable() {
|
default boolean isShareable(DataStoreEntry entry) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
default String summaryString(StoreEntryWrapper wrapper) {
|
default String summaryString(StoreEntryWrapper wrapper) {
|
||||||
|
|
|
@ -161,6 +161,38 @@ public abstract class DataStorage {
|
||||||
public abstract void save();
|
public abstract void save();
|
||||||
|
|
||||||
public abstract boolean supportsSharing();
|
public abstract boolean supportsSharing();
|
||||||
|
public boolean shouldShare(DataStoreCategory entry) {
|
||||||
|
if (!entry.canShare()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataStoreCategory c = entry;
|
||||||
|
do {
|
||||||
|
if (!c.shouldShareChildren()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} while ((c = DataStorage.get()
|
||||||
|
.getStoreCategoryIfPresent(c.getParentCategory())
|
||||||
|
.orElse(null))
|
||||||
|
!= null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldShare(DataStoreEntry entry) {
|
||||||
|
if (!shouldShare(DataStorage.get()
|
||||||
|
.getStoreCategoryIfPresent(entry.getCategoryUuid())
|
||||||
|
.orElseThrow())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataStoreEntry c = entry;
|
||||||
|
do {
|
||||||
|
if (!c.getProvider().isShareable(c)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} while ((c = DataStorage.get().getDisplayParent(c).orElse(null)) != null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected void refreshValidities(boolean makeValid) {
|
protected void refreshValidities(boolean makeValid) {
|
||||||
var changed = new AtomicBoolean(false);
|
var changed = new AtomicBoolean(false);
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class ShareStoreAction implements ActionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
|
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
|
||||||
return o.get().getProvider().isShareable();
|
return o.get().getProvider().isShareable(o.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,10 +24,6 @@ import java.util.List;
|
||||||
|
|
||||||
public class ScriptGroupStoreProvider implements DataStoreProvider {
|
public class ScriptGroupStoreProvider implements DataStoreProvider {
|
||||||
|
|
||||||
public boolean isShareable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comp<?> customEntryComp(StoreSection sec, boolean preferLarge) {
|
public Comp<?> customEntryComp(StoreSection sec, boolean preferLarge) {
|
||||||
ScriptGroupStore s = sec.getWrapper().getEntry().getStore().asNeeded();
|
ScriptGroupStore s = sec.getWrapper().getEntry().getStore().asNeeded();
|
||||||
|
|
|
@ -89,11 +89,6 @@ public class SimpleScriptStoreProvider implements DataStoreProvider {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isShareable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataStoreEntry getDisplayParent(DataStoreEntry store) {
|
public DataStoreEntry getDisplayParent(DataStoreEntry store) {
|
||||||
SimpleScriptStore st = store.getStore().asNeeded();
|
SimpleScriptStore st = store.getStore().asNeeded();
|
||||||
|
|
Loading…
Reference in a new issue