mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-06-28 11:00:28 +12:00
Refactor and cleanup
This commit is contained in:
parent
6af56c451a
commit
0274ade547
|
@ -98,14 +98,14 @@ public interface DataSource {
|
||||||
/**
|
/**
|
||||||
* Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source.
|
* 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);
|
return create(null, type, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for {@link #create(DataSourceId, String, InputStream)}.
|
* 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)) {
|
try (var in = Files.newInputStream(path)) {
|
||||||
return create(id, type, in);
|
return create(id, type, in);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -116,14 +116,14 @@ public interface DataSource {
|
||||||
/**
|
/**
|
||||||
* Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source.
|
* 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);
|
return create(null, type, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for {@link #create(DataSourceId, String, InputStream)}.
|
* 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()) {
|
try (var in = url.openStream()) {
|
||||||
return create(id, type, in);
|
return create(id, type, in);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -134,7 +134,7 @@ public interface DataSource {
|
||||||
/**
|
/**
|
||||||
* Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source.
|
* 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);
|
return create(null, type, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ public interface DataSource {
|
||||||
* @param in the input stream to read
|
* @param in the input stream to read
|
||||||
* @return a {@link DataSource} instances that can be used to access the underlying data
|
* @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);
|
return DataSourceImpl.create(id, type, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ public interface DataSource {
|
||||||
* @param id the data source id
|
* @param id the data source id
|
||||||
* @return a {@link DataSource} instances that can be used to access the underlying data
|
* @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);
|
return DataSourceImpl.create(id, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ public interface DataSource {
|
||||||
* @param in the data store to add
|
* @param in the data store to add
|
||||||
* @return a {@link DataSource} instances that can be used to access the underlying data
|
* @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);
|
return DataSourceImpl.create(id, type, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public interface DataSource {
|
||||||
|
|
||||||
void appendTo(DataSource target);
|
void appendTo(DataSource target);
|
||||||
|
|
||||||
public io.xpipe.core.source.DataSource<?> getInternalSource();
|
io.xpipe.core.source.DataSource<?> getInternalSource();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the id of this data source.
|
* Returns the id of this data source.
|
||||||
|
|
|
@ -15,7 +15,7 @@ import io.xpipe.core.source.DataSourceId;
|
||||||
*/
|
*/
|
||||||
public interface DataTableAccumulator {
|
public interface DataTableAccumulator {
|
||||||
|
|
||||||
public static DataTableAccumulator create(TupleType type) {
|
static DataTableAccumulator create(TupleType type) {
|
||||||
return new DataTableAccumulatorImpl(type);
|
return new DataTableAccumulatorImpl(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,14 +137,14 @@ public final class XPipeApiConnection extends BeaconConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public static interface Handler {
|
public interface Handler {
|
||||||
|
|
||||||
void handle(BeaconConnection con) throws Exception;
|
void handle(BeaconConnection con);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public static interface Mapper<T> {
|
public interface Mapper<T> {
|
||||||
|
|
||||||
T handle(BeaconConnection con) throws Exception;
|
T handle(BeaconConnection con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ public class DataTableAccumulatorImpl implements DataTableAccumulator {
|
||||||
private final XPipeApiConnection connection;
|
private final XPipeApiConnection connection;
|
||||||
private final TupleType type;
|
private final TupleType type;
|
||||||
private int rows;
|
private int rows;
|
||||||
private InternalStreamStore store;
|
private final InternalStreamStore store;
|
||||||
private TupleType writtenDescriptor;
|
private TupleType writtenDescriptor;
|
||||||
private OutputStream bodyOutput;
|
private final OutputStream bodyOutput;
|
||||||
|
|
||||||
public DataTableAccumulatorImpl(TupleType type) {
|
public DataTableAccumulatorImpl(TupleType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
|
@ -70,7 +70,6 @@ public class DataTableImpl extends DataSourceImpl implements DataTable {
|
||||||
public Iterator<TupleNode> iterator() {
|
public Iterator<TupleNode> iterator() {
|
||||||
return new TableIterator();
|
return new TableIterator();
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
private class TableIterator implements Iterator<TupleNode> {
|
private class TableIterator implements Iterator<TupleNode> {
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ public class BrowserAlerts {
|
||||||
return AppWindowHelper.showBlockingAlert(alert -> {
|
return AppWindowHelper.showBlockingAlert(alert -> {
|
||||||
alert.setTitle(AppI18n.get("moveAlertTitle"));
|
alert.setTitle(AppI18n.get("moveAlertTitle"));
|
||||||
alert.setHeaderText(AppI18n.get("moveAlertHeader", source.size(), target.getPath()));
|
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);
|
alert.setAlertType(Alert.AlertType.CONFIRMATION);
|
||||||
})
|
})
|
||||||
.map(b -> b.getButtonData().isDefaultButton())
|
.map(b -> b.getButtonData().isDefaultButton())
|
||||||
|
@ -34,7 +35,8 @@ public class BrowserAlerts {
|
||||||
return AppWindowHelper.showBlockingAlert(alert -> {
|
return AppWindowHelper.showBlockingAlert(alert -> {
|
||||||
alert.setTitle(AppI18n.get("deleteAlertTitle"));
|
alert.setTitle(AppI18n.get("deleteAlertTitle"));
|
||||||
alert.setHeaderText(AppI18n.get("deleteAlertHeader", source.size()));
|
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);
|
alert.setAlertType(Alert.AlertType.CONFIRMATION);
|
||||||
})
|
})
|
||||||
.map(b -> b.getButtonData().isDefaultButton())
|
.map(b -> b.getButtonData().isDefaultButton())
|
||||||
|
@ -43,7 +45,8 @@ public class BrowserAlerts {
|
||||||
|
|
||||||
private static String getSelectedElementsString(List<FileSystem.FileEntry> source) {
|
private static String getSelectedElementsString(List<FileSystem.FileEntry> source) {
|
||||||
var namesHeader = AppI18n.get("selectedElements");
|
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) {
|
if (source.size() > 10) {
|
||||||
names += "\n+ " + (source.size() - 10) + " ...";
|
names += "\n+ " + (source.size() - 10) + " ...";
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ final class BrowserBookmarkList extends SimpleComp {
|
||||||
@Override
|
@Override
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
var root = StoreEntryTree.createTree();
|
var root = StoreEntryTree.createTree();
|
||||||
var view = new TreeView<StoreEntryWrapper>(root);
|
var view = new TreeView<>(root);
|
||||||
view.setShowRoot(false);
|
view.setShowRoot(false);
|
||||||
view.getStyleClass().add("bookmark-list");
|
view.getStyleClass().add("bookmark-list");
|
||||||
view.setCellFactory(param -> {
|
view.setCellFactory(param -> {
|
||||||
|
@ -138,7 +138,7 @@ final class BrowserBookmarkList extends SimpleComp {
|
||||||
});
|
});
|
||||||
event.consume();
|
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 -> {
|
getPseudoClassStates().addListener((SetChangeListener<? super PseudoClass>) change -> {
|
||||||
if (change.getSet().contains(PseudoClass.getPseudoClass("expanded"))) {
|
if (change.getSet().contains(PseudoClass.getPseudoClass("expanded"))) {
|
||||||
icon.set("mdal-keyboard_arrow_down");
|
icon.set("mdal-keyboard_arrow_down");
|
||||||
|
|
|
@ -25,9 +25,7 @@ public class BrowserBreadcrumbBar extends SimpleComp {
|
||||||
@Override
|
@Override
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
Callback<Breadcrumbs.BreadCrumbItem<String>, ButtonBase> crumbFactory = crumb -> {
|
Callback<Breadcrumbs.BreadCrumbItem<String>, ButtonBase> crumbFactory = crumb -> {
|
||||||
var name = crumb.getValue().equals("/")
|
var name = crumb.getValue().equals("/") ? "/" : FileNames.getFileName(crumb.getValue());
|
||||||
? "/"
|
|
||||||
: FileNames.getFileName(crumb.getValue());
|
|
||||||
var btn = new Button(name, null);
|
var btn = new Button(name, null);
|
||||||
btn.setMnemonicParsing(false);
|
btn.setMnemonicParsing(false);
|
||||||
btn.setFocusTraversable(false);
|
btn.setFocusTraversable(false);
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class BrowserClipboard {
|
||||||
List<FileSystem.FileEntry> entries;
|
List<FileSystem.FileEntry> entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Property<Instance> currentCopyClipboard = new SimpleObjectProperty<>();
|
public static final Property<Instance> currentCopyClipboard = new SimpleObjectProperty<>();
|
||||||
public static Instance currentDragClipboard;
|
public static Instance currentDragClipboard;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
|
|
@ -22,14 +22,16 @@ import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Orientation;
|
import javafx.geometry.Orientation;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.input.DragEvent;
|
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.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -252,12 +254,9 @@ public class BrowserComp extends SimpleComp {
|
||||||
|
|
||||||
var label = new Label(model.getName());
|
var label = new Label(model.getName());
|
||||||
label.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
|
label.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
|
||||||
label.addEventHandler(DragEvent.DRAG_ENTERED, new EventHandler<DragEvent>() {
|
label.addEventHandler(
|
||||||
@Override
|
DragEvent.DRAG_ENTERED,
|
||||||
public void handle(DragEvent mouseEvent) {
|
mouseEvent -> Platform.runLater(() -> tabs.getSelectionModel().select(tab)));
|
||||||
Platform.runLater(() -> tabs.getSelectionModel().select(tab));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
label.graphicProperty()
|
label.graphicProperty()
|
||||||
.bind(Bindings.createObjectBinding(
|
.bind(Bindings.createObjectBinding(
|
||||||
|
|
|
@ -26,7 +26,10 @@ final class BrowserContextMenu extends ContextMenu {
|
||||||
AppFont.normal(this.getStyleableNode());
|
AppFont.normal(this.getStyleableNode());
|
||||||
|
|
||||||
var empty = source == null;
|
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)) {
|
if (source != null && !selected.contains(source)) {
|
||||||
selected.add(source);
|
selected.add(source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,19 +49,26 @@ public class BrowserFileListCompEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.getButton() == MouseButton.PRIMARY && t.isShiftDown()) {
|
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 all = tv.getItems();
|
||||||
var min = tv.getSelectionModel().getSelectedIndices().stream().mapToInt(value -> value).min().orElse(1);
|
var min = tv.getSelectionModel().getSelectedIndices().stream()
|
||||||
var max = tv.getSelectionModel().getSelectedIndices().stream().mapToInt(value -> value).max().orElse(all.size() - 1);
|
.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 end = tv.getSelectionModel().getFocusedIndex();
|
||||||
var start = end > min ? min : max;
|
var start = end > min ? min : max;
|
||||||
tv.getSelectionModel().selectRange(Math.min(start, end), Math.max(start, end) + 1);
|
tv.getSelectionModel().selectRange(Math.min(start, end), Math.max(start, end) + 1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSynthetic() {
|
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) {
|
private boolean acceptsDrop(DragEvent event) {
|
||||||
|
@ -80,8 +87,10 @@ public class BrowserFileListCompEntry {
|
||||||
|
|
||||||
// Prevent drag and drops of files into the current directory
|
// Prevent drag and drops of files into the current directory
|
||||||
if (BrowserClipboard.currentDragClipboard
|
if (BrowserClipboard.currentDragClipboard
|
||||||
.getBaseDirectory().getPath()
|
.getBaseDirectory()
|
||||||
.equals(model.getFileSystemModel().getCurrentDirectory().getPath()) && (item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY)) {
|
.getPath()
|
||||||
|
.equals(model.getFileSystemModel().getCurrentDirectory().getPath())
|
||||||
|
&& (item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +161,8 @@ public class BrowserFileListCompEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void acceptDrag(DragEvent event) {
|
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);
|
model.getDraggedOverDirectory().setValue(item);
|
||||||
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
|
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +215,8 @@ public class BrowserFileListCompEntry {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tv = ((TableView<BrowserEntry>) row.getParent().getParent().getParent().getParent());
|
var tv = ((TableView<BrowserEntry>)
|
||||||
|
row.getParent().getParent().getParent().getParent());
|
||||||
tv.getSelectionModel().select(item);
|
tv.getSelectionModel().select(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public final class BrowserFileListModel {
|
||||||
private final ObservableList<FileSystem.FileEntry> selectedRaw =
|
private final ObservableList<FileSystem.FileEntry> selectedRaw =
|
||||||
BindingsHelper.mappedContentBinding(selection, entry -> entry.getRawFileEntry());
|
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<Boolean> draggedOverEmpty = new SimpleBooleanProperty();
|
||||||
private final Property<BrowserEntry> editing = new SimpleObjectProperty<>();
|
private final Property<BrowserEntry> editing = new SimpleObjectProperty<>();
|
||||||
|
|
||||||
|
@ -113,7 +113,8 @@ public final class BrowserFileListModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDoubleClick(BrowserEntry entry) {
|
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();
|
getFileSystemModel().getBrowserModel().finishChooser();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class BrowserFileOverviewComp extends SimpleComp {
|
||||||
event.consume();
|
event.consume();
|
||||||
});
|
});
|
||||||
l.setAlignment(Pos.CENTER_LEFT);
|
l.setAlignment(Pos.CENTER_LEFT);
|
||||||
GrowAugment.create(true,false).augment(l);
|
GrowAugment.create(true, false).augment(l);
|
||||||
return l;
|
return l;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class BrowserModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public static enum Mode {
|
public enum Mode {
|
||||||
BROWSER(false, true, true, true),
|
BROWSER(false, true, true, true),
|
||||||
SINGLE_FILE_CHOOSER(true, false, true, false),
|
SINGLE_FILE_CHOOSER(true, false, true, false),
|
||||||
SINGLE_FILE_SAVE(true, false, true, false),
|
SINGLE_FILE_SAVE(true, false, true, false),
|
||||||
|
@ -80,7 +80,8 @@ public class BrowserModel {
|
||||||
var map = new LinkedHashMap<UUID, String>();
|
var map = new LinkedHashMap<UUID, String>();
|
||||||
openFileSystems.forEach(model -> {
|
openFileSystems.forEach(model -> {
|
||||||
var storageEntry = DataStorage.get().getStoreEntryIfPresent(model.getStore());
|
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
|
// Don't override state if it is empty
|
||||||
|
|
|
@ -51,11 +51,16 @@ public class BrowserNavBar extends SimpleComp {
|
||||||
.styleClass("path-text")
|
.styleClass("path-text")
|
||||||
.apply(struc -> {
|
.apply(struc -> {
|
||||||
SimpleChangeListener.apply(struc.get().focusedProperty(), val -> {
|
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 -> {
|
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 -> {
|
struc.get().setOnMouseClicked(event -> {
|
||||||
|
@ -69,9 +74,11 @@ public class BrowserNavBar extends SimpleComp {
|
||||||
});
|
});
|
||||||
|
|
||||||
struc.get().setPromptText("Overview of " + model.getName());
|
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();
|
s.get().requestFocus();
|
||||||
}).accessibleText("Current path");
|
})
|
||||||
|
.accessibleText("Current path");
|
||||||
|
|
||||||
var graphic = Bindings.createStringBinding(
|
var graphic = Bindings.createStringBinding(
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -90,10 +97,9 @@ public class BrowserNavBar extends SimpleComp {
|
||||||
graphicButton.setAccessibleText("Directory options");
|
graphicButton.setAccessibleText("Directory options");
|
||||||
graphicButton.getStyleClass().add(Styles.LEFT_PILL);
|
graphicButton.getStyleClass().add(Styles.LEFT_PILL);
|
||||||
graphicButton.getStyleClass().add("path-graphic-button");
|
graphicButton.getStyleClass().add("path-graphic-button");
|
||||||
new ContextMenuAugment<>(
|
new ContextMenuAugment<>(event -> event.getButton() == MouseButton.PRIMARY, () -> {
|
||||||
event -> event.getButton() == MouseButton.PRIMARY, () -> {
|
return model.getInOverview().get() ? null : new BrowserContextMenu(model, null);
|
||||||
return model.getInOverview().get() ? null : new BrowserContextMenu(model, null);
|
})
|
||||||
})
|
|
||||||
.augment(new SimpleCompStructure<>(graphicButton));
|
.augment(new SimpleCompStructure<>(graphicButton));
|
||||||
|
|
||||||
var breadcrumbs = new BrowserBreadcrumbBar(model).grow(false, true);
|
var breadcrumbs = new BrowserBreadcrumbBar(model).grow(false, true);
|
||||||
|
@ -104,17 +110,26 @@ public class BrowserNavBar extends SimpleComp {
|
||||||
.apply(struc -> {
|
.apply(struc -> {
|
||||||
var t = struc.get().getChildren().get(0);
|
var t = struc.get().getChildren().get(0);
|
||||||
var b = struc.get().getChildren().get(1);
|
var b = struc.get().getChildren().get(1);
|
||||||
b.visibleProperty().bind(Bindings.createBooleanBinding(() -> {
|
b.visibleProperty()
|
||||||
return !t.isFocused() && !model.getInOverview().get();
|
.bind(Bindings.createBooleanBinding(
|
||||||
}, t.focusedProperty(), model.getInOverview()));
|
() -> {
|
||||||
|
return !t.isFocused()
|
||||||
|
&& !model.getInOverview().get();
|
||||||
|
},
|
||||||
|
t.focusedProperty(),
|
||||||
|
model.getInOverview()));
|
||||||
})
|
})
|
||||||
.grow(false, true);
|
.grow(false, true);
|
||||||
|
|
||||||
var topBox = new HorizontalComp(List.of(Comp.of(() -> graphicButton), stack))
|
var topBox = new HorizontalComp(List.of(Comp.of(() -> graphicButton), stack))
|
||||||
.apply(struc -> struc.get().setAlignment(Pos.CENTER_LEFT))
|
.apply(struc -> struc.get().setAlignment(Pos.CENTER_LEFT))
|
||||||
.apply(struc -> {
|
.apply(struc -> {
|
||||||
((Region) struc.get().getChildren().get(0)).minHeightProperty().bind(((Region) struc.get().getChildren().get(1)).heightProperty());
|
((Region) struc.get().getChildren().get(0))
|
||||||
((Region) struc.get().getChildren().get(0)).maxHeightProperty().bind(((Region) struc.get().getChildren().get(1)).heightProperty());
|
.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 -> {
|
.apply(struc -> {
|
||||||
struc.get().setPickOnBounds(false);
|
struc.get().setPickOnBounds(false);
|
||||||
|
|
|
@ -33,7 +33,9 @@ public class BrowserOverviewComp extends SimpleComp {
|
||||||
.map(s -> FileSystem.FileEntry.ofDirectory(model.getFileSystem(), s))
|
.map(s -> FileSystem.FileEntry.ofDirectory(model.getFileSystem(), s))
|
||||||
.filter(entry -> {
|
.filter(entry -> {
|
||||||
try {
|
try {
|
||||||
var b = sc.getShellDialect().directoryExists(sc, entry.getPath()).executeAndCheck();
|
var b = sc.getShellDialect()
|
||||||
|
.directoryExists(sc, entry.getPath())
|
||||||
|
.executeAndCheck();
|
||||||
return b;
|
return b;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorEvent.fromThrowable(e).handle();
|
ErrorEvent.fromThrowable(e).handle();
|
||||||
|
@ -42,7 +44,8 @@ public class BrowserOverviewComp extends SimpleComp {
|
||||||
})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
var commonOverview = new BrowserFileOverviewComp(model, FXCollections.observableArrayList(common), false);
|
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()
|
var roots = sc.getShellDialect()
|
||||||
.listRoots(sc)
|
.listRoots(sc)
|
||||||
|
|
|
@ -22,36 +22,44 @@ public class BrowserStatusBarComp extends SimpleComp {
|
||||||
@Override
|
@Override
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
var cc = PlatformThread.sync(BrowserClipboard.currentCopyClipboard);
|
var cc = PlatformThread.sync(BrowserClipboard.currentCopyClipboard);
|
||||||
var ccCount = Bindings.createStringBinding(() -> {
|
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";
|
if (cc.getValue() != null && cc.getValue().getEntries().size() > 0) {
|
||||||
} else {
|
return cc.getValue().getEntries().size() + " file"
|
||||||
return null;
|
+ (cc.getValue().getEntries().size() > 1 ? "s" : "") + " in clipboard";
|
||||||
}
|
} else {
|
||||||
}, cc);
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cc);
|
||||||
|
|
||||||
var selectedCount = PlatformThread.sync(Bindings.createIntegerBinding(() -> {
|
var selectedCount = PlatformThread.sync(Bindings.createIntegerBinding(
|
||||||
return model.getFileList().getSelection().size();
|
() -> {
|
||||||
}, model.getFileList().getSelection()));
|
return model.getFileList().getSelection().size();
|
||||||
|
},
|
||||||
|
model.getFileList().getSelection()));
|
||||||
|
|
||||||
var allCount = PlatformThread.sync(Bindings.createIntegerBinding(() -> {
|
var allCount = PlatformThread.sync(Bindings.createIntegerBinding(
|
||||||
return (int) model.getFileList().getAll().getValue().stream().filter(entry -> !entry.isSynthetic()).count();
|
() -> {
|
||||||
}, model.getFileList().getAll()));
|
return (int) model.getFileList().getAll().getValue().stream()
|
||||||
|
.filter(entry -> !entry.isSynthetic())
|
||||||
|
.count();
|
||||||
|
},
|
||||||
|
model.getFileList().getAll()));
|
||||||
|
|
||||||
var selectedComp = new LabelComp(Bindings.createStringBinding(() -> {
|
var selectedComp = new LabelComp(Bindings.createStringBinding(
|
||||||
if (selectedCount.getValue().intValue() == 0) {
|
() -> {
|
||||||
return null;
|
if (selectedCount.getValue().intValue() == 0) {
|
||||||
} else {
|
return null;
|
||||||
return selectedCount.getValue() + " / " + allCount.getValue() + " selected";
|
} else {
|
||||||
}
|
return selectedCount.getValue() + " / " + allCount.getValue() + " selected";
|
||||||
}, selectedCount, allCount));
|
}
|
||||||
|
},
|
||||||
|
selectedCount,
|
||||||
|
allCount));
|
||||||
|
|
||||||
var bar = new ToolBar();
|
var bar = new ToolBar();
|
||||||
bar.getItems().setAll(
|
bar.getItems().setAll(new LabelComp(ccCount).createRegion(), new Spacer(), selectedComp.createRegion());
|
||||||
new LabelComp(ccCount).createRegion(),
|
|
||||||
new Spacer(),
|
|
||||||
selectedComp.createRegion()
|
|
||||||
);
|
|
||||||
bar.getStyleClass().add("status-bar");
|
bar.getStyleClass().add("status-bar");
|
||||||
bar.setOnDragDetected(event -> {
|
bar.setOnDragDetected(event -> {
|
||||||
event.consume();
|
event.consume();
|
||||||
|
|
|
@ -41,7 +41,9 @@ public class BrowserTransferComp extends SimpleComp {
|
||||||
new StackComp(List.of(background)).grow(true, true).styleClass("download-background");
|
new StackComp(List.of(background)).grow(true, true).styleClass("download-background");
|
||||||
|
|
||||||
var binding = BindingsHelper.mappedContentBinding(stage.getItems(), item -> item.getFileEntry());
|
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"))
|
var dragNotice = new LabelComp(AppI18n.observable("dragFiles"))
|
||||||
.apply(struc -> struc.get().setGraphic(new FontIcon("mdi2e-export")))
|
.apply(struc -> struc.get().setGraphic(new FontIcon("mdi2e-export")))
|
||||||
.hide(BindingsHelper.persist(Bindings.isEmpty(stage.getItems())))
|
.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 listBox = new VerticalComp(List.of(list, dragNotice));
|
||||||
var stack = new LoadingOverlayComp(
|
var stack = new LoadingOverlayComp(
|
||||||
new StackComp(List.of(backgroundStack, listBox, clearPane)).apply(DragPseudoClassAugment.create()).apply(struc -> {
|
new StackComp(List.of(backgroundStack, listBox, clearPane))
|
||||||
struc.get().setOnDragOver(event -> {
|
.apply(DragPseudoClassAugment.create())
|
||||||
// Accept drops from inside the app window
|
.apply(struc -> {
|
||||||
if (event.getGestureSource() != null && event.getGestureSource() != struc.get()) {
|
struc.get().setOnDragOver(event -> {
|
||||||
event.acceptTransferModes(TransferMode.ANY);
|
// Accept drops from inside the app window
|
||||||
event.consume();
|
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())
|
struc.get().setOnDragDropped(event -> {
|
||||||
.getEntries();
|
if (event.getGestureSource() != null) {
|
||||||
stage.drop(files);
|
var files = BrowserClipboard.retrieveDrag(event.getDragboard())
|
||||||
event.setDropCompleted(true);
|
.getEntries();
|
||||||
event.consume();
|
stage.drop(files);
|
||||||
}
|
event.setDropCompleted(true);
|
||||||
});
|
event.consume();
|
||||||
struc.get().setOnDragDetected(event -> {
|
}
|
||||||
if (stage.getDownloading().get()) {
|
});
|
||||||
return;
|
struc.get().setOnDragDetected(event -> {
|
||||||
}
|
if (stage.getDownloading().get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var files = stage.getItems().stream()
|
var files = stage.getItems().stream()
|
||||||
.map(item -> {
|
.map(item -> {
|
||||||
try {
|
try {
|
||||||
return item.getLocalFile().toRealPath().toFile();
|
return item.getLocalFile()
|
||||||
} catch (IOException e) {
|
.toRealPath()
|
||||||
throw new RuntimeException(e);
|
.toFile();
|
||||||
}
|
} catch (IOException e) {
|
||||||
})
|
throw new RuntimeException(e);
|
||||||
.toList();
|
}
|
||||||
Dragboard db = struc.get().startDragAndDrop(TransferMode.MOVE);
|
})
|
||||||
var cc = new ClipboardContent();
|
.toList();
|
||||||
cc.putFiles(files);
|
Dragboard db = struc.get().startDragAndDrop(TransferMode.MOVE);
|
||||||
db.setContent(cc);
|
var cc = new ClipboardContent();
|
||||||
|
cc.putFiles(files);
|
||||||
|
db.setContent(cc);
|
||||||
|
|
||||||
var image = BrowserSelectionListComp.snapshot(FXCollections.observableList(stage.getItems().stream()
|
var image = BrowserSelectionListComp.snapshot(
|
||||||
.map(item -> item.getFileEntry())
|
FXCollections.observableList(stage.getItems().stream()
|
||||||
.toList()));
|
.map(item -> item.getFileEntry())
|
||||||
db.setDragView(image, -20, 15);
|
.toList()));
|
||||||
|
db.setDragView(image, -20, 15);
|
||||||
|
|
||||||
event.setDragDetect(true);
|
event.setDragDetect(true);
|
||||||
event.consume();
|
event.consume();
|
||||||
});
|
});
|
||||||
struc.get().setOnDragDone(event -> {
|
struc.get().setOnDragDone(event -> {
|
||||||
if (!event.isAccepted()) {
|
if (!event.isAccepted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stage.getItems().clear();
|
stage.getItems().clear();
|
||||||
event.consume();
|
event.consume();
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
PlatformThread.sync(stage.getDownloading()));
|
PlatformThread.sync(stage.getDownloading()));
|
||||||
return stack.createRegion();
|
return stack.createRegion();
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,7 @@ public class FileSystemHelper {
|
||||||
Files.isExecutable(file),
|
Files.isExecutable(file),
|
||||||
Files.size(file),
|
Files.size(file),
|
||||||
null,
|
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) {
|
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) {
|
if (files.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ public class OpenFileSystemCache {
|
||||||
public boolean isApplicationInPath(String app) {
|
public boolean isApplicationInPath(String app) {
|
||||||
if (!installedApplications.containsKey(app)) {
|
if (!installedApplications.containsKey(app)) {
|
||||||
try {
|
try {
|
||||||
var b = ApplicationHelper.isInPath(model.getFileSystem().getShell().orElseThrow(), app);
|
var b = ApplicationHelper.isInPath(
|
||||||
|
model.getFileSystem().getShell().orElseThrow(), app);
|
||||||
installedApplications.put(app, b);
|
installedApplications.put(app, b);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
installedApplications.put(app, false);
|
installedApplications.put(app, false);
|
||||||
|
|
|
@ -83,7 +83,8 @@ public class OpenFileSystemComp extends SimpleComp {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Region createFileListContent() {
|
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 statusBar = new BrowserStatusBarComp(model);
|
||||||
var fileList = new VerticalComp(List.of(directoryView, statusBar));
|
var fileList = new VerticalComp(List.of(directoryView, statusBar));
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@ public final class OpenFileSystemHistory {
|
||||||
|
|
||||||
private final IntegerProperty cursor = new SimpleIntegerProperty(-1);
|
private final IntegerProperty cursor = new SimpleIntegerProperty(-1);
|
||||||
private final List<String> history = new ArrayList<>();
|
private final List<String> history = new ArrayList<>();
|
||||||
private final BooleanBinding canGoBack = Bindings.createBooleanBinding(
|
private final BooleanBinding canGoBack =
|
||||||
() -> cursor.get() > 0 && history.size() > 1, cursor);
|
Bindings.createBooleanBinding(() -> cursor.get() > 0 && history.size() > 1, cursor);
|
||||||
private final BooleanBinding canGoForth = Bindings.createBooleanBinding(
|
private final BooleanBinding canGoForth =
|
||||||
() -> cursor.get() < history.size() - 1, cursor);
|
Bindings.createBooleanBinding(() -> cursor.get() < history.size() - 1, cursor);
|
||||||
|
|
||||||
public String getCurrent() {
|
public String getCurrent() {
|
||||||
return history.size() > 0 ? history.get(cursor.get()) : null;
|
return history.size() > 0 ? history.get(cursor.get()) : null;
|
||||||
|
|
|
@ -46,9 +46,11 @@ public final class OpenFileSystemModel {
|
||||||
this.browserModel = browserModel;
|
this.browserModel = browserModel;
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this.name = name != null ? name : DataStorage.get().getStoreEntry(store).getName();
|
this.name = name != null ? name : DataStorage.get().getStoreEntry(store).getName();
|
||||||
this.inOverview.bind(Bindings.createBooleanBinding(() -> {
|
this.inOverview.bind(Bindings.createBooleanBinding(
|
||||||
return currentPath.get() == null;
|
() -> {
|
||||||
}, currentPath));
|
return currentPath.get() == null;
|
||||||
|
},
|
||||||
|
currentPath));
|
||||||
fileList = new BrowserFileListModel(this);
|
fileList = new BrowserFileListModel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +149,7 @@ public final class OpenFileSystemModel {
|
||||||
return Optional.of(currentPath.get());
|
return Optional.of(currentPath.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
String dirPath = null;
|
String dirPath;
|
||||||
try {
|
try {
|
||||||
dirPath = FileSystemHelper.validateDirectoryPath(this, normalizedPath);
|
dirPath = FileSystemHelper.validateDirectoryPath(this, normalizedPath);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -314,7 +316,7 @@ public final class OpenFileSystemModel {
|
||||||
cdSyncWithoutCheck(dir);
|
cdSyncWithoutCheck(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initWithDefaultDirectory() throws Exception {
|
public void initWithDefaultDirectory() {
|
||||||
savedState.cd(null);
|
savedState.cd(null);
|
||||||
history.updateCurrent(null);
|
history.updateCurrent(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package io.xpipe.app.browser;
|
package io.xpipe.app.browser;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JacksonException;
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
@ -63,8 +62,7 @@ public class OpenFileSystemSavedState {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public OpenFileSystemSavedState deserialize(JsonParser p, DeserializationContext ctxt)
|
public OpenFileSystemSavedState deserialize(JsonParser p, DeserializationContext ctxt) {
|
||||||
throws IOException, JacksonException {
|
|
||||||
var tree = (ObjectNode) JacksonMapper.getDefault().readTree(p);
|
var tree = (ObjectNode) JacksonMapper.getDefault().readTree(p);
|
||||||
JavaType javaType = JacksonMapper.getDefault()
|
JavaType javaType = JacksonMapper.getDefault()
|
||||||
.getTypeFactory()
|
.getTypeFactory()
|
||||||
|
|
|
@ -7,10 +7,10 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ApplicationPathAction extends BrowserAction {
|
public interface ApplicationPathAction extends BrowserAction {
|
||||||
|
|
||||||
public abstract String getExecutable();
|
String getExecutable();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||||
return model.getCache().isApplicationInPath(getExecutable());
|
return model.getCache().isApplicationInPath(getExecutable());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.ServiceLoader;
|
||||||
|
|
||||||
public interface BrowserAction {
|
public interface BrowserAction {
|
||||||
|
|
||||||
static enum Category {
|
enum Category {
|
||||||
CUSTOM,
|
CUSTOM,
|
||||||
OPEN,
|
OPEN,
|
||||||
NATIVE,
|
NATIVE,
|
||||||
|
@ -21,9 +21,9 @@ public interface BrowserAction {
|
||||||
MUTATION
|
MUTATION
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<BrowserAction> ALL = new ArrayList<>();
|
List<BrowserAction> ALL = new ArrayList<>();
|
||||||
|
|
||||||
public static List<LeafAction> getFlattened() {
|
static List<LeafAction> getFlattened() {
|
||||||
return ALL.stream()
|
return ALL.stream()
|
||||||
.map(browserAction -> browserAction instanceof LeafAction
|
.map(browserAction -> browserAction instanceof LeafAction
|
||||||
? List.of((LeafAction) browserAction)
|
? List.of((LeafAction) browserAction)
|
||||||
|
@ -33,7 +33,10 @@ public interface BrowserAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
static LeafAction byId(String id) {
|
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) {
|
default Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||||
|
@ -52,17 +55,17 @@ public interface BrowserAction {
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
default boolean isActive(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Loader implements ModuleLayerLoader {
|
class Loader implements ModuleLayerLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ModuleLayer layer) {
|
public void init(ModuleLayer layer) {
|
||||||
|
|
|
@ -13,8 +13,12 @@ public abstract class ExecuteApplicationAction implements LeafAction, Applicatio
|
||||||
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
|
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
|
||||||
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
|
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
|
||||||
for (BrowserEntry entry : entries) {
|
for (BrowserEntry entry : entries) {
|
||||||
var command = detach() ? ScriptHelper.createDetachCommand(sc, createCommand(model, entry)) : createCommand(model, entry);
|
var command = detach()
|
||||||
try (var cc = sc.command(command).withWorkingDirectory(model.getCurrentDirectory().getPath()).start()) {
|
? ScriptHelper.createDetachCommand(sc, createCommand(model, entry))
|
||||||
|
: createCommand(model, entry);
|
||||||
|
try (var cc = sc.command(command)
|
||||||
|
.withWorkingDirectory(model.getCurrentDirectory().getPath())
|
||||||
|
.start()) {
|
||||||
cc.discardOrThrow();
|
cc.discardOrThrow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +40,5 @@ public abstract class ExecuteApplicationAction implements LeafAction, Applicatio
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
|
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
public interface LeafAction extends BrowserAction {
|
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) {
|
default Button toButton(OpenFileSystemModel model, List<BrowserEntry> selected) {
|
||||||
var b = new Button();
|
var b = new Button();
|
||||||
|
|
|
@ -25,7 +25,7 @@ public abstract class MultiExecuteAction implements BranchAction {
|
||||||
new LeafAction() {
|
new LeafAction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
|
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||||
model.withShell(
|
model.withShell(
|
||||||
pc -> {
|
pc -> {
|
||||||
for (BrowserEntry entry : entries) {
|
for (BrowserEntry entry : entries) {
|
||||||
|
@ -51,12 +51,11 @@ public abstract class MultiExecuteAction implements BranchAction {
|
||||||
new LeafAction() {
|
new LeafAction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
|
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||||
model.withShell(
|
model.withShell(
|
||||||
pc -> {
|
pc -> {
|
||||||
for (BrowserEntry entry : entries) {
|
for (BrowserEntry entry : entries) {
|
||||||
var cmd = ScriptHelper.createDetachCommand(
|
var cmd = ScriptHelper.createDetachCommand(pc, createCommand(pc, model, entry));
|
||||||
pc, createCommand(pc, model, entry));
|
|
||||||
pc.command(cmd)
|
pc.command(cmd)
|
||||||
.withWorkingDirectory(model.getCurrentDirectory()
|
.withWorkingDirectory(model.getCurrentDirectory()
|
||||||
.getPath())
|
.getPath())
|
||||||
|
@ -74,13 +73,13 @@ public abstract class MultiExecuteAction implements BranchAction {
|
||||||
new LeafAction() {
|
new LeafAction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
|
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||||
model.withShell(
|
model.withShell(
|
||||||
pc -> {
|
pc -> {
|
||||||
for (BrowserEntry entry : entries) {
|
for (BrowserEntry entry : entries) {
|
||||||
pc.command(createCommand(pc, model, entry))
|
pc.command(createCommand(pc, model, entry))
|
||||||
.withWorkingDirectory(model.getCurrentDirectory()
|
.withWorkingDirectory(model.getCurrentDirectory()
|
||||||
.getPath())
|
.getPath())
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,12 +14,14 @@ public abstract class ToFileCommandAction implements LeafAction, ApplicationPath
|
||||||
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
|
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
|
||||||
for (BrowserEntry entry : entries) {
|
for (BrowserEntry entry : entries) {
|
||||||
var command = createCommand(model, entry);
|
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();
|
cc.discardErr();
|
||||||
FileOpener.openCommandOutput(entry.getFileName(), entry, cc);
|
FileOpener.openCommandOutput(entry.getFileName(), entry, cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
|
protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,11 @@ public class BrowserIcons {
|
||||||
public static PrettyImageComp createDefaultFileIcon() {
|
public static PrettyImageComp createDefaultFileIcon() {
|
||||||
return new PrettyImageComp(new SimpleStringProperty("default_file.svg"), 22, 22);
|
return new PrettyImageComp(new SimpleStringProperty("default_file.svg"), 22, 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PrettyImageComp createDefaultDirectoryIcon() {
|
public static PrettyImageComp createDefaultDirectoryIcon() {
|
||||||
return new PrettyImageComp(new SimpleStringProperty("default_folder.svg"), 22, 22);
|
return new PrettyImageComp(new SimpleStringProperty("default_folder.svg"), 22, 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PrettyImageComp createIcon(FileType type) {
|
public static PrettyImageComp createIcon(FileType type) {
|
||||||
return new PrettyImageComp(new SimpleStringProperty(type.getIcon()), 22, 22);
|
return new PrettyImageComp(new SimpleStringProperty(type.getIcon()), 22, 22);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,13 @@ public interface DirectoryType {
|
||||||
List<DirectoryType> ALL = new ArrayList<>();
|
List<DirectoryType> ALL = new ArrayList<>();
|
||||||
|
|
||||||
static DirectoryType byId(String id) {
|
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() {
|
ALL.add(new DirectoryType() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,7 +46,7 @@ public interface DirectoryType {
|
||||||
|
|
||||||
AppResources.with(AppResources.XPIPE_MODULE, "folder_list.txt", path -> {
|
AppResources.with(AppResources.XPIPE_MODULE, "folder_list.txt", path -> {
|
||||||
try (var reader =
|
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;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
var split = line.split("\\|");
|
var split = line.split("\\|");
|
||||||
|
@ -70,7 +73,8 @@ public interface DirectoryType {
|
||||||
var lightOpenIcon = split.length > 4 ? split[5].trim() : openIcon;
|
var lightOpenIcon = split.length > 4 ? split[5].trim() : openIcon;
|
||||||
|
|
||||||
ALL.add(new Simple(
|
ALL.add(new Simple(
|
||||||
id, new IconVariant(lightClosedIcon, closedIcon),
|
id,
|
||||||
|
new IconVariant(lightClosedIcon, closedIcon),
|
||||||
new IconVariant(lightOpenIcon, openIcon),
|
new IconVariant(lightOpenIcon, openIcon),
|
||||||
filter.toArray(String[]::new)));
|
filter.toArray(String[]::new)));
|
||||||
}
|
}
|
||||||
|
@ -82,6 +86,7 @@ public interface DirectoryType {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
private final IconVariant closed;
|
private final IconVariant closed;
|
||||||
private final IconVariant open;
|
private final IconVariant open;
|
||||||
private final String[] names;
|
private final String[] names;
|
||||||
|
@ -99,8 +104,8 @@ public interface DirectoryType {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays.stream(names).anyMatch(name -> FileNames.getFileName(entry.getPath())
|
return Arrays.stream(names)
|
||||||
.equalsIgnoreCase(name));
|
.anyMatch(name -> FileNames.getFileName(entry.getPath()).equalsIgnoreCase(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,12 +8,15 @@ import io.xpipe.core.store.FileSystem;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class FileIconManager {
|
public class FileIconManager {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static SvgCache svgCache = createCache();
|
private static final SvgCache svgCache = createCache();
|
||||||
|
|
||||||
private static boolean loaded;
|
private static boolean loaded;
|
||||||
|
|
||||||
private static SvgCache createCache() {
|
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) {
|
private static String getIconPath(String name) {
|
||||||
|
|
|
@ -18,10 +18,13 @@ public interface FileType {
|
||||||
List<FileType> ALL = new ArrayList<>();
|
List<FileType> ALL = new ArrayList<>();
|
||||||
|
|
||||||
static FileType byId(String id) {
|
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 -> {
|
AppResources.with(AppResources.XPIPE_MODULE, "file_list.txt", path -> {
|
||||||
try (var reader =
|
try (var reader =
|
||||||
new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8))) {
|
new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8))) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import io.xpipe.app.fxcomps.Comp;
|
||||||
import io.xpipe.app.fxcomps.CompStructure;
|
import io.xpipe.app.fxcomps.CompStructure;
|
||||||
import io.xpipe.app.fxcomps.SimpleCompStructure;
|
import io.xpipe.app.fxcomps.SimpleCompStructure;
|
||||||
import io.xpipe.app.prefs.AppPrefs;
|
import io.xpipe.app.prefs.AppPrefs;
|
||||||
|
import io.xpipe.app.prefs.PrefsComp;
|
||||||
import javafx.beans.property.Property;
|
import javafx.beans.property.Property;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
import javafx.scene.input.KeyCode;
|
import javafx.scene.input.KeyCode;
|
||||||
|
@ -41,16 +42,14 @@ public class AppLayoutComp extends Comp<CompStructure<BorderPane>> {
|
||||||
private List<SideMenuBarComp.Entry> createEntryList() {
|
private List<SideMenuBarComp.Entry> createEntryList() {
|
||||||
var l = new ArrayList<>(List.of(
|
var l = new ArrayList<>(List.of(
|
||||||
new SideMenuBarComp.Entry(
|
new SideMenuBarComp.Entry(
|
||||||
AppI18n.observable("browser"),
|
AppI18n.observable("browser"), "mdi2f-file-cabinet", new BrowserComp(BrowserModel.DEFAULT)),
|
||||||
"mdi2f-file-cabinet",
|
|
||||||
new BrowserComp(BrowserModel.DEFAULT)),
|
|
||||||
new SideMenuBarComp.Entry(AppI18n.observable("connections"), "mdi2c-connection", new StoreLayoutComp()),
|
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("data"), "mdsal-dvr", new SourceCollectionLayoutComp()),
|
||||||
new SideMenuBarComp.Entry(
|
new SideMenuBarComp.Entry(
|
||||||
AppI18n.observable("settings"), "mdsmz-miscellaneous_services", new PrefsComp(this))));
|
AppI18n.observable("settings"), "mdsmz-miscellaneous_services", new PrefsComp(this))));
|
||||||
// new SideMenuBarComp.Entry(AppI18n.observable("help"), "mdi2b-book-open-variant", new
|
// new SideMenuBarComp.Entry(AppI18n.observable("help"), "mdi2b-book-open-variant", new
|
||||||
// StorageLayoutComp()),
|
// StorageLayoutComp()),
|
||||||
// new SideMenuBarComp.Entry(AppI18n.observable("account"), "mdi2a-account", new StorageLayoutComp())
|
// new SideMenuBarComp.Entry(AppI18n.observable("account"), "mdi2a-account", new StorageLayoutComp())
|
||||||
if (AppProperties.get().isDeveloperMode()) {
|
if (AppProperties.get().isDeveloperMode()) {
|
||||||
l.add(new SideMenuBarComp.Entry(
|
l.add(new SideMenuBarComp.Entry(
|
||||||
AppI18n.observable("developer"), "mdi2b-book-open-variant", new DeveloperTabComp()));
|
AppI18n.observable("developer"), "mdi2b-book-open-variant", new DeveloperTabComp()));
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ButtonComp extends Comp<CompStructure<Button>> {
|
||||||
}
|
}
|
||||||
var graphic = getGraphic();
|
var graphic = getGraphic();
|
||||||
if (graphic instanceof FontIcon f) {
|
if (graphic instanceof FontIcon f) {
|
||||||
//f.iconColorProperty().bind(button.textFillProperty());
|
// f.iconColorProperty().bind(button.textFillProperty());
|
||||||
SimpleChangeListener.apply(button.fontProperty(), c -> {
|
SimpleChangeListener.apply(button.fontProperty(), c -> {
|
||||||
f.setIconSize((int) new Size(c.getSize(), SizeUnits.PT).pixels());
|
f.setIconSize((int) new Size(c.getSize(), SizeUnits.PT).pixels());
|
||||||
});
|
});
|
||||||
|
|
|
@ -49,7 +49,6 @@ public class DescriptionButtonComp extends SimpleComp {
|
||||||
return bt;
|
return bt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Region createNamedEntry() {
|
private Region createNamedEntry() {
|
||||||
var header = new Label();
|
var header = new Label();
|
||||||
header.textProperty().bind(PlatformThread.sync(name));
|
header.textProperty().bind(PlatformThread.sync(name));
|
||||||
|
|
|
@ -48,8 +48,9 @@ public class IntegratedTextAreaComp extends SimpleComp {
|
||||||
|
|
||||||
private Region createOpenButton(Region container) {
|
private Region createOpenButton(Region container) {
|
||||||
var name = identifier + (fileType != null ? "." + fileType : "");
|
var name = identifier + (fileType != null ? "." + fileType : "");
|
||||||
var button = new IconButtonComp("mdal-edit", () -> FileOpener
|
var button = new IconButtonComp(
|
||||||
.openString(name, this, value.getValue(), (s) -> {
|
"mdal-edit",
|
||||||
|
() -> FileOpener.openString(name, this, value.getValue(), (s) -> {
|
||||||
Platform.runLater(() -> value.setValue(s));
|
Platform.runLater(() -> value.setValue(s));
|
||||||
}))
|
}))
|
||||||
.createRegion();
|
.createRegion();
|
||||||
|
|
|
@ -7,9 +7,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||||
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
|
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
|
||||||
import javafx.beans.property.Property;
|
import javafx.beans.property.Property;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.scene.input.KeyCode;
|
import javafx.scene.input.KeyCode;
|
||||||
import javafx.scene.input.KeyEvent;
|
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
@ -29,19 +27,16 @@ public class LazyTextFieldComp extends Comp<LazyTextFieldComp.Structure> {
|
||||||
var sp = new StackPane();
|
var sp = new StackPane();
|
||||||
var r = new JFXTextField();
|
var r = new JFXTextField();
|
||||||
|
|
||||||
r.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
r.setOnKeyPressed(ke -> {
|
||||||
@Override
|
if (ke.getCode().equals(KeyCode.ESCAPE)) {
|
||||||
public void handle(KeyEvent ke) {
|
currentValue.setValue(appliedValue.getValue());
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ke.getCode().equals(KeyCode.ENTER) || ke.getCode().equals(KeyCode.ESCAPE)) {
|
||||||
|
r.getScene().getRoot().requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
ke.consume();
|
||||||
});
|
});
|
||||||
|
|
||||||
r.focusedProperty().addListener((c, o, n) -> {
|
r.focusedProperty().addListener((c, o, n) -> {
|
||||||
|
|
|
@ -200,7 +200,9 @@ public abstract class MultiStepComp extends Comp<CompStructure<VBox>> {
|
||||||
buttons.setAlignment(Pos.CENTER_RIGHT);
|
buttons.setAlignment(Pos.CENTER_RIGHT);
|
||||||
var nextText = Bindings.createStringBinding(
|
var nextText = Bindings.createStringBinding(
|
||||||
() -> isLastPage() ? AppI18n.get("finishStep") : AppI18n.get("nextStep"), currentStep);
|
() -> 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)
|
var previousButton = new ButtonComp(AppI18n.observable("previousStep"), null, comp::previous)
|
||||||
.styleClass("next")
|
.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) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,9 +53,15 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
|
||||||
var fi = new FontIcon("mdi2u-update");
|
var fi = new FontIcon("mdi2u-update");
|
||||||
var b = new BigIconButton(AppI18n.observable("update"), fi, () -> UpdateAvailableAlert.showIfNeeded());
|
var b = new BigIconButton(AppI18n.observable("update"), fi, () -> UpdateAvailableAlert.showIfNeeded());
|
||||||
b.apply(GrowAugment.create(true, false));
|
b.apply(GrowAugment.create(true, false));
|
||||||
b.hide(PlatformThread.sync(Bindings.createBooleanBinding(() -> {
|
b.hide(PlatformThread.sync(Bindings.createBooleanBinding(
|
||||||
return XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate().getValue() == null;
|
() -> {
|
||||||
}, XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate())));
|
return XPipeDistributionType.get()
|
||||||
|
.getUpdateHandler()
|
||||||
|
.getPreparedUpdate()
|
||||||
|
.getValue()
|
||||||
|
== null;
|
||||||
|
},
|
||||||
|
XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate())));
|
||||||
vbox.getChildren().add(b.createRegion());
|
vbox.getChildren().add(b.createRegion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,5 +76,5 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
|
||||||
return new SimpleCompStructure<>(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) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,7 @@ public class DataSourceTargetChoiceComp extends Comp<CompStructure<ComboBox<Node
|
||||||
selectedApplication.addListener((observable, oldValue, val) -> {
|
selectedApplication.addListener((observable, oldValue, val) -> {
|
||||||
AppCache.update("application-last-used", val != null ? val.getId() : null);
|
AppCache.update("application-last-used", val != null ? val.getId() : null);
|
||||||
});
|
});
|
||||||
var all =
|
var all = DataSourceTarget.getAll().stream().filter(filter).toList();
|
||||||
DataSourceTarget.getAll().stream().filter((p) -> filter.test(p)).toList();
|
|
||||||
|
|
||||||
if (selectedApplication.getValue() == null) {
|
if (selectedApplication.getValue() == null) {
|
||||||
String selectedId = AppCache.get("application-last-used", String.class, () -> 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() {
|
public CompStructure<ComboBox<Node>> createBase() {
|
||||||
var addMoreLabel = new Label(AppI18n.get("addMore"), new FontIcon("mdmz-plus"));
|
var addMoreLabel = new Label(AppI18n.get("addMore"), new FontIcon("mdmz-plus"));
|
||||||
|
|
||||||
var builder = new CustomComboBoxBuilder<DataSourceTarget>(
|
var builder =
|
||||||
selectedApplication, app -> createLabel(app), new Label(""), v -> true);
|
new CustomComboBoxBuilder<>(selectedApplication, app -> createLabel(app), new Label(""), v -> true);
|
||||||
builder.setAccessibleNames(dataSourceTarget -> dataSourceTarget.getName().getValue());
|
builder.setAccessibleNames(
|
||||||
|
dataSourceTarget -> dataSourceTarget.getName().getValue());
|
||||||
|
|
||||||
// builder.addFilter((v, s) -> v.getName().getValue().toLowerCase().contains(s));
|
// builder.addFilter((v, s) -> v.getName().getValue().toLowerCase().contains(s));
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,15 @@ public class DsCollectionComp extends Comp<CompStructure<TreeView<String>>> {
|
||||||
if (con.getValue() != null) {
|
if (con.getValue() != null) {
|
||||||
try {
|
try {
|
||||||
con.getValue().listEntries().forEach(e -> {
|
con.getValue().listEntries().forEach(e -> {
|
||||||
// var item = new TreeItem<String>(e.getFileName());
|
// var item = new TreeItem<String>(e.getFileName());
|
||||||
// c.add(item);
|
// c.add(item);
|
||||||
});
|
});
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ErrorEvent.fromThrowable(ex).handle();
|
ErrorEvent.fromThrowable(ex).handle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ar = new TreeItem<String>(value.getValue());
|
var ar = new TreeItem<>(value.getValue());
|
||||||
ar.getChildren().setAll(c);
|
ar.getChildren().setAll(c);
|
||||||
return ar;
|
return ar;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,12 +116,12 @@ public class DsDataTransferComp extends SimpleComp {
|
||||||
if (c != null && c.getAccessType() == DataSourceTarget.AccessType.PASSIVE) {
|
if (c != null && c.getAccessType() == DataSourceTarget.AccessType.PASSIVE) {
|
||||||
((Region) s.get().getChildren().get(2)).setMaxHeight(0);
|
((Region) s.get().getChildren().get(2)).setMaxHeight(0);
|
||||||
((Region) s.get().getChildren().get(2)).setMinHeight(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 {
|
} else {
|
||||||
|
|
||||||
((Region) s.get().getChildren().get(2)).setMaxHeight(Region.USE_PREF_SIZE);
|
((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)).setMinHeight(Region.USE_PREF_SIZE);
|
||||||
((Region) s.get().getChildren().get(2)).setVisible(true);
|
s.get().getChildren().get(2).setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
s.get().setPrefWidth(600);
|
s.get().setPrefWidth(600);
|
||||||
|
|
|
@ -73,7 +73,8 @@ public class DsProviderChoiceComp extends Comp<CompStructure<ComboBox<Node>>> im
|
||||||
@Override
|
@Override
|
||||||
public CompStructure<ComboBox<Node>> createBase() {
|
public CompStructure<ComboBox<Node>> createBase() {
|
||||||
var comboBox = new CustomComboBoxBuilder<>(provider, this::createGraphic, createDefaultNode(), v -> true);
|
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.add(null);
|
||||||
comboBox.addSeparator();
|
comboBox.addSeparator();
|
||||||
comboBox.addFilter((v, s) -> v.getDisplayName().toLowerCase().contains(s.toLowerCase()));
|
comboBox.addFilter((v, s) -> v.getDisplayName().toLowerCase().contains(s.toLowerCase()));
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class DsStorageGroupSelector extends SimpleComp {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ComboBox<Node> createSimple() {
|
protected ComboBox<Node> createSimple() {
|
||||||
var comboBox = new CustomComboBoxBuilder<DataSourceCollection>(
|
var comboBox = new CustomComboBoxBuilder<>(
|
||||||
selected, DsStorageGroupSelector::createGraphic, createGraphic(null), v -> true);
|
selected, DsStorageGroupSelector::createGraphic, createGraphic(null), v -> true);
|
||||||
comboBox.setAccessibleNames(dataSourceCollection -> dataSourceCollection.getName());
|
comboBox.setAccessibleNames(dataSourceCollection -> dataSourceCollection.getName());
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class DsStructureComp extends Comp<CompStructure<TreeView<String>>> {
|
||||||
item.setValue("[" + i + "] = " + item.getValue());
|
item.setValue("[" + i + "] = " + item.getValue());
|
||||||
c.add(item);
|
c.add(item);
|
||||||
}
|
}
|
||||||
var ar = new TreeItem<String>("[" + n.size() + "... ]");
|
var ar = new TreeItem<>("[" + n.size() + "... ]");
|
||||||
ar.getChildren().setAll(c);
|
ar.getChildren().setAll(c);
|
||||||
return ar;
|
return ar;
|
||||||
} else if (n.isTuple()) {
|
} else if (n.isTuple()) {
|
||||||
|
@ -39,11 +39,11 @@ public class DsStructureComp extends Comp<CompStructure<TreeView<String>>> {
|
||||||
item.setValue((key != null ? key : "" + i) + " = " + item.getValue());
|
item.setValue((key != null ? key : "" + i) + " = " + item.getValue());
|
||||||
c.add(item);
|
c.add(item);
|
||||||
}
|
}
|
||||||
var ar = new TreeItem<String>("( " + n.size() + "... )");
|
var ar = new TreeItem<>("( " + n.size() + "... )");
|
||||||
ar.getChildren().setAll(c);
|
ar.getChildren().setAll(c);
|
||||||
return ar;
|
return ar;
|
||||||
} else {
|
} else {
|
||||||
var ar = new TreeItem<String>(n.asValue().asString());
|
var ar = new TreeItem<>(n.asValue().asString());
|
||||||
return ar;
|
return ar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class DsTableMappingComp extends SimpleComp {
|
||||||
grid.add(output.createRegion(), 2, i);
|
grid.add(output.createRegion(), 2, i);
|
||||||
|
|
||||||
if (i % 2 != 0) {
|
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"));
|
.add("odd"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,8 +263,8 @@ public class GuiDsCreatorMultiStep<DI extends DataStore, DS extends DataSource<D
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case EDIT -> {}
|
case EDIT -> {}
|
||||||
case CREATE -> {
|
case CREATE -> {
|
||||||
list.add(
|
list.add(new Entry(
|
||||||
new Entry(AppI18n.observable("target"), new GuiDsCreatorTransferStep(targetGroup, store, source)));
|
AppI18n.observable("target"), new GuiDsCreatorTransferStep(targetGroup, store, source)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
@ -287,7 +287,7 @@ public class GuiDsCreatorMultiStep<DI extends DataStore, DS extends DataSource<D
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum State {
|
public enum State {
|
||||||
EDIT,
|
EDIT,
|
||||||
CREATE
|
CREATE
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class NamedSourceChoiceComp extends SimpleComp implements Validatable {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T extends DataSource<?>> void setUpListener(ObservableValue<T> prop) {
|
private <T extends DataSource<?>> void setUpListener(ObservableValue<T> prop) {
|
||||||
prop.addListener((c, o, n) -> {
|
prop.addListener((c, o, n) -> {
|
||||||
((Property<T>) selected).setValue((T) n);
|
((Property<T>) selected).setValue(n);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,15 @@ public class DataStoreSelectorComp extends Comp<CompStructure<Button>> {
|
||||||
var button = new JFXButton();
|
var button = new JFXButton();
|
||||||
button.setGraphic(getGraphic());
|
button.setGraphic(getGraphic());
|
||||||
button.setOnAction(e -> {
|
button.setOnAction(e -> {
|
||||||
GuiDsStoreCreator.show("inProgress", null, null, v -> v.getCategory().equals(category), entry -> {
|
GuiDsStoreCreator.show(
|
||||||
chosenStore.setValue(entry.getStore());
|
"inProgress",
|
||||||
}, false);
|
null,
|
||||||
|
null,
|
||||||
|
v -> v.getCategory().equals(category),
|
||||||
|
entry -> {
|
||||||
|
chosenStore.setValue(entry.getStore());
|
||||||
|
},
|
||||||
|
false);
|
||||||
e.consume();
|
e.consume();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,8 +67,7 @@ public class DataStoreSelectorComp extends Comp<CompStructure<Button>> {
|
||||||
return JfxHelper.createNamedEntry(
|
return JfxHelper.createNamedEntry(
|
||||||
AppI18n.get("selectStreamStore"), AppI18n.get("openStreamStoreWizard"), graphic);
|
AppI18n.get("selectStreamStore"), AppI18n.get("openStreamStoreWizard"), graphic);
|
||||||
} else {
|
} else {
|
||||||
return JfxHelper.createNamedEntry(
|
return JfxHelper.createNamedEntry(f.getFileName(), f.getPath(), graphic);
|
||||||
f.getFileName().toString(), f.getPath().toString(), graphic);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@ import java.nio.file.Path;
|
||||||
|
|
||||||
public class DsLocalDirectoryBrowseComp extends Comp<CompStructure<Button>> {
|
public class DsLocalDirectoryBrowseComp extends Comp<CompStructure<Button>> {
|
||||||
|
|
||||||
private final DataSourceProvider provider;
|
private final DataSourceProvider<?> provider;
|
||||||
private final Property<Path> chosenDir;
|
private final Property<Path> chosenDir;
|
||||||
|
|
||||||
public DsLocalDirectoryBrowseComp(DataSourceProvider provider, Property<Path> chosenDir) {
|
public DsLocalDirectoryBrowseComp(DataSourceProvider<?> provider, Property<Path> chosenDir) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.chosenDir = chosenDir;
|
this.chosenDir = chosenDir;
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ public class DsLocalDirectoryBrowseComp extends Comp<CompStructure<Button>> {
|
||||||
button.setGraphic(getGraphic());
|
button.setGraphic(getGraphic());
|
||||||
button.setOnAction(e -> {
|
button.setOnAction(e -> {
|
||||||
var dirChooser = new DirectoryChooser();
|
var dirChooser = new DirectoryChooser();
|
||||||
dirChooser.setTitle(
|
dirChooser.setTitle(AppI18n.get(
|
||||||
AppI18n.get("browseDirectoryTitle", provider.getFileProvider().getFileName()));
|
"browseDirectoryTitle", provider.getFileProvider().getFileName()));
|
||||||
File file = dirChooser.showDialog(button.getScene().getWindow());
|
File file = dirChooser.showDialog(button.getScene().getWindow());
|
||||||
if (file != null && file.exists()) {
|
if (file != null && file.exists()) {
|
||||||
chosenDir.setValue(file.toPath());
|
chosenDir.setValue(file.toPath());
|
||||||
|
@ -55,7 +55,8 @@ public class DsLocalDirectoryBrowseComp extends Comp<CompStructure<Button>> {
|
||||||
private Region getGraphic() {
|
private Region getGraphic() {
|
||||||
var graphic = provider.getDisplayIconFileName();
|
var graphic = provider.getDisplayIconFileName();
|
||||||
if (chosenDir.getValue() == null) {
|
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 {
|
} else {
|
||||||
return JfxHelper.createNamedEntry(
|
return JfxHelper.createNamedEntry(
|
||||||
chosenDir.getValue().getFileName().toString(),
|
chosenDir.getValue().getFileName().toString(),
|
||||||
|
|
|
@ -68,8 +68,7 @@ public class DsLocalFileBrowseComp extends Comp<CompStructure<Button>> {
|
||||||
if (chosenFile.getValue() == null || !(chosenFile.getValue() instanceof FileStore f) || f.getPath() == null) {
|
if (chosenFile.getValue() == null || !(chosenFile.getValue() instanceof FileStore f) || f.getPath() == null) {
|
||||||
return JfxHelper.createNamedEntry(AppI18n.get("browse"), AppI18n.get("selectFileFromComputer"), graphic);
|
return JfxHelper.createNamedEntry(AppI18n.get("browse"), AppI18n.get("selectFileFromComputer"), graphic);
|
||||||
} else {
|
} else {
|
||||||
return JfxHelper.createNamedEntry(
|
return JfxHelper.createNamedEntry(f.getFileName(), f.getPath(), graphic);
|
||||||
f.getFileName().toString(), f.getPath().toString(), graphic);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,7 @@ public class DsStoreProviderChoiceComp extends Comp<CompStructure<ComboBox<Node>
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DataStoreProvider> getProviders() {
|
private List<DataStoreProvider> getProviders() {
|
||||||
return DataStoreProviders.getAll().stream()
|
return DataStoreProviders.getAll().stream().filter(filter).toList();
|
||||||
.filter(filter)
|
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Region createGraphic(DataStoreProvider provider) {
|
private Region createGraphic(DataStoreProvider provider) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ import java.util.function.Predicate;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
|
public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
|
||||||
|
|
||||||
public static enum Mode {
|
public enum Mode {
|
||||||
OPEN,
|
OPEN,
|
||||||
WRITE
|
WRITE
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
var isNamedStore =
|
var isNamedStore =
|
||||||
XPipeDaemon.getInstance().getStoreName(selected.getValue()).isPresent();
|
XPipeDaemon.getInstance().getStoreName(selected.getValue()).isPresent();
|
||||||
var localStore = new SimpleObjectProperty<FileStore>(
|
var localStore = new SimpleObjectProperty<>(
|
||||||
!isNamedStore
|
!isNamedStore
|
||||||
&& selected.getValue() instanceof FileStore fileStore
|
&& selected.getValue() instanceof FileStore fileStore
|
||||||
&& fileStore.getFileSystem() instanceof LocalStore
|
&& fileStore.getFileSystem() instanceof LocalStore
|
||||||
|
@ -101,7 +101,7 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
|
||||||
},
|
},
|
||||||
provider != null ? provider : new SimpleObjectProperty<>());
|
provider != null ? provider : new SimpleObjectProperty<>());
|
||||||
|
|
||||||
var remoteStore = new SimpleObjectProperty<DataStore>(
|
var remoteStore = new SimpleObjectProperty<>(
|
||||||
isNamedStore
|
isNamedStore
|
||||||
&& selected.getValue() instanceof FileStore fileStore
|
&& selected.getValue() instanceof FileStore fileStore
|
||||||
&& !(fileStore.getFileSystem() instanceof LocalStore)
|
&& !(fileStore.getFileSystem() instanceof LocalStore)
|
||||||
|
@ -110,13 +110,13 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable {
|
||||||
var remote = new TabPaneComp.Entry(
|
var remote = new TabPaneComp.Entry(
|
||||||
AppI18n.observable("remote"), "mdi2e-earth", new DsRemoteFileChoiceComp(remoteStore));
|
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(
|
var named = new TabPaneComp.Entry(
|
||||||
AppI18n.observable("stored"),
|
AppI18n.observable("stored"),
|
||||||
"mdrmz-storage",
|
"mdrmz-storage",
|
||||||
NamedStoreChoiceComp.create(filter, namedStore, DataStoreProvider.DataCategory.STREAM));
|
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);
|
localStore.get() == null && remoteStore.get() == null && !isNamedStore ? selected.getValue() : null);
|
||||||
var other = new TabPaneComp.Entry(
|
var other = new TabPaneComp.Entry(
|
||||||
AppI18n.observable("other"),
|
AppI18n.observable("other"),
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
|
||||||
Property<DataStoreProvider> provider,
|
Property<DataStoreProvider> provider,
|
||||||
Property<DataStore> store,
|
Property<DataStore> store,
|
||||||
Predicate<DataStoreProvider> filter,
|
Predicate<DataStoreProvider> filter,
|
||||||
String initialName, boolean exists
|
String initialName,
|
||||||
) {
|
boolean exists) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
@ -97,26 +97,38 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showEdit(DataStoreEntry e) {
|
public static void showEdit(DataStoreEntry e) {
|
||||||
show(e.getName(), e.getProvider(), e.getStore(), v -> true, newE -> {
|
show(
|
||||||
ThreadHelper.runAsync(() -> {
|
e.getName(),
|
||||||
e.applyChanges(newE);
|
e.getProvider(),
|
||||||
if (!DataStorage.get().getStoreEntries().contains(e)) {
|
e.getStore(),
|
||||||
DataStorage.get().addStoreEntry(e);
|
v -> true,
|
||||||
}
|
newE -> {
|
||||||
DataStorage.get().refresh();
|
ThreadHelper.runAsync(() -> {
|
||||||
});
|
e.applyChanges(newE);
|
||||||
}, true);
|
if (!DataStorage.get().getStoreEntries().contains(e)) {
|
||||||
|
DataStorage.get().addStoreEntry(e);
|
||||||
|
}
|
||||||
|
DataStorage.get().refresh();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showCreation(Predicate<DataStoreProvider> filter) {
|
public static void showCreation(Predicate<DataStoreProvider> filter) {
|
||||||
show(null, null, null, filter, e -> {
|
show(
|
||||||
try {
|
null,
|
||||||
DataStorage.get().addStoreEntry(e);
|
null,
|
||||||
// ScanAlert.showAsync(e.getStore(), true);
|
null,
|
||||||
} catch (Exception ex) {
|
filter,
|
||||||
ErrorEvent.fromThrowable(ex).handle();
|
e -> {
|
||||||
}
|
try {
|
||||||
}, false);
|
DataStorage.get().addStoreEntry(e);
|
||||||
|
// ScanAlert.showAsync(e.getStore(), true);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ErrorEvent.fromThrowable(ex).handle();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void show(
|
public static void show(
|
||||||
|
@ -126,8 +138,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
|
||||||
Predicate<DataStoreProvider> filter,
|
Predicate<DataStoreProvider> filter,
|
||||||
Consumer<DataStoreEntry> con,
|
Consumer<DataStoreEntry> con,
|
||||||
boolean exists) {
|
boolean exists) {
|
||||||
var prop = new SimpleObjectProperty<DataStoreProvider>(provider);
|
var prop = new SimpleObjectProperty<>(provider);
|
||||||
var store = new SimpleObjectProperty<DataStore>(s);
|
var store = new SimpleObjectProperty<>(s);
|
||||||
var loading = new SimpleBooleanProperty();
|
var loading = new SimpleBooleanProperty();
|
||||||
var name = "addConnection";
|
var name = "addConnection";
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
|
@ -162,12 +174,26 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comp<?> bottom() {
|
public Comp<?> bottom() {
|
||||||
var disable = Bindings.createBooleanBinding(() -> {
|
var disable = Bindings.createBooleanBinding(
|
||||||
return provider.getValue() == null || store.getValue() == null || !store.getValue().isComplete();
|
() -> {
|
||||||
}, provider, store);
|
return provider.getValue() == null
|
||||||
return new PopupMenuButtonComp(new SimpleStringProperty("Insights >"), Comp.of(() -> {
|
|| store.getValue() == null
|
||||||
return provider.getValue() != null ? provider.getValue().createInsightsComp(store).createRegion() : null;
|
|| !store.getValue().isComplete();
|
||||||
}), true).disable(disable).styleClass("button-comp");
|
},
|
||||||
|
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() {
|
private static boolean showInvalidConfirmAlert() {
|
||||||
|
@ -288,7 +314,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists) {
|
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");
|
messageProp.setValue("Store with name " + name.getValue() + " does already exist");
|
||||||
changedSinceError.setValue(false);
|
changedSinceError.setValue(false);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -116,8 +116,12 @@ public class NamedStoreChoiceComp extends SimpleComp implements Validatable {
|
||||||
refreshShown(list, shown);
|
refreshShown(list, shown);
|
||||||
});
|
});
|
||||||
|
|
||||||
var prop = new SimpleObjectProperty<>(selected.getValue() != null ?
|
var prop = new SimpleObjectProperty<>(
|
||||||
DataStorage.get().getStoreEntryIfPresent(selected.getValue()).orElse(null):null);
|
selected.getValue() != null
|
||||||
|
? DataStorage.get()
|
||||||
|
.getStoreEntryIfPresent(selected.getValue())
|
||||||
|
.orElse(null)
|
||||||
|
: null);
|
||||||
setUpListener(prop);
|
setUpListener(prop);
|
||||||
|
|
||||||
var filterComp = new FilterComp(filterString)
|
var filterComp = new FilterComp(filterString)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.kordamp.ikonli.javafx.FontIcon;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class DataStoreTypeComp extends SimpleComp {
|
public class DataStoreTypeComp extends SimpleComp {
|
||||||
|
|
||||||
private final DataSource<?> source;
|
DataSource<?> source;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class StorageFilter {
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface Filterable {
|
public interface Filterable {
|
||||||
|
|
||||||
boolean shouldShow(String filter);
|
boolean shouldShow(String filter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,10 @@ public class SourceCollectionLayoutComp extends SimpleComp {
|
||||||
var filler = Comp.of(() -> new Region());
|
var filler = Comp.of(() -> new Region());
|
||||||
filler.styleClass("bar");
|
filler.styleClass("bar");
|
||||||
filler.styleClass("filler-bar");
|
filler.styleClass("filler-bar");
|
||||||
var button = new ButtonComp(AppI18n.observable("addCollection"), new FontIcon("mdi2f-folder-plus-outline"), () -> {
|
var button = new ButtonComp(
|
||||||
SourceCollectionViewState.get().addNewCollection();
|
AppI18n.observable("addCollection"), new FontIcon("mdi2f-folder-plus-outline"), () -> {
|
||||||
})
|
SourceCollectionViewState.get().addNewCollection();
|
||||||
|
})
|
||||||
.apply(new FancyTooltipAugment<>("addCollectionFolder"));
|
.apply(new FancyTooltipAugment<>("addCollectionFolder"));
|
||||||
button.styleClass("intro-add-collection-button");
|
button.styleClass("intro-add-collection-button");
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Comparator;
|
||||||
|
|
||||||
public interface SourceCollectionSortMode {
|
public interface SourceCollectionSortMode {
|
||||||
|
|
||||||
static SourceCollectionSortMode ALPHABETICAL_DESC = new SourceCollectionSortMode() {
|
SourceCollectionSortMode ALPHABETICAL_DESC = new SourceCollectionSortMode() {
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "alphabetical-desc";
|
return "alphabetical-desc";
|
||||||
|
@ -21,7 +21,7 @@ public interface SourceCollectionSortMode {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static SourceCollectionSortMode ALPHABETICAL_ASC = new SourceCollectionSortMode() {
|
SourceCollectionSortMode ALPHABETICAL_ASC = new SourceCollectionSortMode() {
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "alphabetical-asc";
|
return "alphabetical-asc";
|
||||||
|
@ -34,7 +34,7 @@ public interface SourceCollectionSortMode {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static SourceCollectionSortMode DATE_DESC = new SourceCollectionSortMode() {
|
SourceCollectionSortMode DATE_DESC = new SourceCollectionSortMode() {
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "date-desc";
|
return "date-desc";
|
||||||
|
@ -48,7 +48,7 @@ public interface SourceCollectionSortMode {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static SourceCollectionSortMode DATE_ASC = new SourceCollectionSortMode() {
|
SourceCollectionSortMode DATE_ASC = new SourceCollectionSortMode() {
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "date-asc";
|
return "date-asc";
|
||||||
|
|
|
@ -35,10 +35,9 @@ public class SourceCollectionWrapper implements StorageFilter.Filterable {
|
||||||
|
|
||||||
public SourceCollectionWrapper(DataSourceCollection collection) {
|
public SourceCollectionWrapper(DataSourceCollection collection) {
|
||||||
this.collection = collection;
|
this.collection = collection;
|
||||||
this.entries =
|
this.entries = new SimpleListProperty<>(FXCollections.observableList(collection.getEntries().stream()
|
||||||
new SimpleListProperty<SourceEntryWrapper>(FXCollections.observableList(collection.getEntries().stream()
|
.map(SourceEntryWrapper::new)
|
||||||
.map(SourceEntryWrapper::new)
|
.collect(Collectors.toCollection(ArrayList::new))));
|
||||||
.collect(Collectors.toCollection(ArrayList::new))));
|
|
||||||
this.size = new SimpleIntegerProperty(collection.getEntries().size());
|
this.size = new SimpleIntegerProperty(collection.getEntries().size());
|
||||||
this.name = new SimpleStringProperty(collection.getName());
|
this.name = new SimpleStringProperty(collection.getName());
|
||||||
this.lastAccess = new SimpleObjectProperty<>(collection.getLastAccess().minus(Duration.ofMillis(500)));
|
this.lastAccess = new SimpleObjectProperty<>(collection.getLastAccess().minus(Duration.ofMillis(500)));
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.kordamp.ikonli.javafx.FontIcon;
|
||||||
|
|
||||||
public class SourceEntryContextMenu<S extends CompStructure<?>> extends ContextMenuAugment<S> {
|
public class SourceEntryContextMenu<S extends CompStructure<?>> extends ContextMenuAugment<S> {
|
||||||
|
|
||||||
|
|
||||||
public SourceEntryContextMenu(boolean showOnPrimaryButton, SourceEntryWrapper entry, Region renameTextField) {
|
public SourceEntryContextMenu(boolean showOnPrimaryButton, SourceEntryWrapper entry, Region renameTextField) {
|
||||||
super(() -> createContextMenu(entry, renameTextField));
|
super(() -> createContextMenu(entry, renameTextField));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ public interface SourceEntryDisplayMode {
|
||||||
SourceEntryDisplayMode LIST = new ListMode();
|
SourceEntryDisplayMode LIST = new ListMode();
|
||||||
SourceEntryDisplayMode TILES = 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 SOURCE_TYPE_WIDTH = 0.15;
|
||||||
private static final double NAME_WIDTH = 0.4;
|
private static final double NAME_WIDTH = 0.4;
|
||||||
|
|
|
@ -11,7 +11,6 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||||
import io.xpipe.app.issue.ErrorEvent;
|
import io.xpipe.app.issue.ErrorEvent;
|
||||||
import io.xpipe.app.storage.DataSourceEntry;
|
import io.xpipe.app.storage.DataSourceEntry;
|
||||||
import io.xpipe.app.storage.DataStorage;
|
import io.xpipe.app.storage.DataStorage;
|
||||||
import io.xpipe.app.storage.StorageElement;
|
|
||||||
import io.xpipe.core.source.DataSource;
|
import io.xpipe.core.source.DataSource;
|
||||||
import io.xpipe.core.store.DataFlow;
|
import io.xpipe.core.store.DataFlow;
|
||||||
import javafx.beans.property.*;
|
import javafx.beans.property.*;
|
||||||
|
@ -37,14 +36,9 @@ public class SourceEntryWrapper implements StorageFilter.Filterable {
|
||||||
|
|
||||||
public SourceEntryWrapper(DataSourceEntry entry) {
|
public SourceEntryWrapper(DataSourceEntry entry) {
|
||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
entry.addListener(new StorageElement.Listener() {
|
entry.addListener(() -> PlatformThread.runLaterIfNeeded(() -> {
|
||||||
@Override
|
update();
|
||||||
public void onUpdate() {
|
}));
|
||||||
PlatformThread.runLaterIfNeeded(() -> {
|
|
||||||
update();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
update();
|
update();
|
||||||
name.addListener((c, o, n) -> {
|
name.addListener((c, o, n) -> {
|
||||||
if (!entry.getName().equals(n)) {
|
if (!entry.getName().equals(n)) {
|
||||||
|
|
|
@ -23,7 +23,8 @@ public class StoreCreationBarComp extends SimpleComp {
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
var newStreamStore = new ButtonComp(
|
var newStreamStore = new ButtonComp(
|
||||||
AppI18n.observable("addCommand"), new FontIcon("mdi2c-code-greater-than"), () -> {
|
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)
|
.styleClass(Styles.FLAT)
|
||||||
.shortcut(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN))
|
.shortcut(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN))
|
||||||
|
@ -38,22 +39,24 @@ public class StoreCreationBarComp extends SimpleComp {
|
||||||
.apply(new FancyTooltipAugment<>("addHost"));
|
.apply(new FancyTooltipAugment<>("addHost"));
|
||||||
|
|
||||||
var newShellStore = new ButtonComp(
|
var newShellStore = new ButtonComp(
|
||||||
AppI18n.observable("addShell"), new FontIcon("mdi2t-text-box-multiple"), () -> {
|
AppI18n.observable("addShell"), new FontIcon("mdi2t-text-box-multiple"), () -> {
|
||||||
GuiDsStoreCreator.showCreation(v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.SHELL));
|
GuiDsStoreCreator.showCreation(
|
||||||
})
|
v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.SHELL));
|
||||||
|
})
|
||||||
.styleClass(Styles.FLAT)
|
.styleClass(Styles.FLAT)
|
||||||
.shortcut(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN))
|
.shortcut(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN))
|
||||||
.apply(new FancyTooltipAugment<>("addShell"));
|
.apply(new FancyTooltipAugment<>("addShell"));
|
||||||
|
|
||||||
var newDbStore = new ButtonComp(
|
var newDbStore = new ButtonComp(AppI18n.observable("addDatabase"), new FontIcon("mdi2d-database-plus"), () -> {
|
||||||
AppI18n.observable("addDatabase"), new FontIcon("mdi2d-database-plus"), () -> {
|
GuiDsStoreCreator.showCreation(
|
||||||
GuiDsStoreCreator.showCreation(v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.DATABASE));
|
v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.DATABASE));
|
||||||
})
|
})
|
||||||
.styleClass(Styles.FLAT)
|
.styleClass(Styles.FLAT)
|
||||||
.shortcut(new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN))
|
.shortcut(new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN))
|
||||||
.apply(new FancyTooltipAugment<>("addDatabase"));
|
.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()));
|
box.apply(s -> AppFont.medium(s.get()));
|
||||||
var bar = box.createRegion();
|
var bar = box.createRegion();
|
||||||
bar.getStyleClass().add("bar");
|
bar.getStyleClass().add("bar");
|
||||||
|
|
|
@ -148,9 +148,12 @@ public class StoreEntryComp extends SimpleComp {
|
||||||
button.getStyleClass().add("store-entry-comp");
|
button.getStyleClass().add("store-entry-comp");
|
||||||
button.setMaxWidth(2000);
|
button.setMaxWidth(2000);
|
||||||
button.setFocusTraversable(true);
|
button.setFocusTraversable(true);
|
||||||
button.accessibleTextProperty().bind(Bindings.createStringBinding(() -> {
|
button.accessibleTextProperty()
|
||||||
return entry.getName();
|
.bind(Bindings.createStringBinding(
|
||||||
}, entry.nameProperty()));
|
() -> {
|
||||||
|
return entry.getName();
|
||||||
|
},
|
||||||
|
entry.nameProperty()));
|
||||||
button.accessibleHelpProperty().bind(entry.getInformation());
|
button.accessibleHelpProperty().bind(entry.getInformation());
|
||||||
button.setOnAction(event -> {
|
button.setOnAction(event -> {
|
||||||
event.consume();
|
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;
|
return button;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +214,8 @@ public class StoreEntryComp extends SimpleComp {
|
||||||
var settingsButton = new IconButtonComp("mdomz-settings");
|
var settingsButton = new IconButtonComp("mdomz-settings");
|
||||||
settingsButton.styleClass("settings");
|
settingsButton.styleClass("settings");
|
||||||
settingsButton.accessibleText("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(GrowAugment.create(false, true));
|
||||||
settingsButton.apply(s -> {
|
settingsButton.apply(s -> {
|
||||||
s.get().prefWidthProperty().bind(Bindings.divide(s.get().heightProperty(), 1.35));
|
s.get().prefWidthProperty().bind(Bindings.divide(s.get().heightProperty(), 1.35));
|
||||||
|
|
|
@ -54,7 +54,8 @@ public class StoreEntryFlatMiniSectionComp extends SimpleComp {
|
||||||
var image = entry.getState() == DataStoreEntry.State.LOAD_FAILED
|
var image = entry.getState() == DataStoreEntry.State.LOAD_FAILED
|
||||||
? "disabled_icon.png"
|
? "disabled_icon.png"
|
||||||
: entry.getProvider().getDisplayIconFileName(entry.getStore());
|
: 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 spacer = new Spacer(depth * 10, Orientation.HORIZONTAL);
|
||||||
var box = new HBox(spacer, label);
|
var box = new HBox(spacer, label);
|
||||||
return box;
|
return box;
|
||||||
|
|
|
@ -31,9 +31,12 @@ public class StoreEntryListComp extends SimpleComp {
|
||||||
@Override
|
@Override
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
var initialCount = StoreViewState.get().getAllEntries().size();
|
var initialCount = StoreViewState.get().getAllEntries().size();
|
||||||
var showIntro = Bindings.createBooleanBinding(() -> {
|
var showIntro = Bindings.createBooleanBinding(
|
||||||
return initialCount == StoreViewState.get().getAllEntries().size() && AppState.get().isInitialLaunch();
|
() -> {
|
||||||
}, StoreViewState.get().getAllEntries());
|
return initialCount == StoreViewState.get().getAllEntries().size()
|
||||||
|
&& AppState.get().isInitialLaunch();
|
||||||
|
},
|
||||||
|
StoreViewState.get().getAllEntries());
|
||||||
var map = new LinkedHashMap<Comp<?>, ObservableBooleanValue>();
|
var map = new LinkedHashMap<Comp<?>, ObservableBooleanValue>();
|
||||||
map.put(
|
map.put(
|
||||||
createList(),
|
createList(),
|
||||||
|
|
|
@ -40,7 +40,8 @@ public class StoreEntrySection extends Comp<CompStructure<VBox>> {
|
||||||
.accessibleText("Expand")
|
.accessibleText("Expand")
|
||||||
.disable(BindingsHelper.persist(
|
.disable(BindingsHelper.persist(
|
||||||
Bindings.size(section.getChildren()).isEqualTo(0)))
|
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);
|
List<Comp<?>> topEntryList = List.of(button, root);
|
||||||
|
|
||||||
var all = section.getChildren();
|
var all = section.getChildren();
|
||||||
|
|
|
@ -18,7 +18,6 @@ import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import org.kordamp.ikonli.javafx.FontIcon;
|
import org.kordamp.ikonli.javafx.FontIcon;
|
||||||
|
|
||||||
|
|
||||||
public class StoreIntroComp extends SimpleComp {
|
public class StoreIntroComp extends SimpleComp {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,15 +52,11 @@ public class StoreIntroComp extends SimpleComp {
|
||||||
docLinkPane.setAlignment(Pos.CENTER);
|
docLinkPane.setAlignment(Pos.CENTER);
|
||||||
|
|
||||||
var v = new VBox(
|
var v = new VBox(
|
||||||
title,
|
title, introDesc, new Separator(Orientation.HORIZONTAL), machine, scanPane
|
||||||
introDesc,
|
// new Separator(Orientation.HORIZONTAL),
|
||||||
new Separator(Orientation.HORIZONTAL),
|
// documentation,
|
||||||
machine,
|
// docLinkPane
|
||||||
scanPane
|
);
|
||||||
// new Separator(Orientation.HORIZONTAL),
|
|
||||||
// documentation,
|
|
||||||
// docLinkPane
|
|
||||||
);
|
|
||||||
v.setMinWidth(Region.USE_PREF_SIZE);
|
v.setMinWidth(Region.USE_PREF_SIZE);
|
||||||
v.setMaxWidth(Region.USE_PREF_SIZE);
|
v.setMaxWidth(Region.USE_PREF_SIZE);
|
||||||
v.setMinHeight(Region.USE_PREF_SIZE);
|
v.setMinHeight(Region.USE_PREF_SIZE);
|
||||||
|
|
|
@ -20,28 +20,27 @@ public class StoreSection implements StorageFilter.Filterable {
|
||||||
private static final Comparator<StoreSection> COMPARATOR = Comparator.<StoreSection, Instant>comparing(
|
private static final Comparator<StoreSection> COMPARATOR = Comparator.<StoreSection, Instant>comparing(
|
||||||
o -> o.wrapper.getEntry().getState().equals(DataStoreEntry.State.COMPLETE_AND_VALID)
|
o -> o.wrapper.getEntry().getState().equals(DataStoreEntry.State.COMPLETE_AND_VALID)
|
||||||
? o.wrapper.getEntry().getLastAccess()
|
? o.wrapper.getEntry().getLastAccess()
|
||||||
: Instant.EPOCH).reversed()
|
: Instant.EPOCH)
|
||||||
|
.reversed()
|
||||||
.thenComparing(
|
.thenComparing(
|
||||||
storeEntrySection -> storeEntrySection.wrapper.getEntry().getName());
|
storeEntrySection -> storeEntrySection.wrapper.getEntry().getName());
|
||||||
|
|
||||||
public static StoreSection createTopLevel() {
|
public static StoreSection createTopLevel() {
|
||||||
var topLevel = BindingsHelper.mappedContentBinding(StoreViewState.get().getAllEntries(), storeEntryWrapper -> create(storeEntryWrapper));
|
var topLevel = BindingsHelper.mappedContentBinding(
|
||||||
var filtered =
|
StoreViewState.get().getAllEntries(), storeEntryWrapper -> create(storeEntryWrapper));
|
||||||
BindingsHelper.filteredContentBinding(topLevel, section -> {
|
var filtered = BindingsHelper.filteredContentBinding(topLevel, section -> {
|
||||||
if (!section.getWrapper().getEntry().getState().isUsable()) {
|
if (!section.getWrapper().getEntry().getState().isUsable()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parent = section.getWrapper()
|
var parent = section.getWrapper()
|
||||||
.getEntry()
|
.getEntry()
|
||||||
.getProvider()
|
.getProvider()
|
||||||
.getParent(section.getWrapper().getEntry().getStore());
|
.getParent(section.getWrapper().getEntry().getStore());
|
||||||
return parent == null
|
return parent == null
|
||||||
|| (DataStorage.get().getStoreEntryIfPresent(parent).isEmpty());
|
|| (DataStorage.get().getStoreEntryIfPresent(parent).isEmpty());
|
||||||
});
|
});
|
||||||
var ordered = BindingsHelper.orderedContentBinding(
|
var ordered = BindingsHelper.orderedContentBinding(filtered, COMPARATOR);
|
||||||
filtered,
|
|
||||||
COMPARATOR);
|
|
||||||
return new StoreSection(null, ordered);
|
return new StoreSection(null, ordered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,14 +53,12 @@ public class StoreSection implements StorageFilter.Filterable {
|
||||||
StoreViewState.get().getAllEntries(),
|
StoreViewState.get().getAllEntries(),
|
||||||
other -> other.getEntry().getState().isUsable()
|
other -> other.getEntry().getState().isUsable()
|
||||||
&& e.getEntry()
|
&& e.getEntry()
|
||||||
.getStore()
|
.getStore()
|
||||||
.equals(other.getEntry()
|
.equals(other.getEntry()
|
||||||
.getProvider()
|
.getProvider()
|
||||||
.getParent(other.getEntry().getStore())));
|
.getParent(other.getEntry().getStore())));
|
||||||
var children = BindingsHelper.mappedContentBinding(filtered, entry1 -> create(entry1));
|
var children = BindingsHelper.mappedContentBinding(filtered, entry1 -> create(entry1));
|
||||||
var ordered = BindingsHelper.orderedContentBinding(
|
var ordered = BindingsHelper.orderedContentBinding(children, COMPARATOR);
|
||||||
children,
|
|
||||||
COMPARATOR);
|
|
||||||
return new StoreSection(e, ordered);
|
return new StoreSection(e, ordered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,8 @@ public class AppActionLinkDetector {
|
||||||
alert.setTitle(AppI18n.get("clipboardActionDetectedTitle"));
|
alert.setTitle(AppI18n.get("clipboardActionDetectedTitle"));
|
||||||
alert.setHeaderText(AppI18n.get("clipboardActionDetectedHeader"));
|
alert.setHeaderText(AppI18n.get("clipboardActionDetectedHeader"));
|
||||||
alert.getDialogPane()
|
alert.getDialogPane()
|
||||||
.setContent(AppWindowHelper.alertContentText(AppI18n.get("clipboardActionDetectedContent")));
|
.setContent(
|
||||||
|
AppWindowHelper.alertContentText(AppI18n.get("clipboardActionDetectedContent")));
|
||||||
})
|
})
|
||||||
.map(buttonType -> buttonType.getButtonData().isDefaultButton())
|
.map(buttonType -> buttonType.getButtonData().isDefaultButton())
|
||||||
.orElse(false);
|
.orElse(false);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Locale;
|
||||||
|
|
||||||
public class AppCharsets {
|
public class AppCharsets {
|
||||||
|
|
||||||
private static List<String> observedCharsets = new ArrayList<>();
|
private static final List<String> observedCharsets = new ArrayList<>();
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
var system = System.getProperty("file.encoding");
|
var system = System.getProperty("file.encoding");
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class AppExtensionManager {
|
||||||
private ModuleLayer baseLayer = ModuleLayer.boot();
|
private ModuleLayer baseLayer = ModuleLayer.boot();
|
||||||
private ModuleLayer extendedLayer;
|
private ModuleLayer extendedLayer;
|
||||||
|
|
||||||
public static void init(boolean loadProviders) throws Exception {
|
public static void init(boolean loadProviders) {
|
||||||
if (INSTANCE != null) {
|
if (INSTANCE != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -242,12 +242,12 @@ public class AppExtensionManager {
|
||||||
.tag("dependencies", ext.get().getDependencies())
|
.tag("dependencies", ext.get().getDependencies())
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
return Optional.of(ext.get());
|
return ext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ErrorEvent.fromThrowable(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();
|
.handle();
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class AppI18n {
|
||||||
private Map<String, String> translations;
|
private Map<String, String> translations;
|
||||||
private Map<String, String> markdownDocumentations;
|
private Map<String, String> markdownDocumentations;
|
||||||
private PrettyTime prettyTime;
|
private PrettyTime prettyTime;
|
||||||
private static AppI18n INSTANCE = new AppI18n();
|
private static final AppI18n INSTANCE = new AppI18n();
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
var i = INSTANCE;
|
var i = INSTANCE;
|
||||||
|
@ -59,7 +59,7 @@ private static AppI18n INSTANCE = new AppI18n();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AppI18n getInstance() {
|
public static AppI18n getInstance() {
|
||||||
return ((AppI18n) INSTANCE);
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StringBinding readableDuration(String s, ObservableValue<Instant> instant) {
|
public static StringBinding readableDuration(String s, ObservableValue<Instant> instant) {
|
||||||
|
@ -73,7 +73,8 @@ private static AppI18n INSTANCE = new AppI18n();
|
||||||
return "null";
|
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);
|
instant);
|
||||||
}
|
}
|
||||||
|
@ -209,9 +210,9 @@ private static AppI18n INSTANCE = new AppI18n();
|
||||||
AtomicInteger lineCounter = new AtomicInteger();
|
AtomicInteger lineCounter = new AtomicInteger();
|
||||||
var simpleName = FilenameUtils.getExtension(module.getName());
|
var simpleName = FilenameUtils.getExtension(module.getName());
|
||||||
String defaultPrefix = simpleName.equals("app") ? "app." : simpleName + ".";
|
String defaultPrefix = simpleName.equals("app") ? "app." : simpleName + ".";
|
||||||
Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
|
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||||
if (!matchesLocale(file)) {
|
if (!matchesLocale(file)) {
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +228,7 @@ private static AppI18n INSTANCE = new AppI18n();
|
||||||
props.forEach((key, value) -> {
|
props.forEach((key, value) -> {
|
||||||
var hasPrefix = key.toString().contains(".");
|
var hasPrefix = key.toString().contains(".");
|
||||||
var usedPrefix = hasPrefix ? "" : defaultPrefix;
|
var usedPrefix = hasPrefix ? "" : defaultPrefix;
|
||||||
translations.put(usedPrefix + key.toString(), value.toString());
|
translations.put(usedPrefix + key, value.toString());
|
||||||
lineCounter.incrementAndGet();
|
lineCounter.incrementAndGet();
|
||||||
});
|
});
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
@ -252,9 +253,9 @@ private static AppI18n INSTANCE = new AppI18n();
|
||||||
}
|
}
|
||||||
|
|
||||||
var moduleName = FilenameUtils.getExtension(module.getName());
|
var moduleName = FilenameUtils.getExtension(module.getName());
|
||||||
Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
|
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||||
if (!matchesLocale(file)) {
|
if (!matchesLocale(file)) {
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -263,10 +264,13 @@ private static AppI18n INSTANCE = new AppI18n();
|
||||||
return FileVisitResult.CONTINUE;
|
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)) {
|
try (var in = Files.newInputStream(file)) {
|
||||||
var usedPrefix = moduleName + ":";
|
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) {
|
} catch (IOException ex) {
|
||||||
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
|
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@ public class AppImages {
|
||||||
|
|
||||||
var simpleName = FilenameUtils.getExtension(module);
|
var simpleName = FilenameUtils.getExtension(module);
|
||||||
String defaultPrefix = simpleName + ":";
|
String defaultPrefix = simpleName + ":";
|
||||||
Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
|
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||||
var relativeFileName = FilenameUtils.separatorsToUnix(
|
var relativeFileName = FilenameUtils.separatorsToUnix(
|
||||||
basePath.relativize(file).toString());
|
basePath.relativize(file).toString());
|
||||||
try {
|
try {
|
||||||
|
@ -108,8 +108,8 @@ public class AppImages {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage toAwtImage(Image fxImage) {
|
public static BufferedImage toAwtImage(Image fxImage) {
|
||||||
BufferedImage img = new BufferedImage(
|
BufferedImage img =
|
||||||
(int) fxImage.getWidth(), (int) fxImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
new BufferedImage((int) fxImage.getWidth(), (int) fxImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||||
for (int x = 0; x < fxImage.getWidth(); x++) {
|
for (int x = 0; x < fxImage.getWidth(); x++) {
|
||||||
for (int y = 0; y < fxImage.getHeight(); y++) {
|
for (int y = 0; y < fxImage.getHeight(); y++) {
|
||||||
int rgb = fxImage.getPixelReader().getArgb(x, y);
|
int rgb = fxImage.getPixelReader().getArgb(x, y);
|
||||||
|
|
|
@ -255,7 +255,7 @@ public class AppMainWindow {
|
||||||
var awt = AppImages.toAwtImage(image);
|
var awt = AppImages.toAwtImage(image);
|
||||||
var file = Path.of(System.getProperty("user.home"), "Desktop", "xpipe-screenshot.png");
|
var file = Path.of(System.getProperty("user.home"), "Desktop", "xpipe-screenshot.png");
|
||||||
try {
|
try {
|
||||||
ImageIO.write(awt, "png",file.toFile());
|
ImageIO.write(awt, "png", file.toFile());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ErrorEvent.fromThrowable(e).handle();
|
ErrorEvent.fromThrowable(e).handle();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ public class AppProperties {
|
||||||
fullVersion = Optional.ofNullable(System.getProperty("io.xpipe.app.fullVersion"))
|
fullVersion = Optional.ofNullable(System.getProperty("io.xpipe.app.fullVersion"))
|
||||||
.map(Boolean::parseBoolean)
|
.map(Boolean::parseBoolean)
|
||||||
.orElse(false);
|
.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");
|
build = Optional.ofNullable(System.getProperty("io.xpipe.app.build")).orElse("unknown");
|
||||||
buildUuid = Optional.ofNullable(System.getProperty("io.xpipe.app.buildId"))
|
buildUuid = Optional.ofNullable(System.getProperty("io.xpipe.app.buildId"))
|
||||||
.map(UUID::fromString)
|
.map(UUID::fromString)
|
||||||
|
|
|
@ -71,8 +71,7 @@ public class AppResources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean withLocalDevResource(
|
private static boolean withLocalDevResource(String module, String file, FailableConsumer<Path, IOException> con) {
|
||||||
String module, String file, FailableConsumer<Path, IOException> con) {
|
|
||||||
try (var fs = openFileSystem(module)) {
|
try (var fs = openFileSystem(module)) {
|
||||||
var url = fs.getPath("").getWrappedPath().toUri().toURL();
|
var url = fs.getPath("").getWrappedPath().toUri().toURL();
|
||||||
if (!url.getProtocol().equals("jar")) {
|
if (!url.getProtocol().equals("jar")) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class AppSocketServer {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
listenerThread.join();
|
listenerThread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public class AppSocketServer {
|
||||||
listenerThread = new Thread(
|
listenerThread = new Thread(
|
||||||
() -> {
|
() -> {
|
||||||
while (running) {
|
while (running) {
|
||||||
Socket clientSocket = null;
|
Socket clientSocket;
|
||||||
try {
|
try {
|
||||||
clientSocket = socket.accept();
|
clientSocket = socket.accept();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -114,7 +114,7 @@ public class AppSocketServer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode node = null;
|
JsonNode node;
|
||||||
try (InputStream blockIn = BeaconFormat.readBlocks(clientSocket.getInputStream())) {
|
try (InputStream blockIn = BeaconFormat.readBlocks(clientSocket.getInputStream())) {
|
||||||
node = JacksonMapper.newMapper().readTree(blockIn);
|
node = JacksonMapper.newMapper().readTree(blockIn);
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ public class AppSocketServer {
|
||||||
|
|
||||||
private void performExchanges(Socket clientSocket, int id) {
|
private void performExchanges(Socket clientSocket, int id) {
|
||||||
try {
|
try {
|
||||||
JsonNode informationNode = null;
|
JsonNode informationNode;
|
||||||
try (InputStream blockIn = BeaconFormat.readBlocks(clientSocket.getInputStream())) {
|
try (InputStream blockIn = BeaconFormat.readBlocks(clientSocket.getInputStream())) {
|
||||||
informationNode = JacksonMapper.newMapper().readTree(blockIn);
|
informationNode = JacksonMapper.newMapper().readTree(blockIn);
|
||||||
}
|
}
|
||||||
|
@ -230,10 +230,8 @@ public class AppSocketServer {
|
||||||
Deobfuscator.deobfuscate(ex);
|
Deobfuscator.deobfuscate(ex);
|
||||||
sendServerErrorResponse(clientSocket, ex);
|
sendServerErrorResponse(clientSocket, ex);
|
||||||
}
|
}
|
||||||
} catch (SocketException ex) {
|
} // Omit it, as this might happen often
|
||||||
// Omit it, as this might happen often
|
catch (Throwable ex) {
|
||||||
ErrorEvent.fromThrowable(ex).omitted(true).build().handle();
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
ErrorEvent.fromThrowable(ex).build().handle();
|
ErrorEvent.fromThrowable(ex).build().handle();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -16,7 +16,8 @@ public class AppSplashScreen {
|
||||||
stage.setResizable(false);
|
stage.setResizable(false);
|
||||||
stage.initStyle(StageStyle.TRANSPARENT);
|
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);
|
var scene = new Scene(new Pane(content), -1, -1, false);
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
|
@ -100,5 +100,4 @@ public class AppStyle {
|
||||||
|
|
||||||
scenes.add(scene);
|
scenes.add(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,11 @@ public class AppTheme {
|
||||||
|
|
||||||
// Animate!
|
// Animate!
|
||||||
var transition = new Timeline(
|
var transition = new Timeline(
|
||||||
new KeyFrame(Duration.ZERO, new KeyValue(imageView.opacityProperty(), 1, Interpolator.EASE_OUT)),
|
|
||||||
new KeyFrame(
|
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 -> {
|
transition.setOnFinished(e -> {
|
||||||
root.getChildren().remove(imageView);
|
root.getChildren().remove(imageView);
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,7 +73,8 @@ public class AppWindowHelper {
|
||||||
childStage.setY(stage.getY() + stage.getHeight() / 2 - childStage.getHeight() / 2);
|
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(() -> {
|
ThreadHelper.runAsync(() -> {
|
||||||
var r = showBlockingAlert(c);
|
var r = showBlockingAlert(c);
|
||||||
if (bt != null) {
|
if (bt != null) {
|
||||||
|
|
|
@ -264,7 +264,7 @@ public abstract class OperationMode {
|
||||||
|
|
||||||
public abstract void onSwitchTo();
|
public abstract void onSwitchTo();
|
||||||
|
|
||||||
public abstract void onSwitchFrom() throws Throwable;
|
public abstract void onSwitchFrom();
|
||||||
|
|
||||||
public abstract void initialSetup() throws Throwable;
|
public abstract void initialSetup() throws Throwable;
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ public abstract class PlatformMode extends OperationMode {
|
||||||
ThreadHelper.sleep(100);
|
ThreadHelper.sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If we downloaded an update, and decided to no longer automatically update, don't remind us!
|
// 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
|
// You can still update manually in the about tab
|
||||||
if (AppPrefs.get().automaticallyUpdate().get()) {
|
if (AppPrefs.get().automaticallyUpdate().get()) {
|
||||||
|
@ -91,7 +90,9 @@ public abstract class PlatformMode extends OperationMode {
|
||||||
protected void waitForPlatform() {
|
protected void waitForPlatform() {
|
||||||
// The platform thread waits for the shutdown hook to finish in case SIGTERM is sent.
|
// 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.
|
// 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 ...");
|
TrackEvent.info("mode", "Waiting for platform thread ...");
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
Platform.runLater(latch::countDown);
|
Platform.runLater(latch::countDown);
|
||||||
|
|
|
@ -21,15 +21,15 @@ public class AskpassExchangeImpl extends AskpassExchange
|
||||||
private final Map<String, SecretValue> passwords = new HashMap<>();
|
private final Map<String, SecretValue> passwords = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
if (OperationMode.get().equals(OperationMode.BACKGROUND)) {
|
if (OperationMode.get().equals(OperationMode.BACKGROUND)) {
|
||||||
OperationMode.switchTo(OperationMode.TRAY);
|
OperationMode.switchTo(OperationMode.TRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SecretValue set = AppCache.get(msg.getId(), SecretValue.class, () -> null);
|
// SecretValue set = AppCache.get(msg.getId(), SecretValue.class, () -> null);
|
||||||
// if (set != null) {
|
// if (set != null) {
|
||||||
// return Response.builder().value(set).build();
|
// return Response.builder().value(set).build();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (requestToId.containsKey(msg.getRequest())) {
|
if (requestToId.containsKey(msg.getRequest())) {
|
||||||
var id = requestToId.remove(msg.getRequest());
|
var id = requestToId.remove(msg.getRequest());
|
||||||
|
@ -37,11 +37,12 @@ public class AskpassExchangeImpl extends AskpassExchange
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passwords.containsKey(msg.getId())) {
|
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 =
|
var prop = new SimpleObjectProperty<SecretValue>();
|
||||||
new SimpleObjectProperty<SecretValue>();
|
|
||||||
var r = AppWindowHelper.showBlockingAlert(alert -> {
|
var r = AppWindowHelper.showBlockingAlert(alert -> {
|
||||||
alert.setTitle(AppI18n.get("askpassAlertTitle"));
|
alert.setTitle(AppI18n.get("askpassAlertTitle"));
|
||||||
alert.setHeaderText(msg.getPrompt());
|
alert.setHeaderText(msg.getPrompt());
|
||||||
|
@ -52,7 +53,7 @@ public class AskpassExchangeImpl extends AskpassExchange
|
||||||
})
|
})
|
||||||
.filter(b -> b.getButtonData().isDefaultButton() && prop.getValue() != null)
|
.filter(b -> b.getButtonData().isDefaultButton() && prop.getValue() != null)
|
||||||
.map(t -> {
|
.map(t -> {
|
||||||
//AppCache.update(msg.getId(), prop.getValue());
|
// AppCache.update(msg.getId(), prop.getValue());
|
||||||
return prop.getValue();
|
return prop.getValue();
|
||||||
})
|
})
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
|
@ -8,7 +8,7 @@ public class FocusExchangeImpl extends FocusExchange
|
||||||
implements MessageExchangeImpl<FocusExchange.Request, FocusExchange.Response> {
|
implements MessageExchangeImpl<FocusExchange.Request, FocusExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
OperationMode.switchUp(OperationMode.map(msg.getMode()));
|
OperationMode.switchUp(OperationMode.map(msg.getMode()));
|
||||||
return Response.builder().build();
|
return Response.builder().build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class OpenExchangeImpl extends OpenExchange
|
||||||
implements MessageExchangeImpl<OpenExchange.Request, OpenExchange.Response> {
|
implements MessageExchangeImpl<OpenExchange.Request, OpenExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
if (msg.getArguments().size() == 0) {
|
if (msg.getArguments().size() == 0) {
|
||||||
OperationMode.switchToAsync(OperationMode.GUI);
|
OperationMode.switchToAsync(OperationMode.GUI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class ProxyFunctionExchangeImpl extends ProxyFunctionExchange
|
||||||
implements MessageExchangeImpl<ProxyFunctionExchange.Request, ProxyFunctionExchange.Response> {
|
implements MessageExchangeImpl<ProxyFunctionExchange.Request, ProxyFunctionExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
msg.getFunction().callLocal();
|
msg.getFunction().callLocal();
|
||||||
return ProxyFunctionExchange.Response.builder()
|
return ProxyFunctionExchange.Response.builder()
|
||||||
.function(msg.getFunction())
|
.function(msg.getFunction())
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class ProxyReadConnectionExchangeImpl extends ProxyReadConnectionExchange
|
||||||
implements MessageExchangeImpl<ProxyReadConnectionExchange.Request, ProxyReadConnectionExchange.Response> {
|
implements MessageExchangeImpl<ProxyReadConnectionExchange.Request, ProxyReadConnectionExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
handler.postResponse(() -> {
|
handler.postResponse(() -> {
|
||||||
var outputSource = DataSource.createInternalDataSource(
|
var outputSource = DataSource.createInternalDataSource(
|
||||||
msg.getSource().getType(), new OutputStreamStore(handler.sendBody()));
|
msg.getSource().getType(), new OutputStreamStore(handler.sendBody()));
|
||||||
|
|
|
@ -8,7 +8,7 @@ public class VersionExchangeImpl extends VersionExchange
|
||||||
implements MessageExchangeImpl<VersionExchange.Request, VersionExchange.Response> {
|
implements MessageExchangeImpl<VersionExchange.Request, VersionExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
var jvmVersion = System.getProperty("java.vm.vendor") + " "
|
var jvmVersion = System.getProperty("java.vm.vendor") + " "
|
||||||
+ System.getProperty("java.vm.name") + " ("
|
+ System.getProperty("java.vm.name") + " ("
|
||||||
+ System.getProperty("java.vm.version") + ")";
|
+ System.getProperty("java.vm.version") + ")";
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class InstanceExchangeImpl extends InstanceExchange
|
||||||
implements MessageExchangeImpl<InstanceExchange.Request, InstanceExchange.Response> {
|
implements MessageExchangeImpl<InstanceExchange.Request, InstanceExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
return Response.builder()
|
return Response.builder()
|
||||||
.instance(XPipeInstanceHelper.getInstance(new LocalStore()).orElseThrow())
|
.instance(XPipeInstanceHelper.getInstance(new LocalStore()).orElseThrow())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class ListCollectionsExchangeImpl extends ListCollectionsExchange
|
||||||
implements MessageExchangeImpl<ListCollectionsExchange.Request, ListCollectionsExchange.Response> {
|
implements MessageExchangeImpl<ListCollectionsExchange.Request, ListCollectionsExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
DataStorage s = DataStorage.get();
|
DataStorage s = DataStorage.get();
|
||||||
var e = s.getSourceCollections().stream()
|
var e = s.getSourceCollections().stream()
|
||||||
.map(col -> CollectionListEntry.builder()
|
.map(col -> CollectionListEntry.builder()
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class ListStoresExchangeImpl extends ListStoresExchange
|
||||||
implements MessageExchangeImpl<ListStoresExchange.Request, ListStoresExchange.Response> {
|
implements MessageExchangeImpl<ListStoresExchange.Request, ListStoresExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
DataStorage s = DataStorage.get();
|
DataStorage s = DataStorage.get();
|
||||||
var e = s.getStoreEntries().stream()
|
var e = s.getStoreEntries().stream()
|
||||||
.filter(entry -> !entry.isDisabled() && entry.getProvider().shouldShow())
|
.filter(entry -> !entry.isDisabled() && entry.getProvider().shouldShow())
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class RenameStoreExchangeImpl extends RenameStoreExchange
|
||||||
implements MessageExchangeImpl<RenameStoreExchange.Request, RenameStoreExchange.Response> {
|
implements MessageExchangeImpl<RenameStoreExchange.Request, RenameStoreExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@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);
|
var s = DataStorage.get().getStoreEntry(msg.getStoreName(), true);
|
||||||
DataStorage.get().renameStoreEntry(s, msg.getNewName());
|
DataStorage.get().renameStoreEntry(s, msg.getNewName());
|
||||||
return Response.builder().build();
|
return Response.builder().build();
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class SourceProviderListExchangeImpl extends SourceProviderListExchange
|
||||||
implements MessageExchangeImpl<SourceProviderListExchange.Request, SourceProviderListExchange.Response> {
|
implements MessageExchangeImpl<SourceProviderListExchange.Request, SourceProviderListExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
var all = DataSourceProviders.getAll();
|
var all = DataSourceProviders.getAll();
|
||||||
var map = new LinkedHashMap<DataSourceType, List<ProviderEntry>>();
|
var map = new LinkedHashMap<DataSourceType, List<ProviderEntry>>();
|
||||||
for (DataSourceType t : DataSourceType.values()) {
|
for (DataSourceType t : DataSourceType.values()) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class StatusExchangeImpl extends StatusExchange
|
||||||
implements MessageExchangeImpl<StatusExchange.Request, StatusExchange.Response> {
|
implements MessageExchangeImpl<StatusExchange.Request, StatusExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
|
public Response handleRequest(BeaconHandler handler, Request msg) {
|
||||||
String mode;
|
String mode;
|
||||||
if (OperationMode.get() == null) {
|
if (OperationMode.get() == null) {
|
||||||
mode = "none";
|
mode = "none";
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue