Java 类javax.swing.event.TreeModelEvent 实例源码

项目:incubator-netbeans    文件:TreeView.java   
@Override
public void treeNodesRemoved(TreeModelEvent e) {
    // called to removed from JTree.expandedState
    super.treeNodesRemoved(e);

    boolean wasSelected = removedNodeWasSelected;
    removedNodeWasSelected = false;

    // part of bugfix #37279, if DnD is active then is useless select a nearby node
    if (ExplorerDnDManager.getDefault().isDnDActive()) {
        return;
    }
    if (wasSelected && tree.getSelectionCount() == 0) {
        TreePath path = findSiblingTreePath(e.getTreePath(), e.getChildIndices());

        // bugfix #39564, don't select again the same object
        if ((path == null) || e.getChildIndices().length == 0) {
            return;
        } else if (path.getPathCount() > 0) {
            tree.setSelectionPath(path);
        }
    }
}
项目:incubator-netbeans    文件:EventBroadcaster.java   
/** Process a structural change event from the user-supplied tree model.
 * This will result in a generic "something changed" 
 * TableModelEvent being fired.  */
@Override
public void treeStructureChanged(TreeModelEvent e) {
    assert SwingUtilities.isEventDispatchThread();

    getTreePathSupport().treeStructureChanged(e);
    fireTreeChange (translateEvent(e), STRUCTURE_CHANGED);

    if (!getLayout().isExpanded(e.getTreePath())) {
        // Do not care about structural changes in collapsed nodes.
        // But the node's leaf property could change...
        treeNodesChanged(e);
        return ;
    }

    getTreePathSupport().clear();

    //We will just fire a "Something happened. Go figure out what." event.
    fireTableChange (new TableModelEvent (getModel()));
}
项目:incubator-netbeans    文件:EventBroadcaster.java   
/**
 * Compute real table row indices of nodes that are affected by the event.
 *
 * @param e Event description.
 * @return Indices of rows in the table where the nodes (affected by the
 * event) are displayed, or null if they are not available.
 */
