r1966 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard: . ext
Author: tchemit Date: 2010-06-14 14:07:18 +0200 (Mon, 14 Jun 2010) New Revision: 1966 Url: http://nuiton.org/repositories/revision/jaxx/1966 Log: share busy state for all models introduce a busy state listener to update cursor of container Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/BusyChangeListener.java Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/ext/WizardExtModel.java Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/BusyChangeListener.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/BusyChangeListener.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/BusyChangeListener.java 2010-06-14 12:07:18 UTC (rev 1966) @@ -0,0 +1,72 @@ +package jaxx.runtime.swing.wizard; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.Component; +import java.awt.Cursor; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** + * To listen the busy state of a {@link WizardModel}. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.1 + */ +public class BusyChangeListener implements PropertyChangeListener { + + /** Logger */ + private static final Log log = LogFactory.getLog(BusyChangeListener.class); + + protected Cursor busyCursor; + + protected Cursor defaultCursor; + + protected final Component ui; + + public BusyChangeListener(Component ui) { + this.ui = ui; + } + + public Component getUi() { + return ui; + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + Boolean value = (Boolean) evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug("busy state changed to " + value); + } + if (value != null && value) { + setBusy(ui, getBusyCursor()); + + + } else { + setUnBusy(ui, getDefaultCursor()); + } + } + + protected void setBusy(Component ui, Cursor busyCursor) { + ui.setCursor(busyCursor); + } + + protected void setUnBusy(Component ui, Cursor unbusyCursor) { + ui.setCursor(unbusyCursor); + } + + protected Cursor getBusyCursor() { + if (busyCursor == null) { + busyCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); + } + return busyCursor; + } + + protected Cursor getDefaultCursor() { + if (defaultCursor == null) { + defaultCursor = Cursor.getDefaultCursor(); + } + return defaultCursor; + } +} Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/BusyChangeListener.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2010-06-12 14:22:33 UTC (rev 1965) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2010-06-14 12:07:18 UTC (rev 1966) @@ -57,6 +57,8 @@ public static final String VALID_STEP_PROPERTY_NAME = "validStep"; + public static final String BUSY_PROPERTY_NAME = "busy"; + /** le type d'une etape du model (doit etre une enumeration) */ protected final Class<E> stepClass; @@ -72,6 +74,9 @@ /** drapeau pour valider l'état de l'étape courante */ protected boolean validStep; + /** un drapeau pour savoir si le modèle est occupé. */ + private boolean busy; + /** * drapeau lorsque le modele effectue des operations de transformation de * modele mais que les écouteurs ne devraient pas tenir compte des @@ -193,6 +198,16 @@ return valueAdjusting; } + public boolean isBusy() { + return busy; + } + + public void setBusy(boolean busy) { + boolean oldValue = this.busy; + this.busy = busy; + firePropertyChange(BUSY_PROPERTY_NAME, oldValue, busy); + } + /** * Change l'univers des etapes. * <p/> Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/ext/WizardExtModel.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/ext/WizardExtModel.java 2010-06-12 14:22:33 UTC (rev 1965) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/ext/WizardExtModel.java 2010-06-14 12:07:18 UTC (rev 1966) @@ -49,8 +49,6 @@ /** Logger */ private static final Log log = LogFactory.getLog(WizardExtModel.class); - public static final String BUSY_PROPERTY_NAME = "busy"; - public static final String OPERATIONS_PROPERTY_NAME = "operations"; public static final String STEP_STATE_PROPERTY_NAME = "stepState"; @@ -74,9 +72,6 @@ /** un drapeau pour savoir siune opération a été lancée */ protected boolean wasStarted; - /** un drapeau pour savoir si le modèle est occupé. */ - protected boolean busy; - @SuppressWarnings("unchecked") public <T extends Enum<T>> WizardExtModel(Class<E> stepClass, E... steps) { super(stepClass, steps); @@ -98,16 +93,6 @@ return wasStarted; } - public boolean isBusy() { - return busy; - } - - public void setBusy(boolean busy) { - boolean oldValue = this.busy; - this.busy = busy; - firePropertyChange(BUSY_PROPERTY_NAME, oldValue, busy); - } - public boolean containsOperation(E step) { return getOperations().contains(step); }
participants (1)
-
tchemit@users.nuiton.org