Search in sources :

Example 1 with GeoPlatformWindow

use of org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow 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 2 with GeoPlatformWindow

use of org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow in project geo-platform by geosdi.

the class BBOXCQLButton method initialize.

@Override
protected void initialize() {
    formData = new FormData("98%");
    final CQLLayerAttributesComboBox attributesComboBox = new CQLLayerAttributesComboBox(this.treePanel);
    attributesComboBox.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_attributeComboBoxLabelText());
    this.minXField.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_minXLabelText());
    this.maxXField.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_maxXLabelText());
    this.minYField.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_minYLabelText());
    this.maxYField.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_maxYLabelText());
    final Button insertButton = new Button(ButtonsConstants.INSTANCE.insertText(), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent be) {
            String theGeom = attributesComboBox.getValue().get(GPAttributeKey.ATTRIBUTE_VALUE.toString()).toString();
            BBOXCQLButton.super.insertTextIntoFilterArea("BBOX(" + theGeom + ", " + minXField.getValue() + ", " + maxXField.getValue() + ", " + minYField.getValue() + ", " + maxYField.getValue() + ")");
            window.hide();
        }
    });
    super.window = new GeoPlatformWindow(true) {

        @Override
        public void addComponent() {
            add(new Label(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_windowInsertParametersLabelText()));
            add(attributesComboBox, formData);
            add(minXField, formData);
            add(minYField, formData);
            add(maxXField, formData);
            add(maxYField, formData);
            add(new Label(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_windowResultLabelText()));
            insertButton.disable();
            addButton(insertButton);
        }

        @Override
        public void initSize() {
            super.setSize("300", "280");
        }

        @Override
        public void setWindowProperties() {
            super.setHeadingHtml(LayerFiltersModuleConstants.INSTANCE.BBOXCQLButton_windowHeadingText());
            super.setLayout(new FormLayout());
        }
    };
    final Listener listener = new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            String theGeomValue = attributesComboBox.getValue().get(GPAttributeKey.ATTRIBUTE_VALUE.toString()).toString();
            Number minXValue = minXField.getValue();
            Number maxXValue = maxXField.getValue();
            Number maxYValue = maxYField.getValue();
            Number minYValue = minYField.getValue();
            if (minXValue == null || minXValue.toString().isEmpty() || maxXValue == null || maxXValue.toString().isEmpty() || maxYValue == null || maxYValue.toString().isEmpty() || minYValue == null || minYValue.toString().isEmpty() || theGeomValue == null || theGeomValue.isEmpty()) {
                insertButton.disable();
            } else {
                insertButton.enable();
            }
        }
    };
    minXField.addListener(Events.OnKeyUp, listener);
    maxXField.addListener(Events.OnKeyUp, listener);
    maxYField.addListener(Events.OnKeyUp, listener);
    minYField.addListener(Events.OnKeyUp, listener);
    attributesComboBox.addSelectionChangedListener(new SelectionChangedListener<GPLayerAttributes>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GPLayerAttributes> se) {
            listener.handleEvent(se);
        }
    });
    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) SelectionChangedListener(com.extjs.gxt.ui.client.event.SelectionChangedListener) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener) GPLayerAttributes(org.geosdi.geoplatform.gui.model.tree.GPLayerAttributes) Label(com.extjs.gxt.ui.client.widget.Label) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) GeoPlatformWindow(org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) CQLLayerAttributesComboBox(org.geosdi.geoplatform.gui.client.widget.cql.combobox.CQLLayerAttributesComboBox)

Example 3 with GeoPlatformWindow

use of org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow in project geo-platform by geosdi.

the class BetweenCQLButton method initialize.

@Override
protected void initialize() {
    this.formData = new FormData("98%");
    this.comparisonParameter.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BetweenCQLButton_comparisonLabelText());
    this.firstParameter.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BetweenCQLButton_firstParameterLabelText());
    this.secondParameter.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.BetweenCQLButton_secondParameterLabelText());
    final Button insertButton = new Button(ButtonsConstants.INSTANCE.insertText(), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent be) {
            BetweenCQLButton.super.insertTextIntoFilterArea(comparisonParameter.getValue() + " BETWEEN " + firstParameter.getValue() + " AND " + secondParameter.getValue());
            window.hide();
        }
    });
    super.window = new GeoPlatformWindow(true) {

        @Override
        public void addComponent() {
            add(new Label(LayerFiltersModuleConstants.INSTANCE.BetweenCQLButton_windowInsertLabelText()));
            add(comparisonParameter, formData);
            add(firstParameter, formData);
            add(secondParameter, formData);
            add(new Label(LayerFiltersModuleConstants.INSTANCE.BetweenCQLButton_windowResultLabelText()));
            insertButton.disable();
            addButton(insertButton);
        }

        @Override
        public void initSize() {
            super.setSize("300", "220");
        }

        @Override
        public void setWindowProperties() {
            super.setHeadingHtml(LayerFiltersModuleConstants.INSTANCE.BetweenCQLButton_windowHeadingText());
            super.setLayout(new FormLayout());
        }
    };
    Listener listener = new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            String comparisonValue = comparisonParameter.getValue();
            String firstValue = firstParameter.getValue();
            String secondValue = secondParameter.getValue();
            if (comparisonValue == null || comparisonValue.trim().equals("") || firstValue == null || firstValue.trim().equals("") || secondValue == null || secondValue.trim().equals("")) {
                insertButton.disable();
            } else {
                insertButton.enable();
            }
        }
    };
    comparisonParameter.addListener(Events.OnKeyUp, listener);
    firstParameter.addListener(Events.OnKeyUp, listener);
    secondParameter.addListener(Events.OnKeyUp, listener);
    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) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) Label(com.extjs.gxt.ui.client.widget.Label) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) GeoPlatformWindow(org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow)

