Changeset 23934


Ignore:
Timestamp:
04/19/11 10:11:46 (10 years ago)
Author:
sjm84
Message:

Extensive improvements to the ATLAS code

Location:
gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas
Files:
2 added
30 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/GS3MapLibrary.gwt.xml

    r23906 r23934  
    1010    <!--<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAtgBCR-EMOIox9GYORrWZ4xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTdn97J3Y4bgIWO98Jw2xGa7SsjVQ"/>-->
    1111    <!--<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAtgBCR-EMOIox9GYORrWZ4xRDDXBaPmHH9_0fCH2SRcUU9bjcjhT3cD_2Hv84s1XjkWPxzMb0RT2hQQ"/>-->
    12     <entry-point class='org.greenstone.client.GS3MapLibrary'/>
     12    <entry-point class='org.greenstone.atlas.client.GS3MapLibrary'/>
    1313</module>
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/FindPlaceService.java

    r23906 r23934  
    1 package org.greenstone.client;
     1package org.greenstone.atlas.client;
    22
    33import java.util.ArrayList;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/FindPlaceServiceAsync.java

    r23906 r23934  
    1 package org.greenstone.client;
     1package org.greenstone.atlas.client;
    22
    33import java.util.ArrayList;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/GS3MapLibrary.java

    r23906 r23934  
    1 package org.greenstone.client;
     1package org.greenstone.atlas.client;
    22
    33import com.google.gwt.core.client.EntryPoint;
     
    158158    protected String _currentCollection = "";
    159159    protected String _currentURL = "";
    160     protected final String _GREENSTONEURL = "http://taniwha.resnet.scms.waikato.ac.nz:8080/greenstone3";
     160    protected final String _GREENSTONEURL = "http://localhost:8486/greenstone3";
    161161    //protected final String _GREENSTONEURL = "http://www.nzdl.org/atlasgreenstone3";
    162162    protected final String _GREENSTONEDEVURL = _GREENSTONEURL + "/dev";
     
    176176        _geocoder = new Geocoder();
    177177
    178         ((ServiceDefTarget) _findPlaceService).setServiceEntryPoint("http://taniwha.resnet.scms.waikato.ac.nz:8080/ATLAS/findPlace");
     178        ((ServiceDefTarget) _findPlaceService).setServiceEntryPoint("http://localhost:8486/ATLAS/findPlace");
    179179        //((ServiceDefTarget) _findPlaceService).setServiceEntryPoint("http://www.nzdl.org/ATLAS/findPlace");
    180180       
     
    191191
    192192        //Load the Greenstone home page
    193         loadPageFromUrl("http://taniwha.resnet.scms.waikato.ac.nz:8080/greenstone3/dev?a=p&sa=home");
     193        loadPageFromUrl(_GREENSTONEDEVURL + "?a=p&sa=home");
    194194    }
    195195
     
    250250        _statusBar.addUpdate("Loading new page", "LoadPage");
    251251       
    252         getNewPage(url);
     252        getNewPage(url.contains("?") ? (url + "&excerpttag=body") : (url + "?excerpttag=body"),
     253            new ResponseFunction(){
     254                public void function(String response){
     255                    HTML newPage = new HTML(response);
     256                    newPage.getElement().setId("newpage");
     257                    Element oldNewPage = (Element) Document.get().getElementById("newpage");
     258                    if(oldNewPage != null)
     259                    {
     260                        oldNewPage.removeFromParent();
     261                    }
     262                    getElementsByTagName("body").get(0).appendChild(newPage.getElement());
     263                    newPage.setVisible(false);
     264
     265                    showLoadedPage();
     266                }
     267            }
     268        );
    253269    }
    254270   
     
    271287    }
    272288   
    273     public void getNewPage(String url)
    274     {
    275         RequestBuilder newPageRequest = new RequestBuilder(RequestBuilder.GET, url.contains("?") ? (url + "&excerpttag=body") : (url + "?excerpttag=body"));
     289    public void getNewPage(String url, final ResponseFunction responseFunc)
     290    {
     291        RequestBuilder newPageRequest = new RequestBuilder(RequestBuilder.GET, url);
    276292        try{
    277293            newPageRequest.sendRequest(null, new RequestCallback()
     
    281297                    if(response.getStatusCode() == Response.SC_OK)
    282298                    {
    283                         HTML newPage = new HTML(response.getText());
    284                         newPage.getElement().setId("newpage");
    285                         Element oldNewPage = (Element) Document.get().getElementById("newpage");
    286                         if(oldNewPage != null)
    287                         {
    288                             oldNewPage.removeFromParent();
    289                         }
    290                         getElementsByTagName("body").get(0).appendChild(newPage.getElement());
    291                         newPage.setVisible(false);
    292 
    293                         showLoadedPage();
     299                        responseFunc.function(response.getText());
    294300                    }
    295301                }
     
    383389           
    384390            //Add <link> and <script> elements to <head>
    385             //changeCSSLinksAndScripts();
     391            getNewPage(_currentURL.contains("?") ? (_currentURL + "&excerpttag=head") : (_currentURL + "?excerpttag=head"),
     392                new ResponseFunction(){
     393                    public void function(String response){
     394                        HTML newPage = new HTML(response);
     395                        changeCSSLinksAndScripts(newPage.getElement());
     396                    }
     397                }
     398            );
    386399        }
    387400        else
    388401        {
    389402            //Add <link> and <script> elements to <head>
    390             //changeCSSLinksAndScripts();
     403            getNewPage(_currentURL.contains("?") ? (_currentURL + "&excerpttag=head") : (_currentURL + "?excerpttag=head"),
     404                new ResponseFunction(){
     405                    public void function(String response){
     406                        HTML newPage = new HTML(response);
     407                        changeCSSLinksAndScripts(newPage.getElement());
     408                    }
     409                }
     410            );
    391411
    392412            //Fix webpage elements so that they point to the correct address
     
    529549        }
    530550       
    531         if(headerElem == null)
    532         {
    533             alert("header is null");
    534         }
    535         if(bodyElem == null)
    536         {
    537             alert("body is null");
    538         }   
    539         if(footerElem == null)
    540         {
    541             alert("footer is null");
    542         }
     551        if(headerElem == null){alert("header is null");}
     552        if(bodyElem == null){alert("body is null");}   
     553        if(footerElem == null){alert("footer is null");}
    543554
    544555        // Add header
     
    875886     * Remove old CSS links from the page and add new ones, the href attributes are also corrected
    876887     */
    877     public void changeCSSLinksAndScripts()
     888    public void changeCSSLinksAndScripts(Element newHead)
    878889    {       
    879         //Get the head section of the HTML page
    880890        Element head = getDocumentHead();
    881 
     891       
    882892        //Get all of the <link> elements from the HTML header
    883893        NodeList<com.google.gwt.dom.client.Element> currentLinks = head.getElementsByTagName("link");
     
    885895        //Get all of the <script> elements from the HTML header
    886896        NodeList<com.google.gwt.dom.client.Element> currentScripts = head.getElementsByTagName("script");
    887 
     897       
    888898        //Add the new links
    889         com.google.gwt.xml.client.NodeList newLinks = _currentNewPageDoc.getElementsByTagName("link"); 
     899        NodeList<com.google.gwt.dom.client.Element> newLinks = newHead.getElementsByTagName("link");   
    890900        for (int i = 0; i < newLinks.getLength(); i++)
    891901        {
    892             com.google.gwt.xml.client.Element e = (com.google.gwt.xml.client.Element) newLinks.item(i);
     902            com.google.gwt.dom.client.Element e = newLinks.getItem(i);
    893903            boolean found = false;
     904
    894905            for(int j = 0; j < currentLinks.getLength(); j++)
    895906            {
     
    902913                }
    903914            }
     915
     916            if(!found)
     917            {
     918                Element newElem = DOM.createElement("link");
     919                newElem.setAttribute("href", e.getAttribute("href"));
     920                newElem.setAttribute("type", e.getAttribute("type"));
     921                newElem.setAttribute("rel", e.getAttribute("rel"));
     922               
     923                if(!newElem.getAttribute("href").startsWith("http://"))
     924                {
     925                    newElem.setAttribute("href", _GREENSTONEURL + "/" + newElem.getAttribute("href")); 
     926                }
     927                head.appendChild(newElem);
     928            }
     929        }
     930       
     931        //Add the new scripts on the page
     932        NodeList<com.google.gwt.dom.client.Element> newScripts = newHead.getElementsByTagName("script");   
     933        for (int i = 0; i < newScripts.getLength(); i++)
     934        {
     935            com.google.gwt.dom.client.Element e = newScripts.getItem(i);
     936            boolean found = false;
     937            for(int j = 0; j < currentScripts.getLength(); j++)
     938            {
     939                Element elem = (Element) currentLinks.getItem(j);
     940                if(e.getAttribute("src").equals(elem.getAttribute("src"))
     941                && e.getAttribute("type").equals(elem.getAttribute("type")))
     942                {
     943                    found = true;
     944                }
     945            }
    904946           
    905947            if(!found)
    906948            {
    907                 Element newElem = DOM.createElement("link");
    908                
    909                 NamedNodeMap map = e.getAttributes();
    910                 for(int k = 0; k < e.getAttributes().getLength(); k++)
    911                 {
    912                     newElem.setAttribute(map.item(k).getNodeName(), map.item(k).getNodeValue());
    913                 }
    914                
    915                 if(!newElem.getAttribute("href").startsWith("http://"))
    916                 {
    917                     newElem.setAttribute("href", _GREENSTONEURL + "/" + newElem.getAttribute("href")); 
    918                 }
    919                 head.appendChild(newElem);
    920             }
    921         }
    922        
    923         //Add the new scripts on the page
    924         com.google.gwt.xml.client.NodeList newScripts = _currentNewPageDoc.getElementsByTagName("script"); 
    925         for (int i = 0; i < newScripts.getLength(); i++)
    926         {
    927             com.google.gwt.xml.client.Element e = (com.google.gwt.xml.client.Element) newScripts.item(i);
    928             boolean found = false;
    929             for(int j = 0; j < currentScripts.getLength(); j++)
    930             {
    931                 Element elem = (Element) currentLinks.getItem(j);
    932                 if(e.getAttribute("src").equals(elem.getAttribute("src"))
    933                 && e.getAttribute("type").equals(elem.getAttribute("type"))
    934                 && e.getAttribute("charset").equals(elem.getAttribute("charset")))
    935                 {
    936                     found = true;
    937                 }
    938             }
    939            
    940             if(!found)
    941             {
    942                 Element newElem = DOM.createElement("link");
    943                
    944                 NamedNodeMap map = e.getAttributes();
    945                 for(int k = 0; k < e.getAttributes().getLength(); k++)
    946                 {
    947                     newElem.setAttribute(map.item(k).getNodeName(), map.item(k).getNodeValue());
    948                 }
    949                
    950                
     949                Element newElem = DOM.createElement("script");
     950                newElem.setAttribute("src", e.getAttribute("src"));
     951                newElem.setAttribute("type", e.getAttribute("type"));
     952                       
    951953                if(!e.getAttribute("src").startsWith("http://"))
    952954                {
     
    993995                continue;
    994996            }
     997           
     998            if(e.getAttribute("href").startsWith("javascript:"))
     999            {
     1000                continue;
     1001            }
     1002           
    9951003            if (!e.getAttribute("href").startsWith("http://") && !e.getAttribute("href").startsWith("/"))
    9961004            {
     
    10451053        $wnd.loadPageFromFormJS = function(form)
    10461054        {
    1047             ml.@org.greenstone.client.GS3MapLibrary::loadPageFromForm(Lcom/google/gwt/user/client/Element;) (form);
     1055            ml.@org.greenstone.atlas.client.GS3MapLibrary::loadPageFromForm(Lcom/google/gwt/user/client/Element;) (form);
    10481056        };
    10491057    }-*/;
     
    10571065        $wnd.loadPageFromUrlJS = function(url)
    10581066        {
    1059             ml.@org.greenstone.client.GS3MapLibrary::loadPageFromUrl(Ljava/lang/String;) (url);
     1067            ml.@org.greenstone.atlas.client.GS3MapLibrary::loadPageFromUrl(Ljava/lang/String;) (url);
    10601068        };
    10611069    }-*/;
     
    10691077        $wnd.loadSpatialSearchPageJS = function()
    10701078        {
    1071             ml.@org.greenstone.client.GS3MapLibrary::loadSpatialSearchPage() ();
     1079            ml.@org.greenstone.atlas.client.GS3MapLibrary::loadSpatialSearchPage() ();
    10721080        };
    10731081    }-*/;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/Menu.java

    r23906 r23934  
    1 package org.greenstone.client;
     1package org.greenstone.atlas.client;
    22
    33import java.util.ArrayList;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/MenuItem.java

    r23906 r23934  
    1 package org.greenstone.client;
     1package org.greenstone.atlas.client;
    22
    33import com.google.gwt.event.dom.client.ClickHandler;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/Place.java

    r23906 r23934  
    1 package org.greenstone.client;
     1package org.greenstone.atlas.client;
    22
    33import java.io.Serializable;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/StatusBar.java

    r23906 r23934  
    1 package org.greenstone.client;
     1package org.greenstone.atlas.client;
    22
    33import java.util.ArrayList;
     
    8787        {
    8888            GS3MapLibrary.logToConsole("Adding progress image");
    89             status += "<br/><img src=\"http://localhost:8080/ATLAS/images/progress.gif\"></img>";
     89            status += "<br/><img src=\"http://localhost:8486/ATLAS/images/progress.gif\"></img>";
    9090        }
    9191        _statusBarDiv.setHTML(status);
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/TemporaryFrame.java

    r22277 r23934  
    1 package org.greenstone.client;
     1package org.greenstone.atlas.client;
    22
    33import com.google.gwt.core.client.JsArray;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/FindPlaceServiceImpl.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.net.URLConnection;
     
    88import java.util.ArrayList;
    99
    10 import org.greenstone.client.FindPlaceService;
    11 import org.greenstone.client.Place;
     10import org.greenstone.atlas.client.FindPlaceService;
     11import org.greenstone.atlas.client.Place;
    1212
    1313import com.google.gwt.user.server.rpc.RemoteServiceServlet;
     
    2525    public Boolean loadGazetteer()
    2626    {
    27         System.out.print("Loading Gazetteer... ");
     27        System.err.println("Loading Gazetteer... ");
    2828        _pageScanner = new PageScanner(this.getServletContext().getRealPath(""));
    29         System.out.println("Done!");
     29        System.err.println("... Done!");
    3030        return true;
    3131    }
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GateScanner.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import gate.Annotation;
     
    3131        {
    3232            BasicConfigurator.configure();
    33             Gate.setGateHome(new File("C:\\Users\\sjm84\\Desktop\\stuff\\Gate5.2"));
    34             Gate.setPluginsHome(new File("C:\\Users\\sjm84\\Desktop\\stuff\\Gate5.2\\plugins"));
    35             Gate.setUserConfigFile(new File("C:\\Users\\sjm84\\Desktop\\stuff\\Gate5.2\\gate.xml"));
     33            Gate.setGateHome(new File("C:\\Users\\sjm84\\Desktop\\Gate"));
     34            Gate.setPluginsHome(new File("C:\\Users\\sjm84\\Desktop\\Gate\\plugins"));
     35            Gate.setUserConfigFile(new File("C:\\Users\\sjm84\\Desktop\\Gate\\gate.xml"));
    3636            Gate.init();
    37             Gate.getCreoleRegister().registerDirectories(new File("C:\\Users\\sjm84\\Desktop\\stuff\\Gate5.2\\plugins\\ANNIE").toURI().toURL());
     37            Gate.getCreoleRegister().registerDirectories(new File("C:\\Users\\sjm84\\Desktop\\Gate\\plugins\\ANNIE").toURI().toURL());
    3838            Gate.getUserConfig().put(GateConstants.DOCUMENT_ADD_SPACE_ON_UNPACK_FEATURE_NAME, new Boolean(false));
    3939           
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerHelper.java

    r22272 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.util.ArrayList;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieFullNode.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.Serializable;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieNode.java

    r22272 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieSmallNode.java

    r22272 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.Serializable;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieTopLevelNode.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.Serializable;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieType1.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.BufferedReader;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieType2.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.BufferedReader;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieType3.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.BufferedReader;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieType4.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.BufferedReader;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GazetteerTrieType5.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.BufferedReader;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/MarkupService.java

    r22272 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/PageScanner.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import gate.util.Out;
     
    1010import java.util.HashMap;
    1111
    12 import org.greenstone.client.Place;
     12import org.greenstone.atlas.client.Place;
    1313
    1414public class PageScanner
     
    4242    public PageScanner(String path)
    4343    {
    44         System.out.println("Loading path = " + path);
     44        System.err.println("Loading path = " + path);
    4545        try
    4646        {
     
    5151            ex.printStackTrace();
    5252        }
    53         System.out.println("Starting loading gazetteer");
     53        System.err.println("Starting loading gazetteer");
    5454        _gazetteer = new GazetteerTrieType2(path + "/dataen.txt");
    5555    }
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/PlaceInformation.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.sql.Connection;
     
    66import java.sql.Statement;
    77import java.util.ArrayList;
    8 import org.greenstone.client.Place;
     8import org.greenstone.atlas.client.Place;
    99import java.util.HashMap;
    1010
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/ScanConfiguration.java

    r22272 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33public class ScanConfiguration
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/ScanResultSet.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.util.ArrayList;
    44import java.util.HashMap;
    55
    6 import org.greenstone.client.Place;
    7 import org.greenstone.server.ServerPlace;
     6import org.greenstone.atlas.client.Place;
     7import org.greenstone.atlas.server.ServerPlace;
    88
    99public class ScanResultSet
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/ServerPlace.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.io.Serializable;
    4 import org.greenstone.client.Place;
     4import org.greenstone.atlas.client.Place;
    55
    66public class ServerPlace implements Serializable
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/ServerSideTests.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.awt.BorderLayout;
     
    3232import javax.swing.event.ListSelectionListener;
    3333
    34 import org.greenstone.client.Place;
     34import org.greenstone.atlas.client.Place;
    3535
    3636public class ServerSideTests
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/StringLengthComparator.java

    r22272 r23934  
    1 package org.greenstone.server;
    2 
     1package org.greenstone.atlas.server;
    32
    43import java.util.Comparator;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/Word.java

    r23906 r23934  
    1 package org.greenstone.server;
     1package org.greenstone.atlas.server;
    22
    33import java.util.ArrayList;
Note: See TracChangeset for help on using the changeset viewer.