[Jsxe-cvs] SF.net SVN: jsxe: [1200] branches/jsxe2/src/net/sourceforge/jsxe/io
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-08-29 20:34:08
|
Revision: 1200 Author: ian_lewis Date: 2006-08-29 13:33:55 -0700 (Tue, 29 Aug 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1200&view=rev Log Message: ----------- Some more compatibility changes Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java branches/jsxe2/src/net/sourceforge/jsxe/io/VFS.java branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/msg/VFSUpdate.java branches/jsxe2/src/net/sourceforge/jsxe/util/SegmentBuffer.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java 2006-08-29 20:10:17 UTC (rev 1199) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java 2006-08-29 20:33:55 UTC (rev 1200) @@ -4,7 +4,7 @@ :folding=explicit:collapseFolds=1: Copyright (C) 1998, 1999, 2000, 2001, 2002 Slava Pestov -Portions Copyright (C) 2004 Ian Lewis (Ian...@me...) +Portions Copyright (C) 2006 Ian Lewis (Ian...@me...) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,12 +26,21 @@ package net.sourceforge.jsxe.io; //{{{ Imports + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.dom2.XMLDocument; +import net.sourceforge.jsxe.gui.TabbedView; +import net.sourceforge.jsxe.OperatingSystem; +import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.util.MiscUtilities; +//}}} + import java.awt.Component; import java.io.*; import java.text.*; import java.util.Date; -import net.sourceforge.jsxe.OperatingSystem; -import net.sourceforge.jsxe.util.Log; + //}}} /** Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/VFS.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/VFS.java 2006-08-29 20:10:17 UTC (rev 1199) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/VFS.java 2006-08-29 20:33:55 UTC (rev 1200) @@ -787,10 +787,9 @@ //{{{ DirectoryEntryCompare class /** - * Implementation of {@link org.gjt.sp.jedit.MiscUtilities.Compare} - * interface that compares {@link VFS.DirectoryEntry} instances. + * Interface that compares {@link VFS.DirectoryEntry} instances. */ - public static class DirectoryEntryCompare implements MiscUtilities.Compare { + public static class DirectoryEntryCompare implements Comparator { private boolean sortIgnoreCase, sortMixFilesAndDirs; Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-08-29 20:10:17 UTC (rev 1199) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-08-29 20:33:55 UTC (rev 1200) @@ -26,10 +26,27 @@ package net.sourceforge.jsxe.io; //{{{ Imports + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.EditBus; +import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.gui.ErrorListDialog; +import net.sourceforge.jsxe.msg.VFSUpdate; +import net.sourceforge.jsxe.util.*; +//}}} + +//{{{ Swing classes import javax.swing.JOptionPane; import javax.swing.SwingUtilities; +//}}} + +//{{{ AWT classes import java.awt.Component; import java.awt.Frame; +//}}} + +//{{{ Java classes import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; @@ -37,12 +54,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Vector; -import net.sourceforge.jsxe.gui.ErrorListDialog; -import net.sourceforge.jsxe.msg.VFSUpdate; -import net.sourceforge.jsxe.util.Log; -import net.sourceforge.jsxe.WorkThreadPool; //}}} +//}}} + /** * jEdit's virtual filesystem allows it to transparently edit files * stored elsewhere than the local filesystem, for example on an FTP @@ -315,28 +330,20 @@ * @param parent True if an update should be sent for the path's * parent too */ - public static void sendVFSUpdate(VFS vfs, String path, boolean parent) - { - if(parent) - { + public static void sendVFSUpdate(VFS vfs, String path, boolean parent) { + if (parent) { sendVFSUpdate(vfs,vfs.getParentOfPath(path),false); sendVFSUpdate(vfs,path,false); - } - else - { + } else { // have to do this hack until VFSPath class is written - if(path.length() != 1 && (path.endsWith("/") - || path.endsWith(java.io.File.separator))) + if (path.length() != 1 && (path.endsWith("/") || path.endsWith(java.io.File.separator))) { path = path.substring(0,path.length() - 1); + } - synchronized(vfsUpdateLock) - { - for(int i = 0; i < vfsUpdates.size(); i++) - { - VFSUpdate msg = (VFSUpdate)vfsUpdates - .get(i); - if(msg.getPath().equals(path)) - { + synchronized(vfsUpdateLock) { + for (int i = 0; i < vfsUpdates.size(); i++) { + VFSUpdate msg = (VFSUpdate)vfsUpdates.get(i); + if (msg.getPath().equals(path)) { // don't send two updates // for the same path return; @@ -345,8 +352,7 @@ vfsUpdates.add(new VFSUpdate(path)); - if(vfsUpdates.size() == 1) - { + if (vfsUpdates.size() == 1) { // we were the first to add an update; // add update sending runnable to AWT // thread @@ -357,22 +363,17 @@ } //}}} //{{{ SendVFSUpdatesSafely class - static class SendVFSUpdatesSafely implements Runnable - { - public void run() - { - synchronized(vfsUpdateLock) - { + static class SendVFSUpdatesSafely implements Runnable { + + public void run() { + synchronized(vfsUpdateLock) { // the vfs browser has what you might call // a design flaw, it doesn't update properly // unless the vfs update for a parent arrives // before any updates for the children. sorting // the list alphanumerically guarantees this. - Collections.sort(vfsUpdates, - new MiscUtilities.StringCompare() - ); - for(int i = 0; i < vfsUpdates.size(); i++) - { + Collections.sort(vfsUpdates, new MiscUtilities.StringCompare()); + for (int i = 0; i < vfsUpdates.size(); i++) { EditBus.send((VFSUpdate)vfsUpdates.get(i)); } Added: branches/jsxe2/src/net/sourceforge/jsxe/msg/VFSUpdate.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/msg/VFSUpdate.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/msg/VFSUpdate.java 2006-08-29 20:33:55 UTC (rev 1200) @@ -0,0 +1,70 @@ +/* +VFSUpdate.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2000 Slava Pestov +Portions Copyright (C) 2006 Ian Lewis (Ian...@me...) + +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. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.msg; + +import net.sourceforge.jsxe.EBMessage; + +/** + * Message sent when a file or directory changes. + * @author Slava Pestov + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id: VFSUpdate.java,v 1.3 2002/05/14 07:34:55 spestov Exp $ + * @since jsXe XX.XX + */ +public class VFSUpdate extends EBMessage { + + //{{{ VFSUpdate constructor + /** + * Creates a VFS update message. + * @param path The path in question + */ + public VFSUpdate(String path) { + super(null); + + if (path == null) { + throw new NullPointerException("Path must be non-null"); + } + + this.path = path; + }//}}} + + //{{{ getPath() + /** + * Returns the path that changed. + */ + public String getPath() { + return path; + }//}}} + + //{{{ paramString() + public String paramString() { + return "path=" + path + "," + super.paramString(); + }//}}} + + //{{{ Private members + private String path; + //}}} +} Modified: branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java 2006-08-29 20:10:17 UTC (rev 1199) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java 2006-08-29 20:33:55 UTC (rev 1200) @@ -134,70 +134,72 @@ return false; } //}}} - // //{{{ constructPath() method - // /** - // * Constructs an absolute path name from a directory and another - // * path name. This method is VFS-aware. - // * @param parent The directory - // * @param path The path name - // */ - // public static String constructPath(String parent, String path) - // { - // if(MiscUtilities.isURL(path)) - // return path; - // else if(path.startsWith("~")) - // return path; - // else - // { - // // have to handle these cases specially on windows. - // if(OperatingSystem.isDOSDerived()) - // { - // if(path.length() == 2 && path.charAt(1) == ':') - // return path; - // else if(path.length() > 2 && path.charAt(1) == ':') - // { - // if(path.charAt(2) != '\\') - // { - // path = path.substring(0,2) + '\\' - // + path.substring(2); - // } - // - // return resolveSymlinks(path); - // } - // else if(path.startsWith("\\\\")) - // return resolveSymlinks(path); - // } - // else if(OperatingSystem.isUnix()) - // { - // // nice and simple - // if(path.length() > 0 && path.charAt(0) == '/') - // return resolveSymlinks(path); - // } - // } - // - // if(parent == null) - // parent = System.getProperty("user.dir"); - // - // if(OperatingSystem.isDOSDerived() && path.startsWith("\\")) - // parent = parent.substring(0,2); - // - // VFS vfs = VFSManager.getVFSForPath(parent); - // return vfs.constructPath(parent,path); - // } //}}} + //{{{ constructPath() method + /** + * Constructs an absolute path name from a directory and another + * path name. This method is VFS-aware. + * @param parent The directory + * @param path The path name + */ + public static String constructPath(String parent, String path) { + + if (MiscUtilities.isURL(path)) { + return path; + } else { + if (path.startsWith("~")) { + return path; + } else { + // have to handle these cases specially on windows. + if (OperatingSystem.isDOSDerived()) { + if (path.length() == 2 && path.charAt(1) == ':') { + return path; + } else { + if (path.length() > 2 && path.charAt(1) == ':') { + if (path.charAt(2) != '\\') { + path = path.substring(0,2) + '\\' + path.substring(2); + } + + return resolveSymlinks(path); + } else { + if (path.startsWith("\\\\")) { + return resolveSymlinks(path); + } + } + } + } else { + if (OperatingSystem.isUnix()) { + // nice and simple + if (path.length() > 0 && path.charAt(0) == '/') { + return resolveSymlinks(path); + } + } + } + } + } + + if (parent == null) { + parent = jsXe.getHomeDirectory(); + } + + if (OperatingSystem.isDOSDerived() && path.startsWith("\\")) { + parent = parent.substring(0,2); + } + + VFS vfs = VFSManager.getVFSForPath(parent); + return vfs.constructPath(parent,path); + } //}}} - // //{{{ constructPath() method - // /** - // * Constructs an absolute path name from three path components. - // * This method is VFS-aware. - // * @param parent The parent directory - // * @param path1 The first path - // * @param path2 The second path - // */ - // public static String constructPath(String parent, - // String path1, String path2) - // { - // return constructPath(constructPath(parent,path1),path2); - // } //}}} + //{{{ constructPath() method + /** + * Constructs an absolute path name from three path components. + * This method is VFS-aware. + * @param parent The parent directory + * @param path1 The first path + * @param path2 The second path + */ + public static String constructPath(String parent, String path1, String path2) { + return constructPath(constructPath(parent,path1),path2); + } //}}} //{{{ concatPath() method /** Added: branches/jsxe2/src/net/sourceforge/jsxe/util/SegmentBuffer.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/SegmentBuffer.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/SegmentBuffer.java 2006-08-29 20:33:55 UTC (rev 1200) @@ -0,0 +1,72 @@ +/* +SegmentBuffer.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2001 Slava Pestov + +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. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.util; + +import javax.swing.text.Segment; + +/** + * An extended segment that you can append text to. + */ +public class SegmentBuffer extends Segment { + + //{{{ SegmentBuffer constructor + public SegmentBuffer(int capacity) + { + ensureCapacity(capacity); + } //}}} + + //{{{ append() method + public void append(char ch) + { + ensureCapacity(count + 1); + array[offset + count] = ch; + count++; + } //}}} + + //{{{ append() method + public void append(char[] text, int off, int len) + { + ensureCapacity(count + len); + System.arraycopy(text,off,array,count,len); + count += len; + } //}}} + + //{{{ Private members + + //{{{ ensureCapacity() method + private void ensureCapacity(int capacity) + { + if(array == null) + array = new char[capacity]; + else if(capacity >= array.length) + { + char[] arrayN = new char[capacity * 2]; + System.arraycopy(array,0,arrayN,0,count); + array = arrayN; + } + } //}}} + + //}}} +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |