package votorola.s.gwt.mediawiki; // Copyright 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 com.google.gwt.dom.client.*; import votorola.s.gwt.stage.*; import votorola.s.gwt.stage.light.*; import votorola.s.gwt.stage.vote.*; import static votorola.a.count.CountNode.DART_SECTOR_MAX; /** The stage light for {@linkplain DifferenceShadows difference shadows}. */ final class ShadowLight extends DifferenceLight { /** Creates the ShadowLight. Create at most one for the entire life of the document, * as currently it does not unregister its listeners or otherwise clean up after * itself. */ ShadowLight( DifferenceShadows _shadows, DifferenceShadowsV _shadowsV, final Stage stage ) { super( VoteTrack.i(stage) ); shadows = _shadows; shadowsV = _shadowsV; init( stage ); } // - D i f f e r e n c e - L i g h t -------------------------------------------------- protected ShadowedDiff differenceFor( final String personName, final String pollName ) { return shadows.diffFor( personName, pollName ); } protected boolean hasDiffLooks() { return true; } protected @Override LightableDifference redirect() { final ShadowedDiff diff = (ShadowedDiff)super.redirect(); // safe cast, no setScene final DifferenceShadowsV.TopBox topBox = shadowsV.topBox(); final Text segCounter = topBox.segCounter(); final String bridgeImgSrc; if( diff == null ) { bridgeImgSrc = DifferenceShadowsV.SRC_DIFF_DISABLED; segCounter.setData( "\u00a0" ); // non-breaking space segCounter.getParentElement().getStyle().setVisibility( Style.Visibility.HIDDEN ); // counter span topBox.segCounterArrow().getStyle().setVisibility( Style.Visibility.HIDDEN ); } else { bridgeImgSrc = DifferenceShadowsV.SRC_DIFF; segCounter.setData( Integer.toString( diff.segmentCount() )); segCounter.getParentElement().getStyle().clearVisibility(); // to default topBox.segCounterArrow().getStyle().clearVisibility(); // to default } // ImageElement.as(topBox.bridgeLink().getFirstChild()).setSrc( bridgeImgSrc ); /// GWT BUG, 'as' resolves to Element ((ImageElement)topBox.bridgeLink().getFirstChild()).setSrc( bridgeImgSrc ); return diff; } protected void run( final LightableDifference.Runner r ) { shadows.run( r ); } //// P r i v a t e /////////////////////////////////////////////////////////////////////// private final DifferenceShadows shadows; private final DifferenceShadowsV shadowsV; }