jdk/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 678 7d331a53a753
child 1299 027d966d5658
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 678
diff changeset
     2
 * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.basic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.filechooser.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.awt.shell.ShellFolder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Basic implementation of a file list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @author Jeff Dinkins
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public class BasicDirectoryModel extends AbstractListModel implements PropertyChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private JFileChooser filechooser = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    // PENDING(jeff) pick the size more sensibly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private Vector fileCache = new Vector(50);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private LoadFilesThread loadThread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private Vector files = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private Vector directories = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private int fetchID = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private PropertyChangeSupport changeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private boolean busy = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    public BasicDirectoryModel(JFileChooser filechooser) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        this.filechooser = filechooser;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        validateFileCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public void propertyChange(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        String prop = e.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        if(prop == JFileChooser.DIRECTORY_CHANGED_PROPERTY ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
           prop == JFileChooser.FILE_VIEW_CHANGED_PROPERTY ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
           prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
           prop == JFileChooser.FILE_HIDING_CHANGED_PROPERTY ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
           prop == JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            validateFileCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        } else if ("UI".equals(prop)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            Object old = e.getOldValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            if (old instanceof BasicFileChooserUI) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                BasicFileChooserUI ui = (BasicFileChooserUI) old;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                BasicDirectoryModel model = ui.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                if (model != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                    model.invalidateFileCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        } else if ("JFileChooserDialogIsClosingProperty".equals(prop)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            invalidateFileCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * This method is used to interrupt file loading thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public void invalidateFileCache() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (loadThread != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            loadThread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            loadThread.cancelRunnables();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            loadThread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public Vector<File> getDirectories() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        synchronized(fileCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            if (directories != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                return directories;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            Vector fls = getFiles();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            return directories;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public Vector<File> getFiles() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        synchronized(fileCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            if (files != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                return files;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            files = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            directories = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            directories.addElement(filechooser.getFileSystemView().createFileObject(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                filechooser.getCurrentDirectory(), "..")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            for (int i = 0; i < getSize(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                File f = (File)fileCache.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                if (filechooser.isTraversable(f)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    directories.add(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    files.add(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            return files;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public void validateFileCache() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        File currentDirectory = filechooser.getCurrentDirectory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (currentDirectory == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (loadThread != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            loadThread.interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            loadThread.cancelRunnables();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        setBusy(true, ++fetchID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        loadThread = new LoadFilesThread(currentDirectory, fetchID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        loadThread.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Renames a file in the underlying file system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @param oldFile a <code>File</code> object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *        the existing file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param newFile a <code>File</code> object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *        the desired new file name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @return <code>true</code> if rename succeeded,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *        otherwise <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public boolean renameFile(File oldFile, File newFile) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        synchronized(fileCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            if (oldFile.renameTo(newFile)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                validateFileCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public void fireContentsChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        // System.out.println("BasicDirectoryModel: firecontentschanged");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        fireContentsChanged(this, 0, getSize()-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public int getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        return fileCache.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    public boolean contains(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        return fileCache.contains(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public int indexOf(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        return fileCache.indexOf(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public Object getElementAt(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return fileCache.get(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Obsolete - not used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public void intervalAdded(ListDataEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Obsolete - not used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public void intervalRemoved(ListDataEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    protected void sort(Vector<? extends File> v){
678
7d331a53a753 6571802: 'Shared Documents' listed in-between C,D drives in the JFileChooser, does not match with native
rupashka
parents: 2
diff changeset
   199
        ShellFolder.sort(v);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    // Obsolete - not used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    protected boolean lt(File a, File b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        // First ignore case when comparing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        int diff = a.getName().toLowerCase().compareTo(b.getName().toLowerCase());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        if (diff != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            return diff < 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            // May differ in case (e.g. "mail" vs. "Mail")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            return a.getName().compareTo(b.getName()) < 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    class LoadFilesThread extends Thread {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        File currentDirectory = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        int fid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        Vector runnables = new Vector(10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        public LoadFilesThread(File currentDirectory, int fid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            super("Basic L&F File Loading Thread");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            this.currentDirectory = currentDirectory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            this.fid = fid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        private void invokeLater(Runnable runnable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            runnables.addElement(runnable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            SwingUtilities.invokeLater(runnable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            run0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            setBusy(false, fid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        public void run0() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            FileSystemView fileSystem = filechooser.getFileSystemView();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            Vector<File> acceptsList = new Vector<File>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            if (isInterrupted()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            // run through the file list, add directories and selectable files to fileCache
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            for (int i = 0; i < list.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                if(filechooser.accept(list[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                    acceptsList.addElement(list[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            if (isInterrupted()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            // First sort alphabetically by filename
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            sort(acceptsList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            Vector newDirectories = new Vector(50);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            Vector newFiles = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            // run through list grabbing directories in chunks of ten
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            for(int i = 0; i < acceptsList.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                File f = (File) acceptsList.elementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                boolean isTraversable = filechooser.isTraversable(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                if (isTraversable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                    newDirectories.addElement(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                } else if (!isTraversable && filechooser.isFileSelectionEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                    newFiles.addElement(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                if(isInterrupted()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            Vector newFileCache = new Vector(newDirectories);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            newFileCache.addAll(newFiles);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            int newSize = newFileCache.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            int oldSize = fileCache.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            if (newSize > oldSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                //see if interval is added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                int start = oldSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                int end = newSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                for (int i = 0; i < oldSize; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                    if (!newFileCache.get(i).equals(fileCache.get(i))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                        start = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                        for (int j = i; j < newSize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                            if (newFileCache.get(j).equals(fileCache.get(i))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                                end = j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                if (start >= 0 && end > start
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                    && newFileCache.subList(end, newSize).equals(fileCache.subList(start, oldSize))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                    if(isInterrupted()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                    invokeLater(new DoChangeContents(newFileCache.subList(start, end), start, null, 0, fid));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                    newFileCache = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            } else if (newSize < oldSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                //see if interval is removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                int start = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                int end = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                for (int i = 0; i < newSize; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                    if (!newFileCache.get(i).equals(fileCache.get(i))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                        start = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                        end = i + oldSize - newSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                if (start >= 0 && end > start
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                    && fileCache.subList(end, oldSize).equals(newFileCache.subList(start, newSize))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    if(isInterrupted()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                    invokeLater(new DoChangeContents(null, 0, new Vector(fileCache.subList(start, end)),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                                                     start, fid));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                    newFileCache = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            if (newFileCache != null && !fileCache.equals(newFileCache)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                if (isInterrupted()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    cancelRunnables(runnables);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                invokeLater(new DoChangeContents(newFileCache, 0, fileCache, 0, fid));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        public void cancelRunnables(Vector runnables) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            for(int i = 0; i < runnables.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                ((DoChangeContents)runnables.elementAt(i)).cancel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        public void cancelRunnables() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            cancelRunnables(runnables);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * Adds a PropertyChangeListener to the listener list. The listener is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * registered for all bound properties of this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * If <code>listener</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @param    listener  the property change listener to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @see #removePropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @see #getPropertyChangeListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    public void addPropertyChangeListener(PropertyChangeListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        if (changeSupport == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            changeSupport = new PropertyChangeSupport(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        changeSupport.addPropertyChangeListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * Removes a PropertyChangeListener from the listener list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * If listener is null, no exception is thrown and no action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @param listener the PropertyChangeListener to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @see #addPropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @see #getPropertyChangeListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public void removePropertyChangeListener(PropertyChangeListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        if (changeSupport != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            changeSupport.removePropertyChangeListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * Returns an array of all the property change listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * registered on this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * @return all of this component's <code>PropertyChangeListener</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *         or an empty array if no property change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *         listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @see      #addPropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @see      #removePropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @see      java.beans.PropertyChangeSupport#getPropertyChangeListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    public PropertyChangeListener[] getPropertyChangeListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        if (changeSupport == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            return new PropertyChangeListener[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        return changeSupport.getPropertyChangeListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Support for reporting bound property changes for boolean properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * This method can be called when a bound property has changed and it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * send the appropriate PropertyChangeEvent to any registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * PropertyChangeListeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @param propertyName the property whose value has changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @param oldValue the property's previous value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * @param newValue the property's new value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    protected void firePropertyChange(String propertyName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                                      Object oldValue, Object newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        if (changeSupport != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            changeSupport.firePropertyChange(propertyName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                                             oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * Set the busy state for the model. The model is considered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * busy when it is running a separate (interruptable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * thread in order to load the contents of a directory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    private synchronized void setBusy(final boolean busy, int fid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        if (fid == fetchID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            boolean oldValue = this.busy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            this.busy = busy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            if (changeSupport != null && busy != oldValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                SwingUtilities.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                        firePropertyChange("busy", !busy, busy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    class DoChangeContents implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        private List addFiles;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        private List remFiles;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        private boolean doFire = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        private int fid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        private int addStart = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        private int remStart = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        private int change;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        public DoChangeContents(List addFiles, int addStart, List remFiles, int remStart, int fid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            this.addFiles = addFiles;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            this.addStart = addStart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            this.remFiles = remFiles;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            this.remStart = remStart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            this.fid = fid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        synchronized void cancel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                doFire = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        public synchronized void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            if (fetchID == fid && doFire) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                int remSize = (remFiles == null) ? 0 : remFiles.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                int addSize = (addFiles == null) ? 0 : addFiles.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                synchronized(fileCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                    if (remSize > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                        fileCache.removeAll(remFiles);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                    if (addSize > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                        fileCache.addAll(addStart, addFiles);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                    files = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                    directories = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                if (remSize > 0 && addSize == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                    fireIntervalRemoved(BasicDirectoryModel.this, remStart, remStart + remSize - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                } else if (addSize > 0 && remSize == 0 && fileCache.size() > addSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                    fireIntervalAdded(BasicDirectoryModel.this, addStart, addStart + addSize - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                    fireContentsChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
}