/*---------------- 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 nl.idgis.giclient.filterencoding.AbstractOperation; import nl.idgis.giclient.filterencoding.ComplexFilter; import nl.idgis.giclient.filterencoding.OperationDefines; import nl.idgis.giclient.filterencoding.PropertyIsInOperation; import nl.idgis.giclient.query.Operand; import nl.idgis.giclient.query.PropertyIsBetweenOperand; import nl.idgis.giclient.query.PropertyIsCompOperand; import nl.idgis.giclient.query.PropertyIsInOperand; import nl.idgis.giclient.query.QueryAspectViewer; import nl.idgis.giclient.query.QueryColumn; import nl.idgis.giclient.Ruler; import nl.idgis.giclient.io.XMLResponse; import nl.idgis.giclient.io.XMLResponseListener; import nl.idgis.giclient.webserviceconnector.QueryConnector; import nl.idgis.giclient.util.Strings; class nl.idgis.giclient.query.OperationViewer extends MovieClip implements XMLResponseListener { var queryColumn:QueryColumn; var queryAspectViewer:QueryAspectViewer; var propColumnWidth:Number; var operatorWidth:Number; var textFormat:TextFormat; var ruler:Ruler; private var propertyField:MovieClip = null; private var operator:Number; private var operation:AbstractOperation=null; private var operand:Operand = null; private var filter:ComplexFilter = null; private var operandValues:Array = new Array(); private var viewerWidth:Number = null; private var viewerHeight:Number = null; //dummy variables to force compilation by MTASC private var propertyIsBetweenOperand:PropertyIsBetweenOperand = null; private var propertyIsCompOperand:PropertyIsCompOperand = null; private var propertyIsInOperand:PropertyIsInOperand = null; //private var = null; function OperationViewer(){ } function getViewerHeight():Number{ return viewerHeight; } function getViewerWidth():Number{ return viewerWidth; } function getOperand():Operand{ return operand; } function getOperator():Number{ return operator; } function getOperation():AbstractOperation{ return operation; } private function resetOperand():Void{ var classType:String = OperationDefines.getClassTypeById(operator); var uiClassName:String = classType + "Operand"; var operandName:String = queryAspectViewer.queryAspect.getName() + queryColumn.getName() + classType; //TODO: eventueel alleen bij verandering van type operand de operand verwijderen. if (this[operandName] == null){ operand = Operand(this.attachMovie(uiClassName,operandName, 3, {_x:propColumnWidth + operatorWidth + 30, _y:0, textFormat:this.textFormat, operationViewer:this})); if(uiClassName=="PropertyIsInOperand"){ operand._x = propColumnWidth + 70; } onResizeOperand(operand); } } function setOperandValues():Void { if(queryColumn.getSearchType().toUpperCase() == "COMBOBOX" || operation instanceof PropertyIsInOperation) { operandValues = new Array(); operandValues.push({label: Strings.getFile("Query").getString("Searching"), data:null}); //alvast resetten, het server request kan lang duren //trace("setOperandValues bezig " + operandValues.length); operand.reset(operandValues); queryAspectViewer.attachMovie("EventBlocker", "blocker", this.getNextHighestDepth(), {_width:this._width, _height:this._height, _alpha:0}); operandValues = new Array(); operandValues.push({label: Strings.getFile("Query").getString("Select"), data:null}); //operandValues.push({label:"-- aussuchen --", data:null}); // serverRequest=http://portal.prvlimburg.nl/risicokaart_prof/giservlet?request=GetDistinctColumnValues&asp=Gemeente&col=Gemeente&valueField=app:naam&labelField=app:naam&layerName=Gemeentegrenzen /* // JM: this block was moved to QueryConnector.getItem() (GIConnector/WFSConnector) var serverRequest:String = "request=GetDistinctColumnValues&asp=" + queryAspectViewer.queryAspect.getName() + "&col=" + queryColumn.getName() + "&labelField=" + queryColumn.getOperandLabelField() + "&valueField=" + queryColumn.getOperandValueField(); var layerName:String = queryAspectViewer.queryAspect.getLayerName(); if(queryColumn.getOperandValueFT() == null) { serverRequest += "&layerName=" + layerName; } else { serverRequest += "&valueFT=" + queryColumn.getOperandValueFT(); } filter = queryAspectViewer.getFilter(); if(filter == null) { var xmlResponse:XMLResponse = new XMLResponse(this, serverRequest); //xmlResponse.setRuler(ruler); //xmlResponse.setPath(GILayer(layer).getServerURL()); xmlResponse.setPath(queryAspectViewer.queryAspect.getServerURL()); xmlResponse.load(); } else { var xml:XML = null; xml = filter.toXML("operandFiltering"); xml.docTypeDecl = ""; //var xmlServer:XMLServer = ruler.getGIClientConfig().getXMLServer(); var xmlServer:XMLServer = new XMLServer(queryAspectViewer.queryAspect.getServerURL()); xmlServer.postAndLoad(xml, this, serverRequest, null); } */ var connector:QueryConnector = queryAspectViewer.queryAspect.getConnector(); connector.getItem( this, queryAspectViewer ); } } function onResizeOperand(operand:Operand):Void{ viewerWidth = operand.getOperandWidth() + propColumnWidth + 30; viewerHeight = operand.getOperandHeight(); queryAspectViewer.onResizeOperationViewer(this); } function onChangeOperand():Void{ queryAspectViewer.onChangeOperand(this); } // JM: moved to QueryResponse.onLoadXMLResponse function onLoadXMLResponse(xmlResponse:XMLResponse):Void { // var rootNode:XMLNode = xmlResponse.firstChild; // if (rootNode.nodeName == "OperandValues") { // var valueNodes:Array = XMLTools.getChildNodes("Value", rootNode); // for (var j:Number = 0; j < valueNodes.length; j++) { // var dataValue:String = XMLTools.getStringValue("Data", valueNodes[j]); // var labelValue:String = XMLTools.getStringValue("Label", valueNodes[j]); // if(dataValue!="null" && labelValue!="null"){ // operandValues.push({label:labelValue,data:dataValue}); // } // } // operand.reset(operandValues); // queryAspectViewer["blocker"].removeMovieClip(); // } } function setItems(array:Array):Void { for (var i:Number = 0; i < array.length; i++) { //trace(array[i]["label"] + " --- " + array[i]["data"]); operandValues.push(array[i]); } operand.reset(operandValues); queryAspectViewer["blocker"].removeMovieClip(); } function resetOperandValues():Void{ operandValues = new Array(); operandValues.push({label: "", data:null}); operand.reset(operandValues); } function toString():String { var s:String = new String(); s = "OPERATION VIEWER\n"; s += " queryColumn.name = " + queryColumn.getName() + "\n"; s += " queryColumn.ftQueryField = " + queryColumn.getFTQueryField() + "\n"; s += " operation = " + operation.toString() + "\n"; s += " filter = " + filter.toXML().toString() + "\n"; return s; } }