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

com.talk2object.plum.interaction.rich.field.component.DateFieldViewBuilder Maven / Gradle / Ivy

There is a newer version: 0.1.22
Show newest version
package com.talk2object.plum.interaction.rich.field.component;

import java.util.Date;

import com.talk2object.plum.interaction.controller.AbstractController;
import com.talk2object.plum.interaction.controller.Controller;
import com.talk2object.plum.interaction.rich.field.DateField;
import com.talk2object.plum.interaction.rich.field.InteractiveField;
import com.talk2object.plum.interaction.viewgeneneration.ViewBuildContext;
import com.talk2object.plum.view._abstract.components.DateTimePicker;
import com.talk2object.plum.view._abstract.window.UIComponent;

public class DateFieldViewBuilder extends AbstractFieldViewBuilder {

	@Override
	protected UIComponent createComponent(InteractiveField input) {
		DateTimePicker dateTimePicker = new DateTimePicker();
		DateTimePicker component = dateTimePicker;

		DateField dateInput = (DateField) input;

		dateTimePicker.setFormat(dateInput.getFormat());
		dateTimePicker.setMode(dateInput.getMode());

		new AbstractController(
				input, component) {

			@Override
			public void updateViewState() {

				getView().setDatetime((Date) getModel().getValue());
			}

			@Override
			public void updateModelState() {

				getModel().setValue(getView().getDatetime());
			}
		};

		return component;
	}

	@Override
	public Class getModelClass() {
		return DateField.class;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy