From a7711fc5b3c4eacb5a322675a7edf09c520764e3 Mon Sep 17 00:00:00 2001 From: jcfranco Date: Tue, 5 Feb 2013 18:14:52 -0800 Subject: [PATCH] Defer SingleLineSearch logic to Geocoder component (requires ArcGIS API for Flex 3.2). --- .../singleLineSearch/SingleLineSearch.mxml | 788 ++++-------------- 1 file changed, 148 insertions(+), 640 deletions(-) diff --git a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml index c08c883..f448c82 100644 --- a/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml +++ b/src/com/esri/viewer/components/singleLineSearch/SingleLineSearch.mxml @@ -19,15 +19,16 @@ + xmlns:components="com.esri.ags.components.*"> 0) + { + useProxy = configXML.useproxy == "true"; + } + const configZoomScale:Number = parseFloat(configXML.zoomscale[0]); if (configZoomScale > 0) { @@ -153,89 +110,73 @@ } const configMinScore:Number = parseFloat(configXML.geocoding.minscore[0]); - if (configMinScore > 0) - { - minscore = configMinScore; - } + geocoder.minScore = (configMinScore > 0) ? configMinScore : 40; - searchPrompt = configXML.labels.searchprompt[0] || hostBaseWidget.getDefaultString("searchPrompt"); - noResultsFoundLabel = configXML.labels.noresults[0] || hostBaseWidget.getDefaultString("noResultsFoundLabel"); + geocoder.prompt = configXML.labels.searchprompt[0] || hostBaseWidget.getDefaultString("searchPrompt"); + geocoder.noResultsText = configXML.labels.noresults[0] || hostBaseWidget.getDefaultString("noResultsFoundLabel"); searchResultTitleLabel = configXML.labels.searchresulttitle[0] || hostBaseWidget.getDefaultString("searchResultTitleLabel"); configureResultSymbols(); configureResultGraphic(); - importSearchResultHistory(); - - isGeocodeEnabled = (configXML.geocoding.@enabled[0] != "false"); - if (isGeocodeEnabled) - { - configureLocator(); - } - - isFindEnabled = (configXML.searchlayers.@enabled[0] != "false" && configXML.searchlayers[0] != null); - if (isFindEnabled) - { - configureSearchLayers(); - } + configureLocatorServices(); + configureFindServices(); } } - private function configureLocator():void + private function configureLocatorServices():void { - const url:String = configXML.geocoding.locator[0] || DEFAULT_LOCATOR_URL; - - if (configXML.useproxy.length() > 0) + var isGeocodeEnabled:Boolean = (configXML.geocoding.@enabled[0] != "false"); + if (!isGeocodeEnabled) { - useProxy = configXML.useproxy == "true"; + locatorConfigured = true; + return; } - const locatorService:JSONTask = new JSONTask(); + const url:String = configXML.geocoding.locator[0] || DEFAULT_LOCATOR_URL; + + var locatorService:GeocoderLocatorService = new GeocoderLocatorService(); locatorService.url = url; - locator.url = url; + locatorService.outFields = [ "Ymax", "Ymin", "Xmax", "Xmin" ]; + + const locatorInfoRequest:JSONTask = new JSONTask(); + locatorInfoRequest.url = url; if (useProxy && configData.proxyUrl) { locatorService.proxyURL = configData.proxyUrl; - locator.proxyURL = configData.proxyUrl; + locatorInfoRequest.proxyURL = configData.proxyUrl; } var urlVars:URLVariables = new URLVariables(); urlVars.f = "json"; - locatorService.execute(urlVars, new AsyncResponder(locatorService_resultHandler, locatorService_faultHandler)); + locatorInfoRequest.execute(urlVars, + new AsyncResponder(locatorInfoRequest_resultHandler, + locatorInfoRequest_faultHandler, + locatorService)); } - private function locatorService_resultHandler(addressFieldData:Object, token:Object = null):void + private function locatorInfoRequest_resultHandler(addressFieldData:Object, locatorService:GeocoderLocatorService):void { if (addressFieldData.singleLineAddressField) { - singleAddressFieldName = addressFieldData.singleLineAddressField.name; + locatorService.singleLineAddressFieldName = addressFieldData.singleLineAddressField.name; } else { showError(hostBaseWidget.getDefaultString("singleLineGeocodingNotSupportedError"), SINGLE_LINE_SEARCH); } + geocoder.locatorServices = [ locatorService ]; locatorConfigured = true; invalidateProperties(); } - override protected function commitProperties():void - { - super.commitProperties(); - - if (isGeocodeEnabled && locatorConfigured - || (isFindEnabled && searchLayersConfigured)) - { - configureSearchInput(); - } - } - - private function locatorService_faultHandler(fault:Fault, token:Object = null):void + private function locatorInfoRequest_faultHandler(fault:Fault, locatorService:GeocoderLocatorService):void { const errorMessage:String = hostBaseWidget.getDefaultString("locatorServiceConnectionError", - locator.url, + locatorService.url, ErrorMessageUtil.getKnownErrorCauseMessage(fault), ErrorMessageUtil.makeHTMLSafe(fault.toString())); showError(errorMessage, SINGLE_LINE_SEARCH); @@ -243,24 +184,35 @@ invalidateProperties(); } - private function showError(message:String, title:String = null):void + private function configureFindServices():void { - _hostBaseWidget.showError(message, title); - } + var isFindEnabled:Boolean = + configXML.searchlayers.@enabled[0] != "false" && configXML.searchlayers[0] != null; - private function configureSearchLayers():void - { - if (configXML.searchlayers.length() > 0) + if (isFindEnabled) { - var searchLayer:SearchLayer; - for each (var layerInfo:XML in configXML.searchlayers.searchlayer) + + if (configXML.searchlayers.length() > 0) { - searchLayer = new SearchLayer(); - searchLayer.layerIds = layerInfo.layerids.toString().split(","); - searchLayer.layerURL = layerInfo.url.toString(); - searchLayer.searchFields = layerInfo.searchfields.toString().split(","); + var findService:GeocoderMapService; + var findServices:Array = []; + + for each (var layerInfo:XML in configXML.searchlayers.searchlayer) + { + findService = new GeocoderMapService(); + findService.layerIds = layerInfo.layerids.toString().split(","); + findService.url = layerInfo.url.toString(); + findService.searchFields = layerInfo.searchfields.toString().split(","); - searchLayers.push(searchLayer); + if (useProxy && configData.proxyUrl) + { + findService.proxyURL = configData.proxyUrl; + } + + findServices.push(findService); + } + + geocoder.mapServices = findServices; } } @@ -326,16 +278,13 @@ map.defaultGraphicsLayer.remove(searchResultGraphic); } - private function importSearchResultHistory():void + override protected function commitProperties():void { - try - { - searchResultHistory.importHistory - (searchResultHistoryStorage.data.searchResultHistory as Array); - } - catch (err:Error) + super.commitProperties(); + + if (locatorConfigured && searchLayersConfigured) { - //ignore + configureSearchInput(); } } @@ -344,8 +293,8 @@ const urlSearchTerm:String = getURLSearchTerm(); if (urlSearchTerm) { - searchTerm = urlSearchTerm; - search(); + geocoder.text = urlSearchTerm; + geocoder.search(); } } @@ -354,203 +303,115 @@ return ViewerContainer.urlConfigParams.search; } - private function search():void + //assumes search result SR compatible with map's + private function showSearchResultOnMap(searchResult:GeocoderSearchResult):void { - if (!searchTerm || (!isGeocodeEnabled && !isFindEnabled)) + if (!searchResult) { return; } - currentState = "searching"; + searchResultGraphic.geometry = searchResult.geometry; + searchResultGraphic.symbol = getSymbolForGeometryType(searchResultGraphic.geometry.type); + var resultExtent:Extent = searchResult.extent; - const hasCurrentSearchInProgress:Boolean = totalResultsToProcess > 0; - if (hasCurrentSearchInProgress) - { - cursorManager.removeBusyCursor(); - } + const popUpInfo:PopUpInfo = new PopUpInfo(); + popUpInfo.description = searchResult.label; + popUpInfo.title = searchResultTitleLabel; + popUpInfo.showZoomToButton = false; //hide the zoom to button as map would be zoomed-in - cursorManager.setBusyCursor(); - map.infoWindow.hide(); - totalResultsToProcess = 0; - searchResults.removeAll(); + const infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer); + infoWindowRenderer.properties = { popUpInfo: popUpInfo }; + searchResultGraphic.infoWindowRenderer = infoWindowRenderer; - lastSearchTimestamp = getTimer(); + popUpRenderer.popUpInfo = popUpInfo; + popUpRenderer.graphic = searchResultGraphic; - if (isGeocodeEnabled) + map.defaultGraphicsLayer.remove(searchResultGraphic); + if (searchResultGraphic.symbol) { - totalResultsToProcess++; - - const addressData:Object = {}; - addressData[singleAddressFieldName] = searchTerm; - var locatorParams:AddressToLocationsParameters = new AddressToLocationsParameters(); - locatorParams.address = addressData; - locatorParams.outFields = [ "Ymax", "Ymin", "Xmax", "Xmin" ]; - locatorParams.location = map.extent.center; - locatorParams.distance = calculateExtentRadius(); - - locator.addressToLocations(locatorParams, new AsyncResponder(locator_resultHandler, locator_faultHandler, lastSearchTimestamp)); + map.defaultGraphicsLayer.add(searchResultGraphic); } - if (isFindEnabled) - { - totalResultsToProcess += searchLayers.length; + const resultPoint:MapPoint = getGeometryCenter(searchResultGraphic.geometry); - var searchLayer:SearchLayer; - for (var i1:Number = 0; i1 < searchLayers.length; i1++) - { - searchLayer = searchLayers[i1]; - findTask.url = searchLayer.layerURL; - var findParams:FindParameters = new FindParameters(); - findParams.contains = true; - findParams.layerIds = searchLayer.layerIds; - findParams.searchFields = searchLayer.searchFields; - findParams.searchText = searchTerm; - findParams.outSpatialReference = map.spatialReference; - findParams.returnGeometry = true; - - findTask.execute(findParams, new AsyncResponder(findTask_resultHandler, findTask_faultHandler, lastSearchTimestamp)); - } + if (resultExtent) + { + map.zoomTo(resultExtent); } - } - - private function calculateExtentRadius():Number - { - var radius:Number; - - if (map.spatialReference.wkid == 4326 - || map.spatialReference.isWebMercator()) + else { - const currentExtent:Extent = map.extent; - var diagonal:Polyline = new Polyline([[ new MapPoint(currentExtent.xmin, currentExtent.ymin), - new MapPoint(currentExtent.xmax, currentExtent.ymax)]]); - - if (map.spatialReference.isWebMercator()) + if (searchResultGraphic.geometry.type == Geometry.MAPPOINT) { - diagonal = WebMercatorUtil.webMercatorToGeographic(diagonal) as Polyline; + if (map.scale > zoomScale) + { + map.scale = zoomScale; + } } - const diagonalLength:Number = GeometryUtil.geodesicLengths([ diagonal ], Units.METERS)[0]; - - radius = Math.round(diagonalLength * 0.5); + map.zoomTo(searchResultGraphic.geometry); } - return radius; + infoWindowShow(resultPoint); } - private function locator_resultHandler(results:Array, searchTimestamp:int):void + private function getSymbolForGeometryType(geometryType:String):Symbol { - if (searchTimestamp != lastSearchTimestamp) - { - return; - } + var symbol:Symbol; - for each (var addressCandidate:AddressCandidate in results) + switch (geometryType) { - if (addressCandidate.score >= minscore) + case Geometry.POLYLINE: + { + symbol = resultSimpleLineSymbol; + break; + } + case Geometry.POLYGON: { - searchResults.addItem(addressCandidate); + symbol = resultSimpleFillSymbol; + break; + } + case Geometry.MAPPOINT: + default: + { + symbol = resultSimpleMarkerSymbol; } } - decreaseProcessedResultCount(); - } - - private function decreaseProcessedResultCount():void - { - totalResultsToProcess--; - - if (totalResultsToProcess == 0) - { - showSearchResults(); - } + return symbol; } - private function showSearchResults():void + private function getGeometryCenter(geometry:Geometry):MapPoint { - cursorManager.removeBusyCursor(); + var center:MapPoint; - if (searchResults.length > 1) - { - currentState = "showingSearchResults"; - resultList.selectedIndex = -1; - } - else if (searchResults.length == 1) + if (geometry is MapPoint) { - storeSearchResult(searchResults.getItemAt(0)); - var searchResult:Object = getSearchResult(searchResults.getItemAt(0)); - searchTerm = searchResult.label; - projectToMapSpatialReferenceAndShowResultOnMap(searchResult); + center = geometry as MapPoint; } - else + else if (geometry) { - currentState = "noResults"; + center = geometry.extent.center; } - } - - private function storeSearchResult(searchResult:Object):void - { - searchResultHistory.addItem(searchResult); - exportSearchResultHistory(); - } - private function exportSearchResultHistory():void - { - try - { - searchResultHistoryStorage.data.searchResultHistory = - searchResultHistory.exportHistory(); - searchResultHistoryStorage.flush(); - } - catch (err:Error) - { - //ignore - } + return center; } - private function getSearchResult(searchResult:Object):Object + private function infoWindowShow(point:MapPoint):void { - var result:Object; - - if (searchResult is FindResult) - { - result = {}; - const findResult:FindResult = searchResult as FindResult; - result.label = findResult.value; - result.geometry = findResult.feature.geometry; - result.extent = null; - } - else if (searchResult is AddressCandidate) - { - result = {}; - const addressCandidate:AddressCandidate = searchResult as AddressCandidate; - result.label = addressCandidate.address; - result.geometry = addressCandidate.location; - result.extent = getGeographicResultExtent(addressCandidate); - } - - return result; + map.infoWindow.content = popUpRenderer; + map.infoWindow.contentOwner = popUpRenderer.graphic; + map.infoWindow.show(point); } - private function getGeographicResultExtent(addressCandidate:AddressCandidate):Extent + protected function geocoder_searchCompleteHandler(event:GeocoderEvent):void { - const canCreateResultExtent:Boolean = addressCandidate - && addressCandidate.attributes - && Boolean(addressCandidate.attributes.Xmin) && Boolean(addressCandidate.attributes.Ymin) - && Boolean(addressCandidate.attributes.Xmax) && Boolean(addressCandidate.attributes.Ymax) - && !isNaN(addressCandidate.attributes.Xmin) && !isNaN(addressCandidate.attributes.Ymin) - && !isNaN(addressCandidate.attributes.Xmax) && !isNaN(addressCandidate.attributes.Ymax); - - return canCreateResultExtent ? new Extent(addressCandidate.attributes.Xmin, - addressCandidate.attributes.Ymin, - addressCandidate.attributes.Xmax, - addressCandidate.attributes.Ymax, - new SpatialReference(4326)) : null; + projectToMapSpatialReferenceAndShowResultOnMap(event.searchResult); } - private function projectToMapSpatialReferenceAndShowResultOnMap(searchResult:Object):void + private function projectToMapSpatialReferenceAndShowResultOnMap(searchResult:GeocoderSearchResult):void { var needToProjectGeometryServerSide:Boolean; - if (map.spatialReference.isWebMercator() && searchResult.geometry.spatialReference && searchResult.geometry.spatialReference.wkid == 4326) @@ -569,13 +430,12 @@ } var needToProjectExtentServerSide:Boolean; - if (searchResult.extent) { if (map.spatialReference.isWebMercator() && searchResult.extent.spatialReference.wkid == 4326) { - searchResult.extent = WebMercatorUtil.geographicToWebMercator(searchResult.extent); + searchResult.extent = WebMercatorUtil.geographicToWebMercator(searchResult.extent) as Extent; } else if (map.spatialReference.wkid == 4326 && searchResult.extent.spatialReference @@ -590,7 +450,6 @@ } var previousShowBusyCursorValue:Boolean = GeometryServiceSingleton.instance.showBusyCursor; - if (needToProjectGeometryServerSide) { projectGeometryServerSide(); @@ -609,7 +468,6 @@ var projectionParams:ProjectParameters = new ProjectParameters(); projectionParams.geometries = [ searchResult.geometry ]; projectionParams.outSpatialReference = map.spatialReference; - GeometryServiceSingleton.instance.showBusyCursor = true; GeometryServiceSingleton.instance.project( projectionParams, new AsyncResponder(projectGeometryResultHandler, @@ -619,7 +477,6 @@ function projectGeometryResultHandler(geometry:Array, token:Object = null):void { searchResult.geometry = geometry[0]; - if (needToProjectExtentServerSide) { projectExtentServerSide(); @@ -635,7 +492,6 @@ var projectionParams:ProjectParameters = new ProjectParameters(); projectionParams.geometries = [ searchResult.extent ]; projectionParams.outSpatialReference = map.spatialReference; - GeometryServiceSingleton.instance.showBusyCursor = true; GeometryServiceSingleton.instance.project( projectionParams, new AsyncResponder(projectExtentResultHandler, @@ -651,10 +507,8 @@ function handleProjectionComplete():void { GeometryServiceSingleton.instance.showBusyCursor = previousShowBusyCursorValue; - var resultHasValidGeometry:Boolean = hasValidGeometry(searchResult.geometry); var resultHasExtentAndIsValid:Boolean = searchResult.extent && hasValidGeometry(searchResult.extent); - if (resultHasExtentAndIsValid && resultHasValidGeometry || resultHasValidGeometry) { @@ -676,7 +530,6 @@ private function hasValidGeometry(geometry:Geometry):Boolean { var isValid:Boolean; - if (geometry) { if (geometry.type == Geometry.MAPPOINT) @@ -700,7 +553,6 @@ isValid = isValidPolyline(geometry as Polyline); } } - return isValid; } @@ -717,11 +569,9 @@ private function hasValidMapPoints(points:Array):Boolean { var isValid:Boolean; - if (points && points.length > 0) { isValid = true; - for each (var point:MapPoint in points) { if (!isValidMapPoint(point)) @@ -731,18 +581,15 @@ } } } - return isValid; } private function isValidPolyline(polyline:Polyline):Boolean { var isValid:Boolean; - if (polyline && polyline.paths && polyline.paths.length > 0) { isValid = true; - for each (var path:Array in polyline.paths) { if (!hasValidMapPoints(path)) @@ -752,18 +599,15 @@ } } } - return isValid; } private function isValidPolygon(polygon:Polygon):Boolean { var isValid:Boolean; - if (polygon && polygon.rings && polygon.rings.length > 0) { isValid = true; - for each (var ring:Array in polygon.rings) { if (!hasValidMapPoints(ring)) @@ -773,363 +617,27 @@ } } } - return isValid; } - private function locator_faultHandler(info:Object, searchTimestamp:int):void - { - if (searchTimestamp != lastSearchTimestamp) - { - return; - } - - showError(info.toString(), SINGLE_LINE_SEARCH); - decreaseProcessedResultCount(); - } - - private function findTask_resultHandler(results:Array, searchTimestamp:int):void - { - if (searchTimestamp != lastSearchTimestamp) - { - return; - } - - for each (var findResult:FindResult in results) - { - searchResults.addItem(findResult); - } - - decreaseProcessedResultCount(); - } - - private function findTask_faultHandler(error:Fault, searchTimestamp:int):void - { - if (searchTimestamp != lastSearchTimestamp) - { - return; - } - - decreaseProcessedResultCount(); - } - - private function processSelectedSearchResult():void - { - if (resultList.selectedItem) - { - storeSearchResult(resultList.selectedItem); - var searchResult:Object = getSearchResult(resultList.selectedItem); - searchTerm = searchResult.label; - projectToMapSpatialReferenceAndShowResultOnMap(searchResult); - resetSearchResultSelection(); - } - } - - private function resetSearchResultSelection():void + protected function geocoder_faultHandler(event:FaultEvent):void { - resultList.dataProvider.removeAll(); - currentState = "normal"; + showError(ErrorMessageUtil.buildFaultMessage(event.fault), SINGLE_LINE_SEARCH); } - //assumes search result SR compatible with map's - private function showSearchResultOnMap(searchResult:Object):void - { - if (!searchResult) - { - return; - } - - searchResultGraphic.geometry = searchResult.geometry; - searchResultGraphic.symbol = getSymbolForGeometryType(searchResultGraphic.geometry.type); - var resultExtent:Extent = searchResult.extent; - - const popUpInfo:PopUpInfo = new PopUpInfo(); - popUpInfo.description = searchResult.label; - popUpInfo.title = searchResultTitleLabel; - popUpInfo.showZoomToButton = false; //hide the zoom to button as map would be zoomed-in - - const infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer); - infoWindowRenderer.properties = { popUpInfo: popUpInfo }; - searchResultGraphic.infoWindowRenderer = infoWindowRenderer; - - popUpRenderer.popUpInfo = popUpInfo; - popUpRenderer.graphic = searchResultGraphic; - - map.defaultGraphicsLayer.remove(searchResultGraphic); - if (searchResultGraphic.symbol) - { - map.defaultGraphicsLayer.add(searchResultGraphic); - } - - const resultPoint:MapPoint = getGeometryCenter(searchResultGraphic.geometry); - - if (resultExtent) - { - map.zoomTo(resultExtent); - } - else - { - if (searchResultGraphic.geometry.type == Geometry.MAPPOINT) - { - if (map.scale > zoomScale) - { - map.scale = zoomScale; - } - } - - map.zoomTo(searchResultGraphic.geometry); - } - - infoWindowShow(resultPoint); - } - - private function getSymbolForGeometryType(geometryType:String):Symbol - { - var symbol:Symbol; - - switch (geometryType) - { - case Geometry.POLYLINE: - { - symbol = resultSimpleLineSymbol; - break; - } - case Geometry.POLYGON: - { - symbol = resultSimpleFillSymbol; - break; - } - case Geometry.MAPPOINT: - default: - { - symbol = resultSimpleMarkerSymbol; - } - } - - return symbol; - } - - private function getGeometryCenter(geometry:Geometry):MapPoint - { - var center:MapPoint; - - if (geometry is MapPoint) - { - center = geometry as MapPoint; - } - else if (geometry) - { - center = geometry.extent.center; - } - - return center; - } - - private function infoWindowShow(point:MapPoint):void - { - map.infoWindow.content = popUpRenderer; - map.infoWindow.contentOwner = popUpRenderer.graphic; - map.infoWindow.show(point); - } - - protected function searchInput_focusInHandler(event:FocusEvent):void - { - if (currentState == "normal") - { - if (searchResults.length > 1) - { - currentState = "showingSearchResults"; - resultList.selectedIndex = -1; - } - else - { - processSearchResult(); - } - } - } - - protected function this_focusOutHandler(event:FocusEvent):void - { - if (event.relatedObject == resultList - || event.relatedObject == searchInput) - { - return; - } - - if (currentState != "searching") - { - currentState = "normal"; - } - } - - protected function searchInput_changeHandler(event:TextOperationEvent):void - { - processSearchResult(); - } - - private function processSearchResult():void - { - if (searchResults.length > 0) - { - searchResults.removeAll(); - } - - const searchResultMatches:Array = searchInHistory(searchTerm); - searchResultHistoryList.source = searchResultMatches; - if (searchResultMatches.length > 0) - { - currentState = "showingPreviousSearchResults"; - resultList.selectedIndex = -1; - } - else - { - currentState = "normal"; - } - } - - private function searchInHistory(input:String):Array - { - const matches:Array = []; - - if (input) - { - input = input.toLowerCase(); - - const searchResultItems:Array = searchResultHistory.items; - var searchResult:Object; - for (var i:int = searchResultItems.length - 1; i >= 0; i--) - { - searchResult = searchResultItems[i]; - - if (searchResult is FindResult && !isFindEnabled - || searchResult is AddressCandidate && !isGeocodeEnabled) - { - continue; - } - - if (SearchResultUtil.searchResultToLabel(searchResult).toLowerCase().indexOf(input) != -1) - { - matches.unshift(searchResult); - if (matches.length >= 10) - { - break; - } - } - } - } - - return matches; - } - - protected function searchInput_keyDownHandler(event:KeyboardEvent):void - { - if (event.keyCode == Keyboard.ESCAPE) - { - currentState = "normal"; - } - - if (event.keyCode == Keyboard.DOWN) - { - processDownKey(); - } - - if (event.keyCode == Keyboard.UP) - { - processUpKey(); - } - } - - private function processUpKey():void - { - if (currentState == "showingPreviousSearchResults" - || currentState == "showingSearchResults") - { - resultList.selectedIndex--; - resultList.ensureIndexIsVisible(resultList.selectedIndex); - } - } - - private function processDownKey():void - { - if (currentState == "showingPreviousSearchResults" - || currentState == "showingSearchResults") - { - resultList.selectedIndex++; - resultList.ensureIndexIsVisible(resultList.selectedIndex); - } - } - - protected function resultList_changeHandler(event:IndexChangeEvent):void - { - if (resultList.selectedIndex > -1) - { - processSelectedSearchResult(); - } - } - - protected function searchInput_enterHandler(event:FlexEvent):void + private function showError(message:String, title:String = null):void { - if (resultList.selectedIndex > -1) - { - processSelectedSearchResult(); - } - else - { - search(); - } + _hostBaseWidget.showError(message, title); } ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - +