Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3898 discussions
[Buix-commits] r367 - trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:40:44 +0000 (Sat, 05 Apr 2008)
New Revision: 367
Modified:
trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
Log:
refactor providers
Modified: trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-05 20:40:27 UTC (rev 366)
+++ trunk/lutinvcs/lutinvcs-provider-svn/src/main/java/org/codelutin/vcs/SVNProvider.java 2008-04-05 20:40:44 UTC (rev 367)
@@ -14,19 +14,37 @@
*/
package org.codelutin.vcs;
+import org.codelutin.vcs.impl.svn.SVNConnexion;
import org.codelutin.vcs.impl.svn.SVNHandler;
-import org.codelutin.vcs.util.AbstractVCSConnexion;
import org.codelutin.vcs.util.AbstractVCSProvider;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
+import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
-/** @author chemit */
-public class SVNProvider extends AbstractVCSProvider<SVNHandler, AbstractVCSConnexion> {
+/**
+ * SVN Provider
+ *
+ * @author chemit
+ */
+public class SVNProvider extends AbstractVCSProvider<SVNConnexion, SVNHandler> {
public SVNProvider() {
- super("SVN", SVNHandler.class);
+ super("SVN", SVNHandler.class, SVNConnexion.class);
}
- public AbstractVCSConnexion newConnection(VCSConnexionMode mode, VCSConfig config) {
- checkHandlerInit();
- return null;
+ @Override
+ public void init() {
+
+ // For using over http:// and https://
+ DAVRepositoryFactory.setup();
+
+ // For using over svn:// and svn+xxx://
+ SVNRepositoryFactoryImpl.setup();
+
+ // For using over file:///
+ FSRepositoryFactory.setup();
+
+ super.init();
}
+
}
1
0
[Buix-commits] r366 - in trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs: . impl/mock
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:40:27 +0000 (Sat, 05 Apr 2008)
New Revision: 366
Removed:
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSConfig.java
Modified:
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java
trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSHandler.java
Log:
refactor providers
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java 2008-04-05 20:40:12 UTC (rev 365)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/MockProvider.java 2008-04-05 20:40:27 UTC (rev 366)
@@ -19,14 +19,10 @@
import org.codelutin.vcs.util.AbstractVCSProvider;
/** @author chemit */
-public class MockProvider extends AbstractVCSProvider<MockVCSHandler, MockConnexion> {
+public class MockProvider extends AbstractVCSProvider<MockConnexion, MockVCSHandler> {
public MockProvider() {
- super("MOCK", MockVCSHandler.class);
+ super("MOCK", MockVCSHandler.class, MockConnexion.class);
}
- public MockConnexion newConnection(VCSConnexionMode mode, VCSConfig config) {
- checkHandlerInit();
- return null;
- }
}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-05 20:40:12 UTC (rev 365)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockConnexion.java 2008-04-05 20:40:27 UTC (rev 366)
@@ -14,27 +14,39 @@
*/
package org.codelutin.vcs.impl.mock;
+import org.codelutin.vcs.ConnectionState;
+import org.codelutin.vcs.MockProvider;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSConnexionMode;
import org.codelutin.vcs.util.AbstractVCSConnexion;
-import org.codelutin.vcs.VCSConfig;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.ConnectionState;
/** @author chemit */
public class MockConnexion extends AbstractVCSConnexion {
- public void init(VCSConfig config, VCSHandler handler) {
+ public MockConnexion(VCSConnexionMode mode, MockProvider provider) {
+ super(mode, provider);
+ }
+
+ public void init(VCSConnexionConfig config) {
state = ConnectionState.INIT;
+ this.config = config;
}
+ public void testConnection() throws VCSException {
+ }
+
@Override
public void close() throws IllegalStateException {
checkInit();
+ fireClose();
}
@Override
public void open() throws IllegalStateException {
checkInit();
- state = ConnectionState.INIT;
+ state = ConnectionState.ON_LINE;
+ fireOpen();
}
}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSConfig.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSConfig.java 2008-04-05 20:40:12 UTC (rev 365)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSConfig.java 2008-04-05 20:40:27 UTC (rev 366)
@@ -1,126 +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.impl.mock;
-
-import org.codelutin.vcs.ConnectionState;
-import org.codelutin.vcs.VCSConfig;
-import org.codelutin.vcs.VCSType;
-import org.codelutin.vcs.VCSTypeRepo;
-
-import java.io.File;
-import java.net.URL;
-
-/** @author chemit */
-public class MockVCSConfig implements VCSConfig {
-
- File localRoot;
- URL remoteRoot;
-
- boolean init;
-
- public boolean canConnect() {
- return false;
- }
-
- public boolean isConnected() {
- return false;
- }
-
- public ConnectionState getConnectionState() {
- return null;
- }
-
- public VCSType getType() {
- return VCSType.MOCK;
- }
-
- public boolean isUseSshConnexion() {
- return false;
- }
-
- public String getHostName() {
- return null;
- }
-
- public File getKeyFile() {
- return null;
- }
-
- public String getUserName() {
- return null;
- }
-
- public boolean isNoPassPhrase() {
- return false;
- }
-
- public String getPassphrase() {
- return null;
- }
-
- public String getRemotePath() {
- return null;
- }
-
- public String getRemoteDatabase() {
- return remoteRoot.toString();
- }
-
- public String getRemoteDatabasePath() {
- return remoteRoot.toString();
- }
-
- public File getLocalDatabasePath() {
- return localRoot;
- }
-
- public VCSTypeRepo getTypeRepo() {
- return null;
- }
-
- public boolean isOffline() {
- return false;
- }
-
- public boolean isReadOnly() {
- return false;
- }
-
- public boolean isInit() {
- return init;
- }
-
- public void validate() {
- }
-
- public void setUseSshConnexion(boolean useSshConnexion) {
- }
-
- public File getSource() {
- return null;
- }
-
- public void setLocalRoot(File localRoot) {
- this.localRoot = localRoot;
- }
-
- public void setRemoteRoot(URL remoteRoot) {
- this.remoteRoot = remoteRoot;
- }
-
- public void setInit(boolean init) {
- this.init = init;
- }
-}
Modified: trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSHandler.java 2008-04-05 20:40:12 UTC (rev 365)
+++ trunk/lutinvcs/lutinvcs-provider-mock/src/main/java/org/codelutin/vcs/impl/mock/MockVCSHandler.java 2008-04-05 20:40:27 UTC (rev 366)
@@ -14,10 +14,9 @@
*/
package org.codelutin.vcs.impl.mock;
-import org.codelutin.vcs.util.AbstractVCSHandler;
-import org.codelutin.vcs.VCSConfig;
import org.codelutin.vcs.VCSException;
import org.codelutin.vcs.VCSState;
+import org.codelutin.vcs.util.AbstractVCSHandler;
import java.io.File;
import java.io.IOException;
@@ -25,103 +24,96 @@
import java.util.List;
/** @author chemit */
-public class MockVCSHandler extends AbstractVCSHandler {
+public class MockVCSHandler extends AbstractVCSHandler<MockConnexion> {
- public MockVCSHandler(VCSConfig config) {
- super(config, "", "");
+ public MockVCSHandler() {
+ super("", "");
}
- public void initWorkingCopy() throws VCSException {
+ public void initWorkingCopy(MockConnexion connexion) throws VCSException {
}
- public String getRemoteUrl() {
+ public VCSState getState(MockConnexion connexion, File fileState, Collection tmp) throws VCSException {
return null;
}
- public VCSState getState(File fileState, Collection tmp) throws VCSException {
+ public VCSState getState(MockConnexion connexion, File file, Collection tmp, boolean noremote) throws VCSException {
return null;
}
- public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
- return null;
- }
-
- public boolean isOnRemote(File file) {
+ public boolean isOnRemote(MockConnexion connexion, File file) {
return false;
}
- public boolean isUpToDate(File file) throws VCSException {
+ public boolean isUpToDate(MockConnexion connexion, File file) throws VCSException {
return false;
}
- public void makeRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ public void makeRemoteDir(MockConnexion connexion, String commitMessage, String... dirNames) throws VCSException {
}
- public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ public void deleteRemoteDir(MockConnexion connexion, String commitMessage, String... dirNames) throws VCSException {
}
- public long add(List<File> files, String msg) throws VCSException {
+ public long add(MockConnexion connexion, List<File> files, String msg) throws VCSException {
return 0;
}
- public void delete(List<File> files, String msg) throws VCSException {
+ public void delete(MockConnexion connexion, List<File> files, String msg) throws VCSException {
}
- public void revert(List<File> files) throws VCSException {
+ public void revert(MockConnexion connexion, List<File> files) throws VCSException {
}
- public long commit(List<File> files, String msg) throws VCSException {
+ public long commit(MockConnexion connexion, List<File> files, String msg) throws VCSException {
return 0;
}
- public void update(File file, Object revision) throws VCSException {
+ public void update(MockConnexion connexion, File file, Object revision) throws VCSException {
}
- public void update(File file) throws VCSException {
+ public void update(MockConnexion connexion, File file) throws VCSException {
}
- public void checkout(File destDir, String module, boolean recurse) throws VCSException {
+ public void checkout(MockConnexion connexion, File destDir, String module, boolean recurse) throws VCSException {
}
- public void checkoutFile(File destDir, String module) throws VCSException {
+ public void checkoutFile(MockConnexion connexion, File destDir, String module) throws VCSException {
}
- public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
+ public long checkoutOnlyTheDirectory(MockConnexion connexion, File root, Object revision) throws VCSException {
return 0;
}
- public List<String> getRemoteStorageNames(File directory) throws VCSException {
+ public List<String> getRemoteStorageNames(MockConnexion connexion, File directory) throws VCSException {
return null;
}
- public Object getRevision(File f) throws VCSException {
+ public Object getRevision(MockConnexion connexion, File f) throws VCSException {
return null;
}
- public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
+ public List getLog(MockConnexion connexion, Object startRevision, Object endRevision, File file) throws VCSException {
return null;
}
- public String getFileContent(File file, Object revision) throws VCSException, IOException {
+ public String getFileContent(MockConnexion connexion, File file, Object revision) throws VCSException, IOException {
return null;
}
- public String getChangeLog(File file) throws VCSException {
+ public String getChangeLog(MockConnexion connexion, File file) throws VCSException {
return null;
}
- public String getDiff(File file) throws VCSException, IOException {
+ public String getDiff(MockConnexion connexion, File file) throws VCSException, IOException {
return null;
}
- public String getDiff(File file, Object againstRevision) throws VCSException, IOException {
+ public String getDiff(MockConnexion connexion, File file, Object againstRevision) throws VCSException, IOException {
return null;
}
- public void testConnection() throws VCSException {
- }
-
- public boolean hasProtocoleChanged() throws VCSException {
+ public boolean hasProtocoleChanged(MockConnexion connexion) throws VCSException {
return false;
}
}
1
0
[Buix-commits] r365 - in trunk/lutinvcs/lutinvcs-ui/src: main/java/org/codelutin/vcs/ui test/java/org/codelutin/vcs/ui
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:40:12 +0000 (Sat, 05 Apr 2008)
New Revision: 365
Modified:
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSPopupAction.java
trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java
trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -15,7 +15,6 @@
package org.codelutin.vcs.ui;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSHandler;
import org.codelutin.vcs.ui.handler.AbstractConfirmUIHandler;
import org.codelutin.vcs.ui.model.ConfirmUIModel;
@@ -26,8 +25,7 @@
protected final JConfirmUI ui;
- public ConfirmUIHandler(VCSHandler handler) {
- super(handler);
+ public ConfirmUIHandler() {
this.ui = new JConfirmUI(this);
}
@@ -47,7 +45,7 @@
VCSAction action = ui.getModel().getAction();
ui.getAccept().setText(action.getLibelle());
ui.getToolbar().setVisible(action.isCommit());
- ui.getHandler().getSelectionModel().setSelectionInterval(0, getModel().getModel().size() - 1);
+ ui.getHandler().getSelectionModel().setSelectionInterval(0, getModel().getModel().getRowCount() - 1);
}
protected void updateMessageUI() {
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -15,12 +15,10 @@
package org.codelutin.vcs.ui;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.ui.handler.AbstractDiffUIHandler;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
import org.codelutin.vcs.ui.model.DiffUIModel;
-import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel;
import javax.swing.ListSelectionModel;
@@ -29,8 +27,7 @@
protected final JDiffUI ui;
- public DiffUIHandler(VCSHandler handler) {
- super(handler);
+ public DiffUIHandler() {
this.ui = new JDiffUI(this);
}
@@ -43,17 +40,17 @@
}
public ListSelectionModel getSelectionModel() {
- AbstractVCSFileStatesModel tabModel = getModel().getTabModel();
- return tabModel == null ? null : ui.getTable(tabModel.getName()).getSelectionModel();
+ AbstractVCSEntriesTableModel tabModel = getModel().getModel();
+ return tabModel == null ? null : ui.getTable(tabModel.getLocation().name().toLowerCase()).getSelectionModel();
}
- public void doSelectTab(SimpleVCSFileStatesModel action) {
+ public void doSelectTab(AbstractVCSEntriesTableModel action) {
}
- public void doSelectFile(VCSFileState model) {
+ public void doSelectFile(VCSEntry model) {
}
- public void doAction(VCSAction action, VCSFileState model) {
+ public void doAction(VCSAction action, VCSEntry model) {
}
public void gotoNextDiff() {
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -1,30 +1,25 @@
package org.codelutin.vcs.ui;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.handler.AbstractSynchUIHandler;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
-import org.codelutin.vcs.ui.model.SimpleVCSFileStatesModel;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
import org.codelutin.vcs.ui.model.SynchUIModel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
/** @author chemit */
-public class SynchUIHandler extends AbstractSynchUIHandler implements ListSelectionListener {
+public class SynchUIHandler extends AbstractSynchUIHandler {
protected final JSynchUI ui;
- public SynchUIHandler(VCSHandler handler) {
- super(handler);
+ public SynchUIHandler() {
this.ui = new JSynchUI(this);
}
@@ -35,9 +30,9 @@
@Override
public void init() {
super.init();
- initTab(VCSUIConstants.SYNCH_ALL_MODEL_PROPERTY);
- initTab(VCSUIConstants.SYNCH_LOCAL_MODEL_PROPERTY);
- initTab(VCSUIConstants.SYNCH_REMOTE_MODEL_PROPERTY);
+ initTab(VCSEntryLocation.ALL);
+ initTab(VCSEntryLocation.LOCAL);
+ initTab(VCSEntryLocation.REMOTE);
}
public SynchUIModel getModel() {
@@ -45,53 +40,45 @@
}
public ListSelectionModel getSelectionModel() {
- AbstractVCSFileStatesModel tabModel = getModel().getTabModel();
- return tabModel == null ? null : ui.getTable(tabModel.getName()).getSelectionModel();
+ return ui.getTable(getModel().getModel().getLocation().name().toLowerCase()).getSelectionModel();
}
- public void doAllAction(VCSAction action, SimpleVCSFileStatesModel model) {
+ public void doAllAction(VCSAction action) {
+ AbstractVCSEntriesTableModel model = getModel().getModel();
log.info(action + " : " + model);
- JTable table = ui.getTable(model.getName());
- ListSelectionModel selectionModel = table.getSelectionModel();
+ ListSelectionModel selectionModel = getSelectionModel();
if (action == VCSAction.REFRESH) {
selectionModel.clearSelection();
// do refresh of all states
- log.info("refresh :" + model.size());
- model.refresh(model.getStates());
+ log.info("refresh :" + model.getRowCount());
+ model.refresh(model.getEntries(), System.nanoTime());
} else {
- model.select(action, selectionModel, true);
- // do action on selected items
- doSelectAction(action, model);
- }
- }
+ List<VCSEntry> entries = model.filter(action, model.getDisplayedEntries(null));
+ if (entries.isEmpty()) {
+ // nothing to do
+ return;
+ }
+ if (action == VCSAction.DIFF) {
+ // show diff ui
+ return;
+ }
+ log.info("files to treate :" + entries.size());
+ JConfirmUI confirmUI = VCSUIFactory.newConfirmUI();
- public void doSelectAction(VCSAction action, SimpleVCSFileStatesModel model) {
- log.info(action + " : " + model);
- JTable table = ui.getTable(model.getName());
- ListSelectionModel selectionModel = table.getSelectionModel();
- if (selectionModel.isSelectionEmpty()) {
- // nothing to do
- return;
+ confirmUI.getModel().init(action, model.getLocation(), entries.toArray(new VCSEntry[entries.size()]));
+
+ confirmUI.setVisible(true);
+ //TODO SynchModel should listener for modification on ActionManagerQueue thread
+ log.info("TODO refresh states for files...");
}
- if (action == VCSAction.DIFF) {
- // show diff ui
- return;
- }
- VCSFileState[] states = model.getData(selectionModel);
- log.info("files to treate :" + states.length);
- JConfirmUI confirmUI = VCSUIFactory.newConfirmUI(getHandler(), Arrays.asList(states));
- confirmUI.getModel().setAction(action);
- confirmUI.setVisible(true);
- //TODO SynchModel should listener for modification on ActionManagerQueue thread
- log.info("TODO refresh states for files...");
}
- public void doSelectTabAction(SimpleVCSFileStatesModel model) {
- log.info(model);
- String tabModelName = model.getName();
- ui.cardLayout.show(ui.preview, tabModelName);
- VCSAction[] actions = model.getActions();
+ public void doSelectLocation(VCSEntryLocation location) {
+ log.info(location);
+
+ ui.cardLayout.show(ui.preview, location.name().toLowerCase() + "Content");
+ VCSAction[] actions = getModel().getModel().getActions((ListSelectionModel) null);
List<String> acts = new ArrayList<String>();
for (VCSAction action : actions) {
acts.add(action.name().toLowerCase());
@@ -105,42 +92,31 @@
ui.getRefreshAll().setEnabled(hasActions);
}
- public void valueChanged(ListSelectionEvent e) {
- ListSelectionModel list = (ListSelectionModel) e.getSource();
- if (!list.getValueIsAdjusting() && log.isDebugEnabled()) {
- log.debug(list);
- }
- }
-
- private void initTab(String modelName) {
- JTable table = ui.getTable(modelName);
- SimpleVCSFileStatesModel fileStatesModel = getModel().getModel(modelName);
+ private void initTab(VCSEntryLocation location) {
+ String s = location.name().toLowerCase();
+ JTable table = ui.getTable(s);
+ AbstractVCSEntriesTableModel fileStatesModel = getModel().getModel();
table.setModel(fileStatesModel);
- table.getSelectionModel().addListSelectionListener(this);
- table.addMouseListener(new ListMouseListener(ui, fileStatesModel));
- JVCSPopup jvcsPopup = ui.getPopup(modelName);
- jvcsPopup.setDispatchAction(new VCSPopupAction(ui, modelName));
+ table.addMouseListener(new ListMouseListener(ui, fileStatesModel, s));
+ JVCSPopup jvcsPopup = ui.getPopup(s);
+ jvcsPopup.setDispatchAction(new VCSPopupAction(ui, location));
}
private class ListMouseListener extends MouseAdapter {
- private final AbstractVCSFileStatesModel model;
+ private final AbstractVCSEntriesTableModel model;
private final ListSelectionModel selectionModel;
private final JTable jTable;
private final JVCSPopup jPopupMenu;
- public ListMouseListener(JSynchUI ui, AbstractVCSFileStatesModel model) {
+ public ListMouseListener(JSynchUI ui, AbstractVCSEntriesTableModel model, String modelName) {
this.model = model;
- String modelName = model.getName();
-
jPopupMenu = ui.getPopup(modelName);
jTable = ui.getTable(modelName);
selectionModel = jTable.getSelectionModel();
- // init actions
-
}
@Override
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSPopupAction.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSPopupAction.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSPopupAction.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -15,13 +15,14 @@
package org.codelutin.vcs.ui;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.handler.VCSAbsractAction;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
import javax.swing.ListSelectionModel;
import java.awt.event.ActionEvent;
-import java.util.Arrays;
+import java.util.List;
/**
* Action of a clik inside the popup menu
@@ -31,30 +32,38 @@
public class VCSPopupAction extends VCSAbsractAction {
private static final long serialVersionUID = -1983061535956510913L;
- protected AbstractVCSFileStatesModel model;
+ protected VCSEntryLocation location;
protected transient ListSelectionModel selectionModel;
- public VCSPopupAction(JSynchUI ui, String modelName) {
- super(ui.getHandler().getHandler());
- this.model = ui.getModel().getModel(modelName);
- this.selectionModel = ui.getTable(modelName).getSelectionModel();
+ protected transient JSynchUI ui;
+
+ protected AbstractVCSEntriesTableModel tableModel;
+
+ public VCSPopupAction(JSynchUI ui, VCSEntryLocation location) {
+ super();
+ this.ui = ui;
+ this.location = location;
+ //this.selectionModel = ui.getHandler().getSelectionModel();
+ this.selectionModel = ui.getTable(location.name().toLowerCase()).getSelectionModel();
+ tableModel = ui.getModel().getModel();
}
public void actionPerformed(ActionEvent e) {
// select only lines for this action inside already selected lines
- model.select(action, selectionModel, false);
- // obtain thoses lines
- VCSFileState[] states = model.getData(selectionModel);
- log.info("action: " + action + ", files to treate :" + states.length);
+ List<VCSEntry> entries = tableModel.filter(action, tableModel.getDisplayedEntries(selectionModel));
+ log.info("action: " + action + ", files to treate :" + entries.size() + " " + selectionModel);
if (action == VCSAction.DIFF) {
// show diff ui
+ ui.getModel().refresh(entries);
+
} else if (action == VCSAction.REFRESH) {
// refresh ui, and update list if needed
+
} else {
// show confirm action ui
- JConfirmUI confirmUI = VCSUIFactory.newConfirmUI(getHandler(), Arrays.asList(states));
- confirmUI.getModel().setAction(action);
- confirmUI.getHandler().getSelectionModel().setSelectionInterval(0, states.length - 1);
+ JConfirmUI confirmUI = VCSUIFactory.newConfirmUI();
+ confirmUI.getModel().init(action, tableModel.getLocation(), entries.toArray(new VCSEntry[entries.size()]));
+ confirmUI.getHandler().getSelectionModel().setSelectionInterval(0, entries.size() - 1);
confirmUI.setVisible(true);
}
}
Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -14,43 +14,36 @@
*/
package org.codelutin.vcs.ui;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
import org.codelutin.vcs.ui.handler.AbstractUIHandler;
-import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-/** @author chemit */
+/**
+ * Factory if VCS UI, using a cache.
+ *
+ * @author chemit
+ */
public class VCSUIFactory {
protected static Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> cache;
- public static Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> getCache() {
- if (cache == null) {
- cache = new HashMap<Class<? extends AbstractUIHandler>, AbstractUIHandler>();
- }
- return cache;
- }
-
protected static JSynchUI synchUI;
protected static JDiffUI diffUI;
protected static JConfirmUI confirmUI;
- public static JSynchUI newSynchUI(VCSHandler handler, List<VCSFileState> states) {
- SynchUIHandler result = newHandler(handler, SynchUIHandler.class, states);
+ public static JSynchUI newSynchUI() {
+ SynchUIHandler result = newHandler(SynchUIHandler.class);
return result.getUi();
}
- public static JDiffUI newDiffUI(VCSHandler handler, List<VCSFileState> states) {
- DiffUIHandler result = newHandler(handler, DiffUIHandler.class, states);
+ public static JDiffUI newDiffUI() {
+ DiffUIHandler result = newHandler(DiffUIHandler.class);
return result.getUi();
}
- public static JConfirmUI newConfirmUI(VCSHandler handler, List<VCSFileState> states) {
- ConfirmUIHandler result = newHandler(handler, ConfirmUIHandler.class, states);
+ public static JConfirmUI newConfirmUI() {
+ ConfirmUIHandler result = newHandler(ConfirmUIHandler.class);
return result.getUi();
}
@@ -61,26 +54,28 @@
cache = null;
}
+ protected static Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> getCache() {
+ if (cache == null) {
+ cache = new HashMap<Class<? extends AbstractUIHandler>, AbstractUIHandler>();
+ }
+ return cache;
+ }
+
@SuppressWarnings({"unchecked"})
- protected static <H extends AbstractUIHandler> H newHandler(VCSHandler handler, Class<H> klass, List<VCSFileState> states) {
+ protected static <H extends AbstractUIHandler> H newHandler(Class<H> klass) {
H result;
result = (H) getCache().get(klass);
if (result == null) {
try {
- result = klass.getConstructor(VCSHandler.class).newInstance(handler);
+ result = klass.newInstance();
result.init();
getCache().put(klass, result);
} catch (InstantiationException e) {
throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage());
} catch (IllegalAccessException e) {
throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage());
- } catch (InvocationTargetException e) {
- throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage());
- } catch (NoSuchMethodException e) {
- throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage());
}
}
- result.getModel().setData(states);
return result;
}
Modified: trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-05 20:37:48 UTC (rev 364)
+++ trunk/lutinvcs/lutinvcs-ui/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-05 20:40:12 UTC (rev 365)
@@ -14,13 +14,17 @@
*/
package org.codelutin.vcs.ui;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSFileStateImpl;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.VCSHandlerFactory;
+import org.codelutin.i18n.I18n;
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSConnexionMode;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
+import org.codelutin.vcs.VCSFactory;
import org.codelutin.vcs.VCSState;
-import org.codelutin.vcs.impl.mock.MockVCSConfig;
+import org.codelutin.vcs.VCSType;
import org.codelutin.vcs.ui.model.SynchUIModel;
+import org.codelutin.vcs.util.VCSConnexionConfigImpl;
+import org.codelutin.vcs.util.VCSEntryImpl;
import java.io.File;
import java.util.ArrayList;
@@ -33,52 +37,57 @@
static java.util.Random r = new java.util.Random();
public static void main(String[] args) {
- org.codelutin.i18n.I18n.init();
- File root = new File(new File("").getAbsolutePath());
+ I18n.init();
- VCSHandler handler = initVCS(root);
+ VCSConnexion connexion = initVCS(new File(new File("").getAbsolutePath()));
- List<VCSFileState> datas = generateListFileStates(handler, 50, "trunk", "local/", "remote/");
+ try {
+ connexion.open();
- JSynchUI synchUI = VCSUIFactory.newSynchUI(handler, datas);
+ JSynchUI ui = VCSUIFactory.newSynchUI();
- synchUI.setVisible(true);
+ fillSynchModel(connexion, ui.getModel(), 20, "trunk", "local/", "remote/");
- handler.close();
+ ui.setVisible(true);
+
+ } finally {
+ connexion.close();
+ }
}
- public static VCSHandler initVCS(File root) {
- MockVCSConfig config = new MockVCSConfig();
- config.setLocalRoot(root);
- config.setInit(true);
- VCSHandlerFactory.setConfig(config);
- return VCSHandlerFactory.getHandler();
+ public static VCSConnexion initVCS(File root) {
+ VCSConnexionConfigImpl config = new VCSConnexionConfigImpl();
+ config.setType(VCSType.MOCK);
+ config.setLocalDatabasePath(root);
+ VCSConnexion connexion = VCSFactory.newConnexion(VCSConnexionMode.ANONYMOUS, config);
+ connexion.init(config);
+ return connexion;
}
- protected static void fillSynchModel(VCSHandler handler, SynchUIModel model, int max, String prefix, String localPRefix, String remotePrefix) {
- List<VCSFileState> datas = generateListFileStates(handler, max, prefix, localPRefix, remotePrefix);
- model.setData(datas);
+ protected static void fillSynchModel(VCSConnexion handler, SynchUIModel model, int max, String prefix, String localPRefix, String remotePrefix) {
+ List<VCSEntry> datas = generateListFileStates(handler, max, prefix, localPRefix, remotePrefix);
+ model.populate(VCSEntryLocation.UNKNOW, datas.toArray(new VCSEntry[datas.size()]));
}
- private static List<VCSFileState> generateListFileStates(VCSHandler handler, int max, String prefix, String localPRefix, String remotePrefix) {
- List<VCSFileState> datas = generateLocalFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), localPRefix);
+ protected static List<VCSEntry> generateListFileStates(VCSConnexion handler, int max, String prefix, String localPRefix, String remotePrefix) {
+ List<VCSEntry> datas = generateLocalFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), localPRefix);
datas.addAll(generateRemoteFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), remotePrefix));
return datas;
}
- protected static List<VCSFileState> generateLocalFileStates(VCSHandler handler, int max, File root, String localPRefix) {
+ protected static List<VCSEntry> generateLocalFileStates(VCSConnexion handler, int max, File root, String localPRefix) {
return generateFileStates(handler, root, max, localPRefix, VCSState.MODIFIED, VCSState.UNVERSIONNED, VCSState.OUT_OF_DATE_AND_MODIFIED, VCSState.REMOVED);
}
- protected static List<VCSFileState> generateRemoteFileStates(VCSHandler handler, int max, File root, String remotePRefix) {
+ protected static List<VCSEntry> generateRemoteFileStates(VCSConnexion handler, int max, File root, String remotePRefix) {
return generateFileStates(handler, root, max, remotePRefix, VCSState.MISSING, VCSState.OUT_OF_DATE, VCSState.OUT_OF_DATE_AND_MODIFIED);
}
- protected static List<VCSFileState> generateFileStates(VCSHandler handler, File root, int max, String prefix, VCSState... states) {
- List<VCSFileState> datas = new ArrayList<VCSFileState>();
+ protected static List<VCSEntry> generateFileStates(VCSConnexion handler, File root, int max, String prefix, VCSState... states) {
+ List<VCSEntry> datas = new ArrayList<VCSEntry>();
for (int i = 0, nbFiles = 1 + r.nextInt(max), size = states.length; i < nbFiles; i++) {
- VCSFileStateImpl state = new VCSFileStateImpl(handler, new File(root, prefix + "file" + i));
+ VCSEntry state = new VCSEntryImpl(handler, root.getName() + File.separator + prefix + "file" + i);
state.setState(states[r.nextInt(size)]);
datas.add(state);
}
1
0
[Buix-commits] r364 - trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:37:48 +0000 (Sat, 05 Apr 2008)
New Revision: 364
Modified:
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:
refactor PRovider, Handler and Connexion
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-05 20:37:32 UTC (rev 363)
+++ trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-en_GB.properties 2008-04-05 20:37:48 UTC (rev 364)
@@ -1,5 +1,3 @@
-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
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-05 20:37:32 UTC (rev 363)
+++ trunk/lutinvcs/lutinvcs-core/src/main/resources/i18n/lutinvcs-core-fr_FR.properties 2008-04-05 20:37:48 UTC (rev 364)
@@ -1,5 +1,3 @@
-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
1
0
[Buix-commits] r363 - in trunk/lutinvcs/lutinvcs-core/src: main/java/org/codelutin/vcs main/java/org/codelutin/vcs/ui/model test/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:37:32 +0000 (Sat, 05 Apr 2008)
New Revision: 363
Removed:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/MethodTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/RepositoryStateTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSFileStateManagerTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSHandlerTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSInitTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalData.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalDataContext.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSStateTest.java
trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSTest.java
Log:
refactor PRovider, Handler and Connexion
Deleted: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,138 +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 static org.codelutin.i18n.I18n._;
-import org.codelutin.util.StringUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ServiceLoader;
-
-/**
- * TODO
- *
- * @author chemit
- * @see VCSConfig
- * @see VCSHandler
- */
-(a)org.codelutin.i18n.I18nable
-public class VCSHandlerFactory {
-
- static protected final Log log = LogFactory.getLog(VCSHandlerFactory.class);
-
- static private VCSHandlerFactory instance;
-
- /** current config to use */
- private VCSConfig config;
-
- /** current vcs handler to use */
- private VCSHandler handler;
-
- /** providers availables */
- private List<VCSProvider> providers;
-
-
- public static VCSHandlerFactory getInstance() {
- if (instance == null) {
- instance = new VCSHandlerFactory();
- }
- return instance;
- }
-
- public static VCSConfig getConfig() {
- VCSHandlerFactory factory = getInstance();
- assertConfigIsNotNull(factory.config);
- return factory.config;
- }
-
- public static void setConfig(VCSConfig value) {
- getInstance().config = value;
- }
-
- public static VCSHandler getHandler() {
- final VCSHandlerFactory factory = getInstance();
- if (factory.handler == null) {
- synchronized (factory) {
- factory.handler = newHandler(getConfig());
- }
- }
- return factory.handler;
- }
-
- /**
- * instanciate a new handler, using a previously instanciate handler config.
- * <p/>
- * the method will produce a runtime exception if config is null and not init.
- *
- * @param config config to use
- * @return the new handler instance
- */
- public static VCSHandler newHandler(VCSConfig config) {
- VCSHandlerFactory factory = getInstance();
-
- assertConfigIsInit(config);
- VCSProvider<?, ?> provider = factory.getProvider(config.getType().name().toUpperCase());
- if (provider == null) {
- throw new IllegalArgumentException("could not find a provider for type " + config.getType());
- }
- return provider.newInstance(getConfig());
- }
-
- private VCSHandlerFactory() {
- long t0 = System.nanoTime();
- providers = new ArrayList<VCSProvider>();
- for (VCSProvider provider : ServiceLoader.load(VCSProvider.class)) {
- providers.add(provider);
- if (log.isDebugEnabled()) {
- log.debug("find " + provider);
- }
- }
- log.info("found " + providers.size() + " provider(s) " + providers.toString() + " in " + StringUtil.convertTime(t0, System.nanoTime()));
- for (VCSProvider provider : providers) {
- log.info(provider.getName() + " [" + provider + ']');
- }
- }
-
- private VCSProvider getProvider(String type) {
- for (VCSProvider provider : providers) {
- if (type.equals(provider.getName().toUpperCase())) {
- return provider;
- }
- }
- throw new IllegalArgumentException("could not found a provier for " + config);
- }
-
- private static void assertConfigIsNotNull(VCSConfig vcsConfig) {
- if (vcsConfig == null) {
- throw new VCSRuntimeException(_("lutinvcs.error.init.no.config", VCSHandlerFactory.class.getName()));
- }
- }
-
- private static void assertConfigIsInit(VCSConfig config) {
- assertConfigIsNotNull(config);
- if (!config.isInit()) {
- throw new VCSRuntimeException(_("lutinvcs.error.init.config", config));
- }
- }
-
-}
\ No newline at end of file
Deleted: 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-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSFileStatesModel.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,280 +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.ui.model;
-
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSState;
-
-import javax.swing.ListSelectionModel;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Simple Table model to display list of VCSFileState
- *
- * @author chemit
- */
-public abstract class AbstractVCSFileStatesModel extends javax.swing.table.AbstractTableModel {
-
- protected final String name;
-
- protected List<VCSFileState> data;
-
- protected final String[] columnNames;
-
- private static final long serialVersionUID = 4697917831388337369L;
-
- protected AbstractVCSFileStatesModel(String name, String[] columnNames) {
- super();
- this.name = name;
- this.columnNames = columnNames;
- }
-
- public List<VCSFileState> getData() {
- return data;
- }
-
- public String getName() {
- return name;
- }
-
- public int getColumnCount() {
- return columnNames.length;
- }
-
- public int getRowCount() {
- return data == null ? 0 : data.size();
- }
-
- /*@Override
- public Class<?> getColumnClass(int columnIndex) {
- return String.class;
- }*/
-
- @Override
- public String getColumnName(int columnIndex) {
- return _(columnNames[columnIndex]);
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- // read only data
- return false;
- }
-
- @Override
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- // read only data
- }
-
-
- public void setData(List<VCSFileState> states) {
- if (data != null) {
- data.clear();
- data.addAll(states);
- } else {
- data = new ArrayList<VCSFileState>(states);
- }
- fireTableDataChanged();
- }
-
- public void addData(VCSFileState... states) {
- if (data != null) {
- data.addAll(Arrays.asList(states));
- } else {
- data = new ArrayList<VCSFileState>(Arrays.asList(states));
- }
- fireTableDataChanged();
- }
-
- public void removeData(VCSFileState... states) {
- if (isEmpty()) {
- return;
- }
- data.removeAll(Arrays.asList(states));
- fireTableDataChanged();
- }
-
- protected boolean isEmpty() {
- return data == null || data.isEmpty();
- }
-
- public void clear() {
- if (isEmpty()) {
- return;
- }
- data.clear();
- fireTableDataChanged();
- }
-
- public VCSFileState[] getData(VCSAction action) {
- if (isEmpty()) {
- return new VCSFileState[0];
- }
- List<VCSFileState> list = new ArrayList<VCSFileState>(data);
- for (Iterator<VCSFileState> it = list.iterator(); it.hasNext();) {
- VCSFileState fileState = it.next();
- List<VCSAction> actions = fileState.getState().getActions();
- if (!actions.contains(action)) {
- it.remove();
- }
- }
- return list.toArray(new VCSFileState[list.size()]);
- }
-
- /**
- * restrict in model, only lines with given action enabled
- *
- * @param action current action to filter
- * @param selectionModel current selection where to filter
- * @param reset if <code>true</code> means take
- */
- public void select(VCSAction action, ListSelectionModel selectionModel, boolean reset) {
- if (isEmpty()) {
- return;
- }
- selectionModel.setValueIsAdjusting(true);
- if (reset) {
- selectionModel.clearSelection();
- }
- for (int i = 0; i < data.size(); i++) {
- VCSFileState fileState = data.get(i);
- List<VCSAction> actions = fileState.getState().getActions();
- if (reset) {
- if (actions.contains(action)) {
- selectionModel.addSelectionInterval(i, i);
- }
- } else if (!actions.contains(action)) {
- selectionModel.removeSelectionInterval(i, i);
- }
- }
- selectionModel.setValueIsAdjusting(false);
- }
-
- public VCSFileState[] getData(VCSState action) {
- if (isEmpty()) {
- return new VCSFileState[0];
- }
- List<VCSFileState> list = new ArrayList<VCSFileState>(data);
- for (Iterator<VCSFileState> it = list.iterator(); it.hasNext();) {
- VCSFileState fileState = it.next();
- if (!action.equals(fileState.getState())) {
- it.remove();
- }
- }
- return list.toArray(new VCSFileState[list.size()]);
- }
-
- public VCSState[] getStates() {
- if (isEmpty()) {
- return new VCSState[0];
- }
- List<VCSState> result = new ArrayList<VCSState>();
- for (VCSFileState vcsFileState : data) {
- VCSState state = vcsFileState.getState();
- if (state != null && !result.contains(state)) {
- result.add(state);
- }
- }
- return result.toArray(new VCSState[result.size()]);
- }
-
- public VCSAction[] getActions() {
- if (isEmpty()) {
- return new VCSAction[0];
- }
- List<VCSAction> result = new ArrayList<VCSAction>();
- 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()]);
- }
-
- public VCSFileState[] getData(ListSelectionModel selectionModel) {
- if (isEmpty() || selectionModel.isSelectionEmpty()) {
- return new VCSFileState[0];
- }
- List<VCSFileState> list = new ArrayList<VCSFileState>();
- for (int i = 0, max = size(); i < max; i++) {
- if (selectionModel.isSelectedIndex(i)) {
- list.add(data.get(i));
- }
- }
- return list.toArray(new VCSFileState[list.size()]);
- }
-
- public VCSAction[] getActions(ListSelectionModel selectionModel) {
- if (isEmpty() || selectionModel.isSelectionEmpty()) {
- return new VCSAction[0];
- }
- List<VCSAction> result = new ArrayList<VCSAction>();
- for (VCSState vcsFileState : getStates(selectionModel)) {
- 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()]);
- }
-
- public VCSState[] getStates(ListSelectionModel selectionModel) {
- if (isEmpty() || selectionModel.isSelectionEmpty()) {
- return new VCSState[0];
- }
- List<VCSState> result = new ArrayList<VCSState>();
- for (int i = 0, max = size(); i < max; i++) {
- if (selectionModel.isSelectedIndex(i)) {
- VCSFileState vcsFileState = data.get(i);
- VCSState state = vcsFileState.getState();
- if (state != null && !result.contains(state)) {
- result.add(state);
- }
- }
- }
- return result.toArray(new VCSState[result.size()]);
- }
-
-
- @Override
- public String toString() {
- return super.toString() + "<name:" + name + ", size:" + (isEmpty() ? "0" : size()) + '>';
- }
-
- public void refresh(VCSState... states) {
- //TODO launch refreshaction on given states
-
- }
-
-
- public int size() {
- return data.size();
- }
-}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/MethodTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/MethodTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/MethodTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,19 +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;
-
-/** @author chemit */
-public @interface MethodTest {
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/RepositoryStateTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/RepositoryStateTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/RepositoryStateTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,68 +0,0 @@
-package org.codelutin.vcs;
-
-import static org.codelutin.vcs.VCSType.SVN;
-
-import java.io.File;
-import java.util.List;
-
-public class RepositoryStateTest extends VCSTest {
- static protected int start, last;
-
- static protected int[] interval;
-
- static protected VCSLocalDataContext context;
-
- protected void setUpVars() {
- vcsType = SVN;
- resetConfiguration = true;
- }
-
- @Override
- protected void initConfig() throws Exception {
- super.initConfig();
- context = new VCSLocalDataContext(getLocalDatabaseFile());
- initVCS();
- }
-
- protected void tearDownVars() throws Exception {
- resetConfiguration = null;
- vcsType = null;
- disposeVCS();
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Demarrage du scenario
- // /////////////////////////////////////////////////////////////////////////
-
- static List<File> list, list2;
-
- static VCSState state;
-
- static long rev1, rev2, rev3;
-
- @MethodTest
- public final void testObtainFileState() {
- //fail("Not yet implemented"); // TODO
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Methodes utiles
- // /////////////////////////////////////////////////////////////////////////
-
- protected void setCommand(VCSState stateToTest, String command) {
- setCommand(start, last, stateToTest, command);
- }
-
- protected void setCommand(int pStart, int pLast, VCSState stateToTest,
- String command) {
- state = stateToTest;
- if (!(pStart == start && pLast == last)) {
- start = pStart;
- last = pLast;
- interval = context.getIndex(pStart, pLast);
- }
- log.info("[state:" + state + "] [" + command + "] on interval ["
- + start + "," + last + "]");
- }
-
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSFileStateManagerTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSFileStateManagerTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSFileStateManagerTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,251 +0,0 @@
-package org.codelutin.vcs;
-
-import static org.codelutin.vcs.VCSLocalData.FILE;
-import static org.codelutin.vcs.VCSState.MISSING;
-import static org.codelutin.vcs.VCSState.MODIFIED;
-import static org.codelutin.vcs.VCSState.OUT_OF_DATE;
-import static org.codelutin.vcs.VCSState.OUT_OF_DATE_AND_MODIFIED;
-import static org.codelutin.vcs.VCSState.UNKNOWN;
-import static org.codelutin.vcs.VCSState.UNVERSIONNED;
-import static org.codelutin.vcs.VCSState.UP_TO_DATE;
-
-import java.io.File;
-import static java.io.File.separator;
-import java.util.ArrayList;
-import static java.util.Arrays.asList;
-import java.util.List;
-
-/**
- * VCSFileStateManager Tester.
- *
- * @author <Authors name>
- * @version 1.0
- * @since <pre>10/14/2007</pre>
- */
-public class VCSFileStateManagerTest extends VCSTest {
-
- static protected int start, last;
- static protected int[] interval;
-
- static protected VCSHandler svnhandler;
- static protected VCSLocalDataContext context;
-
- protected void setUpVars() {
- vcsType = VCSType.SVN;
- resetConfiguration = true;
- }
-
- @Override
- protected void initConfig() throws Exception {
- super.initConfig();
- context = new VCSLocalDataContext(getLocalDatabaseFile());
-
- initVCS();
-
- }
-
- protected void tearDownVars() throws Exception {
- resetConfiguration = null;
- vcsType = null;
- disposeVCS();
- }
-
- ///////////////////////////////////////////////////////////////////////////
- /// Demarrage du scenario
- ///////////////////////////////////////////////////////////////////////////
-
- static List<File> list, list2;
- static List<VCSFileState> listS, list2S;
- static VCSState state;
- static long rev1, rev2, rev3;
-
- @MethodTest
- public void testUnknowState() throws Exception {
-
- // get n files unexisiting files and assert state is unknown
- setCommand(0, 2, UNKNOWN, "");
-
- list = context.getFile(VCSLocalData.FILE, interval);
-
- listS = new ArrayList<VCSFileState>();
- for (File file : list)
- listS.add(VCSFileStateManager.getState(handler, false, file));
- list2S = asList(VCSFileStateManager.getState(handler, false, list));
- assertEquals(listS, list2S);
-
- assertFileState(list, listS, null, false);
-
- assertFileState(list, listS, state, true);
-
- listS = new ArrayList<VCSFileState>();
- for (File file : list)
- listS.add(VCSFileStateManager.getState(handler, true, file));
-
- assertFileState(list, asList(
- VCSFileStateManager.getState(handler, true, list)), state, true);
-
- list2 = context.getFile(VCSLocalData.FILE, "subdir" + separator,
- interval);
-
- assertFileState(list2, list2S, state, true);
-
- }
-
- @MethodTest
- public void testUnversionnedState() throws Exception {
-
- // create n files and assert that state is unversionned
- setCommand(UNVERSIONNED, "");
-
- list = context.create(VCSLocalData.FILE, interval);
- assertFileState(list, listS, state, true);
-
- list2 = context.create(VCSLocalData.FILE, "subdir" + separator,
- interval);
- assertFileState(list2, list2S, state, true);
- }
-
- @MethodTest
- public void testUpToDateState() throws Exception {
-
- // add n files and assert to state is up to date
-
- setCommand(UP_TO_DATE, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- rev1 = handler.add(list, FILE.getCommitMessage("add", this));
-
- assertFileState(list, listS, state, true);
- }
-
- @MethodTest
- public void testMissingState() throws Exception {
-
- // delete locally 5 file and assert to state is missing
-
- setCommand(MISSING, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- context.delete(VCSLocalData.FILE, interval);
-
- assertFileState(list, listS, state, true);
-
- for (File file : list) handler.update(file);
-
- assertFileState(list, listS, UP_TO_DATE, true);
-
- }
-
-
- @MethodTest
- public void testModifiedState() throws Exception {
-
- // modify 5 file and assert to state is modified
-
- setCommand(MODIFIED, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- for (File file : list) modifyFile(file, 10, 'a');
-
- listS = asList(VCSFileStateManager.getState(handler, true, list));
- assertFileState(list, listS, state, true);
-
- handler.revert(list);
- listS = asList(VCSFileStateManager.getState(handler, true, list));
- assertFileState(list, listS, UP_TO_DATE, true);
- }
-
-
- @MethodTest
- public void testOutOfDateState() throws Exception {
-
- // commit n files, revert to first version and assert to state is
- // out to date
-
- setCommand(OUT_OF_DATE, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- for (File file : list) modifyFile(file, 10, 'a');
- listS = asList(VCSFileStateManager.getState(handler, true, list));
- assertFileState(list, listS, MODIFIED, true);
-
- /*rev2 = handler.commit(list, FILE.getCommitMessage("commit one", this));
-
- final SVNRevision revision = SVNRevision.create(rev1);
-
- for (File file : list) handler.update(file, revision);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, state, true);
-
- context.delete(VCSLocalData.FILE, interval);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, MISSING, true);
-
- for (File file : list) handler.update(file, revision);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, state, true);
- */
-
- }
-
- @MethodTest
- public void testOutOfDateAndModifiedState() throws Exception {
-
- // modified n files, revert to first version and assert to state is out
- // to date
-
- setCommand(OUT_OF_DATE_AND_MODIFIED, "");
-
- //list = context.getFile(VCSLocalData.FILE, interval);
-
- for (File file : list) modifyFile(file, 20, 'b');
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, state, true);
-
- //final SVNRevision revision = SVNRevision.create(rev1);
-
- handler.revert(list);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, OUT_OF_DATE, true);
-
- for (File file : list) modifyFile(file, 15, 'c');
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, state, true);
-
- handler.revert(list);
-
- //listS = asList(VCSFileStateManager.getFileState(true, handler, list));
- assertFileState(list, listS, OUT_OF_DATE, true);
- }
-
- ///////////////////////////////////////////////////////////////////////////
- /// Methodes utiles
- ///////////////////////////////////////////////////////////////////////////
-
- protected void setCommand(VCSState stateToTest, String command) {
- setCommand(start, last, stateToTest, command);
- }
-
- protected void setCommand(int pStart, int pLast, VCSState stateToTest,
- String command) {
- state = stateToTest;
- if (!(pStart == start && pLast == last)) {
- start = pStart;
- last = pLast;
- interval = context.getIndex(pStart, pLast);
- }
-
- log.info("[state:" + state + "] [" + command + "] on interval [" + start + "," + last + "]");
- }
-
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSHandlerTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSHandlerTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSHandlerTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,582 +0,0 @@
-package org.codelutin.vcs;
-
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This junit test class tests all methods of the implementation of a VCSHandler <code>XXX</code> (says CVS, or SVN)
- * The VCSType used is junit_<code>XXX</code>
- * The remote database is name is isis-fish-vcs-test_junit
- * The local database name is isis-fish-vcs-test_junit_<code>XXX</code>
- */
-public abstract class VCSHandlerTest extends VCSTest {
-
- //static protected final String patternFile = "_file_{0}.txt";
- //static protected final String patternDirectory = "_directory_{0}.txt";
-
- private static int start, last;
- private static int[] interval;
-
- static protected VCSLocalDataContext context;
-
- protected void setUpVars() {
- resetConfiguration = true;
- }
-
- @Override
- protected void initConfig() throws Exception {
- super.initConfig();
- context = new VCSLocalDataContext(getLocalDatabaseFile());
- }
-
- protected void tearDownVars() {
- resetConfiguration = null;
- vcsType = null;
- }
-
- //TODO Should test configuration ?
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// Tests des cas limites
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @MethodTest
- public void testAddWithNullFileList() throws Exception {
- try {
- handler.add(null, VCSLocalData.FILE.getCommitMessage("add", this));
- fail();
- } catch (VCSRuntimeException e) {
- assertTrue(true);
- }
- }
-
- @MethodTest
- public void testAddUnExistantFiles() throws Exception {
- // try to add non existing file
-
- List<File> files = context.getFile(VCSLocalData.FILE, 0, 1);
-
- long rev = handler.add(files, VCSLocalData.FILE.getCommitMessage("add unexistant ", this));
- assertEquals(rev, -1);
-
- }
-
-
- @MethodTest
- public void testAddUnExistantFilesWithNoCommit() throws Exception {
- try {
- handler.add(null, null);
- fail();
- } catch (VCSRuntimeException e) {
- assertTrue(true);
- }
- }
-
- @MethodTest
- public void testDeleteNullFileList() throws Exception {
- try {
- handler.delete(null, "");
- fail();
- } catch (VCSRuntimeException e) {
- assertTrue(true);
- }
- }
-
- @MethodTest
- public void testDeleteNullFileListWithNocommit() throws Exception {
- try {
- handler.delete(null, null);
- fail();
- } catch (VCSRuntimeException e) {
- assertTrue(true);
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// Preparation repository et working copy
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @MethodTest
- public void testCreateRemoteDatabaseDirectory() throws Exception {
-
- // assert remote database does not exists
- try {
- handler.deleteRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("deldir remote", this), "");
- } catch (VCSException e) {
- // this is ok for this time :)
- // we just wants to be sure the remote database directory does not exists any longer
- }
-
- // create remote directory
- handler.makeRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("mkdir remote", this), "");
-
- // assert remote directory exist now
-
- }
-
- @MethodTest
- public void testCheckoutDatabaseDirectory() throws Exception {
-
- handler.deleteWorkingCopy();
-
- // assert local directory not exists
- assertFalse(getLocalDatabaseFile().exists());
-
- handler.initWorkingCopy();
-
- // assert directory exists and contains vcs configuration directory in this file
- assertTrue(getLocalDatabaseFile().exists());
-
- assertTrue(new File(getLocalDatabaseFile(), handler.getConfLocalDirname()).exists());
-
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// Demarrage du scenario
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- static List<File> list;
-
- @MethodTest
- public void testAddFiles() throws Exception {
- setCommand(0, 4, "add with commit");
- list = context.create(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UNVERSIONNED);
-
- handler.add(list, VCSLocalData.FILE.getCommitMessage("add", this));
-
- assertState(list, VCSState.UP_TO_DATE);
-
- }
-
- @MethodTest
- public void testAddDirectories() throws Exception {
- setCommand(0, 4, "add with commit");
- list = context.create(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UNVERSIONNED);
-
-
- handler.add(list, VCSLocalData.DIRECTORY.getCommitMessage("add", this));
-
- assertState(list, VCSState.UP_TO_DATE);
- }
-
- @MethodTest
- public void testAddFilesWithNoCommit() throws Exception {
- setCommand(5, 9, "add with no commit");
- list = context.create(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UNVERSIONNED);
-
- handler.add(list, null);
-
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testAddDirectoriesWithNoCommit() throws Exception {
- list = context.create(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UNVERSIONNED);
-
- handler.add(list, null);
-
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testCommitAddFiles() throws Exception {
- setCommand(5, 9, "commit unadded");
- list = context.getFile(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UNKNOWN);
-
- handler.commit(list, VCSLocalData.FILE.getCommitMessage("commit unadded", this));
-
- assertState(list, VCSState.UP_TO_DATE);
- }
-
- @MethodTest
- public void testCommitAddDirectories() throws Exception {
- list = context.getFile(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UNKNOWN);
-
- handler.commit(list, VCSLocalData.DIRECTORY.getCommitMessage("commit unadded", this));
-
- assertState(list, VCSState.UP_TO_DATE);
- }
-
- @MethodTest
- public void testDeleteFiles() throws Exception {
- setCommand(7, 9, "delete with commit");
- list = context.getFile(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.delete(list, VCSLocalData.FILE.getCommitMessage("delete", this));
-
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testDeleteDirectories() throws Exception {
- list = context.getFile(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.delete(list, VCSLocalData.DIRECTORY.getCommitMessage("delete", this));
-
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testDeleteFilesWithNocommit() throws Exception {
- setCommand(4, 6, "delete with no commit");
- list = context.getFile(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.delete(list, null);
-
- assertState(list, VCSState.UNKNOWN);
- }
-
-
- @MethodTest
- public void testDeleteDirectoriesWithNocommit() throws Exception {
- list = context.getFile(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.delete(list, null);
-
- assertState(list, VCSState.UNKNOWN);
-
- }
-
- @MethodTest
- public void testCommitDeleteFiles() throws Exception {
- setCommand(4, 6, "commit undeleted");
- list = context.getFile(VCSLocalData.FILE, interval);
- assertState(list, VCSState.UNKNOWN);
-
- handler.commit(list, VCSLocalData.FILE.getCommitMessage("commit undeleted", this));
-
- // when commit a deleted file, we do not delete locally file
- // => so this is a unversioned file
- assertState(list, VCSState.UNVERSIONNED);
-
- // we delete files by hand...
- context.delete(VCSLocalData.FILE, interval);
-
- }
-
- @MethodTest
- public void testCommitDeleteDirectories() throws Exception {
- list = context.getFile(VCSLocalData.DIRECTORY, interval);
- assertState(list, VCSState.UNKNOWN);
-
- handler.commit(list, VCSLocalData.DIRECTORY.getCommitMessage("commit undeleted",
- this));
-
- // when commit a deleted directory, direcotry is deleted !!! Find why ?
- assertState(list, VCSState.UNKNOWN);
- }
-
- @MethodTest
- public void testGetLocalStorageNames() throws Exception {
-
- // at this point of the scenario, we only have a [0-3]
- // (files/directories) left on local and remote
- setCommand(0, 3, "getLocalStorageNames");
-
- List<String> excepted = new ArrayList<String>();
-
- list = context.getFile(VCSLocalData.FILE, interval);
- //list.addAll(context.getFile(VCSLocalData.DIRECTORY, interval));
- for (File f : list) if (f.isFile()) excepted.add(f.getName());
-
- List<String> list2 =
- handler.getLocalStorageNames(getLocalDatabaseFile());
-
- assertEquals(excepted.size(), list2.size());
-
- for (String filename : excepted) {
- assertTrue("should have found a " + filename +
- " file in result but we do not! ",
- list2.contains(filename));
- }
-
- }
-
- @MethodTest
- public void testGetRemoteStorageNames() throws Exception {
-
- // at this point of the scenario, we only have a [0-3]
- // (files/directories) left on local and remote
- setCommand(0, 3, "getRemoteStorageNames");
-
- list = context.getFile(VCSLocalData.FILE, interval);
- //list.addAll(context.getFile(VCSLocalData.DIRECTORY, interval));
-
- List<String> list2 =
- handler.getRemoteStorageNames(getLocalDatabaseFile());
-
- assertEquals(list.size(), list2.size());
-
- // we can not know the style of encoded remote name ?
- //for (File f : list) assertTrue(list2.contains(f));
- }
-
- @MethodTest
- public void testIsOnRemote() throws Exception {
-
- // at this point of the scenario, we only have a [0-3]
- // (files/directories) left on local and remote
- setCommand(0, 3, "isOnRemote");
-
- list = context.getFile(VCSLocalData.FILE, interval);
- list.addAll(context.getFile(VCSLocalData.DIRECTORY, interval));
-
- for (File f : list) assertTrue(handler.isOnRemote(f));
-
- assertFalse(handler.isOnRemote(new File(getLocalDatabaseFile(),
- "nonExistingFile")));
-
- }
-
- @MethodTest
- public void testRevert() throws Exception {
-
- // at this point of the scenario, we only have a [0-3]
- // (files/directories) left on local and remote
- setCommand(0, 3, "revert");
-
- //TODO we only test on file (I don't think you can have
- // a modified directory ? should be check...)
- list = context.getFile(VCSLocalData.FILE, interval);
-
- assertState(list, VCSState.UP_TO_DATE);
-
- handler.revert(list);
-
- // revert on a normal file should have no effect
- assertState(list, VCSState.UP_TO_DATE);
-
- for (File f : list) {
- // we know that file is 0, change it to 10 (with 10 a for example)
- modifyFile(f, 10);
- }
- assertState(list, VCSState.MODIFIED);
-
- handler.revert(list);
-
- // we came back to file with size = 0
-
- assertState(list, VCSState.UP_TO_DATE);
- for (File f : list) assertEquals(f.length(), 0);
-
- // a non existing file can not be revert of course....
- File file = new File(getLocalDatabaseFile(), "nonExistingFile");
- try {
- handler.revert(this.getOneFileAsList(file));
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- }
-
- // now file exists, but still can not revert it since it is not
- // versionned
- file.createNewFile();
- try {
- handler.revert(this.getOneFileAsList(file));
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- } finally {
- file.delete();
- }
- }
-
- @MethodTest
- public void testUpdate() throws Exception {
-
- // at this point of the scenario, we only have a [0-3] (files/directories) left on local and remote
- setCommand(0, 3, "update");
-
- //TODO we only test on file (I don't think you can have a modified directory ? should be check...)
- list = context.getFile(VCSLocalData.FILE, interval);
-
- assertState(list, VCSState.UP_TO_DATE);
-
- File f = list.get(0);
-
- handler.update(f);
-
- // update a non remoted modfied file should have no effect
- assertState(list, VCSState.UP_TO_DATE);
-
- // we know that file is 0, change it to 10 (with 10 a for example)
- modifyFile(f, 20);
-
- // file is modified now
- assertState(f, VCSState.MODIFIED);
-
- // we can not update a modifed file
- try {
- handler.update(f);
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- }
-
- Object fileRevision = handler.getRevision(f);
-
- // delete file
- VCSLocalData.FILE.delete(f);
-
- // update it from remote vcs
- handler.update(f);
-
- // back to normal after update
- assertState(f, VCSState.UP_TO_DATE);
-
- assertEquals(fileRevision, handler.getRevision(f));
-
- // a non existing file can not be revert of course....
- File file = new File(getLocalDatabaseFile(), "nonExistingFile");
- try {
- handler.revert(this.getOneFileAsList(file));
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- }
-
- // now file exists, but still can not revert it since it is not versionned
- file.createNewFile();
- try {
- handler.revert(this.getOneFileAsList(file));
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- } finally {
- file.delete();
- }
-
- }
-
-
- @MethodTest
- public void testIsUpToDate() throws Exception {
-
- // at this point of the scenario, we only have a [0-3] (files/directories) left on local and remote
- setCommand(0, 3, "isUpToDate");
-
- list = context.getFile(VCSLocalData.FILE, interval);
-
- assertTrue(list.size() > 0);
-
- assertState(list, VCSState.UP_TO_DATE);
-
- for (File f : list) assertTrue(handler.isUpToDate(f));
-
- File f = list.get(0);
-
- Object oldRev = handler.getRevision(f);
-
- // modify file : so file is no more upTodate
- modifyFile(f, 30);
-
- assertFalse(handler.isUpToDate(f));
-
- // commit file
- handler.commit(getOneFileAsList(f), VCSLocalData.FILE.getCommitMessage("commit for test", this));
-
- assertTrue(handler.isUpToDate(f));
-
- // delete file from local working copy, so file is no more upToDate
- VCSLocalData.FILE.delete(f);
-
- assertFalse(handler.isUpToDate(f));
-
- // go back to previous version
- handler.update(f, oldRev);
-
- // now local file is out up to date : older revision than on remote repository
- assertFalse(handler.isUpToDate(f));
-
- // delete file from remote repository, so file is no more upToDate
- try {
- handler.delete(getOneFileAsList(f), VCSLocalData.FILE.getCommitMessage("delete", this));
- // we can not delete a non updated file
- fail();
- } catch (VCSException e) {
- assertTrue(true);
- handler.revert(getOneFileAsList(f));
- }
-
- // go back to head
- handler.update(f);
-
- assertTrue(handler.isUpToDate(f));
-
- handler.delete(getOneFileAsList(f), VCSLocalData.FILE.getCommitMessage("delete", this));
-
- assertFalse(handler.isUpToDate(f));
-
- // read file : file is uptodate
-
- f.createNewFile();
-
- handler.add(getOneFileAsList(f), VCSLocalData.FILE.getCommitMessage("readd", this));
-
- assertTrue(handler.isUpToDate(f));
-
- // a non existing file can not be up to date of course...
- File file = new File(getLocalDatabaseFile(), "nonExistingFile");
- assertFalse(handler.isUpToDate(file));
-
- // now file exists, but still not up to date
- file.createNewFile();
- try {
- assertFalse(handler.isUpToDate(file));
- } finally {
- file.delete();
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// Suppression du repository et working copy
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @MethodTest
- public void testDeleteRemoteDir() throws Exception {
-
- // delete remote directory
- handler.deleteRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("deldir remote", this), "");
-
- // assert remote directory doe not exist any more
-
- }
-
- @MethodTest
- public void testDeleteWorkingCopy() throws Exception {
-
- handler.deleteWorkingCopy();
-
- // assert local directory does not exists any longer
- assertFalse(getLocalDatabaseFile().exists());
-
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- /// M�thodes utiles
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- protected void setCommand(int start, int last, String command) {
- if (!(start == VCSHandlerTest.start && last == VCSHandlerTest.last)) {
- VCSHandlerTest.start = start;
- VCSHandlerTest.last = last;
- VCSHandlerTest.interval = context.getIndex(start, last);
- }
-
- log.info("[" + command + "] on interval [" + VCSHandlerTest.start + "," + VCSHandlerTest.last + "]");
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSInitTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSInitTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSInitTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,134 +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 junit.framework.TestCase;
-import org.codelutin.i18n.I18n;
-
-
-/**
- * Test vcs properties at init time. TODO Redo it with new init proccess
- *
- * @author chemit
- * @version 1.0
- * @since <pre>12/09/2007</pre>
- */
-public class VCSInitTest extends TestCase {
-
- static {
- // init i18n
- I18n.init();
- }
-
- public void testFirstLaunchWithCVS() throws Exception {
-// init = new OldVCSInit(
-// VCSType.CVS,
-// new VersionNumber(1,1,0),
-// null
-// );
-// assertTrue(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertFalse(init.isTypeChanged());
-// assertFalse(init.needMigration());
-// assertEquals(init.newVCSProperties.getProperty(VCS_TYPE_REPO), VCSTypeRepo.NONE);
- }
-
- public void testFirstLaunchWithSVN_onHEAD() throws Exception {
-// init = new OldVCSInit(
-// VCSType.SVN,
-// new VersionNumber(1,1,0),
-// null
-// );
-// assertTrue(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertFalse(init.isTypeChanged());
-// assertFalse(init.needMigration());
-// assertEquals(init.newVCSProperties.getProperty(VCS_TYPE_REPO), VCSTypeRepo.HEAD);
- }
-
- public void testFirstLaunchWithSVN_onTAG() throws Exception {
-// init = new OldVCSInit(
-// VCSType.SVN,
-// new VersionNumber(3,0,19),
-// null
-// );
-// assertTrue(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertFalse(init.isTypeChanged());
-// assertFalse(init.needMigration());
-// assertEquals(VCSTypeRepo.TAG,init.newVCSProperties.getProperty(VCS_TYPE_REPO));
- }
-
- public void testPreviousWasCVSNewIsCVS() throws Exception {
-// URI uri = getClass().getResource("/.isis-config-3_cvs").toURI();
-// init = new OldVCSInit(
-// VCSType.CVS,
-// new VersionNumber(1,1,0),
-// uri
-// );
-// assertFalse(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertFalse(init.isTypeChanged());
-// assertFalse(init.needMigration());
-// assertEquals(VCSTypeRepo.NONE,init.newVCSProperties.getProperty(VCS_TYPE_REPO));
- }
-
- public void testPreviousWasCVSNewIsSVN() throws Exception {
-// URI uri = getClass().getResource("/.isis-config-3_cvs").toURI();
-// init = new OldVCSInit(
-// VCSType.SVN,
-// new VersionNumber(1,1,0),
-// uri
-// );
-// assertFalse(init.oldVCSProperties.isEmpty());
-// assertFalse(init.oldVCSProperties.isFull());
-// assertFalse(init.newVCSProperties.isEmpty());
-// assertFalse(init.newVCSProperties.isFull());
-// assertTrue(init.newVCSProperties.isSafe());
-//
-// assertTrue(init.isTypeChanged());
-// assertTrue(init.needMigration());
-// assertEquals(VCSTypeRepo.HEAD,init.newVCSProperties.getProperty(VCS_TYPE_REPO));
- }
-
- public void testPreviousWasSVNNewIsTAG() throws Exception {
- //TODO
- }
-
- public void testPreviousWasSVNNewIsHEAD() throws Exception {
- //TODO
- }
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalData.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalData.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalData.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,112 +0,0 @@
-package org.codelutin.vcs;
-
-import junit.framework.TestCase;
-import org.codelutin.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import static java.text.MessageFormat.format;
-
-/**
- * Util for our local files and directories with a pattern for name,
- * when VCSHandlerTest operation (exist, create, delete).
- *
- * @see VCSHandlerTest
- */
-public enum VCSLocalData {
-
- DIRECTORY("_directory_{0}", "{0} directory by test {1}#{2} at {3}") {
-
- boolean delete(File f) throws IOException {
- return FileUtil.deleteRecursively(f) && f.delete();
- }
- boolean create(File f) throws IOException {
- return f.mkdirs();
- }
- },
-
- FILE("_file_{0}.txt", "{0} file by test {1}#{2} at {3}") {
-
- boolean delete(File f) throws IOException {
- return f.delete();
- }
- boolean create(File f) throws IOException {
- if (!f.getParentFile().exists()) f.getParentFile().mkdirs();
- return f.createNewFile();
- }
- };
-
- abstract boolean create(File f) throws IOException;
-
- abstract boolean delete(File f) throws IOException;
-
- private String pattern;
-
- private String commitPattern;
-
- VCSLocalData(String pattern, String commitPattern) {
- this.commitPattern = commitPattern;
- this.pattern = pattern;
- }
-
- public boolean exists(File root, int... index) {
- for (int i : index)
- if (!getFile(root, i).exists()) return false;
- return true;
- }
-
- public File getFile(File root, int index) {
- return new File(root, format(pattern, index));
- }
-
- public File[] getFile(File root, int... index) {
- File[] result = new File[index.length];
- for (int i1 = 0; i1 < index.length; i1++) {
- int i = index[i1];
- result[i1] = getFile(root, i);
- }
- return result;
- }
-
- public void create(File root, int... index) throws IOException {
- for (int anIndex : index) create(getFile(root, anIndex));
-
- }
-
- public void create(File root, String prefix, int... index) throws IOException {
- for (int anIndex : index) create(getFile(root, prefix, anIndex));
-
- }
-
- private File getFile(File root, String prefix, int anIndex) {
- return new File(root, prefix + format(pattern, anIndex));
- }
-
- public String getFilename(String prefix, int anIndex) {
- return prefix + format(pattern, anIndex);
- }
-
- public boolean delete(File root, int index) throws IOException {
- final File file = getFile(root, index);
- return delete(file);
- }
-
- public boolean delete(File root, int... index) throws IOException {
- for (int i : index)
- if (!delete(root, i)) return false;
- return true;
- }
-
- public String getCommitMessage(String command, TestCase test) {
- return format(commitPattern, command, test.getClass(), test.getName(), new java.util.Date());
- }
-
- public File[] getFile(File root, String prefix, int[] index) {
- File[] result = new File[index.length];
- for (int i1 = 0; i1 < index.length; i1++) {
- int i = index[i1];
- result[i1] = getFile(root, prefix, i);
- }
- return result;
- }
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalDataContext.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalDataContext.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSLocalDataContext.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,60 +0,0 @@
-package org.codelutin.vcs;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class VCSLocalDataContext {
-
- File root;
- private List<File> result;
-
-
- public VCSLocalDataContext(File root) {
- this.root = root;
- }
-
- public boolean exist(VCSLocalData type, int... index) {
- return type.exists(root, index);
- }
-
- public List<File> getFile(VCSLocalData type, int... index) {
- final File[] files = type.getFile(root, index);
- if (result == null) result = new ArrayList<File>();
- else result.clear();
- result.addAll(Arrays.asList(files));
- List<File> res = new ArrayList<File>();
- res.addAll(result);
- return res;
- }
-
- public List<File> create(VCSLocalData type, int... index) throws IOException {
- type.create(root, index);
- return getFile(type, index);
- }
-
- public List<File> create(VCSLocalData type, String prefix, int... index) throws IOException {
- type.create(root, prefix, index);
- return getFile(type, prefix, index);
- }
-
- public List<File> getFile(VCSLocalData type, String prefix, int[] index) {
- final File[] files = type.getFile(root, prefix, index);
- List<File> res = new ArrayList<File>();
- res.addAll(Arrays.asList(files));
- return res;
- }
-
- public void delete(VCSLocalData type, int... index) throws IOException {
- type.delete(root, index);
- }
-
- public int[] getIndex(int first, int last) {
- final int size = last - first;
- int[] result = new int[size + 1];
- for (int i = 0; i <= size; i++) result[i] = i + first;
- return result;
- }
-}
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSStateTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSStateTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSStateTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,235 +0,0 @@
-package org.codelutin.vcs;
-
-import junit.framework.Assert;
-import org.codelutin.util.FileUtil;
-import static org.codelutin.vcs.VCSState.UNVERSIONNED_OR_MISSING;
-import static org.codelutin.vcs.VCSType.SVN;
-import org.codelutin.vcs.util.VCSHelper;
-
-import java.io.File;
-import static java.io.File.separator;
-import java.util.ArrayList;
-import java.util.List;
-
-public class VCSStateTest extends VCSTest {
- static protected int start, last;
-
- static protected int[] interval;
-
- static protected VCSLocalDataContext context;
-
- protected void setUpVars() {
- VCSTest.vcsType = SVN;
- VCSTest.resetConfiguration = true;
- }
-
- @Override
- protected void initConfig() throws Exception {
- super.initConfig();
- context = new VCSLocalDataContext(getLocalDatabaseFile());
-
- initVCS();
- }
-
- protected void tearDownVars() throws Exception {
- VCSTest.resetConfiguration = null;
- VCSTest.vcsType = null;
- disposeVCS();
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Demarrage du scenario
- // /////////////////////////////////////////////////////////////////////////
-
- static List<File> list, list2;
-
- static VCSState state;
-
- static long rev1, rev2, rev3;
-
- @MethodTest
- public void testRemotePathFromLocalFile() throws Exception {
-
- // get n files unexisiting files and assert state is unknown
- setCommand(0, 2, VCSState.UNKNOWN, "conversion from local file to "
- + "remote module path");
-
- list = context.getFile(VCSLocalData.FILE, interval);
-
- for (int i = 0; i < list.size(); i++) {
- Assert.assertEquals(VCSHelper.getRemoteRelativePath(list.get(i), VCSTest.handler),
- VCSLocalData.FILE.getFilename("", i));
- }
-
- list2 = context.create(VCSLocalData.FILE, "subdir" + separator, interval);
- for (int i = 0; i < list2.size(); i++) {
- String expected = VCSHelper.getRemoteRelativePath(list2.get(i),
- VCSTest.handler);
- String actual = VCSHelper.convertToRemoteName(VCSLocalData.FILE
- .getFilename("subdir" + File.separator, i));
- System.out.println("excepted " + expected + " actual " + actual);
- Assert.assertEquals(expected, VCSHelper.convertToRemoteName(actual));
- }
- FileUtil.deleteRecursively(new File(VCSHandlerFactory.getConfig().getLocalDatabasePath(), "subdir"));
- }
-
- @MethodTest
- public void testUnknowState() throws Exception {
-
- // get n files unexisiting files and assert state is unknown
- setCommand(0, 2, VCSState.UNKNOWN, "");
-
- list = context.getFile(VCSLocalData.FILE, interval);
- VCSTest.assertState(list, state);
-
- list2 = context.getFile(VCSLocalData.FILE, "subdir" + separator, interval);
- VCSTest.assertState(list2, state);
- }
-
- @MethodTest
- public void testUnversionnedState() throws Exception {
-
- // create n files and assert that state is unversionned
- setCommand(VCSState.UNVERSIONNED, "");
-
- context.create(VCSLocalData.FILE, interval);
- VCSTest.assertState(list, state);
- }
-
- @MethodTest
- public void testUnversionnedOrMissingState() throws Exception {
-
- // create n files and assert that state is unversionned
- setCommand(VCSState.UNVERSIONNED_OR_MISSING, "");
-
- context.create(VCSLocalData.FILE, "subdir" + separator, interval);
- VCSTest.assertState(list2, UNVERSIONNED_OR_MISSING);
- }
-
- @MethodTest
- public void testUpToDateState() throws Exception {
-
- // add n files and assert to state is up to date
-
- setCommand(VCSState.UP_TO_DATE, "");
-
- rev1 = VCSTest.handler.add(new ArrayList<File>(list),
- VCSLocalData.FILE.getCommitMessage("add", this));
-
- VCSTest.assertState(list, state);
-
- }
-
- @MethodTest
- public void testMissingState() throws Exception {
-
- // delete locally 5 file and assert to state is missing
-
- setCommand(VCSState.MISSING, "");
-
- context.delete(VCSLocalData.FILE, interval);
- VCSTest.assertState(list, state);
-
- update(list);
- VCSTest.assertState(list, VCSState.UP_TO_DATE);
- final File subdir = new File(VCSTest.databaseDirectory, "subdir");
- context.create(VCSLocalData.FILE, "subdir" + separator, interval);
- VCSTest.handler.add(getOneFileAsList(subdir), VCSLocalData.FILE.getCommitMessage(
- "add sub files", this));
-
- VCSTest.handler.add(list2, VCSLocalData.FILE.getCommitMessage("add sub files", this));
- VCSTest.assertState(list2, VCSState.UP_TO_DATE);
-
- FileUtil.deleteRecursively(subdir);
-
- context.create(VCSLocalData.FILE, "subdir" + separator, interval);
-
- VCSTest.assertState(list2, UNVERSIONNED_OR_MISSING);
-
- }
-
- @MethodTest
- public void testModifiedState() throws Exception {
-
- // modify 5 file and assert to state is modified
-
- setCommand(VCSState.MODIFIED, "");
-
- modifyFile(list, 30, 'h');
- VCSTest.assertState(list, state);
-
- VCSTest.handler.revert(list);
- VCSTest.assertState(list, VCSState.UP_TO_DATE);
- }
-
- @MethodTest
- public void testOutOfDateState() throws Exception {
-
- // commit n files, revert to first version and assert to state is
- // out to date
-
- setCommand(VCSState.OUT_OF_DATE, "");
-
- modifyFile(list, 45, 'j');
- VCSTest.assertState(list, VCSState.MODIFIED);
-
- /*rev2 = VCSTest.handler.commit(list, VCSLocalData.FILE.getCommitMessage("commit one", this));
- final SVNRevision revision = SVNRevision.create(rev1);
-
- update(list, revision);
- VCSTest.assertState(list, state);
-
- context.delete(VCSLocalData.FILE, interval);
- VCSTest.assertState(list, VCSState.MISSING);
-
- update(list, revision);
- VCSTest.assertState(list, state);*/
-
- }
-
- @MethodTest
- public void testOutOfDateAndModifiedState() throws Exception {
-
- // modified n files, revert to first version and assert to state is out
- // to date
-
- setCommand(VCSState.OUT_OF_DATE_AND_MODIFIED, "");
-
- modifyFile(list, 14, 'n');
-
- VCSTest.assertState(list, state);
-
- VCSTest.handler.revert(list);
-
- VCSTest.assertState(list, VCSState.OUT_OF_DATE);
-
- modifyFile(list, 46, 'o');
-
- VCSTest.assertState(list, state);
-
- VCSTest.handler.revert(list);
-
- VCSTest.assertState(list, VCSState.OUT_OF_DATE);
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Methodes utiles
- // /////////////////////////////////////////////////////////////////////////
-
- protected void setCommand(VCSState stateToTest, String command) {
- setCommand(start, last, stateToTest, command);
- }
-
- protected void setCommand(int pStart, int pLast, VCSState stateToTest,
- String command) {
- state = stateToTest;
- if (!(pStart == start && pLast == last)) {
- start = pStart;
- last = pLast;
- interval = context.getIndex(pStart, pLast);
- }
- VCSTest.log.info("[state:" + state + "] [" + command + "] on interval ["
- + start + "," + last + "]");
- }
-
-}
\ No newline at end of file
Deleted: trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSTest.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSTest.java 2008-04-05 20:37:17 UTC (rev 362)
+++ trunk/lutinvcs/lutinvcs-core/src/test/java/org/codelutin/vcs/VCSTest.java 2008-04-05 20:37:32 UTC (rev 363)
@@ -1,324 +0,0 @@
-package org.codelutin.vcs;
-
-import junit.framework.TestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.log.LutinLogFactory;
-import org.codelutin.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * abstract test for a vcs should be implements by any new vcs handler
- *
- * @author chemit
- */
-public abstract class VCSTest extends TestCase {
-
- static protected Boolean resetConfiguration;
-
- static protected VCSType vcsType;
-
- /** method to be invoked before first test */
- protected abstract void setUpVars();
-
- /**
- * method to be inocked after last test
- *
- * @throws Exception TODO
- */
- protected abstract void tearDownVars() throws Exception;
-
- /** flag to says we have already invoked setVars method */
- static protected boolean init = false;
-
- static protected VCSConfig config;
-
- static protected File databaseDirectory;
-
- static protected File oldConfig;
-
- static protected VCSHandler handler;
-
- static protected int nbTests;
-
- static protected int currentTest = 0;
-
- static {
- System.setProperty("org.apache.commons.logging.LogFactory", LutinLogFactory.class.getName());
- }
-
- protected static Log log = LogFactory.getLog(VCSTest.class);
-
- protected void resetConfig() throws Exception {
- log.info(" process " + currentTest + "/" + nbTests + " tests for "
- + getClass());
- tearDownVars();
- log.info(" == pause for one second, waiting for next test...");
- Thread.sleep(100);
- nbTests = currentTest = 0;
- config = null;
- handler = null;
- databaseDirectory = null;
- init = false;
-
- // push back previous configuration file
- String path = oldConfig.getAbsolutePath();
- FileUtil.copy(oldConfig, new File(path.substring(0, path.length() - 4)));
- oldConfig.delete();
- }
-
- private static String originalLocalDatabaseName;
- private static String originalRemoteDatabaseName;
-
- protected void initConfig() throws Exception {
- try {
- setUpVars();
-
- long timestamp = System.nanoTime();
-
- nbTests = getNbTests();
-
- log.info("[" + timestamp + "] found " + nbTests + " tests for " + getClass());
-
- File dConfig = new File(System.getProperty("user.home"), ".isis-config-3");
-
- if (dConfig.exists()) {
- oldConfig = new File(dConfig.getParentFile(), dConfig.getName() + "_old");
- FileUtil.copy(dConfig, oldConfig);
- }
-
- //IsisFish.init();
- //TODO force type load(vcsType);
-
- //config = IsisContext.get().getVcsConfig();
- config = null;
-
- String lname = config.getLocalDatabasePath().getName();
- String rname = config.getRemoteDatabase();
- if (originalLocalDatabaseName == null) {
- originalLocalDatabaseName = lname;
- originalRemoteDatabaseName = rname;
- } else {
- lname = originalLocalDatabaseName;
- rname = originalRemoteDatabaseName;
- }
- //IsisVcsConfig.LOCAL_DATABASE_PROPERTY_KEY.setCurrentValue(lname + timestamp);
-
- //IsisVcsConfig.REMOTE_DATABASE_PROPERTY_KEY.setCurrentValue( rname + timestamp);
-
- try {
- config.validate();
-
- } catch (VCSRuntimeException e) {
- log.fatal("Fill missing properties in configuration file ["
- + config.getSource() + "]");
- System.exit(1);
- }
-
- assertTrue(config.isInit());
-
- handler = VCSHandlerFactory.getHandler();
- //handler = IsisContext.get().getVCSHanler();
-
- assertNotNull(handler);
-
- databaseDirectory = config.getLocalDatabasePath();
-
- log.info("localDatabase : [" + databaseDirectory + "]");
- log.info("remoteDatabase : [" + config.getRemoteDatabasePath()
- + "]");
- log.info("remote url : [" + handler.getRemoteUrl() + "]");
- log.debug("handler : " + handler);
- init = true;
- } catch (Exception e) {
- log.error("could not load Default VCSHandler ", e);
- fail();
- }
- }
-
- protected void postInitConfig() throws VCSException {
- // init root of working copy (check it out if it the first use)
- handler.initWorkingCopy();
- assertTrue(databaseDirectory != null && databaseDirectory.exists());
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- if (!init) {
- initConfig();
- }
- currentTest++;
- log.debug(" (" + currentTest + "/" + nbTests + ") : " + this);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- log.debug(" (" + currentTest + "/" + nbTests + ") : " + this);
- if (currentTest == nbTests)
- resetConfig();
- }
-
- protected int getNbTests() {
- int result = 0;
- for (java.lang.reflect.Method method : getClass().getMethods())
- if (method.isAnnotationPresent(MethodTest.class))
- result++;
-
- assertTrue("find no test methods marked with annotation "
- + MethodTest.class + "in class " + getClass(), result > 0);
- return result;
- }
-
- protected MethodTest getMethodTest() {
- try {
-
- return getClass().getMethod(getName()).getAnnotation(
- MethodTest.class);
-
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected File getLocalDatabaseFile() {
- return VCSHandlerFactory.getConfig().getLocalDatabasePath();
- }
-
- protected void update(List<File> list) throws VCSException {
- for (File file : list)
- handler.update(file);
- }
-
- protected void update(List<File> list, VCSRevision revision)
- throws VCSException {
- for (File file : list)
- handler.update(file, revision);
- }
-
- public static void assertState(List<File> files, VCSState status)
- throws VCSException {
- for (File file : files) {
- final VCSState state = handler.getState(file, new ArrayList());
- if (state != status)
- fail("state required [" + status + "] but found [" + state
- + "] for files " + file);
- }
- }
-
- public static void assertFileState(List<File> list,
- List<VCSFileState> files, VCSState status, boolean synch)
- throws VCSException {
- if (synch)
- VCSFileStateManager.doSynch(handler, list);
- VCSState state;
- for (VCSFileState file : files) {
- try {
- state = file.getState();
- if (state != status)
- fail("state required [" + status + "] but found [" + state
- + "] for files " + file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- public static void assertState(File file, VCSState status)
- throws VCSException {
- final VCSState vcsStatus = handler.getState(file, new ArrayList());
- if (vcsStatus != status)
- fail("state required [" + status + "] but found [" + vcsStatus
- + "] for file " + file);
- }
-
- protected void modifyFile(List<File> f) throws IOException {
- modifyFile(f, 10, 'a');
- for (File file : f) {
- modifyFile(file, 10, 'a');
- }
- }
-
- protected void modifyFile(List<File> f, int newSize) throws IOException {
- modifyFile(f, newSize, 'b');
- }
-
- protected void modifyFile(List<File> f, int newSize, char c)
- throws IOException {
- for (File file : f)
- modifyFile(file, newSize, c);
- }
-
- protected void modifyFile(File f, int newSize) throws IOException {
- modifyFile(f, newSize, 'a');
- }
-
- protected void modifyFile(File f, int newSize, char c) throws IOException {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < newSize; i++)
- sb.append(c);
- FileUtil.writeString(f, sb.toString());
- }
-
- protected List<File> getOneFileAsList(File f) {
- List<File> result = new ArrayList<File>();
- result.add(f);
- return result;
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Preparation repository et working copy
- // /////////////////////////////////////////////////////////////////////////
- protected void initVCS() throws VCSException {
- // assert remote database does not exists
- try {
- handler.deleteRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("deldir remote",
- this), "");
- } catch (VCSException e) {
- // this is ok for this time :)
- // we just wants to be sure the remote database directory does not
- // exists any longer
- }
-
- // create remote directory
- handler.makeRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("mkdir remote", this),
- "");
-
- handler.deleteWorkingCopy();
-
- // assert local directory not exists
- assertFalse(getLocalDatabaseFile().exists());
-
- handler.initWorkingCopy();
-
- // assert directory exists and contains vcs configuration directory in
- // this file
- assertTrue(getLocalDatabaseFile().exists());
- assertTrue(new File(getLocalDatabaseFile(), handler
- .getConfLocalDirname()).exists());
- }
-
- // /////////////////////////////////////////////////////////////////////////
- // / Suppression du repository et working copy
- // /////////////////////////////////////////////////////////////////////////
-
- protected void disposeVCS() throws Exception {
-
- // delete remote directory
- handler.deleteRemoteDir(VCSLocalData.DIRECTORY.getCommitMessage("deldir remote",
- this), "");
-
- // delete local working copy
- handler.deleteWorkingCopy();
-
- // assert local directory does not exists any longer
- assertFalse(getLocalDatabaseFile().exists());
-
- }
-
-}
1
0
[Buix-commits] r362 - in trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs: . ui ui/handler ui/model
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:37:17 +0000 (Sat, 05 Apr 2008)
New Revision: 362
Added:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSEntriesTableModel.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSEntriesTableModelImpl.java
Modified:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/VCSUIConstants.java
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/java/org/codelutin/vcs/ui/handler/VCSAbsractAction.java
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/SynchUIModel.java
Log:
refactor PRovider, Handler and Connexion
Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java (from rev 353, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSHandlerFactory.java)
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -0,0 +1,145 @@
+/* *##%
+* 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.util.StringUtil;
+import org.codelutin.vcs.runner.VCSActionManager;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+/**
+ * This classes acts as a factory of {@link VCSProvider}, and {@link VCSConnexion}.
+ *
+ * @author chemit
+ * @see VCSConnexionConfig
+ * @see VCSConnexion
+ * @see VCSProvider
+ * @see VCSHandler
+ */
+(a)org.codelutin.i18n.I18nable
+public class VCSFactory implements VCSConnexionEventListener {
+
+ static protected final Log log = LogFactory.getLog(VCSFactory.class);
+
+ /** shared instance */
+ static protected VCSFactory instance;
+
+ /** providers availables */
+ protected List<VCSProvider> providers;
+
+ /** connexions opened */
+ protected List<VCSConnexion> connexions;
+
+ /** action manager */
+ protected VCSActionManager actionManager;
+
+ protected static VCSFactory getInstance() {
+ if (instance == null) {
+ instance = new VCSFactory();
+ }
+ return instance;
+ }
+
+ public static VCSActionManager getActionManager() {
+ return getInstance().actionManager;
+ }
+
+ /**
+ * instanciate a new connexion.
+ * <p/>
+ * the method will produce a runtime exception if config is null and not init.
+ *
+ * @param mode mode of connexion required
+ * @param config config to use @return the new connexion instance
+ * @return instanicate and init connexion (but not opened).
+ */
+ public static VCSConnexion newConnexion(VCSConnexionMode mode, VCSConnexionConfig config) {
+
+ VCSFactory factory = getInstance();
+ VCSProvider<?, ?> provider;
+
+ // obtain matching provider
+ provider = factory.getProvider(config.getType().name().toUpperCase());
+
+ // make sure provider is init
+ provider.init();
+
+ // delegate instanciation of connexion to provider
+ VCSConnexion connexion = provider.newConnection(mode, config);
+
+ // init connexion
+ connexion.init(config);
+
+ // register connexion
+ connexion.addVCSConnexionEventListener(factory);
+ return connexion;
+ }
+
+ public VCSProvider getProvider(String type) {
+ VCSFactory factory = getInstance();
+ for (VCSProvider provider : factory.providers) {
+ if (type.equals(provider.getName().toUpperCase())) {
+ return provider;
+ }
+ }
+ throw new IllegalArgumentException("could not find a provider for type " + type);
+ }
+
+ public VCSConnexion[] getConnexions() {
+ return connexions.toArray(new VCSConnexion[connexions.size()]);
+ }
+
+ public void open(VCSConnexionEvent event) {
+ // register connexion as active
+ connexions.add(event.getSource());
+ if (connexions.size() == 1) {
+ // first connexion to be opened, open actionManager
+ getActionManager().open();
+ }
+ }
+
+ public void close(VCSConnexionEvent event) {
+ // remove connexion from active
+ connexions.remove(event.getSource());
+ if (connexions.isEmpty()) {
+ // close actionManager ?
+ getActionManager().close();
+ }
+ }
+
+ protected VCSFactory() {
+ long t0 = System.nanoTime();
+ providers = new ArrayList<VCSProvider>();
+ for (VCSProvider provider : ServiceLoader.load(VCSProvider.class)) {
+ providers.add(provider);
+ }
+ log.info("found " + providers.size() + " provider(s) " + providers.toString() + " in " + StringUtil.convertTime(t0, System.nanoTime()));
+ for (VCSProvider provider : providers) {
+ log.info(provider.getName() + " [" + provider + ']');
+ }
+ actionManager = new VCSActionManager();
+ connexions = new ArrayList<VCSConnexion>();
+ }
+
+}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/VCSUIConstants.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/VCSUIConstants.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/VCSUIConstants.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -27,6 +27,8 @@
};
/** model name for synchronize all tab ui */
+ public static final String SYNCH_MODEL_PROPERTY = "modelSynch";
+
public static final String SYNCH_ALL_MODEL_PROPERTY = "modelSynchAll";
/** model name for synchronize local tab ui */
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-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,14 +15,13 @@
package org.codelutin.vcs.ui.handler;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.runner.VCSActionManager;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSEntry;
import org.codelutin.vcs.ui.VCSUIConstants;
-import org.codelutin.vcs.ui.model.AbstractVCSFileStatesModel;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
import org.codelutin.vcs.ui.model.ConfirmUIModel;
import java.beans.PropertyChangeEvent;
+import java.util.List;
/**
* Abstract ConfirmUI handler
@@ -31,14 +30,6 @@
*/
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();
@@ -62,11 +53,11 @@
throw new IllegalStateException("unimplemented property changed : " + evt);
}
- public void doAction(String commitMessage, AbstractVCSFileStatesModel model) {
+ public void doAction(String commitMessage, AbstractVCSEntriesTableModel model) {
VCSAction action = getModel().getAction();
- VCSFileState[] data = selectData(model, action, false);
+ List<VCSEntry> entries = model.filter(action, model.getDisplayedEntries(getSelectionModel()));
if (action.isCommit()) {
getModel().addCommitMessage(commitMessage);
@@ -76,10 +67,10 @@
}
if (log.isDebugEnabled()) {
- log.debug("action:" + action + ", message:" + commitMessage + ", nb files:" + data.length);
+ log.debug("action:" + action + ", message:" + commitMessage + ", nb files:" + entries.size());
}
- actionManager.add(action, data);
+ getActionManager().add(action, entries.toArray(new VCSEntry[entries.size()]), commitMessage);
// dispose ui
getUi().dispose();
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-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractDiffUIHandler.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,21 +15,16 @@
package org.codelutin.vcs.ui.handler;
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.VCSEntry;
import org.codelutin.vcs.ui.VCSUIConstants;
+import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel;
+import org.codelutin.vcs.ui.model.DiffUIModel;
import java.beans.PropertyChangeEvent;
/** @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());
@@ -37,14 +32,14 @@
String action = evt.getPropertyName();
if (VCSUIConstants.TAB_PROPERTY_CHANGED.equals(action)) {
- doSelectTab((SimpleVCSFileStatesModel) evt.getNewValue());
+ doSelectTab((AbstractVCSEntriesTableModel) evt.getNewValue());
} else {
if (VCSUIConstants.FILE_PROPERTY_CHANGED.equals(action)) {
- doSelectFile((VCSFileState) evt.getNewValue());
+ doSelectFile((VCSEntry) evt.getNewValue());
} else {
try {
VCSAction vcsAction = VCSAction.valueOf(action.toUpperCase());
- doAction(vcsAction, (VCSFileState) evt.getNewValue());
+ doAction(vcsAction, (VCSEntry) evt.getNewValue());
} catch (IllegalArgumentException e) {
// ignore ite
}
@@ -52,11 +47,11 @@
}
}
- public abstract void doSelectTab(SimpleVCSFileStatesModel action);
+ public abstract void doSelectTab(AbstractVCSEntriesTableModel action);
- public abstract void doSelectFile(VCSFileState model);
+ public abstract void doSelectFile(VCSEntry model);
- public abstract void doAction(VCSAction action, VCSFileState model);
+ public abstract void doAction(VCSAction action, VCSEntry model);
public abstract void gotoNextDiff();
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-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractSynchUIHandler.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,51 +15,38 @@
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.VCSEntryLocation;
import org.codelutin.vcs.ui.VCSUIConstants;
+import org.codelutin.vcs.ui.model.SynchUIModel;
import java.beans.PropertyChangeEvent;
/** @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());
//}
String action = evt.getPropertyName();
- SimpleVCSFileStatesModel model = (SimpleVCSFileStatesModel) evt.getNewValue();
+
if (VCSUIConstants.TAB_PROPERTY_CHANGED.equals(action)) {
- doSelectTabAction(model);
+ doSelectLocation((VCSEntryLocation) evt.getNewValue());
} else if (action.endsWith("All")) {
try {
String actionName = action.substring(0, action.length() - 3);
VCSAction vcsAction = VCSAction.valueOf(actionName.toUpperCase());
- doAllAction(vcsAction, model);
+ doAllAction(vcsAction);
} catch (IllegalArgumentException e) {
// ignore it ?
}
- } else {
- try {
- VCSAction vcsAction = VCSAction.valueOf(action.toUpperCase());
- doSelectAction(vcsAction, model);
- } catch (IllegalArgumentException e) {
- // ignore it ?
- }
-
}
}
- public abstract void doSelectAction(VCSAction action, SimpleVCSFileStatesModel model);
+ //public abstract void doSelectAction(VCSAction action);
- public abstract void doAllAction(VCSAction action, SimpleVCSFileStatesModel model);
+ public abstract void doAllAction(VCSAction action);
- public abstract void doSelectTabAction(SimpleVCSFileStatesModel action);
+ public abstract void doSelectLocation(VCSEntryLocation action);
}
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-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -16,20 +16,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.vcs.VCSFactory;
+import org.codelutin.vcs.runner.VCSActionManager;
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;
+import javax.swing.ListSelectionModel;
import java.beans.PropertyChangeListener;
/** @author chemit */
public abstract class AbstractUIHandler<M extends AbstractUIModel> implements PropertyChangeListener {
- protected static Log log = LogFactory.getLog(AbstractConfirmUIHandler.class);
+ protected static Log log = LogFactory.getLog(AbstractUIHandler.class);
public abstract M getModel();
@@ -37,17 +35,6 @@
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);
@@ -55,9 +42,7 @@
getModel().addPropertyChangeListener(this);
}
- protected VCSFileState[] selectData(AbstractVCSFileStatesModel model, VCSAction action, boolean b) {
- ListSelectionModel selectionModel = getSelectionModel();
- model.select(action, selectionModel, b);
- return model.getData(selectionModel);
+ protected VCSActionManager getActionManager() {
+ return VCSFactory.getActionManager();
}
}
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/VCSAbsractAction.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/VCSAbsractAction.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/handler/VCSAbsractAction.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -17,7 +17,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSHandler;
import javax.swing.AbstractAction;
@@ -28,19 +27,13 @@
protected VCSAction action;
- protected transient VCSHandler handler;
-
private static final long serialVersionUID = 1074145285171920255L;
- public VCSAbsractAction(VCSHandler handler) {
- this.handler = handler;
+ public VCSAbsractAction() {
}
public void setAction(VCSAction action) {
this.action = action;
}
- public VCSHandler getHandler() {
- return handler;
- }
}
Modified: 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 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -16,8 +16,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
+import org.codelutin.vcs.VCSException;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -29,28 +31,35 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static protected final Log log = LogFactory.getLog(AbstractUIModel.class);
-
/** support for change properties support */
protected PropertyChangeSupport changeSupport;
+ protected final AbstractVCSEntriesTableModel model;
- public abstract void setData(List<VCSFileState> states);
+ protected AbstractUIModel() {
+ model = new SimpleVCSEntriesTableModelImpl(getClass().getSimpleName());
+ }
- public abstract void addData(List<VCSFileState> states);
+ public AbstractVCSEntriesTableModel getModel() {
+ return model;
+ }
- public abstract void removeData(List<VCSFileState> states);
+ public void populate(VCSConnexion connexion) throws VCSException {
+ getModel().populate(connexion, System.nanoTime());
+ }
- 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 void populate(VCSConnexion connexion, List<String> relativeLocalPaths, VCSEntryLocation location) throws VCSException {
+ getModel().populate(connexion, relativeLocalPaths, location, System.nanoTime());
}
+ public void populate(VCSEntryLocation location, VCSEntry[] datas) {
+ getModel().populate(location, datas);
+ }
+
+ public void refresh(List<VCSEntry> entries) {
+ getModel().refresh(entries, System.nanoTime());
+ }
+
public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
if (listener == null) {
return;
Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSEntriesTableModel.java (from rev 345, 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/AbstractVCSEntriesTableModel.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/AbstractVCSEntriesTableModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -0,0 +1,187 @@
+/*
+* ##% 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.ui.model;
+
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.vcs.VCSAction;
+import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSEntries;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSState;
+import org.codelutin.vcs.util.VCSEntriesImpl;
+
+import javax.swing.ListSelectionModel;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Simple Table model to display list of VCSFileState
+ *
+ * @author chemit
+ */
+public abstract class AbstractVCSEntriesTableModel extends javax.swing.table.AbstractTableModel implements VCSEntries {
+
+ protected final String name;
+
+ /** column names */
+ protected final String[] columnNames;
+
+ protected VCSEntryLocation location;
+
+ /** delegate model */
+ protected final transient VCSEntries delegate;
+
+ /** displayed entries */
+ protected final transient List<VCSEntry> displayedEntries;
+
+ private static final long serialVersionUID = 4697917831388337369L;
+
+ protected AbstractVCSEntriesTableModel(String name, String[] columnNames) {
+ super();
+ this.name = name;
+ this.columnNames = columnNames;
+ this.displayedEntries = new ArrayList<VCSEntry>();
+ this.delegate = new VCSEntriesImpl();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public VCSEntryLocation getLocation() {
+ return location;
+ }
+
+ public List<VCSEntry> getDisplayedEntries(ListSelectionModel selectionModel) {
+ return selectionModel == null ? new ArrayList<VCSEntry>(displayedEntries) : filter(selectionModel, displayedEntries);
+ }
+
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ public int getRowCount() {
+ return displayedEntries.size();
+ }
+
+ @Override
+ public String getColumnName(int columnIndex) {
+ return _(columnNames[columnIndex]);
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // read only data
+ return false;
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ // read only data
+ }
+
+ public void setLocation(VCSEntryLocation location) {
+ this.location = location;
+ displayedEntries.clear();
+ displayedEntries.addAll(filter(location, getEntries()));
+ fireTableDataChanged();
+ }
+
+ public VCSAction[] getActions(ListSelectionModel selectionModel) {
+ return getActions(getDisplayedEntries(selectionModel));
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<name:" + name + ", size:" + (getRowCount()) + '>';
+ }
+
+ //===================================================================================================//
+ // === delegate methods =============================================================================//
+ //===================================================================================================//
+
+ public List<VCSEntry> getEntries() {
+ return delegate.getEntries();
+ }
+
+ public List<VCSEntry> filter(VCSAction action, List<VCSEntry> entries) {
+ return delegate.filter(action, entries);
+ }
+
+ public List<VCSEntry> filter(VCSConnexion connexion, List<VCSEntry> entries) {
+ return delegate.filter(connexion, entries);
+ }
+
+ public List<VCSEntry> filter(VCSEntryLocation location, List<VCSEntry> entries) {
+ return delegate.filter(location, entries);
+ }
+
+ public List<VCSEntry> filter(VCSState state, List<VCSEntry> entries) {
+ return delegate.filter(state, entries);
+ }
+
+ public List<VCSEntry> filter(ListSelectionModel selectionModel, List<VCSEntry> entries) {
+ return delegate.filter(selectionModel, entries);
+ }
+
+ public void populate(VCSConnexion connexion, long timestamp) throws VCSException {
+ delegate.populate(connexion, timestamp);
+ updateEntries();
+ }
+
+ public void populate(VCSConnexion connexion, List<String> relativeLocalPaths, VCSEntryLocation location, long timestamp) throws VCSException {
+ delegate.populate(connexion, relativeLocalPaths, location, timestamp);
+ updateEntries();
+ }
+
+ public void populate(VCSEntryLocation location, VCSEntry[] states) {
+ clear();
+ this.location = location;
+ delegate.populate(location, states);
+ updateEntries();
+ }
+
+ public void refresh(List<VCSEntry> entries, long timestamp) throws IllegalStateException {
+ delegate.refresh(entries, timestamp);
+ updateEntries();
+ }
+
+ public VCSAction[] getActions(List<VCSEntry> entries) {
+ return delegate.getActions(entries);
+ }
+
+ public VCSState[] getStates(List<VCSEntry> entries) {
+ return delegate.getStates(entries);
+ }
+
+ public void clear() {
+ delegate.clear();
+ displayedEntries.clear();
+ fireTableDataChanged();
+ }
+
+ protected void updateEntries() {
+ displayedEntries.clear();
+ displayedEntries.addAll(filter(location, delegate.getEntries()));
+ fireTableDataChanged();
+ }
+}
\ No newline at end of file
Modified: 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 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/ConfirmUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,9 +15,9 @@
package org.codelutin.vcs.ui.model;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
import static org.codelutin.vcs.ui.VCSUIConstants.ACTION_PROPERTY_CHANGED;
-import static org.codelutin.vcs.ui.VCSUIConstants.CONFIRM_MODEL_PROPERTY;
import static org.codelutin.vcs.ui.VCSUIConstants.MESSAGE_HISTORY_PROPERTY_CHANGED;
import java.util.ArrayList;
@@ -30,22 +30,12 @@
*/
public class ConfirmUIModel extends AbstractUIModel {
- /** list of states */
- protected SimpleVCSFileStatesModel model;
-
/** history of commit messages */
protected List<String> commitMessages;
/** current action to fired */
protected VCSAction action;
- public AbstractVCSFileStatesModel getModel() {
- if (model == null) {
- model = new SimpleVCSFileStatesModel(CONFIRM_MODEL_PROPERTY);
- }
- return model;
- }
-
public VCSAction getAction() {
return action;
}
@@ -57,12 +47,6 @@
return commitMessages;
}
- public void setAction(VCSAction action) {
- this.action = action;
- // never propagate old action, since need always the property changed
- firePropertyChange(ACTION_PROPERTY_CHANGED, null, action);
- }
-
public void addCommitMessage(String commitMessage) {
if (commitMessage != null && !commitMessage.isEmpty() && !getCommitMessages().contains(commitMessage)) {
// add message in history
@@ -71,16 +55,11 @@
}
}
- public void setData(List<VCSFileState> states) {
- getModel().setData(states);
+ public void init(VCSAction action, VCSEntryLocation location, VCSEntry[] states) {
+ this.action = action;
+ model.clear();
+ model.populate(location, states);
+ // never propagate old action, since need always the property changed
+ firePropertyChange(ACTION_PROPERTY_CHANGED, null, action);
}
-
- 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()]));
- }
-
}
\ No newline at end of file
Modified: 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 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffPanelUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -17,7 +17,7 @@
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.VCSEntry;
import org.codelutin.vcs.VCSHandler;
import java.beans.PropertyChangeListener;
@@ -44,7 +44,7 @@
protected VCSHandler handler;
/** map of models */
- protected VCSFileState model;
+ protected VCSEntry model;
/** support for change properties support */
protected PropertyChangeSupport changeSupport;
Modified: 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/DiffUIModel.java 2008-04-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,16 +15,10 @@
package org.codelutin.vcs.ui.model;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntry;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.VCSUIConstants;
-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
*
@@ -32,122 +26,40 @@
*/
public class DiffUIModel extends AbstractUIModel {
- /** 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;
+ protected VCSEntry fileModel;
/** current action to fired */
protected VCSAction action;
- public DiffUIModel() {
- }
+ private VCSEntryLocation location;
- public DiffUIModel(URL leftRoot, URL rightRoot) {
- this.leftRoot = leftRoot;
- this.rightRoot = rightRoot;
+ public void setLocation(VCSEntryLocation location) {
+ VCSEntryLocation oldLocation = this.location;
+ getModel().setLocation(location);
+ this.location = location;
+ firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldLocation, location);
}
- public AbstractVCSFileStatesModel getTabModel() {
- return tabModel;
- }
- public void setTabModel(AbstractVCSFileStatesModel tabModel) {
- AbstractVCSFileStatesModel oldTabModel = this.tabModel;
- this.tabModel = tabModel;
- firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldTabModel, tabModel);
- }
-
- public void setFileModel(VCSFileState fileModel) {
- VCSFileState oldFileModel = this.fileModel;
+ public void setFileModel(VCSEntry fileModel) {
+ VCSEntry oldFileModel = this.fileModel;
this.fileModel = fileModel;
- firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldFileModel, tabModel);
+ firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldFileModel, fileModel);
}
- 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);
+ firePropertyChange(action.name().toLowerCase() + "All", null, model);
}
- 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);
+ firePropertyChange(action.name().toLowerCase(), null, model);
}
- protected List<SimpleVCSFileStatesModel> getModels() {
- if (models == null) {
- models = new ArrayList<SimpleVCSFileStatesModel>();
- }
- return models;
+ public VCSEntryLocation getLocation() {
+ return location;
}
-
}
\ No newline at end of file
Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSEntriesTableModelImpl.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSEntriesTableModelImpl.java (rev 0)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SimpleVCSEntriesTableModelImpl.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -0,0 +1,52 @@
+/**
+ * # #% 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.VCSEntry;
+import org.codelutin.vcs.VCSState;
+import org.codelutin.vcs.ui.VCSUIConstants;
+
+/** @author chemit */
+public class SimpleVCSEntriesTableModelImpl extends AbstractVCSEntriesTableModel {
+
+ private static final long serialVersionUID = -6397327068709720165L;
+
+ protected SimpleVCSEntriesTableModelImpl(String name) {
+
+ super(name, VCSUIConstants.SIMPLE_COLUMNS_NAMES);
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ if (getRowCount() == 0) {
+ return null;
+ }
+ VCSEntry item = displayedEntries.get(rowIndex);
+ Object result = null;
+ if (columnIndex == 0) {
+ // get module
+ result = item.getRelativeLocalPath();
+ } else if (columnIndex == 1) {
+ // get file
+ result = item.getFile().getName();
+ } else if (columnIndex == 2) {
+ // get status
+ VCSState state = item.getState();
+ result = state == null ? null : state.libelle();
+ }
+ return result;
+ }
+
+
+}
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-05 20:37:02 UTC (rev 361)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/SynchUIModel.java 2008-04-05 20:37:17 UTC (rev 362)
@@ -15,17 +15,9 @@
package org.codelutin.vcs.ui.model;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
+import org.codelutin.vcs.VCSEntryLocation;
import org.codelutin.vcs.ui.VCSUIConstants;
-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.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Model of a repository
*
@@ -33,106 +25,18 @@
*/
public class SynchUIModel extends AbstractUIModel {
- /** local root : wroking copy */
- protected File localRoot;
-
- /** remote root : remote url */
- protected URL remoteRoot;
-
- /** map of models */
- protected List<SimpleVCSFileStatesModel> models;
-
- /** current tab displayed */
- protected AbstractVCSFileStatesModel tabModel;
-
- /** current action to fired */
+ /** current action to be fired */
protected VCSAction action;
- public SynchUIModel() {
+ public void setLocation(VCSEntryLocation location) {
+ VCSEntryLocation oldLocation = getModel().getLocation();
+ getModel().setLocation(location);
+ firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldLocation, location);
}
- public SynchUIModel(File localRoot, URL remoteRoot) {
- this.localRoot = localRoot;
- this.remoteRoot = remoteRoot;
- }
-
- public AbstractVCSFileStatesModel getTabModel() {
- return tabModel;
- }
-
- public void setTabModel(AbstractVCSFileStatesModel tabModel) {
- AbstractVCSFileStatesModel oldTabModel = this.tabModel;
- this.tabModel = tabModel;
- firePropertyChange(VCSUIConstants.TAB_PROPERTY_CHANGED, oldTabModel, tabModel);
- }
-
- public AbstractVCSFileStatesModel getTabModel(String tabModel) {
- return getModel(tabModel);
- }
-
- public void setLocalRoot(File localRoot) {
- this.localRoot = localRoot;
- }
-
- public void setRemoteRoot(URL remoteRoot) {
- this.remoteRoot = remoteRoot;
- }
-
- 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 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 doAllAction(VCSAction action) {
- if (tabModel == null) {
- return;
- }
this.action = action;
- firePropertyChange(action.name().toLowerCase() + "All", null, tabModel);
+ firePropertyChange(action.name().toLowerCase() + "All", null, model);
}
- protected List<SimpleVCSFileStatesModel> getModels() {
- if (models == null) {
- models = new ArrayList<SimpleVCSFileStatesModel>();
- }
- return models;
- }
-
-
}
1
0
[Buix-commits] r361 - trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:37:02 +0000 (Sat, 05 Apr 2008)
New Revision: 361
Modified:
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionManager.java
trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionManager.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionManager.java 2008-04-05 20:36:45 UTC (rev 360)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionManager.java 2008-04-05 20:37:02 UTC (rev 361)
@@ -15,10 +15,7 @@
package org.codelutin.vcs.runner;
import org.codelutin.vcs.VCSAction;
-import org.codelutin.vcs.VCSFileState;
-import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.VCSHandlerEvent;
-import org.codelutin.vcs.VCSHandlerEventListener;
+import org.codelutin.vcs.VCSEntry;
import java.util.concurrent.PriorityBlockingQueue;
@@ -29,10 +26,10 @@
*
* @author chemit
*/
-public class VCSActionManager implements VCSHandlerEventListener {
+public class VCSActionManager {
/** special item to add in queue to stop the thread */
- protected static final QueueItem STOP_ITEM = new QueueItem(null, new VCSFileState[0]);
+ protected static final QueueItem STOP_ITEM = new QueueItem(null, new VCSEntry[0], null);
/** vcs actions runner thread */
protected VCSActionThread thread;
@@ -40,54 +37,60 @@
/** queue */
protected PriorityBlockingQueue<QueueItem> queue;
- public VCSActionManager(VCSHandler handler) {
+ public VCSActionManager() {
queue = new PriorityBlockingQueue<QueueItem>(1024);
- thread = new VCSActionThread(handler, queue);
- handler.addVCSHandlerEventListener(this);
}
- public boolean add(VCSAction action, VCSFileState[] states) {
- QueueItem queueItem = new QueueItem(action, states);
+ public boolean add(VCSAction action, VCSEntry[] states, String message) {
+ QueueItem queueItem = new QueueItem(action, states, message);
return queue.add(queueItem);
}
- public void init(VCSHandlerEvent event) {
+ public void open() {
+ if (thread != null) {
+ // thread is already opend
+ throw new IllegalStateException("thread is already opened");
+ }
+ (thread = new VCSActionThread(queue)).start();
}
- public void open(VCSHandlerEvent event) {
- thread.start();
- }
-
- public void close(VCSHandlerEvent event) {
- thread.handler.removeVCSHandlerEventListener(this);
+ public void close() {
if (!queue.isEmpty()) {
queue.clear();
}
queue.add(VCSActionManager.STOP_ITEM);
+ // remove thread reference: threas was stopped, and can not be any longer restart...
+ thread = null;
}
/** @author chemit */
public static class QueueItem implements Comparable<QueueItem> {
protected long time;
- protected VCSFileState[] states;
+
+ protected VCSEntry[] entries;
protected VCSAction action;
+ protected String message;
-
- public QueueItem(VCSAction action, VCSFileState[] states) {
+ public QueueItem(VCSAction action, VCSEntry[] entries, String message) {
this.time = System.nanoTime();
- this.states = states;
+ this.entries = entries;
this.action = action;
+ this.message = message;
}
public VCSAction getAction() {
return action;
}
- public VCSFileState[] getStates() {
- return states;
+ public VCSEntry[] getEntries() {
+ return entries;
}
+ public String getMessage() {
+ return message;
+ }
+
@Override
public boolean equals(Object o) {
return this == o || o instanceof QueueItem && time == ((QueueItem) o).time;
@@ -100,7 +103,7 @@
@Override
public String toString() {
- return super.toString() + ", time:" + time + ", action:" + action + ", size:" + (states == null ? 0 : states.length);
+ return super.toString() + ", time:" + time + ", action:" + action + ", size:" + (entries == null ? 0 : entries.length);
}
public int compareTo(QueueItem o) {
Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java
===================================================================
--- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java 2008-04-05 20:36:45 UTC (rev 360)
+++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/runner/VCSActionThread.java 2008-04-05 20:37:02 UTC (rev 361)
@@ -17,7 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSException;
import java.util.Date;
import java.util.concurrent.BlockingQueue;
@@ -31,12 +31,8 @@
/** queue */
protected BlockingQueue<VCSActionManager.QueueItem> queue;
- /** handler to use for vcs operations */
- protected VCSHandler handler;
-
- public VCSActionThread(VCSHandler handler, BlockingQueue<VCSActionManager.QueueItem> queue) {
- super("VCSAction Thread [" + handler + "]");
- this.handler = handler;
+ public VCSActionThread(BlockingQueue<VCSActionManager.QueueItem> queue) {
+ super("VCSActionThread");
this.queue = queue;
}
@@ -47,8 +43,6 @@
VCSActionManager.QueueItem item = null;
try {
while (run) {
- // item qui sert a faire la simulation courante
-
log.info("waiting for action...");
item = queue.take();
if (item.getAction() == null) {
@@ -67,8 +61,9 @@
log.info("Stop " + getName() + " at " + new Date());
}
- protected void doAction(VCSActionManager.QueueItem item) {
- log.info("Just take " + item);
+ protected void doAction(VCSActionManager.QueueItem item) throws VCSException {
+ log.info(item);
+ //TODO
switch (item.getAction()) {
case ADD:
break;
@@ -93,5 +88,4 @@
}
}
-
}
1
0
[Buix-commits] r360 - trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:36:45 +0000 (Sat, 05 Apr 2008)
New Revision: 360
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties
trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties 2008-04-05 20:36:34 UTC (rev 359)
+++ trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-en_GB.properties 2008-04-05 20:36:45 UTC (rev 360)
@@ -9,6 +9,9 @@
lutinvcs.action.revert=revert
lutinvcs.action.update=update
lutinvcs.error.checkout.dir=Can''t checkout dir {0}
+lutinvcs.location.all=All
+lutinvcs.location.local=Local
+lutinvcs.location.remote=Remote
lutinvcs.state.missing=missing
lutinvcs.state.modified=modified
lutinvcs.state.outofdate=out of date
Modified: trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties 2008-04-05 20:36:34 UTC (rev 359)
+++ trunk/lutinvcs/lutinvcs-api/src/main/resources/i18n/lutinvcs-api-fr_FR.properties 2008-04-05 20:36:45 UTC (rev 360)
@@ -9,6 +9,9 @@
lutinvcs.action.revert=Rollback
lutinvcs.action.update=Update
lutinvcs.error.checkout.dir=Ne peut pas uploader le fichier ''{0}''
+lutinvcs.location.all=All
+lutinvcs.location.local=Local
+lutinvcs.location.remote=Remote
lutinvcs.state.missing=non pr\u00E9sent
lutinvcs.state.modified=modifi\u00E9
lutinvcs.state.outofdate=obsol\u00E8te
1
0
[Buix-commits] r359 - in trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs: . util
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:36:34 +0000 (Sat, 05 Apr 2008)
New Revision: 359
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java
Log:
refactor PRovider, Handler and Connexion
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -24,7 +24,6 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Collection;
-import java.util.EnumSet;
import java.util.List;
/**
@@ -33,38 +32,32 @@
* @author chemit
*/
-public interface VCSHandler {
+public interface VCSHandler<C extends VCSConnexion> {
- /** @return the location to local working copy */
- File getLocalDatabasePath();
-
/**
* init working copy, says if it is the first we use it it, we will checkout
* the databaseDirectory directory
*
+ * @param connexion vcs connexion to use
* @throws VCSException if any exception while init
*/
- void initWorkingCopy() throws VCSException;
+ void initWorkingCopy(C connexion) throws VCSException;
- /** delete the local working copy with all his files */
- void deleteWorkingCopy();
+ /**
+ * delete the local working copy with all his files
+ *
+ * @param connexion vcs connexion to use
+ */
+ void deleteWorkingCopy(C connexion);
- /** @return the complete remote url to acces repository */
- String getRemoteUrl();
-
- /** @return the config used by this handler */
- VCSConfig getConfig();
-
/**
- * @return a
- * <code>FilenameFilter<code> to detect all files and directories in a vcs working copy that
+ * @return a <code>FilenameFilter<code> to detect all files and directories in a vcs working copy that
* must be handled by vcs
*/
FilenameFilter getVersionnableFilenameFilter();
/**
- * @return a
- * <code>FileFilter<code> to detect all files and directories in a vcs working copy that
+ * @return a <code>FileFilter<code> to detect all files and directories in a vcs working copy that
* must be handled by vcs
*/
FileFilter getVersionnableFileFilter();
@@ -82,174 +75,190 @@
*/
String getConfLocalEntriesFilename();
- VCSState getState(File fileState, Collection tmp) throws VCSException;
+ VCSState getState(C connexion, File file, Collection tmp) throws VCSException;
- VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException;
+ VCSState getState(C connexion, File file, Collection tmp, boolean noremote) throws VCSException;
/**
- * @param file file to test
+ * @param connexion vcs connexion to use
+ * @param file file to test
* @return <code>true</code> if <code>file</code> is on remote
* repository, <code>false</code> otherwise.
*/
- boolean isOnRemote(File file);
+ boolean isOnRemote(C connexion, File file);
/**
- * @param file file to test
+ * @param connexion vcs connexion to use
+ * @param file file to test
* @return <code>true</code> if file is uptodate,<code>false</code>
* otherwise.
* @throws VCSException if any exception while operation
*/
- boolean isUpToDate(File file) throws VCSException;
+ boolean isUpToDate(C connexion, File file) throws VCSException;
/**
- * @param file file to test
+ * @param connexion vcs connexion to use
+ * @param file file to test
* @return <code>true</code> if file is handled by VCS,<code>false</code>
* otherwise.
*/
- boolean isVersionnableFile(File file);
+ boolean isVersionnableFile(C connexion, File file);
/**
* add on remote repository somes directories
*
+ * @param connexion vcs connexion to use
* @param commitMessage commit message
* @param dirNames names of the directories to create on remote repository (could
* used multi-level directories)
* @throws VCSException if any exception while operation
*/
- void makeRemoteDir(String commitMessage, String... dirNames)
+ void makeRemoteDir(C connexion, String commitMessage, String... dirNames)
throws VCSException;
/**
* delete on remote repository somes directories
*
+ * @param connexion vcs connexion to use
* @param commitMessage commit message
* @param dirNames names of the directories to delete on remote repository (could
* used multi-level directories)
* @throws VCSException if any exception while operation
*/
- void deleteRemoteDir(String commitMessage, String... dirNames)
+ void deleteRemoteDir(C connexion, String commitMessage, String... dirNames)
throws VCSException;
/**
* add a list of files into repository
*
- * @param files files to add
- * @param msg message for VCS commit, if <code>null</code> then no commit
- * is performed
+ * @param connexion vcs connexion to use
+ * @param files files to add
+ * @param msg message for VCS commit, if <code>null</code> then no commit
+ * is performed
* @return revision of the operation
* @throws VCSException if any exception while operation
*/
- long add(List<File> files, String msg) throws VCSException;
+ long add(C connexion, List<File> files, String msg) throws VCSException;
// void add(File file, String msg) throws VCSException;
/**
* delete a list of files from repository
*
- * @param files files to delete
- * @param msg message for VCS commit, if <code>null</code> then no commit
- * is performed
+ * @param connexion vcs connexion to use
+ * @param files files to delete
+ * @param msg message for VCS commit, if <code>null</code> then no commit
+ * is performed
* @throws VCSException if any exception while operation
*/
- void delete(List<File> files, String msg) throws VCSException;
+ void delete(C connexion, List<File> files, String msg) throws VCSException;
/**
* revert a list of files from repository
*
- * @param files files to revert
+ * @param connexion vcs connexion to use
+ * @param files files to revert
* @throws VCSException if any exception while operation
*/
- void revert(List<File> files) throws VCSException;
+ void revert(C connexion, List<File> files) throws VCSException;
/**
* commit a list of files into repository
*
- * @param files files to commit
- * @param msg message for VCS commit
+ * @param connexion vcs connexion to use
+ * @param files files to commit
+ * @param msg message for VCS commit
* @return revision of the operation
* @throws VCSException if any exception while operation
*/
- long commit(List<File> files, String msg) throws VCSException;
+ long commit(C connexion, List<File> files, String msg) throws VCSException;
/**
* update a file to repository to a certain revision
*
- * @param file file to update
- * @param revision object representing a revision for the current VCS
+ * @param connexion vcs connexion to use
+ * @param file file to update
+ * @param revision object representing a revision for the current VCS
* @throws VCSException if any exception while operation
*/
- void update(File file, Object revision) throws VCSException;
+ void update(C connexion, File file, Object revision) throws VCSException;
/**
* update a file to repository
*
- * @param file file to update
+ * @param connexion vcs connexion to use
+ * @param file file to update
* @throws VCSException if any exception while operation
*/
- void update(File file) throws VCSException;
+ void update(C connexion, File file) throws VCSException;
/**
* checkout a module from repository to a local file
*
- * @param destDir local file where to checkout
- * @param module module's name to checkout
- * @param recurse flag to say to recurse checkout or not.
+ * @param connexion vcs connexion to use
+ * @param destDir local file where to checkout
+ * @param module module's name to checkout
+ * @param recurse flag to say to recurse checkout or not.
* @throws VCSException if any exception while operation
*/
- void checkout(File destDir, String module, boolean recurse)
- throws VCSException;
+ void checkout(C connexion, File destDir, String module, boolean recurse) throws VCSException;
- void checkoutFile(File destDir, String module) throws VCSException;
+ void checkoutFile(C connexion, File destDir, String module) throws VCSException;
- long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException;
+ long checkoutOnlyTheDirectory(C connexion, File root, Object revision) throws VCSException;
/**
* TODO This is not the good place : VCS != Storage
*
+ * @param connexion vcs connexion to use
* @param directory directory to treate
* @return TODO
* @throws VCSException TODO
*/
- List<String> getRemoteStorageNames(File directory) throws VCSException;
+ List<String> getRemoteStorageNames(C connexion, File directory) throws VCSException;
/**
* TODO This is not the good place : VCS != Storage
*
+ * @param connexion vcs connexion to use
* @param directory directory to treate
* @return TODO
*/
- List<String> getLocalStorageNames(File directory);
+ List<String> getLocalStorageNames(C connexion, File directory);
/**
- * @param f local file to treate
+ * @param connexion vcs connexion to use
+ * @param f local file to treate
* @return current local revision of a file
* @throws VCSException TODO
*/
- Object getRevision(File f) throws VCSException;
+ Object getRevision(C connexion, File f) throws VCSException;
/**
* Obtain the list of log entries for the file
*
+ * @param connexion vcs connexion to use
* @param startRevision TODO
* @param endRevision TODO
* @param file file to treate
* @return list of log entries for this file between two revisions
* @throws VCSException if any exception while grabbing infos
*/
- List getLog(Object startRevision, Object endRevision, File file)
+ List getLog(C connexion, Object startRevision, Object endRevision, File file)
throws VCSException;
/**
* obtain the content of a file for a specific revision
*
- * @param file file to obtain
- * @param revision revision treated
+ * @param connexion vcs connexion to use
+ * @param file file to obtain
+ * @param revision revision treated
* @return the content of the file on repository for the specific revision
* passed as arguement.
* @throws VCSException if any exception while operation
* @throws java.io.IOException TODO
*/
- String getFileContent(File file, Object revision) throws VCSException, IOException;
+ String getFileContent(C connexion, File file, Object revision) throws VCSException, IOException;
/**
* Build the changelog for <code>file</code> from current revision of this
@@ -263,19 +272,21 @@
* <li>commit message</li>
* </ul>
*
- * @param file file to treate
+ * @param connexion vcs connexion to use
+ * @param file file to treate
* @return a string representation of change log for the local file to the
* head ?
* @throws VCSException if any exception while building changelog
*/
- String getChangeLog(File file) throws VCSException;
+ String getChangeLog(C connexion, File file) throws VCSException;
/**
* Generate in the ouputstream the diff between the current revision of the
* local file against headest revision on repository. <br>
* If file is uptodate, then does nothing.
*
- * @param file the file to treate
+ * @param connexion vcs connexion to use
+ * @param file the file to treate
* @return the diff
* @throws VCSException inf any exception while building diff, such as :
* <ul>
@@ -286,7 +297,7 @@
* </ul>
* @throws java.io.IOException if io problem with streams
*/
- String getDiff(File file) throws VCSException, IOException;
+ String getDiff(C connexion, File file) throws VCSException, IOException;
/**
* Generate in the ouputstream the diff between the current revision of the
@@ -294,6 +305,7 @@
* repository. <br>
* If file is uptodate, then does nothing.
*
+ * @param connexion vcs connexion to use
* @param file the file to treate
* @param againstRevision the against revision to use
* @return the diff
@@ -306,28 +318,9 @@
* </ul>
* @throws java.io.IOException if problem with streams
*/
- String getDiff(File file, Object againstRevision) throws VCSException, IOException;
+ String getDiff(C connexion, File file, Object againstRevision) throws VCSException, IOException;
- /**
- * test if connection is ok
- *
- * @throws VCSException if any problem
- */
- void testConnection() throws VCSException;
- boolean hasProtocoleChanged() throws VCSException;
+ boolean hasProtocoleChanged(C connexion) throws VCSException;
- void addVCSHandlerEventListener(VCSHandlerEventListener l);
-
- void removeVCSHandlerEventListener(VCSHandlerEventListener l);
-
- void open();
-
- void close();
-
- EnumSet<VCSAction> getAuthorizedActions();
-
- public boolean isConnected();
-
- public boolean hasWriteAccess();
}
\ No newline at end of file
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSProvider.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -14,8 +14,6 @@
*/
package org.codelutin.vcs;
-import java.util.List;
-
/**
* The contract to be realized to provide vcs communication.
* <p/>
@@ -25,36 +23,30 @@
* @see VCSHandler
* @see VCSConnexion
*/
-public interface VCSProvider<H extends VCSHandler, C extends VCSConnexion> {
+public interface VCSProvider<C extends VCSConnexion, H extends VCSHandler<C>> {
/** @return the identifier of the vcs provider (eg SVN, CVS, MOCK) */
String getName();
- /** @return list of known connexions. */
- List<C> getConnexions();
-
/**
* return a new VCSHandler instance for given config.
*
* @return the cached instance of handler
- * @throws IllegalStateException if handler was not init via {@link #newInstance(VCSConfig)}
+ * @throws IllegalStateException if provider was not init via {@link #init()}
*/
H getHandler() throws IllegalStateException;
- /**
- * return a new VCSHandler instance for given config.
- *
- * @param config svn handler config
- * @return the new instance
- * @throws IllegalStateException if any pb while init handler
- */
- H newInstance(VCSConfig config) throws IllegalStateException;
+ /** init the provider */
+ void init();
/**
+ * Instanciate an new connexion for a given config, and init it.
+ *
* @param mode the mode required
* @param config the config to be used
* @return the new connexion initializd <b>but not opened</b>.
+ * @throws IllegalStateException if provider was not init via {@link #init()}
*/
- C newConnection(VCSConnexionMode mode, VCSConfig config);
+ C newConnection(VCSConnexionMode mode, VCSConnexionConfig config) throws IllegalStateException;
}
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -14,29 +14,62 @@
*/
package org.codelutin.vcs.util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ListenerSet;
import org.codelutin.vcs.ConnectionState;
+import org.codelutin.vcs.VCSAction;
import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSConnexionEvent;
+import org.codelutin.vcs.VCSConnexionEvent.Type;
+import org.codelutin.vcs.VCSConnexionEventListener;
import org.codelutin.vcs.VCSConnexionMode;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSProvider;
+import org.codelutin.vcs.VCSState;
import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.io.IOException;
import java.net.URI;
-import java.util.Map;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.List;
/** @author chemit */
public abstract class AbstractVCSConnexion implements VCSConnexion {
- public static final String OPTION_LOGIN = "login";
- public static final String OPTION_PASSWORD = "password";
- public static final String OPTION_PASSPHRASE = "passphrase";
- public static final String OPTION_KEY_FILE = "keyfile";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static protected final Log log = LogFactory.getLog(AbstractVCSConnexion.class);
protected File localRoot;
protected URI remoteRoot;
protected VCSConnexionMode mode;
protected ConnectionState state;
- protected Map<String, String> options;
+ protected VCSConnexionConfig config;
+ protected VCSProvider<AbstractVCSConnexion, ?> provider;
+
+ protected ListenerSet<VCSConnexionEventListener> listeners = new ListenerSet<VCSConnexionEventListener>();
+
+ @SuppressWarnings({"unchecked"})
+ protected AbstractVCSConnexion(VCSConnexionMode mode, VCSProvider provider) {
+ this.mode = mode;
+ this.provider = provider;
+ }
+
+ public VCSHandler<AbstractVCSConnexion> getHandler() throws IllegalStateException {
+ return getProvider().getHandler();
+ }
+
+ public VCSProvider<AbstractVCSConnexion, ?> getProvider() {
+ return provider;
+ }
+
public File getWorkingCopy() throws IllegalStateException {
checkInit();
return localRoot;
@@ -52,9 +85,8 @@
return mode;
}
- public Map<String, String> getOptions() throws IllegalStateException {
- checkInit();
- return options;
+ public VCSConnexionConfig getConfig() throws IllegalStateException {
+ return config;
}
public boolean isOpen() throws IllegalStateException {
@@ -72,6 +104,180 @@
return state == ConnectionState.ERROR;
}
+ public void addVCSConnexionEventListener(VCSConnexionEventListener l) {
+ listeners.add(l);
+ }
+
+ public void removeVCSConnexionEventListener(VCSConnexionEventListener l) {
+ listeners.remove(l);
+ }
+
+ public void initWorkingCopy() throws VCSException {
+ getHandler().initWorkingCopy(this);
+ }
+
+ public void deleteWorkingCopy() {
+ getHandler().deleteWorkingCopy(this);
+ }
+
+ public FilenameFilter getVersionnableFilenameFilter() {
+ return getHandler().getVersionnableFilenameFilter();
+ }
+
+ public FileFilter getVersionnableFileFilter() {
+ return getHandler().getVersionnableFileFilter();
+ }
+
+ public String getConfLocalDirname() {
+ return getHandler().getConfLocalDirname();
+ }
+
+ public String getConfLocalEntriesFilename() {
+ return getHandler().getConfLocalEntriesFilename();
+ }
+
+ public VCSState getState(File fileState, Collection tmp) throws VCSException {
+ return getHandler().getState(this, fileState, tmp);
+ }
+
+ public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
+ return getHandler().getState(this, file, tmp, noremote);
+ }
+
+ public boolean isOnRemote(File file) {
+ return getHandler().isOnRemote(this, file);
+ }
+
+ public boolean isUpToDate(File file) throws VCSException {
+ return getHandler().isUpToDate(this, file);
+ }
+
+ public boolean isVersionnableFile(File file) {
+ return getHandler().isVersionnableFile(this, file);
+ }
+
+ public void makeRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ getHandler().makeRemoteDir(this, commitMessage, dirNames);
+ }
+
+ public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ getHandler().deleteRemoteDir(this, commitMessage, dirNames);
+ }
+
+ public long add(List<File> files, String msg) throws VCSException {
+ return getHandler().add(this, files, msg);
+ }
+
+ public void delete(List<File> files, String msg) throws VCSException {
+ getHandler().delete(this, files, msg);
+ }
+
+ public void revert(List<File> files) throws VCSException {
+ getHandler().revert(this, files);
+ }
+
+ public long commit(List<File> files, String msg) throws VCSException {
+ return getHandler().commit(this, files, msg);
+ }
+
+ public void update(File file, Object revision) throws VCSException {
+ getHandler().update(this, file, revision);
+ }
+
+ public void update(File file) throws VCSException {
+ getHandler().update(this, file);
+ }
+
+ public void checkout(File destDir, String module, boolean recurse) throws VCSException {
+ getHandler().checkout(this, destDir, module, recurse);
+ }
+
+ public void checkoutFile(File destDir, String module) throws VCSException {
+ getHandler().checkoutFile(this, destDir, module);
+ }
+
+ public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
+ return getHandler().checkoutOnlyTheDirectory(this, root, revision);
+ }
+
+ public List<String> getRemoteStorageNames(File directory) throws VCSException {
+ return getHandler().getRemoteStorageNames(this, directory);
+ }
+
+ public List<String> getLocalStorageNames(File directory) {
+ return getHandler().getLocalStorageNames(this, directory);
+ }
+
+ public Object getRevision(File f) throws VCSException {
+ return getHandler().getRevision(this, f);
+ }
+
+ public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
+ return getHandler().getLog(this, startRevision, endRevision, file);
+ }
+
+ public String getFileContent(File file, Object revision) throws VCSException, IOException {
+ return getHandler().getFileContent(this, file, revision);
+ }
+
+ public String getChangeLog(File file) throws VCSException {
+ return getHandler().getChangeLog(this, file);
+ }
+
+ public String getDiff(File file) throws VCSException, IOException {
+ return getHandler().getDiff(this, file);
+ }
+
+ public String getDiff(File file, Object againstRevision) throws VCSException, IOException {
+ return getHandler().getDiff(this, file, againstRevision);
+ }
+
+ public boolean hasProtocoleChanged() throws VCSException {
+ return getHandler().hasProtocoleChanged(this);
+ }
+
+ /**
+ * Obtain the set of permitted vcs actions.
+ *
+ * @return the EnumSet of authorized action according to current vcs config
+ */
+ public EnumSet<VCSAction> getAuthorizedActions() {
+ boolean canWrite = hasWriteAccess();
+ EnumSet<VCSAction> result = EnumSet.noneOf(VCSAction.class);
+ for (VCSAction vcsAction : VCSAction.values()) {
+ if (!vcsAction.isWrite() || canWrite) {
+ result.add(vcsAction);
+ }
+ }
+ return result;
+ }
+
+ public boolean hasWriteAccess() {
+ return !getConfig().isUseSshConnexion() && getMode() != VCSConnexionMode.ANONYMOUS;
+ }
+
+ public void addVCSHandlerEventListener(VCSConnexionEventListener l) {
+ listeners.add(l);
+ }
+
+ public void removeVCSHandlerEventListener(VCSConnexionEventListener l) {
+ listeners.remove(l);
+ }
+
+ protected void fireOpen() {
+ VCSConnexionEvent e = new VCSConnexionEvent(this, Type.OPEN);
+ for (VCSConnexionEventListener l : listeners) {
+ l.open(e);
+ }
+ }
+
+ protected void fireClose() {
+ VCSConnexionEvent e = new VCSConnexionEvent(this, Type.CLOSE);
+ for (VCSConnexionEventListener l : listeners) {
+ l.close(e);
+ }
+ }
+
protected void checkInit() throws IllegalStateException {
if (state == null) {
throw new IllegalStateException("connexion was not init");
@@ -85,4 +291,5 @@
}
}
+
}
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -21,15 +21,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import static org.codelutin.i18n.I18n._;
import org.codelutin.util.FileUtil;
-import org.codelutin.util.ListenerSet;
-import org.codelutin.vcs.VCSHandlerEvent.Type;
+import org.codelutin.vcs.VCSConnexion;
import org.codelutin.vcs.VCSHandler;
-import org.codelutin.vcs.VCSConfig;
-import org.codelutin.vcs.VCSHandlerEventListener;
-import org.codelutin.vcs.VCSHandlerEvent;
import org.codelutin.vcs.VCSRuntimeException;
-import org.codelutin.vcs.VCSAction;
+import org.codelutin.vcs.VCSTypeRepo;
import java.io.File;
import java.io.FileFilter;
@@ -37,14 +34,13 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.EnumSet;
/**
* abstract VCSHandler base with usefull methods that does not need vcs specific code.
*
* @author chemit
*/
-public abstract class AbstractVCSHandler implements VCSHandler {
+public abstract class AbstractVCSHandler<C extends VCSConnexion> implements VCSHandler<C> {
/** to use log facility, just put in your code: log.info(\"...\"); */
static protected final Log log = LogFactory.getLog(AbstractVCSHandler.class);
@@ -58,13 +54,13 @@
protected final FileFilter versionnableFileFilter;
protected final String confLocalDirName;
protected final String confLocalEntriesFilename;
+ public static final String LOCAL_SEP = File.separator;
+ public static final String LOCAL_SEP_PATTERN = "\\".equals(LOCAL_SEP) ?
+ LOCAL_SEP + LOCAL_SEP : LOCAL_SEP;
+ public static final String REMOTE_SEP = "/";
+ public static final String REMOTE_SEP_PATTERN = "/";
- protected final VCSConfig config;
-
- protected ListenerSet<VCSHandlerEventListener> listeners = new ListenerSet<VCSHandlerEventListener>();
-
- protected AbstractVCSHandler(VCSConfig config, final String vCSConfLocalDirName, String vCSConfLocalEntriesFilename) {
- this.config = config;
+ protected AbstractVCSHandler(final String vCSConfLocalDirName, String vCSConfLocalEntriesFilename) {
this.confLocalDirName = vCSConfLocalDirName;
this.confLocalEntriesFilename = vCSConfLocalEntriesFilename;
this.versionnableFilenameFilter = new FilenameFilter() {
@@ -77,24 +73,8 @@
return dir.isFile() || (!vCSConfLocalDirName.equals(dir.getName()) && !"CVS".equals(dir.getName()));
}
};
- fireInit();
}
- public VCSConfig getConfig() {
- return config;
- }
-
- public File getLocalDatabasePath() {
- return config.getLocalDatabasePath();
- }
-
- public void deleteWorkingCopy() {
- if (getLocalDatabasePath().exists()) {
- FileUtil.deleteRecursively(getLocalDatabasePath());
- getLocalDatabasePath().delete();
- }
- }
-
public FilenameFilter getVersionnableFilenameFilter() {
return versionnableFilenameFilter;
}
@@ -111,12 +91,19 @@
return confLocalEntriesFilename;
}
- public boolean isVersionnableFile(File file) {
+ public boolean isVersionnableFile(C connexion, File file) {
assertFileExists(file, "file is empty or non existant");
return !confLocalDirName.equalsIgnoreCase(file.getName());
}
- public List<String> getLocalStorageNames(File directory) {
+ public void deleteWorkingCopy(C connexion) {
+ if (connexion.getConfig().getLocalDatabasePath().exists()) {
+ FileUtil.deleteRecursively(connexion.getConfig().getLocalDatabasePath());
+ connexion.getConfig().getLocalDatabasePath().delete();
+ }
+ }
+
+ public List<String> getLocalStorageNames(C connexion, File directory) {
List<String> result = new ArrayList<String>();
if (directory.exists()) {
getFiles0(directory, result, "");
@@ -125,49 +112,24 @@
return result;
}
- public void addVCSHandlerEventListener(VCSHandlerEventListener l) {
- listeners.add(l);
- }
-
- public void removeVCSHandlerEventListener(VCSHandlerEventListener l) {
- listeners.remove(l);
- }
-
- public void open() {
- fireOpen();
- }
-
- public void close() {
- fireClose();
- }
-
- protected void fireInit() {
- VCSHandlerEvent e = new VCSHandlerEvent(this, Type.INIT);
- for (VCSHandlerEventListener l : listeners) {
- l.init(e);
+ public void doCheckoutDir(C connexion, File... dirs) {
+ for (File dir : dirs) {
+ try {
+ if (!dir.exists() || !isFileInWorkingCopy(dir, this, connexion, true)) {
+ checkoutOnlyTheDirectory(connexion, dir, null);
+ }
+ } catch (Exception eee) {
+ log.warn(_("lutinvcs.error.checkout.dir", dir), eee);
+ break;
+ }
}
}
- protected void fireOpen() {
- VCSHandlerEvent e = new VCSHandlerEvent(this, Type.OPEN);
- for (VCSHandlerEventListener l : listeners) {
- l.open(e);
- }
+ protected void assertFileExists(File file, String msg) {
+ if (file == null || !file.exists())
+ throw new VCSRuntimeException(msg + " (file passed : [" + file + "])");
}
- protected void fireClose() {
- VCSHandlerEvent e = new VCSHandlerEvent(this, Type.CLOSE);
- for (VCSHandlerEventListener l : listeners) {
- l.close(e);
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- close();
- }
-
protected void getFiles0(File directory, List<String> result, String prefix) {
//TODO put the hardcored value in a property!!!
if (directory.getName().equals("data")) return;
@@ -183,32 +145,132 @@
}
}
- protected void assertFileExists(File file, String msg) {
- if (file == null || !file.exists())
- throw new VCSRuntimeException(msg + " (file passed : [" + file + "])");
+ public static boolean isFileInWorkingCopy(File parent, String name, VCSHandler handler, VCSConnexion connexion, boolean underVCS) {
+ if (parent == null || name == null)
+ throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInWorkingCopy can not be invoked with some null parameter but was. [" + parent + "," + name + "," +
+ handler + "]");
+ return isFileInWorkingCopy(new File(parent, name), handler, connexion, underVCS);
}
+ public static boolean isFileInWorkingCopy(File file, VCSHandler handler, VCSConnexion connexion, boolean underVCS) {
+ if (file == null || handler == null)
+ throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInWorkingCopy can not be invoked with some null parameter but was. [" + file + "," + handler + "]");
+ String rootPath = connexion.getConfig().getLocalDatabasePath().getAbsolutePath();
+ String localPath = file.getAbsolutePath();
+ if (localPath.startsWith(rootPath) && !underVCS) {
+ return true;
+ }
+ final File realDir = file.isDirectory() ? file : file.getParentFile();
+ return isFileInCheckedDir(realDir, handler);
+ }
+
+ public static boolean isFileInCheckedDir(File file, VCSHandler handler) {
+ if (file == null || handler == null)
+ throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInCheckedDir can not be invoked with some null parameter but was. [" + file + "," + handler + "]");
+ final File realDir = file.isDirectory() ? file : file.getParentFile();
+ return (new File(realDir, handler.getConfLocalDirname()).exists());
+
+ }
+
+ public static void assertFileInWC(File file, VCSHandler handler, VCSConnexion connexion) {
+ if (!isFileInWorkingCopy(file, handler, connexion, false))
+ throw new VCSRuntimeException("the file [" + file + "] is not in the working copy [" + connexion.getConfig().getLocalDatabasePath() + "]");
+ }
+
+ public static String getRemoteRelativePath(File f, VCSHandler handler, VCSConnexion connexion) {
+ if (!isFileInWorkingCopy(f, handler, connexion, false)) return null;
+ //System.out.println("file on vcs working copy : "+f);
+ String rootPath = connexion.getConfig().getLocalDatabasePath().getAbsolutePath();
+ String localPath = f.getAbsolutePath();
+ if (!localPath.startsWith(rootPath)) return null;
+ localPath = localPath.substring(rootPath.length() + 1);
+ return convertToRemoteName(localPath);
+ }
+
+ public static String getLocalRelativePath(String remoteRelativePath, VCSHandler handler, VCSConnexion connexion) {
+ String localPath = convertToLocalName(remoteRelativePath);
+ final File file = new File(connexion.getConfig().getLocalDatabasePath(), localPath);
+ if (!isFileInWorkingCopy(file, handler, connexion, false)) return null;
+ return localPath;
+ }
+
+ public static String convertToRemoteName(String txt) {
+ return txt.replaceAll(LOCAL_SEP_PATTERN, REMOTE_SEP);
+ }
+
+ public static String convertToLocalName(String txt) {
+ return txt.replaceAll(REMOTE_SEP_PATTERN, LOCAL_SEP);
+ }
+
/**
- * Obtain the set of permitted vcs actions.
- *
- * @return the EnumSet of authorized action according to current vcs config
+ * @param typeRepo the type of repo to used
+ * @param remotePath the unclean remote path to use
+ * @return the remote path from the old one according to given type repo
*/
- public EnumSet<VCSAction> getAuthorizedActions() {
- boolean canWrite = hasWriteAccess();
- EnumSet<VCSAction> result = EnumSet.noneOf(VCSAction.class);
- for (VCSAction vcsAction : VCSAction.values()) {
- if (!vcsAction.isWrite() || canWrite) {
- result.add(vcsAction);
- }
+ public static String getRemotePath(VCSTypeRepo typeRepo, String remotePath) {
+ String result = cleanRemotePath(remotePath);
+ switch (typeRepo) {
+ case BRANCH:
+ case TAG:
+ result = remotePath + '/' + typeRepo.getPath();
+ break;
+ case HEAD:
+ result = remotePath;
+ break;
}
return result;
}
- public boolean isConnected() {
- return getConfig().isConnected();
+ /**
+ * @param typeRepo the type of repo to use
+ * @param version the version to use
+ * @return the remoteDatabase according to type of repo and version
+ */
+ public static String getRemoteDatabase(VCSTypeRepo typeRepo, String version) {
+ String result = null;
+ switch (typeRepo) {
+ case BRANCH:
+ case TAG:
+ result = version;
+ break;
+ case HEAD:
+ result = VCSTypeRepo.HEAD.getPath();
+ break;
+ }
+ return result;
}
- public boolean hasWriteAccess() {
- return !getConfig().isReadOnly();
+ /**
+ * to clean a remote path from typeRepo suffix.
+ * <p/>
+ * For example, having a url svn://XXX/trunk then remove /trunk.
+ * <p/>
+ * Or if having svn://XXX/branches/YYY then remove /branches/YYY
+ * Or if having svn://XXX/tags/YYY then remove /tags/YYY
+ *
+ * @param remotePath the remote path to clean
+ * @return the cleaned remote path
+ */
+ public static String cleanRemotePath(String remotePath) {
+ int pos = remotePath.indexOf(VCSTypeRepo.BRANCH.getPath());
+ if (pos > -1) {
+ // found a branch
+ remotePath = remotePath.substring(0, pos - 1);
+ } else {
+ pos = remotePath.indexOf(VCSTypeRepo.HEAD.getPath());
+ if (pos > -1) {
+ // found a branch
+ remotePath = remotePath.substring(0, pos - 1);
+ } else {
+ pos = remotePath.indexOf(VCSTypeRepo.TAG.getPath());
+ if (pos > -1) {
+ // found a tag
+ remotePath = remotePath.substring(0, pos - 1);
+ } else {
+ // remote path was clean
+ }
+ }
+ }
+ return remotePath;
}
}
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java 2008-04-05 20:36:07 UTC (rev 358)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/util/AbstractVCSProvider.java 2008-04-05 20:36:34 UTC (rev 359)
@@ -14,70 +14,76 @@
*/
package org.codelutin.vcs.util;
-import org.codelutin.vcs.VCSConfig;
import org.codelutin.vcs.VCSConnexion;
+import org.codelutin.vcs.VCSConnexionConfig;
+import org.codelutin.vcs.VCSConnexionMode;
import org.codelutin.vcs.VCSHandler;
import org.codelutin.vcs.VCSProvider;
import java.lang.reflect.InvocationTargetException;
-import java.util.List;
/**
* base implementation of provider with a cached handler and list of connexions
*
* @author chemit
*/
-public abstract class AbstractVCSProvider<H extends VCSHandler, C extends VCSConnexion> implements VCSProvider<H, C> {
+public abstract class AbstractVCSProvider<C extends VCSConnexion, H extends VCSHandler<C>> implements VCSProvider<C, H> {
protected H handler;
- protected List<C> connexions;
-
protected final String name;
private final Class<H> handlerImpl;
+ private final Class<C> connexionImpl;
- protected AbstractVCSProvider(String name, Class<H> handlerImpl) {
+ protected AbstractVCSProvider(String name, Class<H> handlerImpl, Class<C> connexionImpl) {
this.name = name;
this.handlerImpl = handlerImpl;
+ this.connexionImpl = connexionImpl;
}
public final String getName() {
return name;
}
- public List<C> getConnexions() {
- if (connexions == null) {
- connexions = new java.util.ArrayList<C>();
- }
- return connexions;
- }
-
public H getHandler() throws IllegalStateException {
checkHandlerInit();
return handler;
}
- public H newInstance(VCSConfig config) throws IllegalStateException {
- if (handler != null) {
- return handler;
- }
+ public C newConnection(VCSConnexionMode mode, VCSConnexionConfig config) throws IllegalStateException {
+ checkHandlerInit();
try {
- return handlerImpl.getConstructor(VCSConfig.class).newInstance(config);
+ C connexion = connexionImpl.getConstructor(VCSConnexionMode.class, getClass()).newInstance(mode, this);
+ connexion.init(config);
+ return connexion;
} catch (InstantiationException e) {
- throw new IllegalStateException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ throw new RuntimeException("could not instanciate connexion " + connexionImpl + " for reason " + e.getMessage());
} catch (IllegalAccessException e) {
- throw new IllegalStateException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ throw new RuntimeException("could not instanciate connexion " + connexionImpl + " for reason " + e.getMessage());
} catch (InvocationTargetException e) {
- throw new IllegalStateException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ throw new RuntimeException("could not instanciate connexion " + connexionImpl + " for reason " + e.getMessage());
} catch (NoSuchMethodException e) {
- throw new IllegalStateException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ throw new RuntimeException("could not instanciate connexion " + connexionImpl + " for reason " + e.getMessage());
}
}
+ public void init() {
+ if (handler == null) {
+ try {
+ handler = handlerImpl.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("could not instanciate the handler " + handlerImpl + " for reason " + e.getMessage());
+ }
+ }
+ }
+
protected void checkHandlerInit() throws IllegalStateException {
if (handler == null) {
throw new IllegalStateException("handler was not init in " + this);
}
}
+
}
1
0
[Buix-commits] r358 - trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
by tchemit@users.labs.libre-entreprise.org 05 Apr '08
05 Apr '08
Author: tchemit
Date: 2008-04-05 20:36:07 +0000 (Sat, 05 Apr 2008)
New Revision: 358
Modified:
trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSState.java
Log:
use VCSEntryLocation as property to VCSState
Modified: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSState.java
===================================================================
--- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSState.java 2008-04-05 20:35:25 UTC (rev 357)
+++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSState.java 2008-04-05 20:36:07 UTC (rev 358)
@@ -30,7 +30,7 @@
* <br/>
* The only action for this state is to delete the file, nothing else.
*/
- UP_TO_DATE("uptodate", n_("lutinvcs.state.uptodate"), false, false, DELETE),
+ UP_TO_DATE("uptodate", n_("lutinvcs.state.uptodate"), VCSEntryLocation.ALL, DELETE),
/**
* when a local file matches a remote copy but not the latest one.
@@ -42,8 +42,7 @@
* <li>{@link VCSAction#CHANGELOG}</li>
* </ul>
*/
- OUT_OF_DATE("outofdate", n_("lutinvcs.state.outofdate"), false, true,
- UPDATE, DIFF, CHANGELOG),
+ OUT_OF_DATE("outofdate", n_("lutinvcs.state.outofdate"), VCSEntryLocation.REMOTE, UPDATE, DIFF, CHANGELOG),
/**
* when a local file does not matches his remote latest copy, but is based
@@ -56,8 +55,7 @@
* <li>{@link VCSAction#DIFF}</li>
* </ul>
*/
- MODIFIED("modified", n_("lutinvcs.state.modified"), true, false,
- COMMIT, OVERWRITE_AND_UPDATE, REVERT, DIFF),
+ MODIFIED("modified", n_("lutinvcs.state.modified"), VCSEntryLocation.LOCAL, COMMIT, OVERWRITE_AND_UPDATE, REVERT, DIFF),
/**
* when a local file does not match the working version remote copy and
@@ -71,9 +69,7 @@
* <li>{@link VCSAction#CHANGELOG}</li>
* </ul>
*/
- OUT_OF_DATE_AND_MODIFIED("outofdateAndModified",
- n_("lutinvcs.state.outofdateAndModified"), true, true,
- OVERWRITE_AND_UPDATE, REVERT, DIFF, CHANGELOG),
+ OUT_OF_DATE_AND_MODIFIED("outofdateAndModified", n_("lutinvcs.state.outofdateAndModified"), VCSEntryLocation.ALL, OVERWRITE_AND_UPDATE, REVERT, DIFF, CHANGELOG),
/**
* when a local file does not exist on remote repository.
@@ -82,7 +78,7 @@
* <li>{@link VCSAction#ADD}</li>
* </ul>
*/
- UNVERSIONNED("unversionned", n_("lutinvcs.state.unversionned"), true, false, ADD, REVERT),
+ UNVERSIONNED("unversionned", n_("lutinvcs.state.unversionned"), VCSEntryLocation.LOCAL, ADD, REVERT),
/**
* when a file exists on remote repository but not locally.
@@ -91,7 +87,7 @@
* <li>{@link VCSAction#UPDATE}</li>
* </ul>
*/
- MISSING("missing", n_("lutinvcs.state.missing"), false, true, UPDATE),
+ MISSING("missing", n_("lutinvcs.state.missing"), VCSEntryLocation.REMOTE, UPDATE),
/**
* when a file is unversionned or missing : this special and durty state
@@ -107,35 +103,34 @@
* <p/>
* </ul>
*/
- UNVERSIONNED_OR_MISSING("unversionnedOrMissing",
- n_("lutinvcs.state.unversionnedOrMissing"), true, true, ADD, UPDATE),
+ UNVERSIONNED_OR_MISSING("unversionnedOrMissing", n_("lutinvcs.state.unversionnedOrMissing"), VCSEntryLocation.LOCAL, ADD, UPDATE),
- REMOVED("removed", n_("lutinvcs.state.removed"), true, false, DELETE, REVERT),
+ REMOVED("removed", n_("lutinvcs.state.removed"), VCSEntryLocation.LOCAL, DELETE, REVERT),
/** to deal with other cases (...) */
- UNKNOWN("unknown", n_("lutinvcs.state.unknown"), true, false);
+ UNKNOWN("unknown", n_("lutinvcs.state.unknown"), null);
/** libelle to be used */
private final String libelle;
/** key of the state */
private final String key;
- /** flag to indicate if state is on a local file */
- private final boolean local;
- /** flag to indicate if state is on a remote file */
- private final boolean remote;
+
/** VCSAction associated with this state */
private final List<VCSAction> actions;
- VCSState(String key, String libelle, boolean local, boolean remote, VCSAction... actions) {
+ /** location of the state */
+ private VCSEntryLocation location;
+
+ VCSState(String key, String libelle, VCSEntryLocation location, VCSAction... actions) {
+ this.location = location;
this.libelle = libelle;
List<VCSAction> actions1 = new ArrayList<VCSAction>(Arrays.asList(actions));
// refresh action is enabled for all states
actions1.add(VCSAction.REFRESH);
this.actions = Collections.unmodifiableList(actions1);
this.key = key;
- this.local = local;
- this.remote = remote;
+
}
public String libelle() {
@@ -150,12 +145,16 @@
return key;
}
+ public VCSEntryLocation getLocation() {
+ return location;
+ }
+
public boolean isLocal() {
- return local;
+ return location != VCSEntryLocation.REMOTE;
}
public boolean isRemote() {
- return remote;
+ return location != VCSEntryLocation.LOCAL;
}
public boolean authorizeAction(VCSAction... actions) {
1
0