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

eu.future.earth.gwt.client.date.picker.DatePickerDialog Maven / Gradle / Ivy

The newest version!
package eu.future.earth.gwt.client.date.picker;

import java.util.Date;

import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Widget;

import eu.future.earth.client.date.DateNoTimeZone;
import eu.future.earth.gwt.client.FtrGwtDatePickerCss;
import eu.future.earth.gwt.client.date.picker.DateSelectEvent.DateSelectEventActions;
import eu.future.earth.gwt.client.ui.button.CleanPopupPanel;
import eu.future.earth.gwt.client.ui.button.UiType;

public class DatePickerDialog extends CleanPopupPanel implements DateSelectListener, HasDateSelectHandlers {

	private DatePickerMonthNavigator whole = null;

	private final UiType type;

	public DatePickerDialog(DatePickerRenderer renderer, UiType newType) {
		super(true);
		type = newType;
		super.setStyleName(FtrGwtDatePickerCss.DIALOG);
		whole = new DatePickerMonthNavigator(renderer, type);
		setWidget(whole);
		whole.setWidth("250px");
		whole.addDateSelectEventHandler(this);
	}

	public void addWidgetToPicker(Widget newWidget) {
		whole.addWidgetToPicker(newWidget);
	};

	public void show(Widget below) {
		if (below == null) {
			super.show();
			super.center();
		} else {
			super.show();
			super.showRelativeTo(below);
		}
	}

	public void setSelectedDate(Date newDate) {
		whole.setSelectedDate(newDate);
	}

	@Override
	public HandlerRegistration addDateSelectEventHandler(DateSelectListener handler) {
		return addHandler(handler, DateSelectEvent.getType());
	}

	@Override
	public void handleDateSelectEvent(DateSelectEvent newEvent) {
		if (newEvent.getCommand() == DateSelectEventActions.SELECT_DAY) {
			DateSelectEvent.fire(this, newEvent);
			this.hide();
		}
		if (newEvent.getCommand() == DateSelectEventActions.SELECT_NEW_MONTH) {
			DateSelectEvent.fire(this, newEvent);
			this.hide();
		}
		if (newEvent.getCommand() == DateSelectEventActions.NAVIGATE_MONTH) {
			DateSelectEvent.fire(this, newEvent);
		}
	}

	public Date getSelected() {
		return whole.getSelected();
	}

	public DateNoTimeZone getSelectedNoTimeZOne() {
		return whole.getSelectedNoTimeZOne();
	}

	public void setSelectedDate(DateNoTimeZone theDate) {
		whole.setSelectedDate(theDate);
	}

	public Date getFirstDateShow() {
		return whole.getFirstDateShow();
	}

	public Date getLastDateShow() {
		return whole.getLastDateShow();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy