classpath-patches
[Top][All Lists]
Advanced

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

Re: [cp-patches] FYI: javax.swing.filechooser.FileSystemView


From: David Gilbert
Subject: Re: [cp-patches] FYI: javax.swing.filechooser.FileSystemView
Date: Tue, 11 Oct 2005 11:34:59 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050728)

Michael Koch wrote:

On Tue, Oct 11, 2005 at 10:31:22AM +0000, David Gilbert wrote:
I committed this patch, there is no need for a new FileSystemView to be created for each call to getFileSystemView():

2005-10-11  David Gilbert  <address@hidden>

        * javax/swing/filechooser/FileSystemView.java
        (defaultFileSystemView): new private field,
        (getFileSystemView): initialise (if necessary) and return
        defaultFileSystemView.

I have a Mauve test that I'll commit in a moment...

Please include the actual patches you commit here too.


Cheers,
Michael aka "The Nitpicker"
Thanks and sorry!  See attached diff.txt.

Regards,

Dave
Index: javax/swing/filechooser/FileSystemView.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/filechooser/FileSystemView.java,v
retrieving revision 1.8
diff -u -r1.8 FileSystemView.java
--- javax/swing/filechooser/FileSystemView.java 18 Sep 2005 03:06:39 -0000      
1.8
+++ javax/swing/filechooser/FileSystemView.java 11 Oct 2005 09:23:52 -0000
@@ -48,6 +48,9 @@
  */
 public abstract class FileSystemView
 {
+  /** The instance returned by address@hidden #getFileSystemView()}. */
+  private static FileSystemView defaultFileSystemView;
+  
   /**
    * DOCUMENT ME!
    *
@@ -148,20 +151,22 @@
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns a default address@hidden FileSystemView} appropriate for the 
platform.
    *
-   * @return DOCUMENT ME!
+   * @return A default address@hidden FileSystemView} appropriate for the 
platform.
    */
   public static FileSystemView getFileSystemView()
   {
-    if (File.separator.equals("/"))
-      return new UnixFileSystemView();
-
-    // else if (File.Separator.equals("\"))
-    // return new Win32FileSystemView();
-    // else 
-    // return new GenericFileSystemView();
-    return null;
+    if (defaultFileSystemView == null)
+      {
+        if (File.separator.equals("/"))
+          defaultFileSystemView = new UnixFileSystemView();
+        // else if (File.Separator.equals("\"))
+        //   return new Win32FileSystemView();
+        // else 
+        //   return new GenericFileSystemView();
+      }
+    return defaultFileSystemView;
   }
 
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]