本文整理汇总了Java中javax.swing.event.TreeExpansionEvent类的典型用法代码示例。如果您正苦于以下问题:Java TreeExpansionEvent类的具体用法?Java TreeExpansionEvent怎么用?Java TreeExpansionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TreeExpansionEvent类属于javax.swing.event包,在下文中一共展示了TreeExpansionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: treeExpansionVetoed
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
/** Messaged if the tree expansion event (for which we will have already
* constructed a TableModelEvent) was vetoed; disposes of the constructed
* TableModelEvent in that circumstance. */
@Override
public void treeExpansionVetoed(TreeExpansionEvent event, ExpandVetoException exception) {
assert SwingUtilities.isEventDispatchThread();
log ("treeExpansionVetoed", exception);
//Make sure the event that was vetoed is the one we're interested in
if (event == inProgressEvent) {
//If so, delete the expansion event we thought we were going
//to use in treeExpanded/treeCollapsed, so that it doesn't
//stick around forever holding references to objects from the
//model
pendingExpansionEvent = null;
inProgressEvent = null;
}
}
示例2: initExpandCollapseNotify
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
private Object initExpandCollapseNotify(TreeExpansionEvent event) {
Node node = Visualizer.findNode(event.getPath ().getLastPathComponent());
Object obj = node.getLookup().lookup(Object.class);
Object actOn;
node = node.getParentNode();
if (node == null) {
actOn = new Integer(0);
} else {
Children ch = node.getChildren();
if (ch instanceof TreeModelNode.TreeModelChildren) {
actOn = ((TreeModelNode.TreeModelChildren) ch).getTreeDepth();
} else {
actOn = ch;
}
}
Models.CompoundModel model = getModel();
if (model != null) {
DefaultTreeExpansionManager.get(model).setChildrenToActOn(actOn);
}
return obj;
}
示例3: treeExpanded
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
@Override
public void treeExpanded(TreeExpansionEvent evt) {
TreePath path = evt.getPath();
DirectoryNode node = (DirectoryNode) path
.getLastPathComponent();
if(!node.isLoaded()) {
expandNode(fileChooser, path);
} else {
// fixed #96954, to be able to add a new directory
// when the node has been already loaded
if(addNewDirectory) {
addNewDirectory(path);
addNewDirectory = false;
}
// Fix for IZ#123815 : Cannot refresh the tree content
refreshNode( path , node );
}
}
示例4: treeExpanded
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
@Override
public void treeExpanded(final TreeExpansionEvent event) {
final TreePath treePath = event.getPath();
final Object expandedTreePathObject = treePath.getLastPathComponent();
if (!(expandedTreePathObject instanceof TreeNode)) {
return;
}
final TreeNode expandedTreeNode = (TreeNode) expandedTreePathObject;
if (expandedTreeNode.getChildCount() == 1) {
final TreeNode descendantTreeNode = expandedTreeNode.getChildAt(0);
if (descendantTreeNode.isLeaf()) {
return;
}
final TreePath nextTreePath = treePath.pathByAddingChild(descendantTreeNode);
tree.expandPath(nextTreePath);
}
}
示例5: treeExpanded
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
public void treeExpanded(TreeExpansionEvent event) {
// ensure children gets expanded later
if (event.getPath() != null) {
Object lastElement = event.getPath().getLastPathComponent();
if (lastElement instanceof FileTreeNode && useNodeQueue) {
if (((FileTreeNode)lastElement).isLoaded()) {
for (Enumeration e = ((FileTreeNode)lastElement).children();
e.hasMoreElements();
) {
//Object node = enum.nextElement();
addToQueue((FileTreeNode)e.nextElement(), tree);
}
}
}
}
}
示例6: treeCollapsed
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
public void treeCollapsed(TreeExpansionEvent event)
{
Object source = event.getSource();
if(getEventSource() != null ||
trees == null ||
trees.isEmpty())
return;
setEventSource(event.getSource());
Iterator<AlignerTree> t = trees.iterator();
while(t.hasNext()) {
AlignerTree tree = t.next();
if(getEventSource() == tree)
continue;
if(tree.isSynchronized()) {
tree.collapsePath(event.getPath());
}
}
setEventSource(null);
}
示例7: treeExpanded
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
public void treeExpanded(TreeExpansionEvent event) {
final Object[] path = event.getPath().getPath();
if (path.length == 2) {
// top node has been expanded => watch disk recursively
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path[1];
Object userObject = node.getUserObject();
if (userObject instanceof FileNodeDescriptor) {
final VirtualFile file = ((FileNodeDescriptor)userObject).getElement().getFile();
if (file != null && file.isDirectory()) {
final String rootPath = file.getPath();
if (myRequests.get(rootPath) == null) {
final LocalFileSystem.WatchRequest watchRequest = LocalFileSystem.getInstance().addRootToWatch(rootPath, true);
myRequests.put(rootPath, watchRequest);
}
}
}
}
}
示例8: treeWillExpand
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
@Override
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
final InspectionTreeNode node = (InspectionTreeNode)event.getPath().getLastPathComponent();
final Object userObject = node.getUserObject();
//TODO: never re-sort
if (node.isValid() && !myExpandedUserObjects.contains(userObject)) {
sortChildren(node);
nodeStructureChanged(node);
}
myExpandedUserObjects.add(userObject);
// Smart expand
if (node.getChildCount() == 1) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
expandPath(new TreePath(node.getPath()));
}
});
}
}
示例9: doubleClickHandler
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
private void doubleClickHandler(ActionEvent e) throws ParseException {
logger.debug("-- double click --");
TreePath[] paths = tree.getSelectionPaths();
if (paths != null) {
for (TreePath path : paths) {
if (((TreeNode) path.getLastPathComponent()).getAllowsChildren()) {
if (doubleClickExpandEnabled) {
try {
treeWillExpand(new TreeExpansionEvent(this, path));
} catch (ExpandVetoException eve) {
logger.debug("Expand Veto: ", eve.getMessage());
}
}
} else {
doubleClickAction(path);
}
}
}
}
示例10: treeWillExpand
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
/**
* @see javax.swing.event.TreeWillExpandListener#treeWillExpand(javax.swing.event.TreeExpansionEvent)
*/
public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException {
logger.debug("Tree will expand " + e.getPath());
/*
* DefaultMutableTreeNode node = (DefaultMutableTreeNode)
* tree.getLastSelectedPathComponent(); if (node == null) { return; }
* logger.debug(""+node.getPath()[node.getLevel()]); // buttons
* disabling switch(node.getLevel()) { case LEVEL_FOLDERS: // disconnect
* childrens from the node Enumeration enumeration=node.children(); //
* delete nodes itself while (enumeration.hasMoreElements()) { Object
* object=enumeration.nextElement();
* treeNodeToResourceUriMap.remove(object);
* treeModel.removeNodeFromParent((MutableTreeNode)object); } // get
* folder URI logger.debug("Expanding folder:
* "+treeNodeToResourceUriMap.get(node)); FolderResource folder =new
* FolderResource(MindRaider.folderCustodian.get((String)treeNodeToResourceUriMap.get(node)));
* String[] notebookUris=folder.getNotebookUris(); if (notebookUris !=
* null) { for (int i= 0; i < notebookUris.length; i++) {
* NotebookResource notebook=new
* NotebookResource(MindRider.notebookCustodian.get(notebookUris[i]));
* addNotebookNode(node,notebook.resource.metadata.uri.toASCIIString(),notebook.getLabel()); } } }
*/
}
示例11: treeWillExpand
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
public void treeWillExpand(final TreeExpansionEvent event) throws ExpandVetoException {
final TreePath path = event.getPath();
final DefaultMutableTreeNode lastTreeNode = (DefaultMutableTreeNode) path.getLastPathComponent();
SwingWorker<?, ?> worker = null;
if (lastTreeNode.getChildCount() == 1) {
final DefaultMutableTreeNode firstChildNode = (DefaultMutableTreeNode) lastTreeNode.getChildAt(0);
if (firstChildNode.getUserObject() == LOADING_TABLES_STRING) {
// Load a schema's tables
worker = new LoadTablesSwingWorker(lastTreeNode);
} else if (firstChildNode.getUserObject() == LOADING_COLUMNS_STRING) {
// Load a table's columns
worker = new LoadColumnsSwingWorker(path, lastTreeNode);
}
}
if (worker != null) {
worker.execute();
}
}
示例12: treeExpanded
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
public void treeExpanded(TreeExpansionEvent event) {
System.out.println("Tree expanded");
TreePath path = event.getPath();
Object lastPathComponent = path.getLastPathComponent();
int children = tree.getModel().getChildCount(lastPathComponent);
if (children == 1) {
Object o = tree.getModel().getChild(lastPathComponent, 0);
if (o instanceof BugAspects) {
final TreePath p = path.pathByAddingChild(o);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
System.out.println("auto expanding " + p);
tree.expandPath(p);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
}
示例13: treeCollapsed
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
/**
* Method to handle tree collapse events. When a tree is collapsed, all name enumerations under
* the collapsed node are canceled.
*
* @param event TreeExpansionEvent object for the event
*
* @return void
*/
public void treeCollapsed(TreeExpansionEvent event) {
DefaultMutableTreeNode node = getTreeNode(event.getPath());
Name nodeName = getNameNode(node);
Log.fine("nodeName: " + nodeName.toString());
ContentName prefixToCancel = ContentName.ROOT;
if (nodeName.path == null) {
Log.fine("collapsed the tree at the root");
} else {
prefixToCancel = new ContentName(nodeName.path, nodeName.name);
Log.fine("tree collapsed at: " + prefixToCancel.toString());
}
Log.fine("cancelling prefix: " + prefixToCancel);
_nameEnumerator.cancelEnumerationsWithPrefix(prefixToCancel);
}
示例14: folderTreeExpanded
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
private void folderTreeExpanded(TreeExpansionEvent event)
{
TreePath path = event.getPath();
if(path.getLastPathComponent() instanceof LinkTreeNode && path.getLastPathComponent() != getBiblioNode()){
LinkTreeNode node = (LinkTreeNode)path.getLastPathComponent();
if(node.getParent() == null){
DefaultTreeModel model = (DefaultTreeModel)this.getModel();
Debug.println("Node hovering nowhere, try to find the right one..");
LinkTreeNode find = find((DefaultMutableTreeNode) model.getRoot(), node.getLinkDir());
if(find == null){
Debug.println("No node found...");
return;
}
node = find;
}
node.setHighPriority();
loadNode(node, false, false);
}
}
示例15: treeExpanded
import javax.swing.event.TreeExpansionEvent; //导入依赖的package包/类
public void treeExpanded(TreeExpansionEvent event) {
final DefaultMutableTreeNode node = getTreeNode(event.getPath());
final FileNode fnode = getFileNode(node);
Thread runner = new Thread() {
public void run() {
if (fnode != null && fnode.expand(node)) {
Runnable runnable = new Runnable() {
public void run() {
mModel.reload(node);
}
};
SwingUtilities.invokeLater(runnable);
}
}
};
runner.start();
}