Search in sources :

Example 1 with TimeField

use of com.extjs.gxt.ui.client.widget.form.TimeField in project kapua by eclipse.

the class DateRangeSelectorChart method showCustomDateRangeDialog.

private void showCustomDateRangeDialog() {
    Date end = m_endDate;
    if (end == null) {
        end = new Date();
    }
    final Dialog dialog = new Dialog();
    dialog.setBodyBorder(false);
    dialog.setHeading(MSGS.dataDateRangeCustomTitle());
    dialog.setWidth(300);
    dialog.setHeight(145);
    dialog.setHideOnButtonClick(true);
    dialog.setButtons(Dialog.OKCANCEL);
    dialog.setHideOnButtonClick(false);
    dialog.setModal(true);
    FormData formData = new FormData("-20");
    final FormPanel form = new FormPanel();
    form.setHeaderVisible(false);
    final DateField endDateField = new DateField();
    endDateField.setFieldLabel(MSGS.dataDateRangeStopDate());
    endDateField.setAllowBlank(false);
    endDateField.setValue(end);
    endDateField.setEditable(false);
    form.add(endDateField, formData);
    final TimeField endTimeField = new TimeField();
    endTimeField.setFormat(DateTimeFormat.getFormat("HH:mm"));
    endTimeField.setTriggerAction(TriggerAction.ALL);
    endTimeField.setFieldLabel(MSGS.dataDateRangeStopTime());
    endTimeField.setAllowBlank(false);
    endTimeField.setDateValue(end);
    endTimeField.setEditable(false);
    form.add(endTimeField, formData);
    dialog.add(form);
    dialog.getButtonById("ok").addSelectionListener(new SelectionListener<ButtonEvent>() {

        public void componentSelected(ButtonEvent ce) {
            if (form.isValid()) {
                long lEndDate = endDateField.getValue().getTime();
                lEndDate = lEndDate + (long) endTimeField.getValue().getHour() * 60L * 60L * 1000L + (long) endTimeField.getValue().getMinutes() * 60L * 1000L;
                m_endDate = new Date(lEndDate);
                DateTimeFormat dtf = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT);
                StringBuilder sb = new StringBuilder();
                sb.append(dtf.format(m_endDate));
                m_dateRange.setText(sb.toString());
                dialog.hide();
                if (m_listener != null) {
                    m_listener.onUpdate();
                }
            }
        }
    });
    dialog.getButtonById("cancel").addSelectionListener(new SelectionListener<ButtonEvent>() {

        public void componentSelected(ButtonEvent ce) {
            dialog.hide();
        }
    });
    dialog.show();
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) TimeField(com.extjs.gxt.ui.client.widget.form.TimeField) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) Dialog(com.extjs.gxt.ui.client.widget.Dialog) DateField(com.extjs.gxt.ui.client.widget.form.DateField) Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Example 2 with TimeField

use of com.extjs.gxt.ui.client.widget.form.TimeField in project geo-platform by geosdi.

the class TimeCQLButton method addDateAndTimeToContainer.

private void addDateAndTimeToContainer(LayoutContainer layoutContainer, String dataLabel, String timeLabel) {
    final DateField dateField = new DateField();
    dateField.setFieldLabel(dataLabel);
    dateField.setData("text", LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_dateFieldText());
    layoutContainer.setData(dataLabel, dateField);
    final TimeField timeField = new TimeField();
    timeField.setFieldLabel(timeLabel);
    timeField.setData("text", LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_timeFieldText());
    layoutContainer.setData(timeLabel, timeField);
    layoutContainer.add(dateField);
    layoutContainer.add(timeField);
}
Also used : TimeField(com.extjs.gxt.ui.client.widget.form.TimeField) DateField(com.extjs.gxt.ui.client.widget.form.DateField)

Example 3 with TimeField

use of com.extjs.gxt.ui.client.widget.form.TimeField in project geo-platform by geosdi.

the class TimeCQLButton method initialize.

@Override
protected void initialize() {
    formData = new FormData("98%");
    final RadioGroup radioGroup = new RadioGroup(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_radioGroupText());
    radioGroup.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_radioGroupFieldLabelText());
    final Radio beforeRadioButton = new Radio();
    beforeRadioButton.setData(RADIO_KEY_VALUE, "BEFORE");
    beforeRadioButton.setBoxLabel(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_beforeRadioGroupLabelText());
    beforeRadioButton.setHideLabel(Boolean.TRUE);
    final Radio afterRadioButton = new Radio();
    afterRadioButton.setData(RADIO_KEY_VALUE, "AFTER");
    afterRadioButton.setBoxLabel(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_afterRadioGroupLabelText());
    afterRadioButton.setHideLabel(Boolean.TRUE);
    final Radio duringRadioButton = new Radio();
    duringRadioButton.setData(RADIO_KEY_VALUE, "DURING");
    duringRadioButton.setBoxLabel(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_duringRadioGroupLabelText());
    duringRadioButton.setHideLabel(Boolean.TRUE);
    final Radio beforeOrDuringRadioButton = new Radio();
    beforeOrDuringRadioButton.setData(RADIO_KEY_VALUE, "BEFORE OR DURING");
    beforeOrDuringRadioButton.setBoxLabel(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_beforeOrDuringRadioGroupLabelText());
    beforeOrDuringRadioButton.setHideLabel(Boolean.TRUE);
    final Radio duringOrAfterRadioButton = new Radio();
    duringOrAfterRadioButton.setData(RADIO_KEY_VALUE, "DURING OR AFTER");
    duringOrAfterRadioButton.setBoxLabel(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_duringOrAfterRadioGroupLabelText());
    duringOrAfterRadioButton.setHideLabel(Boolean.TRUE);
    radioGroup.add(beforeRadioButton);
    radioGroup.add(beforeOrDuringRadioButton);
    radioGroup.add(duringRadioButton);
    radioGroup.add(duringOrAfterRadioButton);
    radioGroup.add(afterRadioButton);
    timeContainer = new LayoutContainer(new FormLayout());
    timeContainer.setVisible(Boolean.FALSE);
    this.addDateAndTimeToContainer(timeContainer, DATE_KEY_VALUE, TIME_KEY_VALUE);
    periodContainer = new LayoutContainer(new FormLayout());
    periodContainer.setVisible(Boolean.FALSE);
    this.addDateAndTimeToContainer(periodContainer, DATE_START_KEY_VALUE, TIME_START_KEY_VALUE);
    this.addDateAndTimeToContainer(periodContainer, DATE_END_KEY_VALUE, TIME_END_KEY_VALUE);
    Listener<FieldEvent> timeListener = new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent fe) {
            if ((Boolean) fe.getValue()) {
                timeContainer.setVisible(true);
                periodContainer.setVisible(false);
            }
        }
    };
    afterRadioButton.addListener(Events.Change, timeListener);
    beforeRadioButton.addListener(Events.Change, timeListener);
    Listener<FieldEvent> periodListener = new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent fe) {
            if ((Boolean) fe.getValue()) {
                periodContainer.setVisible(true);
                timeContainer.setVisible(false);
            }
        }
    };
    beforeOrDuringRadioButton.addListener(Events.Change, periodListener);
    duringOrAfterRadioButton.addListener(Events.Change, periodListener);
    duringRadioButton.addListener(Events.Change, periodListener);
    final Button insertButton = new Button(ButtonsConstants.INSTANCE.insertText(), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent be) {
            String temporalPredicate = radioGroup.getValue().getData(RADIO_KEY_VALUE);
            // System.out.println("Temporal predicate: " + temporalPredicate);
            StringBuilder timeBuilder = new StringBuilder(temporalPredicate);
            timeBuilder.append(" ");
            if (timeContainer.isVisible()) {
                DateField dateField = timeContainer.getData(DATE_KEY_VALUE);
                // System.out.println("Data: " + DateTimeFormat.getFormat("yyyy-MM-dd").format(dateField.getValue()));
                TimeField timeField = timeContainer.getData(TIME_KEY_VALUE);
                // System.out.println("Time: " + timeField.getValue().getText());
                timeBuilder.append(DateTimeFormat.getFormat("yyyy-MM-dd").format(dateField.getValue()));
                timeBuilder.append("T");
                timeBuilder.append(timeField.getValue().getText());
                timeBuilder.append(":00Z");
            } else if (periodContainer.isVisible()) {
                DateField dateStartField = periodContainer.getData(DATE_START_KEY_VALUE);
                TimeField timeStartField = periodContainer.getData(TIME_START_KEY_VALUE);
                timeBuilder.append(DateTimeFormat.getFormat("yyyy-MM-dd").format(dateStartField.getValue()));
                timeBuilder.append("T");
                timeBuilder.append(timeStartField.getValue().getText());
                timeBuilder.append(":00Z/");
                DateField dateEndField = periodContainer.getData(DATE_END_KEY_VALUE);
                TimeField timeEndField = periodContainer.getData(TIME_END_KEY_VALUE);
                timeBuilder.append(DateTimeFormat.getFormat("yyyy-MM-dd").format(dateEndField.getValue()));
                timeBuilder.append("T");
                timeBuilder.append(timeEndField.getValue().getText());
                timeBuilder.append(":00Z");
            } else {
                return;
            }
            TimeCQLButton.super.insertTextIntoFilterArea(timeBuilder.toString());
            window.hide();
        }
    });
    super.window = new GeoPlatformWindow(true) {

        @Override
        public void addComponent() {
            add(new Label(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_windowSelectLabelText()));
            add(radioGroup, formData);
            add(timeContainer, formData);
            add(periodContainer, formData);
            add(new Label(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_windowResultLabelText()));
            addButton(insertButton);
        }

        @Override
        public void initSize() {
            super.setSize("570", "270");
        }

        @Override
        public void setWindowProperties() {
            super.setHeadingHtml(LayerFiltersModuleConstants.INSTANCE.TimeCQLButton_windowHeadingText());
            super.setLayout(new FormLayout());
        }
    };
    super.initialized = Boolean.TRUE;
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) Listener(com.extjs.gxt.ui.client.event.Listener) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) Label(com.extjs.gxt.ui.client.widget.Label) Radio(com.extjs.gxt.ui.client.widget.form.Radio) GeoPlatformWindow(org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow) TimeField(com.extjs.gxt.ui.client.widget.form.TimeField) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) DateField(com.extjs.gxt.ui.client.widget.form.DateField)

