This commit is contained in:
crschnick
2025-06-12 09:35:03 +00:00
parent 7113503ec6
commit fcb8a8d2af
6 changed files with 7 additions and 73 deletions

View File

@@ -43,7 +43,7 @@ public interface ActionProvider {
.filter(aClass -> aClass.getSimpleName().equals("Action"))
.findFirst()
.map(aClass -> (Class<? extends AbstractAction>) aClass);
return Optional.of(child.get());
return child.isPresent() ? Optional.of(child.get()) : Optional.empty();
}
class Loader implements ModuleLayerLoader {

View File

@@ -1,65 +0,0 @@
package io.xpipe.app.comp.base;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.CompStructure;
import io.xpipe.app.comp.SimpleCompStructure;
import io.xpipe.app.comp.augment.ContextMenuAugment;
import io.xpipe.app.util.ContextMenuHelper;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ObservableValue;
import javafx.css.Size;
import javafx.css.SizeUnits;
import javafx.scene.control.Button;
import javafx.scene.control.MenuItem;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.List;
public class DropdownComp extends Comp<CompStructure<Button>> {
private final List<Comp<?>> items;
public DropdownComp(List<Comp<?>> items) {
this.items = items;
}
@Override
public CompStructure<Button> createBase() {
var cm = ContextMenuHelper.create();
cm.getItems()
.setAll(items.stream()
.map(comp -> {
return new MenuItem(null, comp.createRegion());
})
.toList());
Button button = (Button) new ButtonComp(null, () -> {})
.apply(new ContextMenuAugment<>(e -> true, null, () -> {
return cm;
}))
.createRegion();
List<? extends ObservableValue<Boolean>> l = cm.getItems().stream()
.map(menuItem -> menuItem.getGraphic().visibleProperty())
.toList();
button.visibleProperty()
.bind(Bindings.createBooleanBinding(
() -> {
return l.stream().anyMatch(booleanObservableValue -> booleanObservableValue.getValue());
},
l.toArray(ObservableValue[]::new)));
var graphic = new FontIcon("mdi2c-chevron-double-down");
button.fontProperty().subscribe(c -> {
graphic.setIconSize((int) new Size(c.getSize(), SizeUnits.PT).pixels());
});
button.setGraphic(graphic);
button.getStyleClass().add("dropdown-comp");
button.setAccessibleText("Dropdown actions");
return new SimpleCompStructure<>(button);
}
}

View File

@@ -17,7 +17,7 @@ public interface HubMenuLeafProvider<T extends DataStore> extends HubMenuItemPro
return false;
}
default void execute(DataStoreEntryRef<T> ref) throws Exception {
default void execute(DataStoreEntryRef<T> ref) {
createAction(ref).executeAsync();
}

View File

@@ -282,7 +282,7 @@ public abstract class StoreEntryComp extends SimpleComp {
p.getIcon(getWrapper().getEntry().ref()),
leaf != null
? () -> {
leaf.createAction(getWrapper().getEntry().ref()).executeAsync();
leaf.execute(getWrapper().getEntry().ref());
}
: null);
if (branch != null) {
@@ -543,7 +543,7 @@ public abstract class StoreEntryComp extends SimpleComp {
}
item.setOnAction(event -> {
leaf.createAction(getWrapper().getEntry().ref()).executeAsync();
leaf.execute(getWrapper().getEntry().ref());
event.consume();
if (event.getTarget() instanceof Menu m) {
m.getParentPopup().hide();

View File

@@ -355,8 +355,7 @@ public class StoreEntryWrapper {
entry.notifyUpdate(true, false);
if (found != null) {
if (found instanceof HubMenuLeafProvider<?> def) {
var act = def.createAction(entry.ref());
act.executeAsync();
def.execute(getEntry().ref());
}
} else {
entry.setExpanded(!entry.isExpanded());

View File

@@ -268,7 +268,7 @@ public class RunScriptActionProviderMenu
}
@Override
public void execute(DataStoreEntryRef<ShellStore> ref) throws Exception {
public void execute(DataStoreEntryRef<ShellStore> ref) {
var cat = StoreViewState.get().getCategoryWrapper(DataStorage.get().getStoreCategory(ref.get()));
cat.select();
}
@@ -315,7 +315,7 @@ public class RunScriptActionProviderMenu
}
@Override
public void execute(DataStoreEntryRef<ShellStore> ref) throws Exception {
public void execute(DataStoreEntryRef<ShellStore> ref) {
var cat = StoreViewState.get().getCategoryWrapper(DataStorage.get().getStoreCategory(ref.get()));
StoreCategoryConfigComp.show(cat);
}