Add restart action

This commit is contained in:
crschnick 2024-10-26 13:39:08 +00:00
parent ba92419c6d
commit f13cfcedff
3 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,59 @@
package io.xpipe.ext.base.store;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.DataStore;
import javafx.beans.value.ObservableValue;
import lombok.Value;
public class StoreRestartAction implements ActionProvider {
@Override
public LeafDataStoreCallSite<?> getLeafDataStoreCallSite() {
return new LeafDataStoreCallSite<DataStore>() {
@Override
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
return new Action(store);
}
@Override
public Class<DataStore> getApplicableClass() {
return DataStore.class;
}
@Override
public ObservableValue<String> getName(DataStoreEntryRef<DataStore> store) {
return AppI18n.observable("restart");
}
@Override
public String getIcon(DataStoreEntryRef<DataStore> store) {
return "mdi2r-restart";
}
@Override
public boolean requiresValidStore() {
return false;
}
@Override
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
return o.getStore() instanceof StartableStore && o.getStore() instanceof StoppableStore;
}
};
}
@Value
static class Action implements ActionProvider.Action {
DataStoreEntryRef<DataStore> entry;
@Override
public void execute() throws Exception {
((StoppableStore) entry.getStore()).stop();
((StartableStore) entry.getStore()).start();
}
}
}

View file

@ -13,6 +13,7 @@ import io.xpipe.ext.base.service.*;
import io.xpipe.ext.base.store.StorePauseAction;
import io.xpipe.ext.base.store.StoreStartAction;
import io.xpipe.ext.base.store.StoreStopAction;
import io.xpipe.ext.base.store.StoreRestartAction;
open module io.xpipe.ext.base {
exports io.xpipe.ext.base;
@ -76,6 +77,7 @@ open module io.xpipe.ext.base {
StoreStopAction,
StoreStartAction,
StorePauseAction,
StoreRestartAction,
ServiceOpenAction,
ServiceOpenHttpAction,
ServiceOpenHttpsAction,

View file

@ -5,6 +5,7 @@ launch=Launch
start=Start
stop=Stop
pause=Pause
restart=Restart
refresh=Refresh
options=Options
newFile=New file