Search in sources :

Example 1 with ExistingLocationValidator

use of gaiasky.util.validator.ExistingLocationValidator in project gaiasky by langurmonkey.

the class LandAtWindow method build.

@Override
protected void build() {
    latlonCb = new OwnCheckBox(I18n.txt("context.lonlat"), skin, "radio", pad10);
    latlonCb.setChecked(false);
    latlonCb.addListener(new EventListener() {

        @Override
        public boolean handle(com.badlogic.gdx.scenes.scene2d.Event event) {
            if (event instanceof ChangeEvent) {
                if (latlonCb.isChecked()) {
                    enableComponents(false, location);
                    enableComponents(true, longitude, latitude);
                    stage.setKeyboardFocus(longitude);
                }
                return true;
            }
            return false;
        }
    });
    longitude = new OwnTextField("", skin, new FloatValidator(0, 360));
    latitude = new OwnTextField("", skin, new FloatValidator(-90, 90));
    locationCb = new OwnCheckBox(I18n.txt("context.location"), skin, "radio", pad10);
    locationCb.setChecked(true);
    locationCb.addListener(new EventListener() {

        @Override
        public boolean handle(com.badlogic.gdx.scenes.scene2d.Event event) {
            if (event instanceof ChangeEvent) {
                if (locationCb.isChecked()) {
                    enableComponents(true, location);
                    enableComponents(false, longitude, latitude);
                    stage.setKeyboardFocus(location);
                }
                return true;
            }
            return false;
        }
    });
    location = new OwnTextField("", skin, new ExistingLocationValidator(target));
    new ButtonGroup<CheckBox>(latlonCb, locationCb);
    content.add(locationCb).left().top().padBottom(pad10).colspan(4).row();
    content.add(new OwnLabel(I18n.txt("context.location"), skin)).left().top().padRight(pad10);
    content.add(location).left().top().padBottom(pad10 * 2).row();
    content.add(latlonCb).left().top().padBottom(pad10).colspan(4).row();
    content.add(new OwnLabel(I18n.txt("context.longitude"), skin)).left().top().padRight(pad10);
    content.add(longitude).left().top().padRight(pad10 * 2);
    content.add(new OwnLabel(I18n.txt("context.latitude"), skin)).left().top().padRight(pad10);
    content.add(latitude).left().top();
}
Also used : ExistingLocationValidator(gaiasky.util.validator.ExistingLocationValidator) OwnTextField(gaiasky.util.scene2d.OwnTextField) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) ButtonGroup(com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup) OwnCheckBox(gaiasky.util.scene2d.OwnCheckBox) OwnLabel(gaiasky.util.scene2d.OwnLabel) EventListener(com.badlogic.gdx.scenes.scene2d.EventListener) FloatValidator(gaiasky.util.validator.FloatValidator)

Aggregations

EventListener (com.badlogic.gdx.scenes.scene2d.EventListener)1 ButtonGroup (com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup)1 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)1 OwnCheckBox (gaiasky.util.scene2d.OwnCheckBox)1 OwnLabel (gaiasky.util.scene2d.OwnLabel)1 OwnTextField (gaiasky.util.scene2d.OwnTextField)1 ExistingLocationValidator (gaiasky.util.validator.ExistingLocationValidator)1 FloatValidator (gaiasky.util.validator.FloatValidator)1