package bluej.stride.operations;
import java.util.List;
import java.util.function.Consumer;
import bluej.stride.slots.EditableSlot.MenuItemOrder;
import javafx.beans.value.ObservableValue;
import bluej.stride.generic.Frame;
import bluej.stride.generic.InteractionManager;
import bluej.utility.Utility;
| Implementation of FrameOperation, designed to allow you to
| pass a lambda as the execute method.
|
public class CustomFrameOperation
extends FrameOperation{
private List<ItemLabel> labels;
private Consumer<List<Frame>> action;
public CustomFrameOperation(InteractionManager editor, String identifier, Combine combine, List<String> name, MenuItemOrder menuOrder, Consumer<List<Frame>> action)
{
super(editor, identifier, combine);
this.labels = Utility.mapList(name, n -> l(n, menuOrder));
this.action = action;
}
public CustomFrameOperation(InteractionManager editor, String identifier, List<String> name, MenuItemOrder menuOrder, Frame f, Runnable action)
{
this(editor, identifier, Combine.ONE, name, menuOrder, frames -> {
if (frames.size() != 1 || frames.get(0) != f) {
if (frames.size() != 0)
throw new IllegalStateException();
}
action.run();
});
}
@Override
protected void execute(List<Frame> frames)
{
action.accept(frames);
}
@Override
public List getLabels()
{
return labels;
}
@Override
public boolean onlyOnContextMenu()
{
return true;
}
}
top,
use,
map,
class CustomFrameOperation
. CustomFrameOperation
. CustomFrameOperation
. execute
. getLabels
. onlyOnContextMenu
67 neLoCode
+ 2 LoComm