More reformat

This commit is contained in:
crschnick 2024-02-23 05:47:23 +00:00
parent 6b7ce70cd7
commit 35dfb9cb8f
40 changed files with 112 additions and 25 deletions

View file

@ -2,8 +2,8 @@ package io.xpipe.app.browser;
import io.xpipe.app.browser.icon.DirectoryType;
import io.xpipe.app.browser.icon.FileType;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileSystem;
import lombok.Getter;

View file

@ -12,9 +12,9 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.HumanReadableFormat;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileSystem;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;

View file

@ -33,6 +33,7 @@ public class BrowserSelectionListComp extends SimpleComp {
ObservableList<FileSystem.FileEntry> list;
Function<FileSystem.FileEntry, ObservableValue<String>> nameTransformation;
public BrowserSelectionListComp(ObservableList<FileSystem.FileEntry> list) {
this(list, entry -> new SimpleStringProperty(FileNames.getFileName(entry.getPath())));
}

View file

@ -35,9 +35,12 @@ public class OpenFileSystemSavedState {
private static final Timer TIMEOUT_TIMER = new Timer(true);
private static final int STORED = 10;
@Setter
private OpenFileSystemModel model;
private String lastDirectory;
@NonNull
private ObservableList<RecentEntry> recentDirectories;

View file

@ -9,7 +9,10 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public interface DirectoryType {

View file

@ -21,6 +21,7 @@ public class LoadingOverlayComp extends Comp<CompStructure<StackPane>> {
private final Comp<?> comp;
private final ObservableValue<Boolean> showLoading;
private final ObservableValue<Number> progress;
public LoadingOverlayComp(Comp<?> comp, ObservableValue<Boolean> loading, ObservableValue<Number> progress) {
this.comp = comp;
this.showLoading = PlatformThread.sync(loading);

View file

@ -29,6 +29,7 @@ public class OsLogoComp extends SimpleComp {
public OsLogoComp(StoreEntryWrapper wrapper) {
this(wrapper, new SimpleObjectProperty<>(SystemStateComp.State.SUCCESS));
}
public OsLogoComp(StoreEntryWrapper wrapper, ObservableValue<SystemStateComp.State> state) {
this.wrapper = wrapper;
this.state = state;

View file

@ -32,6 +32,7 @@ public class TileButtonComp extends Comp<TileButtonComp.Structure> {
private final ObservableValue<String> description;
private final ObservableValue<String> icon;
private final Consumer<ActionEvent> action;
public TileButtonComp(String nameKey, String descriptionKey, String icon, Consumer<ActionEvent> action) {
this.name = AppI18n.observable(nameKey);
this.description = AppI18n.observable(descriptionKey);

View file

@ -65,8 +65,7 @@ public class StoreCategoryWrapper {
}
public boolean contains(StoreEntryWrapper entry) {
return entry.getEntry().getCategoryUuid().equals(category.getUuid())
|| containedEntries.contains(entry);
return entry.getEntry().getCategoryUuid().equals(category.getUuid()) || containedEntries.contains(entry);
}
public void select() {
@ -124,7 +123,11 @@ public class StoreCategoryWrapper {
containedEntries.setAll(StoreViewState.get().getAllEntries().stream()
.filter(entry -> {
return entry.getEntry().getCategoryUuid().equals(category.getUuid())
|| (AppPrefs.get().showChildCategoriesInParentCategory().get() && children.stream().anyMatch(storeCategoryWrapper -> storeCategoryWrapper.contains(entry)));
|| (AppPrefs.get()
.showChildCategoriesInParentCategory()
.get()
&& children.stream()
.anyMatch(storeCategoryWrapper -> storeCategoryWrapper.contains(entry)));
})
.toList());
children.setAll(StoreViewState.get().getCategories().stream()

View file

@ -173,7 +173,10 @@ public class StoreCreationComp extends DialogComp {
e -> {
try {
DataStorage.get().addStoreEntryIfNotPresent(e);
if (e.getProvider().shouldHaveChildren() && AppPrefs.get().openConnectionSearchWindowOnConnectionCreation().get()) {
if (e.getProvider().shouldHaveChildren()
&& AppPrefs.get()
.openConnectionSearchWindowOnConnectionCreation()
.get()) {
ScanAlert.showAsync(e);
}
} catch (Exception ex) {

View file

@ -48,6 +48,7 @@ public abstract class StoreEntryComp extends SimpleComp {
App.getApp().getStage().widthProperty().divide(2.2).add(-200);
protected final StoreEntryWrapper wrapper;
protected final Comp<?> content;
public StoreEntryComp(StoreEntryWrapper wrapper, Comp<?> content) {
this.wrapper = wrapper;
this.content = content;

View file

@ -24,6 +24,7 @@ public class StoreSection {
ObservableList<StoreSection> shownChildren;
int depth;
ObservableBooleanValue showDetails;
public StoreSection(
StoreEntryWrapper wrapper,
ObservableList<StoreSection> allChildren,

View file

@ -32,6 +32,7 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
private static final PseudoClass ODD = PseudoClass.getPseudoClass("odd-depth");
private static final PseudoClass EVEN = PseudoClass.getPseudoClass("even-depth");
private final StoreSection section;
@Builder.Default
private final BiConsumer<StoreSection, Comp<CompStructure<Button>>> augment = (section1, buttonComp) -> {};

View file

@ -25,14 +25,18 @@ public class StoreViewState {
private static StoreViewState INSTANCE;
private final StringProperty filter = new SimpleStringProperty();
@Getter
private final ObservableList<StoreEntryWrapper> allEntries =
FXCollections.observableList(new CopyOnWriteArrayList<>());
@Getter
private final ObservableList<StoreCategoryWrapper> categories =
FXCollections.observableList(new CopyOnWriteArrayList<>());
@Getter
private final Property<StoreCategoryWrapper> activeCategory = new SimpleObjectProperty<>();
@Getter
private StoreSection currentTopLevelSection;

View file

@ -22,10 +22,13 @@ import java.util.List;
public class AppLayoutModel {
private static AppLayoutModel INSTANCE;
@Getter
private final SavedState savedState;
@Getter
private final List<Entry> entries;
private final Property<Entry> selected;
private final ObservableValue<Entry> selectedWrapper;

View file

@ -207,8 +207,10 @@ public class AppTheme {
public static final List<Theme> ALL =
List.of(PRIMER_LIGHT, PRIMER_DARK, NORD_LIGHT, NORD_DARK, CUPERTINO_LIGHT, CUPERTINO_DARK, DRACULA);
protected final String id;
@Getter
protected final String cssId;
protected final atlantafx.base.theme.Theme theme;
static Theme getDefaultLightTheme() {

View file

@ -28,6 +28,7 @@ public class ChoiceComp<T> extends Comp<CompStructure<ComboBox<T>>> {
Property<T> value;
ObservableValue<Map<T, ObservableValue<String>>> range;
boolean includeNone;
public ChoiceComp(Property<T> value, Map<T, ObservableValue<String>> range, boolean includeNone) {
this.value = value;
this.range = new SimpleObjectProperty<>(range);

View file

@ -19,6 +19,7 @@ public class TextAreaComp extends Comp<TextAreaComp.Structure> {
private final Property<String> currentValue;
private final Property<String> lastAppliedValue;
private final boolean lazy;
public TextAreaComp(Property<String> value) {
this(value, false);
}

View file

@ -16,6 +16,7 @@ public class ErrorEvent {
private static final Map<Throwable, ErrorEventBuilder> EVENT_BASES = new ConcurrentHashMap<>();
private static final Set<Throwable> HANDLED = new CopyOnWriteArraySet<>();
@Builder.Default
private final boolean omitted = false;
@ -23,14 +24,19 @@ public class ErrorEvent {
private final boolean reportable = true;
private final Throwable throwable;
@Singular
private final List<ErrorAction> customActions;
private String description;
private boolean terminal;
@Setter
private boolean shouldSendDiagnostics;
@Singular
private List<Path> attachments;
private String email;
private String userReport;
private boolean unhandled;

View file

@ -33,6 +33,7 @@ public class LauncherCommand implements Callable<Integer> {
@CommandLine.Parameters(paramLabel = "<input>")
final List<String> inputs = List.of();
@CommandLine.Option(
names = {"--mode"},
description = "The mode to launch the daemon in or switch too",

View file

@ -106,22 +106,29 @@ public class AppPrefs {
bindDeveloperTrue(developerDisableGuiRestrictions);
private final ObjectProperty<SupportedLocale> language =
map(new SimpleObjectProperty<>(SupportedLocale.ENGLISH), "language", SupportedLocale.class);
@Getter
private final Property<InPlaceSecretValue> lockPassword = new SimpleObjectProperty<>();
@Getter
private final StringProperty lockCrypt =
mapVaultSpecific(new SimpleStringProperty(), "workspaceLock", String.class);
private final IntegerProperty editorReloadTimeout =
map(new SimpleIntegerProperty(1000), "editorReloadTimeout", Integer.class);
private final BooleanProperty confirmDeletions =
map(new SimpleBooleanProperty(true), "confirmDeletions", Boolean.class);
@Getter
private final List<AppPrefsCategory> categories;
private final AppPrefsStorageHandler globalStorageHandler = new AppPrefsStorageHandler(
AppProperties.get().getDataDir().resolve("settings").resolve("preferences.json"));
private final Map<Mapping<?>, Comp<?>> customEntries = new LinkedHashMap<>();
@Getter
private final Property<AppPrefsCategory> selectedCategory;
private final PrefsHandler extensionHandler = new PrefsHandlerImpl();
private AppPrefs() {

View file

@ -33,13 +33,11 @@ public class AppearanceCategory extends AppPrefsCategory {
.nameAndDescription("condenseConnectionDisplay")
.addToggle(prefs.condenseConnectionDisplay)
.nameAndDescription("showChildCategoriesInParentCategory")
.addToggle(prefs.showChildCategoriesInParentCategory)
)
.addToggle(prefs.showChildCategoriesInParentCategory))
.addTitle("workflow")
.sub(new OptionsBuilder()
.nameAndDescription("openConnectionSearchWindowOnConnectionCreation")
.addToggle(prefs.openConnectionSearchWindowOnConnectionCreation)
)
.addToggle(prefs.openConnectionSearchWindowOnConnectionCreation))
.addTitle("windowOptions")
.sub(new OptionsBuilder()
.nameAndDescription("windowOpacity")

View file

@ -84,13 +84,13 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.MACOS);
public boolean isAvailable() {
return getApplicationPath().isPresent();
}
@Override
public boolean isAvailable() {
return getApplicationPath().isPresent();
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.MACOS);
}
}
@ -173,11 +173,6 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
return Optional.empty();
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.WINDOWS);
}
@Override
public boolean isAvailable() {
var path = determineFromPath();
@ -188,5 +183,10 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
var installation = determineInstallation();
return installation.isPresent() && Files.exists(installation.get());
}
@Override
public boolean isSelectable() {
return OsType.getLocal().equals(OsType.WINDOWS);
}
}
}

View file

@ -127,6 +127,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
List.of(VSCODIUM_LINUX, VSCODE_LINUX, KATE, GEDIT, PLUMA, LEAFPAD, MOUSEPAD, GNOME);
List<ExternalEditorType> MACOS_EDITORS = List.of(BBEDIT, VSCODIUM_MACOS, VSCODE_MACOS, SUBLIME_MACOS, TEXT_EDIT);
List<ExternalEditorType> CROSS_PLATFORM_EDITORS = List.of(FLEET, INTELLIJ, PYCHARM, WEBSTORM, CLION);
@SuppressWarnings("TrivialFunctionalExpressionUsage")
List<ExternalEditorType> ALL = ((Supplier<List<ExternalEditorType>>) () -> {
var all = new ArrayList<ExternalEditorType>();

View file

@ -847,12 +847,12 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
}
@Override
public boolean isSelectable() {
public boolean isAvailable() {
return true;
}
@Override
public boolean isAvailable() {
public boolean isSelectable() {
return true;
}
}

View file

@ -6,7 +6,10 @@ import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.UserReportComp;
import io.xpipe.app.util.*;
import io.xpipe.app.util.DesktopHelper;
import io.xpipe.app.util.FileOpener;
import io.xpipe.app.util.OptionsBuilder;
import io.xpipe.app.util.TerminalLauncher;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.LocalStore;

View file

@ -16,6 +16,7 @@ import java.util.regex.Matcher;
public class ContextualFileReference {
private static String lastDataDir;
@NonNull
private final String path;

View file

@ -40,17 +40,25 @@ public abstract class DataStorage {
private static DataStorage INSTANCE;
protected final Path dir;
@Getter
protected final List<DataStoreCategory> storeCategories;
protected final Map<DataStoreEntry, DataStoreEntry> storeEntries;
@Getter
protected final Set<DataStoreEntry> storeEntriesSet;
protected final ReentrantLock busyIo = new ReentrantLock();
@Getter
private final List<StorageListener> listeners = new CopyOnWriteArrayList<>();
private final Map<DataStoreEntry, DataStoreEntry> storeEntriesInProgress = new ConcurrentHashMap<>();
@Getter
protected boolean loaded;
@Getter
@Setter
protected DataStoreCategory selectedCategory;

View file

@ -26,26 +26,35 @@ import java.util.stream.Collectors;
public class DataStoreEntry extends StorageElement {
Map<String, Object> storeCache = new LinkedHashMap<>();
@NonFinal
Validity validity;
@NonFinal
@Setter
JsonNode storeNode;
@Getter
@NonFinal
DataStore store;
@NonFinal
Configuration configuration;
@NonFinal
boolean expanded;
@NonFinal
boolean inRefresh;
@NonFinal
@Setter
boolean observing;
@Getter
@NonFinal
DataStoreProvider provider;
@NonFinal
UUID categoryUuid;

View file

@ -18,6 +18,7 @@ public class DataStoreSecret {
InPlaceSecretValue internalSecret;
String usedPasswordLockCrypt;
@Setter
@NonFinal
TreeNode originalNode;

View file

@ -6,7 +6,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.util.ScriptHelper;
import io.xpipe.app.util.TerminalLauncher;
import io.xpipe.core.process.*;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.LocalStore;
import io.xpipe.core.util.XPipeInstallation;

View file

@ -23,10 +23,13 @@ public enum XPipeDistributionType {
CHOCO("choco", true, () -> new ChocoUpdater());
private static XPipeDistributionType type;
@Getter
private final String id;
@Getter
private final boolean supportsUrls;
private final Supplier<UpdateHandler> updateHandlerSupplier;
private UpdateHandler updateHandler;

View file

@ -8,7 +8,10 @@ import io.xpipe.core.store.ShellStore;
import java.io.IOException;
import java.nio.file.Files;
import java.util.*;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
public class XPipeInstanceHelper {

View file

@ -10,6 +10,7 @@ public class BooleanScope implements AutoCloseable {
private boolean invert;
private boolean forcePlatform;
private boolean wait;
public BooleanScope(BooleanProperty prop) {
this.prop = prop;
}

View file

@ -11,11 +11,15 @@ import java.util.function.Function;
public class CommandBuilder {
private final List<Element> elements = new ArrayList<>();
@Getter
private final Map<String, Element> environmentVariables = new LinkedHashMap<>();
private final List<FailableConsumer<ShellControl, Exception>> setup = new ArrayList<>();
@Getter
private CountDown countDown;
@Getter
private UUID uuid;

View file

@ -7,8 +7,10 @@ public class CountDown {
private long lastMillis = -1;
private long millisecondsLeft;
@Setter
private boolean active;
@Getter
private long maxMillis;

View file

@ -81,13 +81,17 @@ public interface FileSystem extends Closeable, AutoCloseable {
Boolean executable;
long size;
String mode;
@NonNull
FileKind kind;
@NonNull
@NonFinal
String path;
@NonFinal
String extension;
@NonFinal
String name;

View file

@ -11,6 +11,7 @@ public class SecretReference {
UUID secretId;
int subId;
public SecretReference(Object store) {
this.secretId = UuidHelper.generateFromObject(store);
this.subId = 0;

View file

@ -64,6 +64,7 @@ public enum PredefinedScriptStore {
private final String name;
private final Supplier<ScriptStore> scriptStore;
private final UUID uuid;
@Setter
private DataStoreEntryRef<ScriptStore> entry;

View file

@ -27,8 +27,10 @@ import java.util.*;
public abstract class ScriptStore extends JacksonizedValue implements DataStore, StatefulDataStore<ScriptStore.State> {
protected final DataStoreEntryRef<ScriptGroupStore> group;
@Singular
protected final List<DataStoreEntryRef<ScriptStore>> scripts;
protected final String description;
public static ShellControl controlWithDefaultScripts(ShellControl pc) {