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

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

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

import javafx.scene.Node;
import javafx.scene.control.Pagination;
import javafx.util.Callback;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.util.UtilData;
import xworker.javafx.beans.property.PropertyFactory;

public class PaginationActions {
	static{
		PropertyFactory.regist(Pagination.class, "maxPageIndicatorCountProperty", o -> {
			Pagination obj = (Pagination) o;
			return obj.maxPageIndicatorCountProperty();
		});
		PropertyFactory.regist(Pagination.class, "pageFactoryProperty", o -> {
			Pagination obj = (Pagination) o;
			return obj.pageFactoryProperty();
		});
		PropertyFactory.regist(Pagination.class, "currentPageIndexProperty", o -> {
			Pagination obj = (Pagination) o;
			return obj.currentPageIndexProperty();
		});
		PropertyFactory.regist(Pagination.class, "pageCountProperty", o -> {
			Pagination obj = (Pagination) o;
			return obj.pageCountProperty();
		});
	}

	@SuppressWarnings("unchecked")
	public static void init(Pagination p, Thing thing, ActionContext actionContext) {
		ControlActions.init(p, thing, actionContext);

		if (thing.valueExists("currentPageIndex")) {
			p.setCurrentPageIndex(thing.getInt("currentPageIndex"));
		}
		if (thing.valueExists("maxPageIndicatorCount")) {
			p.setMaxPageIndicatorCount(thing.getInt("maxPageIndicatorCount"));
		}
		if (thing.valueExists("pageCount")) {
			p.setPageCount(thing.getInt("pageCount"));
		}
		if (thing.valueExists("pageFactory")) {
			Callback pageFactory = (Callback) UtilData.getData(thing.getString("pageFactory"), actionContext);
			if(pageFactory != null) {
				p.setPageFactory(pageFactory);
			}
		}		
	}
	
	public static Pagination create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");
		
		Pagination item = new Pagination();
		init(item, self, actionContext);
		actionContext.g().put(self.getMetadata().getName(), item);
		
		actionContext.peek().put("parent", item);
		for(Thing child : self.getChilds()) {
			child.doAction("create", actionContext);			
		}
		
		return item;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy