Author: tchemit Date: 2008-03-31 20:43:54 +0000 (Mon, 31 Mar 2008) New Revision: 252 Removed: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/VCSRepositoryState.java Log: pur generation module Deleted: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/VCSRepositoryState.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/VCSRepositoryState.java 2008-03-31 20:43:36 UTC (rev 251) +++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/VCSRepositoryState.java 2008-03-31 20:43:54 UTC (rev 252) @@ -1,200 +0,0 @@ -/* ##% -* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin, -* Benjamin Poussin, 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; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.codelutin.vcs.ui.FileStateTableModel; - -import java.io.File; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; - -/** - * Permet de rechercher et conserve les differences entre le repository local et - * distant. - * - * @author poussin - * @author chemit - */ -public class VCSRepositoryState { - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static protected final Log log = LogFactory.getLog(VCSRepositoryState.class); - - /** liste des �tats des fichiers scann�s */ - protected List<VCSFileState> states = new ArrayList<VCSFileState>(); - - /** tableau des model de table (un par �tat VCSState) */ - protected FileStateTableModel[] models; - - /** le r�pertoire racine du working copy local */ - protected File root; - - /** vcs states to be authorized in this model */ - protected VCSState[] acceptedStates; - - /** vcs actions to be authorized in this model */ - protected EnumSet<VCSAction> acceptedActions; - - /** vcs handler to use (lazy instanciation) */ - protected VCSHandler handler; - - public static final VCSState[] UPDATE_STATES = { - org.codelutin.vcs.VCSState.OUT_OF_DATE, - org.codelutin.vcs.VCSState.MODIFIED, - org.codelutin.vcs.VCSState.OUT_OF_DATE_AND_MODIFIED, - org.codelutin.vcs.VCSState.UNVERSIONNED, - org.codelutin.vcs.VCSState.MISSING - }; - - /** - * @param handler handlet to use - * @param root directory of root local working copy - * @param actions accepted actions - * @param modules la liste des modules a traiter - * @throws VCSException if any problem while building - */ - protected VCSRepositoryState(VCSHandler handler, File root, EnumSet<VCSAction> actions, File... modules) throws VCSException { - this.acceptedActions = actions; - this.root = root; - this.acceptedStates = UPDATE_STATES; - this.handler = handler; - // scan all modules - for (File mod : modules) { - states.addAll(doScan(mod, acceptedStates)); - } - } - - public VCSHandler getHandler() { - return handler; - } - - /** - * @param handler vcs handler to use for synch operation - * @throws VCSException if any problem while synchro - */ - public void doSynch(VCSHandler handler) throws VCSException { - long timestamp = System.nanoTime(); - for (VCSFileState fileState : states) { - fileState.doSynch(handler, timestamp); - } - } - - public File getRoot() { - return root; - } - - public List<VCSFileState> getStates() { - return states; - } - - public VCSState[] getAcceptedStates() { - return acceptedStates; - } - - public FileStateTableModel getModel(VCSState state) { - return getModels()[state.ordinal()]; - } - - - protected FileStateTableModel[] getModels() { - if (models == null) { - models = new FileStateTableModel[VCSState.values().length]; - } - return models; - } - - public void createUIModels() { - for (VCSState state : acceptedStates) { - getModels()[state.ordinal()] = new FileStateTableModel(VCSFileStateManager.filter(states, state), acceptedActions); - } - } - - public List<VCSFileState> selected(VCSState... wanted) { - if (wanted.length == 0) { - wanted = acceptedStates; - } - List<VCSFileState> result = new ArrayList<VCSFileState>(); - for (VCSState state : wanted) { - FileStateTableModel tableModel = getModel(state); - if (tableModel != null) { - result.addAll(tableModel.getSelected()); - } - } - return result; - } - - public void checkAll(boolean toUse, VCSState... wanted) { - if (wanted.length == 0) wanted = acceptedStates; - for (VCSState state : wanted) { - FileStateTableModel tableModel = getModel(state); - if (tableModel != null) { - tableModel.checkAll(0, toUse); - } - } - } - - public boolean isModelEmpty() { - for (VCSState state : acceptedStates) { - FileStateTableModel tableModel = getModel(state); - if (tableModel != null && tableModel.getRowCount() > 0) { - return false; - } - } - return true; - } - - public int getModelSelectedSize() { - int result = 0; - for (VCSState state : acceptedStates) { - result += getModelSelectedSize(state); - } - return result; - } - - public boolean isModelEmpty(VCSState state) { - FileStateTableModel tableModel = getModel(state); - return !(tableModel != null && tableModel.getRowCount() > 0); - } - - public int getModelSize(VCSState state) { - FileStateTableModel tableModel = getModel(state); - return tableModel == null ? 0 : tableModel.getRowCount(); - } - - public int getModelSelectedSize(VCSState state) { - FileStateTableModel tableModel = getModel(state); - return tableModel == null ? 0 : tableModel.getSelectedSize(); - } - - private List<VCSFileState> doScan(File module, VCSState... acceptedStates) - throws VCSException { - // obtain list of all VCSFileState found in module directory - List<VCSFileState> states; - states = VCSFileStateManager.doScan(getHandler(), module, true, acceptedStates); - return states; - } - - public EnumSet<VCSAction> getAcceptedActions() { - return acceptedActions; - } -}
participants (1)
-
tchemit@users.labs.libre-entreprise.org