javax.swing.event.TreeExpansionEvent源码实例Demo

类javax.swing.event.TreeExpansionEvent源码实例Demo

下面列出了javax.swing.event.TreeExpansionEvent 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo   文件: FileChooserDialogImpl.java
public void treeExpanded(TreeExpansionEvent event) {
  final Object[] path = event.getPath().getPath();
  if (path.length == 2 && path[1] instanceof DefaultMutableTreeNode) {
    // 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);
        }
      }
    }
  }
}
 
源代码2 项目: netbeans   文件: EventBroadcaster.java
/** 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;
    }
}
 
源代码3 项目: netbeans   文件: TreeModelRoot.java
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;
}
 
源代码4 项目: netbeans   文件: DirectoryChooserUI.java
@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 );
    }
}
 
源代码5 项目: Luyten   文件: Model.java
@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);
	}
}
 
源代码6 项目: consulo   文件: InspectionTree.java
@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()));
      }
    });
  }
}
 
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);
        }
      }
    }
  }
}
 
源代码8 项目: consulo   文件: ScopeTreeViewPanel.java
@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);
}
 
private void setExpandedState(TreeExpansionEvent event, boolean shouldExpand) {
//AS TODO: Make sure this code is really not needed (3/1/2017)
//            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 BaseNodeDescriptor) {
////          ((BaseNodeDescriptor)element).setShouldExpand(shouldExpand);
//                }
//            }
        }
 
源代码10 项目: java-swing-tips   文件: MainPanel.java
@Override public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException {
  TreePath path = e.getPath();
  Object o = path.getLastPathComponent();
  if (o instanceof DefaultMutableTreeNode) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) o;
    File file = (File) node.getUserObject();
    if (file.isFile()) {
      throw new ExpandVetoException(e, "Tree expansion cancelled");
    }
  }
}
 
源代码11 项目: stendhal   文件: FileTree.java
@Override
public void treeExpanded(final TreeExpansionEvent evt) {
	// The expanded path
	final TreePath path = evt.getPath();
	// The tree
	final JTree tree = (JTree) evt.getSource();

	// Get the last component of the path and
	// arrange to have it fully populated.
	final FileTreeNode node = (FileTreeNode) path.getLastPathComponent();
	if (node.populateDirectories(true)) {
		((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node);
	}
}
 
源代码12 项目: netbeans   文件: ResultsOutlineSupport.java
@Override
public void treeExpanded(TreeExpansionEvent event) {
    if (!expansionListenerEnabled) {
        return;
    }
    Object lpc = event.getPath().getLastPathComponent();
    Node node = Visualizer.findNode(lpc);
    if (node != null) {
        expandOnlyChilds(node);
    }
}
 
源代码13 项目: netbeans   文件: EventBroadcaster.java
/** Receives a TreeWillCollapse event and constructs a TableModelEvent
 * based on the pending changes while the model still reflects the unchanged
 * state */
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
    assert SwingUtilities.isEventDispatchThread();
    
    log ("treeWillCollapse", event);
    
    //Construct the TableModelEvent here, before data structures have
    //changed.  We will fire it from TreeCollapsed if the change is 
    //not vetoed.
    pendingExpansionEvent = translateEvent (event, false);
    log ("treeWillCollapse generated ", pendingExpansionEvent);
    inProgressEvent = event;
}
 
源代码14 项目: megan-ce   文件: InspectorWindow.java
/**
 * Invoked whenever a node in the tree is about to be collapsed.
 */
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
    if (inspectorWindow.isLocked()) {
        if (dir.getDocument().getProgressListener() != null)
            dir.getDocument().getProgressListener().setUserCancelled(true);
        throw new ExpandVetoException(event);
    }
}
 
源代码15 项目: netbeans   文件: EventBroadcaster.java
/** Updates the layout to mark the descendants of the events path as also
 * expanded if they were the last it was expanded, then fires a table change. */
@Override
public void treeExpanded(TreeExpansionEvent event) {
    assert SwingUtilities.isEventDispatchThread();
    
    log ("treeExpanded", event);
    
    //Mysterious how the event could be null, but JTree tests it
    //so we will too.
    if(event != null) {
        updateExpandedDescendants(event.getPath());
    }

    log ("about to fire", pendingExpansionEvent);
    
    //Now fire a change on the owning row so its display is updated (it
    //may have just become an expandable node)
    int row;
    if (event != null) {
        TreePath path = event.getPath();
        row = getLayout().getRowForPath(path);
    } else {
        row = -1;
    }
    TableModelEvent evt;
    if (row == -1) {
        evt = new TableModelEvent(getModel());
    } else {
        evt = new TableModelEvent(getModel(), row, row, 0, TableModelEvent.UPDATE);
    }
    fireTableChange(new TableModelEvent[] {evt, pendingExpansionEvent});
    
    pendingExpansionEvent = null;
    inProgressEvent = null;
}
 
源代码16 项目: netbeans   文件: TreePathSupport.java
private void fireTreeWillExpand (TreeExpansionEvent e, boolean expanded) throws ExpandVetoException {
    int size = weListeners.size();
    
    TreeWillExpandListener[] listeners = new TreeWillExpandListener[size];
    synchronized (this) {
        listeners = weListeners.toArray(listeners);
    }
    for (int i=0; i < listeners.length; i++) {
        if (expanded) {
            listeners[i].treeWillExpand(e);
        } else {
            listeners[i].treeWillCollapse(e);
        }
    }
}
 
源代码17 项目: IrScrutinizer   文件: TreeImporter.java
@Override
public void treeExpanded(TreeExpansionEvent event) {
    DefaultMutableTreeNode remote = (DefaultMutableTreeNode) event.getPath().getLastPathComponent();
    if (!Remote.class.isInstance(remote.getUserObject())) // Just to be on the safe side...
        return;

    for (Enumeration e = remote.children(); e.hasMoreElements();) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
        Command command = (Command) node.getUserObject();
    }
}
 
源代码18 项目: megan-ce   文件: InspectorWindow.java
/**
 * Invoked whenever a node in the tree is about to be expanded.
 */
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
    if (inspectorWindow.isLocked()) {
        if (dir.getDocument().getProgressListener() != null)
            dir.getDocument().getProgressListener().setUserCancelled(true);
        throw new ExpandVetoException(event);
    }

    final TreePath path = event.getPath();
    final NodeBase node = (NodeBase) path.getLastPathComponent();
    if (node.getChildCount() > 0) { // has already been expanded
        if (node.isCompleted())
            return;
        else {
            int result = JOptionPane.showConfirmDialog(inspectorWindow.getFrame(), "List of children incomplete, re-fetch?", "Re-fetch", JOptionPane.YES_NO_CANCEL_OPTION);
            if (result == JOptionPane.NO_OPTION)
                return;
            else if (result == JOptionPane.CANCEL_OPTION)
                throw new ExpandVetoException(event);
            else // remove all children to trigger re-download
                node.removeAllChildren();
        }
    }

    if (node instanceof TopLevelNode) {
        inspectorWindow.addChildren((TopLevelNode) node);
    } else if (node instanceof ReadHeadLineNode) {
        inspectorWindow.addChildren((ReadHeadLineNode) node, path.getPathComponent(1).toString());
    }
    if (node instanceof ReadDataHeadLineNode) {
        inspectorWindow.addChildren((ReadDataHeadLineNode) node);
    } else if (node instanceof MatchHeadLineNode) {
        inspectorWindow.addChildren((MatchHeadLineNode) node);
    }
}
 
源代码19 项目: netbeans   文件: Browser.java
@Override
public void treeExpanded(TreeExpansionEvent event) {
    Object obj = event.getPath().getLastPathComponent();
    if(obj == null) return;
    Node n = Visualizer.findNode(obj);
    if(n instanceof RepositoryPathNode) {
        RepositoryPathNode node = (RepositoryPathNode) n;
        node.expand();
    }
}
 
源代码20 项目: consulo   文件: FileSystemTreeImpl.java
@Override
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);
      }


      final boolean async = myTreeBuilder.isToBuildChildrenInBackground(virtualFile);
      if (virtualFile instanceof NewVirtualFile) {
        RefreshQueue.getInstance().refresh(async, false, null, ModalityState.stateForComponent(myTree), virtualFile);
      }
      else {
        virtualFile.refresh(async, false);
      }
    }
  }
}
 
源代码21 项目: pdfxtk   文件: Preferences.java
public void treeExpanded(TreeExpansionEvent event) {
     tree = (JTree)event.getSource();
     
     if(tree.getParent().getParent() instanceof JScrollPane)
SwingUtilities.invokeLater(this);
     
     state.add(event.getPath(), tree);
   }
 
源代码22 项目: netbeans   文件: TreeModelRoot.java
/**
  * Called whenever an item in the tree has been expanded.
  */
public void treeExpanded (TreeExpansionEvent event) {
    Models.CompoundModel model = getModel();
    if (model != null) {
        model.nodeExpanded (initExpandCollapseNotify(event));
    }
}
 
源代码23 项目: netbeans   文件: TreeModelRoot.java
/**
  * Called whenever an item in the tree has been collapsed.
  */
public void treeCollapsed (TreeExpansionEvent event) {
    Models.CompoundModel model = getModel();
    if (model != null) {
        model.nodeCollapsed (initExpandCollapseNotify(event));
    }
}
 
源代码24 项目: megan-ce   文件: InspectorWindow.java
/**
 * Called whenever an item in the tree has been collapsed.
 */
public void treeCollapsed(TreeExpansionEvent event) {
    final TreePath path = event.getPath();
    final NodeBase node = (NodeBase) path.getLastPathComponent();
    if (!inspectorWindow.getClassification2RootNode().containsValue(node)) {
        //node.removeAllChildren();
        DefaultTreeModel model = (DefaultTreeModel) inspectorWindow.dataTree.getModel();
        model.nodeStructureChanged(node);
    }
    inspectorWindow.updateView(Director.ALL);
}
 
源代码25 项目: nextreports-designer   文件: DBBrowserTree.java
public void treeExpanded(TreeExpansionEvent ev) {
	final TreePath path = ev.getPath();
	final Object parentObj = path.getLastPathComponent();
	if (parentObj instanceof DBBrowserNode) {
		startExpandingTree((DBBrowserNode) parentObj, false, null);
		// expandedPathNames.put(path.toString(), null);
	}
}
 
源代码26 项目: flutter-intellij   文件: InspectorPanel.java
@Override
public void treeExpanded(TreeExpansionEvent event) {
  final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)event.getPath().getLastPathComponent();
  maybeLoadChildren(treeNode);

  if (!programaticExpansionInProgress) {
    lastExpanded = treeNode;
    animateTo(treeNode);
  }
}
 
源代码27 项目: consulo   文件: FileChooserDialogImpl.java
public void treeCollapsed(TreeExpansionEvent event) {
}
 
源代码28 项目: pcgen   文件: CompanionInfoTab.java
@Override
public void treeCollapsed(TreeExpansionEvent event)
{
	saveExpansionState();
}
 
源代码29 项目: MogwaiERDesignerNG   文件: OutlineComponent.java
@Override
public void treeExpanded(TreeExpansionEvent aEvent) {
	DefaultMutableTreeNode theNode = (DefaultMutableTreeNode) aEvent
			.getPath().getLastPathComponent();
	expandedUserObjects.add(theNode.getUserObject());
}
 
源代码30 项目: IrScrutinizer   文件: TreeImporter.java
@Override
public void treeCollapsed(TreeExpansionEvent event) {
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法