Author: tchemit Date: 2008-04-02 09:14:33 +0000 (Wed, 02 Apr 2008) New Revision: 293 Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java Log: handler de l'ui synch Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java (from rev 276, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIHandler.java) =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java 2008-04-02 09:14:33 UTC (rev 293) @@ -0,0 +1,61 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.vcs.ui.action; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.vcs.VCSAction; +import org.codelutin.vcs.ui.model.SynchUIModel; +import org.codelutin.vcs.ui.model.SynchVCSFileStatesModel; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** @author chemit */ +public abstract class AbstractSynchUIHandler implements PropertyChangeListener { + + protected static Log log = LogFactory.getLog(AbstractSynchUIHandler.class); + + public void propertyChange(PropertyChangeEvent evt) { + //if (log.isDebugEnabled()) { + log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + //} + String action = evt.getPropertyName(); + SynchVCSFileStatesModel model = (SynchVCSFileStatesModel) evt.getNewValue(); + if (SynchUIModel.TAB_PROPERTY_CHANGED.equals(action)) { + doSelectTabAction(model); + } else if (action.endsWith("All")) { + String actionName = action.substring(0, action.length() - 3); + doAllAction(VCSAction.valueOf(actionName.toUpperCase()), model); + } else { + doSelectAction(VCSAction.valueOf(action.toUpperCase()), model); + } + } + + public abstract SynchUIModel getModel(); + + public abstract void doSelectAction(VCSAction action, SynchVCSFileStatesModel model); + + public abstract void doAllAction(VCSAction action, SynchVCSFileStatesModel model); + + public abstract void doSelectTabAction(SynchVCSFileStatesModel action); + + public void init() { + if (getModel() == null) { + throw new IllegalStateException("no model was defined for " + this); + } + getModel().addPropertyChangeListener(this); + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org