home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / filechooser / WindowsFileSystemView.class (.txt) < prev   
Encoding:
Java Class File  |  1999-07-15  |  3.1 KB  |  106 lines

  1. package javax.swing.filechooser;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.lang.reflect.Method;
  6. import java.util.Vector;
  7.  
  8. class WindowsFileSystemView extends FileSystemView {
  9.    private static final Object[] noArgs = new Object[0];
  10.    private static final Class[] noArgTypes = new Class[0];
  11.    private static Method listRootsMethod = null;
  12.    private static boolean listRootsMethodChecked = false;
  13.    // $FF: synthetic field
  14.    static Class class$java$io$File;
  15.  
  16.    // $FF: synthetic method
  17.    static Class class$(String var0) {
  18.       try {
  19.          return Class.forName(var0);
  20.       } catch (ClassNotFoundException var2) {
  21.          throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  22.       }
  23.    }
  24.  
  25.    public File createNewFolder(File var1) throws IOException {
  26.       if (var1 == null) {
  27.          throw new IOException("Containing directory is null:");
  28.       } else {
  29.          Object var2 = null;
  30.          File var4 = ((FileSystemView)this).createFileObject(var1, "New Folder");
  31.  
  32.          for(int var3 = 2; var4.exists() && var3 < 100; ++var3) {
  33.             var4 = ((FileSystemView)this).createFileObject(var1, "New Folder (" + var3 + ")");
  34.          }
  35.  
  36.          if (var4.exists()) {
  37.             throw new IOException("Directory already exists:" + var4.getAbsolutePath());
  38.          } else {
  39.             var4.mkdirs();
  40.             return var4;
  41.          }
  42.       }
  43.    }
  44.  
  45.    public File[] getRoots() {
  46.       if (!listRootsMethodChecked) {
  47.          try {
  48.             listRootsMethod = (class$java$io$File != null ? class$java$io$File : (class$java$io$File = class$("java.io.File"))).getMethod("listRoots", noArgTypes);
  49.          } catch (NoSuchMethodException var10) {
  50.          } finally {
  51.             listRootsMethodChecked = true;
  52.          }
  53.       }
  54.  
  55.       if (listRootsMethod != null) {
  56.          try {
  57.             File[] var13 = (File[])listRootsMethod.invoke((Object)null, noArgs);
  58.  
  59.             for(int var14 = 0; var14 < var13.length; ++var14) {
  60.                var13[var14] = new FileSystemRoot(var13[var14]);
  61.             }
  62.  
  63.             return var13;
  64.          } catch (Exception var12) {
  65.             ((Throwable)var12).printStackTrace();
  66.             return null;
  67.          }
  68.       } else {
  69.          Vector var1 = new Vector();
  70.          FileSystemRoot var2 = new FileSystemRoot("A:\\");
  71.          var1.addElement(var2);
  72.  
  73.          for(char var3 = 'C'; var3 <= 'Z'; ++var3) {
  74.             char[] var4 = new char[]{var3, ':', '\\'};
  75.             String var5 = new String(var4);
  76.             FileSystemRoot var6 = new FileSystemRoot(var5);
  77.             if (var6 != null && ((File)var6).exists()) {
  78.                var1.addElement(var6);
  79.             }
  80.          }
  81.  
  82.          File[] var15 = new File[var1.size()];
  83.          var1.copyInto(var15);
  84.          return var15;
  85.       }
  86.    }
  87.  
  88.    public boolean isHiddenFile(File var1) {
  89.       return false;
  90.    }
  91.  
  92.    public boolean isRoot(File var1) {
  93.       if (!var1.isAbsolute()) {
  94.          return false;
  95.       } else {
  96.          String var2 = var1.getParent();
  97.          if (var2 == null) {
  98.             return true;
  99.          } else {
  100.             File var3 = new File(var2);
  101.             return var3.equals(var1);
  102.          }
  103.       }
  104.    }
  105. }
  106.