Author: tchemit Date: 2008-04-03 17:01:02 +0000 (Thu, 03 Apr 2008) New Revision: 304 Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSFileStatesModel.java Removed: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchVCSFileStatesModel.java Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java Log: model d'uis Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java 2008-04-03 17:01:02 UTC (rev 304) @@ -0,0 +1,108 @@ +/** + * # #% 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 org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.VCSHandler; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.List; + +/** @author chemit */ +public abstract class AbstractUIModel { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static protected final Log log = LogFactory.getLog(AbstractUIModel.class); + + /** vcs handler to use (lazy instanciation) */ + protected VCSHandler handler; + /** support for change properties support */ + protected PropertyChangeSupport changeSupport; + + public VCSHandler getHandler() { + return handler; + } + + public abstract void setData(List<VCSFileState> states); + + public abstract void addData(List<VCSFileState> states); + + public abstract void removeData(List<VCSFileState> states); + + protected void splitStates(List<VCSFileState> states, List<VCSFileState> local, List<VCSFileState> remote) { + for (VCSFileState state : states) { + if (state.getState() != null && state.getState().isLocal()) { + local.add(state); + } + if (state.getState() != null && state.getState().isRemote()) { + remote.add(state); + } + } + } + + 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); + } +} Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java 2008-04-03 17:01:02 UTC (rev 304) @@ -0,0 +1,106 @@ +/** + * # #% 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.codelutin.vcs.VCSAction; +import org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.VCSHandler; + +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * Model of a repository + * + * @author chemit + */ +public class ConfirmUIModel extends AbstractUIModel { + + + /** la propri�t� pour indiquer un changement de racine d'arbre */ + public static final String ACTION_PROPERTY_CHANGED = "tab"; + + /** local root : wroking copy */ + protected URL localRoot; + + /** remote root : remote url */ + protected URL remoteRoot; + + /** model */ + protected SimpleVCSFileStatesModel model; + + /** current action to fired */ + protected VCSAction action; + + protected List<String> messageHistory; + + public ConfirmUIModel() { + } + + public ConfirmUIModel(VCSHandler handler, URL leftRoot, URL rightRoot) { + this.handler = handler; + this.localRoot = leftRoot; + this.remoteRoot = rightRoot; + } + + public AbstractVCSFileStatesModel getModel() { + if (model == null) { + model = new SimpleVCSFileStatesModel(action + ""); + } + return model; + } + + public List<String> getMessageHistory() { + if (messageHistory == null) { + messageHistory = new ArrayList<String>(); + } + return messageHistory; + } + + public void setData(List<VCSFileState> states) { + getModel().setData(states); + } + + public void addData(List<VCSFileState> states) { + getModel().addData(states.toArray(new VCSFileState[states.size()])); + } + + public void removeData(List<VCSFileState> states) { + getModel().removeData(states.toArray(new VCSFileState[states.size()])); + } + + public void doAction(String commitMesssage) { + if (model == null || action == null) { + return; + } + if (commitMesssage != null && !getMessageHistory().contains(commitMesssage)) { + getMessageHistory().add(commitMesssage); + } + firePropertyChange(action.name().toLowerCase(), null, commitMesssage); + } + + public void setAction(VCSAction action) { + VCSAction oldAction = this.action; + this.action = action; + firePropertyChange(ACTION_PROPERTY_CHANGED, oldAction, action); + } + + public VCSAction getAction() { + return action; + } + + +} \ No newline at end of file Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java 2008-04-03 17:01:02 UTC (rev 304) @@ -0,0 +1,157 @@ +/** + * # #% 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 org.codelutin.vcs.VCSAction; +import org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.VCSHandler; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.net.URL; + +/** + * Model of a diff panel (remote content vs local content + * + * @author chemit + */ +public class DiffPanelUIModel { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static protected final Log log = LogFactory.getLog(DiffPanelUIModel.class); + + /** local root : wroking copy */ + protected URL leftRoot; + + /** remote root : remote url */ + protected URL rightRoot; + + /** vcs handler to use (lazy instanciation) */ + protected VCSHandler handler; + + /** map of models */ + protected VCSFileState model; + + /** support for change properties support */ + protected PropertyChangeSupport changeSupport; + + /** local content */ + protected String leftContent; + + /** remote content */ + protected String rightContent; + + /** current action to fired */ + protected VCSAction action; + + public DiffPanelUIModel() { + } + + public DiffPanelUIModel(VCSHandler handler, URL leftRoot, URL rightRoot) { + this.handler = handler; + this.leftRoot = leftRoot; + this.rightRoot = rightRoot; + } + + public VCSHandler getHandler() { + return handler; + } + + public URL getLeftRoot() { + return leftRoot; + } + + public URL getRightRoot() { + return rightRoot; + } + + public String getLeftContent() { + return leftContent; + } + + public String getRightContent() { + return rightContent; + } + + public void setLeftContent(String leftContent) { + this.leftContent = leftContent; + } + + public void setLeftRoot(URL leftRoot) { + this.leftRoot = leftRoot; + } + + public void setRightContent(String rightContent) { + this.rightContent = rightContent; + } + + public void setRightRoot(URL rightRoot) { + this.rightRoot = rightRoot; + } + + 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); + } + +} \ No newline at end of file Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java (from rev 298, 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/DiffUIModel.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java 2008-04-03 17:01:02 UTC (rev 304) @@ -0,0 +1,172 @@ +/** + * # #% 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.codelutin.vcs.VCSAction; +import org.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.VCSHandler; +import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_ALL_MODEL_PROPERTY; +import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_LOCAL_MODEL_PROPERTY; +import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_REMOTE_MODEL_PROPERTY; + +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * Model of a repository + * + * @author chemit + */ +public class DiffUIModel extends AbstractUIModel { + + /** property to indicate change tab */ + public static final String TAB_PROPERTY_CHANGED = "tab"; + + /** property to indicate change file (display a new DiffPanelUI) */ + public static final String FILE_PROPERTY_CHANGED = "file"; + + public static final String NEXT_DIFF_PROPERTY_CHANGED = "nextDiff"; + + public static final String PREVIOUS_DIFF_PROPERTY_CHANGED = "previousDiff"; + + public static final String REFRESH_PROPERTY_CHANGED = "refresh"; + + 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 URL leftRoot; + + /** remote root : remote url */ + protected URL rightRoot; + + /** map of models */ + protected List<SimpleVCSFileStatesModel> models; + + /** current tab displayed */ + protected AbstractVCSFileStatesModel tabModel; + + /** current file displayed */ + protected VCSFileState fileModel; + + /** current action to fired */ + protected VCSAction action; + + public DiffUIModel() { + } + + public DiffUIModel(VCSHandler handler, URL leftRoot, URL rightRoot) { + this.handler = handler; + this.leftRoot = leftRoot; + this.rightRoot = rightRoot; + } + + public AbstractVCSFileStatesModel getTabModel() { + return tabModel; + } + + public void setTabModel(AbstractVCSFileStatesModel tabModel) { + AbstractVCSFileStatesModel oldTabModel = this.tabModel; + this.tabModel = tabModel; + firePropertyChange(TAB_PROPERTY_CHANGED, oldTabModel, tabModel); + } + + public void setFileModel(VCSFileState fileModel) { + VCSFileState oldFileModel = this.fileModel; + this.fileModel = fileModel; + firePropertyChange(TAB_PROPERTY_CHANGED, oldFileModel, tabModel); + } + + public AbstractVCSFileStatesModel getTabModel(String tabModel) { + return getModel(tabModel); + } + + public void setLeftRoot(URL leftRoot) { + this.leftRoot = leftRoot; + } + + public void setRightRoot(URL rightRoot) { + this.rightRoot = rightRoot; + } + + public SimpleVCSFileStatesModel getModel(String modelName) { + SimpleVCSFileStatesModel tableModel = null; + for (SimpleVCSFileStatesModel model : getModels()) { + if (modelName.equals(model.getName())) { + tableModel = model; + break; + } + } + if (tableModel == null) { + getModels().add(tableModel = new SimpleVCSFileStatesModel(modelName)); + } + return tableModel; + } + + public void doAllAction(VCSAction action) { + if (tabModel == null) { + return; + } + this.action = action; + firePropertyChange(action.name().toLowerCase() + "All", null, tabModel); + } + + public void setData(List<VCSFileState> states) { + getModel(SYNCH_ALL_MODEL_PROPERTY).setData(states); + List<VCSFileState> local = new ArrayList<VCSFileState>(); + List<VCSFileState> remote = new ArrayList<VCSFileState>(); + splitStates(states, local, remote); + getModel(SYNCH_LOCAL_MODEL_PROPERTY).setData(local); + getModel(SYNCH_REMOTE_MODEL_PROPERTY).setData(remote); + } + + public void addData(List<VCSFileState> states) { + getModel(SYNCH_ALL_MODEL_PROPERTY).setData(states); + List<VCSFileState> local = new ArrayList<VCSFileState>(); + List<VCSFileState> remote = new ArrayList<VCSFileState>(); + splitStates(states, local, remote); + getModel(SYNCH_LOCAL_MODEL_PROPERTY).addData(local.toArray(new VCSFileState[local.size()])); + getModel(SYNCH_REMOTE_MODEL_PROPERTY).addData(remote.toArray(new VCSFileState[remote.size()])); + } + + public void removeData(List<VCSFileState> states) { + getModel(SYNCH_ALL_MODEL_PROPERTY).removeData(states.toArray(new VCSFileState[states.size()])); + List<VCSFileState> local = new ArrayList<VCSFileState>(); + List<VCSFileState> remote = new ArrayList<VCSFileState>(); + splitStates(states, local, remote); + getModel(SYNCH_LOCAL_MODEL_PROPERTY).removeData(local.toArray(new VCSFileState[local.size()])); + getModel(SYNCH_REMOTE_MODEL_PROPERTY).removeData(remote.toArray(new VCSFileState[remote.size()])); + } + + public void doAction(VCSAction action) { + if (tabModel == null) { + return; + } + this.action = action; + firePropertyChange(action.name().toLowerCase(), null, tabModel); + } + + protected List<SimpleVCSFileStatesModel> getModels() { + if (models == null) { + models = new ArrayList<SimpleVCSFileStatesModel>(); + } + return models; + } + +} \ No newline at end of file Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSFileStatesModel.java (from rev 301, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchVCSFileStatesModel.java) =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSFileStatesModel.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSFileStatesModel.java 2008-04-03 17:01:02 UTC (rev 304) @@ -0,0 +1,49 @@ +/** + * # #% 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.codelutin.vcs.VCSFileState; +import org.codelutin.vcs.VCSState; +import org.codelutin.vcs.ui.VCSUIConstants; + +/** @author chemit */ +public class SimpleVCSFileStatesModel extends AbstractVCSFileStatesModel { + + private static final long serialVersionUID = -7592705623128585146L; + + public SimpleVCSFileStatesModel(String name) { + super(name, VCSUIConstants.SIMPLE_COLUMNS_NAMES); + } + + public Object getValueAt(int rowIndex, int columnIndex) { + if (isEmpty()) return null; + VCSFileState item = data.get(rowIndex); + Object result = null; + if (columnIndex == 0) { + // get module + result = item.getModuleName(); + } else if (columnIndex == 1) { + // get file + result = item.getModuleRelativeFileName(); + } else if (columnIndex == 2) { + // get status + VCSState state = item.getState(); + result = state == null ? null : state.libelle(); + } + return result; + } + + +} \ No newline at end of file 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-03 17:00:51 UTC (rev 303) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java 2008-04-03 17:01:02 UTC (rev 304) @@ -14,17 +14,13 @@ */ package org.codelutin.vcs.ui.model; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.codelutin.vcs.VCSAction; import org.codelutin.vcs.VCSFileState; import org.codelutin.vcs.VCSHandler; -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 static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_ALL_MODEL_PROPERTY; +import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_LOCAL_MODEL_PROPERTY; +import static org.codelutin.vcs.ui.VCSUIConstants.SYNCH_REMOTE_MODEL_PROPERTY; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; import java.io.File; import java.net.URL; import java.util.ArrayList; @@ -35,11 +31,8 @@ * * @author chemit */ -public class SynchUIModel { +public class SynchUIModel extends AbstractUIModel { - /** 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"; @@ -65,15 +58,9 @@ /** remote root : remote url */ protected URL remoteRoot; - /** vcs handler to use (lazy instanciation) */ - protected VCSHandler handler; - /** map of models */ - protected List<SynchVCSFileStatesModel> models; + protected List<SimpleVCSFileStatesModel> models; - /** support for change properties support */ - protected PropertyChangeSupport changeSupport; - /** current tab displayed */ protected AbstractVCSFileStatesModel tabModel; @@ -115,45 +102,45 @@ this.remoteRoot = remoteRoot; } - public SynchVCSFileStatesModel getModel(String modelName) { - SynchVCSFileStatesModel tableModel = null; - for (SynchVCSFileStatesModel model : getModels()) { + public SimpleVCSFileStatesModel getModel(String modelName) { + SimpleVCSFileStatesModel tableModel = null; + for (SimpleVCSFileStatesModel model : getModels()) { if (modelName.equals(model.getName())) { tableModel = model; break; } } if (tableModel == null) { - getModels().add(tableModel = new SynchVCSFileStatesModel(modelName)); + getModels().add(tableModel = new SimpleVCSFileStatesModel(modelName)); } return tableModel; } public void setData(List<VCSFileState> states) { - getModel(ALL_MODEL_PROPERTY).setData(states); + getModel(SYNCH_ALL_MODEL_PROPERTY).setData(states); List<VCSFileState> local = new ArrayList<VCSFileState>(); List<VCSFileState> remote = new ArrayList<VCSFileState>(); splitStates(states, local, remote); - getModel(LOCAL_MODEL_PROPERTY).setData(local); - getModel(REMOTE_MODEL_PROPERTY).setData(remote); + getModel(SYNCH_LOCAL_MODEL_PROPERTY).setData(local); + getModel(SYNCH_REMOTE_MODEL_PROPERTY).setData(remote); } public void addData(List<VCSFileState> states) { - getModel(ALL_MODEL_PROPERTY).setData(states); + getModel(SYNCH_ALL_MODEL_PROPERTY).setData(states); List<VCSFileState> local = new ArrayList<VCSFileState>(); List<VCSFileState> remote = new ArrayList<VCSFileState>(); splitStates(states, local, remote); - getModel(LOCAL_MODEL_PROPERTY).addData(local.toArray(new VCSFileState[local.size()])); - getModel(REMOTE_MODEL_PROPERTY).addData(remote.toArray(new VCSFileState[remote.size()])); + getModel(SYNCH_LOCAL_MODEL_PROPERTY).addData(local.toArray(new VCSFileState[local.size()])); + getModel(SYNCH_REMOTE_MODEL_PROPERTY).addData(remote.toArray(new VCSFileState[remote.size()])); } public void removeData(List<VCSFileState> states) { - getModel(ALL_MODEL_PROPERTY).removeData(states.toArray(new VCSFileState[states.size()])); + getModel(SYNCH_ALL_MODEL_PROPERTY).removeData(states.toArray(new VCSFileState[states.size()])); List<VCSFileState> local = new ArrayList<VCSFileState>(); List<VCSFileState> remote = new ArrayList<VCSFileState>(); splitStates(states, local, remote); - getModel(LOCAL_MODEL_PROPERTY).removeData(local.toArray(new VCSFileState[local.size()])); - getModel(REMOTE_MODEL_PROPERTY).removeData(remote.toArray(new VCSFileState[remote.size()])); + getModel(SYNCH_LOCAL_MODEL_PROPERTY).removeData(local.toArray(new VCSFileState[local.size()])); + getModel(SYNCH_REMOTE_MODEL_PROPERTY).removeData(remote.toArray(new VCSFileState[remote.size()])); } public void doAllAction(VCSAction action) { @@ -164,72 +151,12 @@ 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 List<SynchVCSFileStatesModel> getModels() { + protected List<SimpleVCSFileStatesModel> getModels() { if (models == null) { - models = new ArrayList<SynchVCSFileStatesModel>(); + models = new ArrayList<SimpleVCSFileStatesModel>(); } return models; } - protected void splitStates(List<VCSFileState> states, List<VCSFileState> local, List<VCSFileState> remote) { - for (VCSFileState state : states) { - if (state.getState() != null && state.getState().isLocal()) { - local.add(state); - } - if (state.getState() != null && state.getState().isRemote()) { - remote.add(state); - } - } - } + } Deleted: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchVCSFileStatesModel.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchVCSFileStatesModel.java 2008-04-03 17:00:51 UTC (rev 303) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchVCSFileStatesModel.java 2008-04-03 17:01:02 UTC (rev 304) @@ -1,47 +0,0 @@ -/** - * # #% 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.codelutin.vcs.VCSFileState; -import org.codelutin.vcs.VCSState; -import org.codelutin.vcs.ui.VCSUIConstants; - -/** @author chemit */ -public class SynchVCSFileStatesModel extends AbstractVCSFileStatesModel { - private static final long serialVersionUID = -7592705623128585146L; - - public SynchVCSFileStatesModel(String name) { - super(name, VCSUIConstants.SIMPLE_COLUMNS_NAMES); - } - - public Object getValueAt(int rowIndex, int columnIndex) { - if (isEmpty()) return null; - VCSFileState item = data.get(rowIndex); - Object result = null; - if (columnIndex == 0) { - // get module - result = item.getModuleName(); - } else if (columnIndex == 1) { - // get file - result = item.getModuleRelativeFileName(); - } else if (columnIndex == 2) { - // get status - VCSState state = item.getState(); - result = state == null ? null : state.libelle(); - } - return result; - } - -}
participants (1)
-
tchemit@users.labs.libre-entreprise.org