/*---------------- FILE HEADER --------------------------------------- This file is part of Geoide. Copyright (C) 2005-2006 by: IDgis B.V. http://www.idgis.nl This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: Herman Assink IDgis bv P.O. Box 15 7450 AA Holten The Netherlands E-Mail: herman.assink@idgis.nl * @version 1.4.0 * @author IDgis team * ------------------------------------------------------------------------*/ import mx.controls.TextInput; import mx.utils.Delegate; import nl.idgis.giclient.filterencoding.PropertyIsCompOperation; import nl.idgis.giclient.framework.IDComboBox; import nl.idgis.giclient.query.Operand; class nl.idgis.giclient.query.PropertyIsCompOperand extends Operand { private var valueField : Object = null; private var valueButton : Button = null; function PropertyIsCompOperand() { paint(); } private function paint() { var valueFieldName : String = this._name + "ValueField"; if(operationViewer.queryColumn.getSearchType().toUpperCase() != "TEXTINPUT") { valueField = IDComboBox(attachMovie("IDComboBox", valueFieldName = "Combo", this.getNextHighestDepth(), {_width:100})); valueField.addEventListener("select", Delegate.create(this, onChangeSelectedValue)); valueField.editable = true; } else { valueField = TextInput(attachMovie("TextInput", valueFieldName + "Text", getNextHighestDepth(), {_width:120})); valueField.text = operationViewer.queryColumn.getValueFormat(); valueField.addEventListener("change", Delegate.create(this, onChangeTypedValue)); //TODO: format van de inputtext moet exact opgegeven kunnen worden if (operationViewer.queryColumn.getValueFormat() == "99999") { valueField.restrict = "0-9 , -"; } operandWidth = TextInput(valueField).__width; operationViewer.onResizeOperand(this); } } private function onChangeSelectedValue(eventObject : Object) { var selectedValue : String; // valueField.selectedIndex = 0 is "Alles" of "Selecteer een waarde" if(valueField.selectedIndex != 0) { selectedValue = valueField.selectedItem.data; } else { selectedValue = null; } resetOperationValue(selectedValue); operationViewer.onChangeOperand(); valueField.textField.text = valueField.selectedItem.label; } private function onChangeTypedValue(eventObject : Object) { resetOperationValue(valueField.text); operationViewer.onChangeOperand(); } private function resetOperationValue(value : String) : Void { PropertyIsCompOperation(operationViewer.getOperation()).setLiteral(value); } function reset(values : Array) { PropertyIsCompOperation(operationViewer.getOperation()).setLiteral(null); if(operationViewer.queryColumn.getSearchType().toUpperCase() != "TEXTINPUT") { valueField.dataProvider = values; IDComboBox(valueField).resize(); operandWidth = IDComboBox(valueField).getWidth(); operationViewer.onResizeOperand(this); //zet de default selectie, als er maar een is te kiezen deze gelijk kiezen if(values.length > 2 || values.length == 1) { valueField.selectedIndex = 0; } else { valueField.selectedIndex = 1; onChangeSelectedValue(); } } } }