001package votorola.a.count.gwt; // Copyright 2011, 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 com.google.gwt.regexp.shared.*;
004import com.google.gwt.view.client.*;
005import votorola.g.web.gwt.*;
006
007
008/** The selection of a superaccount.
009  */
010public interface SacSelection extends SelectionModel<SacJS>
011{
012
013
014    /** The value pattern of an 'a' superaccount selection switch.  It takes one of two
015      * equivalent forms, as shown in this example:
016      *
017      *     <ul><li><code> vVotes </code></li>
018      *         <li><code> v'Votes </code></li></ul>
019      *
020      * <p>"v" is the {@linkplain CountingMethodJS.SwitchMnemonic mnemonic} for the
021      * counting method, and "Votes" is the {@linkplain SacJS#accountName() account name}.
022      * Either form is acceptable in this case.  The apostrophe form
023      * (<code>v'Votes</code>) is required only if the account name begins with an ASCII
024      * lower case letter a-z (example below), digit 0-9 or apostrophe:</p>
025      *
026      *   <ul><li><code> q'my account </code></li></ul>
027      *
028      * <p>A match against the pattern sets group 1 to the counting method mnemonic ("q"
029      * in this case) and 2 to the account name ("my account").</p>
030      */
031    public static final RegExp A_PATTERN = RegExp.compile( "^([a-z][a-z0-9]*)'?(.+)$" );
032
033
034
035   // - S a c - S e l e c t i o n --------------------------------------------------------
036
037
038    /** The 'a' superaccount selection switch (which ought not to be a switch).  It
039      * directly controls which superaccount is selected.  The form of the switch value is
040      * defined by {@linkplain #A_PATTERN A_PATTERN}.
041      *
042      * This ought not to be a switch and should be recoded when work resumes on the RAC.
043      * Account selection is not really a structural change to the UI and should not be
044      * stored as navigable state.  See {@linkplain votorola.s.gwt.scene.Scenes Scenes}
045      * for the reason.
046      *
047      *     @see #getSac()
048      */
049    public Switch aSacSwitch();
050
051
052
053    /** The count that is currently shown, or null if none is shown.  The value is bound
054      * via the {@linkplain GWTX#bus() event bus} to property name <tt>count</tt>.
055      */
056    public CountJS count();
057
058
059
060    /** The superaccount that is currently selected, or null if none is selected.  Null
061      * occurs only if no count is shown.
062      *
063      *     @see #setSac(SacJS)
064      */
065    public SacJS getSac();
066
067
068        /** Sets the superaccount that is currently selected.  It is equivalent to:<pre>
069          *
070          *     setSelected( newSac, true );</pre>
071          *
072          * <p>Setting the superaccount to null, or explicitly deselecting it, does not
073          * have the effect of actual deselection.  Rather it selects the {@linkplain
074          * CountJS#nullSuperaccount() null superaccount}.</p>
075          *
076          *     @see #getSac()
077          */
078        public void setSac( SacJS newSac );
079
080
081}