Author: tchemit Date: 2008-04-03 22:21:13 +0000 (Thu, 03 Apr 2008) New Revision: 327 Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties Log: vcsHandler in UIHandler Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java 2008-04-03 22:19:40 UTC (rev 326) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java 2008-04-03 22:21:13 UTC (rev 327) @@ -15,44 +15,76 @@ package org.codelutin.vcs.ui.handler; import org.codelutin.vcs.VCSAction; +import org.codelutin.vcs.VCSActionManager; import org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.VCSHandler; +import org.codelutin.vcs.ui.VCSUIConstants; import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel; import org.codelutin.vcs.ui.model.ConfirmUIModel; -import org.codelutin.vcs.ui.VCSUIConstants; -import javax.swing.ListSelectionModel; import java.beans.PropertyChangeEvent; -/** @author chemit */ +/** + * Abstract ConfirmUI handler + * + * @author chemit + */ public abstract class AbstractConfirmUIHandler extends AbstractUIHandler<ConfirmUIModel> { + protected final VCSActionManager actionManager; + + + protected AbstractConfirmUIHandler(VCSHandler handler) { + super(handler); + this.actionManager = new VCSActionManager(handler); + } + protected abstract void updateUI(); + protected abstract void updateMessageUI(); + public void propertyChange(PropertyChangeEvent evt) { - //if (log.isDebugEnabled()) { - log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); - //} + if (log.isDebugEnabled()) { + log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + } String action = evt.getPropertyName(); if (VCSUIConstants.ACTION_PROPERTY_CHANGED.equals(action)) { updateUI(); return; } - try { - String commitMessage = (String) evt.getNewValue(); - VCSAction vcsAction = VCSAction.valueOf(action.toUpperCase()); - doAction(vcsAction, commitMessage, getModel().getModel()); - } catch (IllegalArgumentException e) { - // ignore ite + + if (VCSUIConstants.MESSAGE_HISTORY_PROPERTY_CHANGED.equals(action)) { + updateMessageUI(); + return; } + + throw new IllegalStateException("unimplemented property changed : " + evt); } - public void doAction(VCSAction action, String commitMessage, AbstractVCSFileStatesModel model) { - ListSelectionModel selectionModel = getSelectionModel(); - model.select(action, selectionModel, false); - VCSFileState[] data = model.getData(selectionModel); - //TODO fire vcs action on given data - log.info("action:" + action + ", message:" + commitMessage + ", nb files:" + data.length); + public void doAction(String commitMessage, AbstractVCSFileStatesModel model) { + + VCSAction action = getModel().getAction(); + + VCSFileState[] data = selectData(model, action, false); + + if (action.isCommit()) { + getModel().addCommitMessage(commitMessage); + + } else { + commitMessage = null; + } + + if (log.isDebugEnabled()) { + log.debug("action:" + action + ", message:" + commitMessage + ", nb files:" + data.length); + } + + actionManager.add(action, data); + + // dispose ui + getUi().dispose(); + } + } \ No newline at end of file Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java 2008-04-03 22:19:40 UTC (rev 326) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java 2008-04-03 22:21:13 UTC (rev 327) @@ -16,6 +16,7 @@ import org.codelutin.vcs.VCSAction; import org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.VCSHandler; import org.codelutin.vcs.ui.model.DiffUIModel; import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel; import org.codelutin.vcs.ui.VCSUIConstants; @@ -25,6 +26,10 @@ /** @author chemit */ public abstract class AbstractDiffUIHandler extends AbstractUIHandler<DiffUIModel> { + protected AbstractDiffUIHandler(VCSHandler handler) { + super(handler); + } + public void propertyChange(PropertyChangeEvent evt) { //if (log.isDebugEnabled()) { log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java 2008-04-03 22:19:40 UTC (rev 326) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java 2008-04-03 22:21:13 UTC (rev 327) @@ -15,6 +15,7 @@ package org.codelutin.vcs.ui.handler; import org.codelutin.vcs.VCSAction; +import org.codelutin.vcs.VCSHandler; import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel; import org.codelutin.vcs.ui.model.SynchUIModel; import org.codelutin.vcs.ui.VCSUIConstants; @@ -24,6 +25,10 @@ /** @author chemit */ public abstract class AbstractSynchUIHandler extends AbstractUIHandler<SynchUIModel> { + protected AbstractSynchUIHandler(VCSHandler handler) { + super(handler); + } + public void propertyChange(PropertyChangeEvent evt) { //if (log.isDebugEnabled()) { log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java 2008-04-03 22:19:40 UTC (rev 326) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java 2008-04-03 22:21:13 UTC (rev 327) @@ -17,6 +17,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.vcs.ui.model.AbstractUIModel; +import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel; +import org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.VCSAction; +import org.codelutin.vcs.VCSHandler; import javax.swing.ListSelectionModel; import javax.swing.JDialog; @@ -33,10 +37,27 @@ public abstract ListSelectionModel getSelectionModel(); + /** vcs handler to use (lazy instanciation) */ + protected VCSHandler handler; + + public VCSHandler getHandler() { + return handler; + } + + protected AbstractUIHandler(VCSHandler handler) { + this.handler = handler; + } + public void init() { if (getModel() == null) { throw new IllegalStateException("no model was defined for " + this); } getModel().addPropertyChangeListener(this); } + + protected VCSFileState[] selectData(AbstractVCSFileStatesModel model, VCSAction action, boolean b) { + ListSelectionModel selectionModel = getSelectionModel(); + model.select(action, selectionModel, b); + return model.getData(selectionModel); + } } Modified: trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties 2008-04-03 22:19:40 UTC (rev 326) +++ trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties 2008-04-03 22:21:13 UTC (rev 327) @@ -1,6 +1,7 @@ lutinvcs.error.checkout.dir=Can''t checkout dir {0} lutinvcs.error.init.config=config is not init, you should invoke on the config validate(true) method to validate it and finish his init {0} lutinvcs.error.init.no.config=should invoke {0}\#init(VCSType,Properties) before required instance. +lutinvcs.error.thread.action= lutinvcs.file=File lutinvcs.module=Module lutinvcs.status=Status Modified: trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties 2008-04-03 22:19:40 UTC (rev 326) +++ trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties 2008-04-03 22:21:13 UTC (rev 327) @@ -1,6 +1,7 @@ lutinvcs.error.checkout.dir=Can''t checkout dir {0} lutinvcs.error.init.config=config is not init, you should invoke on the config validate(true) method to validate it and finish his init {0} lutinvcs.error.init.no.config=should invoke {0}\#init(VCSType,Properties) before required instance. +lutinvcs.error.thread.action= lutinvcs.file=Fichier lutinvcs.module=Module lutinvcs.status=Status
participants (1)
-
tchemit@users.labs.libre-entreprise.org