mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Add model info to branching actions
This commit is contained in:
parent
f382f30476
commit
d629fdddc8
8 changed files with 17 additions and 14 deletions
|
@ -66,7 +66,7 @@ final class BrowserContextMenu extends ContextMenu {
|
|||
|
||||
if (a instanceof BranchAction la) {
|
||||
var m = new Menu(a.getName(model, used) + " ...");
|
||||
for (LeafAction sub : la.getBranchingActions()) {
|
||||
for (LeafAction sub : la.getBranchingActions(model, used)) {
|
||||
var subUsed = resolveIfNeeded(sub, selected);
|
||||
if (!sub.isApplicable(model, subUsed)) {
|
||||
continue;
|
||||
|
|
|
@ -179,7 +179,7 @@ final class BrowserFileListComp extends SimpleComp {
|
|||
private void prepareTableShortcuts(TableView<BrowserEntry> table) {
|
||||
table.setOnKeyPressed(event -> {
|
||||
var selected = fileList.getSelection();
|
||||
BrowserAction.getFlattened().stream()
|
||||
BrowserAction.getFlattened(fileList.getFileSystemModel(), selected).stream()
|
||||
.filter(browserAction -> browserAction.isApplicable(fileList.getFileSystemModel(), selected)
|
||||
&& browserAction.isActive(fileList.getFileSystemModel(), selected))
|
||||
.filter(browserAction -> browserAction.getShortcut() != null)
|
||||
|
|
|
@ -47,10 +47,10 @@ public class OpenFileSystemComp extends SimpleComp {
|
|||
overview.disableProperty().bind(model.getInOverview());
|
||||
overview.setAccessibleText("System overview");
|
||||
|
||||
var backBtn = BrowserAction.byId("back").toButton(model, List.of());
|
||||
var forthBtn = BrowserAction.byId("forward").toButton(model, List.of());
|
||||
var refreshBtn = BrowserAction.byId("refresh").toButton(model, List.of());
|
||||
var terminalBtn = BrowserAction.byId("openTerminal").toButton(model, List.of());
|
||||
var backBtn = BrowserAction.byId("back", model, List.of()).toButton(model, List.of());
|
||||
var forthBtn = BrowserAction.byId("forward", model, List.of()).toButton(model, List.of());
|
||||
var refreshBtn = BrowserAction.byId("refresh", model, List.of()).toButton(model, List.of());
|
||||
var terminalBtn = BrowserAction.byId("openTerminal", model, List.of()).toButton(model, List.of());
|
||||
|
||||
var menuButton = new MenuButton(null, new FontIcon("mdral-folder_open"));
|
||||
new ContextMenuAugment<>(
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package io.xpipe.app.browser.action;
|
||||
|
||||
import io.xpipe.app.browser.BrowserEntry;
|
||||
import io.xpipe.app.browser.OpenFileSystemModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BranchAction extends BrowserAction {
|
||||
|
||||
List<LeafAction> getBranchingActions();
|
||||
List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries);
|
||||
}
|
||||
|
|
|
@ -23,17 +23,17 @@ public interface BrowserAction {
|
|||
|
||||
List<BrowserAction> ALL = new ArrayList<>();
|
||||
|
||||
static List<LeafAction> getFlattened() {
|
||||
static List<LeafAction> getFlattened(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return ALL.stream()
|
||||
.map(browserAction -> browserAction instanceof LeafAction
|
||||
? List.of((LeafAction) browserAction)
|
||||
: ((BranchAction) browserAction).getBranchingActions())
|
||||
: ((BranchAction) browserAction).getBranchingActions(model, entries))
|
||||
.flatMap(List::stream)
|
||||
.toList();
|
||||
}
|
||||
|
||||
static LeafAction byId(String id) {
|
||||
return getFlattened().stream()
|
||||
static LeafAction byId(String id, OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return getFlattened(model, entries).stream()
|
||||
.filter(browserAction -> id.equals(browserAction.getId()))
|
||||
.findAny()
|
||||
.orElseThrow();
|
||||
|
|
|
@ -20,7 +20,7 @@ public abstract class MultiExecuteAction implements BranchAction {
|
|||
protected abstract String createCommand(ShellControl sc, OpenFileSystemModel model, BrowserEntry entry);
|
||||
|
||||
@Override
|
||||
public List<LeafAction> getBranchingActions() {
|
||||
public List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return List.of(
|
||||
new LeafAction() {
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class CopyPathAction implements BrowserAction, BranchAction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<LeafAction> getBranchingActions() {
|
||||
public List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return List.of(
|
||||
new LeafAction() {
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public class NewItemAction implements BrowserAction, BranchAction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<LeafAction> getBranchingActions() {
|
||||
public List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return List.of(
|
||||
new LeafAction() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue