/*
* 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.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
super(new BorderLayout());
// Create a tree that allows one selection at a time.
/******
// Listen for when the selection changes.
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
SourceTreeNode node = (SourceTreeNode)
(e.getPath().getLastPathComponent());
interpreter.executeCommand("view " + node.getRelativePath());
}
});
******/
public void mouseClicked(MouseEvent e) {
if(selRow != -1) {
if(e.getClickCount() == 1) {
// If user clicks on leaf, select it, and issue 'view' command.
}
}
}
}
};
// Create listener for source path changes.
//### remove listeners on exit!
}
}
}
}
}
try {
} catch (SecurityException e) {
return null;
}
}
private boolean isDirectory;
private boolean isExpanded;
boolean isDirectory) {
this.relativePath = relativePath;
this.isDirectory = isDirectory;
}
return name;
}
return relativePath;
}
private void expandIfNeeded() {
try {
if (!isExpanded && isDirectory) {
? files[i]
children[i] =
}
}
isExpanded = true;
} catch (SecurityException e) {
}
}
// -- interface TreeNode --
/*
* Returns the child <code>TreeNode</code> at index
* <code>childIndex</code>.
*/
return children[childIndex];
}
/**
* Returns the number of children <code>TreeNode</code>s the receiver
* contains.
*/
public int getChildCount() {
}
/**
* Returns the parent <code>TreeNode</code> of the receiver.
*/
return parent;
}
/**
* Returns the index of <code>node</code> in the receivers children.
* If the receiver does not contain <code>node</code>, -1 will be
* returned.
*/
return i;
}
}
return -1;
}
/**
* Returns true if the receiver allows children.
*/
public boolean getAllowsChildren() {
return isDirectory;
}
/**
* Returns true if the receiver is a leaf.
*/
public boolean isLeaf() {
return !isDirectory;
}
/**
* Returns the children of the receiver as an Enumeration.
*/
return new Enumeration() {
int i = 0;
public boolean hasMoreElements() {
}
throw new NoSuchElementException();
}
return children[i++];
}
};
}
}
}