Package thegame.layers.options

Source Code of thegame.layers.options.FieldAction$Shell

/*
* 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);
    }
}
TOP

Related Classes of thegame.layers.options.FieldAction$Shell

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.