/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package thegame.layers.options;
import java.util.List;
import thegame.gui.GameMenuElement;
import thegame.gui.SelectionMenuCell;
import thegame.gui.SelectionMenuComponent;
import thegame.layers.Options;
/**
*
* @author www.b23prodtm.info
*/
public class FieldAction<VALUE> extends Field<VALUE> {
/**
* execute an shell(Swing, File IO, etc.) action
*/
public static abstract class Shell<RETURNVALUE> {
protected abstract RETURNVALUE execute();
}
Shell<VALUE> validate;
public FieldAction(String name, Shell<VALUE> doAction) {
super(name, null, null);
this.validate = doAction;
}
@Override
public SelectionMenuComponent makeOptionSlider(Options options, SelectionMenuComponent parent, List<SelectionMenuCell> menu) {
GameMenuElement._addToMenu(options.gui, menu, name, new Runnable() {
public void run() {
FieldAction.this.currentValue = validate.execute();
}
}, null);
return new SelectionMenuComponent(options.gui, name, parent, menu, SelectionMenuComponent.VERTICAL_LAYOUT);
}
}