package votorola.s.gwt.stage.vote; // 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 com.google.gwt.user.client.ui.Widget; import votorola.a.count.*; import votorola.g.hold.*; import votorola.g.web.gwt.*; import votorola.g.web.gwt.event.*; /** A major component of a {@linkplain VoteTrackV track view}. */ public abstract class MajorV extends Widget { /** Creates a new MajorV. * * @see #place() * @see #trackV() */ MajorV( XCastRelation _place, VoteTrackV _trackV ) { place = _place; trackV = _trackV; } // ------------------------------------------------------------------------------------ /** The relative location of this view within its {@linkplain VoteTrackV parent}; one * of {@linkplain XCastRelation#VOTER VOTER} (left) {@linkplain * XCastRelation#CO_VOTER CO_VOTER} (center) or {@linkplain XCastRelation#CANDIDATE * CANDIDATE} (right). Co-voters are understood to include {@linkplain * votorola.a.count.XCastRelation#CO_BASE base co-candidates}, and are collectively * referred to as "cast peers". */ public final XCastRelation place() { return place; } private final XCastRelation place; /** The spool for the release of associated holds. When unwound it releases the holds * of this view, thereby disabling it. */ final Spool spool() { return spool; } private final Spool spool = new Spool1(); /** The overall view of which this view is a component. */ final VoteTrackV trackV() { // return (VoteTrackV)getParent().getParent(); /* ignore sporadic [cast] redundancy // warning. Left out it fails anyway (1.7 compiler bug?) */ //// too fragile during init, when parent may be unknown (failed on upgrade to GWT 2.5) return trackV; } private final VoteTrackV trackV; // - W i d g e t ---------------------------------------------------------------------- protected @Override final void onUnload() { super.onUnload(); spool.unwind(); } public @Override final void removeFromParent() { if( super.getParent() != null ) throw new UnsupportedOperationException(); } // - U I - O b j e c t --------------------------------------------------------------- /** Answers whether this view is nominally visible. Returns false if the visibility * style is "hidden", true otherwise. The value is bound via the {@linkplain * GWTX#bus() event bus} to property name visible. * * @see #setVisible(boolean) */ public @Override final boolean isVisible() { return !"hidden".equals( getElement().getStyle().getVisibility() ); } public @Override final void setVisible( final boolean toBe ) { if( toBe == isVisible() ) return; if( toBe ) getElement().getStyle().clearVisibility(); else getElement().getStyle().setVisibility( Style.Visibility.HIDDEN ); // as opposed to display='none', so it still affects spacing of layout GWTX.i().bus().fireEventFromSource( new PropertyChange("visible"), MajorV.this ); } }