mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-22 09:16:29 +00:00
State rework
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
package io.xpipe.ext.base.action;
|
||||
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.ext.ActionProvider;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
import io.xpipe.app.util.ObservableDataStore;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import lombok.Value;
|
||||
|
||||
public class ObserveStoreAction implements ActionProvider {
|
||||
|
||||
@Override
|
||||
public DataStoreCallSite<?> getDataStoreCallSite() {
|
||||
return new DataStoreCallSite<ObservableDataStore>() {
|
||||
|
||||
@Override
|
||||
public ActionProvider.Action createAction(DataStoreEntryRef<ObservableDataStore> store) {
|
||||
return new Action(store);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ObservableDataStore> getApplicableClass() {
|
||||
return ObservableDataStore.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObservableValue<String> getName(DataStoreEntryRef<ObservableDataStore> store) {
|
||||
return store.getStore().getObserverState()
|
||||
? AppI18n.observable("base.stopObserve")
|
||||
: AppI18n.observable("base.observe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIcon(DataStoreEntryRef<ObservableDataStore> store) {
|
||||
return store.getStore().getObserverState() ? "mdi2e-eye-off-outline" : "mdi2e-eye-outline";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Action implements ActionProvider.Action {
|
||||
|
||||
DataStoreEntryRef<ObservableDataStore> store;
|
||||
|
||||
@Override
|
||||
public boolean requiresJavaFXPlatform() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
store.getStore().toggleObserverState(!store.getStore().getObserverState());
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ import io.xpipe.app.util.FixedHierarchyStore;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import lombok.Value;
|
||||
|
||||
public class RefreshStoreAction implements ActionProvider {
|
||||
public class RefreshStoreChildrenAction implements ActionProvider {
|
||||
|
||||
@Override
|
||||
public ActionProvider.DataStoreCallSite<?> getDataStoreCallSite() {
|
||||
+2
-2
@@ -32,7 +32,7 @@ public class DesktopApplicationStoreProvider implements DataStoreProvider {
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
s.getDesktop().getStore().runScript(store.getName(), s.getDesktop().getStore().getUsedDialect(), s.getFullCommand());
|
||||
s.getDesktop().getStore().runDesktopScript(store.getName(), s.getDesktop().getStore().getUsedDialect(), s.getFullCommand());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class DesktopApplicationStoreProvider implements DataStoreProvider {
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
s.getDesktop().getStore().runScript(store.getName(), s.getDesktop().getStore().getUsedDialect(), s.getFullCommand());
|
||||
s.getDesktop().getStore().runDesktopScript(store.getName(), s.getDesktop().getStore().getUsedDialect(), s.getFullCommand());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ public interface DesktopBaseStore extends DataStore {
|
||||
|
||||
boolean supportsDesktopAccess();
|
||||
|
||||
void runScript(String name, ShellDialect dialect, String script) throws Exception;
|
||||
void runDesktopScript(String name, ShellDialect dialect, String script) throws Exception;
|
||||
|
||||
void runTerminal(String name, ExternalTerminalType terminalType, ShellDialect dialect, String script) throws Exception;
|
||||
void runDesktopTerminal(String name, ExternalTerminalType terminalType, ShellDialect dialect, String script) throws Exception;
|
||||
|
||||
ShellDialect getUsedDialect();
|
||||
|
||||
|
||||
@@ -53,12 +53,12 @@ public class DesktopEnvironmentStore extends JacksonizedValue implements Desktop
|
||||
|
||||
public void launch(String n, String commands) throws Exception {
|
||||
var fullName = n + " [" + getSelfEntry().getName() + "]";
|
||||
base.getStore().runScript(fullName, dialect, getMergedInitCommands(commands));
|
||||
base.getStore().runDesktopScript(fullName, dialect, getMergedInitCommands(commands));
|
||||
}
|
||||
|
||||
public void launchSelf() throws Exception {
|
||||
var fullName = getSelfEntry().getName();
|
||||
base.getStore().runTerminal(fullName, terminal, dialect, getMergedInitCommands(null));
|
||||
base.getStore().runDesktopTerminal(fullName, terminal, dialect, getMergedInitCommands(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,13 +67,13 @@ public class DesktopEnvironmentStore extends JacksonizedValue implements Desktop
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runScript(String name, ShellDialect dialect, String script) throws Exception {
|
||||
base.getStore().runScript(name, dialect, script);
|
||||
public void runDesktopScript(String name, ShellDialect dialect, String script) throws Exception {
|
||||
base.getStore().runDesktopScript(name, dialect, script);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTerminal(String name, ExternalTerminalType terminalType, ShellDialect dialect, String script) throws Exception {
|
||||
base.getStore().runTerminal(name,terminalType,dialect,script);
|
||||
public void runDesktopTerminal(String name, ExternalTerminalType terminalType, ShellDialect dialect, String script) throws Exception {
|
||||
base.getStore().runDesktopTerminal(name,terminalType,dialect,script);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,8 +58,7 @@ open module io.xpipe.ext.base {
|
||||
StoreStopAction,
|
||||
StoreStartAction,
|
||||
StorePauseAction,
|
||||
CloneStoreAction,
|
||||
RefreshStoreAction,
|
||||
CloneStoreAction, RefreshStoreChildrenAction,
|
||||
ScanAction,
|
||||
LaunchAction,
|
||||
XPipeUrlAction,
|
||||
|
||||
Reference in New Issue
Block a user