Rework pro context menu entries

This commit is contained in:
crschnick 2023-12-28 07:38:37 +00:00
parent a81ea216aa
commit 75d6b1ed4f
2 changed files with 19 additions and 17 deletions

View file

@ -59,7 +59,8 @@ public interface LeafAction extends BrowserAction {
}
default MenuItem toItem(OpenFileSystemModel model, List<BrowserEntry> selected, UnaryOperator<String> nameFunc) {
var mi = new MenuItem(nameFunc.apply(getName(model, selected)));
var name = nameFunc.apply(getName(model, selected));
var mi = new MenuItem(name);
mi.setOnAction(event -> {
ThreadHelper.runFailableAsync(() -> {
BooleanScope.execute(model.getBusy(), () -> {
@ -80,7 +81,7 @@ public interface LeafAction extends BrowserAction {
if (getProFeatureId() != null && !LicenseProvider.get().getFeature(getProFeatureId()).isSupported()) {
mi.setDisable(true);
mi.setGraphic(new FontIcon("mdi2p-professional-hexagon"));
mi.setText(mi.getText() + " (Pro)");
}
return mi;

View file

@ -268,27 +268,28 @@ public abstract class StoreEntryComp extends SimpleComp {
!LicenseProvider.get().getFeature(p.getKey().getProFeatureId()).isSupported();
if (proRequired) {
item.setDisable(true);
item.setGraphic(new FontIcon("mdi2p-professional-hexagon"));
item.textProperty().bind(Bindings.createStringBinding(() -> name.getValue() + " (Pro)",name));
} else {
item.textProperty().bind(name);
}
Menu menu = actionProvider.canLinkTo() ? (Menu) item : null;
item.setOnAction(event -> {
if (menu != null && !event.getTarget().equals(menu)) {
return;
}
item.setOnAction(event -> {
if (menu != null && !event.getTarget().equals(menu)) {
return;
}
if (menu != null && menu.isDisable()) {
return;
}
if (menu != null && menu.isDisable()) {
return;
}
contextMenu.hide();
ThreadHelper.runFailableAsync(() -> {
var action = actionProvider.createAction(
wrapper.getEntry().ref());
action.execute();
});
contextMenu.hide();
ThreadHelper.runFailableAsync(() -> {
var action = actionProvider.createAction(
wrapper.getEntry().ref());
action.execute();
});
item.textProperty().bind(name);
});
if (actionProvider.activeType() == ActionProvider.DataStoreCallSite.ActiveType.ONLY_SHOW_IF_ENABLED) {
item.visibleProperty().bind(p.getValue());
} else if (actionProvider.activeType() == ActionProvider.DataStoreCallSite.ActiveType.ALWAYS_SHOW) {