Example 4 with GeoPlatformWindow

use of org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow in project geo-platform by geosdi.

the class INCQLButton method initialize.

@Override
protected void initialize() {
    formData = new FormData("98%");
    final CQLLayerAttributesComboBox attributesComboBox = new CQLLayerAttributesComboBox(this.treePanel);
    attributesComboBox.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.INCQLButton_attributeLabelText());
    this.parameter1.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.INCQLButton_parameter1LabelText());
    this.parameter2.setFieldLabel(LayerFiltersModuleConstants.INSTANCE.INCQLButton_parameter2LabelText());
    this.parameterPanel.setHeaderVisible(Boolean.FALSE);
    this.parameterPanel.add(parameter1, formData);
    this.parameterPanel.add(parameter2, formData);
    this.fieldList.add(parameter1);
    this.fieldList.add(parameter2);
    this.insertButton = new Button(ButtonsConstants.INSTANCE.insertText(), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent be) {
            String attribute = null;
            if (attributesComboBox.getValue() != null) {
                attribute = attributesComboBox.getValue().get(GPAttributeKey.ATTRIBUTE_VALUE.toString()).toString();
            }
            attribute = attribute != null ? attribute + " " : "";
            StringBuilder stringToInsert = new StringBuilder(attribute);
            stringToInsert.append("IN(");
            boolean isFirstIteration = true;
            for (GPSecureStringTextField textField : fieldList) {
                String parameterValue = textField.getValue();
                if (isFirstIteration) {
                    stringToInsert.append(parameterValue);
                    isFirstIteration = false;
                } else {
                    stringToInsert.append(", ");
                    stringToInsert.append(parameterValue);
                }
            }
            stringToInsert.append(")");
            INCQLButton.super.insertTextIntoFilterArea(stringToInsert.toString());
            window.hide();
        }
    });
    super.window = new GeoPlatformWindow(true) {

        @Override
        public void addComponent() {
            add(new Label(LayerFiltersModuleConstants.INSTANCE.INCQLButton_windowResultLabelText()));
            add(attributesComboBox, formData);
            add(parameterPanel, formData);
            Button addExpressionButton = new Button(LayerFiltersModuleConstants.INSTANCE.INCQLButton_windowAddParameterButtonText());
            addExpressionButton.setIcon(AbstractImagePrototype.create(BasicWidgetResources.ICONS.done()));
            addExpressionButton.setToolTip(LayerFiltersModuleConstants.INSTANCE.INCQLButton_windowExpressionTooltipText());
            addExpressionButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @Override
                public void componentSelected(ButtonEvent ce) {
                    INCQLButton.this.addParameterFieldRow();
                }
            });
            add(addExpressionButton);
            add(new Label(LayerFiltersModuleConstants.INSTANCE.INCQLButton_windowResultLabelText()));
            insertButton.disable();
            addButton(insertButton);
        }

        @Override
        public void initSize() {
            super.setSize("370", "350");
        }

        @Override
        public void setWindowProperties() {
            super.setHeadingHtml(LayerFiltersModuleConstants.INSTANCE.INCQLButton_windowHeadingText());
            super.setLayout(new FormLayout());
        }
    };
    this.keyUplistener = new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            for (GPSecureStringTextField textField : fieldList) {
                String parameterValue = textField.getValue();
                if (parameterValue == null || parameterValue.isEmpty()) {
                    insertButton.disable();
                    return;
                }
            }
            insertButton.enable();
        }
    };
    parameter1.addListener(Events.OnKeyUp, keyUplistener);
    parameter2.addListener(Events.OnKeyUp, keyUplistener);
    attributesComboBox.addSelectionChangedListener(new SelectionChangedListener<GPLayerAttributes>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GPLayerAttributes> se) {
            keyUplistener.handleEvent(se);
        }
    });
    super.initialized = Boolean.TRUE;
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) GPSecureStringTextField(org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField) GPLayerAttributes(org.geosdi.geoplatform.gui.model.tree.GPLayerAttributes) Label(com.extjs.gxt.ui.client.widget.Label) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) GeoPlatformWindow(org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) CQLLayerAttributesComboBox(org.geosdi.geoplatform.gui.client.widget.cql.combobox.CQLLayerAttributesComboBox) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener)

Aggregations

ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)4 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)4 Label (com.extjs.gxt.ui.client.widget.Label)4 Button (com.extjs.gxt.ui.client.widget.button.Button)4 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)4 FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)4 GeoPlatformWindow (org.geosdi.geoplatform.gui.client.widget.GeoPlatformWindow)4 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)3 Listener (com.extjs.gxt.ui.client.event.Listener)3 CQLLayerAttributesComboBox (org.geosdi.geoplatform.gui.client.widget.cql.combobox.CQLLayerAttributesComboBox)2 GPLayerAttributes (org.geosdi.geoplatform.gui.model.tree.GPLayerAttributes)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 SelectionChangedListener (com.extjs.gxt.ui.client.event.SelectionChangedListener)1 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)1 DateField (com.extjs.gxt.ui.client.widget.form.DateField)1 Radio (com.extjs.gxt.ui.client.widget.form.Radio)1 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)1 TimeField (com.extjs.gxt.ui.client.widget.form.TimeField)1 GPSecureStringTextField (org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField)1