package com.test;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.smartgwt.client.data.DateRange;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.MiniDateRangeItem;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.Layout;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class App implements EntryPoint {

	private Layout panel;

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		MiniDateRangeItem dateItem = new MiniDateRangeItem("dateRangeItem");
		dateItem.setWidth("*");
		dateItem.addChangedHandler(changedEvent -> {
			GWT.log("Changed!");
			DateRange dr = (DateRange) changedEvent.getValue();
			Label l = new Label("Start=" + dr.getStartDate() + " End=" + dr.getEndDate());
			l.setWidth100();
			l.setHeight(30);
			l.setWrap(false);
			panel.addMember(l);
		});

		DynamicForm form = new DynamicForm();
		form.setNumCols(3);
		form.setColWidths(100, 300, "*");
		form.setWidth100();
		form.setItems(dateItem);

		panel = new VLayout();
		panel.setWidth100();
		panel.setHeight100();
		panel.setMembers(form);
		panel.draw();
	}
}
