package 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. import org.apache.wicket.Page; import votorola.g.lang.*; import votorola.g.web.wic.*; /** A tab in a navigation bar, serving as a link to a page. */ public abstract @ThreadSafe class NavTab { // - N a v - T a b -------------------------------------------------------------------- /** The bookmark for the page to which this tab links. */ public abstract Bookmark bookmark(); /** Answers whether or not the tab is to be enabled, when it is off the selection * path. Tabs on the selection path are always disabled. The default implementation * of this method in NavTab returns true. */ public boolean isEnabled( VRequestCycle _cycle ) { return true; } /** The navigation bar that contains this tab. * * @see #setNavBar(NavBar) * @throws NullPointerException if the navbar has not been set. */ public final NavBar navBar() { if( navBar == null ) throw new NullPointerException(); return navBar; } private volatile NavBar navBar; /** Sets the navigation bar that contains this tab. Called once only, * during construction of the navigation bar. * * @return this navigation tab. * * @see #navBar() * @throws IllegalStateException if a second call to this method is detected, * though such detection not guaranteed. */ public final NavTab setNavBar( final NavBar navBar ) { if( this.navBar != null ) throw new IllegalStateException(); this.navBar = navBar; return NavTab.this; } /** The class of pages to which this tab links, or null if there is no single class. * The default implementation of this method in NavTab returns the page class of this * tab's bookmark. */ public Class pageClass() { return bookmark().pageClass(); } // /** Returns a runner to handle any clicks on this tab. The default implementation of // * this method in NavTab constructs and returns a bookmark runner for this tab's // * bookmark. // * // * @see BookmarkRunner // */ // public RequestCycleRunner runner( VRequestCycle cycle ) // { // return new BookmarkRunner( bookmark() ); // } ///// runners removed on migration to stateless pages /** A short title for this tab, suitable as the body of a link. */ public abstract String shortTitle( VRequestCycle _cycle ); }