Index: gs3-extensions/atlas-src/trunk/src/org/greenstone/GS3MapLibrary.gwt.xml
===================================================================
--- gs3-extensions/atlas-src/trunk/src/org/greenstone/GS3MapLibrary.gwt.xml (revision 22278)
+++ (revision )
@@ -1,10 +1,0 @@
-
-
-
-
-
-
-
-
-
-
Index: gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/GS3MapLibrary.gwt.xml
===================================================================
--- gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/GS3MapLibrary.gwt.xml (revision 23906)
+++ gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/GS3MapLibrary.gwt.xml (revision 23906)
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/FindPlaceService.java
===================================================================
--- gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/FindPlaceService.java (revision 23906)
+++ gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/FindPlaceService.java (revision 23906)
@@ -0,0 +1,21 @@
+package org.greenstone.client;
+
+import java.util.ArrayList;
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+@RemoteServiceRelativePath("findPlace")
+public interface FindPlaceService extends RemoteService
+{
+ Boolean isGazetteerLoaded();
+ Boolean findPlacesInText(String text, String html);
+ ArrayList> findPlacesInMultipleTexts(String[] texts);
+ Boolean loadGazetteer();
+ ArrayList getPlaces(double maxScore, double minScore, long minPopulation, boolean locality, boolean region, boolean country, int numberOfPlacesToGet);
+ Boolean adjustScoringParams(double penalty, double parentBonus, double indirectReferencePercent);
+ String getMarkedUpText();
+ ArrayList updateGazetteer(int start, int end);
+ Boolean addToDatabase(Place p, float lat, float lng);
+ ArrayList spatialSearch(ArrayList points);
+ Place getPlaceById(long id);
+}
Index: gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/FindPlaceServiceAsync.java
===================================================================
--- gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/FindPlaceServiceAsync.java (revision 23906)
+++ gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/FindPlaceServiceAsync.java (revision 23906)
@@ -0,0 +1,20 @@
+package org.greenstone.client;
+
+import java.util.ArrayList;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+public interface FindPlaceServiceAsync
+{
+ void getMarkedUpText(AsyncCallback callback);
+ void isGazetteerLoaded(AsyncCallback callback);
+ void findPlacesInText(String text, String html, AsyncCallback callback);
+ void loadGazetteer(AsyncCallback callback);
+ void getPlaces(double maxScore, double minScore, long minPopulation, boolean locality, boolean region, boolean country, int numberOfPlacesToGet, AsyncCallback> callback);
+ void adjustScoringParams(double penalty, double parentBonus, double indirectReferencePercent, AsyncCallback callback);
+ void findPlacesInMultipleTexts(String[] texts, AsyncCallback>> callback);
+ void updateGazetteer(int start, int end, AsyncCallback> callback);
+ void addToDatabase(Place p, float lat, float lng, AsyncCallback callback);
+ void spatialSearch(ArrayList points, AsyncCallback> callback);
+ void getPlaceById(long id, AsyncCallback callback);
+}
Index: gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/GS3MapLibrary.java
===================================================================
--- gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/GS3MapLibrary.java (revision 23906)
+++ gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/GS3MapLibrary.java (revision 23906)
@@ -0,0 +1,2939 @@
+package org.greenstone.client;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.JsArray;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.MouseMoveEvent;
+import com.google.gwt.event.dom.client.MouseMoveHandler;
+import com.google.gwt.event.dom.client.MouseOutEvent;
+import com.google.gwt.event.dom.client.MouseOutHandler;
+import com.google.gwt.event.dom.client.MouseOverEvent;
+import com.google.gwt.event.dom.client.MouseOverHandler;
+import com.google.gwt.event.dom.client.MouseUpEvent;
+import com.google.gwt.event.dom.client.MouseUpHandler;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.maps.client.InfoWindow;
+import com.google.gwt.maps.client.InfoWindowContent;
+import com.google.gwt.maps.client.MapWidget;
+import com.google.gwt.maps.client.control.ControlAnchor;
+import com.google.gwt.maps.client.control.ControlPosition;
+import com.google.gwt.maps.client.control.LargeMapControl;
+import com.google.gwt.maps.client.control.MapTypeControl;
+import com.google.gwt.maps.client.control.Control.CustomControl;
+import com.google.gwt.maps.client.event.MapClickHandler;
+import com.google.gwt.maps.client.event.MapMoveHandler;
+import com.google.gwt.maps.client.event.PolygonClickHandler;
+import com.google.gwt.maps.client.geocode.Geocoder;
+import com.google.gwt.maps.client.geocode.LatLngCallback;
+import com.google.gwt.maps.client.geom.LatLng;
+import com.google.gwt.maps.client.overlay.Marker;
+import com.google.gwt.maps.client.overlay.MarkerOptions;
+import com.google.gwt.maps.client.overlay.Polygon;
+import com.google.gwt.maps.client.overlay.Polyline;
+import com.google.gwt.maps.client.overlay.PolylineOptions;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.FormPanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Hidden;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.xml.client.NamedNodeMap;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.FormElement;
+import com.google.gwt.dom.client.InputElement;
+import com.google.gwt.dom.client.NativeEvent;
+import com.google.gwt.dom.client.Node;
+import com.google.gwt.dom.client.NodeCollection;
+import com.google.gwt.dom.client.NodeList;
+import com.google.gwt.dom.client.OptionElement;
+import com.google.gwt.dom.client.SelectElement;
+import com.google.gwt.dom.client.TextAreaElement;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+public class GS3MapLibrary implements EntryPoint
+{
+ protected MapWidget _map;
+
+ protected VerticalPanel _containerPanel = new VerticalPanel();
+ protected VerticalPanel _scoreAdjustPanel = new VerticalPanel();
+ protected VerticalPanel _headerDiv = new VerticalPanel();
+ protected HorizontalPanel _viewPanel = new HorizontalPanel();
+
+ protected StatusBar _statusBar = null;
+
+ protected HTML _gsPanel = new HTML();
+ protected HTML _columnViewBox = new HTML();
+
+ protected HorizontalPanel _contentDiv = new HorizontalPanel();
+ protected HorizontalPanel _footerDiv = new HorizontalPanel();
+
+ protected Menu _currentDocumentMenu = null;
+ protected Menu _lastCreatedPlaceMenu = null;
+
+ protected FlowPanel _radioPanel = new FlowPanel();
+ protected FlowPanel _checkBoxPanel = new FlowPanel();
+
+ protected Label _loadingBox = new Label("");
+ protected Label _mapLoadingLabel = new Label("Loading map content");
+
+ protected ListBox _textViewSelector = new ListBox();
+
+ protected Button _geoQueryButton = new Button("Specify Search Square");
+
+ protected Timer _loadingTimer = null;
+ protected Timer _resizeCheckTimer = null;
+ protected Timer _scrollCheckTimer = null;
+ protected Timer _placeMouseOverTimer = null;
+ protected Timer _documentMouseOverTimer = null;
+ protected Timer _menuOverTimer = null;
+ protected Timer _menuOutTimer = null;
+
+ protected Geocoder _geocoder = null;
+
+ protected static FindPlaceServiceAsync _findPlaceService = GWT.create(FindPlaceService.class);
+
+ protected ArrayList _currentPlaces = null;
+ protected ArrayList _highlightedPlaces = new ArrayList();
+ protected ArrayList _highlightedTextPlaces = new ArrayList();
+ protected ArrayList _visiblePlaceSets = new ArrayList();
+ protected ArrayList _areaPoints = new ArrayList();
+ protected ArrayList _removedPlaces = new ArrayList();
+
+ protected ArrayList> _currentMultiPlaces = null;
+
+ protected HashMap _chosenPlaces = new HashMap();
+
+ protected HandlerRegistration _fishEyeHandlerReg = null;
+ protected HandlerRegistration _columnViewHandlerReg = null;
+
+ protected MapMoveHandler _mapMoveHandler = null;
+ protected MapClickHandler _spatialSearchClickHandler = null;
+ protected SpatialSearchControls _searchControls = null;
+
+ protected final int _MAXVISIBLEMARKERS = 500;
+ protected int _currentZoomLevel = 2;
+ protected int _loadingCount = 0;
+ protected int _currentBrowserPixelWidth = 0;
+ protected int _currentBrowserPixelHeight = 0;
+ protected int _currentScrollTopValue = 0;
+
+ protected boolean _updatingMap = false;
+ protected boolean _gazetteerLoaded = false;
+ protected boolean _redraw = false;
+ protected boolean _resize = false;
+ protected boolean _mapVisible = false;
+ protected boolean _gsVisible = true;
+ protected boolean _frameLoaded = false;
+ protected boolean _initialised = false;
+ protected boolean _showAllPlaces = false;
+ protected boolean _mouseEventPause = false;
+ protected boolean _mapMoveHandlerOn = true;
+ protected boolean _searchResultsPage = false;
+
+ protected String _selectedPlaceName = "";
+ protected String _currentCollection = "";
+ protected String _currentURL = "";
+ protected final String _GREENSTONEURL = "http://taniwha.resnet.scms.waikato.ac.nz:8080/greenstone3";
+ //protected final String _GREENSTONEURL = "http://www.nzdl.org/atlasgreenstone3";
+ protected final String _GREENSTONEDEVURL = _GREENSTONEURL + "/dev";
+
+ protected com.google.gwt.xml.client.Document _currentNewPageDoc;
+
+ /**
+ * GWT module entry point
+ */
+ public void onModuleLoad()
+ {
+ _statusBar = new StatusBar(this);
+ //Make the Firebug console so that browsers that don't have it don't break
+ setUpConsole();
+
+ //Get a Google geocoder to help find places that the Gazetteer does not know the coordinates for
+ _geocoder = new Geocoder();
+
+ ((ServiceDefTarget) _findPlaceService).setServiceEntryPoint("http://taniwha.resnet.scms.waikato.ac.nz:8080/ATLAS/findPlace");
+ //((ServiceDefTarget) _findPlaceService).setServiceEntryPoint("http://www.nzdl.org/ATLAS/findPlace");
+
+ //Setup native Javascript functions
+ setUpLoadPageFromUrl(this);
+ setUpLoadPageFromForm(this);
+ setUpLoadSpatialSearchPage(this);
+
+ //Setup the map
+ setUpMap();
+
+ //Set up the list box that stores the text view options
+ setUpTextViewSelector();
+
+ //Load the Greenstone home page
+ loadPageFromUrl("http://taniwha.resnet.scms.waikato.ac.nz:8080/greenstone3/dev?a=p&sa=home");
+ }
+
+ /**
+ * Adds the three options to the text view selector
+ */
+ public void setUpTextViewSelector()
+ {
+ _textViewSelector.addItem("Normal");
+ _textViewSelector.addItem("Fisheye");
+ _textViewSelector.addItem("Column");
+ }
+
+ /**
+ * Loads the page at the given URL
+ * @param url is the url to load
+ */
+ public void loadPageFromUrl(String url)
+ {
+ //Make sure a url was given
+ if(url == null)
+ {
+ return;
+ }
+
+ //Save the given url for later use
+ _currentURL = url;
+
+ //Set Greenstone to be visible
+ _gsVisible = true;
+
+ //Clear the map
+ _map.clearOverlays();
+
+ updateHandlers();
+ clearStatusUpdates();
+
+ //Check if the page being loaded is a search page
+ if (url.contains("s1.query="))
+ {
+ //Load the search page
+ loadSearchPageFromUrl(url);
+ }
+ else
+ {
+ //This page is not a search page
+ _searchResultsPage = false;
+ }
+
+ //If the url contains a collection name
+ if (url.contains("&c="))
+ {
+ //Store the collection name
+ _currentCollection = getCollectionFromURL(url);
+ }
+
+ //Add the "Page loading" update to the status bar"
+ _statusBar.addUpdate("Loading new page", "LoadPage");
+
+ getNewPage(url);
+ }
+
+ public void loadPageWithoutUrl()
+ {
+ //Set the current url to be empty
+ _currentURL = "";
+
+ //Set Greenstone to be visible
+ _gsVisible = true;
+
+ //Clear the map
+ _map.clearOverlays();
+
+ updateHandlers();
+ clearStatusUpdates();
+
+ //Add the "Page loading" update to the status bar"
+ _statusBar.addUpdate("Loading new page", "LoadPage");
+ }
+
+ public void getNewPage(String url)
+ {
+ RequestBuilder newPageRequest = new RequestBuilder(RequestBuilder.GET, url.contains("?") ? (url + "&excerpttag=body") : (url + "?excerpttag=body"));
+ try{
+ newPageRequest.sendRequest(null, new RequestCallback()
+ {
+ public void onResponseReceived(Request request, Response response)
+ {
+ if(response.getStatusCode() == Response.SC_OK)
+ {
+ HTML newPage = new HTML(response.getText());
+ newPage.getElement().setId("newpage");
+ Element oldNewPage = (Element) Document.get().getElementById("newpage");
+ if(oldNewPage != null)
+ {
+ oldNewPage.removeFromParent();
+ }
+ getElementsByTagName("body").get(0).appendChild(newPage.getElement());
+ newPage.setVisible(false);
+
+ showLoadedPage();
+ }
+ }
+
+ public void onError(Request request, Throwable exception)
+ {
+ alert("Problem loading new page -> " + exception.getMessage());
+ }
+ });
+ }
+ catch(Exception ex)
+ {
+ alert("Exception while creating the new page request -> " + ex.getMessage());
+ }
+ }
+
+ /**
+ * Clears several of the status updates that should not persist across pages
+ */
+ public void clearStatusUpdates()
+ {
+ _statusBar.removeUpdate("DisPlaces");
+ _statusBar.removeUpdate("SearchLoad");
+ _statusBar.removeUpdate("TextSearch");
+ }
+
+ /**
+ * Gets a collection name from a given url
+ * @param url the url to search for a collection in
+ * @return the collection name
+ */
+ public String getCollectionFromURL(String url)
+ {
+ int start = (url.indexOf("&c=") + 3);
+ int end = -1;
+ if (url.indexOf("&", (url.indexOf("&c=") + 1)) == -1)
+ {
+ end = url.length();
+ }
+ else
+ {
+ end = url.indexOf("&", (url.indexOf("&c=") + 1));
+ }
+ return url.substring(start, end);
+ }
+
+ /**
+ * Sets up various handlers for a new page
+ */
+ public void updateHandlers()
+ {
+ if (_fishEyeHandlerReg != null)
+ {
+ _fishEyeHandlerReg.removeHandler();
+ _fishEyeHandlerReg = null;
+ }
+
+ if (!_mapMoveHandlerOn)
+ {
+ _mapMoveHandlerOn = true;
+ _map.addMapMoveHandler(_mapMoveHandler);
+ }
+
+ if (_searchControls != null)
+ {
+ _map.removeControl(_searchControls);
+ _searchControls = null;
+ }
+
+ if (_spatialSearchClickHandler != null)
+ {
+ _map.removeMapClickHandler(_spatialSearchClickHandler);
+ _spatialSearchClickHandler = null;
+ }
+ }
+
+ /**
+ * Moves the loaded page from the temporary frame to the main page
+ */
+ private void showLoadedPage()
+ {
+ //If ATLAS has not yet been initialised then do so
+ if (!_initialised)
+ {
+ //Fix webpage elements so that they point to the correct address
+ fixForms();
+ fixAnchors();
+ fixImages();
+
+ initialiseATLAS();
+
+ //Add and