All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xworker.javafx.control.DatePickerActions Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package xworker.javafx.control;

import javafx.scene.control.DatePicker;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;
import xworker.javafx.util.JavaFXUtils;

import java.time.LocalDate;
import java.time.chrono.Chronology;

public class DatePickerActions {
	static{
		PropertyFactory.regist(DatePicker.class, "dayCellFactoryProperty", o -> {
			DatePicker obj = (DatePicker) o;
			return obj.dayCellFactoryProperty();
		});
		PropertyFactory.regist(DatePicker.class, "showWeekNumbersProperty", o -> {
			DatePicker obj = (DatePicker) o;
			return obj.showWeekNumbersProperty();
		});
		PropertyFactory.regist(DatePicker.class, "chronologyProperty", o -> {
			DatePicker obj = (DatePicker) o;
			return obj.chronologyProperty();
		});
		PropertyFactory.regist(DatePicker.class, "converterProperty", o -> {
			DatePicker obj = (DatePicker) o;
			return obj.converterProperty();
		});
	}

	public static void init(DatePicker picker, Thing thing, ActionContext actionContext) {
		ComboBoxBaseActions.init(picker, thing, actionContext);

		if(thing.valueExists("value")){
			LocalDate value = JavaFXUtils.getObject(thing, "value", actionContext);
			if(value != null){
				picker.setValue(value);
			}
		}
		
		if(thing.valueExists("chronology")) {
			Chronology chronology = JavaFXUtils.getChronology(thing.getString("chronology"));
			if(chronology != null) {
				picker.setChronology(chronology);
			}
		}
		
		if(thing.valueExists("showWeekNumbers")) {
			picker.setShowWeekNumbers(thing.getBoolean("showWeekNumbers"));
		}
	}
	
	public static DatePicker create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");
		
		DatePicker picker = new DatePicker();
		init(picker, self, actionContext);
		actionContext.g().put(self.getMetadata().getName(), picker);
		
		actionContext.peek().put("parent", picker);
		for(Thing child : self.getChilds()) {
			child.doAction("create", actionContext);
		}
		
		return picker;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy