r273 - in trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui: . action model
Author: tchemit Date: 2008-04-01 02:26:00 +0000 (Tue, 01 Apr 2008) New Revision: 273 Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/VCSAbsractAction.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/VCSSynchAction.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIHandler.java Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java Log: ui-jaxx module Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/VCSAbsractAction.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/VCSAbsractAction.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/VCSAbsractAction.java 2008-04-01 02:26:00 UTC (rev 273) @@ -0,0 +1,36 @@ +/** + * # #% 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.VCSHandler; + +import javax.swing.AbstractAction; + +/** @author chemit */ +public abstract class VCSAbsractAction extends AbstractAction { + + protected final VCSAction action; + + protected transient VCSHandler handler; + + private static final long serialVersionUID = 1074145285171920255L; + + public VCSAbsractAction(VCSHandler handler, VCSAction action) { + this.handler = handler; + this.action = action; + } + +} Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/VCSSynchAction.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/VCSSynchAction.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/action/VCSSynchAction.java 2008-04-01 02:26:00 UTC (rev 273) @@ -0,0 +1,37 @@ +/** + * # #% 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.ui.model.SynchUIHandler; + +import java.awt.event.ActionEvent; + +/** @author chemit */ +public class VCSSynchAction extends VCSAbsractAction { + + private static final long serialVersionUID = 5214785331070517352L; + + protected transient SynchUIHandler uiHandler; + + public VCSSynchAction(SynchUIHandler uiHandler, VCSAction action) { + super(uiHandler.getModel().getHandler(), action); + this.uiHandler = uiHandler; + } + + public void actionPerformed(ActionEvent e) { + + } +} Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java 2008-04-01 02:25:29 UTC (rev 272) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java 2008-04-01 02:26:00 UTC (rev 273) @@ -168,12 +168,15 @@ return new VCSAction[0]; } List<VCSAction> result = new ArrayList<VCSAction>(); - for (VCSFileState vcsFileState : data) { - VCSAction action = vcsFileState.getAction(); - if (action != null && !result.contains(action)) { - result.add(action); + for (VCSState vcsFileState : getStates()) { + List<VCSAction> action = vcsFileState.getActions(); + for (VCSAction vcsAction : action) { + if (vcsAction != null && !result.contains(vcsAction)) { + result.add(vcsAction); + } } } return result.toArray(new VCSAction[result.size()]); } + } \ No newline at end of file Added: 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/model/SynchUIHandler.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIHandler.java 2008-04-01 02:26:00 UTC (rev 273) @@ -0,0 +1,62 @@ +/** + * # #% 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.model; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** @author chemit */ +public abstract class SynchUIHandler implements PropertyChangeListener { + + protected static Log log = LogFactory.getLog(SynchUIHandler.class); + + public void propertyChange(PropertyChangeEvent evt) { + //if (log.isDebugEnabled()) { + log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + //} + + } + + protected SynchUIHandler() { + } + + public abstract SynchUIModel getModel(); + + public void init() { + if (getModel() == null) { + throw new IllegalStateException("no model was defined for " + this); + } + getModel().addPropertyChangeListener(SynchUIModel.TAB_PROPERTY_CHANGED, this); + } + + public void dispatchAction(String action) { + if (action.endsWith("All")) { + doAllAction(action.substring(0, action.length() - 3)); + } else { + doSelectAction(action); + } + } + + protected void doSelectAction(String action) { + log.info(action); + } + + protected void doAllAction(String action) { + log.info(action); + } +} Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java 2008-04-01 02:25:29 UTC (rev 272) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java 2008-04-01 02:26:00 UTC (rev 273) @@ -18,15 +18,19 @@ import org.apache.commons.logging.LogFactory; import org.codelutin.vcs.VCSFileState; import org.codelutin.vcs.VCSHandler; +import org.codelutin.vcs.VCSAction; import static org.codelutin.vcs.ui.VCSUIConstants.ALL_MODEL_PROPERTY; import static org.codelutin.vcs.ui.VCSUIConstants.LOCAL_MODEL_PROPERTY; import static org.codelutin.vcs.ui.VCSUIConstants.REMOTE_MODEL_PROPERTY; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.TreeMap; /** @@ -39,6 +43,25 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static protected final Log log = LogFactory.getLog(SynchUIModel.class); + /** la propri�t� pour indiquer un changement de racine d'arbre */ + public static final String TAB_PROPERTY_CHANGED = "tab"; + + public static final String DIFF_ALL_PROPERTY_CHANGED = "diffAll"; + + public static final String COMMIT_ALL_PROPERTY_CHANGED = "commitAll"; + + public static final String UPDATE_ALL_PROPERTY_CHANGED = "updateAll"; + + public static final String REVERT_ALL_PROPERTY_CHANGED = "revertAll"; + + public static final String DIFF_PROPERTY_CHANGED = "diff"; + + public static final String COMMIT_PROPERTY_CHANGED = "commit"; + + public static final String UPDATE_PROPERTY_CHANGED = "update"; + + public static final String REVERT_PROPERTY_CHANGED = "revert"; + /** local root : wroking copy */ protected File localRoot; @@ -51,6 +74,14 @@ /** map of models */ protected Map<String, SynchVCSFileStatesModel> models; + /** support for change properties support */ + protected PropertyChangeSupport changeSupport; + + /** current tab displayed */ + protected AbstractVCSFileStatesModel tabModel; + /** current action to fired */ + protected VCSAction action; + public SynchUIModel() { } @@ -60,6 +91,33 @@ this.remoteRoot = remoteRoot; } + public VCSHandler getHandler() { + return handler; + } + + public AbstractVCSFileStatesModel getTabModel() { + return tabModel; + } + + public void setTabModel(AbstractVCSFileStatesModel tabModel) { + AbstractVCSFileStatesModel oldTabModel = this.tabModel; + this.tabModel = tabModel; + firePropertyChange(TAB_PROPERTY_CHANGED, oldTabModel, tabModel); + } + + public AbstractVCSFileStatesModel getTabModel(String tabModel) { + return getModel(tabModel); + } + + public String getTabModelName(AbstractVCSFileStatesModel model) { + for (Entry<String, SynchVCSFileStatesModel> entry : models.entrySet()) { + if (model.equals(entry.getValue())) { + return entry.getKey(); + } + } + return null; + } + public void setLocalRoot(File localRoot) { this.localRoot = localRoot; } @@ -103,6 +161,65 @@ getModel(REMOTE_MODEL_PROPERTY).removeData(remote.toArray(new VCSFileState[remote.size()])); } + public void doAllAction(VCSAction action) { + if (tabModel == null) { + return; + } + this.action = action; + firePropertyChange(action.name().toLowerCase() + "All", null, tabModel); + } + + 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); + } + protected Map<String, SynchVCSFileStatesModel> getModels() { if (models == null) { models = new TreeMap<String, SynchVCSFileStatesModel>();
participants (1)
-
tchemit@users.labs.libre-entreprise.org