private int[] computeRowIndices(TreeModelEvent e) {
    int[] rowIndices;
    int parentRow = getLayout().getRowForPath(e.getTreePath());
    if (e.getChildren() != null) {
        rowIndices = new int[e.getChildren().length];
        for (int i = 0; i < e.getChildren().length; i++) {
            TreePath childPath =
                    e.getTreePath().pathByAddingChild(e.getChildren()[i]);
            int index = getLayout().getRowForPath(childPath);
            rowIndices[i] = index < 0
                    // child node is not shown yet, compute child row from
                    // parent row and index of the child
                    ? parentRow + e.getChildIndices()[i] + 1
                    : index;
        }
    } else {
        rowIndices = null;
    }
    return rowIndices;
}
项目:incubator-netbeans    文件:Outline.java   
/** Set whether or not the root is visible */
public void setRootVisible (boolean val) {
    if (getOutlineModel() == null) {
        cachedRootVisible = val ? Boolean.TRUE : Boolean.FALSE;
    }
    if (val != isRootVisible()) {
        getLayoutCache().setRootVisible(val);
        if( getLayoutCache().getRowCount() > 0 ) {
            TreePath rootPath = getLayoutCache().getPathForRow(0);
            if( null != rootPath )
                getLayoutCache().treeStructureChanged(new TreeModelEvent(this, rootPath));
        }
        sortAndFilter();
        firePropertyChange("rootVisible", !val, val); //NOI18N
    }
}
项目:incubator-netbeans    文件:ComponentsSelectionPanel.java   
public void valueForPathChanged(final TreePath path, final Object value) {
    if (path.getLastPathComponent() instanceof Product) {
        final Product product = (Product) path.getLastPathComponent();

        switch (product.getStatus()) {
        case NOT_INSTALLED:
            product.setStatus(Status.TO_BE_INSTALLED);
            updateRequirements(product);
            break;
        case TO_BE_INSTALLED:
            product.setStatus(Status.NOT_INSTALLED);
            break;
        case INSTALLED:
            product.setStatus(Status.TO_BE_UNINSTALLED);
            break;
        case TO_BE_UNINSTALLED:
            product.setStatus(Status.INSTALLED);
            break;
        }
    }

    final TreeModelListener[] clone;
    synchronized (listeners) {
        clone = listeners.toArray(new TreeModelListener[0]);
    }

    final TreeModelEvent event = new TreeModelEvent(this, path);
    for (TreeModelListener listener: clone) {
        listener.treeNodesChanged(event);
    }
}
项目:incubator-netbeans    文件:LanguagesNavigatorModel.java   
private void fire () {
    TreeModelListener[] listeners = listenerList.getListeners (TreeModelListener.class);
    if (listeners.length == 0) return;
    TreeModelEvent e = new TreeModelEvent (this, new Object[] {getRoot ()});
    for (int i = 0; i < listeners.length; i++)
        listeners [i].treeStructureChanged (e);
}
项目:incubator-netbeans    文件:LanguagesNavigatorModel.java   
private void fireRemove(ASTNavigatorNode node, int[] indices, ASTNavigatorNode[] children,
        LinkedList<ASTNavigatorNode> nodePath) {
    TreeModelListener[] listeners = listenerList.getListeners (TreeModelListener.class);
    if (listeners.length == 0) return;
    TreePath path = new TreePath(nodePath.toArray());
    TreeModelEvent e = new TreeModelEvent (this, path, indices, children);
    for (int i = 0; i < listeners.length; i++)
        listeners [i].treeNodesRemoved (e);
}
项目:incubator-netbeans    文件:TreeView.java   
@Override
public void treeStructureChanged(TreeModelEvent e) {
    // Remember selections and expansions
    TreePath[] selectionPaths = getSelectionPaths();
    java.util.Enumeration expanded = getExpandedDescendants(e.getTreePath());

    // Restructure the node
    super.treeStructureChanged(e);

    // Expand previously expanded paths
    if (expanded != null) {
        while (expanded.hasMoreElements()) {
            expandPath((TreePath) expanded.nextElement());
        }
    }

    // Select previously selected paths
    if ((selectionPaths != null) && (selectionPaths.length > 0)) {
        boolean wasSelected = isPathSelected(selectionPaths[0]);

        setSelectionPaths(selectionPaths);

        if (!wasSelected) {
            // do not scroll if the first selection path survived structure change
            scrollPathToVisible(selectionPaths[0]);
        }
    }
}
项目:incubator-netbeans    文件:NodeTreeModel.java   
void nodesWereInsertedInternal(final VisualizerEvent ev) {
    if (listenerList == null) {
        return;
    }

    TreeNode node = ev.getVisualizer();
    Object[] path = getPathToRoot(node);

    Object[] listeners = listenerList.getListenerList();
    TreeModelEvent e = null;
    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length-2; i>=0; i-=2) {
        if (listeners[i]==TreeModelListener.class) {
            // Lazily create the event:
            if (e == null) {
                e = new TreeModelEventImpl(this, path, ev);
            }
            try {
                ((TreeModelListener)listeners[i+1]).treeNodesInserted(e);
            } catch (IndexOutOfBoundsException ex) {
                LOG.log(Level.WARNING, "Visualizer: {0}", node);
                Node n = Visualizer.findNode(node);
                LOG.log(Level.WARNING, "Node: {0}", n);
                if (n != null) {
                    LOG.log(Level.WARNING, "  # children: {0}", n.getChildren().getNodesCount());
                    LOG.log(Level.WARNING, "  children: {0}", n.getChildren().getClass());
                }
                LOG.log(Level.WARNING, "Path: {0}", Arrays.toString(path));
                LOG.log(Level.WARNING, "ev.getArray: {0}", Arrays.toString(ev.getArray()));
                LOG.log(Level.WARNING, "ev.getSnapshot: {0}", ev.getSnapshot());
                throw ex;
            }
        }
    }
}
项目:incubator-netbeans    文件:EventBroadcaster.java   
/** Fire the passed TreeModelEvent of the specified type to all
 * registered TreeModelListeners.  The passed event should already have
 * its source set to be the model. */
