mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-01 09:40:35 +13:00
Add ability to clone connections for #124
This commit is contained in:
parent
8c8dd99ad2
commit
cbcafb12e3
4 changed files with 72 additions and 0 deletions
|
@ -101,6 +101,10 @@ public interface DataStoreProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean canClone() {
|
||||||
|
return getCreationCategory() != null;
|
||||||
|
}
|
||||||
|
|
||||||
default DataStoreEntry getDisplayParent(DataStoreEntry store) {
|
default DataStoreEntry getDisplayParent(DataStoreEntry store) {
|
||||||
return getSyntheticParent(store);
|
return getSyntheticParent(store);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package io.xpipe.ext.base.action;
|
||||||
|
|
||||||
|
import io.xpipe.app.core.AppI18n;
|
||||||
|
import io.xpipe.app.ext.ActionProvider;
|
||||||
|
import io.xpipe.app.storage.DataStorage;
|
||||||
|
import io.xpipe.app.storage.DataStoreEntry;
|
||||||
|
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||||
|
import io.xpipe.core.store.DataStore;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import lombok.Value;
|
||||||
|
|
||||||
|
public class CloneStoreAction implements ActionProvider {
|
||||||
|
|
||||||
|
@Value
|
||||||
|
static class Action implements ActionProvider.Action {
|
||||||
|
|
||||||
|
DataStoreEntry store;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresJavaFXPlatform() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
DataStorage.get().addStoreEntryIfNotPresent(
|
||||||
|
DataStoreEntry.createNew(store.getName() + " (Copy)",store.getStore()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataStoreCallSite<?> getDataStoreCallSite() {
|
||||||
|
return new DataStoreCallSite<>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSystemAction() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
|
||||||
|
return new Action(store.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<DataStore> getApplicableClass() {
|
||||||
|
return DataStore.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
|
||||||
|
return o.get().getProvider().canClone();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObservableValue<String> getName(DataStoreEntryRef<DataStore> store) {
|
||||||
|
return AppI18n.observable("base.clone");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIcon(DataStoreEntryRef<DataStore> store) {
|
||||||
|
return "mdi2c-content-copy";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,6 +50,7 @@ open module io.xpipe.ext.base {
|
||||||
JavapAction,
|
JavapAction,
|
||||||
JarAction;
|
JarAction;
|
||||||
provides ActionProvider with
|
provides ActionProvider with
|
||||||
|
CloneStoreAction,
|
||||||
RefreshStoreAction,
|
RefreshStoreAction,
|
||||||
ScanAction,
|
ScanAction,
|
||||||
LaunchAction,
|
LaunchAction,
|
||||||
|
|
|
@ -19,6 +19,7 @@ observe=Start observing
|
||||||
stopObserve=Stop observing
|
stopObserve=Stop observing
|
||||||
createShortcut=Create desktop shortcut
|
createShortcut=Create desktop shortcut
|
||||||
browseFiles=Browse Files
|
browseFiles=Browse Files
|
||||||
|
clone=Clone
|
||||||
targetPath=Target path
|
targetPath=Target path
|
||||||
newDirectory=New directory
|
newDirectory=New directory
|
||||||
copyShareLink=Copy link
|
copyShareLink=Copy link
|
||||||
|
|
Loading…
Reference in a new issue