mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-22 15:40:31 -04:00
Cleanup
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user