private synchronized void fireTreeChange (TreeModelEvent e, int type) {
    //Event may be null for offscreen info, etc.
    if (e == null) {
        return;
    }
    assert (e.getSource() == getModel());

    TreeModelListener[] listeners;
    synchronized (this) {
        listeners = new TreeModelListener[treeListeners.size()];
        listeners = treeListeners.toArray(listeners);
    }

    log ("fireTreeChange-" + types[type], e);

    //Now refire it to any listeners
    for (int i=0; i < listeners.length; i++) {
        switch (type) {
            case NODES_CHANGED :
                listeners[i].treeNodesChanged(e);
                break;
            case NODES_INSERTED :
                listeners[i].treeNodesInserted(e);
                break;
            case NODES_REMOVED :
                listeners[i].treeNodesRemoved(e);
                break;
            case STRUCTURE_CHANGED :
                listeners[i].treeStructureChanged(e);
                break;
            default :
                assert false;
        }
    }
}
项目:incubator-netbeans    文件:EventBroadcaster.java   
/** Creates an identical TreeModelEvent with the model we are proxying
 * as the event source */
private TreeModelEvent translateEvent (TreeModelEvent e) {
    //Create a new TreeModelEvent with us as the source
    TreeModelEvent nue = new TreeModelEvent (getModel(), e.getPath(), 
        e.getChildIndices(), e.getChildren());
    return nue;
}
项目:incubator-netbeans    文件:LookTreeModel.java   
void fireDisplayChange(LookTreeNode source) {
    if (listeners.isEmpty()) {
        return;
    }
    LookTreeNode parent = source.getParent();
    TreePath path = findPath(parent != null ? parent : source);
    int[] childIndices = parent != null ? new int[] {getIndexOfChild(parent, source)} : null;
    Object[] children = parent != null ? new Object[] {source} : null;
    TreeModelEvent ev = new TreeModelEvent(this, path, childIndices, children);
    for (TreeModelListener l : listeners) {
        l.treeNodesChanged(ev);
    }
}
项目:incubator-netbeans    文件:LookTreeModel.java   
void fireChildrenChange(LookTreeNode source) {
    logger.log(Level.FINER, "fireChildrenChange: {0}", source);
    if (listeners.isEmpty()) {
        return;
    }
    // XXX this is crude, could try to actually compute added/removed children...
    TreePath path = (source == root) ? null : findPath(source.getParent());
    TreeModelEvent ev = new TreeModelEvent(this, path, null, null);
    for (TreeModelListener l : listeners) {
        logger.log(Level.FINER, "firing: {0} to {1}", new Object[] {ev, l});
        l.treeStructureChanged(ev);
    }
}
项目:AgentWorkbench    文件:ThreadMonitorDetailTreeTab.java   
@Override
public void treeStructureChanged(TreeModelEvent e) {    
    threadTree.expandRow(0);
    threadTree.expandRow(1);
    threadTree.expandRow(2);
    threadTree.expandRow(3);
}
项目:rapidminer    文件:RepositoryTreeModel.java   
private TreeModelEvent makeChangeEvent(Entry entry) {
    TreePath path = getPathTo(entry.getContainingFolder());
    int index;
    if (entry instanceof Repository) {
        index = RepositoryManager.getInstance(null).getRepositories().indexOf(entry);
    } else {
        index = getIndexOfChild(entry.getContainingFolder(), entry);
    }
    return new TreeModelEvent(RepositoryTreeModel.this, path, new int[] { index }, new Object[] { entry });
}
项目:rapidminer    文件:RepositoryTreeModel.java   
@Override
public void entryAdded(final Entry newEntry, Folder parent) {
    SwingTools.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            final TreeModelEvent e = makeChangeEvent(newEntry);
            for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
                l.treeNodesInserted(e);
            }
        }
    });
}
项目:rapidminer    文件:RepositoryTreeModel.java   
@Override
public void entryRemoved(final Entry removedEntry, final Folder parent, final int index) {

    // Save path of parent
    final RepositoryTreeUtil treeUtil = new RepositoryTreeUtil();
    TreePath parentPath = getPathTo(parent);
    treeUtil.saveSelectionPath(parentPath);

    // Fire event
    final TreeModelEvent e = new TreeModelEvent(RepositoryTreeModel.this, parentPath, new int[] { index },
            new Object[] { removedEntry });
    SwingTools.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
                l.treeNodesRemoved(e);
            }

        }
    });

    // Restore path of parent
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            treeUtil.restoreSelectionPaths(parentTree);
        }
    });
}
项目:rapidminer    文件:RepositoryTreeModel.java   
@Override
public void entryChanged(final Entry entry) {
    final TreeModelEvent e = makeChangeEvent(entry);
    SwingTools.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
                l.treeNodesChanged(e);
            }
        }
    });
}
项目:rapidminer    文件:RepositoryTreeModel.java   
private void refresh() {
    for (Repository repo : root.getRepositories()) {
        final TreeModelEvent e = makeChangeEvent(repo);
        SwingTools.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
                    l.treeStructureChanged(e);
                }
            }
        });
    }
}
项目:rapidminer    文件:ProcessTreeModel.java   
private void fireTreeNodesChanged(Operator operator) {
    TreeModelEvent e = makeChangeEvent(operator);
    if (e.getChildIndices() != null && e.getChildIndices()[0] != -1) { // otherwise the
        // operator is in
        // the state of
        // being removed and
        // has
        // triggered an
        // update while
        // dying.
        for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) {
            l.treeNodesChanged(e);
        }
    }
}
项目:rapidminer    文件:ProcessTreeModel.java   
private void fireTreeNodesRemoved(Operator operator, int oldIndex) {
    TreePath path = getPathTo(operator).getParentPath();
    TreeModelEvent e = new TreeModelEvent(this, path, new int[] { oldIndex }, new Object[] { operator });
    for (TreeModelListener l : listenerList.getListeners(TreeModelListener.class)) {
        l.treeNodesRemoved(e);
    }
}
项目:marathonv5    文件:GenealogyModel.java   
/**
 * The only event raised by this model is TreeStructureChanged with the root
 * as path, i.e. the whole tree has changed.
 */
