本文整理汇总了Java中javax.swing.event.TreeExpansionEvent.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java TreeExpansionEvent.getPath方法的具体用法?Java TreeExpansionEvent.getPath怎么用?Java TreeExpansionEvent.getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.TreeExpansionEvent
的用法示例。
在下文中一共展示了TreeExpansionEvent.getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 );
}
}
示例2: 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);
}
}
示例3: 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);
}
}
}
}
}
示例4: 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();
}
}
示例5: 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();
}
}
});
}
}
}
示例6: 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);
}
}
示例7: treeWillExpand
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
@Override
public void treeWillExpand(TreeExpansionEvent event)
throws ExpandVetoException {
// prepare wait cursor and optionally show it
TreePath path = event.getPath();
prepareWaitCursor(DragDropUtilities.secureFindNode(path.getLastPathComponent()));
}
示例8: treeCollapsed
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
public void treeCollapsed(TreeExpansionEvent e) {
TreePath p = e.getPath();
int index = p.getPathCount() - 1;
Object collapsed = p.getLastPathComponent();
Object[] components = expanded.toArray();
for (Object component : components) {
TreePath epath = (TreePath) component;
if ((epath.getPathCount() > index) && (epath.getPathComponent(index).equals(collapsed))) {
expanded.remove(epath);
}
}
}
示例9: treeCollapsed
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
public void treeCollapsed(TreeExpansionEvent e) {
TreePath p = e.getPath();
int index = p.getPathCount() - 1;
Object collapsed = p.getLastPathComponent();
Object[] components = expanded.toArray();
for(int i=0; i<components.length; i++){
TreePath epath = (TreePath) components[i];
if( (epath.getPathCount() > index) && (epath.getPathComponent(index).equals(collapsed))){
expanded.remove(epath);
}
}
}
示例10: treeCollapsed
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
@Override
public void treeCollapsed(TreeExpansionEvent e) {
TreePath p = e.getPath();
int index = p.getPathCount() - 1;
Object collapsed = p.getLastPathComponent();
Object[] components = expanded.toArray();
for (int i = 0; i < components.length; i++) {
TreePath epath = (TreePath) components[i];
if ((epath.getPathCount() > index) && (epath.getPathComponent(index).equals(collapsed))) {
expanded.remove(epath);
}
}
}
示例11: treeWillCollapse
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
final TreePath path = event.getPath();
if (path == null) return;
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
if (node instanceof DirectoryNode) {
Set<FileNode> fileNodes = null;
for (int i = node.getChildCount() - 1; i >= 0; i--) {
final TreeNode childNode = node.getChildAt(i);
if (childNode instanceof ClassNode) {
final ClassNode classNode = (ClassNode)childNode;
final PsiFile containingFile = classNode.getContainingFile();
if (containingFile != null && containingFile.isValid()) {
if (fileNodes == null) {
fileNodes = new HashSet<FileNode>();
}
fileNodes.add(new FileNode(containingFile.getVirtualFile(), myProject, true));
}
node.remove(classNode);
}
}
if (fileNodes != null) {
for (FileNode fileNode : fileNodes) {
node.add(fileNode);
}
}
TreeUtil.sort(node, getNodeComparator());
final Object source = event.getSource();
if (source instanceof JTree) {
((DefaultTreeModel)((JTree)source).getModel()).reload(node);
}
}
}
示例12: treeExpanded
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
public void treeExpanded(final TreeExpansionEvent event) {
if (myTreeBuilder == null || !myTreeBuilder.isNodeBeingBuilt(event.getPath())) return;
TreePath path = event.getPath();
DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
if (node.getUserObject() instanceof FileNodeDescriptor) {
FileNodeDescriptor nodeDescriptor = (FileNodeDescriptor)node.getUserObject();
final FileElement fileDescriptor = nodeDescriptor.getElement();
final VirtualFile virtualFile = fileDescriptor.getFile();
if (virtualFile != null) {
if (!myEverExpanded.contains(virtualFile)) {
if (virtualFile instanceof NewVirtualFile) {
((NewVirtualFile)virtualFile).markDirty();
}
myEverExpanded.add(virtualFile);
}
AbstractTreeStructure treeStructure = myTreeBuilder.getTreeStructure();
final boolean async = treeStructure != null && treeStructure.isToBuildChildrenInBackground(virtualFile);
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_MODAL, new Runnable() {
@Override
public void run() {
if (virtualFile instanceof NewVirtualFile) {
RefreshQueue.getInstance().refresh(async, false, null, ModalityState.stateForComponent(myTree), virtualFile);
}
else {
virtualFile.refresh(async, false);
}
}
});
}
}
}
示例13: treeWillExpand
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
@Override
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
final TreePath path = event.getPath();
if (path == null) return;
final PackageDependenciesNode node = (PackageDependenciesNode)path.getLastPathComponent();
node.sortChildren();
((DefaultTreeModel)myTree.getModel()).reload(node);
}
示例14: setExpandedState
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
private void setExpandedState(TreeExpansionEvent event, boolean shouldExpand) {
final TreePath path = event.getPath();
final AbstractTreeUi ui = getUi();
final Object lastPathComponent = path.getLastPathComponent();
if (lastPathComponent != null) {
final Object element = ui.getElementFor(lastPathComponent);
if (element instanceof AntBuildFileBase) {
((AntBuildFileBase)element).setShouldExpand(shouldExpand);
}
}
}
示例15: treeExpanded
import javax.swing.event.TreeExpansionEvent; //导入方法依赖的package包/类
public void treeExpanded(TreeExpansionEvent evt)
{
// Get the node to be expanded.
final TreePath path = evt.getPath();
final Object parentObj = path.getLastPathComponent();
if (parentObj instanceof ObjectTreeNode)
{
startExpandingTree((ObjectTreeNode)parentObj, false, null, false);
_expandedPathNames.put(path.toString(), null);
}
}