mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-22 07:29:05 -04:00
Remove selection mode class
This commit is contained in:
@@ -4,7 +4,6 @@ import io.xpipe.app.browser.file.BrowserConnectionListComp;
|
||||
import io.xpipe.app.browser.file.BrowserConnectionListFilterComp;
|
||||
import io.xpipe.app.browser.file.BrowserEntry;
|
||||
import io.xpipe.app.browser.file.BrowserFileSystemTabComp;
|
||||
import io.xpipe.app.browser.file.BrowserFileSystemTabModel;
|
||||
import io.xpipe.app.comp.Comp;
|
||||
import io.xpipe.app.comp.base.*;
|
||||
import io.xpipe.app.core.AppFontSizes;
|
||||
@@ -50,13 +49,14 @@ public class BrowserFileChooserSessionComp extends ModalOverlayContentComp {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public static void openSingleFile(
|
||||
public static void open(
|
||||
Supplier<DataStoreEntryRef<? extends FileSystemStore>> store,
|
||||
Supplier<FilePath> initialPath,
|
||||
Consumer<FileReference> file,
|
||||
boolean save,
|
||||
boolean directory,
|
||||
Predicate<DataStoreEntry> filter) {
|
||||
var model = new BrowserFileChooserSessionModel(BrowserFileSystemTabModel.SelectionMode.SINGLE_FILE);
|
||||
var model = new BrowserFileChooserSessionModel(directory);
|
||||
model.setOnFinish(fileStores -> {
|
||||
file.accept(fileStores.size() > 0 ? fileStores.getFirst() : null);
|
||||
});
|
||||
|
||||
@@ -27,14 +27,14 @@ import java.util.function.Consumer;
|
||||
@Getter
|
||||
public class BrowserFileChooserSessionModel extends BrowserAbstractSessionModel<BrowserFileSystemTabModel> {
|
||||
|
||||
private final BrowserFileSystemTabModel.SelectionMode selectionMode;
|
||||
private final ObservableList<BrowserEntry> fileSelection = FXCollections.observableArrayList();
|
||||
private final boolean directory;
|
||||
|
||||
@Setter
|
||||
private Consumer<List<FileReference>> onFinish;
|
||||
|
||||
public BrowserFileChooserSessionModel(BrowserFileSystemTabModel.SelectionMode selectionMode) {
|
||||
this.selectionMode = selectionMode;
|
||||
public BrowserFileChooserSessionModel(boolean directory) {
|
||||
this.directory = directory;
|
||||
selectedEntry.addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue == null) {
|
||||
fileSelection.clear();
|
||||
@@ -96,7 +96,6 @@ public class BrowserFileChooserSessionModel extends BrowserAbstractSessionModel<
|
||||
model = new BrowserFileSystemTabModel(
|
||||
this,
|
||||
store,
|
||||
selectionMode,
|
||||
customFileSystemFactory != null
|
||||
? customFileSystemFactory
|
||||
: ref -> ref.getStore().createFileSystem());
|
||||
|
||||
@@ -65,7 +65,6 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel<Browser
|
||||
var tab = new BrowserFileSystemTabModel(
|
||||
DEFAULT,
|
||||
DataStorage.get().local().ref(),
|
||||
BrowserFileSystemTabModel.SelectionMode.ALL,
|
||||
ref -> ref.getStore().createFileSystem());
|
||||
try {
|
||||
DEFAULT.openSync(tab, null);
|
||||
@@ -233,7 +232,6 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel<Browser
|
||||
model = new BrowserFileSystemTabModel(
|
||||
this,
|
||||
store,
|
||||
BrowserFileSystemTabModel.SelectionMode.ALL,
|
||||
customFileSystemFactory != null
|
||||
? customFileSystemFactory
|
||||
: ref -> ref.getStore().createFileSystem());
|
||||
|
||||
@@ -336,11 +336,7 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||
}
|
||||
|
||||
private void prepareTableSelectionModel(TableView<BrowserEntry> table) {
|
||||
if (!fileList.getSelectionMode().isMultiple()) {
|
||||
table.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||
} else {
|
||||
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
}
|
||||
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
table.getSelectionModel().setCellSelectionEnabled(false);
|
||||
|
||||
var updateFromModel = new BooleanScope(new SimpleBooleanProperty());
|
||||
|
||||
@@ -24,8 +24,6 @@ public final class BrowserFileListModel {
|
||||
static final Comparator<BrowserEntry> FILE_TYPE_COMPARATOR =
|
||||
Comparator.comparing(path -> path.getRawFileEntry().resolved().getKind() != FileKind.DIRECTORY);
|
||||
|
||||
private final BrowserFileSystemTabModel.SelectionMode selectionMode;
|
||||
|
||||
private final BrowserFileSystemTabModel fileSystemModel;
|
||||
private final Property<Comparator<BrowserEntry>> comparatorProperty =
|
||||
new SimpleObjectProperty<>(FILE_TYPE_COMPARATOR);
|
||||
@@ -37,9 +35,7 @@ public final class BrowserFileListModel {
|
||||
private final Property<Boolean> draggedOverEmpty = new SimpleBooleanProperty();
|
||||
private final Property<BrowserEntry> editing = new SimpleObjectProperty<>();
|
||||
|
||||
public BrowserFileListModel(
|
||||
BrowserFileSystemTabModel.SelectionMode selectionMode, BrowserFileSystemTabModel fileSystemModel) {
|
||||
this.selectionMode = selectionMode;
|
||||
public BrowserFileListModel(BrowserFileSystemTabModel fileSystemModel) {
|
||||
this.fileSystemModel = fileSystemModel;
|
||||
|
||||
fileSystemModel.getFilter().addListener((observable, oldValue, newValue) -> {
|
||||
|
||||
@@ -30,6 +30,7 @@ import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import javafx.scene.control.SelectionMode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -68,10 +69,9 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
|
||||
public BrowserFileSystemTabModel(
|
||||
BrowserAbstractSessionModel<?> model,
|
||||
DataStoreEntryRef<? extends FileSystemStore> entry,
|
||||
SelectionMode selectionMode,
|
||||
FailableFunction<DataStoreEntryRef<FileSystemStore>, FileSystem, Exception> fileSystemFactory) {
|
||||
super(model, entry);
|
||||
this.fileList = new BrowserFileListModel(selectionMode, this);
|
||||
this.fileList = new BrowserFileListModel(this);
|
||||
this.fileSystemFactory = fileSystemFactory;
|
||||
}
|
||||
|
||||
@@ -608,24 +608,4 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
|
||||
cdSync(f.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@SuppressWarnings("unused")
|
||||
public enum SelectionMode {
|
||||
SINGLE_FILE(false, true, false),
|
||||
MULTIPLE_FILE(true, true, false),
|
||||
SINGLE_DIRECTORY(false, false, true),
|
||||
MULTIPLE_DIRECTORY(true, false, true),
|
||||
ALL(true, true, true);
|
||||
|
||||
private final boolean multiple;
|
||||
private final boolean acceptsFiles;
|
||||
private final boolean acceptsDirectories;
|
||||
|
||||
SelectionMode(boolean multiple, boolean acceptsFiles, boolean acceptsDirectories) {
|
||||
this.multiple = multiple;
|
||||
this.acceptsFiles = acceptsFiles;
|
||||
this.acceptsDirectories = acceptsDirectories;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class ContextualFileReferenceChoiceComp extends Comp<CompStructure<HBox>>
|
||||
private final ContextualFileReferenceSync sync;
|
||||
private final List<PreviousFileReference> previousFileReferences;
|
||||
private final Predicate<DataStoreEntry> filter;
|
||||
private final boolean directory;
|
||||
|
||||
@Setter
|
||||
private ObservableValue<FilePath> prompt;
|
||||
@@ -55,10 +56,12 @@ public class ContextualFileReferenceChoiceComp extends Comp<CompStructure<HBox>>
|
||||
Property<FilePath> filePath,
|
||||
ContextualFileReferenceSync sync,
|
||||
List<PreviousFileReference> previousFileReferences,
|
||||
Predicate<DataStoreEntry> filter) {
|
||||
Predicate<DataStoreEntry> filter, boolean directory
|
||||
) {
|
||||
this.sync = sync;
|
||||
this.previousFileReferences = previousFileReferences;
|
||||
this.filter = filter;
|
||||
this.directory = directory;
|
||||
this.fileSystem = new SimpleObjectProperty<>();
|
||||
fileSystem.subscribe(val -> {
|
||||
this.fileSystem.setValue(val);
|
||||
@@ -74,7 +77,7 @@ public class ContextualFileReferenceChoiceComp extends Comp<CompStructure<HBox>>
|
||||
var path = previousFileReferences.isEmpty() ? createTextField() : createComboBox();
|
||||
var fileBrowseButton = new ButtonComp(null, new FontIcon("mdi2f-folder-open-outline"), () -> {
|
||||
var replacement = ProcessControlProvider.get().replace(fileSystem.getValue());
|
||||
BrowserFileChooserSessionComp.openSingleFile(
|
||||
BrowserFileChooserSessionComp.open(
|
||||
() -> replacement,
|
||||
() -> filePath.getValue() != null
|
||||
? filePath.getValue().getParent()
|
||||
@@ -86,6 +89,7 @@ public class ContextualFileReferenceChoiceComp extends Comp<CompStructure<HBox>>
|
||||
}
|
||||
},
|
||||
false,
|
||||
directory,
|
||||
filter);
|
||||
})
|
||||
.styleClass(sync != null ? Styles.CENTER_PILL : Styles.RIGHT_PILL)
|
||||
|
||||
@@ -41,7 +41,8 @@ public class FileBrowserCategory extends AppPrefsCategory {
|
||||
prefs.downloadsDirectory,
|
||||
null,
|
||||
List.of(),
|
||||
e -> e.equals(DataStorage.get().local()))
|
||||
e -> e.equals(DataStorage.get().local()),
|
||||
true)
|
||||
.maxWidth(getCompWidth()),
|
||||
prefs.downloadsDirectory)
|
||||
.pref(prefs.pinLocalMachineOnStartup)
|
||||
|
||||
@@ -148,7 +148,8 @@ public class IconsCategory extends AppPrefsCategory {
|
||||
dir,
|
||||
null,
|
||||
List.of(),
|
||||
en -> en.equals(DataStorage.get().local()))
|
||||
en -> en.equals(DataStorage.get().local()),
|
||||
true)
|
||||
.prefWidth(350));
|
||||
modal.withDefaultButtons(() -> {
|
||||
if (dir.get() == null) {
|
||||
|
||||
@@ -36,7 +36,8 @@ public class SshCategory extends AppPrefsCategory {
|
||||
prefs.sshAgentSocket,
|
||||
null,
|
||||
List.of(),
|
||||
e -> e.equals(DataStorage.get().local()));
|
||||
e -> e.equals(DataStorage.get().local()),
|
||||
false);
|
||||
choice.setPrompt(prefs.defaultSshAgentSocket);
|
||||
choice.maxWidth(600);
|
||||
options.sub(
|
||||
|
||||
@@ -60,7 +60,8 @@ public class EnpassPasswordManager implements PasswordManager {
|
||||
prop,
|
||||
null,
|
||||
List.of(),
|
||||
e -> e.equals(DataStorage.get().local()));
|
||||
e -> e.equals(DataStorage.get().local()),
|
||||
true);
|
||||
comp.apply(struc -> {
|
||||
var text = (TextField) struc.get().getChildren().getFirst();
|
||||
text.requestFocus();
|
||||
|
||||
@@ -135,7 +135,7 @@ public interface DataStorageGroupStrategy {
|
||||
.nameAndDescription("fileSecretChoice")
|
||||
.addComp(new ContextualFileReferenceChoiceComp(
|
||||
new ReadOnlyObjectWrapper<>(DataStorage.get().local().ref()),
|
||||
file, null, List.of(), e -> e.equals(DataStorage.get().local())), file)
|
||||
file, null, List.of(), e -> e.equals(DataStorage.get().local()), false), file)
|
||||
.nonNull()
|
||||
.bind(
|
||||
() -> {
|
||||
|
||||
@@ -51,7 +51,8 @@ public class CustomPkcs11LibraryStrategy implements SshIdentityStrategy {
|
||||
file,
|
||||
null,
|
||||
List.of(),
|
||||
e -> e.equals(DataStorage.get().local())),
|
||||
e -> e.equals(DataStorage.get().local()),
|
||||
false),
|
||||
file)
|
||||
.nonNull()
|
||||
.bind(
|
||||
|
||||
@@ -137,7 +137,8 @@ public class KeyFileStrategy implements SshIdentityStrategy {
|
||||
keyPath,
|
||||
config.isAllowKeyFileSync() ? sync : null,
|
||||
List.of(),
|
||||
e -> e.equals(DataStorage.get().local())),
|
||||
e -> e.equals(DataStorage.get().local()),
|
||||
false),
|
||||
keyPath)
|
||||
.nonNull()
|
||||
.name("keyPassword")
|
||||
|
||||
Reference in New Issue
Block a user