org.spiffyui.client.nav
Class MainNavBar

java.lang.Object
  extended by FlowPanel
      extended by org.spiffyui.client.nav.HasNavBarListenersPanel
          extended by org.spiffyui.client.nav.MainNavBar
All Implemented Interfaces:
HistoryCallback

public class MainNavBar
extends HasNavBarListenersPanel
implements HistoryCallback

This is the navigation bar for the main page.


Field Summary
protected static java.lang.String SELECTED_CLASS
          The class used for selected navigation items
 
Constructor Summary
MainNavBar()
          Create a new MainNavBar
 
Method Summary
 void add(Widget w)
           
protected  void addHistoryItem(java.lang.String historyToken)
          Deprecated. This method is deprecated and will not be called.
protected  void addHistoryItem(java.lang.String historyToken, java.lang.String title)
          A routine to store a history token that this Navbar can use when called in the future when the forward or back button's are called.
protected  void addNavItem(NavItem item)
          Addes a nav item to the list of anchors to listen to
 void clear()
          Remove all the items from this navigation bar.
 void fireEvent(NavItem item, boolean addToHistory)
          Fires the click event on the specified nav item
 boolean getBookmarkable()
           
 NavItem getItem(java.lang.String id)
          Gets a navigation item from the navigation menu.
 NavItem getSelectedItem()
          Get the currently selected navigation item in this navigation bar.
 void historyChanged(java.lang.String id)
          Call-back when the history item is retrieved after a browser back or forward button is pressed.
 void onClick(ClickEvent event)
           
 void remove(NavItem item)
          Remove the specified NavItem from the navigation bar.
 boolean selectItem(NavItem item)
          Selects the specified navigation item and fires the navigation event to let all listeners know it was selected.
 boolean selectItem(NavItem item, boolean addToHistory, boolean doFirePreEvent)
          Selects the specified navigation item and fires the navigation event to let all listeners know it was selected.
 boolean selectItem(NavItem item, boolean addToHistory, boolean doFirePreEvent, boolean doFireSelectEvent)
          Selects the specified navigation item and can fire the navigation event to let all listeners know it was selected, if the doFireSelectedEvent parameter is set accordingly.
 void setBookmarkable(boolean bookmarkable)
           
 void setEnabled(boolean enabled)
          Set the navigation bar to be enabled or disabled.
 
Methods inherited from class org.spiffyui.client.nav.HasNavBarListenersPanel
addListener, fireEvent, firePreEvent, isEnabled, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTED_CLASS

protected static final java.lang.String SELECTED_CLASS
The class used for selected navigation items

See Also:
Constant Field Values
Constructor Detail

MainNavBar

public MainNavBar()
Create a new MainNavBar

Method Detail

add

public void add(Widget w)

addNavItem

protected void addNavItem(NavItem item)
Addes a nav item to the list of anchors to listen to

Parameters:
item - the nav item to add

onClick

public void onClick(ClickEvent event)

historyChanged

public void historyChanged(java.lang.String id)
Call-back when the history item is retrieved after a browser back or forward button is pressed. The default implementation will be to treat the supplied id as a NavItem reference and select the one with the same ID. If you subclass and overload the addHistoryItem(String,String) routine, you will probably need to overload this method as well, to ensure that the supplied id (or history token) is translated correctly for your subclass.

Specified by:
historyChanged in interface HistoryCallback
Parameters:
id - The history token previously stored on the history stack.

selectItem

public boolean selectItem(NavItem item)
Selects the specified navigation item and fires the navigation event to let all listeners know it was selected. This intentionally does not fire a pre-event so that it cannot be intercepted. Returns true if NavItem found, false otherwise

Parameters:
item - the item to select
Returns:
true if the item is one of the NavItems of the NavBar, false if not a member such as logout

selectItem

public boolean selectItem(NavItem item,
                          boolean addToHistory,
                          boolean doFirePreEvent)
Selects the specified navigation item and fires the navigation event to let all listeners know it was selected. Returns true if NavItem found, false otherwise

Parameters:
item - the item to select
addToHistory - true if this item should be added to the browser's history and false otherwise
doFirePreEvent - true to allow interception and cancelling of the event, false to not fire the pre-event
Returns:
true if the item is one of the NavItems of the NavBar, false if not a member such as logout

selectItem

public boolean selectItem(NavItem item,
                          boolean addToHistory,
                          boolean doFirePreEvent,
                          boolean doFireSelectEvent)
Selects the specified navigation item and can fire the navigation event to let all listeners know it was selected, if the doFireSelectedEvent parameter is set accordingly. Returns true if NavItem found, false otherwise

Parameters:
item - the item to select
addToHistory - true if this item should be added to the browser's history and false otherwise
doFirePreEvent - true to allow interception and cancelling of the event, false to not fire the pre-event
doFireSelectEvent - true to fire the selection event to navbar listeners, false to not fire the event
Returns:
true if the item is one of the NavItems of the NavBar, false if not a member such as logout

getSelectedItem

public NavItem getSelectedItem()
Get the currently selected navigation item in this navigation bar.

Returns:
the currently selected navigation item or null if no items are selected

getItem

public NavItem getItem(java.lang.String id)
Gets a navigation item from the navigation menu.

Parameters:
id - The id of the item to get
Returns:
the item with that id or null if it doesn't exist

setEnabled

public void setEnabled(boolean enabled)
Set the navigation bar to be enabled or disabled. A disabled navigation bar is gray and never fires selection events.

Overrides:
setEnabled in class HasNavBarListenersPanel
Parameters:
enabled - true for enabled and false for disabled

fireEvent

public void fireEvent(NavItem item,
                      boolean addToHistory)
Description copied from class: HasNavBarListenersPanel
Fires the click event on the specified nav item

Overrides:
fireEvent in class HasNavBarListenersPanel
Parameters:
item - the nav item that was clicked
addToHistory - true if this item should be added to the browser history and false otherwise

addHistoryItem

@Deprecated
protected void addHistoryItem(java.lang.String historyToken)
Deprecated. This method is deprecated and will not be called.

A routine to store a history token that this Navbar can use when called in the future when the forward or back button's are called.

This is available for subclasses to overload if they wish to store a token that is not based on the NavItem's ID. For instance the situation where there are multiple types of identifiers being used to reconstitute a past application state.

Please note that if you overload this method you will need to provide an alternative implementation of the history callback routine historyChanged(String). That will need to translate the stored token that your overloaded addHistoryItem routine stored.

Parameters:
historyToken - A string value that will server as a token about the applications state
See Also:
MainNavBar.addHistoryItem

addHistoryItem

protected void addHistoryItem(java.lang.String historyToken,
                              java.lang.String title)
A routine to store a history token that this Navbar can use when called in the future when the forward or back button's are called.

This is available for subclasses to overload if they wish to store a token that is not based on the NavItem's ID. For instance the situation where there are multiple types of identifiers being used to reconstitute a past application state.

Please note that if you overload this method you will need to provide an alternative implementation of the history callback routine historyChanged(String). That will need to translate the stored token that your overloaded addHistoryItem routine stored.

Parameters:
historyToken - A string value that will server as a token about the applications state
title - the window title for this history item

setBookmarkable

public void setBookmarkable(boolean bookmarkable)

getBookmarkable

public boolean getBookmarkable()

clear

public void clear()
Remove all the items from this navigation bar.


remove

public void remove(NavItem item)
Remove the specified NavItem from the navigation bar.

Parameters:
item - the item to remove