You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by "Thamm, Russell" <ru...@dsto.defence.gov.au> on 2002/07/22 08:41:53 UTC
SPFileChooser and JDK 1.4
Hi,
has anybody looked at the incompatibilities between SPFileChooser and JDK
1.4?
The current code keeps being passed a Win32ShellFolder object when it
expects a SPFile
object.
I gather that most of the problems are due to the extensive changes made to
javax.swing.filechooser.FileSystemView class.
The other problem appears to be the model for the Directory ComboBox. This
automatically
adds ShellFolder objects to the ComboBox. I cannot work out how to override
this model.
Russell Thamm
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: SPFileChooser and JDK 1.4
Posted by Justin Lipton <ju...@speedlegal.com>.
Hi Russell,
I've been playing with this from time to time.
You're spot on about the changes and I've bugged a couple of the issues with
Sun.
Here are the changes that I've made - it seems to work OK - hope I haven't
missed anything ;)
Cheers,
Justin.
Index: src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java,v
retrieving revision 1.5
diff -u -r1.5 SPFileChooser.java
--- src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java 28
Mar 2002 06:23:09 -0000 1.5
+++ src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java 22
Jul 2002 07:30:14 -0000
@@ -221,6 +221,7 @@
return (SPFile) directoryService.getHomeDirectory();
}
+
public void gotoDirectory(SPFile aFile) {
SPFile currentDir = (!aFile.isTraversable())
? (SPFile) aFile.getParentFile()
@@ -273,6 +274,12 @@
}
return isCorrect;
}
+
+ public void setCurrentDirectory(File dir) {
+ if (dir==null)
+ dir = getDirectoryService().getRoot();
+ super.setCurrentDirectory(dir);
+ }
}// End of SPFileChooser class
Index: src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java,v
retrieving revision 1.8
diff -u -r1.8 SPFile.java
--- src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java 28 Mar
2002 06:23:10 -0000 1.8
+++ src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java 22 Jul
2002 07:30:17 -0000
@@ -65,6 +65,8 @@
import java.io.*;
import java.util.*;
+import java.text.SimpleDateFormat;
+import java.text.ParseException;
import javax.swing.JOptionPane;
import org.apache.webdav.lib.*;
@@ -73,6 +75,7 @@
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpClient;
+import org.apache.webdav.ui.lib.properties.SPProperty;
/**
* Title: SPFile.java
@@ -84,7 +87,16 @@
public class SPFile extends File {
private SPDirectoryService directoryService;
- private SPResourceNode _resourceNode;
+ private SPResourceNode _resourceNode=null;
+
+ private static SimpleDateFormat formats [] = {
+ new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"),
+ new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"),
+ new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz"),
+ new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy"),
+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"),
+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'")
+ };
@@ -239,17 +256,53 @@
public long getContentLength() {
+ /*
GetContentLengthProperty prop = (GetContentLengthProperty)
getResourceNode().getProperty("getcontentlength");
return prop.getLength();
+ */
+ SPProperty prop =
getResourceNode().getProperty("getcontentlength");
+ if (prop!=null)
+ return Integer.parseInt(prop.getPropertyAsString());
+ return 0;
+ }
+
+
+ public long lastModified() {
+ SPProperty prop = getResourceNode().getProperty("getlastmodified");
+ if (prop!=null) {
+ Date date = null;
+ int index =0;
+ for (index=0; (date==null && index<formats.length); index++) {
+ try {
+ date =
formats[index].parse(prop.getPropertyAsString());
+ } catch (ParseException pe) {
+ ;
+ }
+ }
+ // Make sure things are optimised...
+ if (index>0) {
+ SimpleDateFormat nonOptimal = formats[0];
+ formats[0] = formats[index];
+ formats[index] = nonOptimal;
+ }
+ if (date!=null)
+ return date.getTime();
+ }
+ return 0;
}
+ public long length() {
+ return getContentLength();
+ }
+
+
/*
* Returns null if the resource node is not found in server
*/
public SPResourceNode getResourceNode() {
if (_resourceNode!=null)
- return _resourceNode;
+ return _resourceNode;
SPResourceNode theNode=null;
Index:
src/java/org/apache/webdav/ui/filechooser/plafui/SPMetalFileChooserUI.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/plafui/SPMetalFileChooserUI.java,v
retrieving revision 1.3
diff -u -r1.3 SPMetalFileChooserUI.java
---
src/java/org/apache/webdav/ui/filechooser/plafui/SPMetalFileChooserUI.java
28 Mar 2002 06:23:10 -0000 1.3
+++
src/java/org/apache/webdav/ui/filechooser/plafui/SPMetalFileChooserUI.java
22 Jul 2002 07:30:21 -0000
@@ -77,7 +77,6 @@
import org.apache.webdav.ui.filechooser.dir.*;
import org.apache.webdav.ui.filechooser.*;
-
public class SPMetalFileChooserUI extends MetalFileChooserUI {
private Action approveAction = new ApproveAction();
@@ -114,6 +113,7 @@
return new MetalDoubleClickListener(list);
}
+
protected class MetalDoubleClickListener extends MouseAdapter {
protected JList list;
@@ -170,11 +170,16 @@
&& (chooser.isFilterNaming())
&& (fFilter instanceof SPFileFilter) ) {
SPFileFilter filter = (SPFileFilter) fFilter;
+ if (!filename.endsWith((String) filter.getFileExtension(0)))
+ filename = filename.concat(
+ (String) filter.getFileExtension(0));
+ /*
int dotIndex = filename.indexOf(".");
if (dotIndex < 0) {
filename = filename.concat(
(String) filter.getFileExtension(0));
}
+ */
}
// check for directory change action
@@ -253,6 +258,7 @@
return this;
}
}//MetalFileRenderer inner class
+
private SPFileChooser getSPFileChooser() {
return (SPFileChooser) getFileChooser();
Index:
src/java/org/apache/webdav/ui/filechooser/plafui/SPWindowsFileChooserUI.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/plafui/SPWindowsFileChooserUI.java,v
retrieving revision 1.3
diff -u -r1.3 SPWindowsFileChooserUI.java
---
src/java/org/apache/webdav/ui/filechooser/plafui/SPWindowsFileChooserUI.java
28 Mar 2002 06:23:10 -0000 1.3
+++
src/java/org/apache/webdav/ui/filechooser/plafui/SPWindowsFileChooserUI.java
22 Jul 2002 07:30:22 -0000
@@ -169,11 +169,16 @@
&& (chooser.isFilterNaming())
&& (fFilter instanceof SPFileFilter) ) {
SPFileFilter filter = (SPFileFilter) fFilter;
+ if (!filename.endsWith((String) filter.getFileExtension(0)))
+ filename = filename.concat(
+ (String) filter.getFileExtension(0));
+ /*
int dotIndex = filename.indexOf(".");
if (dotIndex < 0) {
filename = filename.concat(
(String) filter.getFileExtension(0));
}
+ */
}
// check for directory change action
Thamm, Russell wrote:
>Hi,
>
>has anybody looked at the incompatibilities between SPFileChooser and JDK
>1.4?
>
>The current code keeps being passed a Win32ShellFolder object when it
>expects a SPFile
>object.
>
>I gather that most of the problems are due to the extensive changes made to
>javax.swing.filechooser.FileSystemView class.
>
>The other problem appears to be the model for the Directory ComboBox. This
>automatically
>adds ShellFolder objects to the ComboBox. I cannot work out how to override
>this model.
>
>Russell Thamm
>
>
>--
>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
--
SPEEDLEGAL
Melbourne & San Francisco
Tel +61 (0)3 9670 0141
Fax +61 (0)3 9670 0142
www.speedlegal.com
SmartPrecedent(R) software
The most intelligent way to create documents
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>