Ignore:
Timestamp:
2010-06-18T16:08:27+12:00 (14 years ago)
Author:
sjm84
Message:

Added several improvements to the code such as the ability to remove places if they from the text and map if they should not be places

Location:
gs3-extensions/atlas-src/trunk/src/org/greenstone
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/client/GS3MapLibrary.java

    r22272 r22277  
    1111import com.google.gwt.event.dom.client.ClickEvent;
    1212import com.google.gwt.event.dom.client.ClickHandler;
    13 import com.google.gwt.event.dom.client.MouseDownEvent;
    14 import com.google.gwt.event.dom.client.MouseDownHandler;
    15 import com.google.gwt.event.dom.client.MouseEvent;
    1613import com.google.gwt.event.dom.client.MouseMoveEvent;
    1714import com.google.gwt.event.dom.client.MouseMoveHandler;
     
    129126
    130127    protected ArrayList<ArrayList<Place>> _currentMultiPlaces = null;
    131 
    132     protected HashMap<String, Place> _chosenPlaces = new HashMap<String, Place>();
     128    protected ArrayList<String> _removedPlaces = new ArrayList<String>();
     129   
     130    protected HashMap<String, Place> _chosenPlaces = new HashMap<String, Place>(); 
    133131
    134132    protected HandlerRegistration _fishEyeHandlerReg = null;
     
    15951593
    15961594                //If a different place with this name has been chosen then don't use it
    1597                 if (_chosenPlaces.containsKey(p.getName()) && !_chosenPlaces.get(p.getName()).equals(p))
     1595                if ((_chosenPlaces.containsKey(p.getName()) && !_chosenPlaces.get(p.getName()).equals(p)) || _removedPlaces.contains(p.getName()))
    15981596                {
    15991597                    continue;
     
    23252323            }
    23262324        }));
    2327 
    2328         final MenuItem prevMenuItem = new MenuItem("Remove all highlights", new ClickHandler()
     2325       
     2326        menuItems.add(new MenuItem("Remove all highlights", new ClickHandler()
    23292327        {
    23302328            public void onClick(ClickEvent event)
     
    23502348                _currentDocumentMenu.hideMenu();
    23512349            }
     2350        }));
     2351       
     2352        final MenuItem prevMenuItem = new MenuItem("Remove this place", new ClickHandler()
     2353        {
     2354            public void onClick(ClickEvent event)
     2355            {
     2356                _removedPlaces.add(_selectedPlaceName);
     2357                _currentDocumentMenu.hideMenu();
     2358               
     2359                JsArray<Element> textPlaces = getElementsByTagName("span");
     2360
     2361                //Add the place spans to the array
     2362                for (int j = 0; j < textPlaces.length(); j++)
     2363                {
     2364                    Element e = textPlaces.get(j);
     2365                    if (e.getAttribute("class").equals("place") && e.getInnerText().equals(_selectedPlaceName))
     2366                    {
     2367                        e.getParentElement().insertBefore(e.getFirstChild(), e);
     2368                    }
     2369                }
     2370               
     2371                addPlacesToMap(_currentPlaces, "#FFFFFF", "#00FF00", false);
     2372            }
    23522373        });
    23532374        menuItems.add(prevMenuItem);
    23542375
    2355         menuItems.add(new MenuItem("Choose correct place           >", new ClickHandler()
     2376        menuItems.add(new MenuItem("Choose correct place >", new ClickHandler()
    23562377        {
    23572378            public void onClick(ClickEvent event)
     
    23592380                logToConsole("MARKER!");
    23602381                ArrayList<MenuItem> places = new ArrayList<MenuItem>();
     2382
    23612383                ArrayList<Place> matchingPlaces = new ArrayList<Place>();
    23622384
     
    23682390                    }
    23692391                }
    2370 
     2392               
    23712393                for (final Place p : matchingPlaces)
    23722394                {
     
    24252447                placeMenu.showMenu();
    24262448            }
    2427         }));
     2449        }){
     2450            public boolean condition()
     2451            {
     2452                ArrayList<Place> matchingPlaces = new ArrayList<Place>();
     2453
     2454                if(_currentPlaces == null || _currentPlaces.size() == 0)
     2455                {
     2456                    return false;
     2457                }
     2458               
     2459                for (Place p : _currentPlaces)
     2460                {
     2461                    if (p.getName().equals(_selectedPlaceName))
     2462                    {
     2463                        matchingPlaces.add(p);
     2464                    }
     2465                }
     2466               
     2467                if(matchingPlaces.size() > 1)
     2468                {
     2469                    return true;
     2470                }
     2471                return false;
     2472            }
     2473        });
    24282474
    24292475        documentMenu.addMenuItems(menuItems);
     
    26162662            public void run()
    26172663            {
     2664                _currentDocumentMenu.refreshMenu();
    26182665                _currentDocumentMenu.moveMenu(x, y);
    26192666                _currentDocumentMenu.showMenu();
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/client/Menu.java

    r22272 r22277  
    1313public class Menu
    1414{
     15    protected Element _parent = null;
    1516    protected ArrayList<Menu> _childMenus = new ArrayList<Menu>();
    1617    protected ArrayList<MenuItem> _menuItems = new ArrayList<MenuItem>();
     
    2122    public Menu(Element parent, MouseOverHandler onMouseOver, MouseOutHandler onMouseOut)
    2223    {
     24        _parent = parent;
    2325        parent.appendChild(_menuDiv.getElement());
    2426        _menuDiv.getElement().getStyle().setProperty("background", "#FFFFFF");
     
    3234    public void addMenuItems(ArrayList<MenuItem> menuItems)
    3335    {
     36        _menuItems = menuItems;
    3437        int maxWidth = -1;
    3538        for(int i = 0; i < menuItems.size(); i++)
    3639        {
     40            if(!menuItems.get(i).condition())
     41            {
     42                continue;
     43            }
    3744            Element item = menuItems.get(i).getMenuElement();
    3845            item.getStyle().setProperty("background", "#FFFFFF");
     
    6976        {
    7077            public void run()
    71             {
    72                 //GS3MapLibrary.logToConsole("Menu height = " + _menuDiv.getOffsetHeight() + ", Div height = " + GS3MapLibrary.getElementById("GSContent").getOffsetHeight() + ", Top = " + GS3MapLibrary.getElementById("GSContent").getAbsoluteTop());
    73                
     78            {               
    7479                if (_menuDiv.getOffsetHeight() > GS3MapLibrary.getElementById("GSContent").getOffsetHeight())
    7580                {
     
    8085                else if(y + _menuDiv.getOffsetHeight() > GS3MapLibrary.getElementById("GSFooter").getAbsoluteTop())
    8186                {
    82                     //GS3MapLibrary.logToConsole("TRUE, " + (y + _menuDiv.getOffsetHeight()) + " is greater than " + GS3MapLibrary.getElementById("GSFooter").getAbsoluteTop());
    8387                    _menuDiv.getElement().getStyle().setProperty("top", (y - ( y + _menuDiv.getOffsetHeight() - GS3MapLibrary.getElementById("GSFooter").getAbsoluteTop()) + "px"));
    84                 }
    85                 else
    86                 {
    87                     //GS3MapLibrary.logToConsole("FALSE, " + (y + _menuDiv.getOffsetHeight()) + " is less than " + GS3MapLibrary.getElementById("GSFooter").getAbsoluteTop());
    8888                }
    8989                _menuDiv.setVisible(true);
     
    111111    }
    112112   
     113    public void refreshMenu()
     114    {
     115        _parent.removeChild(_menuDiv.getElement());
     116        _menuDiv = new HTML();
     117        _parent.appendChild(_menuDiv.getElement());
     118        _menuDiv.getElement().getStyle().setProperty("background", "#FFFFFF");
     119        _menuDiv.getElement().getStyle().setProperty("padding", "2px");
     120        _menuDiv.getElement().getStyle().setProperty("position", "absolute");
     121        addMenuItems(_menuItems);
     122    }
     123   
    113124    public void showMenu()
    114125    {
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/client/MenuItem.java

    r22272 r22277  
    1919    }
    2020   
     21    public boolean condition()
     22    {
     23        return true;
     24    }
     25   
    2126    public ClickHandler getClickHandler()
    2227    {
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/client/TemporaryFrame.java

    r22272 r22277  
    3838            public void run()
    3939            {
    40                 if (timerCount++ > 25)
     40                if (timerCount++ > 10)
    4141                {
    4242                    _doneLoading = true;
  • gs3-extensions/atlas-src/trunk/src/org/greenstone/server/PageScanner.java

    r22272 r22277  
    77
    88import org.greenstone.client.Place;
    9 
    10 import com.google.apphosting.utils.servlet.DatastoreViewerServlet.Page;
    119
    1210public class PageScanner
Note: See TracChangeset for help on using the changeset viewer.