[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] [Home]

RE: Checking out sub-folders


On Wed, 1 Dec 1999, Tim Endres wrote:

> > The other 2 patches sent at the same time was to be able to run excel (it
> > was picky about having \ as path separator and getting things wrapped in
> > "") and to get the list of servers sorted alphabetically.
> 
> I do not remember ever seeing these other two patches.
> But then, I am getting old...

No problem. I'll send them again. Note that these are of the kind "it
works for us" so they probably need looking over ... The indentation of
the sort routine was not changed to fit your style for example.

With these changes we can start excel on a file as an "action". And we get
the list of servers sorted alphabetically.

/Urban

diff -ur source.orig/com/ice/jcvsii/ExecViewer.java source/com/ice/jcvsii/ExecViewer.java
--- source.orig/com/ice/jcvsii/ExecViewer.java	Mon May 17 12:39:58 1999
+++ source/com/ice/jcvsii/ExecViewer.java	Mon Oct 25 10:08:47 1999
@@ -96,6 +96,20 @@
 		FileDataSource fds = (FileDataSource) ds;
 		String fileName = fds.getFile().getPath();
 
+		// Excel does not like / in pathnames, so we replace / with
+		// the platforms property setting.
+		// When doing file->edit you get /, with dbl-click you get \
+		StringBuffer tmpFileName = new StringBuffer(fileName);
+		int n = 0;
+		char ch = System.getProperty("file.separator").charAt(0);
+		while ( ( n = fileName.indexOf('/', n) ) != -1)
+			{
+			tmpFileName.setCharAt(n, ch);
+			n++;
+			}
+		fileName = tmpFileName.toString();
+
+
 		String envSpec = null;
 		String argSpec = null;
 
@@ -137,6 +151,15 @@
 			}
 
 		Hashtable subHash = new Hashtable();
+
+		// To handle filenames with space you need to wrap them in ""
+		// on NT (and 9x?)
+		String osname = System.getProperty("os.name");
+		if (osname.startsWith( "Windows" ) && 
+		    fileName.indexOf(' ') != -1)
+			{
+			fileName = '"' + fileName + '"';
+			}
 
 		subHash.put( "FILE", fileName );
 		subHash.put( "CWD", Config.getPreferences().getCurrentDirectory() );
diff -ur source.orig/com/ice/jcvsii/Config.java source/com/ice/jcvsii/Config.java
--- source.orig/com/ice/jcvsii/Config.java	Mon Jul 26 23:13:46 1999
+++ source/com/ice/jcvsii/Config.java	Mon Oct 18 18:18:04 1999
@@ -499,6 +499,25 @@
 		}
 
 
+
+	// Insertionsort - O(n^2) but it is short. This belongs in
+	// some kind of "Util" class
+	private void sortServerVector(Vector v)
+	{
+	    for (int i = 1; i < v.size(); i++) {
+		int j = i;
+		ServerDef B = (ServerDef) v.elementAt(i);
+		while (j > 0) {
+		    ServerDef A = (ServerDef) v.elementAt(j-1);
+		    if (A.compareTo(B) <= 0)
+			break;
+		    v.setElementAt(A, j);
+		    j--;
+		}
+		v.setElementAt(B, j);
+	    }
+	}
+
 	public void
 	enumerateServerDefinitions( Enumeration enum )
 		{
@@ -537,6 +556,8 @@
 						( name, method, module, user, host, repos, desc ) );
 			// UNDONE report missing name!
 			}
+
+		sortServerVector(this.servers);
 		}
 
 	public void
diff -ur source.orig/com/ice/jcvsii/ServerDef.java source/com/ice/jcvsii/ServerDef.java
--- source.orig/com/ice/jcvsii/ServerDef.java	Thu Apr  1 14:29:56 1999
+++ source/com/ice/jcvsii/ServerDef.java	Mon Oct 18 18:15:10 1999
@@ -112,5 +112,13 @@
 		{
 		return this.method;
 		}
+
+	// returns 0 if equal, > 0 if this > other, else < 0
+	public int
+	compareTo( ServerDef other )
+		{
+			String s = other.getName();
+			return name.compareTo(s);
+		}
 	}