Author: tchemit Date: 2008-04-03 17:00:51 +0000 (Thu, 03 Apr 2008) New Revision: 303 Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractConfirmUIHandler.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractDiffUIHandler.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractUIHandler.java Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java Log: handlers d'ui Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractConfirmUIHandler.java (from rev 298, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java) =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractConfirmUIHandler.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractConfirmUIHandler.java 2008-04-03 17:00:51 UTC (rev 303) @@ -0,0 +1,57 @@ +/** + * # #% 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.codelutin.vcs.VCSAction; +import org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel; +import org.codelutin.vcs.ui.model.ConfirmUIModel; + +import javax.swing.ListSelectionModel; +import java.beans.PropertyChangeEvent; + +/** @author chemit */ +public abstract class AbstractConfirmUIHandler extends AbstractUIHandler<ConfirmUIModel> { + + protected abstract void updateUI(); + + public void propertyChange(PropertyChangeEvent evt) { + //if (log.isDebugEnabled()) { + log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + //} + String action = evt.getPropertyName(); + + if (ConfirmUIModel.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 + } + } + + 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); + } + +} \ No newline at end of file Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractDiffUIHandler.java (from rev 298, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java) =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractDiffUIHandler.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractDiffUIHandler.java 2008-04-03 17:00:51 UTC (rev 303) @@ -0,0 +1,59 @@ +/** + * # #% 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.codelutin.vcs.VCSAction; +import org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.ui.model.DiffUIModel; +import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel; + +import java.beans.PropertyChangeEvent; + +/** @author chemit */ +public abstract class AbstractDiffUIHandler extends AbstractUIHandler<DiffUIModel> { + + public void propertyChange(PropertyChangeEvent evt) { + //if (log.isDebugEnabled()) { + log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + //} + String action = evt.getPropertyName(); + + if (DiffUIModel.TAB_PROPERTY_CHANGED.equals(action)) { + doSelectTab((SimpleVCSFileStatesModel) evt.getNewValue()); + } else { + if (DiffUIModel.FILE_PROPERTY_CHANGED.equals(action)) { + doSelectFile((VCSFileState) evt.getNewValue()); + } else { + try { + VCSAction vcsAction = VCSAction.valueOf(action.toUpperCase()); + doAction(vcsAction, (VCSFileState) evt.getNewValue()); + } catch (IllegalArgumentException e) { + // ignore ite + } + } + } + } + + public abstract void doSelectTab(SimpleVCSFileStatesModel action); + + public abstract void doSelectFile(VCSFileState model); + + public abstract void doAction(VCSAction action, VCSFileState model); + + public abstract void gotoNextDiff(); + + public abstract void gotoPreviousDiff(); + +} \ No newline at end of file Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java 2008-04-03 16:59:29 UTC (rev 302) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractSynchUIHandler.java 2008-04-03 17:00:51 UTC (rev 303) @@ -14,48 +14,46 @@ */ 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.SimpleVCSFileStatesModel; 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 { +public abstract class AbstractSynchUIHandler extends AbstractUIHandler<SynchUIModel> { - 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(); + SimpleVCSFileStatesModel model = (SimpleVCSFileStatesModel) 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); + try { + String actionName = action.substring(0, action.length() - 3); + VCSAction vcsAction = VCSAction.valueOf(actionName.toUpperCase()); + doAllAction(vcsAction, model); + } catch (IllegalArgumentException e) { + // ignore it ? + } } else { - doSelectAction(VCSAction.valueOf(action.toUpperCase()), model); + try { + VCSAction vcsAction = VCSAction.valueOf(action.toUpperCase()); + doSelectAction(vcsAction, model); + } catch (IllegalArgumentException e) { + // ignore it ? + } + } } - public abstract SynchUIModel getModel(); + public abstract void doSelectAction(VCSAction action, SimpleVCSFileStatesModel model); - public abstract void doSelectAction(VCSAction action, SynchVCSFileStatesModel model); + public abstract void doAllAction(VCSAction action, SimpleVCSFileStatesModel model); - public abstract void doAllAction(VCSAction action, SynchVCSFileStatesModel model); + public abstract void doSelectTabAction(SimpleVCSFileStatesModel action); - public abstract void doSelectTabAction(SynchVCSFileStatesModel action); - - public void init() { - if (getModel() == null) { - throw new IllegalStateException("no model was defined for " + this); - } - getModel().addPropertyChangeListener(this); - } } Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractUIHandler.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/AbstractUIHandler.java 2008-04-03 17:00:51 UTC (rev 303) @@ -0,0 +1,42 @@ +/** + * # #% 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.ui.model.AbstractUIModel; + +import javax.swing.ListSelectionModel; +import javax.swing.JDialog; +import java.beans.PropertyChangeListener; + +/** @author chemit */ +public abstract class AbstractUIHandler<M extends AbstractUIModel> implements PropertyChangeListener { + + protected static Log log = LogFactory.getLog(AbstractConfirmUIHandler.class); + + public abstract M getModel(); + + public abstract JDialog getUi(); + + public abstract ListSelectionModel getSelectionModel(); + + public void init() { + if (getModel() == null) { + throw new IllegalStateException("no model was defined for " + this); + } + getModel().addPropertyChangeListener(this); + } +}