001package votorola.a.web.wic; // Copyright 2008, 2012, Michael Allan.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE.
002
003import org.apache.wicket.Page;
004import votorola.g.lang.*;
005import votorola.g.web.wic.*;
006
007
008/** A tab in a navigation bar, serving as a link to a page.
009  */
010public abstract @ThreadSafe class NavTab
011{
012
013
014   // - N a v - T a b --------------------------------------------------------------------
015
016
017    /** The bookmark for the page to which this tab links.
018      */
019    public abstract Bookmark bookmark();
020
021
022
023    /** Answers whether or not the tab is to be enabled, when it is off the selection
024      * path.  Tabs on the selection path are always disabled.  The default implementation
025      * of this method in NavTab returns true.
026      */
027    public boolean isEnabled( VRequestCycle _cycle ) { return true; }
028
029
030
031    /** The navigation bar that contains this tab.
032      *
033      *     @see #setNavBar(NavBar)
034      *     @throws NullPointerException if the navbar has not been set.
035      */
036    public final NavBar navBar()
037    {
038        if( navBar == null ) throw new NullPointerException();
039
040        return navBar;
041    }
042
043
044        private volatile NavBar navBar;
045
046
047        /** Sets the navigation bar that contains this tab.  Called once only,
048          * during construction of the navigation bar.
049          *
050          *     @return this navigation tab.
051          *
052          *     @see #navBar()
053          *     @throws IllegalStateException if a second call to this method is detected,
054          *       though such detection not guaranteed.
055          */
056        public final NavTab setNavBar( final NavBar navBar )
057        {
058            if( this.navBar != null ) throw new IllegalStateException();
059
060            this.navBar = navBar;
061            return NavTab.this;
062        }
063
064
065
066    /** The class of pages to which this tab links, or null if there is no single class.
067      * The default implementation of this method in NavTab returns the page class of this
068      * tab's bookmark.
069      */
070    public Class<? extends Page> pageClass() { return bookmark().pageClass(); }
071
072
073
074 // /** Returns a runner to handle any clicks on this tab.  The default implementation of
075 //   * this method in NavTab constructs and returns a bookmark runner for this tab's
076 //   * bookmark.
077 //   *
078 //   *     @see BookmarkRunner
079 //   */
080 // public RequestCycleRunner runner( VRequestCycle cycle )
081 // {
082 //     return new BookmarkRunner( bookmark() );
083 // }
084 ///// runners removed on migration to stateless pages
085
086
087
088    /** A short title for this tab, suitable as the body of a link.
089      */
090    public abstract String shortTitle( VRequestCycle _cycle );
091
092
093
094}