This commit is contained in:
crschnick 2023-05-19 16:32:17 +00:00
parent a4cd30311a
commit 7b5ea652b6
51 changed files with 279 additions and 363 deletions

View file

@ -8,7 +8,7 @@ import javafx.scene.control.Alert;
import java.util.List;
import java.util.stream.Collectors;
public class FileBrowserAlerts {
public class BrowserAlerts {
public static boolean showMoveAlert(List<FileSystem.FileEntry> source, FileSystem.FileEntry target) {
if (source.stream().noneMatch(entry -> entry.isDirectory())) {

View file

@ -23,15 +23,15 @@ import javafx.scene.layout.Region;
import java.util.Timer;
import java.util.TimerTask;
final class BookmarkList extends SimpleComp {
final class BrowserBookmarkList extends SimpleComp {
public static final Timer DROP_TIMER = new Timer("dnd", true);
private Point2D lastOver = new Point2D(-1, -1);
private TimerTask activeTask;
private final FileBrowserModel model;
private final BrowserModel model;
BookmarkList(FileBrowserModel model) {
BrowserBookmarkList(BrowserModel model) {
this.model = model;
}

View file

@ -14,11 +14,11 @@ import javafx.util.Callback;
import java.util.ArrayList;
public class FileBrowserBreadcrumbBar extends SimpleComp {
public class BrowserBreadcrumbBar extends SimpleComp {
private final OpenFileSystemModel model;
public FileBrowserBreadcrumbBar(OpenFileSystemModel model) {
public BrowserBreadcrumbBar(OpenFileSystemModel model) {
this.model = model;
}

View file

@ -12,7 +12,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class FileBrowserClipboard {
public class BrowserClipboard {
@Value
public static class Instance {

View file

@ -34,11 +34,11 @@ import static atlantafx.base.theme.Styles.DENSE;
import static atlantafx.base.theme.Styles.toggleStyleClass;
import static javafx.scene.control.TabPane.TabClosingPolicy.ALL_TABS;
public class FileBrowserComp extends SimpleComp {
public class BrowserComp extends SimpleComp {
private final FileBrowserModel model;
private final BrowserModel model;
public FileBrowserComp(FileBrowserModel model) {
public BrowserComp(BrowserModel model) {
this.model = model;
}
@ -50,16 +50,16 @@ public class FileBrowserComp extends SimpleComp {
FileIconManager.loadIfNecessary();
});
var bookmarksList = new BookmarkList(model).createRegion();
var bookmarksList = new BrowserBookmarkList(model).createRegion();
VBox.setVgrow(bookmarksList, Priority.ALWAYS);
var localDownloadStage = new LocalFileTransferComp(model.getLocalTransfersStage())
var localDownloadStage = new BrowserTransferComp(model.getLocalTransfersStage())
.hide(PlatformThread.sync(Bindings.createBooleanBinding(
() -> {
if (model.getOpenFileSystems().size() == 0) {
return true;
}
if (!model.getMode().equals(FileBrowserModel.Mode.BROWSER)) {
if (!model.getMode().equals(BrowserModel.Mode.BROWSER)) {
return true;
}
@ -89,7 +89,7 @@ public class FileBrowserComp extends SimpleComp {
}
private Region addBottomBar(Region r) {
if (model.getMode().equals(FileBrowserModel.Mode.BROWSER)) {
if (model.getMode().equals(BrowserModel.Mode.BROWSER)) {
return r;
}
@ -210,7 +210,7 @@ public class FileBrowserComp extends SimpleComp {
tabs.setTabDragPolicy(TabPane.TabDragPolicy.REORDER);
tabs.setTabMinWidth(Region.USE_COMPUTED_SIZE);
if (!model.getMode().equals(FileBrowserModel.Mode.BROWSER)) {
if (!model.getMode().equals(BrowserModel.Mode.BROWSER)) {
tabs.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
tabs.getStyleClass().add("singular");
} else {
@ -258,7 +258,7 @@ public class FileBrowserComp extends SimpleComp {
tab.setGraphic(label);
GrowAugment.create(true, false).augment(new SimpleCompStructure<>(label));
if (!this.model.getMode().equals(FileBrowserModel.Mode.BROWSER)) {
if (!this.model.getMode().equals(BrowserModel.Mode.BROWSER)) {
label.setManaged(false);
label.setVisible(false);
}

View file

@ -1,5 +1,3 @@
/* SPDX-License-Identifier: MIT */
package io.xpipe.app.browser;
import io.xpipe.app.browser.action.BranchAction;
@ -11,12 +9,12 @@ import javafx.scene.control.ContextMenu;
import javafx.scene.control.Menu;
import javafx.scene.control.SeparatorMenuItem;
final class FileContextMenu extends ContextMenu {
final class BrowserContextMenu extends ContextMenu {
private final OpenFileSystemModel model;
private final boolean empty;
public FileContextMenu(OpenFileSystemModel model, boolean empty) {
public BrowserContextMenu(OpenFileSystemModel model, boolean empty) {
super();
this.model = model;
this.empty = empty;
@ -28,7 +26,7 @@ final class FileContextMenu extends ContextMenu {
var selected = empty || model.getFileList().getSelected().isEmpty()
? FXCollections.observableArrayList(
new FileBrowserEntry(model.getCurrentDirectory(), model.getFileList(), false))
new BrowserEntry(model.getCurrentDirectory(), model.getFileList(), false))
: model.getFileList().getSelected();
for (BrowserAction.Category cat : BrowserAction.Category.values()) {

View file

@ -7,15 +7,15 @@ import io.xpipe.core.store.FileSystem;
import lombok.Getter;
@Getter
public class FileBrowserEntry {
public class BrowserEntry {
private final FileListModel model;
private final BrowserFileListModel model;
private final FileSystem.FileEntry rawFileEntry;
private final boolean synthetic;
private final FileType fileType;
private final DirectoryType directoryType;
public FileBrowserEntry(FileSystem.FileEntry rawFileEntry, FileListModel model, boolean synthetic) {
public BrowserEntry(FileSystem.FileEntry rawFileEntry, BrowserFileListModel model, boolean synthetic) {
this.rawFileEntry = rawFileEntry;
this.model = model;
this.synthetic = synthetic;

View file

@ -1,5 +1,3 @@
/* SPDX-License-Identifier: MIT */
package io.xpipe.app.browser;
import atlantafx.base.theme.Styles;
@ -44,7 +42,7 @@ import java.util.Objects;
import static io.xpipe.app.util.HumanReadableFormat.byteCount;
import static javafx.scene.control.TableColumn.SortType.ASCENDING;
final class FileListComp extends AnchorPane {
final class BrowserFileListComp extends AnchorPane {
private static final PseudoClass HIDDEN = PseudoClass.getPseudoClass("hidden");
private static final PseudoClass EMPTY = PseudoClass.getPseudoClass("empty");
@ -54,11 +52,11 @@ final class FileListComp extends AnchorPane {
private static final PseudoClass DRAG_OVER = PseudoClass.getPseudoClass("drag-over");
private static final PseudoClass DRAG_INTO_CURRENT = PseudoClass.getPseudoClass("drag-into-current");
private final FileListModel fileList;
private final BrowserFileListModel fileList;
public FileListComp(FileListModel fileList) {
public BrowserFileListComp(BrowserFileListModel fileList) {
this.fileList = fileList;
TableView<FileBrowserEntry> table = createTable();
TableView<BrowserEntry> table = createTable();
SimpleChangeListener.apply(table.comparatorProperty(), (newValue) -> {
fileList.setComparator(newValue);
});
@ -69,8 +67,8 @@ final class FileListComp extends AnchorPane {
}
@SuppressWarnings("unchecked")
private TableView<FileBrowserEntry> createTable() {
var filenameCol = new TableColumn<FileBrowserEntry, String>("Name");
private TableView<BrowserEntry> createTable() {
var filenameCol = new TableColumn<BrowserEntry, String>("Name");
filenameCol.setCellValueFactory(param -> new SimpleStringProperty(
param.getValue() != null
? FileNames.getFileName(
@ -80,22 +78,22 @@ final class FileListComp extends AnchorPane {
filenameCol.setSortType(ASCENDING);
filenameCol.setCellFactory(col -> new FilenameCell(fileList.getEditing()));
var sizeCol = new TableColumn<FileBrowserEntry, Number>("Size");
var sizeCol = new TableColumn<BrowserEntry, Number>("Size");
sizeCol.setCellValueFactory(param ->
new SimpleLongProperty(param.getValue().getRawFileEntry().getSize()));
sizeCol.setCellFactory(col -> new FileSizeCell());
var mtimeCol = new TableColumn<FileBrowserEntry, Instant>("Modified");
var mtimeCol = new TableColumn<BrowserEntry, Instant>("Modified");
mtimeCol.setCellValueFactory(param ->
new SimpleObjectProperty<>(param.getValue().getRawFileEntry().getDate()));
mtimeCol.setCellFactory(col -> new FileTimeCell());
var modeCol = new TableColumn<FileBrowserEntry, String>("Attributes");
var modeCol = new TableColumn<BrowserEntry, String>("Attributes");
modeCol.setCellValueFactory(param ->
new SimpleObjectProperty<>(param.getValue().getRawFileEntry().getMode()));
modeCol.setCellFactory(col -> new FileModeCell());
var table = new TableView<FileBrowserEntry>();
var table = new TableView<BrowserEntry>();
table.setPlaceholder(new Region());
table.getStyleClass().add(Styles.STRIPED);
table.getColumns().setAll(filenameCol, sizeCol, modeCol, mtimeCol);
@ -105,11 +103,11 @@ final class FileListComp extends AnchorPane {
return true;
}
var syntheticFirst = Comparator.<FileBrowserEntry, Boolean>comparing(path -> !path.isSynthetic());
var dirsFirst = Comparator.<FileBrowserEntry, Boolean>comparing(
var syntheticFirst = Comparator.<BrowserEntry, Boolean>comparing(path -> !path.isSynthetic());
var dirsFirst = Comparator.<BrowserEntry, Boolean>comparing(
path -> !path.getRawFileEntry().isDirectory());
Comparator<? super FileBrowserEntry> us =
Comparator<? super BrowserEntry> us =
syntheticFirst.thenComparing(dirsFirst).thenComparing(comp);
FXCollections.sort(param.getItems(), us);
return true;
@ -127,15 +125,15 @@ final class FileListComp extends AnchorPane {
return table;
}
private void prepareTableSelectionModel(TableView<FileBrowserEntry> table) {
if (fileList.getMode().equals(FileBrowserModel.Mode.SINGLE_FILE_CHOOSER)
|| fileList.getMode().equals(FileBrowserModel.Mode.DIRECTORY_CHOOSER)) {
private void prepareTableSelectionModel(TableView<BrowserEntry> table) {
if (fileList.getMode().equals(BrowserModel.Mode.SINGLE_FILE_CHOOSER)
|| fileList.getMode().equals(BrowserModel.Mode.DIRECTORY_CHOOSER)) {
table.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
} else {
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
table.getSelectionModel().getSelectedItems().addListener((ListChangeListener<? super FileBrowserEntry>) c -> {
table.getSelectionModel().getSelectedItems().addListener((ListChangeListener<? super BrowserEntry>) c -> {
// Explicitly unselect synthetic entries since we can't use a custom selection model as that is bugged in
// JavaFX
var toSelect = c.getList().stream()
@ -157,7 +155,7 @@ final class FileListComp extends AnchorPane {
});
});
fileList.getSelected().addListener((ListChangeListener<? super FileBrowserEntry>) c -> {
fileList.getSelected().addListener((ListChangeListener<? super BrowserEntry>) c -> {
if (c.getList().equals(table.getSelectionModel().getSelectedItems())) {
return;
}
@ -178,7 +176,7 @@ final class FileListComp extends AnchorPane {
});
}
private void prepareTableShortcuts(TableView<FileBrowserEntry> table) {
private void prepareTableShortcuts(TableView<BrowserEntry> table) {
table.setOnKeyPressed(event -> {
var selected = fileList.getSelected();
BrowserAction.getFlattened().stream()
@ -195,8 +193,8 @@ final class FileListComp extends AnchorPane {
});
}
private void prepareTableEntries(TableView<FileBrowserEntry> table) {
var emptyEntry = new FileListCompEntry(table, null, fileList);
private void prepareTableEntries(TableView<BrowserEntry> table) {
var emptyEntry = new BrowserFileListCompEntry(table, null, fileList);
table.setOnDragOver(event -> {
emptyEntry.onDragOver(event);
});
@ -214,17 +212,17 @@ final class FileListComp extends AnchorPane {
});
table.setRowFactory(param -> {
TableRow<FileBrowserEntry> row = new TableRow<>();
TableRow<BrowserEntry> row = new TableRow<>();
new ContextMenuAugment<>(false, () -> {
if (row.getItem() != null && row.getItem().isSynthetic()) {
return null;
}
return new FileContextMenu(fileList.getFileSystemModel(), row.getItem() == null);
return new BrowserContextMenu(fileList.getFileSystemModel(), row.getItem() == null);
})
.augment(new SimpleCompStructure<>(row));
var listEntry = Bindings.createObjectBinding(
() -> new FileListCompEntry(row, row.getItem(), fileList), row.itemProperty());
() -> new BrowserFileListCompEntry(row, row.getItem(), fileList), row.itemProperty());
row.itemProperty().addListener((observable, oldValue, newValue) -> {
row.pseudoClassStateChanged(DRAG, false);
@ -275,9 +273,9 @@ final class FileListComp extends AnchorPane {
}
private void prepareTableChanges(
TableView<FileBrowserEntry> table,
TableColumn<FileBrowserEntry, Instant> mtimeCol,
TableColumn<FileBrowserEntry, String> modeCol) {
TableView<BrowserEntry> table,
TableColumn<BrowserEntry, Instant> mtimeCol,
TableColumn<BrowserEntry, String> modeCol) {
var lastDir = new SimpleObjectProperty<FileSystem.FileEntry>();
Runnable updateHandler = () -> {
PlatformThread.runLaterIfNeeded(() -> {
@ -363,7 +361,7 @@ final class FileListComp extends AnchorPane {
}
}
private class FilenameCell extends TableCell<FileBrowserEntry, String> {
private class FilenameCell extends TableCell<BrowserEntry, String> {
private final StringProperty img = new SimpleStringProperty();
private final StringProperty text = new SimpleStringProperty();
@ -375,7 +373,7 @@ final class FileListComp extends AnchorPane {
private final BooleanProperty updating = new SimpleBooleanProperty();
public FilenameCell(Property<FileBrowserEntry> editing) {
public FilenameCell(Property<BrowserEntry> editing) {
editing.addListener((observable, oldValue, newValue) -> {
if (getTableRow().getItem() != null && getTableRow().getItem().equals(newValue)) {
PlatformThread.runLaterIfNeeded(() -> textField.requestFocus());
@ -440,7 +438,7 @@ final class FileListComp extends AnchorPane {
}
}
private static class FileSizeCell extends TableCell<FileBrowserEntry, Number> {
private static class FileSizeCell extends TableCell<BrowserEntry, Number> {
@Override
protected void updateItem(Number fileSize, boolean empty) {
@ -458,7 +456,7 @@ final class FileListComp extends AnchorPane {
}
}
private static class FileModeCell extends TableCell<FileBrowserEntry, String> {
private static class FileModeCell extends TableCell<BrowserEntry, String> {
@Override
protected void updateItem(String mode, boolean empty) {
@ -471,7 +469,7 @@ final class FileListComp extends AnchorPane {
}
}
private static class FileTimeCell extends TableCell<FileBrowserEntry, Instant> {
private static class FileTimeCell extends TableCell<BrowserEntry, Instant> {
@Override
protected void updateItem(Instant fileTime, boolean empty) {

View file

@ -12,18 +12,18 @@ import java.util.Timer;
import java.util.TimerTask;
@Getter
public class FileListCompEntry {
public class BrowserFileListCompEntry {
public static final Timer DROP_TIMER = new Timer("dnd", true);
private final Node row;
private final FileBrowserEntry item;
private final FileListModel model;
private final BrowserEntry item;
private final BrowserFileListModel model;
private Point2D lastOver = new Point2D(-1, -1);
private TimerTask activeTask;
public FileListCompEntry(Node row, FileBrowserEntry item, FileListModel model) {
public BrowserFileListCompEntry(Node row, BrowserEntry item, BrowserFileListModel model) {
this.row = row;
this.item = item;
this.model = model;
@ -47,7 +47,7 @@ public class FileListCompEntry {
}
if (t.getButton() == MouseButton.PRIMARY && t.isShiftDown()) {
var tv = ((TableView<FileBrowserEntry>) row.getParent().getParent().getParent().getParent());
var tv = ((TableView<BrowserEntry>) row.getParent().getParent().getParent().getParent());
var all = tv.getItems();
var min = tv.getSelectionModel().getSelectedItems().stream().mapToInt(entry -> all.indexOf(entry)).min().orElse(1);
var max = tv.getSelectionModel().getSelectedItems().stream().mapToInt(entry -> all.indexOf(entry)).max().orElse(all.size() - 1);
@ -69,7 +69,7 @@ public class FileListCompEntry {
return true;
}
if (FileBrowserClipboard.currentDragClipboard == null) {
if (BrowserClipboard.currentDragClipboard == null) {
return false;
}
@ -78,14 +78,14 @@ public class FileListCompEntry {
}
// Prevent drag and drops of files into the current directory
if (FileBrowserClipboard.currentDragClipboard
if (BrowserClipboard.currentDragClipboard
.getBaseDirectory().getPath()
.equals(model.getFileSystemModel().getCurrentDirectory().getPath()) && (item == null || !item.getRawFileEntry().isDirectory())) {
return false;
}
// Prevent dropping items onto themselves
if (item != null && FileBrowserClipboard.currentDragClipboard.getEntries().contains(item)) {
if (item != null && BrowserClipboard.currentDragClipboard.getEntries().contains(item)) {
return false;
}
@ -110,7 +110,7 @@ public class FileListCompEntry {
// Accept drops from inside the app window
if (event.getGestureSource() != null) {
var files = FileBrowserClipboard.retrieveDrag(event.getDragboard()).getEntries();
var files = BrowserClipboard.retrieveDrag(event.getDragboard()).getEntries();
var target = item != null && item.getRawFileEntry().isDirectory()
? item.getRawFileEntry()
: model.getFileSystemModel().getCurrentDirectory();
@ -141,9 +141,9 @@ public class FileListCompEntry {
var selected = model.getSelectedRaw();
Dragboard db = row.startDragAndDrop(TransferMode.COPY);
db.setContent(FileBrowserClipboard.startDrag(model.getFileSystemModel().getCurrentDirectory(), selected));
db.setContent(BrowserClipboard.startDrag(model.getFileSystemModel().getCurrentDirectory(), selected));
Image image = SelectedFileListComp.snapshot(selected);
Image image = BrowserSelectionListComp.snapshot(selected);
db.setDragView(image, -20, 15);
event.setDragDetect(true);
@ -204,7 +204,7 @@ public class FileListCompEntry {
return;
}
var tv = ((TableView<FileBrowserEntry>) row.getParent().getParent().getParent().getParent());
var tv = ((TableView<BrowserEntry>) row.getParent().getParent().getParent().getParent());
tv.getSelectionModel().select(item);
}

View file

@ -1,5 +1,3 @@
/* SPDX-License-Identifier: MIT */
package io.xpipe.app.browser;
import io.xpipe.app.fxcomps.util.BindingsHelper;
@ -23,29 +21,29 @@ import java.util.function.Predicate;
import java.util.stream.Stream;
@Getter
public final class FileListModel {
public final class BrowserFileListModel {
static final Comparator<FileBrowserEntry> FILE_TYPE_COMPARATOR =
static final Comparator<BrowserEntry> FILE_TYPE_COMPARATOR =
Comparator.comparing(path -> !path.getRawFileEntry().isDirectory());
static final Predicate<FileBrowserEntry> PREDICATE_ANY = path -> true;
static final Predicate<FileBrowserEntry> PREDICATE_NOT_HIDDEN = path -> true;
static final Predicate<BrowserEntry> PREDICATE_ANY = path -> true;
static final Predicate<BrowserEntry> PREDICATE_NOT_HIDDEN = path -> true;
private final OpenFileSystemModel fileSystemModel;
private final Property<Comparator<FileBrowserEntry>> comparatorProperty =
private final Property<Comparator<BrowserEntry>> comparatorProperty =
new SimpleObjectProperty<>(FILE_TYPE_COMPARATOR);
private final Property<List<FileBrowserEntry>> all = new SimpleObjectProperty<>(new ArrayList<>());
private final Property<List<FileBrowserEntry>> shown = new SimpleObjectProperty<>(new ArrayList<>());
private final ObjectProperty<Predicate<FileBrowserEntry>> predicateProperty =
private final Property<List<BrowserEntry>> all = new SimpleObjectProperty<>(new ArrayList<>());
private final Property<List<BrowserEntry>> shown = new SimpleObjectProperty<>(new ArrayList<>());
private final ObjectProperty<Predicate<BrowserEntry>> predicateProperty =
new SimpleObjectProperty<>(path -> true);
private final ObservableList<FileBrowserEntry> selected = FXCollections.observableArrayList();
private final ObservableList<BrowserEntry> selected = FXCollections.observableArrayList();
private final ObservableList<FileSystem.FileEntry> selectedRaw =
BindingsHelper.mappedContentBinding(selected, entry -> entry.getRawFileEntry());
private final Property<FileBrowserEntry> draggedOverDirectory = new SimpleObjectProperty<FileBrowserEntry>();
private final Property<BrowserEntry> draggedOverDirectory = new SimpleObjectProperty<BrowserEntry>();
private final Property<Boolean> draggedOverEmpty = new SimpleBooleanProperty();
private final Property<FileBrowserEntry> editing = new SimpleObjectProperty<>();
private final Property<BrowserEntry> editing = new SimpleObjectProperty<>();
public FileListModel(OpenFileSystemModel fileSystemModel) {
public BrowserFileListModel(OpenFileSystemModel fileSystemModel) {
this.fileSystemModel = fileSystemModel;
fileSystemModel.getFilter().addListener((observable, oldValue, newValue) -> {
@ -53,7 +51,7 @@ public final class FileListModel {
});
}
public FileBrowserModel.Mode getMode() {
public BrowserModel.Mode getMode() {
return fileSystemModel.getBrowserModel().getMode();
}
@ -61,23 +59,23 @@ public final class FileListModel {
try (var s = newFiles) {
var parent = fileSystemModel.getCurrentParentDirectory();
var l = Stream.concat(
parent != null ? Stream.of(new FileBrowserEntry(parent, this, true)) : Stream.of(),
parent != null ? Stream.of(new BrowserEntry(parent, this, true)) : Stream.of(),
s.filter(entry -> entry != null)
.limit(5000)
.map(entry -> new FileBrowserEntry(entry, this, false)))
.map(entry -> new BrowserEntry(entry, this, false)))
.toList();
all.setValue(l);
refreshShown();
}
}
public void setComparator(Comparator<FileBrowserEntry> comparator) {
public void setComparator(Comparator<BrowserEntry> comparator) {
comparatorProperty.setValue(comparator);
refreshShown();
}
private void refreshShown() {
List<FileBrowserEntry> filtered = fileSystemModel.getFilter().getValue() != null
List<BrowserEntry> filtered = fileSystemModel.getFilter().getValue() != null
? all.getValue().stream()
.filter(entry -> {
var name = FileNames.getFileName(
@ -90,7 +88,7 @@ public final class FileListModel {
.toList()
: all.getValue();
Comparator<FileBrowserEntry> tableComparator = comparatorProperty.getValue();
Comparator<BrowserEntry> tableComparator = comparatorProperty.getValue();
var comparator =
tableComparator != null ? FILE_TYPE_COMPARATOR.thenComparing(tableComparator) : FILE_TYPE_COMPARATOR;
var listCopy = new ArrayList<>(filtered);
@ -111,8 +109,8 @@ public final class FileListModel {
}
}
public void onDoubleClick(FileBrowserEntry entry) {
if (!entry.getRawFileEntry().isDirectory() && getMode().equals(FileBrowserModel.Mode.SINGLE_FILE_CHOOSER)) {
public void onDoubleClick(BrowserEntry entry) {
if (!entry.getRawFileEntry().isDirectory() && getMode().equals(BrowserModel.Mode.SINGLE_FILE_CHOOSER)) {
getFileSystemModel().getBrowserModel().finishChooser();
return;
}
@ -127,7 +125,7 @@ public final class FileListModel {
}
}
public ObjectProperty<Predicate<FileBrowserEntry>> predicateProperty() {
public ObjectProperty<Predicate<BrowserEntry>> predicateProperty() {
return predicateProperty;
}
}

View file

@ -13,7 +13,7 @@ import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import org.kordamp.ikonli.javafx.FontIcon;
public class FileFilterComp extends Comp<FileFilterComp.Structure> {
public class BrowserFilterComp extends Comp<BrowserFilterComp.Structure> {
@Override
public Structure createBase() {
@ -90,7 +90,7 @@ public class FileFilterComp extends Comp<FileFilterComp.Structure> {
private final Property<String> filterString;
public FileFilterComp(Property<String> filterString) {
public BrowserFilterComp(Property<String> filterString) {
this.filterString = filterString;
}
}

View file

@ -1,5 +1,3 @@
/* SPDX-License-Identifier: MIT */
package io.xpipe.app.browser;
import javafx.beans.binding.Bindings;
@ -12,7 +10,7 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
final class FileBrowserHistory {
final class BrowserHistory {
private final IntegerProperty cursor = new SimpleIntegerProperty(0);
private final List<String> history = new ArrayList<>();

View file

@ -15,9 +15,9 @@ import java.util.Objects;
import java.util.function.Consumer;
@Getter
public class FileBrowserModel {
public class BrowserModel {
public FileBrowserModel(Mode mode) {
public BrowserModel(Mode mode) {
this.mode = mode;
}
@ -29,7 +29,7 @@ public class FileBrowserModel {
DIRECTORY_CHOOSER
}
public static final FileBrowserModel DEFAULT = new FileBrowserModel(Mode.BROWSER);
public static final BrowserModel DEFAULT = new BrowserModel(Mode.BROWSER);
private final Mode mode;
@ -38,7 +38,7 @@ public class FileBrowserModel {
private final ObservableList<OpenFileSystemModel> openFileSystems = FXCollections.observableArrayList();
private final Property<OpenFileSystemModel> selected = new SimpleObjectProperty<>();
private final LocalFileTransferStage localTransfersStage = new LocalFileTransferStage();
private final BrowserTransferModel localTransfersStage = new BrowserTransferModel();
public void finishChooser() {
if (getMode().equals(Mode.BROWSER)) {

View file

@ -43,7 +43,7 @@ public class BrowserNavBar extends SimpleComp {
}
});
var breadcrumbs = new FileBrowserBreadcrumbBar(model)
var breadcrumbs = new BrowserBreadcrumbBar(model)
.hide(pathBar.focusedProperty())
.createRegion();

View file

@ -22,10 +22,10 @@ import lombok.Value;
@Value
@EqualsAndHashCode(callSuper = true)
public class SelectedFileListComp extends SimpleComp {
public class BrowserSelectionListComp extends SimpleComp {
public static Image snapshot(ObservableList<FileSystem.FileEntry> list) {
var r = new SelectedFileListComp(list).styleClass("drag").createRegion();
var r = new BrowserSelectionListComp(list).styleClass("drag").createRegion();
var scene = new Scene(r);
AppWindowHelper.setupStylesheets(scene);
AppStyle.addStylesheets(scene);

View file

@ -15,13 +15,13 @@ import lombok.Value;
@Value
@EqualsAndHashCode(callSuper = true)
public class FileBrowserStatusBarComp extends SimpleComp {
public class BrowserStatusBarComp extends SimpleComp {
OpenFileSystemModel model;
@Override
protected Region createSimple() {
var cc = PlatformThread.sync(FileBrowserClipboard.currentCopyClipboard);
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";
@ -60,7 +60,7 @@ public class FileBrowserStatusBarComp extends SimpleComp {
AppFont.small(bar);
// Use status bar as an extension of file list
new ContextMenuAugment<>(false, () -> new FileContextMenu(model,true)).augment(new SimpleCompStructure<>(bar));
new ContextMenuAugment<>(false, () -> new BrowserContextMenu(model, true)).augment(new SimpleCompStructure<>(bar));
return bar;
}

View file

@ -24,11 +24,11 @@ import org.kordamp.ikonli.javafx.FontIcon;
import java.io.IOException;
import java.util.List;
public class LocalFileTransferComp extends SimpleComp {
public class BrowserTransferComp extends SimpleComp {
private final LocalFileTransferStage stage;
private final BrowserTransferModel stage;
public LocalFileTransferComp(LocalFileTransferStage stage) {
public BrowserTransferComp(BrowserTransferModel stage) {
this.stage = stage;
}
@ -41,7 +41,7 @@ public class LocalFileTransferComp 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 SelectedFileListComp(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())))
@ -71,7 +71,7 @@ public class LocalFileTransferComp extends SimpleComp {
});
struc.get().setOnDragDropped(event -> {
if (event.getGestureSource() != null) {
var files = FileBrowserClipboard.retrieveDrag(event.getDragboard())
var files = BrowserClipboard.retrieveDrag(event.getDragboard())
.getEntries();
stage.drop(files);
event.setDropCompleted(true);
@ -97,7 +97,7 @@ public class LocalFileTransferComp extends SimpleComp {
cc.putFiles(files);
db.setContent(cc);
var image = SelectedFileListComp.snapshot(FXCollections.observableList(stage.getItems().stream()
var image = BrowserSelectionListComp.snapshot(FXCollections.observableList(stage.getItems().stream()
.map(item -> item.getFileEntry())
.toList()));
db.setDragView(image, -20, 15);

View file

@ -17,7 +17,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Value
public class LocalFileTransferStage {
public class BrowserTransferModel {
private static final Path TEMP =
FileUtils.getTempDirectory().toPath().resolve("xpipe").resolve("download");

View file

@ -18,11 +18,9 @@ import javafx.scene.input.KeyCombination;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import org.kordamp.ikonli.feather.Feather;
import org.kordamp.ikonli.javafx.FontIcon;
import static io.xpipe.app.browser.FileListModel.PREDICATE_NOT_HIDDEN;
import static io.xpipe.app.util.Controls.iconButton;
import static io.xpipe.app.browser.BrowserFileListModel.PREDICATE_NOT_HIDDEN;
public class OpenFileSystemComp extends SimpleComp {
@ -41,11 +39,11 @@ public class OpenFileSystemComp extends SimpleComp {
}
private Region createContent() {
var backBtn = iconButton(Feather.ARROW_LEFT, false);
var backBtn = new Button(null, new FontIcon("fth-arrow-left"));
backBtn.setOnAction(e -> model.back());
backBtn.disableProperty().bind(model.getHistory().canGoBackProperty().not());
var forthBtn = iconButton(Feather.ARROW_RIGHT, false);
var forthBtn = new Button(null, new FontIcon("fth-arrow-right"));
forthBtn.setOnAction(e -> model.forth());
forthBtn.disableProperty().bind(model.getHistory().canGoForthProperty().not());
@ -59,9 +57,9 @@ public class OpenFileSystemComp extends SimpleComp {
terminalBtn.disableProperty().bind(PlatformThread.sync(model.getNoDirectory()));
var menuButton = new MenuButton(null, new FontIcon("mdral-folder_open"));
new ContextMenuAugment<>(true, () -> new FileContextMenu(model, true)).augment(new SimpleCompStructure<>(menuButton));
new ContextMenuAugment<>(true, () -> new BrowserContextMenu(model, true)).augment(new SimpleCompStructure<>(menuButton));
var filter = new FileFilterComp(model.getFilter()).createStructure();
var filter = new BrowserFilterComp(model.getFilter()).createStructure();
Shortcuts.addShortcut(filter.toggleButton(), new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN));
var topBar = new ToolBar();
@ -70,11 +68,11 @@ public class OpenFileSystemComp extends SimpleComp {
// ~
FileListComp directoryView = new FileListComp(model.getFileList());
BrowserFileListComp directoryView = new BrowserFileListComp(model.getFileList());
var root = new VBox(topBar, directoryView);
if (model.getBrowserModel().getMode() == FileBrowserModel.Mode.BROWSER) {
root.getChildren().add(new FileBrowserStatusBarComp(model).createRegion());
if (model.getBrowserModel().getMode() == BrowserModel.Mode.BROWSER) {
root.getChildren().add(new BrowserStatusBarComp(model).createRegion());
}
VBox.setVgrow(directoryView, Priority.ALWAYS);
root.setPadding(Insets.EMPTY);

View file

@ -1,5 +1,3 @@
/* SPDX-License-Identifier: MIT */
package io.xpipe.app.browser;
import io.xpipe.app.comp.base.ModalOverlayComp;
@ -37,21 +35,21 @@ public final class OpenFileSystemModel {
private final FileSystemStore store;
private FileSystem fileSystem;
private final Property<String> filter = new SimpleStringProperty();
private final FileListModel fileList;
private final BrowserFileListModel fileList;
private final ReadOnlyObjectWrapper<String> currentPath = new ReadOnlyObjectWrapper<>();
private final FileBrowserHistory history = new FileBrowserHistory();
private final BrowserHistory history = new BrowserHistory();
private final BooleanProperty busy = new SimpleBooleanProperty();
private final FileBrowserModel browserModel;
private final BrowserModel browserModel;
private final BooleanProperty noDirectory = new SimpleBooleanProperty();
private final Property<OpenFileSystemSavedState> savedState = new SimpleObjectProperty<>();
private final OpenFileSystemCache cache = new OpenFileSystemCache(this);
private final Property<ModalOverlayComp.OverlayContent> overlay = new SimpleObjectProperty<>();
private boolean local;
public OpenFileSystemModel(FileBrowserModel browserModel, FileSystemStore store) {
public OpenFileSystemModel(BrowserModel browserModel, FileSystemStore store) {
this.browserModel = browserModel;
this.store = store;
fileList = new FileListModel(this);
fileList = new BrowserFileListModel(this);
addListeners();
}
@ -243,7 +241,7 @@ public final class OpenFileSystemModel {
var same = files.get(0).getFileSystem().equals(target.getFileSystem());
if (same) {
if (!FileBrowserAlerts.showMoveAlert(files, target)) {
if (!BrowserAlerts.showMoveAlert(files, target)) {
return;
}
}
@ -309,7 +307,7 @@ public final class OpenFileSystemModel {
return;
}
if (!FileBrowserAlerts.showDeleteAlert(fileList.getSelectedRaw())) {
if (!BrowserAlerts.showDeleteAlert(fileList.getSelectedRaw())) {
return;
}
@ -391,7 +389,7 @@ public final class OpenFileSystemModel {
});
}
public FileBrowserHistory getHistory() {
public BrowserHistory getHistory() {
return history;
}

View file

@ -37,8 +37,8 @@ public class StandaloneFileBrowser {
public static void openSingleFile(Property<FileStore> file) {
PlatformThread.runLaterIfNeeded(() -> {
var model = new FileBrowserModel(FileBrowserModel.Mode.SINGLE_FILE_CHOOSER);
var comp = new FileBrowserComp(model)
var model = new BrowserModel(BrowserModel.Mode.SINGLE_FILE_CHOOSER);
var comp = new BrowserComp(model)
.apply(struc -> struc.get().setPrefSize(1200, 700))
.apply(struc -> AppFont.normal(struc.get()));
var window = AppWindowHelper.sideWindow(AppI18n.get("openFileTitle"), stage -> comp, true, null);
@ -52,8 +52,8 @@ public class StandaloneFileBrowser {
public static void saveSingleFile(Property<FileStore> file) {
PlatformThread.runLaterIfNeeded(() -> {
var model = new FileBrowserModel(FileBrowserModel.Mode.SINGLE_FILE_SAVE);
var comp = new FileBrowserComp(model)
var model = new BrowserModel(BrowserModel.Mode.SINGLE_FILE_SAVE);
var comp = new BrowserComp(model)
.apply(struc -> struc.get().setPrefSize(1200, 700))
.apply(struc -> AppFont.normal(struc.get()));
var window = AppWindowHelper.sideWindow(AppI18n.get("saveFileTitle"), stage -> comp, true, null);

View file

@ -1,6 +1,6 @@
package io.xpipe.app.browser.action;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import java.util.List;
@ -10,7 +10,7 @@ public interface ApplicationPathAction extends BrowserAction {
public abstract String getExecutable();
@Override
public default boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public default boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
if (entries.size() == 0) {
return false;
}
@ -18,10 +18,10 @@ public interface ApplicationPathAction extends BrowserAction {
return entries.stream().allMatch(entry -> isApplicable(model, entry));
}
boolean isApplicable(OpenFileSystemModel model, FileBrowserEntry entry);
boolean isApplicable(OpenFileSystemModel model, BrowserEntry entry);
@Override
public default boolean isActive(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
return model.getCache().isApplicationInPath(getExecutable());
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.app.browser.action;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.util.ModuleLayerLoader;
@ -32,7 +32,7 @@ public interface BrowserAction {
.toList();
}
default Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
default Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return null;
}
@ -48,13 +48,13 @@ public interface BrowserAction {
return false;
}
public abstract String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries);
public abstract String getName(OpenFileSystemModel model, List<BrowserEntry> entries);
public default boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public default boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return true;
}
public default boolean isActive(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
return true;
}

View file

@ -1,6 +1,6 @@
package io.xpipe.app.browser.action;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.util.ScriptHelper;
import io.xpipe.core.process.ShellControl;
@ -10,9 +10,9 @@ import java.util.List;
public abstract class ExecuteApplicationAction implements LeafAction, ApplicationPathAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
for (FileBrowserEntry entry : entries) {
for (BrowserEntry entry : entries) {
var command = detach() ? ScriptHelper.createDetachCommand(sc, createCommand(model, entry)) : createCommand(model, entry);
try (var cc = sc.command(command).workingDirectory(model.getCurrentDirectory().getPath()).start()) {
cc.discardOrThrow();
@ -24,6 +24,6 @@ public abstract class ExecuteApplicationAction implements LeafAction, Applicatio
return false;
}
protected abstract String createCommand(OpenFileSystemModel model, FileBrowserEntry entry);
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
}

View file

@ -1,6 +1,6 @@
package io.xpipe.app.browser.action;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.util.BusyProperty;
import io.xpipe.app.util.ThreadHelper;
@ -11,9 +11,9 @@ import java.util.function.UnaryOperator;
public interface LeafAction extends BrowserAction {
public abstract void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception;
public abstract void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception;
default MenuItem toItem(OpenFileSystemModel model, List<FileBrowserEntry> selected, UnaryOperator<String> nameFunc) {
default MenuItem toItem(OpenFileSystemModel model, List<BrowserEntry> selected, UnaryOperator<String> nameFunc) {
var mi = new MenuItem(nameFunc.apply(getName(model, selected)));
mi.setOnAction(event -> {
ThreadHelper.runFailableAsync(() -> {

View file

@ -1,6 +1,6 @@
package io.xpipe.app.browser.action;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.ScriptHelper;
@ -13,11 +13,11 @@ import java.util.List;
public abstract class MultiExecuteAction implements BranchAction {
protected String filesArgument(List<FileBrowserEntry> entries) {
protected String filesArgument(List<BrowserEntry> entries) {
return entries.size() == 1 ? entries.get(0).getOptionallyQuotedFileName() : "(" + entries.size() + ")";
}
protected abstract String createCommand(ShellControl sc, OpenFileSystemModel model, FileBrowserEntry entry);
protected abstract String createCommand(ShellControl sc, OpenFileSystemModel model, BrowserEntry entry);
@Override
public List<LeafAction> getBranchingActions() {
@ -25,10 +25,10 @@ public abstract class MultiExecuteAction implements BranchAction {
new LeafAction() {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
model.withShell(
pc -> {
for (FileBrowserEntry entry : entries) {
for (BrowserEntry entry : entries) {
var cmd = pc.command(createCommand(pc, model, entry))
.workingDirectory(model.getCurrentDirectory()
.getPath())
@ -44,17 +44,17 @@ public abstract class MultiExecuteAction implements BranchAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "in " + AppPrefs.get().terminalType().getValue().toTranslatedString();
}
},
new LeafAction() {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
model.withShell(
pc -> {
for (FileBrowserEntry entry : entries) {
for (BrowserEntry entry : entries) {
var cmd = ScriptHelper.createDetachCommand(
pc, createCommand(pc, model, entry));
pc.command(cmd)
@ -67,17 +67,17 @@ public abstract class MultiExecuteAction implements BranchAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "in background";
}
},
new LeafAction() {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
model.withShell(
pc -> {
for (FileBrowserEntry entry : entries) {
for (BrowserEntry entry : entries) {
pc.command(createCommand(pc, model, entry))
.workingDirectory(model.getCurrentDirectory()
.getPath())
@ -88,7 +88,7 @@ public abstract class MultiExecuteAction implements BranchAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "wait for completion";
}
});

View file

@ -4,7 +4,7 @@ import io.xpipe.app.fxcomps.impl.PrettyImageComp;
import io.xpipe.core.store.FileSystem;
import javafx.beans.property.SimpleStringProperty;
public class FileBrowserIcons {
public class BrowserIcons {
public static PrettyImageComp createDefaultFileIcon() {
return new PrettyImageComp(new SimpleStringProperty("default_file.svg"), 22, 22);
}

View file

@ -1,7 +1,7 @@
package io.xpipe.app.comp;
import io.xpipe.app.browser.FileBrowserComp;
import io.xpipe.app.browser.FileBrowserModel;
import io.xpipe.app.browser.BrowserComp;
import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.comp.about.AboutTabComp;
import io.xpipe.app.comp.base.SideMenuBarComp;
import io.xpipe.app.comp.storage.store.StoreLayoutComp;
@ -47,7 +47,7 @@ public class AppLayoutComp extends Comp<CompStructure<BorderPane>> {
new SideMenuBarComp.Entry(
AppI18n.observable("browser"),
"mdi2f-file-cabinet",
new FileBrowserComp(FileBrowserModel.DEFAULT)),
new BrowserComp(BrowserModel.DEFAULT)),
// new SideMenuBarComp.Entry(AppI18n.observable("data"), "mdsal-dvr", new SourceCollectionLayoutComp()),
new SideMenuBarComp.Entry(
AppI18n.observable("settings"), "mdsmz-miscellaneous_services", new PrefsComp(this)),

View file

@ -1,6 +1,6 @@
package io.xpipe.app.launcher;
import io.xpipe.app.browser.FileBrowserModel;
import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.issue.ErrorEvent;
@ -117,7 +117,7 @@ public abstract class LauncherInput {
}
var dir = Files.isDirectory(file) ? file : file.getParent();
FileBrowserModel.DEFAULT.openFileSystemAsync(ShellStore.createLocal(), dir.toString());
BrowserModel.DEFAULT.openFileSystemAsync(ShellStore.createLocal(), dir.toString());
}
@Override

View file

@ -1,5 +1,3 @@
/* SPDX-License-Identifier: MIT */
package io.xpipe.app.util;
import javafx.geometry.Insets;

View file

@ -1,73 +1,5 @@
/* SPDX-License-Identifier: MIT */
package io.xpipe.app.util;
import javafx.scene.control.*;
import javafx.scene.input.KeyCombination;
import org.kordamp.ikonli.Ikon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.net.URI;
import static atlantafx.base.theme.Styles.BUTTON_ICON;
public final class Controls {
public static Button iconButton(Ikon icon, boolean disable) {
return button("", icon, disable, BUTTON_ICON);
}
public static Button button(String text, Ikon icon, boolean disable, String... styleClasses) {
var button = new Button(text);
if (icon != null) {
button.setGraphic(new FontIcon(icon));
}
button.setDisable(disable);
button.getStyleClass().addAll(styleClasses);
return button;
}
public static MenuItem menuItem(String text, Ikon graphic, KeyCombination accelerator) {
return menuItem(text, graphic, accelerator, false);
}
public static MenuItem menuItem(String text, Ikon graphic, KeyCombination accelerator, boolean disable) {
var item = new MenuItem(text);
if (graphic != null) {
item.setGraphic(new FontIcon(graphic));
}
if (accelerator != null) {
item.setAccelerator(accelerator);
}
item.setDisable(disable);
return item;
}
public static ToggleButton toggleButton(String text,
Ikon icon,
ToggleGroup group,
boolean selected,
String... styleClasses) {
var toggleButton = new ToggleButton(text);
if (icon != null) {
toggleButton.setGraphic(new FontIcon(icon));
}
if (group != null) {
toggleButton.setToggleGroup(group);
}
toggleButton.setSelected(selected);
toggleButton.getStyleClass().addAll(styleClasses);
return toggleButton;
}
public static Hyperlink hyperlink(String text, URI uri) {
var hyperlink = new Hyperlink(text);
if (uri != null) {
hyperlink.setOnAction(event -> Hyperlinks.open(uri.toString()));
}
return hyperlink;
}
}

View file

@ -1,5 +1,3 @@
/* SPDX-License-Identifier: MIT */
package io.xpipe.app.util;
import java.text.CharacterIterator;

View file

@ -1,7 +1,7 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserClipboard;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserClipboard;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import javafx.scene.Node;
@ -15,8 +15,8 @@ import java.util.List;
public class CopyAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
FileBrowserClipboard.startCopy(
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
BrowserClipboard.startCopy(
model.getCurrentDirectory(), entries.stream().map(entry -> entry.getRawFileEntry()).toList());
}
@ -26,7 +26,7 @@ public class CopyAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2c-content-copy");
}
@ -41,7 +41,7 @@ public class CopyAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Copy";
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.BranchAction;
import io.xpipe.app.browser.action.BrowserAction;
@ -16,7 +16,7 @@ import java.util.stream.Collectors;
public class CopyPathAction implements BrowserAction, BranchAction {
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Copy location";
}
@ -35,12 +35,12 @@ public class CopyPathAction implements BrowserAction, BranchAction {
return List.of(
new LeafAction() {
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Absolute Path";
}
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
var s = entries.stream()
.map(entry -> entry.getRawFileEntry().getPath())
.collect(Collectors.joining("\n"));
@ -51,17 +51,17 @@ public class CopyPathAction implements BrowserAction, BranchAction {
},
new LeafAction() {
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Absolute Path (Quoted)";
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.stream().anyMatch(entry -> entry.getRawFileEntry().getPath().contains(" "));
}
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
var s = entries.stream()
.map(entry -> "\"" + entry.getRawFileEntry().getPath() + "\"")
.collect(Collectors.joining("\n"));
@ -72,12 +72,12 @@ public class CopyPathAction implements BrowserAction, BranchAction {
},
new LeafAction() {
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "File Name";
}
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
var s = entries.stream()
.map(entry ->
FileNames.getFileName(entry.getRawFileEntry().getPath()))
@ -89,17 +89,17 @@ public class CopyPathAction implements BrowserAction, BranchAction {
},
new LeafAction() {
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "File Name (Quoted)";
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.stream().anyMatch(entry -> FileNames.getFileName(entry.getRawFileEntry().getPath()).contains(" "));
}
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
var s = entries.stream()
.map(entry ->
"\"" + FileNames.getFileName(entry.getRawFileEntry().getPath()) + "\"")

View file

@ -1,7 +1,7 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserAlerts;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserAlerts;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.FileSystemHelper;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
@ -16,9 +16,9 @@ import java.util.List;
public class DeleteAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
var toDelete = entries.stream().map(entry -> entry.getRawFileEntry()).toList();
if (!FileBrowserAlerts.showDeleteAlert(toDelete)) {
if (!BrowserAlerts.showDeleteAlert(toDelete)) {
return;
}
@ -32,7 +32,7 @@ public class DeleteAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2d-delete");
}
@ -42,7 +42,7 @@ public class DeleteAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Delete";
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.app.prefs.AppPrefs;
@ -13,8 +13,8 @@ import java.util.List;
public class EditFileAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
for (FileBrowserEntry entry : entries) {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
for (BrowserEntry entry : entries) {
FileOpener.openInTextEditor(entry.getRawFileEntry());
}
}
@ -25,17 +25,17 @@ public class EditFileAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2p-pencil");
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.stream().noneMatch(entry -> entry.getRawFileEntry().isDirectory());
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Edit with " + AppPrefs.get().externalEditor().getValue().toTranslatedString();
}
}

View file

@ -1,9 +1,9 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.BrowserAction;
import io.xpipe.app.browser.icon.FileBrowserIcons;
import io.xpipe.app.browser.icon.BrowserIcons;
import io.xpipe.app.browser.icon.FileType;
import javafx.scene.Node;
@ -12,14 +12,14 @@ import java.util.List;
public interface FileTypeAction extends BrowserAction {
@Override
default boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
default boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
var t = getType();
return entries.stream().allMatch(entry -> t.matches(entry.getRawFileEntry()));
}
@Override
default Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
return FileBrowserIcons.createIcon(getType()).createRegion();
default Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return BrowserIcons.createIcon(getType()).createRegion();
}
FileType getType();

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.icon.FileType;
import io.xpipe.core.process.ShellControl;
@ -15,22 +15,22 @@ public class JarAction extends JavaAction implements FileTypeAction {
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return super.isApplicable(model, entries) && FileTypeAction.super.isApplicable(model, entries);
}
@Override
public boolean isApplicable(OpenFileSystemModel model, FileBrowserEntry entry) {
public boolean isApplicable(OpenFileSystemModel model, BrowserEntry entry) {
return entry.getFileName().endsWith(".jar");
}
@Override
protected String createCommand(ShellControl sc, OpenFileSystemModel model, FileBrowserEntry entry) {
protected String createCommand(ShellControl sc, OpenFileSystemModel model, BrowserEntry entry) {
return "java -jar " + entry.getOptionallyQuotedFileName();
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "java -jar " + filesArgument(entries);
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.ApplicationPathAction;
import io.xpipe.app.browser.action.MultiExecuteAction;
@ -10,7 +10,7 @@ import java.util.List;
public abstract class JavaAction extends MultiExecuteAction implements ApplicationPathAction {
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Java";
}

View file

@ -1,11 +1,11 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.BranchAction;
import io.xpipe.app.browser.action.BrowserAction;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.app.browser.icon.FileBrowserIcons;
import io.xpipe.app.browser.icon.BrowserIcons;
import io.xpipe.app.comp.base.ModalOverlayComp;
import io.xpipe.app.fxcomps.Comp;
import javafx.beans.property.SimpleStringProperty;
@ -18,12 +18,12 @@ import java.util.List;
public class NewItemAction implements BrowserAction, BranchAction {
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2p-plus-box-outline");
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "New";
}
@ -33,7 +33,7 @@ public class NewItemAction implements BrowserAction, BranchAction {
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.size() == 1 && entries.get(0).getRawFileEntry().getPath().equals(model.getCurrentPath().get());
}
@ -47,12 +47,12 @@ public class NewItemAction implements BrowserAction, BranchAction {
return List.of(
new LeafAction() {
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "File";
}
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
var name = new SimpleStringProperty();
model.getOverlay().setValue(new ModalOverlayComp.OverlayContent("newFile", Comp.of(() -> {
var creationName = new TextField();
@ -64,18 +64,18 @@ public class NewItemAction implements BrowserAction, BranchAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
return FileBrowserIcons.createDefaultFileIcon().createRegion();
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return BrowserIcons.createDefaultFileIcon().createRegion();
}
},
new LeafAction() {
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Directory";
}
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
var name = new SimpleStringProperty();
model.getOverlay().setValue(new ModalOverlayComp.OverlayContent("newDirectory", Comp.of(() -> {
var creationName = new TextField();
@ -86,8 +86,8 @@ public class NewItemAction implements BrowserAction, BranchAction {
}));
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
return FileBrowserIcons.createDefaultDirectoryIcon().createRegion();
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return BrowserIcons.createDefaultDirectoryIcon().createRegion();
}
});
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import javafx.scene.Node;
@ -14,7 +14,7 @@ import java.util.List;
public class OpenDirectoryAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
model.cd(entries.get(0).getRawFileEntry().getPath());
}
@ -24,12 +24,12 @@ public class OpenDirectoryAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2f-folder-open");
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.size() == 1 && entries.stream().allMatch(entry -> entry.getRawFileEntry().isDirectory());
}
@ -39,7 +39,7 @@ public class OpenDirectoryAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Open";
}
}

View file

@ -1,7 +1,7 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.FileBrowserModel;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import javafx.scene.Node;
@ -15,7 +15,7 @@ import java.util.List;
public class OpenDirectoryInNewTabAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
model.getBrowserModel().openFileSystemAsync(model.getStore().asNeeded(), entries.get(0).getRawFileEntry().getPath());
}
@ -25,13 +25,13 @@ public class OpenDirectoryInNewTabAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2f-folder-open-outline");
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
return entries.size() == 1 && entries.stream().allMatch(entry -> entry.getRawFileEntry().isDirectory()) && model.getBrowserModel().getMode() == FileBrowserModel.Mode.BROWSER;
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.size() == 1 && entries.stream().allMatch(entry -> entry.getRawFileEntry().isDirectory()) && model.getBrowserModel().getMode() == BrowserModel.Mode.BROWSER;
}
@Override
@ -45,7 +45,7 @@ public class OpenDirectoryInNewTabAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Open in new tab";
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.app.util.FileOpener;
@ -15,7 +15,7 @@ import java.util.List;
public class OpenFileDefaultAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
for (var entry : entries) {
FileOpener.openInDefaultApplication(entry.getRawFileEntry());
}
@ -27,12 +27,12 @@ public class OpenFileDefaultAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2b-book-open-variant");
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.stream().noneMatch(entry -> entry.getRawFileEntry().isDirectory());
}
@ -42,7 +42,7 @@ public class OpenFileDefaultAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Open";
}
}

View file

@ -2,7 +2,7 @@ package io.xpipe.ext.base.browser;
import com.sun.jna.platform.win32.Shell32;
import com.sun.jna.platform.win32.WinUser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.core.process.OsType;
@ -19,7 +19,7 @@ import java.util.List;
public class OpenFileWithAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
switch (OsType.getLocal()) {
case OsType.Windows windows -> {
Shell32.INSTANCE.ShellExecute(
@ -48,12 +48,12 @@ public class OpenFileWithAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2b-book-open-page-variant-outline");
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
var os = model.getFileSystem().getShell();
return os.isPresent()
&& !os.get().getOsType().equals(OsType.MACOS)
@ -67,7 +67,7 @@ public class OpenFileWithAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Open with ...";
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.core.process.OsType;
@ -12,17 +12,17 @@ import java.util.List;
public class OpenInNativeManagerAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
ShellControl sc = model.getFileSystem().getShell().get();
ShellDialect d = sc.getShellDialect();
for (FileBrowserEntry entry : entries) {
for (BrowserEntry entry : entries) {
var e = entry.getRawFileEntry().getPath();
switch (OsType.getLocal()) {
case OsType.Windows windows -> {
sc.executeSimpleCommand("explorer " + d.fileArgument(e));
}
case OsType.Linux linux -> {
var action = entry.getRawFileEntry().isDirectory() ? "org.freedesktop.FileManager1.ShowFolders" : "org.freedesktop.FileManager1.ShowFiles";
var action = entry.getRawFileEntry().isDirectory() ? "org.freedesktop.FileManager1.ShowFolders" : "org.freedesktop.FileManager1.ShowItems";
var dbus = String.format("""
dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 %s array:string:"file://%s" string:""
""", action, entry.getRawFileEntry().getPath());
@ -47,12 +47,12 @@ public class OpenInNativeManagerAction implements LeafAction {
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return model.isLocal();
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return switch (OsType.getLocal()) {
case OsType.Windows windows -> "Browse in Windows Explorer";
case OsType.Linux linux -> "Browse in default file manager";

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.core.impl.FileNames;
@ -13,9 +13,9 @@ import java.util.List;
public class OpenNativeFileDetailsAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
ShellControl sc = model.getFileSystem().getShell().get();
for (FileBrowserEntry entry : entries) {
for (BrowserEntry entry : entries) {
var e = entry.getRawFileEntry().getPath();
switch (OsType.getLocal()) {
case OsType.Windows windows -> {
@ -57,13 +57,13 @@ public class OpenNativeFileDetailsAction implements LeafAction {
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
var os = model.getFileSystem().getShell();
return os.isPresent();
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
var sc = model.getFileSystem().getShell();
return sc.isPresent() && !sc.get().getOsType().equals(OsType.WINDOWS);
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Show details";
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.app.prefs.AppPrefs;
@ -15,7 +15,7 @@ import java.util.List;
public class OpenTerminalAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
if (entries.size() == 0) {
model.openTerminalAsync(model.getCurrentDirectory().getPath());
return;
@ -32,12 +32,12 @@ public class OpenTerminalAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2c-console");
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.stream().allMatch(entry -> entry.getRawFileEntry().isDirectory());
}
@ -47,7 +47,7 @@ public class OpenTerminalAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Open in " + AppPrefs.get().terminalType().getValue().toTranslatedString();
}
}

View file

@ -1,7 +1,7 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserClipboard;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserClipboard;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import javafx.scene.Node;
@ -15,8 +15,8 @@ import java.util.List;
public class PasteAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
var clipboard = FileBrowserClipboard.retrieveCopy();
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
var clipboard = BrowserClipboard.retrieveCopy();
if (clipboard == null) {
return;
}
@ -32,18 +32,18 @@ public class PasteAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2c-content-paste");
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.size() < 2 && entries.stream().allMatch(entry -> entry.getRawFileEntry().isDirectory());
}
@Override
public boolean isActive(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
return FileBrowserClipboard.retrieveCopy() != null;
public boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
return BrowserClipboard.retrieveCopy() != null;
}
@Override
@ -57,7 +57,7 @@ public class PasteAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Paste";
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import javafx.scene.Node;
@ -14,7 +14,7 @@ import java.util.List;
public class RenameAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<FileBrowserEntry> entries) throws Exception {
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
model.getFileList().getEditing().setValue(entries.get(0));
}
@ -24,12 +24,12 @@ public class RenameAction implements LeafAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2r-rename-box");
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.size() == 1;
}
@ -39,7 +39,7 @@ public class RenameAction implements LeafAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Rename";
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.MultiExecuteAction;
import io.xpipe.core.process.OsType;
@ -45,22 +45,22 @@ public class RunAction extends MultiExecuteAction {
}
@Override
public Node getIcon(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
return new FontIcon("mdi2p-play");
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "Run";
}
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
return entries.stream().allMatch(entry -> isExecutable(entry.getRawFileEntry()));
}
@Override
protected String createCommand(ShellControl sc, OpenFileSystemModel model, FileBrowserEntry entry) {
protected String createCommand(ShellControl sc, OpenFileSystemModel model, BrowserEntry entry) {
return sc.getShellDialect().runScript(entry.getFileName());
}
}

View file

@ -1,6 +1,6 @@
package io.xpipe.ext.base.browser;
import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.ExecuteApplicationAction;
import io.xpipe.core.impl.FileNames;
@ -16,12 +16,12 @@ public class UnzipAction extends ExecuteApplicationAction {
}
@Override
public boolean isApplicable(OpenFileSystemModel model, FileBrowserEntry entry) {
public boolean isApplicable(OpenFileSystemModel model, BrowserEntry entry) {
return entry.getRawFileEntry().getPath().endsWith(".zip") && !OsType.getLocal().equals(OsType.WINDOWS);
}
@Override
protected String createCommand(OpenFileSystemModel model, FileBrowserEntry entry) {
protected String createCommand(OpenFileSystemModel model, BrowserEntry entry) {
return "unzip -o " + entry.getOptionallyQuotedFileName() + " -d " + FileNames.quoteIfNecessary(FileNames.getBaseName(entry.getFileName()));
}
@ -31,7 +31,7 @@ public class UnzipAction extends ExecuteApplicationAction {
}
@Override
public String getName(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
return "unzip [...]";
}
}