001: /**
002: * Wizard Framework
003: * Copyright 2004 - 2005 Andrew Pietsch
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * $Id: WizardModel.java,v 1.13 2007/09/22 01:34:11 pietschy Exp $
020: */package org.pietschy.wizard;
021:
022: import org.pietschy.wizard.models.StaticModel;
023: import org.pietschy.wizard.models.MultiPathModel;
024:
025: import javax.swing.*;
026: import java.beans.PropertyChangeListener;
027: import java.beans.PropertyChangeEvent;
028: import java.util.Iterator;
029:
030: /**
031: * This interface defines the Model for wizards. It provides various methods for determining
032: * the steps of the wizard along with the current traversal state of the wizard. The {@link Wizard}
033: * monitors the model using a {@link PropertyChangeListener} so all changes to the model properties
034: * must fire {@link PropertyChangeEvent}s.
035: * <p>
036: * Most users should subclass either {@link StaticModel} or {@link MultiPathModel}. Implementors
037: * of more specialized models should consider extending {@link AbstractWizardModel} as it provides
038: * the basic methods and propery change management required by all models.
039: */
040: public interface WizardModel {
041:
042: /**
043: * Checks if the previous button should be enabled.
044: * @return <tt>true</tt> if the previou button should be enabled, <tt>false</tt> otherwise.
045: */
046: public boolean isPreviousAvailable();
047:
048: /**
049: * Checks if the next button should be enabled.
050: * @return <tt>true</tt> if the next button should be enabled, <tt>false</tt> otherwise.
051: */
052: public boolean isNextAvailable();
053:
054: /**
055: * Checks if the last button should be enabled.
056: * @return <tt>true</tt> if the last button should be enabled, <tt>false</tt> otherwise.
057: * @see #isLastVisible
058: */
059: public boolean isLastAvailable();
060:
061: /**
062: * Checks if the last button should be displayed. This method should only return true if
063: * the {@link #isLastAvailable} will return true at any point. Returning false will prevent
064: * the last button from appearing on the wizard at all.
065: * @return <tt>true</tt> if the last button should be displayed, <tt>false</tt> otherwise.
066: */
067: boolean isLastVisible();
068:
069: /**
070: * Increments the model the the next step and fires the appropriate property change events.
071: * This method must only be called if {@link #isNextAvailable} returns <tt>true</tt>.
072: */
073: public void nextStep();
074:
075: /**
076: * Takes the model back to the previsou step and fires the appropriate property change events.
077: * This method must only be called if {@link #isPreviousAvailable} returns <tt>true</tt>.
078: */
079: public void previousStep();
080:
081: /**
082: * Takes the model to the last step in the wizard and fires the appropriate property change
083: * events. This method must only be called if
084: * {@link #isLastAvailable} returns <tt>true</tt>.
085: */
086: public void lastStep();
087:
088: /**
089: * Takes the model back to the first step and fires the appropriate property change events.
090: */
091: public void reset();
092:
093: /**
094: * Gets the current active step the wizard should display.
095: * @return the active step.
096: */
097: public WizardStep getActiveStep();
098:
099: /**
100: * Checks if the specified step is the last step in the wizard.
101: * @param step the step to check
102: * @return <tt>true</tt> if its the final step in the wizard, <tt>false</tt> otherwise.
103: */
104: public boolean isLastStep(WizardStep step);
105:
106: /**
107: * Returns an iterator over all the steps in the model. The iteration order is not guarenteed
108: * to the be the order of traversal.
109: * @return an iterator over all the steps of the model
110: */
111: public Iterator stepIterator();
112:
113: /**
114: * Adds a {@link PropertyChangeListener} to this model.
115: * @param listener the listener to add.
116: */
117: public void addPropertyChangeListener(
118: PropertyChangeListener listener);
119:
120: /**
121: * Removes a {@link PropertyChangeListener} from this model.
122: * @param listener the listener to remove.
123: */
124: public void removePropertyChangeListener(
125: PropertyChangeListener listener);
126:
127: /**
128: * Adds a {@link PropertyChangeListener} to this model.
129: * @param propertyName the property to listen to.
130: * @param listener the listener to add.
131: */
132: public void addPropertyChangeListener(String propertyName,
133: PropertyChangeListener listener);
134:
135: /**
136: * Removes a {@link PropertyChangeListener} from this model.
137: * @param propertyName the property to stop listening to.
138: * @param listener the listener to remove.
139: */
140: public void removePropertyChangeListener(String propertyName,
141: PropertyChangeListener listener);
142:
143: /**
144: * Called to request the model to update it current state. This will be called when ever
145: * a step transition occurs but may also be called by the current {@link WizardStep} to
146: * force a refresh.
147: */
148: public void refreshModelState();
149:
150: boolean isCancelAvailable();
151: }
|