package votorola.s.wic.count; // Copyright 2008-2010, 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 java.net.*;
import java.util.*;
import org.apache.wicket.model.*;
import org.apache.wicket.markup.html.basic.*;
import org.apache.wicket.markup.html.link.*;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import votorola.a.*;
import votorola.a.count.*;
import votorola.a.web.wic.*;
import votorola.g.*;
import votorola.g.lang.*;
import votorola.g.locale.*;
import votorola.g.net.*;
import votorola.g.web.wic.*;
import votorola.g.util.*;
import static votorola.a.voter.IDPair.NOBODY;
/** The count engine overview page. Query parameters for this page are:
*
*
*
* Key |
* Value |
* Default |
*
* a |
*
* The area name (AREA) in a multi-area pollwiki. This sets wiki file
* File:AREALogo as the wgLogo image (top left), and wiki page AREA as its link
* target. This is only needed for use with a multi-area pollwiki. |
*
* Null, setting the {@linkplain PollService#wgLogoImageLocation() image} and
* {@linkplain PollService#wgLogoLinkTarget() link} from the most recently requested
* poll. |
*
*
*
*
* @see WP_CountEngine.html
*/
@ThreadRestricted("wicket") @org.apache.wicket.devutils.stateless.StatelessComponent
public final class WP_CountEngine extends VPageHTML implements TabbedPage
{
/** Constructs a WP_CountEngine.
*/
public WP_CountEngine( final PageParameters pP ) // bookmarkable page iff constructor public & (default|PageParameter)
throws java.io.IOException, javax.script.ScriptException, java.sql.SQLException
{
final VRequestCycle cycle = VRequestCycle.get();
final VoteServer.Run vsRun = VOWicket.get().vsRun();
final VoteServer vS = vsRun.voteServer();
final String pollName;
final String wgLogoLinkTarget;
{
final String imageLocation;
{
String name = VSession.get().scopePoll().getLastName();
final String a = pP.get( "a" ).toString();
if( a == null )
{
if( name == null ) name = Poll.TEST_POLL_NAME;
final PollService poll = vsRun.scopePoll().ensurePoll( name );
imageLocation = poll.wgLogoImageLocation();
wgLogoLinkTarget = poll.wgLogoLinkTarget();
}
else
{
if( name != null && !name.startsWith( a )) // change of area
{
name = null;
VSession.get().scopePoll().setLastName( name );
}
final String aEnc = MediaWiki.demiEncodedPageName( a, vS.pollwiki().maybeUgly() );
imageLocation = vS.pollwiki().appendPageSpecifier( "Special:FilePath/" + aEnc
+ "Logo.png" ).toString();
wgLogoLinkTarget = vS.pollwiki().appendPageSpecifier( aEnc ).toString();
}
pollName = name;
}
add( new WC_WGLogo( "wgLogo", imageLocation, wgLogoLinkTarget, cycle ));
}
add( new WC_NavigationHead( "navHead", WP_CountEngine.this, cycle ));
add( new WC_NavPile( "navPile", navTab(cycle), cycle ));
final BundleFormatter bunW = cycle.bunW();
// Title
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
final String shortTitle = bunW.l( "s.wic.count.WP_CountEngine.tab.shortTitle" );
add( new Label( "title", shortTitle + " " + vS.serverName() + "/" + vS.name() ));
add( new Label( "h", shortTitle ));
// Links to resources
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{
final String loc = vS.pollwiki().uri().toASCIIString();
final ExternalLink tr = new ExternalLink( "pollwiki", loc ); // JavaScript link
tr.add( new Label( "th", bunW.l( "s.wic.count.WP_CountEngine.pollwiki" )));
tr.add( new ExternalLink( "td", loc, URIX.httpStripped( loc ))); // ordinary link nested in JavaScript link
add( tr );
}
add( new Label( "thVoteServer", shortTitle ));
add( new Label( "tdVoteServer", URIX.httpStripped(
cycle.uriFor(WP_CountEngine.class).toString() )));
}
// ````````````````````````````````````````````````````````````````````````````````````
// init for early use
/** The left-hand navigation tab, fetching the overview page
* (an instance of WP_CountEngine).
*/
public static final NavTab NAV_TAB = new NavTab()
{
private final Bookmark bookmark = new Bookmark( WP_CountEngine.class );
public @Override Bookmark bookmark() { return bookmark; }
public String shortTitle( VRequestCycle cycle )
{
return cycle.bunW().l( "s.wic.count.WP_CountEngine.tab.shortTitle" );
}
};
// ------------------------------------------------------------------------------------
/** The bar for navigating among the count engine pages.
*/
public static NavBar navBar() { return navBar; }
private static final NavBar navBar = new NavBar()
{
public SuperTab superTab() { return superTab; } // "Polls"
private final SuperTab superTab = new SuperTab( this )
{
public String shortTitle( VRequestCycle cycle )
{
return cycle.bunW().l( "s.wic.count.WP_CountEngine.superTab.shortTitle" );
}
};
public List tabList() { return tabList; }
private final ArrayListU tabList = new ArrayListU( new NavTab[]
{
// NAV_TAB.setNavBar( this ),
//// this page is largely empty at present, so leave it out of the nav bar
WP_Poll.NAV_TAB.setNavBar( this ),
WP_Votespace.NAV_TAB.setNavBar( this ),
WP_Rank.NAV_TAB.setNavBar( this ),
});
};
// - T a b b e d - P a g e ------------------------------------------------------------
/** @see #NAV_TAB
*/
public NavTab navTab( VRequestCycle cycle ) { return NAV_TAB; }
}