protected void fireTreeStructureChanged(Person oldRoot) {
    int len = treeModelListeners.size();
    TreeModelEvent e = new TreeModelEvent(this, new Object[] { oldRoot });
    for (TreeModelListener tml : treeModelListeners) {
        tml.treeStructureChanged(e);
    }
}
项目:VASSAL-src    文件:Inventory.java   
public void fireNodesRemoved(Object[] path, int[] childIndices,
                             Object[] children) {
  TreeModelEvent e = new TreeModelEvent(this, path, childIndices, children);
  for (TreeModelListener l : treeModelListeners) {
    l.treeNodesRemoved(e);
  }
}
项目:truevfs    文件:TFileTreeModel.java   
/**
 * Updates the given node in the tree.
 * This method calls {@link TreeModelListener#treeNodesChanged(TreeModelEvent)}
 * on all listeners of this {@code TreeModel}.
 */
public void nodeChanged(final TFile node) {
    final TFile parent = node.getParentFile();
    final int index = getIndexOfChild(parent, node); // old index
    if (index == -1)
        return;
    fireTreeNodesChanged(new TreeModelEvent(
            this, newTreePath(parent),
            new int[] { index }, new TFile[] { node }));
}
项目:truevfs    文件:TFileTreeModel.java   
/**
 * Removes the given node from the tree.
 * This method calls {@link TreeModelListener#treeNodesRemoved(TreeModelEvent)}
 * on all listeners of this {@code TreeModel}.
 */
public void nodeRemoved(final TFile node) {
    final TFile parent = node.getParentFile();
    final int index = getIndexOfChild(parent, node); // old index
    if (index == -1)
        return;
    forget(node, true);
    forget(parent, false);
    // Fill cache again so that subsequent removes don't suffer a cache miss.
    // Otherwise, the display wouldn't mirror the cache anymore.
    getChildren(parent);
    fireTreeNodesRemoved(new TreeModelEvent(
            this, newTreePath(parent),
            new int[] { index }, new TFile[] { node }));
}
项目:truevfs    文件:TFileTreeModel.java   
/**
 * Refreshes the tree structure for the entire tree.
 * This method calls {@link TreeModelListener#treeStructureChanged(TreeModelEvent)}
 * on all listeners of this {@code TreeModel}.
 */
