home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / plaf / metal / MetalFileChooserUI$DirectoryComboBoxModel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.4 KB  |  112 lines

  1. package javax.swing.plaf.metal;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.Vector;
  6. import javax.swing.AbstractListModel;
  7. import javax.swing.ComboBoxModel;
  8. import javax.swing.plaf.basic.BasicFileChooserUI;
  9.  
  10. public class MetalFileChooserUI$DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
  11.    Vector directories;
  12.    int topIndex;
  13.    int pathCount;
  14.    File selectedDirectory;
  15.    // $FF: synthetic field
  16.    private final MetalFileChooserUI this$0;
  17.  
  18.    public MetalFileChooserUI$DirectoryComboBoxModel(MetalFileChooserUI var1) {
  19.       this.this$0 = var1;
  20.       this.directories = new Vector();
  21.       this.topIndex = -1;
  22.       this.pathCount = 0;
  23.       this.selectedDirectory = null;
  24.       File[] var2 = ((BasicFileChooserUI)var1).getFileChooser().getFileSystemView().getRoots();
  25.  
  26.       for(int var3 = 0; var3 < var2.length; ++var3) {
  27.          this.directories.addElement(var2[var3]);
  28.       }
  29.  
  30.       File var4 = ((BasicFileChooserUI)var1).getFileChooser().getCurrentDirectory();
  31.       if (var4 != null) {
  32.          this.addItem(var4);
  33.       }
  34.  
  35.    }
  36.  
  37.    private void removeSelectedDirectory() {
  38.       if (this.topIndex >= 0) {
  39.          for(int var1 = this.topIndex; var1 < this.topIndex + this.pathCount; ++var1) {
  40.             this.directories.removeElementAt(this.topIndex + 1);
  41.          }
  42.       }
  43.  
  44.       this.topIndex = -1;
  45.       this.pathCount = 0;
  46.       this.selectedDirectory = null;
  47.    }
  48.  
  49.    private void addItem(File var1) {
  50.       if (var1 != null) {
  51.          if (this.selectedDirectory != null) {
  52.             this.removeSelectedDirectory();
  53.          }
  54.  
  55.          Object var2 = null;
  56.  
  57.          try {
  58.             var7 = this.this$0.getFileChooser().getFileSystemView().createFileObject(var1.getCanonicalPath());
  59.          } catch (IOException var6) {
  60.             return;
  61.          }
  62.  
  63.          File var3 = var7;
  64.  
  65.          Vector var4;
  66.          for(var4 = new Vector(10); var3.getParent() != null; var3 = this.this$0.getFileChooser().getFileSystemView().createFileObject(var3.getParent())) {
  67.             var4.addElement(var3);
  68.             if (this.directories.contains(var3)) {
  69.                this.topIndex = this.directories.indexOf(var3);
  70.             }
  71.          }
  72.  
  73.          this.pathCount = var4.size();
  74.          if (this.topIndex < 0) {
  75.             if (this.directories.contains(var3)) {
  76.                this.topIndex = this.directories.indexOf(var3);
  77.             } else {
  78.                this.directories.addElement(var3);
  79.             }
  80.          }
  81.  
  82.          for(int var5 = 0; var5 < var4.size(); ++var5) {
  83.             this.directories.insertElementAt(var4.elementAt(var5), this.topIndex + 1);
  84.          }
  85.  
  86.          this.setSelectedItem(var7);
  87.       }
  88.    }
  89.  
  90.    public void setSelectedItem(Object var1) {
  91.       this.selectedDirectory = (File)var1;
  92.       ((AbstractListModel)this).fireContentsChanged(this, -1, -1);
  93.    }
  94.  
  95.    public Object getSelectedItem() {
  96.       return this.selectedDirectory;
  97.    }
  98.  
  99.    public int getSize() {
  100.       return this.directories.size();
  101.    }
  102.  
  103.    public Object getElementAt(int var1) {
  104.       return this.directories.elementAt(var1);
  105.    }
  106.  
  107.    // $FF: synthetic method
  108.    static void access$600(MetalFileChooserUI$DirectoryComboBoxModel var0, File var1) {
  109.       var0.addItem(var1);
  110.    }
  111. }
  112.