Merge branch icons into master [release]

This commit is contained in:
crschnick
2024-10-01 10:29:31 +00:00
parent 19b341d848
commit dbea577662
5425 changed files with 52433 additions and 1535 deletions
@@ -55,7 +55,8 @@ public class BrowseStoreAction implements ActionProvider {
@Override
public void execute() {
DataStoreEntryRef<FileSystemStore> replacement = ProcessControlProvider.get().replace(entry.ref());
DataStoreEntryRef<FileSystemStore> replacement =
ProcessControlProvider.get().replace(entry.ref());
BrowserSessionModel.DEFAULT.openFileSystemAsync(replacement, null, new SimpleBooleanProperty());
AppLayoutModel.get().selectBrowser();
}
@@ -0,0 +1,60 @@
package io.xpipe.ext.base.action;
import io.xpipe.app.comp.store.StoreIconChoiceDialogComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.DataStore;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import lombok.Value;
public class ChangeStoreIconAction implements ActionProvider {
@Override
public LeafDataStoreCallSite<?> getLeafDataStoreCallSite() {
return new LeafDataStoreCallSite<>() {
@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 ObservableValue<String> getName(DataStoreEntryRef<DataStore> store) {
return AppI18n.observable("base.changeIcon");
}
@Override
public String getIcon(DataStoreEntryRef<DataStore> store) {
return "mdi2t-tooltip-image-outline";
}
};
}
@Value
static class Action implements ActionProvider.Action {
DataStoreEntry entry;
@Override
public void execute() {
Platform.runLater(() -> {
StoreIconChoiceDialogComp.show(entry);
});
}
}
}
@@ -6,7 +6,9 @@ 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;
import java.time.Duration;
@@ -72,7 +72,7 @@ public class RefreshChildrenStoreAction implements ActionProvider {
@Override
public void execute() {
DataStorage.get().refreshChildren(store);
DataStorage.get().refreshChildren(store, null);
}
}
}
@@ -2,13 +2,13 @@ package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.process.CommandControl;
import io.xpipe.core.process.ElevationFunction;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.store.ShellStore;
import javafx.beans.value.ObservableValue;
@@ -70,7 +70,7 @@ public class ScanStoreAction implements ActionProvider {
@Override
public void execute() {
if (entry == null || entry.getStore() instanceof ShellStore) {
ScanAlert.showForShellStore(entry);
ScanAlert.showForShellStore(entry, null);
}
}
}
@@ -10,8 +10,8 @@ import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FilePath;
import javafx.beans.value.ObservableValue;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
@@ -59,7 +59,13 @@ public class OpenNativeFileDetailsAction implements LeafAction {
}
var file = new FilePath(e);
sc.command(CommandBuilder.of().add("xdg-open").addFile(entry.getRawFileEntry().getKind() == FileKind.DIRECTORY ? file : file.getParent())).execute();
sc.command(CommandBuilder.of()
.add("xdg-open")
.addFile(
entry.getRawFileEntry().getKind() == FileKind.DIRECTORY
? file
: file.getParent()))
.execute();
}
case OsType.MacOs macOs -> {
sc.osascriptCommand(String.format(
@@ -1,6 +1,6 @@
package io.xpipe.ext.base.script;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.resources.AppResources;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.process.ShellDialects;
@@ -1,11 +1,16 @@
package io.xpipe.ext.base.script;
import io.xpipe.app.comp.store.StoreCreationComp;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.FileOpener;
import io.xpipe.core.process.OsType;
import lombok.Value;
import java.util.Arrays;
public class SimpleScriptQuickEditAction implements ActionProvider {
@Override
public DefaultDataStoreCallSite<?> getDefaultDataStoreCallSite() {
@@ -29,17 +34,26 @@ public class SimpleScriptQuickEditAction implements ActionProvider {
@Override
public void execute() {
var predefined = DataStorage.get()
.getStoreCategoryIfPresent(ref.get().getCategoryUuid())
.map(category -> category.getUuid().equals(DataStorage.PREDEFINED_SCRIPTS_CATEGORY_UUID))
.orElse(false)
&& Arrays.stream(PredefinedScriptStore.values())
.anyMatch(predefinedScriptStore -> predefinedScriptStore
.getName()
.equals(ref.get().getName()));
if (predefined) {
StoreCreationComp.showEdit(ref.get());
return;
}
var script = ref.getStore();
var dialect = script.getMinimumDialect();
var ext = dialect.getScriptFileEnding();
var name = OsType.getLocal().makeFileSystemCompatible(ref.get().getName());
FileOpener.openString(
name + "." + ext,
this,
script.getCommands(),
(s) -> {
ref.get().setStoreInternal(script.toBuilder().commands(s).build(), true);
});
FileOpener.openString(name + "." + ext, this, script.getCommands(), (s) -> {
ref.get().setStoreInternal(script.toBuilder().commands(s).build(), true);
});
}
}
}
@@ -4,7 +4,6 @@ import io.xpipe.app.comp.base.IntegratedTextAreaComp;
import io.xpipe.app.comp.base.ListSelectorComp;
import io.xpipe.app.comp.base.SystemStateComp;
import io.xpipe.app.comp.store.StoreEntryWrapper;
import io.xpipe.app.comp.store.StoreSection;
import io.xpipe.app.comp.store.StoreViewState;
import io.xpipe.app.core.AppExtensionManager;
import io.xpipe.app.core.AppI18n;
@@ -16,6 +15,7 @@ import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.impl.DataStoreChoiceComp;
import io.xpipe.app.fxcomps.impl.DataStoreListChoiceComp;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.DataStoreFormatter;
import io.xpipe.app.util.MarkdownBuilder;
import io.xpipe.app.util.OptionsBuilder;
import io.xpipe.app.util.Validator;
@@ -27,8 +27,6 @@ import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import lombok.SneakyThrows;
@@ -37,6 +35,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, DataStoreProvider {
@@ -210,13 +209,29 @@ public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, Da
}
@Override
public ObservableValue<String> informationString(StoreSection section) {
SimpleScriptStore scriptStore =
section.getWrapper().getEntry().getStore().asNeeded();
return new SimpleStringProperty((scriptStore.getMinimumDialect() != null
? scriptStore.getMinimumDialect().getDisplayName() + " "
: "")
+ " snippet");
public boolean alwaysShowSummary() {
return true;
}
@Override
public String summaryString(StoreEntryWrapper wrapper) {
SimpleScriptStore st = wrapper.getEntry().getStore().asNeeded();
var init = st.isInitScript() ? AppI18n.get("init") : null;
var file = st.isRunnableScript() ? AppI18n.get("file") : null;
var shell = st.isRunnableScript() ? AppI18n.get("shell") : null;
var runnable = st.isRunnableScript() ? AppI18n.get("hub") : null;
var type = st.getMinimumDialect() != null
? st.getMinimumDialect().getDisplayName() + " " + AppI18n.get("script")
: null;
var suffix = String.join(
" / ",
Stream.of(init, shell, file, runnable).filter(s -> s != null).toList());
if (!suffix.isEmpty()) {
suffix = "(" + suffix + ")";
} else {
suffix = null;
}
return DataStoreFormatter.join(type, suffix);
}
@SneakyThrows
@@ -8,6 +8,7 @@ import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.OptionsBuilder;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.NetworkTunnelStore;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
@@ -1,11 +1,11 @@
package io.xpipe.ext.base.service;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.FixedHierarchyStore;
import io.xpipe.app.util.Validators;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.FixedChildStore;
import io.xpipe.core.store.ValidationContext;
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.AccessLevel;
@@ -22,7 +22,7 @@ import java.util.List;
@Jacksonized
@JsonTypeName("fixedServiceGroup")
public class FixedServiceGroupStore extends AbstractServiceGroupStore<FixedServiceCreatorStore>
implements DataStore, FixedHierarchyStore {
implements DataStore, FixedHierarchyStore<ValidationContext<?>> {
@Override
public void checkComplete() throws Throwable {
@@ -32,9 +32,14 @@ public class FixedServiceGroupStore extends AbstractServiceGroupStore<FixedServi
@Override
@SuppressWarnings("unchecked")
public List<? extends DataStoreEntryRef<? extends FixedChildStore>> listChildren(DataStoreEntry self)
public List<? extends DataStoreEntryRef<? extends FixedChildStore>> listChildren(ValidationContext<?> context)
throws Exception {
return (List<? extends DataStoreEntryRef<? extends FixedChildStore>>)
getParent().getStore().createFixedServices();
}
@Override
public ValidationContext<?> createContext() throws Exception {
return null;
}
}
@@ -10,10 +10,12 @@ import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.app.ext.DataStoreUsageCategory;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.resources.SystemIcons;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.DataStoreFormatter;
import io.xpipe.app.util.TerminalLauncher;
import io.xpipe.core.process.ShellStoreState;
import io.xpipe.core.store.ShellStore;
import io.xpipe.ext.base.script.ScriptStore;
@@ -29,11 +31,21 @@ public interface ShellStoreProvider extends DataStoreProvider {
public void execute() throws Exception {
var replacement = ProcessControlProvider.get().replace(entry.ref());
ShellStore store = replacement.getStore().asNeeded();
var control = ScriptStore.controlWithDefaultScripts(store.control());
control.onInit(sc -> {
if (entry.getStorePersistentState() instanceof ShellStoreState shellStoreState
&& shellStoreState.getShellDialect() == null) {
var found = SystemIcons.detectForSystem(sc);
if (found.isPresent()) {
entry.setIcon(found.get().getIconName(), false);
}
}
});
TerminalLauncher.open(
replacement.get(),
DataStorage.get().getStoreEntryDisplayName(replacement.get()),
null,
ScriptStore.controlWithDefaultScripts(store.control()));
control);
}
};
}
@@ -33,6 +33,11 @@ public class StorePauseAction implements ActionProvider {
public String getIcon(DataStoreEntryRef<PauseableStore> store) {
return "mdi2p-pause";
}
@Override
public boolean requiresValidStore() {
return false;
}
};
}
@@ -33,6 +33,11 @@ public class StoreStartAction implements ActionProvider {
public String getIcon(DataStoreEntryRef<StartableStore> store) {
return "mdi2p-play";
}
@Override
public boolean requiresValidStore() {
return false;
}
};
}
@@ -33,6 +33,11 @@ public class StoreStopAction implements ActionProvider {
public String getIcon(DataStoreEntryRef<StoppableStore> store) {
return "mdi2s-stop";
}
@Override
public boolean requiresValidStore() {
return false;
}
};
}
+2 -1
View File
@@ -77,7 +77,8 @@ open module io.xpipe.ext.base {
XPipeUrlAction,
EditStoreAction,
BrowseStoreAction,
ScanStoreAction;
ScanStoreAction,
ChangeStoreIconAction;
provides DataStoreProvider with
FixedServiceGroupStoreProvider,
CustomServiceGroupStoreProvider,