mirror of
https://github.com/xpipe-io/xpipe.git
synced 2025-04-17 01:33:36 +00:00
Rework [stage]
This commit is contained in:
parent
6110df09a4
commit
88a6aa756f
23 changed files with 92 additions and 93 deletions
|
@ -27,6 +27,7 @@ import java.io.IOException;
|
|||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -54,8 +55,7 @@ public class BrowserFileSystemSavedState {
|
|||
|
||||
public BrowserFileSystemSavedState() {
|
||||
lastDirectory = null;
|
||||
recentDirectories =
|
||||
FXCollections.synchronizedObservableList(FXCollections.observableList(new ArrayList<>(STORED)));
|
||||
recentDirectories = FXCollections.observableList(new CopyOnWriteArrayList<>());
|
||||
}
|
||||
|
||||
static BrowserFileSystemSavedState loadForStore(BrowserFileSystemTabModel model) {
|
||||
|
@ -165,9 +165,9 @@ public class BrowserFileSystemSavedState {
|
|||
var cleaned = recentDirectories.stream()
|
||||
.map(recentEntry -> new RecentEntry(recentEntry.directory.toDirectory(), recentEntry.time))
|
||||
.filter(distinctBy(recentEntry -> recentEntry.getDirectory()))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
.collect(Collectors.toCollection(CopyOnWriteArrayList::new));
|
||||
return new BrowserFileSystemSavedState(
|
||||
null, FXCollections.synchronizedObservableList(FXCollections.observableList(cleaned)));
|
||||
null, FXCollections.observableList(cleaned));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import lombok.SneakyThrows;
|
|||
import lombok.Value;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@Value
|
||||
@JsonDeserialize(using = BrowserHistorySavedStateImpl.Deserializer.class)
|
||||
|
@ -26,7 +27,7 @@ public class BrowserHistorySavedStateImpl implements BrowserHistorySavedState {
|
|||
ObservableList<Entry> lastSystems;
|
||||
|
||||
public BrowserHistorySavedStateImpl(List<Entry> lastSystems) {
|
||||
this.lastSystems = FXCollections.synchronizedObservableList(FXCollections.observableArrayList(lastSystems));
|
||||
this.lastSystems = FXCollections.observableList(new CopyOnWriteArrayList<>(lastSystems));
|
||||
}
|
||||
|
||||
private static BrowserHistorySavedStateImpl INSTANCE;
|
||||
|
|
|
@ -18,7 +18,10 @@ import javafx.scene.layout.VBox;
|
|||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class BrowserOverviewComp extends SimpleComp {
|
||||
|
||||
|
@ -38,7 +41,7 @@ public class BrowserOverviewComp extends SimpleComp {
|
|||
|
||||
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
|
||||
|
||||
var commonPlatform = FXCollections.<FileEntry>synchronizedObservableList(FXCollections.observableArrayList());
|
||||
var commonPlatform = FXCollections.<FileEntry>observableList(new CopyOnWriteArrayList<>());
|
||||
ThreadHelper.runFailableAsync(() -> {
|
||||
var common = sc.getOsType().determineInterestingPaths(sc).stream()
|
||||
.map(s -> FileEntry.ofDirectory(model.getFileSystem(), s))
|
||||
|
|
|
@ -19,6 +19,7 @@ import javafx.collections.ListChangeListener;
|
|||
import lombok.Getter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class StoreViewState {
|
||||
|
@ -27,12 +28,10 @@ public class StoreViewState {
|
|||
private final StringProperty filter = new SimpleStringProperty();
|
||||
|
||||
@Getter
|
||||
private final DerivedObservableList<StoreEntryWrapper> allEntries = new DerivedObservableList<>(
|
||||
FXCollections.synchronizedObservableList(FXCollections.observableArrayList()), true);
|
||||
private final DerivedObservableList<StoreEntryWrapper> allEntries = new DerivedObservableList<>(FXCollections.observableList(new CopyOnWriteArrayList<>()), true);
|
||||
|
||||
@Getter
|
||||
private final DerivedObservableList<StoreCategoryWrapper> categories = new DerivedObservableList<>(
|
||||
FXCollections.synchronizedObservableList(FXCollections.observableArrayList()), true);
|
||||
private final DerivedObservableList<StoreCategoryWrapper> categories = new DerivedObservableList<>(FXCollections.observableList(new CopyOnWriteArrayList<>()), true);
|
||||
|
||||
@Getter
|
||||
private final IntegerProperty entriesListVisibilityObservable = new SimpleIntegerProperty();
|
||||
|
|
|
@ -184,8 +184,10 @@ public class AppTheme {
|
|||
return;
|
||||
}
|
||||
|
||||
var nowDark = isDarkMode();
|
||||
AppCache.update("lastDarkTheme", nowDark);
|
||||
PlatformThread.runLaterIfNeededBlocking(() -> {
|
||||
var nowDark = isDarkMode();
|
||||
AppCache.update("lastDarkTheme", nowDark);
|
||||
});
|
||||
}
|
||||
|
||||
private static void setDefault() {
|
||||
|
|
|
@ -78,8 +78,10 @@ public class PlatformInit {
|
|||
PlatformState.initPlatformOrThrow();
|
||||
AppGpuCheck.check();
|
||||
AppFont.init();
|
||||
AppStyle.init();
|
||||
AppTheme.init();
|
||||
PlatformThread.runLaterIfNeededBlocking(() -> {
|
||||
AppStyle.init();
|
||||
AppTheme.init();
|
||||
});
|
||||
AppI18n.init();
|
||||
AppDesktopIntegration.init();
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public interface ShellControl extends ProcessControl {
|
|||
|
||||
ShellControl withSourceStore(DataStore store);
|
||||
|
||||
List<ShellTerminalInitCommand> getInitCommands();
|
||||
List<ShellTerminalInitCommand> getTerminalInitCommands();
|
||||
|
||||
ParentSystemAccess getParentSystemAccess();
|
||||
|
||||
|
|
|
@ -6,74 +6,9 @@ import java.util.Optional;
|
|||
|
||||
public interface ShellTerminalInitCommand {
|
||||
|
||||
default void runDumb(ShellControl shellControl) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
default Optional<String> terminalContent(ShellControl shellControl) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
default boolean runInDumb() {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean canPotentiallyRunInDialect(ShellDialect dialect);
|
||||
|
||||
default boolean runInTerminal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
interface Terminal extends ShellTerminalInitCommand {
|
||||
|
||||
Optional<String> terminalContent(ShellControl shellControl) throws Exception;
|
||||
|
||||
default boolean runInTerminal() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class Simple implements ShellTerminalInitCommand {
|
||||
|
||||
@NonNull
|
||||
private final String content;
|
||||
|
||||
private final ShellDialect dialect;
|
||||
|
||||
private final boolean dumb;
|
||||
|
||||
private final boolean terminal;
|
||||
|
||||
public Simple(@NonNull String content, ShellDialect dialect, boolean dumb, boolean terminal) {
|
||||
this.content = content;
|
||||
this.dialect = dialect;
|
||||
this.dumb = dumb;
|
||||
this.terminal = terminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runDumb(ShellControl shellControl) throws Exception {
|
||||
shellControl.executeSimpleCommand(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> terminalContent(ShellControl shellControl) {
|
||||
return Optional.of(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runInDumb() {
|
||||
return dumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPotentiallyRunInDialect(ShellDialect dialect) {
|
||||
return this.dialect == null || this.dialect.isCompatibleTo(dialect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runInTerminal() {
|
||||
return terminal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ public class WrapperShellControl implements ShellControl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ShellTerminalInitCommand> getInitCommands() {
|
||||
return parent.getInitCommands();
|
||||
public List<ShellTerminalInitCommand> getTerminalInitCommands() {
|
||||
return parent.getTerminalInitCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
BIN
dist/logo/ico/logo_32x32.png
vendored
BIN
dist/logo/ico/logo_32x32.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
BIN
dist/logo/logo.ico
vendored
BIN
dist/logo/logo.ico
vendored
Binary file not shown.
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 131 KiB |
|
@ -9,6 +9,7 @@ import lombok.Setter;
|
|||
public enum PredefinedScriptGroup {
|
||||
CLINK("Clink", null, false),
|
||||
STARSHIP("Starship", "Sets up and enables the starship shell prompt", true),
|
||||
OHMYPOSH("Oh My Posh", "Sets up and enables the oh-my-posh shell prompt", true),
|
||||
MANAGEMENT("Management", "Some commonly used management scripts", true),
|
||||
FILES("Files", "Scripts for files", true);
|
||||
|
||||
|
|
|
@ -80,6 +80,37 @@ public enum PredefinedScriptStore {
|
|||
.minimumDialect(ShellDialects.SH)
|
||||
.commands(file(("diff.sh")))
|
||||
.fileScript(true)
|
||||
.build()),
|
||||
GIT_CONFIG("Git Config", () -> SimpleScriptStore.builder()
|
||||
.group(PredefinedScriptGroup.MANAGEMENT.getEntry())
|
||||
.minimumDialect(null)
|
||||
.commands(file(("git_config.sh")))
|
||||
.runnableScript(true)
|
||||
.build()),
|
||||
OHMYPOSH_CMD("Oh My Posh cmd", () -> SimpleScriptStore.builder()
|
||||
.group(PredefinedScriptGroup.OHMYPOSH.getEntry())
|
||||
.minimumDialect(ShellDialects.CMD)
|
||||
.script(CLINK_SETUP.getEntry())
|
||||
.commands(file(("ohmyposh.bat")))
|
||||
.initScript(true)
|
||||
.build()),
|
||||
OHMYPOSH_BASH("Oh My Posh bash", () -> SimpleScriptStore.builder()
|
||||
.group(PredefinedScriptGroup.OHMYPOSH.getEntry())
|
||||
.minimumDialect(ShellDialects.BASH)
|
||||
.commands(file(("ohmyposh.sh")))
|
||||
.initScript(true)
|
||||
.build()),
|
||||
OHMYPOSH_ZSH("Oh My Posh zsh", () -> SimpleScriptStore.builder()
|
||||
.group(PredefinedScriptGroup.OHMYPOSH.getEntry())
|
||||
.minimumDialect(ShellDialects.ZSH)
|
||||
.commands(file(("ohmyposh.sh")))
|
||||
.initScript(true)
|
||||
.build()),
|
||||
OHMYPOSH_POWERSHELL("Oh My Posh Powershell", () -> SimpleScriptStore.builder()
|
||||
.group(PredefinedScriptGroup.OHMYPOSH.getEntry())
|
||||
.minimumDialect(ShellDialects.POWERSHELL)
|
||||
.commands(file(("ohmyposh.ps1")))
|
||||
.initScript(true)
|
||||
.build());
|
||||
|
||||
private final String name;
|
||||
|
|
|
@ -48,12 +48,12 @@ public class ScriptStoreSetup {
|
|||
|
||||
@Override
|
||||
public boolean canPotentiallyRunInDialect(ShellDialect dialect) {
|
||||
return s.getStore().getMinimumDialect().isCompatibleTo(dialect);
|
||||
return s.getStore().isCompatible(dialect);
|
||||
}
|
||||
});
|
||||
});
|
||||
if (!bringFlattened.isEmpty()) {
|
||||
pc.withInitSnippet(new ShellTerminalInitCommand.Terminal() {
|
||||
pc.withInitSnippet(new ShellTerminalInitCommand() {
|
||||
|
||||
String dir;
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class ScriptStoreSetup {
|
|||
|
||||
var applicable = refs.stream()
|
||||
.filter(simpleScriptStore ->
|
||||
simpleScriptStore.getStore().getMinimumDialect().isCompatibleTo(proc.getShellDialect()))
|
||||
simpleScriptStore.getStore().isCompatible(proc.getShellDialect()))
|
||||
.toList();
|
||||
if (applicable.isEmpty()) {
|
||||
return null;
|
||||
|
|
|
@ -49,7 +49,7 @@ public class SimpleScriptQuickEditAction implements ActionProvider {
|
|||
|
||||
var script = ref.getStore();
|
||||
var dialect = script.getMinimumDialect();
|
||||
var ext = dialect.getScriptFileEnding();
|
||||
var ext = dialect != null ? dialect.getScriptFileEnding() : "sh";
|
||||
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);
|
||||
|
|
|
@ -42,11 +42,11 @@ public class SimpleScriptStore extends ScriptStore implements SelfReferentialSto
|
|||
|
||||
public boolean isCompatible(ShellControl shellControl) {
|
||||
var targetType = shellControl.getOriginalShellDialect();
|
||||
return minimumDialect.isCompatibleTo(targetType);
|
||||
return minimumDialect == null || minimumDialect.isCompatibleTo(targetType);
|
||||
}
|
||||
|
||||
public boolean isCompatible(ShellDialect dialect) {
|
||||
return minimumDialect.isCompatibleTo(dialect);
|
||||
return minimumDialect == null || minimumDialect.isCompatibleTo(dialect);
|
||||
}
|
||||
|
||||
private String assembleScript(ShellControl shellControl) {
|
||||
|
@ -83,7 +83,6 @@ public class SimpleScriptStore extends ScriptStore implements SelfReferentialSto
|
|||
public void checkComplete() throws Throwable {
|
||||
Validators.nonNull(group);
|
||||
super.checkComplete();
|
||||
Validators.nonNull(minimumDialect);
|
||||
if (!initScript && !shellScript && !fileScript && !runnableScript) {
|
||||
throw new ValidationException(AppI18n.get("app.valueMustNotBeEmpty"));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,11 @@ import java.util.stream.Stream;
|
|||
|
||||
public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, DataStoreProvider {
|
||||
|
||||
@Override
|
||||
public boolean showProviderChoice() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpLink() {
|
||||
return DocumentationLink.SCRIPTING.getLink();
|
||||
|
@ -93,7 +98,7 @@ public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, Da
|
|||
.orElseThrow(),
|
||||
"io.xpipe.ext.proc.ShellDialectChoiceComp")
|
||||
.getDeclaredConstructor(List.class, Property.class, boolean.class)
|
||||
.newInstance(availableDialects, dialect, false);
|
||||
.newInstance(availableDialects, dialect, true);
|
||||
|
||||
var vals = List.of(0, 1, 2, 3);
|
||||
var selectedStart = new ArrayList<Integer>();
|
||||
|
@ -141,7 +146,6 @@ public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, Da
|
|||
.description("minimumShellDialectDescription")
|
||||
.longDescription("base:scriptCompatibility")
|
||||
.addComp(choice, dialect)
|
||||
.nonNull()
|
||||
.name("scriptContents")
|
||||
.description("scriptContentsDescription")
|
||||
.longDescription("base:script")
|
||||
|
@ -211,7 +215,7 @@ public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, Da
|
|||
var runnable = st.isRunnableScript() ? AppI18n.get("hub") : null;
|
||||
var type = st.getMinimumDialect() != null
|
||||
? st.getMinimumDialect().getDisplayName() + " " + AppI18n.get("script")
|
||||
: null;
|
||||
: AppI18n.get("genericScript");
|
||||
var suffix = String.join(
|
||||
" / ",
|
||||
Stream.of(init, shell, file, runnable).filter(s -> s != null).toList());
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
git config --global user.name "My name"
|
||||
git config --global user.email "myemail@myorg.com"
|
||||
git config --global core.autocrlf true
|
|
@ -0,0 +1,5 @@
|
|||
WHERE /q winget && winget install JanDeDobbeleer.OhMyPosh -s winget || powershell -ExecutionPolicy Bypass -Command "Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))"
|
||||
SET "PATH=%PATH%;%USERPROFILE%\AppData\Local\Programs\oh-my-posh\bin"
|
||||
MKDIR "%TEMP%\\xpipe\\scriptdata\\starship" >NUL 2>NUL
|
||||
ECHO load(io.popen('oh-my-posh init cmd'):read("*a"))() > "%TEMP%\\xpipe\\scriptdata\\ohmyposh\\ohmyposh.lua"
|
||||
clink inject --quiet --profile "%TEMP%\\xpipe\\scriptdata\\ohmyposh"
|
|
@ -0,0 +1,7 @@
|
|||
if (Get-Command "winget" -ErrorAction SilentlyContinue) {
|
||||
winget install JanDeDobbeleer.OhMyPosh -s winget
|
||||
} else {
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))
|
||||
}
|
||||
$env:Path += ";$env:USERPROFILE\AppData\Local\Programs\oh-my-posh\bin"
|
||||
& ([ScriptBlock]::Create((oh-my-posh init $(oh-my-posh get shell) --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))
|
|
@ -0,0 +1,5 @@
|
|||
test -f ~/.local/bin/oh-my-posh
|
||||
if [ $? != 0 ]; then
|
||||
which brew >/dev/null 2>&1 && brew install jandedobbeleer/oh-my-posh/oh-my-posh || curl -s https://ohmyposh.dev/install.sh | bash -s;
|
||||
fi
|
||||
eval "$(~/.local/bin/oh-my-posh init $(~/.local/bin/oh-my-posh get shell))"
|
2
lang/strings/translations_en.properties
generated
2
lang/strings/translations_en.properties
generated
|
@ -740,6 +740,7 @@ shell=Shell
|
|||
hub=Hub
|
||||
#context: Computer script
|
||||
script=script
|
||||
genericScript=Generic script
|
||||
archiveName=Archive name
|
||||
compress=Compress
|
||||
compressContents=Compress contents
|
||||
|
@ -1378,3 +1379,4 @@ querying=Querying ...
|
|||
retrievedPassword=Obtained: $PASSWORD$
|
||||
refreshOpenpubkey=Refresh openpubkey identity
|
||||
refreshOpenpubkeyDescription=Run opkssh refresh to make the openpubkey identity valid again
|
||||
all=All
|
||||
|
|
2
version
2
version
|
@ -1 +1 @@
|
|||
16.0-7
|
||||
16.0-8
|
||||
|
|
Loading…
Add table
Reference in a new issue