/*---------------- 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.DataGrid; import mx.utils.Delegate; import nl.idgis.giclient.filterencoding.OperationDefines; import nl.idgis.giclient.filterencoding.PropertyIsCompOperation; import nl.idgis.giclient.filterencoding.PropertyIsInOperation; import nl.idgis.giclient.framework.ModalFrameFactory; import nl.idgis.giclient.query.Operand; import nl.idgis.giclient.util.Strings; class nl.idgis.giclient.query.PropertyIsInOperand extends Operand { private var pickerValues:Array; private var resultGrid:DataGrid = null; function PropertyIsInOperand() { operandHeight = 75; paint(); } private function paint(){ attachMovie("Button", "rowValuePickerButton", this.getNextHighestDepth(), {_width:18,_x:0, _y:0 , label: "..."}); this["rowValuePickerButton"].addEventListener("click", Delegate.create(this, onClickRowValuePickerButton)); resultGrid = DataGrid(this.attachMovie("DataGrid", "result_mc", this.getNextHighestDepth(), {_x:20,_y: 0,_visible:false})); resultGrid.setSize(160,65); operandWidth = 180; operationViewer.onResizeOperand(this); } private function onClickRowValuePickerButton(eventObject:Object):Void{ openValuePicker(); } private function openValuePicker():Void{ var scrl:Boolean = false; var initObject:Object = new Object(); var paneHeight:Number = values.length * 20 + 80; if (paneHeight > 600){ paneHeight = 600; scrl = true; } initObject = {scrollContent: "lib://ValuePicker" , paneTitle: // "Waarden kiezer", (Strings.getFile("map").getString("valueschooser")), resizable: false, hasShader: false, doorzichtig:true, _x:300, _y:300, isScrolling:scrl}; initObject["contentProperties"] = new Object(); initObject["contentProperties"]["returnObject"] = this; initObject["contentProperties"]["values"] = pickerValues; ModalFrameFactory.makeFrame(initObject,300,paneHeight); } private function closeValuePicker():Void{ ModalFrameFactory.removeFrame(); } function reset(values:Array):Void{ this.values = values; pickerValues = new Array(); //de eerste doet niet mee is "-- Selecteer een waarde --" oid for (var i:Number = 1; i < this.values.length; i++) { pickerValues.push([this.values[i],false]); } resultGrid.removeAll(); resultGrid._visible = false; PropertyIsInOperation(operationViewer.getOperation()).setInArgs(null); } function setValues(returnedValues:Array):Void{ closeValuePicker(); resetOperationArgs(returnedValues); } private function resetOperationArgs(returnedValues:Array):Void{ var compOperations:Array = new Array(); resultGrid.removeAll(); resultGrid._visible = false; var operatorId:Number = operationViewer.getOperator(); var ftPropertyName:String = operationViewer.queryColumn.getFTQueryField(); var operandPropertyName:String = operationViewer.queryColumn.getOperandValueField(); for (var i:Number = 0; i < returnedValues.length; i++) { if(returnedValues[i][1]== true){ var compOperation:PropertyIsCompOperation = new PropertyIsCompOperation(OperationDefines.PROPERTYISEQUALTO, ftPropertyName, operandPropertyName, returnedValues[i][0].data); compOperations.push(compOperation); var item:Object = {gekozen_waarden:returnedValues[i][0].label}; resultGrid.addItem(item); resultGrid._visible = true; } } if(compOperations.length == 0) { PropertyIsInOperation(operationViewer.getOperation()).setInArgs(null); }else { PropertyIsInOperation(operationViewer.getOperation()).setInArgs(compOperations); } operationViewer.onChangeOperand(); } }