当前位置: 首页>>代码示例>>Java>>正文


Java TreeModelEvent.getChildIndices方法代码示例

本文整理汇总了Java中javax.swing.event.TreeModelEvent.getChildIndices方法的典型用法代码示例。如果您正苦于以下问题:Java TreeModelEvent.getChildIndices方法的具体用法?Java TreeModelEvent.getChildIndices怎么用?Java TreeModelEvent.getChildIndices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.event.TreeModelEvent的用法示例。


在下文中一共展示了TreeModelEvent.getChildIndices方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeRowIndices

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:EventBroadcaster.java

示例2: treeNodesRemoved

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/**
 * <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();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:49,代码来源:FixedHeightLayoutCache.java

示例3: treeNodesChanged

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/**
 * <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();
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:49,代码来源:FixedHeightLayoutCache.java

示例4: treeNodesInserted

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
@Override
public void treeNodesInserted(TreeModelEvent e)
{
	int[] indices = e.getChildIndices();
	Arrays.sort(indices);
	fireTableRowsInserted(indices[0], indices[indices.length - 1]);
}
 
开发者ID:equella,项目名称:Equella,代码行数:8,代码来源:PowerSearchModel.java

示例5: treeNodesRemoved

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
@Override
public void treeNodesRemoved(TreeModelEvent e)
{
	int[] indices = e.getChildIndices();
	Arrays.sort(indices);
	fireTableRowsDeleted(indices[0], indices[indices.length - 1]);
}
 
开发者ID:equella,项目名称:Equella,代码行数:8,代码来源:PowerSearchModel.java

示例6: treeNodesChanged

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
@Override
public void treeNodesChanged(TreeModelEvent e)
{
	int[] indices = e.getChildIndices();
	Arrays.sort(indices);
	fireTableRowsUpdated(indices[0], indices[indices.length - 1]);
}
 
开发者ID:equella,项目名称:Equella,代码行数:8,代码来源:PowerSearchModel.java

示例7: treeNodesInserted

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/**
 * <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();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:FixedHeightLayoutCache.java

示例8: treeNodesInserted

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
public void treeNodesInserted(TreeModelEvent treeModelEvent) {
    cnt++;
    indexes = treeModelEvent.getChildIndices();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ContextTreeViewModelTest.java

示例9: treeNodesRemoved

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
public void treeNodesRemoved(TreeModelEvent treeModelEvent) {
    cnt++;
    indexes = treeModelEvent.getChildIndices();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ContextTreeViewModelTest.java

示例10: treeNodesInserted

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/**
 * Invoked after nodes have been inserted into the tree.
 *
 * <p><code>e.path</code> returns the parent of the new nodes.
 * <p><code>e.childIndices</code> returns the indices of the new nodes in
 * ascending order.
 *
 * @param e the <code>TreeModelEvent</code> of interest
 */
public void treeNodesInserted(TreeModelEvent e) {
    if(e != null) {
        int               changedIndexs[];
        TreeStateNode     changedParentNode;

        changedIndexs = e.getChildIndices();
        changedParentNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false);
        /* Only need to update the children if the node has been
           expanded once. */
        // PENDING(scott): make sure childIndexs is sorted!
        if(changedParentNode != null && changedIndexs != null &&
           changedIndexs.length > 0) {
            if(changedParentNode.hasBeenExpanded()) {
                boolean            makeVisible;
                int                counter;
                Object             changedParent;
                TreeStateNode      newNode;
                int                oldChildCount = changedParentNode.
                                      getChildCount();

                changedParent = changedParentNode.getValue();
                makeVisible = ((changedParentNode == root &&
                                !rootVisible) ||
                               (changedParentNode.getRow() != -1 &&
                                changedParentNode.isExpanded()));
                for(counter = 0;counter < changedIndexs.length;counter++)
                {
                    newNode = this.createNodeAt(changedParentNode,
                                                changedIndexs[counter]);
                }
                if(oldChildCount == 0) {
                    // Update the size of the parent.
                    changedParentNode.updatePreferredSize();
                }
                if(treeSelectionModel != null)
                    treeSelectionModel.resetRowSelection();
                /* Update the y origins from the index of the parent
                   to the end of the visible rows. */
                if(!isFixedRowHeight() && (makeVisible ||
                                           (oldChildCount == 0 &&
                                    changedParentNode.isVisible()))) {
                    if(changedParentNode == root)
                        this.updateYLocationsFrom(0);
                    else
                        this.updateYLocationsFrom(changedParentNode.
                                                  getRow());
                    this.visibleNodesChanged();
                }
                else if(makeVisible)
                    this.visibleNodesChanged();
            }
            else if(treeModel.getChildCount(changedParentNode.getValue())
                    - changedIndexs.length == 0) {
                changedParentNode.updatePreferredSize();
                if(!isFixedRowHeight() && changedParentNode.isVisible())
                    updateYLocationsFrom(changedParentNode.getRow());
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:70,代码来源:VariableHeightLayoutCache.java

示例11: treeNodesChanged

import javax.swing.event.TreeModelEvent; //导入方法依赖的package包/类
/**
 * 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><code>e.path</code> returns the path the parent of the
 * changed node(s).
 *
 * <p><code>e.childIndices</code> returns the index(es) of the
 * changed node(s).
 *
 * @param e the <code>TreeModelEvent</code> of interest
 */
public void treeNodesChanged(TreeModelEvent e) {
    if(e != null) {
        int               changedIndexs[];
        TreeStateNode     changedNode;

        changedIndexs = e.getChildIndices();
        changedNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false);
        if(changedNode != null) {
            Object            changedValue = changedNode.getValue();

            /* Update the size of the changed node, as well as all the
               child indexs that are passed in. */
            changedNode.updatePreferredSize();
            if(changedNode.hasBeenExpanded() && changedIndexs != null) {
                int                counter;
                TreeStateNode      changedChildNode;

                for(counter = 0; counter < changedIndexs.length;
                    counter++) {
                    changedChildNode = (TreeStateNode)changedNode
                                .getChildAt(changedIndexs[counter]);
                    /* Reset the user object. */
                    changedChildNode.setUserObject
                                (treeModel.getChild(changedValue,
                                                 changedIndexs[counter]));
                    changedChildNode.updatePreferredSize();
                }
            }
            else if (changedNode == root) {
                // Null indicies for root indicates it changed.
                changedNode.updatePreferredSize();
            }
            if(!isFixedRowHeight()) {
                int          aRow = changedNode.getRow();

                if(aRow != -1)
                    this.updateYLocationsFrom(aRow);
            }
            this.visibleNodesChanged();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:VariableHeightLayoutCache.java


注:本文中的javax.swing.event.TreeModelEvent.getChildIndices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。