public void refresh() {
    cache.clear();
    if (root != null)
        fireTreeStructureChanged(
                new TreeModelEvent(this, newTreePath(root), null, null));
}
项目:truevfs    文件:TFileTreeModel.java   
/**
 * This method calls {@link TreeModelListener#treeStructureChanged(TreeModelEvent)}
 * on all listeners of this {@code TreeModel}.
 * May be used to tell the listeners about a change in the file system.
 */
// TODO: Declare this package private.
protected void fireTreeNodesChanged(final TreeModelEvent evt) {
    final EventListener[] l = listeners.getListeners(TreeModelListener.class);
    for (int i = 0, ll = l.length; i < ll; i++)
        ((TreeModelListener) l[i]).treeNodesChanged(evt);
}
项目:truevfs    文件:TFileTreeModel.java   
/**
 * This method calls {@link TreeModelListener#treeStructureChanged(TreeModelEvent)}
 * on all listeners of this {@code TreeModel}.
 * May be used to tell the listeners about a change in the file system.
 */
// TODO: Declare this package private.
protected void fireTreeNodesInserted(final TreeModelEvent evt) {
    final EventListener[] l = listeners.getListeners(TreeModelListener.class);
    for (int i = 0, ll = l.length; i < ll; i++)
        ((TreeModelListener) l[i]).treeNodesInserted(evt);
}
项目:truevfs    文件:TFileTreeModel.java   
/**
 * This method calls {@link TreeModelListener#treeStructureChanged(TreeModelEvent)}
 * on all listeners of this {@code TreeModel}.
 * May be used to tell the listeners about a change in the file system.
 */
// TODO: Declare this package private.
protected void fireTreeNodesRemoved(final TreeModelEvent evt) {
    final EventListener[] l = listeners.getListeners(TreeModelListener.class);
    for (int i = 0, ll = l.length; i < ll; i++)
        ((TreeModelListener) l[i]).treeNodesRemoved(evt);
}
项目:jdk8u-jdk    文件:FixedHeightLayoutCache.java   
/**
 * <p>Invoked after nodes have been removed from the tree.  Note that
 * if a subtree is removed from the tree, this method may only be
 * invoked once for the root of the removed subtree, not once for
 * each individual set of siblings removed.</p>
 *
 * <p>e.path() returns the former parent of the deleted nodes.</p>
 *
 * <p>e.childIndices() returns the indices the nodes had before they were deleted in ascending order.</p>
 */