Example 4 with TimeField

use of com.extjs.gxt.ui.client.widget.form.TimeField in project geo-platform by geosdi.

the class TimeInputWidget method addComponent.

@Override
public void addComponent() {
    final Button insertButton = new Button("Insert", new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent be) {
            StringBuilder timeBuilder = new StringBuilder();
            if (timeContainer.isVisible()) {
                DateField dateField = timeContainer.getData(DATE_KEY_VALUE);
                TimeField timeField = timeContainer.getData(TIME_KEY_VALUE);
                timeBuilder.append(DateTimeFormat.getFormat("yyyy-MM-dd").format(dateField.getValue()));
                timeBuilder.append("T");
                timeBuilder.append(timeField.getValue().getText());
                timeBuilder.append(":00Z");
            }
            dateSelectedEvent.setDate(timeBuilder.toString());
            bus.fireEventFromSource(dateSelectedEvent, TimeInputWidget.this);
            TimeInputWidget.super.hide();
        }
    });
    addButton(insertButton);
    formData = new FormData("98%");
    timeContainer = new LayoutContainer(new FormLayout());
    this.addDateAndTimeToContainer(timeContainer, DATE_KEY_VALUE, TIME_KEY_VALUE);
    add(new Label("Please, select the required parameters."));
    add(timeContainer, formData);
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) TimeField(com.extjs.gxt.ui.client.widget.form.TimeField) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) Label(com.extjs.gxt.ui.client.widget.Label) DateField(com.extjs.gxt.ui.client.widget.form.DateField)

Example 5 with TimeField

use of com.extjs.gxt.ui.client.widget.form.TimeField in project geo-platform by geosdi.

the class TimeInputWidget method addDateAndTimeToContainer.

private void addDateAndTimeToContainer(LayoutContainer layoutContainer, String dataLabel, String timeLabel) {
    final DateField dateField = new DateField();
    dateField.setFieldLabel(dataLabel);
    dateField.setData("text", "Enter the date");
    layoutContainer.setData(dataLabel, dateField);
    final TimeField timeField = new TimeField();
    timeField.setFieldLabel(timeLabel);
    timeField.setData("text", "Enter the time");
    layoutContainer.setData(timeLabel, timeField);
    layoutContainer.add(dateField);
    layoutContainer.add(timeField);
}
Also used : TimeField(com.extjs.gxt.ui.client.widget.form.TimeField) DateField(com.extjs.gxt.ui.client.widget.form.DateField)

Aggregations

DateField (com.extjs.gxt.ui.client.widget.form.DateField)6 TimeField (com.extjs.gxt.ui.client.widget.form.TimeField)6 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)4 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)4 Dialog (com.extjs.gxt.ui.client.widget.Dialog)2 Label (com.extjs.gxt.ui.client.widget.Label)2 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)2 Button (com.extjs.gxt.ui.client.widget.button.Button)2 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)2 FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)2 DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)2 Date (java.util.Date)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 Listener (com.extjs.gxt.ui.client.event.Listener)1 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)1 Radio (com.extjs.gxt.ui.client.widget.form.Radio)1 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)1 Validator (com.extjs.gxt.ui.client.widget.form.Validator)1 GeoPlatformWindow (org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow)1