Author: tchemit Date: 2008-04-16 21:07:57 +0000 (Wed, 16 Apr 2008) New Revision: 530 Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIModel.java Log: using jaxx class Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUI.java 2008-04-16 20:57:35 UTC (rev 529) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUI.java 2008-04-16 21:07:57 UTC (rev 530) @@ -14,15 +14,6 @@ */ package org.codelutin.vcs.ui.util; -import org.codelutin.vcs.ui.action.HelpAction; -import org.codelutin.vcs.ui.action.ShowConfigAction; - -import javax.swing.AbstractAction; -import javax.swing.AbstractButton; -import javax.swing.JDialog; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; - /** * A abstract dialog contract to be realised by a dialog * <p/> @@ -30,51 +21,13 @@ * * @author chemit */ -public abstract class AbstractUI<H extends AbstractUIHandler> extends JDialog implements WindowListener { +public abstract class AbstractUI<H extends AbstractUIHandler> extends jaxx.DialogUI<H> { - private H handler; - - public abstract AbstractButton getHelp(); - - protected AbstractUI() { - UIHelper.setQuitAction(this); - addWindowListener(this); + protected javax.swing.AbstractAction createHelpAction() { + return org.codelutin.vcs.ui.action.HelpAction.createAction(this); } - public H getHandler() { - return handler; + protected javax.swing.AbstractAction createShowConfigAction() { + return org.codelutin.vcs.ui.action.ShowConfigAction.createAction(this); } - - public void setHandler(H handler) { - this.handler = handler; - } - - protected AbstractAction createHelpAction() { - return HelpAction.createAction(this); - } - - protected AbstractAction createShowConfigAction() { - return ShowConfigAction.createAction(this); - } - - public void windowOpened(WindowEvent e) { - } - - public void windowClosed(WindowEvent e) { - } - - public void windowClosing(WindowEvent e) { - } - - public void windowIconified(WindowEvent e) { - } - - public void windowDeiconified(WindowEvent e) { - } - - public void windowActivated(WindowEvent e) { - } - - public void windowDeactivated(WindowEvent e) { - } } Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java 2008-04-16 20:57:35 UTC (rev 529) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) @@ -14,47 +14,14 @@ */ package org.codelutin.vcs.ui.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.beans.PropertyChangeListener; - /** * TODO Move this classe in jaxx * * @author chemit */ -public abstract class AbstractUIHandler<M extends AbstractUIModel, U extends AbstractUI<? extends AbstractUIHandler>> implements PropertyChangeListener { +public abstract class AbstractUIHandler<M extends AbstractUIModel, U extends AbstractUI<? extends AbstractUIHandler>> extends jaxx.DialogUIHandler<M, U> { - protected static Log log = LogFactory.getLog(AbstractUIHandler.class); - - /** ui handled */ - private U ui; - - /** model handled */ - private M model; - protected AbstractUIHandler(U ui, M model) { - this.ui = ui; - this.model = model; + super(ui, model); } - - public final U getUi() { - return ui; - } - - public final M getModel() { - return model; - } - - public void init() { - if (model == null) { - throw new IllegalStateException("no model was defined for " + this); - } - model.addPropertyChangeListener(this); - } - - public void dispose() { - model.removePropertyChangeListener(this); - } } Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIModel.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIModel.java 2008-04-16 20:57:35 UTC (rev 529) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIModel.java 2008-04-16 21:07:57 UTC (rev 530) @@ -14,77 +14,14 @@ */ package org.codelutin.vcs.ui.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import jaxx.DialogUIModel; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - /** * TODO Move this classe in jaxx * Abstract ui model, with property change support. * * @author chemit */ -public abstract class AbstractUIModel { +public abstract class AbstractUIModel extends DialogUIModel { - static protected final Log log = LogFactory.getLog(AbstractUIModel.class); - - /** support for change properties support */ - protected PropertyChangeSupport changeSupport; - - protected AbstractUIModel() { - - } - - public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - if (listener == null) { - return; - } - if (changeSupport == null) { - changeSupport = new PropertyChangeSupport(this); - } - changeSupport.addPropertyChangeListener(propertyName, listener); - } - - public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { - if (listener == null) { - return; - } - if (changeSupport == null) { - changeSupport = new PropertyChangeSupport(this); - } - changeSupport.addPropertyChangeListener(listener); - } - - public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { - if (listener == null || changeSupport == null) { - return; - } - changeSupport.removePropertyChangeListener(listener); - } - - public synchronized void removePropertyChangeListeners() { - if (changeSupport == null) { - return; - } - for (PropertyChangeListener listener : getPropertyChangeListeners()) { - changeSupport.removePropertyChangeListener(listener); - } - } - - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { - if (changeSupport == null) { - return new PropertyChangeListener[0]; - } - return changeSupport.getPropertyChangeListeners(); - } - - public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - if (changeSupport == null || (oldValue == null && newValue == null) || - (oldValue != null && oldValue.equals(newValue))) { - return; - } - changeSupport.firePropertyChange(propertyName, oldValue, newValue); - } }