public void treeNodesRemoved(TreeModelEvent e) {
    if(e != null) {
        int                  changedIndexs[];
        int                  maxCounter;
        TreePath             parentPath = SwingUtilities2.getTreePath(e, getModel());
        FHTreeStateNode      changedParentNode = getNodeForPath
                                   (parentPath, false, false);

        changedIndexs = e.getChildIndices();
        // PENDING(scott): make sure that changedIndexs are sorted in
        // ascending order.
        if(changedParentNode != null && changedIndexs != null &&
           (maxCounter = changedIndexs.length) > 0) {
            Object[]           children = e.getChildren();
            boolean            isVisible =
                (changedParentNode.isVisible() &&
                 changedParentNode.isExpanded());

            for(int counter = maxCounter - 1; counter >= 0; counter--) {
                changedParentNode.removeChildAtModelIndex
                                 (changedIndexs[counter], isVisible);
            }
            if(isVisible) {
                if(treeSelectionModel != null)
                    treeSelectionModel.resetRowSelection();
                if (treeModel.getChildCount(changedParentNode.
                                            getUserObject()) == 0 &&
                              changedParentNode.isLeaf()) {
                    // Node has become a leaf, collapse it.
                    changedParentNode.collapse(false);
                }
                visibleNodesChanged();
            }
            else if(changedParentNode.isVisible())
                visibleNodesChanged();
        }
    }
}
项目:Equella    文件:PowerSearchModel.java   
@Override
public void treeNodesInserted(TreeModelEvent e)
{
    int[] indices = e.getChildIndices();
    Arrays.sort(indices);
    fireTableRowsInserted(indices[0], indices[indices.length - 1]);
}
项目:Equella    文件:PowerSearchModel.java   
@Override
public void treeNodesRemoved(TreeModelEvent e)
{
    int[] indices = e.getChildIndices();
    Arrays.sort(indices);
    fireTableRowsDeleted(indices[0], indices[indices.length - 1]);
}
项目:Logisim    文件:ProjectExplorer.java   
void fireStructureChanged() {
    TreeModelEvent e = new TreeModelEvent(ProjectExplorer.this, new Object[] { model.getRoot() });
    for (TreeModelListener l : listeners) {
        l.treeStructureChanged(e);
    }
    ProjectExplorer.this.repaint();
}
项目:Equella    文件:SchemaTree.java   
@Override
public void treeNodesInserted(TreeModelEvent e)
{
    if( e.getChildren().length >= 1 )
    {
        expandToNode((SchemaNode) e.getChildren()[0]);
    }
}
项目:Equella    文件:SchemaTree.java   
@Override
public void treeStructureChanged(TreeModelEvent e)
{
    if( model.getRoot().getChildCount() > 0 )
    {
        expandToNode((SchemaNode) model.getRoot().getChildAt(0));
    }
}
项目:Equella    文件:WizardModel.java   
/**
 * Notifies all listeners that have registered interest for notification on
 * this event type. The event instance is lazily created using the
 * parameters passed into the fire method.
 * 
 * @param source the node being changed
 * @param path the path to the root node
 * @param childIndices the indices of the changed elements
 * @param children the changed elements
 * @see EventListenerList
 */
private void fireTreeNodesInserted(TreePath path, int[] childIndices, Object[] children)
{
    TreeModelListener[] listeners = listenerList.getListeners(TreeModelListener.class);
    if( listeners != null && listeners.length > 0 )
    {
        TreeModelEvent e = new TreeModelEvent(this, path, childIndices, children);
        for( TreeModelListener listener : listeners )
        {
            listener.treeNodesInserted(e);
        }
    }
}
项目:Equella    文件:WizardModel.java   
/**
 * Notifies all listeners that have registered interest for notification on
 * this event type. The event instance is lazily created using the
 * parameters passed into the fire method.
 * 
 * @param path the path to the root node
 * @param childIndices the indices of the changed elements
 * @param children the changed elements
 * @see EventListenerList
 */
private void fireTreeNodesRemoved(TreePath path, int[] childIndices, Object[] children)
{
    TreeModelListener[] listeners = listenerList.getListeners(TreeModelListener.class);
    if( listeners != null && listeners.length > 0 )
    {
        TreeModelEvent e = new TreeModelEvent(this, path, childIndices, children);
        for( TreeModelListener listener : listeners )
        {
            listener.treeNodesRemoved(e);
        }
    }
}
项目:OpenJSharp    文件:FixedHeightLayoutCache.java   
/**
 * <p>Invoked after a node (or a set of siblings) has changed in some
 * way. The node(s) have not changed locations in the tree or
 * altered their children arrays, but other attributes have
 * changed and may affect presentation. Example: the name of a
 * file has changed, but it is in the same location in the file
 * system.</p>
 *
 * <p>e.path() returns the path the parent of the changed node(s).</p>
 *
 * <p>e.childIndices() returns the index(es) of the changed node(s).</p>
 */
