/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* NavServices-like implementation of a file Table
*
* Some of it came from BasicDirectoryModel
*/
private final boolean fSortAscending[] = {true, true};
// private boolean fSortAscending = true;
private boolean fSortNames = true;
public AquaFileSystemModel(final JFileChooser filechooser, final JTable filelist, final String[] colNames) {
fileCacheLock = new Object();
this.filechooser = filechooser;
}
void updateSelectionMode() {
// Save dialog lists can't be multi select, because all we're selecting is the next folder to open
final boolean b = filechooser.isMultiSelectionEnabled() && filechooser.getDialogType() != JFileChooser.SAVE_DIALOG;
fFileList.setSelectionMode(b ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION);
}
if (prop == JFileChooser.DIRECTORY_CHANGED_PROPERTY || prop == JFileChooser.FILE_VIEW_CHANGED_PROPERTY || prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY || prop == JFileChooser.FILE_HIDING_CHANGED_PROPERTY) {
}
}
if (prop == SORT_ASCENDING_CHANGED) {
}
}
public void invalidateFileCache() {
directories = null;
synchronized(fileCacheLock) {
}
}
}
return directories;
}
directories.addElement(filechooser.getFileSystemView().createFileObject(filechooser.getCurrentDirectory(), ".."));
synchronized(fileCacheLock) {
if (filechooser.isTraversable(f)) {
} else {
files.addElement(f);
}
}
}
return files;
}
synchronized (fileCacheLock) {
if (loadThread != null) {
if (loadThread.isAlive()) {
return;
}
}
}
}
public void validateFileCache() {
if (currentDirectory == null) {
return;
}
if (loadThread != null) {
// interrupt
}
fetchID++;
// PENDING(jeff) pick the size more sensibly
synchronized(fileCacheLock) {
}
loadThread.start();
}
public int getColumnCount() {
return 2;
}
return fColumnNames[col];
}
return Date.class;
}
public int getRowCount() {
synchronized(fileCacheLock) {
}
return 0;
}
}
// SAK: Part of fix for 3168263. The fileCache contains
// SortableFiles, so when finding a file in the list we need to
// first create a sortable file.
synchronized(fileCacheLock) {
}
return false;
}
}
synchronized(fileCacheLock) {
}
return 0;
}
}
// AbstractListModel interface
}
// AbstractTableModel interface
synchronized(fileCacheLock) {
}
return null;
}
}
// PENDING(jeff) - implement
}
// PENDING(jeff) - implement
}
}
// Liberated from the 1.1 SortDemo
//
// This is a generic version of C.A.R Hoare's Quick Sort
// algorithm. This will handle arrays that are already
// sorted, and arrays with duplicate keys.<BR>
//
// If you think of a one dimensional array as going from
// the lowest index on the left to the highest index on the right
// then the parameters to this function are lowest index or
// left and highest index or right. The first time you call
// this function it will be with the parameters 0, a.length - 1.
//
// @param a an integer array
// @param lo0 left boundary of array partition
// @param hi0 right boundary of array partition
abstract class QuickSort {
// Arbitrarily establishing partition element as the midpoint of
// the array.
// loop through the array until indices cross
// find the first element that is greater than or equal to
// the partition element starting from the left Index.
//
// Nasty to have to cast here. Would it be quicker
// to copy the vectors into arrays and sort the arrays?
++lo;
}
// find an element that is smaller than or equal to
// the partition element starting from the right Index.
--hi;
}
// if the indexes have not crossed, swap
++lo;
--hi;
}
}
// If the right index has not reached the left side of array
// must now sort the left partition.
}
// If the left index has not reached the right side of array
// must now sort the right partition.
}
}
}
a.setElementAt(a.elementAt(j), i);
a.setElementAt(T, j);
}
}
}
}
return a.fDateValue < b.fDateValue;
}
}
// for speed in sorting, displaying
long fDateValue;
fFile = f;
}
return fDate;
}
}
}
int fid;
super("Aqua L&F File Loading Thread");
this.currentDirectory = currentDirectory;
}
public void run() {
// Return all files to the file chooser. The UI will disable or enable
// the file name if the current filter approves.
}
// Sort based on settings.
// Don't separate directories from files
for (int i = 0; i < listSize;) {
SortableFile f;
chunk.addElement(f);
}
if (isInterrupted()) {
// interrupted, cancel all runnables
return;
}
}
synchronized (fileCacheLock) {
for (final Runnable r : queuedTasks) {
}
}
}
}
}
}
private boolean doFire = true;
private final int fid;
this.contentFiles = files;
}
synchronized void cancel() {
synchronized(lock) {
doFire = false;
}
}
public void run() {
synchronized(lock) {
if (doFire) {
synchronized(fileCacheLock) {
fireTableRowsInserted(i, i);
}
}
}
}
contentFiles = null;
directories = null;
}
}
}
}
}