Search in sources :

Example 1 with DatePickerEvent

use of com.extjs.gxt.ui.client.event.DatePickerEvent in project geo-platform by geosdi.

the class TimePeriodDateMultifield method addComponents.

protected void addComponents() {
    super.setSpacing(20);
    this.dtFormat = DateTimeFormat.getFormat("dd-MM-yyyy");
    this.dateField = new DateField();
    this.dateField.setToolTip(dateTooltip());
    this.dateField.getPropertyEditor().setFormat(dtFormat);
    this.dateField.setWidth(90);
    this.dateField.setEditable(false);
    this.dateField.setAllowBlank(Boolean.FALSE);
    DatePicker datePicker = this.dateField.getDatePicker();
    datePicker.addListener(Events.Select, new Listener<DatePickerEvent>() {

        @Override
        public void handleEvent(DatePickerEvent dpe) {
            date = dpe.getDate();
            hourField.clear();
            hourField.enable();
            minuteField.setEnabled(Boolean.TRUE);
            Date dateWithZeroTime = FORMATTER_DATE.parse(FORMATTER_DATE.format(limitDate));
            afterDateSelected(dateWithZeroTime);
            refreshDate();
        }
    });
    this.hourField = new SpinnerField();
    this.hourField.addListener(Events.Change, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            minuteField.clear();
            minuteField.enable();
            Date time = FORMATTER_TIME.parse(FORMATTER_TIME.format(limitDate));
            Date dateWithZeroTime = FORMATTER_DATE.parse(FORMATTER_DATE.format(limitDate));
            afterHourSelected(dateWithZeroTime, time);
            refreshDate();
        }
    });
    this.hourField.setToolTip(hourTooltip());
    this.hourField.setWidth(40);
    this.hourField.disable();
    this.hourField.setAllowBlank(Boolean.FALSE);
    this.minuteField = new SpinnerField();
    this.minuteField.setToolTip(minuteTooltip());
    this.minuteField.disable();
    this.minuteField.setWidth(40);
    this.minuteField.setAllowBlank(Boolean.FALSE);
    this.minuteField.addListener(Events.Change, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            refreshDate();
        }
    });
    super.setFieldLabel(fieldLabel());
    super.setOrientation(Style.Orientation.HORIZONTAL);
    super.add(this.dateField);
    super.add(this.hourField);
    super.add(this.minuteField);
    super.addStyleName("dateMultifield");
    super.setValidator(addValidator());
    setMaxMinValue();
}
Also used : SpinnerField(com.extjs.gxt.ui.client.widget.form.SpinnerField) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) DatePickerEvent(com.extjs.gxt.ui.client.event.DatePickerEvent) DateField(com.extjs.gxt.ui.client.widget.form.DateField) DatePicker(com.extjs.gxt.ui.client.widget.DatePicker) Date(java.util.Date)

Example 2 with DatePickerEvent

use of com.extjs.gxt.ui.client.event.DatePickerEvent in project geo-platform by geosdi.

the class TimeAccordionWidget method addDateFields.

private void addDateFields() {
    DateTimeFormat dtFormat = DateTimeFormat.getFormat("dd-MM-yyyy");
    startDate = new DateField();
    startDate.setToolTip(CatalogFinderConstants.INSTANCE.TimeAccordionWidget_startDateTooltipText());
    startDate.getPropertyEditor().setFormat(dtFormat);
    startDate.setWidth(100);
    startDate.setEditable(false);
    DatePicker startDatePicker = startDate.getDatePicker();
    startDatePicker.addListener(Events.Select, new Listener<DatePickerEvent>() {

        @Override
        public void handleEvent(DatePickerEvent dpe) {
            setStartDate(dpe.getDate());
        }
    });
    endDate = new DateField();
    endDate.setToolTip(CatalogFinderConstants.INSTANCE.TimeAccordionWidget_endDateTooltipText());
    endDate.getPropertyEditor().setFormat(dtFormat);
    endDate.setWidth(100);
    endDate.setEditable(false);
    DatePicker endDatePicker = endDate.getDatePicker();
    endDatePicker.addListener(Events.Select, new Listener<DatePickerEvent>() {

        @Override
        public void handleEvent(DatePickerEvent dpe) {
            setEndDate(dpe.getDate());
        }
    });
    multiDates = new MultiField<DateField>();
    multiDates.setOrientation(Style.Orientation.HORIZONTAL);
    multiDates.add(new LabelField(CatalogFinderConstants.INSTANCE.TimeAccordionWidget_multidatesFromText()));
    multiDates.add(startDate);
    multiDates.add(new LabelField(CatalogFinderConstants.INSTANCE.TimeAccordionWidget_multidatesToText()));
    multiDates.add(endDate);
    // Disabled by default
    multiDates.disable();
    super.add(multiDates, new FlowData(5));
}
Also used : FlowData(com.extjs.gxt.ui.client.widget.layout.FlowData) DatePickerEvent(com.extjs.gxt.ui.client.event.DatePickerEvent) DatePicker(com.extjs.gxt.ui.client.widget.DatePicker) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Aggregations

DatePickerEvent (com.extjs.gxt.ui.client.event.DatePickerEvent)2 DatePicker (com.extjs.gxt.ui.client.widget.DatePicker)2 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 DateField (com.extjs.gxt.ui.client.widget.form.DateField)1 SpinnerField (com.extjs.gxt.ui.client.widget.form.SpinnerField)1 FlowData (com.extjs.gxt.ui.client.widget.layout.FlowData)1 DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)1 Date (java.util.Date)1