private void sendTextToServer ( ) { statusLabel . setText ( "" ) ; conceptList . clear ( ) ; // don't do anything if we have no text final String text = mainTextArea . getText ( ) ; if ( text . length ( ) < 1 ) { statusLabel . setText ( messages . pleaseEnterTextLabel ( ) ) ; return ; } // disable interaction while we wait for the response glassPanel . setPositionAndShow ( ) ; // build up the AnalysisRequest JSON object // start with any options final JSONArray options = new JSONArray ( ) ; setSemanticTypesOption ( types , options ) ; // defaults options . set ( options . size ( ) , new JSONString ( "word_sense_disambiguation" ) ) ; options . set ( options . size ( ) , new JSONString ( "composite_phrases 8" ) ) ; options . set ( options . size ( ) , new JSONString ( "no_derivational_variants" ) ) ; options . set ( options . size ( ) , new JSONString ( "strict_model" ) ) ; options . set ( options . size ( ) , new JSONString ( "ignore_word_order" ) ) ; options . set ( options . size ( ) , new JSONString ( "allow_large_n" ) ) ; options . set ( options . size ( ) , new JSONString ( "restrict_to_sources SNOMEDCT_US" ) ) ; final JSONObject analysisRequest = new JSONObject ( ) ; analysisRequest . put ( "text" , new JSONString ( text ) ) ; analysisRequest . put ( "options" , options ) ; // send the input to the server final RequestBuilder builder = new RequestBuilder ( RequestBuilder . POST , webserviceUrl ) ; builder . setHeader ( "Content-Type" , MediaType . APPLICATION_JSON ) ; builder . setRequestData ( analysisRequest . toString ( ) ) ; // create the async callback builder . setCallback ( new SnomedRequestCallback ( conceptList , statusLabel , glassPanel , typeCodeToDescription ) ) ; // send the request try { builder . send ( ) ; } catch ( final RequestException e ) { statusLabel . setText ( messages . problemPerformingAnalysisLabel ( ) ) ; GWT . log ( "There was a problem performing the analysis: " + e . getMessage ( ) , e ) ; glassPanel . hide ( ) ; } }
send the text from the mainTextArea to the server and accept an async response