Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
A Mavenisation of the Quaqua Mac OSX Swing Look and Feel (Java library)
Quaqua Look and Feel (C) 2003-2010, Werner Randelshofer.
Mavenisation by Matt Gumbley, DevZendo.org - for problems with
Mavenisation, see Matt; for issues with Quaqua, see the Quaqua home page.
For full license details, see http://randelshofer.ch/quaqua/license.html
/*
* @(#)SidebarTreeModel.java 4.1 2009-04-05
*
* Copyright (c) 2007-2010 Werner Randelshofer, Immensee, Switzerland.
* All rights reserved.
*
* The copyright of this software is owned by Werner Randelshofer.
* You may not use, copy or modify this software, except in
* accordance with the license agreement you entered into with
* Werner Randelshofer. For details see accompanying license terms.
*/
package ch.randelshofer.quaqua.leopard.filechooser;
import ch.randelshofer.quaqua.osx.OSXFile;
import ch.randelshofer.quaqua.filechooser.*;
import ch.randelshofer.quaqua.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.io.*;
import java.util.*;
import ch.randelshofer.quaqua.*;
import ch.randelshofer.quaqua.ext.base64.*;
import ch.randelshofer.quaqua.ext.nanoxml.*;
/**
* SidebarTreeModel.
*
* @author Werner Randelshofer
* @version 4.1 2009-04-05 Added defaultUserItems for Linux.
* 4.0 2008-07-15 Rewrote updating of devices node.
* 3.1 2008-05-09 FileNode reads value of variable userName lazily.
* 3.0.1 2008-04-17 Method FileNode.getIcon fired wrong event.
* 3.0 2008-03-26 Method treeNodesChanged() must map model viewIndices
* to view viewIndices for the change event that it fires on its own. Method
* updateSystemItem must attempt to merge existing view nodes, because the JTree
* might have stored selection paths to the nodes.
* 2.0 2007-11-24 Added support for Darwin.
* 1.0 November 10, 2007 Created.
*/
public class SidebarTreeModel extends DefaultTreeModel implements TreeModelListener {
/**
* This file contains information about the system list and holds the aliases
* for the user list.
*/
private final static File sidebarFile = new File(QuaquaManager.getProperty("user.home"), "Library/Preferences/com.apple.sidebarlists.plist");
/**
* Holds the tree volumesPath to the /Volumes folder.
*/
private TreePath volumesPath;
/**
* Holds the FileSystemTreeModel.
*/
private TreeModel model;
/**
* Represents the "Devices" node in the sidebar.
*/
private DefaultMutableTreeNode devicesNode;
/**
* Represents the "Places" node in the sidebar.
*/
private DefaultMutableTreeNode placesNode;
/**
* Intervals between validations.
*/
private final static long VALIDATION_TTL = 60000;
/**
* Time for next validation of the model.
*/
private long bestBefore;
/**
* The JFileChooser.
*/
private JFileChooser fileChooser;
/**
* Sequential dispatcher for the lazy creation of icons.
*/
private SequentialDispatcher dispatcher = new SequentialDispatcher();
/**
* This hash map is used to determine the sequence and visibility of the
* items in the system list.
* HashMap
*/
private HashMap systemItemsMap = new HashMap();
/**
* The defaultUserItems are used when we fail to read the user items from
* the sidebarFile.
*/
private final static File[] defaultUserItems;
static {
if (QuaquaManager.isOSX()
|| QuaquaManager.getOS() == QuaquaManager.DARWIN) {
defaultUserItems = new File[]{
new File(QuaquaManager.getProperty("user.home"), "Desktop"),
new File(QuaquaManager.getProperty("user.home"), "Documents"),
new File(QuaquaManager.getProperty("user.home"))
};
} else if (QuaquaManager.getOS() == QuaquaManager.WINDOWS) {
defaultUserItems = new File[]{
new File(QuaquaManager.getProperty("user.home"), "Desktop"),
// Japanese ideographs for Desktop:
new File(QuaquaManager.getProperty("user.home"), "\u684c\u9762"),
new File(QuaquaManager.getProperty("user.home"), "My Documents"),
new File(QuaquaManager.getProperty("user.home"))
};
} else if (QuaquaManager.getOS() == QuaquaManager.LINUX) {
defaultUserItems = new File[]{
new File(QuaquaManager.getProperty("user.home"), "Desktop"),
new File("/media"),
new File(QuaquaManager.getProperty("user.home"), "Documents"),
new File(QuaquaManager.getProperty("user.home"))
};
} else {
defaultUserItems = new File[]{
new File(QuaquaManager.getProperty("user.home"))
};
}
}
/** Creates a new instance. */
public SidebarTreeModel(JFileChooser fileChooser, TreePath path, TreeModel model) {
super(new DefaultMutableTreeNode(), true);
this.fileChooser = fileChooser;
this.volumesPath = path;
this.model = model;
devicesNode = new DefaultMutableTreeNode(UIManager.getString("FileChooser.devices"));
devicesNode.setAllowsChildren(true);
placesNode = new DefaultMutableTreeNode(UIManager.getString("FileChooser.places"));
placesNode.setAllowsChildren(true);
DefaultMutableTreeNode r = (DefaultMutableTreeNode) getRoot();
r.add(devicesNode);
r.add(placesNode);
validate();
updateDevicesNode();
model.addTreeModelListener(this);
}
public void lazyValidate() {
// throw new UnsupportedOperationException("Not yet implemented");
}
/**
* Immediately validates the model.
*/
private void validate() {
// Prevent multiple invocations of this method by lazyValidate(),
// while we are validating;
bestBefore = Long.MAX_VALUE;
dispatcher.dispatch(
new Worker