package fgis.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.gwtopenmaps.openlayers.client.LonLat;
import org.gwtopenmaps.openlayers.client.Map;
import org.gwtopenmaps.openlayers.client.MapOptions;
import org.gwtopenmaps.openlayers.client.MapWidget;
import org.gwtopenmaps.openlayers.client.OpenLayers;
import org.gwtopenmaps.openlayers.client.Projection;
import org.gwtopenmaps.openlayers.client.control.LayerSwitcher;
import org.gwtopenmaps.openlayers.client.control.OverviewMap;
import org.gwtopenmaps.openlayers.client.control.ScaleLine;
import org.gwtopenmaps.openlayers.client.layer.TransitionEffect;
import org.gwtopenmaps.openlayers.client.layer.WMS;
import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
import org.gwtopenmaps.openlayers.client.layer.WMSParams;

public final class FgisEntry
  implements EntryPoint
{
  private static final Logger LOG = Logger.getLogger( FgisEntry.class.getName() );

  public void onModuleLoad()
  {
    OpenLayers.setProxyHost( GWT.getHostPageBaseURL() + "map_proxy?targetURL=" );
    //create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    //causes the mouse popup to display coordinates in this format
    defaultMapOptions.setDisplayProjection( new Projection( "EPSG:4326" ) );
    defaultMapOptions.setNumZoomLevels( 16 );

    //Create a MapWidget
    final MapWidget mapWidget = new MapWidget( "500px", "500px", defaultMapOptions );
    //Create a WMS layer as base layer
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat( "image/png" );
    wmsParams.setLayers( "topp:tasmania_state_boundaries" );
    wmsParams.setStyles( "" );

    //create a WMS layer
    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setUntiled();
    wmsLayerParams.setTransitionEffect( TransitionEffect.RESIZE );

    String wmsUrl = "http://demo.opengeo.org/geoserver/wms";

    final WMS wmsLayer = new WMS( "Basic WMS", wmsUrl, wmsParams,
                                  wmsLayerParams );

    //Add the WMS to the map
    Map map = mapWidget.getMap();
    map.addLayer( wmsLayer );

    //The actual refresh
    final Button butRefresh = new Button( "Refresh WMS", new ClickHandler()
    {
      public void onClick( ClickEvent event )
      {
        final WMSParams wmsParams = new WMSParams();
        wmsParams.setParameter( ( (Double) Math.random() ).toString(), ( (Double) Math.random() ).toString() );
        wmsLayer.mergeNewParams( wmsParams );
        wmsLayer.redraw();
      }
    } );

    //Lets add some default controls to the map
    //+ sign in the upperright corner to display the layer switcher
    map.addControl( new LayerSwitcher() );
    //+ sign in the lowerright to display the overviewmap
    map.addControl( new OverviewMap() );
    //Display the scaleline
    map.addControl( new ScaleLine() );

    //Center and zoom to a location
    map.setCenter( new LonLat( 146.7, -41.8 ), 6 );

    final Panel panel = new VerticalPanel();


    panel.add( mapWidget );
    panel.add( butRefresh );

    RootPanel.get().add( panel );

    //force the map to fall behind popups
    mapWidget.getElement().getFirstChildElement().getStyle().setZIndex( 0 );

  }
}

@@ -208,50 +208,8 @@
 er;%0A
-import com.google.gwt.user.client.Window;%0A
 impo
@@ -345,58 +345,8 @@
 el;%0A
-import com.google.gwt.user.client.ui.SimplePanel;%0A
 impo
@@ -397,40 +397,8 @@
 el;%0A
-import java.util.logging.Level;%0A
 impo
@@ -1440,16 +1440,22 @@
 ons%0A    
+final 
 MapOptio
@@ -1840,16 +1840,22 @@
 yer%0A    
+final 
 WMSParam
@@ -2047,16 +2047,22 @@
 yer%0A    
+final 
 WMSOptio
@@ -2204,16 +2204,22 @@
 );%0A%0A    
+final 
 String w
@@ -2267,17 +2267,16 @@
 r/wms%22;%0A
-%0A
     fina
@@ -2336,42 +2336,8 @@
 ams,
-%0A                                 
  wms
@@ -2385,16 +2385,22 @@
 map%0A    
+final 
 Map map 
@@ -2585,16 +2585,22 @@
 onClick(
+ final
  ClickEv
@@ -2948,16 +2948,17 @@
 he upper
+ 
 right co
@@ -3060,16 +3060,17 @@
 he lower
+ 
 right to
@@ -3090,16 +3090,17 @@
 overview
+ 
 map%0A    
@@ -3159,16 +3159,17 @@
 he scale
+ 
 line%0A   
@@ -3249,22 +3249,29 @@
     
-map.setC
+final LonLat c
 enter
-(
+ =
  new
@@ -3297,11 +3297,75 @@
 .8 )
-, 6
+;%0A    final int zoomLevel = 6;%0A    map.setCenter( center, zoomLevel
  );%0A
@@ -3411,17 +3411,16 @@
 nel();%0A%0A
-%0A
     pane
@@ -3623,15 +3623,14 @@
 x( 0 );%0A
-%0A
   %7D%0A%7D%0A

Add some final qualifiers