mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Reformat
This commit is contained in:
parent
dacd24a8e5
commit
06a7ef27b5
19 changed files with 143 additions and 109 deletions
|
@ -163,7 +163,9 @@ public class AppBeaconServer {
|
|||
if (notFoundHtml == null) {
|
||||
AppResources.with(AppResources.XPIPE_MODULE, "misc/api.md", file -> {
|
||||
var md = Files.readString(file);
|
||||
md = md.replaceAll(Pattern.quote( """
|
||||
md = md.replaceAll(
|
||||
Pattern.quote(
|
||||
"""
|
||||
> 400 Response
|
||||
|
||||
```json
|
||||
|
@ -171,8 +173,10 @@ public class AppBeaconServer {
|
|||
"message": "string"
|
||||
}
|
||||
```
|
||||
"""), "");
|
||||
notFoundHtml = MarkdownHelper.toHtml(md,
|
||||
"""),
|
||||
"");
|
||||
notFoundHtml = MarkdownHelper.toHtml(
|
||||
md,
|
||||
head -> {
|
||||
return head + "\n" + "<link rel=\"stylesheet\" href=\"markdown.css\">"
|
||||
+ "\n" + "<link rel=\"stylesheet\" href=\"github-dark.min.css\">"
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package io.xpipe.app.beacon.impl;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.beacon.BeaconClientException;
|
||||
import io.xpipe.beacon.api.ConnectionInfoExchange;
|
||||
import io.xpipe.core.store.StorePath;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -15,7 +16,9 @@ public class ConnectionInfoExchangeImpl extends ConnectionInfoExchange {
|
|||
public Object handle(HttpExchange exchange, Request msg) throws BeaconClientException {
|
||||
var list = new ArrayList<InfoResponse>();
|
||||
for (UUID uuid : msg.getConnections()) {
|
||||
var e = DataStorage.get().getStoreEntryIfPresent(uuid).orElseThrow(() -> new BeaconClientException("Unknown connection: " + uuid));
|
||||
var e = DataStorage.get()
|
||||
.getStoreEntryIfPresent(uuid)
|
||||
.orElseThrow(() -> new BeaconClientException("Unknown connection: " + uuid));
|
||||
|
||||
var names = DataStorage.get()
|
||||
.getStorePath(DataStorage.get()
|
||||
|
@ -24,9 +27,17 @@ public class ConnectionInfoExchangeImpl extends ConnectionInfoExchange {
|
|||
.getNames();
|
||||
var cat = new StorePath(names.subList(1, names.size()));
|
||||
|
||||
var apply = InfoResponse.builder().lastModified(e.getLastModified()).lastUsed(e.getLastUsed()).connection(e.getCategoryUuid()).category(cat).name(
|
||||
DataStorage.get().getStorePath(e)).rawData(e.getStore()).usageCategory(e.getProvider().getUsageCategory()).type(
|
||||
e.getProvider().getId()).state(e.getStorePersistentState()).build();
|
||||
var apply = InfoResponse.builder()
|
||||
.lastModified(e.getLastModified())
|
||||
.lastUsed(e.getLastUsed())
|
||||
.connection(e.getCategoryUuid())
|
||||
.category(cat)
|
||||
.name(DataStorage.get().getStorePath(e))
|
||||
.rawData(e.getStore())
|
||||
.usageCategory(e.getProvider().getUsageCategory())
|
||||
.type(e.getProvider().getId())
|
||||
.state(e.getStorePersistentState())
|
||||
.build();
|
||||
list.add(apply);
|
||||
}
|
||||
return Response.builder().infos(list).build();
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package io.xpipe.app.beacon.impl;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.beacon.api.ConnectionQueryExchange;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -13,7 +14,8 @@ public class ConnectionQueryExchangeImpl extends ConnectionQueryExchange {
|
|||
|
||||
@Override
|
||||
public Object handle(HttpExchange exchange, Request msg) {
|
||||
var catMatcher = Pattern.compile(toRegex("all connections/" + msg.getCategoryFilter().toLowerCase()));
|
||||
var catMatcher = Pattern.compile(
|
||||
toRegex("all connections/" + msg.getCategoryFilter().toLowerCase()));
|
||||
var conMatcher = Pattern.compile(toRegex(msg.getConnectionFilter().toLowerCase()));
|
||||
var typeMatcher = Pattern.compile(toRegex(msg.getTypeFilter().toLowerCase()));
|
||||
|
||||
|
@ -49,7 +51,9 @@ public class ConnectionQueryExchangeImpl extends ConnectionQueryExchange {
|
|||
found.add(storeEntry);
|
||||
}
|
||||
|
||||
return Response.builder().found(found.stream().map(entry -> entry.getUuid()).toList()).build();
|
||||
return Response.builder()
|
||||
.found(found.stream().map(entry -> entry.getUuid()).toList())
|
||||
.build();
|
||||
}
|
||||
|
||||
private String toRegex(String pattern) {
|
||||
|
|
|
@ -31,7 +31,8 @@ public class FsReadExchangeImpl extends FsReadExchange {
|
|||
var file = BlobManager.get().newBlobFile();
|
||||
try (var in = fs.openInput(msg.getPath().toString())) {
|
||||
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), size);
|
||||
try (var fileOut = Files.newOutputStream(file.resolve(msg.getPath().getFileName()))) {
|
||||
try (var fileOut =
|
||||
Files.newOutputStream(file.resolve(msg.getPath().getFileName()))) {
|
||||
fixedIn.transferTo(fileOut);
|
||||
}
|
||||
in.transferTo(OutputStream.nullOutputStream());
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
package io.xpipe.app.browser;
|
||||
|
||||
import atlantafx.base.theme.Styles;
|
||||
import io.xpipe.app.comp.store.StoreCategoryWrapper;
|
||||
import io.xpipe.app.comp.store.StoreViewState;
|
||||
import io.xpipe.app.fxcomps.SimpleComp;
|
||||
import io.xpipe.app.fxcomps.impl.FilterComp;
|
||||
import io.xpipe.app.fxcomps.impl.HorizontalComp;
|
||||
import io.xpipe.app.util.DataStoreCategoryChoiceComp;
|
||||
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.scene.layout.Region;
|
||||
|
||||
import atlantafx.base.theme.Styles;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -29,9 +31,7 @@ public final class BrowserBookmarkHeaderComp extends SimpleComp {
|
|||
StoreViewState.get().getActiveCategory(),
|
||||
this.category)
|
||||
.styleClass(Styles.LEFT_PILL);
|
||||
var filter = new FilterComp(this.filter)
|
||||
.styleClass(Styles.RIGHT_PILL)
|
||||
.hgrow();
|
||||
var filter = new FilterComp(this.filter).styleClass(Styles.RIGHT_PILL).hgrow();
|
||||
|
||||
var top = new HorizontalComp(List.of(category, filter))
|
||||
.apply(struc -> struc.get().setFillHeight(true))
|
||||
|
|
|
@ -50,7 +50,10 @@ public class BrowserSelectionListComp extends SimpleComp {
|
|||
|
||||
@Override
|
||||
protected Region createSimple() {
|
||||
var c = new ListBoxViewComp<>(list, list, entry -> {
|
||||
var c = new ListBoxViewComp<>(
|
||||
list,
|
||||
list,
|
||||
entry -> {
|
||||
return Comp.of(() -> {
|
||||
var image = PrettyImageHelper.ofFixedSizeSquare(entry.getIcon(), 24)
|
||||
.createRegion();
|
||||
|
|
|
@ -97,7 +97,10 @@ public class BrowserWelcomeComp extends SimpleComp {
|
|||
var storeList = new VBox();
|
||||
storeList.setSpacing(8);
|
||||
|
||||
var listBox = new ListBoxViewComp<>(list, list, e -> {
|
||||
var listBox = new ListBoxViewComp<>(
|
||||
list,
|
||||
list,
|
||||
e -> {
|
||||
var disable = new SimpleBooleanProperty();
|
||||
var entryButton = entryButton(e, disable);
|
||||
var dirButton = dirButton(e, disable);
|
||||
|
@ -109,7 +112,8 @@ public class BrowserWelcomeComp extends SimpleComp {
|
|||
.prefHeightProperty()
|
||||
.bind(struc.get().heightProperty());
|
||||
});
|
||||
}, true)
|
||||
},
|
||||
true)
|
||||
.apply(struc -> {
|
||||
VBox vBox = (VBox) struc.get().getContent();
|
||||
vBox.setSpacing(10);
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.xpipe.app.fxcomps.CompStructure;
|
|||
import io.xpipe.app.fxcomps.SimpleCompStructure;
|
||||
import io.xpipe.app.fxcomps.util.DerivedObservableList;
|
||||
import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.collections.ListChangeListener;
|
||||
|
@ -32,7 +33,8 @@ public class ListBoxViewComp<T> extends Comp<CompStructure<ScrollPane>> {
|
|||
private final int limit = Integer.MAX_VALUE;
|
||||
private final boolean scrollBar;
|
||||
|
||||
public ListBoxViewComp(ObservableList<T> shown, ObservableList<T> all, Function<T, Comp<?>> compFunction, boolean scrollBar) {
|
||||
public ListBoxViewComp(
|
||||
ObservableList<T> shown, ObservableList<T> all, Function<T, Comp<?>> compFunction, boolean scrollBar) {
|
||||
this.shown = PlatformThread.sync(shown);
|
||||
this.all = PlatformThread.sync(all);
|
||||
this.compFunction = compFunction;
|
||||
|
@ -64,10 +66,13 @@ public class ListBoxViewComp<T> extends Comp<CompStructure<ScrollPane>> {
|
|||
scroll.skinProperty().subscribe(newValue -> {
|
||||
if (newValue != null) {
|
||||
ScrollBar bar = (ScrollBar) scroll.lookup(".scroll-bar:vertical");
|
||||
bar.opacityProperty().bind(Bindings.createDoubleBinding(() -> {
|
||||
bar.opacityProperty()
|
||||
.bind(Bindings.createDoubleBinding(
|
||||
() -> {
|
||||
var v = bar.getVisibleAmount();
|
||||
return v < 1.0 ? 1.0 : 0.0;
|
||||
}, bar.visibleAmountProperty()));
|
||||
},
|
||||
bar.visibleAmountProperty()));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -28,29 +28,22 @@ public class StoreCreationMenu {
|
|||
|
||||
menu.getItems().add(category("addHost", "mdi2h-home-plus", DataStoreCreationCategory.HOST, "ssh"));
|
||||
|
||||
menu.getItems()
|
||||
.add(category("addDesktop", "mdi2c-camera-plus", DataStoreCreationCategory.DESKTOP, null));
|
||||
menu.getItems().add(category("addDesktop", "mdi2c-camera-plus", DataStoreCreationCategory.DESKTOP, null));
|
||||
|
||||
menu.getItems().add(category("addShell", "mdi2t-text-box-multiple", DataStoreCreationCategory.SHELL, null));
|
||||
|
||||
menu.getItems()
|
||||
.add(category("addShell", "mdi2t-text-box-multiple", DataStoreCreationCategory.SHELL, null));
|
||||
.add(category("addScript", "mdi2s-script-text-outline", DataStoreCreationCategory.SCRIPT, "script"));
|
||||
|
||||
menu.getItems().add(category("addService", "mdi2c-cloud-braces", DataStoreCreationCategory.SERVICE, null));
|
||||
|
||||
menu.getItems()
|
||||
.add(category(
|
||||
"addScript", "mdi2s-script-text-outline", DataStoreCreationCategory.SCRIPT, "script"));
|
||||
.add(category("addTunnel", "mdi2v-vector-polyline-plus", DataStoreCreationCategory.TUNNEL, null));
|
||||
|
||||
menu.getItems()
|
||||
.add(category("addService", "mdi2c-cloud-braces", DataStoreCreationCategory.SERVICE, null));
|
||||
.add(category("addCommand", "mdi2c-code-greater-than", DataStoreCreationCategory.COMMAND, "cmd"));
|
||||
|
||||
menu.getItems()
|
||||
.add(category(
|
||||
"addTunnel", "mdi2v-vector-polyline-plus", DataStoreCreationCategory.TUNNEL, null));
|
||||
|
||||
menu.getItems()
|
||||
.add(category(
|
||||
"addCommand", "mdi2c-code-greater-than", DataStoreCreationCategory.COMMAND, "cmd"));
|
||||
|
||||
menu.getItems()
|
||||
.add(category("addDatabase", "mdi2d-database-plus", DataStoreCreationCategory.DATABASE, null));
|
||||
menu.getItems().add(category("addDatabase", "mdi2d-database-plus", DataStoreCreationCategory.DATABASE, null));
|
||||
}
|
||||
|
||||
private static MenuItem category(
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.xpipe.app.comp.base.ListBoxViewComp;
|
|||
import io.xpipe.app.comp.base.MultiContentComp;
|
||||
import io.xpipe.app.fxcomps.Comp;
|
||||
import io.xpipe.app.fxcomps.SimpleComp;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.scene.layout.Region;
|
||||
|
|
|
@ -134,7 +134,9 @@ public class StoreSectionComp extends Comp<CompStructure<VBox>> {
|
|||
section.getWrapper().getExpanded(),
|
||||
section.getAllChildren().getList());
|
||||
var content = new ListBoxViewComp<>(
|
||||
listSections.getList(), section.getAllChildren().getList(), (StoreSection e) -> {
|
||||
listSections.getList(),
|
||||
section.getAllChildren().getList(),
|
||||
(StoreSection e) -> {
|
||||
return StoreSection.customSection(e, false).apply(GrowAugment.create(true, false));
|
||||
},
|
||||
false)
|
||||
|
@ -151,8 +153,7 @@ public class StoreSectionComp extends Comp<CompStructure<VBox>> {
|
|||
var full = new VerticalComp(List.of(
|
||||
topEntryList,
|
||||
Comp.separator().hide(expanded.not()),
|
||||
content
|
||||
.styleClass("children-content")
|
||||
content.styleClass("children-content")
|
||||
.hide(Bindings.or(
|
||||
Bindings.not(section.getWrapper().getExpanded()),
|
||||
Bindings.size(section.getShownChildren().getList())
|
||||
|
|
|
@ -9,6 +9,7 @@ import io.xpipe.app.fxcomps.impl.IconButtonComp;
|
|||
import io.xpipe.app.fxcomps.impl.PrettyImageHelper;
|
||||
import io.xpipe.app.fxcomps.impl.VerticalComp;
|
||||
import io.xpipe.app.storage.DataStoreColor;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
@ -133,15 +134,16 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
|
|||
section.getAllChildren().getList())
|
||||
: section.getShownChildren();
|
||||
var content = new ListBoxViewComp<>(
|
||||
listSections.getList(), section.getAllChildren().getList(), (StoreSection e) -> {
|
||||
listSections.getList(),
|
||||
section.getAllChildren().getList(),
|
||||
(StoreSection e) -> {
|
||||
return new StoreSectionMiniComp(e, this.augment, this.action);
|
||||
},
|
||||
section.getWrapper() == null)
|
||||
.minHeight(0)
|
||||
.hgrow();
|
||||
|
||||
list.add(content
|
||||
.styleClass("children-content")
|
||||
list.add(content.styleClass("children-content")
|
||||
.hide(Bindings.or(
|
||||
Bindings.not(expanded),
|
||||
Bindings.size(section.getAllChildren().getList()).isEqualTo(0))));
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.xpipe.app.core.window;
|
|||
|
||||
import io.xpipe.app.core.App;
|
||||
import io.xpipe.core.process.OsType;
|
||||
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.stage.Stage;
|
||||
|
|
|
@ -233,5 +233,4 @@ public interface DataStoreProvider {
|
|||
}
|
||||
|
||||
List<Class<?>> getStoreClasses();
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,10 @@ public class DataStoreListChoiceComp<T extends DataStore> extends SimpleComp {
|
|||
|
||||
@Override
|
||||
protected Region createSimple() {
|
||||
var list = new ListBoxViewComp<>(selectedList, selectedList, t -> {
|
||||
var list = new ListBoxViewComp<>(
|
||||
selectedList,
|
||||
selectedList,
|
||||
t -> {
|
||||
if (t == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,8 @@ public class StoreCategoryComp extends SimpleComp {
|
|||
var l = category.getChildren()
|
||||
.sorted(Comparator.comparing(storeCategoryWrapper ->
|
||||
storeCategoryWrapper.nameProperty().getValue().toLowerCase(Locale.ROOT)));
|
||||
var children = new ListBoxViewComp<>(l, l, storeCategoryWrapper -> new StoreCategoryComp(storeCategoryWrapper), false);
|
||||
var children =
|
||||
new ListBoxViewComp<>(l, l, storeCategoryWrapper -> new StoreCategoryComp(storeCategoryWrapper), false);
|
||||
|
||||
var emptyBinding = Bindings.isEmpty(category.getChildren());
|
||||
var v = new VerticalComp(List.of(categoryButton, children.hide(emptyBinding)));
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.xpipe.beacon.api;
|
|||
|
||||
import io.xpipe.beacon.BeaconInterface;
|
||||
import io.xpipe.core.store.StorePath;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.NonNull;
|
||||
import lombok.Value;
|
||||
|
@ -34,7 +35,6 @@ public class ConnectionInfoExchange extends BeaconInterface<ConnectionInfoExchan
|
|||
List<@NonNull InfoResponse> infos;
|
||||
}
|
||||
|
||||
|
||||
@Jacksonized
|
||||
@Builder
|
||||
@Value
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.xpipe.beacon.api;
|
||||
|
||||
import io.xpipe.beacon.BeaconInterface;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.NonNull;
|
||||
import lombok.Value;
|
||||
|
|
Loading…
Reference in a new issue