public void treeNodesChanged(TreeModelEvent e) {
    if(e != null) {
        int                 changedIndexs[];
        FHTreeStateNode     changedParent = getNodeForPath
                              (SwingUtilities2.getTreePath(e, getModel()), false, false);
        int                 maxCounter;

        changedIndexs = e.getChildIndices();
        /* Only need to update the children if the node has been
           expanded once. */
        // PENDING(scott): make sure childIndexs is sorted!
        if (changedParent != null) {
            if (changedIndexs != null &&
                (maxCounter = changedIndexs.length) > 0) {
                Object       parentValue = changedParent.getUserObject();

                for(int counter = 0; counter < maxCounter; counter++) {
                    FHTreeStateNode    child = changedParent.
                             getChildAtModelIndex(changedIndexs[counter]);

                    if(child != null) {
                        child.setUserObject(treeModel.getChild(parentValue,
                                                 changedIndexs[counter]));
                    }
                }
                if(changedParent.isVisible() && changedParent.isExpanded())
                    visibleNodesChanged();
            }
            // Null for root indicates it changed.
            else if (changedParent == root && changedParent.isVisible() &&
                     changedParent.isExpanded()) {
                visibleNodesChanged();
            }
        }
    }
}
项目:OpenJSharp    文件:FixedHeightLayoutCache.java   
/**
 * <p>Invoked after nodes have been inserted into the tree.</p>
 *
 * <p>e.path() returns the parent of the new nodes
 * <p>e.childIndices() returns the indices of the new nodes in
 * ascending order.
 */
public void treeNodesInserted(TreeModelEvent e) {
    if(e != null) {
        int                 changedIndexs[];
        FHTreeStateNode     changedParent = getNodeForPath
                              (SwingUtilities2.getTreePath(e, getModel()), false, false);
        int                 maxCounter;

        changedIndexs = e.getChildIndices();
        /* Only need to update the children if the node has been
           expanded once. */
        // PENDING(scott): make sure childIndexs is sorted!
        if(changedParent != null && changedIndexs != null &&
           (maxCounter = changedIndexs.length) > 0) {
            boolean          isVisible =
                (changedParent.isVisible() &&
                 changedParent.isExpanded());

            for(int counter = 0; counter < maxCounter; counter++) {
                changedParent.childInsertedAtModelIndex
                    (changedIndexs[counter], isVisible);
            }
            if(isVisible && treeSelectionModel != null)
                treeSelectionModel.resetRowSelection();
            if(changedParent.isVisible())
                this.visibleNodesChanged();
        }
    }
}
项目:OpenJSharp    文件:FixedHeightLayoutCache.java   
/**
 * <p>Invoked after nodes have been removed from the tree.  Note that
 * if a subtree is removed from the tree, this method may only be
 * invoked once for the root of the removed subtree, not once for
 * each individual set of siblings removed.</p>
 *
 * <p>e.path() returns the former parent of the deleted nodes.</p>
 *
 * <p>e.childIndices() returns the indices the nodes had before they were deleted in ascending order.</p>
 */
public void treeNodesRemoved(TreeModelEvent e) {
    if(e != null) {
        int                  changedIndexs[];
        int                  maxCounter;
        TreePath             parentPath = SwingUtilities2.getTreePath(e, getModel());
        FHTreeStateNode      changedParentNode = getNodeForPath
                                   (parentPath, false, false);

        changedIndexs = e.getChildIndices();
        // PENDING(scott): make sure that changedIndexs are sorted in
        // ascending order.
        if(changedParentNode != null && changedIndexs != null &&
           (maxCounter = changedIndexs.length) > 0) {
            Object[]           children = e.getChildren();
            boolean            isVisible =
                (changedParentNode.isVisible() &&
                 changedParentNode.isExpanded());

            for(int counter = maxCounter - 1; counter >= 0; counter--) {
                changedParentNode.removeChildAtModelIndex
                                 (changedIndexs[counter], isVisible);
            }
            if(isVisible) {
                if(treeSelectionModel != null)
                    treeSelectionModel.resetRowSelection();
                if (treeModel.getChildCount(changedParentNode.
                                            getUserObject()) == 0 &&
                              changedParentNode.isLeaf()) {
                    // Node has become a leaf, collapse it.
                    changedParentNode.collapse(false);
                }
                visibleNodesChanged();
            }
            else if(changedParentNode.isVisible())
                visibleNodesChanged();
        }
    }
}