Refactor and cleanup

This commit is contained in:
crschnick 2023-06-16 03:38:39 +00:00
parent 6af56c451a
commit 0274ade547
299 changed files with 1634 additions and 1335 deletions

View file

@ -98,14 +98,14 @@ public interface DataSource {
/**
* Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source.
*/
public static DataSource createAnonymous(String type, Path path) {
static DataSource createAnonymous(String type, Path path) {
return create(null, type, path);
}
/**
* Wrapper for {@link #create(DataSourceId, String, InputStream)}.
*/
public static DataSource create(DataSourceId id, String type, Path path) {
static DataSource create(DataSourceId id, String type, Path path) {
try (var in = Files.newInputStream(path)) {
return create(id, type, in);
} catch (IOException e) {
@ -116,14 +116,14 @@ public interface DataSource {
/**
* Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source.
*/
public static DataSource createAnonymous(String type, URL url) {
static DataSource createAnonymous(String type, URL url) {
return create(null, type, url);
}
/**
* Wrapper for {@link #create(DataSourceId, String, InputStream)}.
*/
public static DataSource create(DataSourceId id, String type, URL url) {
static DataSource create(DataSourceId id, String type, URL url) {
try (var in = url.openStream()) {
return create(id, type, in);
} catch (IOException e) {
@ -134,7 +134,7 @@ public interface DataSource {
/**
* Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source.
*/
public static DataSource createAnonymous(String type, InputStream in) {
static DataSource createAnonymous(String type, InputStream in) {
return create(null, type, in);
}
@ -146,7 +146,7 @@ public interface DataSource {
* @param in the input stream to read
* @return a {@link DataSource} instances that can be used to access the underlying data
*/
public static DataSource create(DataSourceId id, String type, InputStream in) {
static DataSource create(DataSourceId id, String type, InputStream in) {
return DataSourceImpl.create(id, type, in);
}
@ -156,7 +156,7 @@ public interface DataSource {
* @param id the data source id
* @return a {@link DataSource} instances that can be used to access the underlying data
*/
public static DataSource create(DataSourceId id, io.xpipe.core.source.DataSource<?> source) {
static DataSource create(DataSourceId id, io.xpipe.core.source.DataSource<?> source) {
return DataSourceImpl.create(id, source);
}
@ -169,7 +169,7 @@ public interface DataSource {
* @param in the data store to add
* @return a {@link DataSource} instances that can be used to access the underlying data
*/
public static DataSource create(DataSourceId id, String type, DataStore in) {
static DataSource create(DataSourceId id, String type, DataStore in) {
return DataSourceImpl.create(id, type, in);
}
@ -177,7 +177,7 @@ public interface DataSource {
void appendTo(DataSource target);
public io.xpipe.core.source.DataSource<?> getInternalSource();
io.xpipe.core.source.DataSource<?> getInternalSource();
/**
* Returns the id of this data source.

View file

@ -15,7 +15,7 @@ import io.xpipe.core.source.DataSourceId;
*/
public interface DataTableAccumulator {
public static DataTableAccumulator create(TupleType type) {
static DataTableAccumulator create(TupleType type) {
return new DataTableAccumulatorImpl(type);
}

View file

@ -137,14 +137,14 @@ public final class XPipeApiConnection extends BeaconConnection {
}
@FunctionalInterface
public static interface Handler {
public interface Handler {
void handle(BeaconConnection con) throws Exception;
void handle(BeaconConnection con);
}
@FunctionalInterface
public static interface Mapper<T> {
public interface Mapper<T> {
T handle(BeaconConnection con) throws Exception;
T handle(BeaconConnection con);
}
}

View file

@ -28,9 +28,9 @@ public class DataTableAccumulatorImpl implements DataTableAccumulator {
private final XPipeApiConnection connection;
private final TupleType type;
private int rows;
private InternalStreamStore store;
private final InternalStreamStore store;
private TupleType writtenDescriptor;
private OutputStream bodyOutput;
private final OutputStream bodyOutput;
public DataTableAccumulatorImpl(TupleType type) {
this.type = type;

View file

@ -70,7 +70,6 @@ public class DataTableImpl extends DataSourceImpl implements DataTable {
public Iterator<TupleNode> iterator() {
return new TableIterator();
}
;
private class TableIterator implements Iterator<TupleNode> {

View file

@ -19,7 +19,8 @@ public class BrowserAlerts {
return AppWindowHelper.showBlockingAlert(alert -> {
alert.setTitle(AppI18n.get("moveAlertTitle"));
alert.setHeaderText(AppI18n.get("moveAlertHeader", source.size(), target.getPath()));
alert.getDialogPane().setContent(AppWindowHelper.alertContentText(getSelectedElementsString(source)));
alert.getDialogPane()
.setContent(AppWindowHelper.alertContentText(getSelectedElementsString(source)));
alert.setAlertType(Alert.AlertType.CONFIRMATION);
})
.map(b -> b.getButtonData().isDefaultButton())
@ -34,7 +35,8 @@ public class BrowserAlerts {
return AppWindowHelper.showBlockingAlert(alert -> {
alert.setTitle(AppI18n.get("deleteAlertTitle"));
alert.setHeaderText(AppI18n.get("deleteAlertHeader", source.size()));
alert.getDialogPane().setContent(AppWindowHelper.alertContentText(getSelectedElementsString(source)));
alert.getDialogPane()
.setContent(AppWindowHelper.alertContentText(getSelectedElementsString(source)));
alert.setAlertType(Alert.AlertType.CONFIRMATION);
})
.map(b -> b.getButtonData().isDefaultButton())
@ -43,7 +45,8 @@ public class BrowserAlerts {
private static String getSelectedElementsString(List<FileSystem.FileEntry> source) {
var namesHeader = AppI18n.get("selectedElements");
var names = namesHeader + "\n" + source.stream().limit(10).map(entry -> "- " + entry.getPath()).collect(Collectors.joining("\n"));
var names = namesHeader + "\n"
+ source.stream().limit(10).map(entry -> "- " + entry.getPath()).collect(Collectors.joining("\n"));
if (source.size() > 10) {
names += "\n+ " + (source.size() - 10) + " ...";
}

View file

@ -45,7 +45,7 @@ final class BrowserBookmarkList extends SimpleComp {
@Override
protected Region createSimple() {
var root = StoreEntryTree.createTree();
var view = new TreeView<StoreEntryWrapper>(root);
var view = new TreeView<>(root);
view.setShowRoot(false);
view.getStyleClass().add("bookmark-list");
view.setCellFactory(param -> {
@ -138,7 +138,7 @@ final class BrowserBookmarkList extends SimpleComp {
});
event.consume();
});
var icon = new SimpleObjectProperty<String>("mdal-keyboard_arrow_right");
var icon = new SimpleObjectProperty<>("mdal-keyboard_arrow_right");
getPseudoClassStates().addListener((SetChangeListener<? super PseudoClass>) change -> {
if (change.getSet().contains(PseudoClass.getPseudoClass("expanded"))) {
icon.set("mdal-keyboard_arrow_down");

View file

@ -25,9 +25,7 @@ public class BrowserBreadcrumbBar extends SimpleComp {
@Override
protected Region createSimple() {
Callback<Breadcrumbs.BreadCrumbItem<String>, ButtonBase> crumbFactory = crumb -> {
var name = crumb.getValue().equals("/")
? "/"
: FileNames.getFileName(crumb.getValue());
var name = crumb.getValue().equals("/") ? "/" : FileNames.getFileName(crumb.getValue());
var btn = new Button(name, null);
btn.setMnemonicParsing(false);
btn.setFocusTraversable(false);

View file

@ -21,7 +21,7 @@ public class BrowserClipboard {
List<FileSystem.FileEntry> entries;
}
public static Property<Instance> currentCopyClipboard = new SimpleObjectProperty<>();
public static final Property<Instance> currentCopyClipboard = new SimpleObjectProperty<>();
public static Instance currentDragClipboard;
@SneakyThrows

View file

@ -22,14 +22,16 @@ import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ListChangeListener;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.input.DragEvent;
import javafx.scene.layout.*;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import java.util.HashMap;
import java.util.Map;
@ -252,12 +254,9 @@ public class BrowserComp extends SimpleComp {
var label = new Label(model.getName());
label.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
label.addEventHandler(DragEvent.DRAG_ENTERED, new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent mouseEvent) {
Platform.runLater(() -> tabs.getSelectionModel().select(tab));
}
});
label.addEventHandler(
DragEvent.DRAG_ENTERED,
mouseEvent -> Platform.runLater(() -> tabs.getSelectionModel().select(tab)));
label.graphicProperty()
.bind(Bindings.createObjectBinding(

View file

@ -26,7 +26,10 @@ final class BrowserContextMenu extends ContextMenu {
AppFont.normal(this.getStyleableNode());
var empty = source == null;
var selected = new ArrayList<>(empty ? List.of(new BrowserEntry(model.getCurrentDirectory(), model.getFileList(), false)) : model.getFileList().getSelection());
var selected = new ArrayList<>(
empty
? List.of(new BrowserEntry(model.getCurrentDirectory(), model.getFileList(), false))
: model.getFileList().getSelection());
if (source != null && !selected.contains(source)) {
selected.add(source);
}

View file

@ -49,19 +49,26 @@ public class BrowserFileListCompEntry {
}
if (t.getButton() == MouseButton.PRIMARY && t.isShiftDown()) {
var tv = ((TableView<BrowserEntry>) row.getParent().getParent().getParent().getParent());
var tv = ((TableView<BrowserEntry>)
row.getParent().getParent().getParent().getParent());
var all = tv.getItems();
var min = tv.getSelectionModel().getSelectedIndices().stream().mapToInt(value -> value).min().orElse(1);
var max = tv.getSelectionModel().getSelectedIndices().stream().mapToInt(value -> value).max().orElse(all.size() - 1);
var min = tv.getSelectionModel().getSelectedIndices().stream()
.mapToInt(value -> value)
.min()
.orElse(1);
var max = tv.getSelectionModel().getSelectedIndices().stream()
.mapToInt(value -> value)
.max()
.orElse(all.size() - 1);
var end = tv.getSelectionModel().getFocusedIndex();
var start = end > min ? min : max;
tv.getSelectionModel().selectRange(Math.min(start, end), Math.max(start, end) + 1);
return;
}
}
public boolean isSynthetic() {
return item != null && item.getRawFileEntry().equals(model.getFileSystemModel().getCurrentParentDirectory());
return item != null
&& item.getRawFileEntry().equals(model.getFileSystemModel().getCurrentParentDirectory());
}
private boolean acceptsDrop(DragEvent event) {
@ -80,8 +87,10 @@ public class BrowserFileListCompEntry {
// Prevent drag and drops of files into the current directory
if (BrowserClipboard.currentDragClipboard
.getBaseDirectory().getPath()
.equals(model.getFileSystemModel().getCurrentDirectory().getPath()) && (item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY)) {
.getBaseDirectory()
.getPath()
.equals(model.getFileSystemModel().getCurrentDirectory().getPath())
&& (item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY)) {
return false;
}
@ -152,7 +161,8 @@ public class BrowserFileListCompEntry {
}
private void acceptDrag(DragEvent event) {
model.getDraggedOverEmpty().setValue(item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY);
model.getDraggedOverEmpty()
.setValue(item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY);
model.getDraggedOverDirectory().setValue(item);
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
@ -205,7 +215,8 @@ public class BrowserFileListCompEntry {
return;
}
var tv = ((TableView<BrowserEntry>) row.getParent().getParent().getParent().getParent());
var tv = ((TableView<BrowserEntry>)
row.getParent().getParent().getParent().getParent());
tv.getSelectionModel().select(item);
}

View file

@ -38,7 +38,7 @@ public final class BrowserFileListModel {
private final ObservableList<FileSystem.FileEntry> selectedRaw =
BindingsHelper.mappedContentBinding(selection, entry -> entry.getRawFileEntry());
private final Property<BrowserEntry> draggedOverDirectory = new SimpleObjectProperty<BrowserEntry>();
private final Property<BrowserEntry> draggedOverDirectory = new SimpleObjectProperty<>();
private final Property<Boolean> draggedOverEmpty = new SimpleBooleanProperty();
private final Property<BrowserEntry> editing = new SimpleObjectProperty<>();
@ -113,7 +113,8 @@ public final class BrowserFileListModel {
}
public void onDoubleClick(BrowserEntry entry) {
if (entry.getRawFileEntry().getKind() != FileKind.DIRECTORY && getMode().equals(BrowserModel.Mode.SINGLE_FILE_CHOOSER)) {
if (entry.getRawFileEntry().getKind() != FileKind.DIRECTORY
&& getMode().equals(BrowserModel.Mode.SINGLE_FILE_CHOOSER)) {
getFileSystemModel().getBrowserModel().finishChooser();
return;
}

View file

@ -35,7 +35,7 @@ public class BrowserFileOverviewComp extends SimpleComp {
event.consume();
});
l.setAlignment(Pos.CENTER_LEFT);
GrowAugment.create(true,false).augment(l);
GrowAugment.create(true, false).augment(l);
return l;
});
};

View file

@ -34,7 +34,7 @@ public class BrowserModel {
}
@Getter
public static enum Mode {
public enum Mode {
BROWSER(false, true, true, true),
SINGLE_FILE_CHOOSER(true, false, true, false),
SINGLE_FILE_SAVE(true, false, true, false),
@ -80,7 +80,8 @@ public class BrowserModel {
var map = new LinkedHashMap<UUID, String>();
openFileSystems.forEach(model -> {
var storageEntry = DataStorage.get().getStoreEntryIfPresent(model.getStore());
storageEntry.ifPresent(entry -> map.put(entry.getUuid(), model.getCurrentPath().get()));
storageEntry.ifPresent(
entry -> map.put(entry.getUuid(), model.getCurrentPath().get()));
});
// Don't override state if it is empty

View file

@ -51,11 +51,16 @@ public class BrowserNavBar extends SimpleComp {
.styleClass("path-text")
.apply(struc -> {
SimpleChangeListener.apply(struc.get().focusedProperty(), val -> {
struc.get().pseudoClassStateChanged(INVISIBLE, !val && !model.getInOverview().get());
struc.get()
.pseudoClassStateChanged(
INVISIBLE,
!val && !model.getInOverview().get());
});
SimpleChangeListener.apply(model.getInOverview(), val -> {
struc.get().pseudoClassStateChanged(INVISIBLE, !val && !struc.get().isFocused());
struc.get()
.pseudoClassStateChanged(
INVISIBLE, !val && !struc.get().isFocused());
});
struc.get().setOnMouseClicked(event -> {
@ -69,9 +74,11 @@ public class BrowserNavBar extends SimpleComp {
});
struc.get().setPromptText("Overview of " + model.getName());
}).shortcut(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN), s -> {
})
.shortcut(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN), s -> {
s.get().requestFocus();
}).accessibleText("Current path");
})
.accessibleText("Current path");
var graphic = Bindings.createStringBinding(
() -> {
@ -90,10 +97,9 @@ public class BrowserNavBar extends SimpleComp {
graphicButton.setAccessibleText("Directory options");
graphicButton.getStyleClass().add(Styles.LEFT_PILL);
graphicButton.getStyleClass().add("path-graphic-button");
new ContextMenuAugment<>(
event -> event.getButton() == MouseButton.PRIMARY, () -> {
return model.getInOverview().get() ? null : new BrowserContextMenu(model, null);
})
new ContextMenuAugment<>(event -> event.getButton() == MouseButton.PRIMARY, () -> {
return model.getInOverview().get() ? null : new BrowserContextMenu(model, null);
})
.augment(new SimpleCompStructure<>(graphicButton));
var breadcrumbs = new BrowserBreadcrumbBar(model).grow(false, true);
@ -104,17 +110,26 @@ public class BrowserNavBar extends SimpleComp {
.apply(struc -> {
var t = struc.get().getChildren().get(0);
var b = struc.get().getChildren().get(1);
b.visibleProperty().bind(Bindings.createBooleanBinding(() -> {
return !t.isFocused() && !model.getInOverview().get();
}, t.focusedProperty(), model.getInOverview()));
b.visibleProperty()
.bind(Bindings.createBooleanBinding(
() -> {
return !t.isFocused()
&& !model.getInOverview().get();
},
t.focusedProperty(),
model.getInOverview()));
})
.grow(false, true);
var topBox = new HorizontalComp(List.of(Comp.of(() -> graphicButton), stack))
.apply(struc -> struc.get().setAlignment(Pos.CENTER_LEFT))
.apply(struc -> {
((Region) struc.get().getChildren().get(0)).minHeightProperty().bind(((Region) struc.get().getChildren().get(1)).heightProperty());
((Region) struc.get().getChildren().get(0)).maxHeightProperty().bind(((Region) struc.get().getChildren().get(1)).heightProperty());
((Region) struc.get().getChildren().get(0))
.minHeightProperty()
.bind(((Region) struc.get().getChildren().get(1)).heightProperty());
((Region) struc.get().getChildren().get(0))
.maxHeightProperty()
.bind(((Region) struc.get().getChildren().get(1)).heightProperty());
})
.apply(struc -> {
struc.get().setPickOnBounds(false);

View file

@ -33,7 +33,9 @@ public class BrowserOverviewComp extends SimpleComp {
.map(s -> FileSystem.FileEntry.ofDirectory(model.getFileSystem(), s))
.filter(entry -> {
try {
var b = sc.getShellDialect().directoryExists(sc, entry.getPath()).executeAndCheck();
var b = sc.getShellDialect()
.directoryExists(sc, entry.getPath())
.executeAndCheck();
return b;
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
@ -42,7 +44,8 @@ public class BrowserOverviewComp extends SimpleComp {
})
.toList();
var commonOverview = new BrowserFileOverviewComp(model, FXCollections.observableArrayList(common), false);
var commonPane = new SimpleTitledPaneComp(AppI18n.observable("common"), commonOverview).apply(struc -> VBox.setVgrow(struc.get(), Priority.NEVER));
var commonPane = new SimpleTitledPaneComp(AppI18n.observable("common"), commonOverview)
.apply(struc -> VBox.setVgrow(struc.get(), Priority.NEVER));
var roots = sc.getShellDialect()
.listRoots(sc)

View file

@ -22,36 +22,44 @@ public class BrowserStatusBarComp extends SimpleComp {
@Override
protected Region createSimple() {
var cc = PlatformThread.sync(BrowserClipboard.currentCopyClipboard);
var ccCount = Bindings.createStringBinding(() -> {
if (cc.getValue() != null && cc.getValue().getEntries().size() > 0) {
return cc.getValue().getEntries().size() + " file" + (cc.getValue().getEntries().size() > 1 ? "s" : "") + " in clipboard";
} else {
return null;
}
}, cc);
var ccCount = Bindings.createStringBinding(
() -> {
if (cc.getValue() != null && cc.getValue().getEntries().size() > 0) {
return cc.getValue().getEntries().size() + " file"
+ (cc.getValue().getEntries().size() > 1 ? "s" : "") + " in clipboard";
} else {
return null;
}
},
cc);
var selectedCount = PlatformThread.sync(Bindings.createIntegerBinding(() -> {
return model.getFileList().getSelection().size();
}, model.getFileList().getSelection()));
var selectedCount = PlatformThread.sync(Bindings.createIntegerBinding(
() -> {
return model.getFileList().getSelection().size();
},
model.getFileList().getSelection()));
var allCount = PlatformThread.sync(Bindings.createIntegerBinding(() -> {
return (int) model.getFileList().getAll().getValue().stream().filter(entry -> !entry.isSynthetic()).count();
}, model.getFileList().getAll()));
var allCount = PlatformThread.sync(Bindings.createIntegerBinding(
() -> {
return (int) model.getFileList().getAll().getValue().stream()
.filter(entry -> !entry.isSynthetic())
.count();
},
model.getFileList().getAll()));
var selectedComp = new LabelComp(Bindings.createStringBinding(() -> {
if (selectedCount.getValue().intValue() == 0) {
return null;
} else {
return selectedCount.getValue() + " / " + allCount.getValue() + " selected";
}
}, selectedCount, allCount));
var selectedComp = new LabelComp(Bindings.createStringBinding(
() -> {
if (selectedCount.getValue().intValue() == 0) {
return null;
} else {
return selectedCount.getValue() + " / " + allCount.getValue() + " selected";
}
},
selectedCount,
allCount));
var bar = new ToolBar();
bar.getItems().setAll(
new LabelComp(ccCount).createRegion(),
new Spacer(),
selectedComp.createRegion()
);
bar.getItems().setAll(new LabelComp(ccCount).createRegion(), new Spacer(), selectedComp.createRegion());
bar.getStyleClass().add("status-bar");
bar.setOnDragDetected(event -> {
event.consume();

View file

@ -41,7 +41,9 @@ public class BrowserTransferComp extends SimpleComp {
new StackComp(List.of(background)).grow(true, true).styleClass("download-background");
var binding = BindingsHelper.mappedContentBinding(stage.getItems(), item -> item.getFileEntry());
var list = new BrowserSelectionListComp(binding).apply(struc -> struc.get().setMinHeight(150)).grow(false, true);
var list = new BrowserSelectionListComp(binding)
.apply(struc -> struc.get().setMinHeight(150))
.grow(false, true);
var dragNotice = new LabelComp(AppI18n.observable("dragFiles"))
.apply(struc -> struc.get().setGraphic(new FontIcon("mdi2e-export")))
.hide(BindingsHelper.persist(Bindings.isEmpty(stage.getItems())))
@ -61,59 +63,64 @@ public class BrowserTransferComp extends SimpleComp {
var listBox = new VerticalComp(List.of(list, dragNotice));
var stack = new LoadingOverlayComp(
new StackComp(List.of(backgroundStack, listBox, clearPane)).apply(DragPseudoClassAugment.create()).apply(struc -> {
struc.get().setOnDragOver(event -> {
// Accept drops from inside the app window
if (event.getGestureSource() != null && event.getGestureSource() != struc.get()) {
event.acceptTransferModes(TransferMode.ANY);
event.consume();
}
});
struc.get().setOnDragDropped(event -> {
if (event.getGestureSource() != null) {
var files = BrowserClipboard.retrieveDrag(event.getDragboard())
.getEntries();
stage.drop(files);
event.setDropCompleted(true);
event.consume();
}
});
struc.get().setOnDragDetected(event -> {
if (stage.getDownloading().get()) {
return;
}
new StackComp(List.of(backgroundStack, listBox, clearPane))
.apply(DragPseudoClassAugment.create())
.apply(struc -> {
struc.get().setOnDragOver(event -> {
// Accept drops from inside the app window
if (event.getGestureSource() != null && event.getGestureSource() != struc.get()) {
event.acceptTransferModes(TransferMode.ANY);
event.consume();
}
});
struc.get().setOnDragDropped(event -> {
if (event.getGestureSource() != null) {
var files = BrowserClipboard.retrieveDrag(event.getDragboard())
.getEntries();
stage.drop(files);
event.setDropCompleted(true);
event.consume();
}
});
struc.get().setOnDragDetected(event -> {
if (stage.getDownloading().get()) {
return;
}
var files = stage.getItems().stream()
.map(item -> {
try {
return item.getLocalFile().toRealPath().toFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.toList();
Dragboard db = struc.get().startDragAndDrop(TransferMode.MOVE);
var cc = new ClipboardContent();
cc.putFiles(files);
db.setContent(cc);
var files = stage.getItems().stream()
.map(item -> {
try {
return item.getLocalFile()
.toRealPath()
.toFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.toList();
Dragboard db = struc.get().startDragAndDrop(TransferMode.MOVE);
var cc = new ClipboardContent();
cc.putFiles(files);
db.setContent(cc);
var image = BrowserSelectionListComp.snapshot(FXCollections.observableList(stage.getItems().stream()
.map(item -> item.getFileEntry())
.toList()));
db.setDragView(image, -20, 15);
var image = BrowserSelectionListComp.snapshot(
FXCollections.observableList(stage.getItems().stream()
.map(item -> item.getFileEntry())
.toList()));
db.setDragView(image, -20, 15);
event.setDragDetect(true);
event.consume();
});
struc.get().setOnDragDone(event -> {
if (!event.isAccepted()) {
return;
}
event.setDragDetect(true);
event.consume();
});
struc.get().setOnDragDone(event -> {
if (!event.isAccepted()) {
return;
}
stage.getItems().clear();
event.consume();
});
}),
stage.getItems().clear();
event.consume();
});
}),
PlatformThread.sync(stage.getDownloading()));
return stack.createRegion();
}

View file

@ -101,8 +101,7 @@ public class FileSystemHelper {
Files.isExecutable(file),
Files.size(file),
null,
Files.isDirectory(file) ? FileKind.DIRECTORY : FileKind.FILE
);
Files.isDirectory(file) ? FileKind.DIRECTORY : FileKind.FILE);
}
public static void dropLocalFilesInto(FileSystem.FileEntry entry, List<Path> files) {
@ -122,7 +121,7 @@ public class FileSystemHelper {
}
}
public static void delete(List<FileSystem.FileEntry> files) throws Exception {
public static void delete(List<FileSystem.FileEntry> files) {
if (files.size() == 0) {
return;
}

View file

@ -34,7 +34,8 @@ public class OpenFileSystemCache {
public boolean isApplicationInPath(String app) {
if (!installedApplications.containsKey(app)) {
try {
var b = ApplicationHelper.isInPath(model.getFileSystem().getShell().orElseThrow(), app);
var b = ApplicationHelper.isInPath(
model.getFileSystem().getShell().orElseThrow(), app);
installedApplications.put(app, b);
} catch (Exception e) {
installedApplications.put(app, false);

View file

@ -83,7 +83,8 @@ public class OpenFileSystemComp extends SimpleComp {
}
private Region createFileListContent() {
var directoryView = new BrowserFileListComp(model.getFileList()).apply(struc -> VBox.setVgrow(struc.get(), Priority.ALWAYS));
var directoryView = new BrowserFileListComp(model.getFileList())
.apply(struc -> VBox.setVgrow(struc.get(), Priority.ALWAYS));
var statusBar = new BrowserStatusBarComp(model);
var fileList = new VerticalComp(List.of(directoryView, statusBar));

View file

@ -13,10 +13,10 @@ public final class OpenFileSystemHistory {
private final IntegerProperty cursor = new SimpleIntegerProperty(-1);
private final List<String> history = new ArrayList<>();
private final BooleanBinding canGoBack = Bindings.createBooleanBinding(
() -> cursor.get() > 0 && history.size() > 1, cursor);
private final BooleanBinding canGoForth = Bindings.createBooleanBinding(
() -> cursor.get() < history.size() - 1, cursor);
private final BooleanBinding canGoBack =
Bindings.createBooleanBinding(() -> cursor.get() > 0 && history.size() > 1, cursor);
private final BooleanBinding canGoForth =
Bindings.createBooleanBinding(() -> cursor.get() < history.size() - 1, cursor);
public String getCurrent() {
return history.size() > 0 ? history.get(cursor.get()) : null;

View file

@ -46,9 +46,11 @@ public final class OpenFileSystemModel {
this.browserModel = browserModel;
this.store = store;
this.name = name != null ? name : DataStorage.get().getStoreEntry(store).getName();
this.inOverview.bind(Bindings.createBooleanBinding(() -> {
return currentPath.get() == null;
}, currentPath));
this.inOverview.bind(Bindings.createBooleanBinding(
() -> {
return currentPath.get() == null;
},
currentPath));
fileList = new BrowserFileListModel(this);
}
@ -147,7 +149,7 @@ public final class OpenFileSystemModel {
return Optional.of(currentPath.get());
}
String dirPath = null;
String dirPath;
try {
dirPath = FileSystemHelper.validateDirectoryPath(this, normalizedPath);
} catch (Exception ex) {
@ -314,7 +316,7 @@ public final class OpenFileSystemModel {
cdSyncWithoutCheck(dir);
}
public void initWithDefaultDirectory() throws Exception {
public void initWithDefaultDirectory() {
savedState.cd(null);
history.updateCurrent(null);
}

View file

@ -1,6 +1,5 @@
package io.xpipe.app.browser;
import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
@ -63,8 +62,7 @@ public class OpenFileSystemSavedState {
@Override
@SneakyThrows
public OpenFileSystemSavedState deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JacksonException {
public OpenFileSystemSavedState deserialize(JsonParser p, DeserializationContext ctxt) {
var tree = (ObjectNode) JacksonMapper.getDefault().readTree(p);
JavaType javaType = JacksonMapper.getDefault()
.getTypeFactory()

View file

@ -7,10 +7,10 @@ import java.util.List;
public interface ApplicationPathAction extends BrowserAction {
public abstract String getExecutable();
String getExecutable();
@Override
public default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
return model.getCache().isApplicationInPath(getExecutable());
}
}

View file

@ -13,7 +13,7 @@ import java.util.ServiceLoader;
public interface BrowserAction {
static enum Category {
enum Category {
CUSTOM,
OPEN,
NATIVE,
@ -21,9 +21,9 @@ public interface BrowserAction {
MUTATION
}
static List<BrowserAction> ALL = new ArrayList<>();
List<BrowserAction> ALL = new ArrayList<>();
public static List<LeafAction> getFlattened() {
static List<LeafAction> getFlattened() {
return ALL.stream()
.map(browserAction -> browserAction instanceof LeafAction
? List.of((LeafAction) browserAction)
@ -33,7 +33,10 @@ public interface BrowserAction {
}
static LeafAction byId(String id) {
return getFlattened().stream().filter(browserAction -> id.equals(browserAction.getId())).findAny().orElseThrow();
return getFlattened().stream()
.filter(browserAction -> id.equals(browserAction.getId()))
.findAny()
.orElseThrow();
}
default Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
@ -52,17 +55,17 @@ public interface BrowserAction {
return false;
}
public abstract String getName(OpenFileSystemModel model, List<BrowserEntry> entries);
String getName(OpenFileSystemModel model, List<BrowserEntry> entries);
public default boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
default boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return true;
}
public default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
return true;
}
public static class Loader implements ModuleLayerLoader {
class Loader implements ModuleLayerLoader {
@Override
public void init(ModuleLayer layer) {

View file

@ -13,8 +13,12 @@ public abstract class ExecuteApplicationAction implements LeafAction, Applicatio
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
for (BrowserEntry entry : entries) {
var command = detach() ? ScriptHelper.createDetachCommand(sc, createCommand(model, entry)) : createCommand(model, entry);
try (var cc = sc.command(command).withWorkingDirectory(model.getCurrentDirectory().getPath()).start()) {
var command = detach()
? ScriptHelper.createDetachCommand(sc, createCommand(model, entry))
: createCommand(model, entry);
try (var cc = sc.command(command)
.withWorkingDirectory(model.getCurrentDirectory().getPath())
.start()) {
cc.discardOrThrow();
}
}
@ -36,6 +40,5 @@ public abstract class ExecuteApplicationAction implements LeafAction, Applicatio
return false;
}
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
}

View file

@ -15,7 +15,7 @@ import java.util.function.UnaryOperator;
public interface LeafAction extends BrowserAction {
public abstract void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception;
void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception;
default Button toButton(OpenFileSystemModel model, List<BrowserEntry> selected) {
var b = new Button();

View file

@ -25,7 +25,7 @@ public abstract class MultiExecuteAction implements BranchAction {
new LeafAction() {
@Override
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) {
model.withShell(
pc -> {
for (BrowserEntry entry : entries) {
@ -51,12 +51,11 @@ public abstract class MultiExecuteAction implements BranchAction {
new LeafAction() {
@Override
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) {
model.withShell(
pc -> {
for (BrowserEntry entry : entries) {
var cmd = ScriptHelper.createDetachCommand(
pc, createCommand(pc, model, entry));
var cmd = ScriptHelper.createDetachCommand(pc, createCommand(pc, model, entry));
pc.command(cmd)
.withWorkingDirectory(model.getCurrentDirectory()
.getPath())
@ -74,13 +73,13 @@ public abstract class MultiExecuteAction implements BranchAction {
new LeafAction() {
@Override
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) {
model.withShell(
pc -> {
for (BrowserEntry entry : entries) {
pc.command(createCommand(pc, model, entry))
.withWorkingDirectory(model.getCurrentDirectory()
.getPath())
.getPath())
.execute();
}
},

View file

@ -14,12 +14,14 @@ public abstract class ToFileCommandAction implements LeafAction, ApplicationPath
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
for (BrowserEntry entry : entries) {
var command = createCommand(model, entry);
try (var cc = sc.command(command).withWorkingDirectory(model.getCurrentDirectory().getPath()).start()) {
try (var cc = sc.command(command)
.withWorkingDirectory(model.getCurrentDirectory().getPath())
.start()) {
cc.discardErr();
FileOpener.openCommandOutput(entry.getFileName(), entry, cc);
}
}
}
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
}

View file

@ -8,9 +8,11 @@ public class BrowserIcons {
public static PrettyImageComp createDefaultFileIcon() {
return new PrettyImageComp(new SimpleStringProperty("default_file.svg"), 22, 22);
}
public static PrettyImageComp createDefaultDirectoryIcon() {
return new PrettyImageComp(new SimpleStringProperty("default_folder.svg"), 22, 22);
}
public static PrettyImageComp createIcon(FileType type) {
return new PrettyImageComp(new SimpleStringProperty(type.getIcon()), 22, 22);
}

View file

@ -19,10 +19,13 @@ public interface DirectoryType {
List<DirectoryType> ALL = new ArrayList<>();
static DirectoryType byId(String id) {
return ALL.stream().filter(fileType -> fileType.getId().equals(id)).findAny().orElseThrow();
return ALL.stream()
.filter(fileType -> fileType.getId().equals(id))
.findAny()
.orElseThrow();
}
public static void loadDefinitions() {
static void loadDefinitions() {
ALL.add(new DirectoryType() {
@Override
@ -43,7 +46,7 @@ public interface DirectoryType {
AppResources.with(AppResources.XPIPE_MODULE, "folder_list.txt", path -> {
try (var reader =
new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8))) {
new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
var split = line.split("\\|");
@ -70,7 +73,8 @@ public interface DirectoryType {
var lightOpenIcon = split.length > 4 ? split[5].trim() : openIcon;
ALL.add(new Simple(
id, new IconVariant(lightClosedIcon, closedIcon),
id,
new IconVariant(lightClosedIcon, closedIcon),
new IconVariant(lightOpenIcon, openIcon),
filter.toArray(String[]::new)));
}
@ -82,6 +86,7 @@ public interface DirectoryType {
@Getter
private final String id;
private final IconVariant closed;
private final IconVariant open;
private final String[] names;
@ -99,8 +104,8 @@ public interface DirectoryType {
return false;
}
return Arrays.stream(names).anyMatch(name -> FileNames.getFileName(entry.getPath())
.equalsIgnoreCase(name));
return Arrays.stream(names)
.anyMatch(name -> FileNames.getFileName(entry.getPath()).equalsIgnoreCase(name));
}
@Override

View file

@ -8,12 +8,15 @@ import io.xpipe.core.store.FileSystem;
import javafx.scene.image.Image;
import lombok.Getter;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class FileIconManager {
@Getter
private static SvgCache svgCache = createCache();
private static final SvgCache svgCache = createCache();
private static boolean loaded;
private static SvgCache createCache() {
@ -61,7 +64,9 @@ public class FileIconManager {
}
}
return entry.getKind() == FileKind.DIRECTORY ? (open ? "default_folder_opened.svg" : "default_folder.svg") : "default_file.svg";
return entry.getKind() == FileKind.DIRECTORY
? (open ? "default_folder_opened.svg" : "default_folder.svg")
: "default_file.svg";
}
private static String getIconPath(String name) {

View file

@ -18,10 +18,13 @@ public interface FileType {
List<FileType> ALL = new ArrayList<>();
static FileType byId(String id) {
return ALL.stream().filter(fileType -> fileType.getId().equals(id)).findAny().orElseThrow();
return ALL.stream()
.filter(fileType -> fileType.getId().equals(id))
.findAny()
.orElseThrow();
}
public static void loadDefinitions() {
static void loadDefinitions() {
AppResources.with(AppResources.XPIPE_MODULE, "file_list.txt", path -> {
try (var reader =
new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8))) {

View file

@ -9,6 +9,7 @@ import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.PrefsComp;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.input.KeyCode;
@ -41,16 +42,14 @@ public class AppLayoutComp extends Comp<CompStructure<BorderPane>> {
private List<SideMenuBarComp.Entry> createEntryList() {
var l = new ArrayList<>(List.of(
new SideMenuBarComp.Entry(
AppI18n.observable("browser"),
"mdi2f-file-cabinet",
new BrowserComp(BrowserModel.DEFAULT)),
AppI18n.observable("browser"), "mdi2f-file-cabinet", new BrowserComp(BrowserModel.DEFAULT)),
new SideMenuBarComp.Entry(AppI18n.observable("connections"), "mdi2c-connection", new StoreLayoutComp()),
// new SideMenuBarComp.Entry(AppI18n.observable("data"), "mdsal-dvr", new SourceCollectionLayoutComp()),
new SideMenuBarComp.Entry(
AppI18n.observable("settings"), "mdsmz-miscellaneous_services", new PrefsComp(this))));
// new SideMenuBarComp.Entry(AppI18n.observable("help"), "mdi2b-book-open-variant", new
// StorageLayoutComp()),
// new SideMenuBarComp.Entry(AppI18n.observable("account"), "mdi2a-account", new StorageLayoutComp())
// new SideMenuBarComp.Entry(AppI18n.observable("help"), "mdi2b-book-open-variant", new
// StorageLayoutComp()),
// new SideMenuBarComp.Entry(AppI18n.observable("account"), "mdi2a-account", new StorageLayoutComp())
if (AppProperties.get().isDeveloperMode()) {
l.add(new SideMenuBarComp.Entry(
AppI18n.observable("developer"), "mdi2b-book-open-variant", new DeveloperTabComp()));

View file

@ -55,7 +55,7 @@ public class ButtonComp extends Comp<CompStructure<Button>> {
}
var graphic = getGraphic();
if (graphic instanceof FontIcon f) {
//f.iconColorProperty().bind(button.textFillProperty());
// f.iconColorProperty().bind(button.textFillProperty());
SimpleChangeListener.apply(button.fontProperty(), c -> {
f.setIconSize((int) new Size(c.getSize(), SizeUnits.PT).pixels());
});

View file

@ -49,7 +49,6 @@ public class DescriptionButtonComp extends SimpleComp {
return bt;
}
private Region createNamedEntry() {
var header = new Label();
header.textProperty().bind(PlatformThread.sync(name));

View file

@ -48,8 +48,9 @@ public class IntegratedTextAreaComp extends SimpleComp {
private Region createOpenButton(Region container) {
var name = identifier + (fileType != null ? "." + fileType : "");
var button = new IconButtonComp("mdal-edit", () -> FileOpener
.openString(name, this, value.getValue(), (s) -> {
var button = new IconButtonComp(
"mdal-edit",
() -> FileOpener.openString(name, this, value.getValue(), (s) -> {
Platform.runLater(() -> value.setValue(s));
}))
.createRegion();

View file

@ -7,9 +7,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleStringProperty;
import javafx.event.EventHandler;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
import lombok.Builder;
import lombok.Value;
@ -29,19 +27,16 @@ public class LazyTextFieldComp extends Comp<LazyTextFieldComp.Structure> {
var sp = new StackPane();
var r = new JFXTextField();
r.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ESCAPE)) {
currentValue.setValue(appliedValue.getValue());
}
if (ke.getCode().equals(KeyCode.ENTER) || ke.getCode().equals(KeyCode.ESCAPE)) {
r.getScene().getRoot().requestFocus();
}
ke.consume();
r.setOnKeyPressed(ke -> {
if (ke.getCode().equals(KeyCode.ESCAPE)) {
currentValue.setValue(appliedValue.getValue());
}
if (ke.getCode().equals(KeyCode.ENTER) || ke.getCode().equals(KeyCode.ESCAPE)) {
r.getScene().getRoot().requestFocus();
}
ke.consume();
});
r.focusedProperty().addListener((c, o, n) -> {

View file

@ -200,7 +200,9 @@ public abstract class MultiStepComp extends Comp<CompStructure<VBox>> {
buttons.setAlignment(Pos.CENTER_RIGHT);
var nextText = Bindings.createStringBinding(
() -> isLastPage() ? AppI18n.get("finishStep") : AppI18n.get("nextStep"), currentStep);
var nextButton = new ButtonComp(nextText, null, comp::next).apply(struc -> struc.get().setDefaultButton(true)).styleClass("next");
var nextButton = new ButtonComp(nextText, null, comp::next)
.apply(struc -> struc.get().setDefaultButton(true))
.styleClass("next");
var previousButton = new ButtonComp(AppI18n.observable("previousStep"), null, comp::previous)
.styleClass("next")
@ -283,5 +285,5 @@ public abstract class MultiStepComp extends Comp<CompStructure<VBox>> {
}
}
public static record Entry(ObservableValue<String> name, Step<?> step) {}
public record Entry(ObservableValue<String> name, Step<?> step) {}
}

View file

@ -53,9 +53,15 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
var fi = new FontIcon("mdi2u-update");
var b = new BigIconButton(AppI18n.observable("update"), fi, () -> UpdateAvailableAlert.showIfNeeded());
b.apply(GrowAugment.create(true, false));
b.hide(PlatformThread.sync(Bindings.createBooleanBinding(() -> {
return XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate().getValue() == null;
}, XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate())));
b.hide(PlatformThread.sync(Bindings.createBooleanBinding(
() -> {
return XPipeDistributionType.get()
.getUpdateHandler()
.getPreparedUpdate()
.getValue()
== null;
},
XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate())));
vbox.getChildren().add(b.createRegion());
}
@ -70,5 +76,5 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
return new SimpleCompStructure<>(vbox);
}
public static record Entry(ObservableValue<String> name, String icon, Comp<?> comp) {}
public record Entry(ObservableValue<String> name, String icon, Comp<?> comp) {}
}

View file

@ -33,8 +33,7 @@ public class DataSourceTargetChoiceComp extends Comp<CompStructure<ComboBox<Node
selectedApplication.addListener((observable, oldValue, val) -> {
AppCache.update("application-last-used", val != null ? val.getId() : null);
});
var all =
DataSourceTarget.getAll().stream().filter((p) -> filter.test(p)).toList();
var all = DataSourceTarget.getAll().stream().filter(filter).toList();
if (selectedApplication.getValue() == null) {
String selectedId = AppCache.get("application-last-used", String.class, () -> null);
@ -67,9 +66,10 @@ public class DataSourceTargetChoiceComp extends Comp<CompStructure<ComboBox<Node
public CompStructure<ComboBox<Node>> createBase() {
var addMoreLabel = new Label(AppI18n.get("addMore"), new FontIcon("mdmz-plus"));
var builder = new CustomComboBoxBuilder<DataSourceTarget>(
selectedApplication, app -> createLabel(app), new Label(""), v -> true);
builder.setAccessibleNames(dataSourceTarget -> dataSourceTarget.getName().getValue());
var builder =
new CustomComboBoxBuilder<>(selectedApplication, app -> createLabel(app), new Label(""), v -> true);
builder.setAccessibleNames(
dataSourceTarget -> dataSourceTarget.getName().getValue());
// builder.addFilter((v, s) -> v.getName().getValue().toLowerCase().contains(s));

View file

@ -30,15 +30,15 @@ public class DsCollectionComp extends Comp<CompStructure<TreeView<String>>> {
if (con.getValue() != null) {
try {
con.getValue().listEntries().forEach(e -> {
// var item = new TreeItem<String>(e.getFileName());
// c.add(item);
// var item = new TreeItem<String>(e.getFileName());
// c.add(item);
});
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
}
}
var ar = new TreeItem<String>(value.getValue());
var ar = new TreeItem<>(value.getValue());
ar.getChildren().setAll(c);
return ar;
}

View file

@ -116,12 +116,12 @@ public class DsDataTransferComp extends SimpleComp {
if (c != null && c.getAccessType() == DataSourceTarget.AccessType.PASSIVE) {
((Region) s.get().getChildren().get(2)).setMaxHeight(0);
((Region) s.get().getChildren().get(2)).setMinHeight(0);
((Region) s.get().getChildren().get(2)).setVisible(false);
s.get().getChildren().get(2).setVisible(false);
} else {
((Region) s.get().getChildren().get(2)).setMaxHeight(Region.USE_PREF_SIZE);
((Region) s.get().getChildren().get(2)).setMinHeight(Region.USE_PREF_SIZE);
((Region) s.get().getChildren().get(2)).setVisible(true);
s.get().getChildren().get(2).setVisible(true);
}
});
s.get().setPrefWidth(600);

View file

@ -73,7 +73,8 @@ public class DsProviderChoiceComp extends Comp<CompStructure<ComboBox<Node>>> im
@Override
public CompStructure<ComboBox<Node>> createBase() {
var comboBox = new CustomComboBoxBuilder<>(provider, this::createGraphic, createDefaultNode(), v -> true);
comboBox.setAccessibleNames(dataSourceProvider -> dataSourceProvider != null ? dataSourceProvider.getDisplayName() : null);
comboBox.setAccessibleNames(
dataSourceProvider -> dataSourceProvider != null ? dataSourceProvider.getDisplayName() : null);
comboBox.add(null);
comboBox.addSeparator();
comboBox.addFilter((v, s) -> v.getDisplayName().toLowerCase().contains(s.toLowerCase()));

View file

@ -29,7 +29,7 @@ public class DsStorageGroupSelector extends SimpleComp {
@Override
protected ComboBox<Node> createSimple() {
var comboBox = new CustomComboBoxBuilder<DataSourceCollection>(
var comboBox = new CustomComboBoxBuilder<>(
selected, DsStorageGroupSelector::createGraphic, createGraphic(null), v -> true);
comboBox.setAccessibleNames(dataSourceCollection -> dataSourceCollection.getName());

View file

@ -28,7 +28,7 @@ public class DsStructureComp extends Comp<CompStructure<TreeView<String>>> {
item.setValue("[" + i + "] = " + item.getValue());
c.add(item);
}
var ar = new TreeItem<String>("[" + n.size() + "... ]");
var ar = new TreeItem<>("[" + n.size() + "... ]");
ar.getChildren().setAll(c);
return ar;
} else if (n.isTuple()) {
@ -39,11 +39,11 @@ public class DsStructureComp extends Comp<CompStructure<TreeView<String>>> {
item.setValue((key != null ? key : "" + i) + " = " + item.getValue());
c.add(item);
}
var ar = new TreeItem<String>("( " + n.size() + "... )");
var ar = new TreeItem<>("( " + n.size() + "... )");
ar.getChildren().setAll(c);
return ar;
} else {
var ar = new TreeItem<String>(n.asValue().asString());
var ar = new TreeItem<>(n.asValue().asString());
return ar;
}
}

View file

@ -38,7 +38,7 @@ public class DsTableMappingComp extends SimpleComp {
grid.add(output.createRegion(), 2, i);
if (i % 2 != 0) {
grid.getChildren().stream().skip((i * 3)).forEach(node -> node.getStyleClass()
grid.getChildren().stream().skip((i * 3L)).forEach(node -> node.getStyleClass()
.add("odd"));
}
}

View file

@ -263,8 +263,8 @@ public class GuiDsCreatorMultiStep<DI extends DataStore, DS extends DataSource<D
switch (state) {
case EDIT -> {}
case CREATE -> {
list.add(
new Entry(AppI18n.observable("target"), new GuiDsCreatorTransferStep(targetGroup, store, source)));
list.add(new Entry(
AppI18n.observable("target"), new GuiDsCreatorTransferStep(targetGroup, store, source)));
}
}
return list;
@ -287,7 +287,7 @@ public class GuiDsCreatorMultiStep<DI extends DataStore, DS extends DataSource<D
window.close();
}
public static enum State {
public enum State {
EDIT,
CREATE
}

View file

@ -62,7 +62,7 @@ public class NamedSourceChoiceComp extends SimpleComp implements Validatable {
@SuppressWarnings("unchecked")
private <T extends DataSource<?>> void setUpListener(ObservableValue<T> prop) {
prop.addListener((c, o, n) -> {
((Property<T>) selected).setValue((T) n);
((Property<T>) selected).setValue(n);
});
}

View file

@ -30,9 +30,15 @@ public class DataStoreSelectorComp extends Comp<CompStructure<Button>> {
var button = new JFXButton();
button.setGraphic(getGraphic());
button.setOnAction(e -> {
GuiDsStoreCreator.show("inProgress", null, null, v -> v.getCategory().equals(category), entry -> {
chosenStore.setValue(entry.getStore());
}, false);
GuiDsStoreCreator.show(
"inProgress",
null,
null,
v -> v.getCategory().equals(category),
entry -> {
chosenStore.setValue(entry.getStore());
},
false);
e.consume();
});
@ -61,8 +67,7 @@ public class DataStoreSelectorComp extends Comp<CompStructure<Button>> {
return JfxHelper.createNamedEntry(
AppI18n.get("selectStreamStore"), AppI18n.get("openStreamStoreWizard"), graphic);
} else {
return JfxHelper.createNamedEntry(
f.getFileName().toString(), f.getPath().toString(), graphic);
return JfxHelper.createNamedEntry(f.getFileName(), f.getPath(), graphic);
}
}
}

View file

@ -18,10 +18,10 @@ import java.nio.file.Path;
public class DsLocalDirectoryBrowseComp extends Comp<CompStructure<Button>> {
private final DataSourceProvider provider;
private final DataSourceProvider<?> provider;
private final Property<Path> chosenDir;
public DsLocalDirectoryBrowseComp(DataSourceProvider provider, Property<Path> chosenDir) {
public DsLocalDirectoryBrowseComp(DataSourceProvider<?> provider, Property<Path> chosenDir) {
this.provider = provider;
this.chosenDir = chosenDir;
}
@ -32,8 +32,8 @@ public class DsLocalDirectoryBrowseComp extends Comp<CompStructure<Button>> {
button.setGraphic(getGraphic());
button.setOnAction(e -> {
var dirChooser = new DirectoryChooser();
dirChooser.setTitle(
AppI18n.get("browseDirectoryTitle", provider.getFileProvider().getFileName()));
dirChooser.setTitle(AppI18n.get(
"browseDirectoryTitle", provider.getFileProvider().getFileName()));
File file = dirChooser.showDialog(button.getScene().getWindow());
if (file != null && file.exists()) {
chosenDir.setValue(file.toPath());
@ -55,7 +55,8 @@ public class DsLocalDirectoryBrowseComp extends Comp<CompStructure<Button>> {
private Region getGraphic() {
var graphic = provider.getDisplayIconFileName();
if (chosenDir.getValue() == null) {
return JfxHelper.createNamedEntry(AppI18n.get("browse"), AppI18n.get("selectDirectoryFromComputer"), graphic);
return JfxHelper.createNamedEntry(
AppI18n.get("browse"), AppI18n.get("selectDirectoryFromComputer"), graphic);
} else {
return JfxHelper.createNamedEntry(
chosenDir.getValue().getFileName().toString(),

View file

@ -68,8 +68,7 @@ public class DsLocalFileBrowseComp extends Comp<CompStructure<Button>> {
if (chosenFile.getValue() == null || !(chosenFile.getValue() instanceof FileStore f) || f.getPath() == null) {
return JfxHelper.createNamedEntry(AppI18n.get("browse"), AppI18n.get("selectFileFromComputer"), graphic);
} else {
return JfxHelper.createNamedEntry(
f.getFileName().toString(), f.getPath().toString(), graphic);
return JfxHelper.createNamedEntry(f.getFileName(), f.getPath(), graphic);
}
}
}

View file

@ -33,9 +33,7 @@ public class DsStoreProviderChoiceComp extends Comp<CompStructure<ComboBox<Node>
}
private List<DataStoreProvider> getProviders() {
return DataStoreProviders.getAll().stream()
.filter(filter)
.toList();
return DataStoreProviders.getAll().stream().filter(filter).toList();
}
private Region createGraphic(DataStoreProvider provider) {

View file

@ -39,7 +39,7 @@ import java.util.function.Predicate;
@EqualsAndHashCode(callSuper = true)
public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
public static enum Mode {
public enum Mode {
OPEN,
WRITE
}
@ -71,7 +71,7 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
protected Region createSimple() {
var isNamedStore =
XPipeDaemon.getInstance().getStoreName(selected.getValue()).isPresent();
var localStore = new SimpleObjectProperty<FileStore>(
var localStore = new SimpleObjectProperty<>(
!isNamedStore
&& selected.getValue() instanceof FileStore fileStore
&& fileStore.getFileSystem() instanceof LocalStore
@ -101,7 +101,7 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
},
provider != null ? provider : new SimpleObjectProperty<>());
var remoteStore = new SimpleObjectProperty<DataStore>(
var remoteStore = new SimpleObjectProperty<>(
isNamedStore
&& selected.getValue() instanceof FileStore fileStore
&& !(fileStore.getFileSystem() instanceof LocalStore)
@ -110,13 +110,13 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
var remote = new TabPaneComp.Entry(
AppI18n.observable("remote"), "mdi2e-earth", new DsRemoteFileChoiceComp(remoteStore));
var namedStore = new SimpleObjectProperty<DataStore>(isNamedStore ? selected.getValue() : null);
var namedStore = new SimpleObjectProperty<>(isNamedStore ? selected.getValue() : null);
var named = new TabPaneComp.Entry(
AppI18n.observable("stored"),
"mdrmz-storage",
NamedStoreChoiceComp.create(filter, namedStore, DataStoreProvider.DataCategory.STREAM));
var otherStore = new SimpleObjectProperty<DataStore>(
var otherStore = new SimpleObjectProperty<>(
localStore.get() == null && remoteStore.get() == null && !isNamedStore ? selected.getValue() : null);
var other = new TabPaneComp.Entry(
AppI18n.observable("other"),

View file

@ -61,8 +61,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
Property<DataStoreProvider> provider,
Property<DataStore> store,
Predicate<DataStoreProvider> filter,
String initialName, boolean exists
) {
String initialName,
boolean exists) {
this.parent = parent;
this.provider = provider;
this.store = store;
@ -97,26 +97,38 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
}
public static void showEdit(DataStoreEntry e) {
show(e.getName(), e.getProvider(), e.getStore(), v -> true, newE -> {
ThreadHelper.runAsync(() -> {
e.applyChanges(newE);
if (!DataStorage.get().getStoreEntries().contains(e)) {
DataStorage.get().addStoreEntry(e);
}
DataStorage.get().refresh();
});
}, true);
show(
e.getName(),
e.getProvider(),
e.getStore(),
v -> true,
newE -> {
ThreadHelper.runAsync(() -> {
e.applyChanges(newE);
if (!DataStorage.get().getStoreEntries().contains(e)) {
DataStorage.get().addStoreEntry(e);
}
DataStorage.get().refresh();
});
},
true);
}
public static void showCreation(Predicate<DataStoreProvider> filter) {
show(null, null, null, filter, e -> {
try {
DataStorage.get().addStoreEntry(e);
// ScanAlert.showAsync(e.getStore(), true);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
}
}, false);
show(
null,
null,
null,
filter,
e -> {
try {
DataStorage.get().addStoreEntry(e);
// ScanAlert.showAsync(e.getStore(), true);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
}
},
false);
}
public static void show(
@ -126,8 +138,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
Predicate<DataStoreProvider> filter,
Consumer<DataStoreEntry> con,
boolean exists) {
var prop = new SimpleObjectProperty<DataStoreProvider>(provider);
var store = new SimpleObjectProperty<DataStore>(s);
var prop = new SimpleObjectProperty<>(provider);
var store = new SimpleObjectProperty<>(s);
var loading = new SimpleBooleanProperty();
var name = "addConnection";
Platform.runLater(() -> {
@ -162,12 +174,26 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
@Override
public Comp<?> bottom() {
var disable = Bindings.createBooleanBinding(() -> {
return provider.getValue() == null || store.getValue() == null || !store.getValue().isComplete();
}, provider, store);
return new PopupMenuButtonComp(new SimpleStringProperty("Insights >"), Comp.of(() -> {
return provider.getValue() != null ? provider.getValue().createInsightsComp(store).createRegion() : null;
}), true).disable(disable).styleClass("button-comp");
var disable = Bindings.createBooleanBinding(
() -> {
return provider.getValue() == null
|| store.getValue() == null
|| !store.getValue().isComplete();
},
provider,
store);
return new PopupMenuButtonComp(
new SimpleStringProperty("Insights >"),
Comp.of(() -> {
return provider.getValue() != null
? provider.getValue()
.createInsightsComp(store)
.createRegion()
: null;
}),
true)
.disable(disable)
.styleClass("button-comp");
}
private static boolean showInvalidConfirmAlert() {
@ -288,7 +314,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
}
if (!exists) {
if (name.getValue() != null && DataStorage.get().getStoreEntryIfPresent(name.getValue()).isPresent()) {
if (name.getValue() != null
&& DataStorage.get().getStoreEntryIfPresent(name.getValue()).isPresent()) {
messageProp.setValue("Store with name " + name.getValue() + " does already exist");
changedSinceError.setValue(false);
return false;

View file

@ -116,8 +116,12 @@ public class NamedStoreChoiceComp extends SimpleComp implements Validatable {
refreshShown(list, shown);
});
var prop = new SimpleObjectProperty<>(selected.getValue() != null ?
DataStorage.get().getStoreEntryIfPresent(selected.getValue()).orElse(null):null);
var prop = new SimpleObjectProperty<>(
selected.getValue() != null
? DataStorage.get()
.getStoreEntryIfPresent(selected.getValue())
.orElse(null)
: null);
setUpListener(prop);
var filterComp = new FilterComp(filterString)

View file

@ -14,7 +14,7 @@ import org.kordamp.ikonli.javafx.FontIcon;
@EqualsAndHashCode(callSuper = true)
public class DataStoreTypeComp extends SimpleComp {
private final DataSource<?> source;
DataSource<?> source;
@Override
protected Region createSimple() {

View file

@ -49,7 +49,7 @@ public class StorageFilter {
return filter;
}
public static interface Filterable {
public interface Filterable {
boolean shouldShow(String filter);
}

View file

@ -49,9 +49,10 @@ public class SourceCollectionLayoutComp extends SimpleComp {
var filler = Comp.of(() -> new Region());
filler.styleClass("bar");
filler.styleClass("filler-bar");
var button = new ButtonComp(AppI18n.observable("addCollection"), new FontIcon("mdi2f-folder-plus-outline"), () -> {
SourceCollectionViewState.get().addNewCollection();
})
var button = new ButtonComp(
AppI18n.observable("addCollection"), new FontIcon("mdi2f-folder-plus-outline"), () -> {
SourceCollectionViewState.get().addNewCollection();
})
.apply(new FancyTooltipAugment<>("addCollectionFolder"));
button.styleClass("intro-add-collection-button");

View file

@ -7,7 +7,7 @@ import java.util.Comparator;
public interface SourceCollectionSortMode {
static SourceCollectionSortMode ALPHABETICAL_DESC = new SourceCollectionSortMode() {
SourceCollectionSortMode ALPHABETICAL_DESC = new SourceCollectionSortMode() {
@Override
public String getId() {
return "alphabetical-desc";
@ -21,7 +21,7 @@ public interface SourceCollectionSortMode {
}
};
static SourceCollectionSortMode ALPHABETICAL_ASC = new SourceCollectionSortMode() {
SourceCollectionSortMode ALPHABETICAL_ASC = new SourceCollectionSortMode() {
@Override
public String getId() {
return "alphabetical-asc";
@ -34,7 +34,7 @@ public interface SourceCollectionSortMode {
}
};
static SourceCollectionSortMode DATE_DESC = new SourceCollectionSortMode() {
SourceCollectionSortMode DATE_DESC = new SourceCollectionSortMode() {
@Override
public String getId() {
return "date-desc";
@ -48,7 +48,7 @@ public interface SourceCollectionSortMode {
}
};
static SourceCollectionSortMode DATE_ASC = new SourceCollectionSortMode() {
SourceCollectionSortMode DATE_ASC = new SourceCollectionSortMode() {
@Override
public String getId() {
return "date-asc";

View file

@ -35,10 +35,9 @@ public class SourceCollectionWrapper implements StorageFilter.Filterable {
public SourceCollectionWrapper(DataSourceCollection collection) {
this.collection = collection;
this.entries =
new SimpleListProperty<SourceEntryWrapper>(FXCollections.observableList(collection.getEntries().stream()
.map(SourceEntryWrapper::new)
.collect(Collectors.toCollection(ArrayList::new))));
this.entries = new SimpleListProperty<>(FXCollections.observableList(collection.getEntries().stream()
.map(SourceEntryWrapper::new)
.collect(Collectors.toCollection(ArrayList::new))));
this.size = new SimpleIntegerProperty(collection.getEntries().size());
this.name = new SimpleStringProperty(collection.getName());
this.lastAccess = new SimpleObjectProperty<>(collection.getLastAccess().minus(Duration.ofMillis(500)));

View file

@ -18,7 +18,6 @@ import org.kordamp.ikonli.javafx.FontIcon;
public class SourceEntryContextMenu<S extends CompStructure<?>> extends ContextMenuAugment<S> {
public SourceEntryContextMenu(boolean showOnPrimaryButton, SourceEntryWrapper entry, Region renameTextField) {
super(() -> createContextMenu(entry, renameTextField));
}

View file

@ -11,9 +11,9 @@ public interface SourceEntryDisplayMode {
SourceEntryDisplayMode LIST = new ListMode();
SourceEntryDisplayMode TILES = new ListMode();
public Region create(List<SourceEntryWrapper> entries);
Region create(List<SourceEntryWrapper> entries);
static class ListMode implements SourceEntryDisplayMode {
class ListMode implements SourceEntryDisplayMode {
private static final double SOURCE_TYPE_WIDTH = 0.15;
private static final double NAME_WIDTH = 0.4;

View file

@ -11,7 +11,6 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.storage.DataSourceEntry;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.StorageElement;
import io.xpipe.core.source.DataSource;
import io.xpipe.core.store.DataFlow;
import javafx.beans.property.*;
@ -37,14 +36,9 @@ public class SourceEntryWrapper implements StorageFilter.Filterable {
public SourceEntryWrapper(DataSourceEntry entry) {
this.entry = entry;
entry.addListener(new StorageElement.Listener() {
@Override
public void onUpdate() {
PlatformThread.runLaterIfNeeded(() -> {
update();
});
}
});
entry.addListener(() -> PlatformThread.runLaterIfNeeded(() -> {
update();
}));
update();
name.addListener((c, o, n) -> {
if (!entry.getName().equals(n)) {

View file

@ -23,7 +23,8 @@ public class StoreCreationBarComp extends SimpleComp {
protected Region createSimple() {
var newStreamStore = new ButtonComp(
AppI18n.observable("addCommand"), new FontIcon("mdi2c-code-greater-than"), () -> {
GuiDsStoreCreator.showCreation(v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.COMMAND));
GuiDsStoreCreator.showCreation(
v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.COMMAND));
})
.styleClass(Styles.FLAT)
.shortcut(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN))
@ -38,22 +39,24 @@ public class StoreCreationBarComp extends SimpleComp {
.apply(new FancyTooltipAugment<>("addHost"));
var newShellStore = new ButtonComp(
AppI18n.observable("addShell"), new FontIcon("mdi2t-text-box-multiple"), () -> {
GuiDsStoreCreator.showCreation(v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.SHELL));
})
AppI18n.observable("addShell"), new FontIcon("mdi2t-text-box-multiple"), () -> {
GuiDsStoreCreator.showCreation(
v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.SHELL));
})
.styleClass(Styles.FLAT)
.shortcut(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN))
.apply(new FancyTooltipAugment<>("addShell"));
var newDbStore = new ButtonComp(
AppI18n.observable("addDatabase"), new FontIcon("mdi2d-database-plus"), () -> {
GuiDsStoreCreator.showCreation(v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.DATABASE));
})
var newDbStore = new ButtonComp(AppI18n.observable("addDatabase"), new FontIcon("mdi2d-database-plus"), () -> {
GuiDsStoreCreator.showCreation(
v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.DATABASE));
})
.styleClass(Styles.FLAT)
.shortcut(new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN))
.apply(new FancyTooltipAugment<>("addDatabase"));
var box = new VerticalComp(List.of(newHostStore, newShellStore, newStreamStore, newDbStore)).apply(struc -> struc.get().setFillWidth(true));
var box = new VerticalComp(List.of(newHostStore, newShellStore, newStreamStore, newDbStore))
.apply(struc -> struc.get().setFillWidth(true));
box.apply(s -> AppFont.medium(s.get()));
var bar = box.createRegion();
bar.getStyleClass().add("bar");

View file

@ -148,9 +148,12 @@ public class StoreEntryComp extends SimpleComp {
button.getStyleClass().add("store-entry-comp");
button.setMaxWidth(2000);
button.setFocusTraversable(true);
button.accessibleTextProperty().bind(Bindings.createStringBinding(() -> {
return entry.getName();
}, entry.nameProperty()));
button.accessibleTextProperty()
.bind(Bindings.createStringBinding(
() -> {
return entry.getName();
},
entry.nameProperty()));
button.accessibleHelpProperty().bind(entry.getInformation());
button.setOnAction(event -> {
event.consume();
@ -160,7 +163,8 @@ public class StoreEntryComp extends SimpleComp {
});
});
new ContextMenuAugment<>(() -> StoreEntryComp.this.createContextMenu()).augment(new SimpleCompStructure<>(button));
new ContextMenuAugment<>(() -> StoreEntryComp.this.createContextMenu())
.augment(new SimpleCompStructure<>(button));
return button;
}
@ -210,7 +214,8 @@ public class StoreEntryComp extends SimpleComp {
var settingsButton = new IconButtonComp("mdomz-settings");
settingsButton.styleClass("settings");
settingsButton.accessibleText("Settings");
settingsButton.apply(new ContextMenuAugment<>(event -> event.getButton() == MouseButton.PRIMARY, () -> StoreEntryComp.this.createContextMenu()));
settingsButton.apply(new ContextMenuAugment<>(
event -> event.getButton() == MouseButton.PRIMARY, () -> StoreEntryComp.this.createContextMenu()));
settingsButton.apply(GrowAugment.create(false, true));
settingsButton.apply(s -> {
s.get().prefWidthProperty().bind(Bindings.divide(s.get().heightProperty(), 1.35));

View file

@ -54,7 +54,8 @@ public class StoreEntryFlatMiniSectionComp extends SimpleComp {
var image = entry.getState() == DataStoreEntry.State.LOAD_FAILED
? "disabled_icon.png"
: entry.getProvider().getDisplayIconFileName(entry.getStore());
var label = new Label(entry.getName(), new PrettyImageComp(new SimpleStringProperty(image), 20, 20).createRegion());
var label =
new Label(entry.getName(), new PrettyImageComp(new SimpleStringProperty(image), 20, 20).createRegion());
var spacer = new Spacer(depth * 10, Orientation.HORIZONTAL);
var box = new HBox(spacer, label);
return box;

View file

@ -31,9 +31,12 @@ public class StoreEntryListComp extends SimpleComp {
@Override
protected Region createSimple() {
var initialCount = StoreViewState.get().getAllEntries().size();
var showIntro = Bindings.createBooleanBinding(() -> {
return initialCount == StoreViewState.get().getAllEntries().size() && AppState.get().isInitialLaunch();
}, StoreViewState.get().getAllEntries());
var showIntro = Bindings.createBooleanBinding(
() -> {
return initialCount == StoreViewState.get().getAllEntries().size()
&& AppState.get().isInitialLaunch();
},
StoreViewState.get().getAllEntries());
var map = new LinkedHashMap<Comp<?>, ObservableBooleanValue>();
map.put(
createList(),

View file

@ -40,7 +40,8 @@ public class StoreEntrySection extends Comp<CompStructure<VBox>> {
.accessibleText("Expand")
.disable(BindingsHelper.persist(
Bindings.size(section.getChildren()).isEqualTo(0)))
.grow(false, true).styleClass("expand-button");
.grow(false, true)
.styleClass("expand-button");
List<Comp<?>> topEntryList = List.of(button, root);
var all = section.getChildren();

View file

@ -18,7 +18,6 @@ import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import org.kordamp.ikonli.javafx.FontIcon;
public class StoreIntroComp extends SimpleComp {
@Override
@ -53,15 +52,11 @@ public class StoreIntroComp extends SimpleComp {
docLinkPane.setAlignment(Pos.CENTER);
var v = new VBox(
title,
introDesc,
new Separator(Orientation.HORIZONTAL),
machine,
scanPane
// new Separator(Orientation.HORIZONTAL),
// documentation,
// docLinkPane
);
title, introDesc, new Separator(Orientation.HORIZONTAL), machine, scanPane
// new Separator(Orientation.HORIZONTAL),
// documentation,
// docLinkPane
);
v.setMinWidth(Region.USE_PREF_SIZE);
v.setMaxWidth(Region.USE_PREF_SIZE);
v.setMinHeight(Region.USE_PREF_SIZE);

View file

@ -20,28 +20,27 @@ public class StoreSection implements StorageFilter.Filterable {
private static final Comparator<StoreSection> COMPARATOR = Comparator.<StoreSection, Instant>comparing(
o -> o.wrapper.getEntry().getState().equals(DataStoreEntry.State.COMPLETE_AND_VALID)
? o.wrapper.getEntry().getLastAccess()
: Instant.EPOCH).reversed()
: Instant.EPOCH)
.reversed()
.thenComparing(
storeEntrySection -> storeEntrySection.wrapper.getEntry().getName());
public static StoreSection createTopLevel() {
var topLevel = BindingsHelper.mappedContentBinding(StoreViewState.get().getAllEntries(), storeEntryWrapper -> create(storeEntryWrapper));
var filtered =
BindingsHelper.filteredContentBinding(topLevel, section -> {
if (!section.getWrapper().getEntry().getState().isUsable()) {
return true;
}
var topLevel = BindingsHelper.mappedContentBinding(
StoreViewState.get().getAllEntries(), storeEntryWrapper -> create(storeEntryWrapper));
var filtered = BindingsHelper.filteredContentBinding(topLevel, section -> {
if (!section.getWrapper().getEntry().getState().isUsable()) {
return true;
}
var parent = section.getWrapper()
.getEntry()
.getProvider()
.getParent(section.getWrapper().getEntry().getStore());
return parent == null
|| (DataStorage.get().getStoreEntryIfPresent(parent).isEmpty());
});
var ordered = BindingsHelper.orderedContentBinding(
filtered,
COMPARATOR);
var parent = section.getWrapper()
.getEntry()
.getProvider()
.getParent(section.getWrapper().getEntry().getStore());
return parent == null
|| (DataStorage.get().getStoreEntryIfPresent(parent).isEmpty());
});
var ordered = BindingsHelper.orderedContentBinding(filtered, COMPARATOR);
return new StoreSection(null, ordered);
}
@ -54,14 +53,12 @@ public class StoreSection implements StorageFilter.Filterable {
StoreViewState.get().getAllEntries(),
other -> other.getEntry().getState().isUsable()
&& e.getEntry()
.getStore()
.equals(other.getEntry()
.getStore()
.equals(other.getEntry()
.getProvider()
.getParent(other.getEntry().getStore())));
var children = BindingsHelper.mappedContentBinding(filtered, entry1 -> create(entry1));
var ordered = BindingsHelper.orderedContentBinding(
children,
COMPARATOR);
var ordered = BindingsHelper.orderedContentBinding(children, COMPARATOR);
return new StoreSection(e, ordered);
}

View file

@ -65,7 +65,8 @@ public class AppActionLinkDetector {
alert.setTitle(AppI18n.get("clipboardActionDetectedTitle"));
alert.setHeaderText(AppI18n.get("clipboardActionDetectedHeader"));
alert.getDialogPane()
.setContent(AppWindowHelper.alertContentText(AppI18n.get("clipboardActionDetectedContent")));
.setContent(
AppWindowHelper.alertContentText(AppI18n.get("clipboardActionDetectedContent")));
})
.map(buttonType -> buttonType.getButtonData().isDefaultButton())
.orElse(false);

View file

@ -11,7 +11,7 @@ import java.util.Locale;
public class AppCharsets {
private static List<String> observedCharsets = new ArrayList<>();
private static final List<String> observedCharsets = new ArrayList<>();
public static void init() {
var system = System.getProperty("file.encoding");

View file

@ -29,7 +29,7 @@ public class AppExtensionManager {
private ModuleLayer baseLayer = ModuleLayer.boot();
private ModuleLayer extendedLayer;
public static void init(boolean loadProviders) throws Exception {
public static void init(boolean loadProviders) {
if (INSTANCE != null) {
return;
}
@ -242,12 +242,12 @@ public class AppExtensionManager {
.tag("dependencies", ext.get().getDependencies())
.handle();
return Optional.of(ext.get());
return ext;
}
}
} catch (Throwable t) {
ErrorEvent.fromThrowable(t)
.description("Unable to load extension from " + dir.toString() + ". Is the installation corrupted?")
.description("Unable to load extension from " + dir + ". Is the installation corrupted?")
.handle();
}
return Optional.empty();

View file

@ -40,7 +40,7 @@ public class AppI18n {
private Map<String, String> translations;
private Map<String, String> markdownDocumentations;
private PrettyTime prettyTime;
private static AppI18n INSTANCE = new AppI18n();
private static final AppI18n INSTANCE = new AppI18n();
public static void init() {
var i = INSTANCE;
@ -59,7 +59,7 @@ private static AppI18n INSTANCE = new AppI18n();
}
public static AppI18n getInstance() {
return ((AppI18n) INSTANCE);
return INSTANCE;
}
public static StringBinding readableDuration(String s, ObservableValue<Instant> instant) {
@ -73,7 +73,8 @@ private static AppI18n INSTANCE = new AppI18n();
return "null";
}
return op.apply(getInstance().prettyTime.format(instant.getValue().minus(Duration.ofSeconds(1))));
return op.apply(
getInstance().prettyTime.format(instant.getValue().minus(Duration.ofSeconds(1))));
},
instant);
}
@ -209,9 +210,9 @@ private static AppI18n INSTANCE = new AppI18n();
AtomicInteger lineCounter = new AtomicInteger();
var simpleName = FilenameUtils.getExtension(module.getName());
String defaultPrefix = simpleName.equals("app") ? "app." : simpleName + ".";
Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
if (!matchesLocale(file)) {
return FileVisitResult.CONTINUE;
}
@ -227,7 +228,7 @@ private static AppI18n INSTANCE = new AppI18n();
props.forEach((key, value) -> {
var hasPrefix = key.toString().contains(".");
var usedPrefix = hasPrefix ? "" : defaultPrefix;
translations.put(usedPrefix + key.toString(), value.toString());
translations.put(usedPrefix + key, value.toString());
lineCounter.incrementAndGet();
});
} catch (IOException ex) {
@ -252,9 +253,9 @@ private static AppI18n INSTANCE = new AppI18n();
}
var moduleName = FilenameUtils.getExtension(module.getName());
Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
if (!matchesLocale(file)) {
return FileVisitResult.CONTINUE;
}
@ -263,10 +264,13 @@ private static AppI18n INSTANCE = new AppI18n();
return FileVisitResult.CONTINUE;
}
var name = file.getFileName().toString().substring(0, file.getFileName().toString().lastIndexOf("_"));
var name = file.getFileName()
.toString()
.substring(0, file.getFileName().toString().lastIndexOf("_"));
try (var in = Files.newInputStream(file)) {
var usedPrefix = moduleName + ":";
markdownDocumentations.put(usedPrefix + name, new String(in.readAllBytes(), StandardCharsets.UTF_8));
markdownDocumentations.put(
usedPrefix + name, new String(in.readAllBytes(), StandardCharsets.UTF_8));
} catch (IOException ex) {
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
}

View file

@ -38,9 +38,9 @@ public class AppImages {
var simpleName = FilenameUtils.getExtension(module);
String defaultPrefix = simpleName + ":";
Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
var relativeFileName = FilenameUtils.separatorsToUnix(
basePath.relativize(file).toString());
try {
@ -108,8 +108,8 @@ public class AppImages {
}
public static BufferedImage toAwtImage(Image fxImage) {
BufferedImage img = new BufferedImage(
(int) fxImage.getWidth(), (int) fxImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
BufferedImage img =
new BufferedImage((int) fxImage.getWidth(), (int) fxImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
for (int x = 0; x < fxImage.getWidth(); x++) {
for (int y = 0; y < fxImage.getHeight(); y++) {
int rgb = fxImage.getPixelReader().getArgb(x, y);

View file

@ -255,7 +255,7 @@ public class AppMainWindow {
var awt = AppImages.toAwtImage(image);
var file = Path.of(System.getProperty("user.home"), "Desktop", "xpipe-screenshot.png");
try {
ImageIO.write(awt, "png",file.toFile());
ImageIO.write(awt, "png", file.toFile());
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
}

View file

@ -35,7 +35,8 @@ public class AppProperties {
fullVersion = Optional.ofNullable(System.getProperty("io.xpipe.app.fullVersion"))
.map(Boolean::parseBoolean)
.orElse(false);
version = Optional.ofNullable(System.getProperty("io.xpipe.app.version")).orElse("dev");
version =
Optional.ofNullable(System.getProperty("io.xpipe.app.version")).orElse("dev");
build = Optional.ofNullable(System.getProperty("io.xpipe.app.build")).orElse("unknown");
buildUuid = Optional.ofNullable(System.getProperty("io.xpipe.app.buildId"))
.map(UUID::fromString)

View file

@ -71,8 +71,7 @@ public class AppResources {
}
}
private static boolean withLocalDevResource(
String module, String file, FailableConsumer<Path, IOException> con) {
private static boolean withLocalDevResource(String module, String file, FailableConsumer<Path, IOException> con) {
try (var fs = openFileSystem(module)) {
var url = fs.getPath("").getWrappedPath().toUri().toURL();
if (!url.getProtocol().equals("jar")) {

View file

@ -79,7 +79,7 @@ public class AppSocketServer {
}
try {
listenerThread.join();
} catch (InterruptedException e) {
} catch (InterruptedException ignored) {
}
}
@ -89,7 +89,7 @@ public class AppSocketServer {
listenerThread = new Thread(
() -> {
while (running) {
Socket clientSocket = null;
Socket clientSocket;
try {
clientSocket = socket.accept();
} catch (Exception ex) {
@ -114,7 +114,7 @@ public class AppSocketServer {
return false;
}
JsonNode node = null;
JsonNode node;
try (InputStream blockIn = BeaconFormat.readBlocks(clientSocket.getInputStream())) {
node = JacksonMapper.newMapper().readTree(blockIn);
}
@ -180,7 +180,7 @@ public class AppSocketServer {
private void performExchanges(Socket clientSocket, int id) {
try {
JsonNode informationNode = null;
JsonNode informationNode;
try (InputStream blockIn = BeaconFormat.readBlocks(clientSocket.getInputStream())) {
informationNode = JacksonMapper.newMapper().readTree(blockIn);
}
@ -230,10 +230,8 @@ public class AppSocketServer {
Deobfuscator.deobfuscate(ex);
sendServerErrorResponse(clientSocket, ex);
}
} catch (SocketException ex) {
// Omit it, as this might happen often
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
} catch (Throwable ex) {
} // Omit it, as this might happen often
catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).build().handle();
} finally {
try {

View file

@ -16,7 +16,8 @@ public class AppSplashScreen {
stage.setResizable(false);
stage.initStyle(StageStyle.TRANSPARENT);
var content = new ImageView(Main.class.getResource("resources/img/loading.gif").toString());
var content = new ImageView(
Main.class.getResource("resources/img/loading.gif").toString());
var scene = new Scene(new Pane(content), -1, -1, false);
stage.setScene(scene);
stage.show();

View file

@ -100,5 +100,4 @@ public class AppStyle {
scenes.add(scene);
}
}

View file

@ -95,9 +95,11 @@ public class AppTheme {
// Animate!
var transition = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(imageView.opacityProperty(), 1, Interpolator.EASE_OUT)),
new KeyFrame(
Duration.millis(1250), new KeyValue(imageView.opacityProperty(), 0, Interpolator.EASE_OUT)));
Duration.ZERO, new KeyValue(imageView.opacityProperty(), 1, Interpolator.EASE_OUT)),
new KeyFrame(
Duration.millis(1250),
new KeyValue(imageView.opacityProperty(), 0, Interpolator.EASE_OUT)));
transition.setOnFinished(e -> {
root.getChildren().remove(imageView);
});

View file

@ -73,7 +73,8 @@ public class AppWindowHelper {
childStage.setY(stage.getY() + stage.getHeight() / 2 - childStage.getHeight() / 2);
}
public static void showAlert(Consumer<Alert> c, ObservableValue<Boolean> loading, Consumer<Optional<ButtonType>> bt) {
public static void showAlert(
Consumer<Alert> c, ObservableValue<Boolean> loading, Consumer<Optional<ButtonType>> bt) {
ThreadHelper.runAsync(() -> {
var r = showBlockingAlert(c);
if (bt != null) {

View file

@ -264,7 +264,7 @@ public abstract class OperationMode {
public abstract void onSwitchTo();
public abstract void onSwitchFrom() throws Throwable;
public abstract void onSwitchFrom();
public abstract void initialSetup() throws Throwable;

View file

@ -77,7 +77,6 @@ public abstract class PlatformMode extends OperationMode {
ThreadHelper.sleep(100);
}
// If we downloaded an update, and decided to no longer automatically update, don't remind us!
// You can still update manually in the about tab
if (AppPrefs.get().automaticallyUpdate().get()) {
@ -91,7 +90,9 @@ public abstract class PlatformMode extends OperationMode {
protected void waitForPlatform() {
// The platform thread waits for the shutdown hook to finish in case SIGTERM is sent.
// Therefore, we do not wait for the platform when being in a shutdown hook.
if (PlatformState.getCurrent() == PlatformState.RUNNING && !Platform.isFxApplicationThread() && !OperationMode.isInShutdownHook()) {
if (PlatformState.getCurrent() == PlatformState.RUNNING
&& !Platform.isFxApplicationThread()
&& !OperationMode.isInShutdownHook()) {
TrackEvent.info("mode", "Waiting for platform thread ...");
CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(latch::countDown);

View file

@ -21,15 +21,15 @@ public class AskpassExchangeImpl extends AskpassExchange
private final Map<String, SecretValue> passwords = new HashMap<>();
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
if (OperationMode.get().equals(OperationMode.BACKGROUND)) {
OperationMode.switchTo(OperationMode.TRAY);
}
// SecretValue set = AppCache.get(msg.getId(), SecretValue.class, () -> null);
// if (set != null) {
// return Response.builder().value(set).build();
// }
// SecretValue set = AppCache.get(msg.getId(), SecretValue.class, () -> null);
// if (set != null) {
// return Response.builder().value(set).build();
// }
if (requestToId.containsKey(msg.getRequest())) {
var id = requestToId.remove(msg.getRequest());
@ -37,11 +37,12 @@ public class AskpassExchangeImpl extends AskpassExchange
}
if (passwords.containsKey(msg.getId())) {
return Response.builder().value(passwords.get(msg.getId()).getSecretValue()).build();
return Response.builder()
.value(passwords.get(msg.getId()).getSecretValue())
.build();
}
var prop =
new SimpleObjectProperty<SecretValue>();
var prop = new SimpleObjectProperty<SecretValue>();
var r = AppWindowHelper.showBlockingAlert(alert -> {
alert.setTitle(AppI18n.get("askpassAlertTitle"));
alert.setHeaderText(msg.getPrompt());
@ -52,7 +53,7 @@ public class AskpassExchangeImpl extends AskpassExchange
})
.filter(b -> b.getButtonData().isDefaultButton() && prop.getValue() != null)
.map(t -> {
//AppCache.update(msg.getId(), prop.getValue());
// AppCache.update(msg.getId(), prop.getValue());
return prop.getValue();
})
.orElse(null);

View file

@ -8,7 +8,7 @@ public class FocusExchangeImpl extends FocusExchange
implements MessageExchangeImpl<FocusExchange.Request, FocusExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
OperationMode.switchUp(OperationMode.map(msg.getMode()));
return Response.builder().build();
}

View file

@ -9,7 +9,7 @@ public class OpenExchangeImpl extends OpenExchange
implements MessageExchangeImpl<OpenExchange.Request, OpenExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
if (msg.getArguments().size() == 0) {
OperationMode.switchToAsync(OperationMode.GUI);
}

View file

@ -7,7 +7,7 @@ public class ProxyFunctionExchangeImpl extends ProxyFunctionExchange
implements MessageExchangeImpl<ProxyFunctionExchange.Request, ProxyFunctionExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
msg.getFunction().callLocal();
return ProxyFunctionExchange.Response.builder()
.function(msg.getFunction())

View file

@ -11,7 +11,7 @@ public class ProxyReadConnectionExchangeImpl extends ProxyReadConnectionExchange
implements MessageExchangeImpl<ProxyReadConnectionExchange.Request, ProxyReadConnectionExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
handler.postResponse(() -> {
var outputSource = DataSource.createInternalDataSource(
msg.getSource().getType(), new OutputStreamStore(handler.sendBody()));

View file

@ -8,7 +8,7 @@ public class VersionExchangeImpl extends VersionExchange
implements MessageExchangeImpl<VersionExchange.Request, VersionExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
var jvmVersion = System.getProperty("java.vm.vendor") + " "
+ System.getProperty("java.vm.name") + " ("
+ System.getProperty("java.vm.version") + ")";

View file

@ -10,7 +10,7 @@ public class InstanceExchangeImpl extends InstanceExchange
implements MessageExchangeImpl<InstanceExchange.Request, InstanceExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
return Response.builder()
.instance(XPipeInstanceHelper.getInstance(new LocalStore()).orElseThrow())
.build();

View file

@ -10,7 +10,7 @@ public class ListCollectionsExchangeImpl extends ListCollectionsExchange
implements MessageExchangeImpl<ListCollectionsExchange.Request, ListCollectionsExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
DataStorage s = DataStorage.get();
var e = s.getSourceCollections().stream()
.map(col -> CollectionListEntry.builder()

View file

@ -12,7 +12,7 @@ public class ListStoresExchangeImpl extends ListStoresExchange
implements MessageExchangeImpl<ListStoresExchange.Request, ListStoresExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
DataStorage s = DataStorage.get();
var e = s.getStoreEntries().stream()
.filter(entry -> !entry.isDisabled() && entry.getProvider().shouldShow())

View file

@ -9,7 +9,7 @@ public class RenameStoreExchangeImpl extends RenameStoreExchange
implements MessageExchangeImpl<RenameStoreExchange.Request, RenameStoreExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
var s = DataStorage.get().getStoreEntry(msg.getStoreName(), true);
DataStorage.get().renameStoreEntry(s, msg.getNewName());
return Response.builder().build();

View file

@ -15,7 +15,7 @@ public class SourceProviderListExchangeImpl extends SourceProviderListExchange
implements MessageExchangeImpl<SourceProviderListExchange.Request, SourceProviderListExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
var all = DataSourceProviders.getAll();
var map = new LinkedHashMap<DataSourceType, List<ProviderEntry>>();
for (DataSourceType t : DataSourceType.values()) {

View file

@ -9,7 +9,7 @@ public class StatusExchangeImpl extends StatusExchange
implements MessageExchangeImpl<StatusExchange.Request, StatusExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
public Response handleRequest(BeaconHandler handler, Request msg) {
String mode;
if (OperationMode.get() == null) {
mode = "none";

Some files were not shown because too many files have changed in this diff Show more