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

File:
1 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();
Note: See TracChangeset for help on using the changeset viewer.