Java Code Examples for sun.swing.SwingUtilities2#getTreePath()
The following examples show how to use
sun.swing.SwingUtilities2#getTreePath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicTreeUI.java From JDKSourceCode1.8 with MIT License | 5 votes |
public void treeStructureChanged(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeStructureChanged(e); updateLeadSelectionRow(); TreePath pPath = SwingUtilities2.getTreePath(e, getModel()); if (pPath != null) { pPath = pPath.getParentPath(); } if(pPath == null || treeState.isExpanded(pPath)) updateSize(); } }
Example 2
Source File: BasicTreeUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void treeNodesRemoved(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeNodesRemoved(e); updateLeadSelectionRow(); TreePath path = SwingUtilities2.getTreePath(e, getModel()); if(treeState.isExpanded(path) || treeModel.getChildCount(path.getLastPathComponent()) == 0) updateSize(); } }
Example 3
Source File: BasicTreeUI.java From hottub with GNU General Public License v2.0 | 5 votes |
public void treeNodesRemoved(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeNodesRemoved(e); updateLeadSelectionRow(); TreePath path = SwingUtilities2.getTreePath(e, getModel()); if(treeState.isExpanded(path) || treeModel.getChildCount(path.getLastPathComponent()) == 0) updateSize(); } }
Example 4
Source File: BasicTreeUI.java From JDKSourceCode1.8 with MIT License | 5 votes |
public void treeNodesRemoved(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeNodesRemoved(e); updateLeadSelectionRow(); TreePath path = SwingUtilities2.getTreePath(e, getModel()); if(treeState.isExpanded(path) || treeModel.getChildCount(path.getLastPathComponent()) == 0) updateSize(); } }
Example 5
Source File: BasicTreeUI.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public void treeNodesRemoved(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeNodesRemoved(e); updateLeadSelectionRow(); TreePath path = SwingUtilities2.getTreePath(e, getModel()); if(treeState.isExpanded(path) || treeModel.getChildCount(path.getLastPathComponent()) == 0) updateSize(); } }
Example 6
Source File: BasicTreeUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public void treeNodesRemoved(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeNodesRemoved(e); updateLeadSelectionRow(); TreePath path = SwingUtilities2.getTreePath(e, getModel()); if(treeState.isExpanded(path) || treeModel.getChildCount(path.getLastPathComponent()) == 0) updateSize(); } }
Example 7
Source File: BasicTreeUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void treeStructureChanged(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeStructureChanged(e); updateLeadSelectionRow(); TreePath pPath = SwingUtilities2.getTreePath(e, getModel()); if (pPath != null) { pPath = pPath.getParentPath(); } if(pPath == null || treeState.isExpanded(pPath)) updateSize(); } }
Example 8
Source File: BasicTreeUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void treeStructureChanged(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeStructureChanged(e); updateLeadSelectionRow(); TreePath pPath = SwingUtilities2.getTreePath(e, getModel()); if (pPath != null) { pPath = pPath.getParentPath(); } if(pPath == null || treeState.isExpanded(pPath)) updateSize(); } }
Example 9
Source File: BasicTreeUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void treeStructureChanged(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeStructureChanged(e); updateLeadSelectionRow(); TreePath pPath = SwingUtilities2.getTreePath(e, getModel()); if (pPath != null) { pPath = pPath.getParentPath(); } if(pPath == null || treeState.isExpanded(pPath)) updateSize(); } }
Example 10
Source File: BasicTreeUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void treeNodesRemoved(TreeModelEvent e) { if(treeState != null && e != null) { treeState.treeNodesRemoved(e); updateLeadSelectionRow(); TreePath path = SwingUtilities2.getTreePath(e, getModel()); if(treeState.isExpanded(path) || treeModel.getChildCount(path.getLastPathComponent()) == 0) updateSize(); } }
Example 11
Source File: FixedHeightLayoutCache.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * <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(); } } }
Example 12
Source File: VariableHeightLayoutCache.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Invoked after the tree has drastically changed structure from a * given node down. If the path returned by <code>e.getPath</code> * is of length one and the first element does not identify the * current root node the first element should become the new root * of the tree. * * <p><code>e.path</code> holds the path to the node. * <p><code>e.childIndices</code> returns <code>null</code>. * * @param e the <code>TreeModelEvent</code> of interest */ public void treeStructureChanged(TreeModelEvent e) { if(e != null) { TreePath changedPath = SwingUtilities2.getTreePath(e, getModel()); TreeStateNode changedNode; changedNode = getNodeForPath(changedPath, false, false); // Check if root has changed, either to a null root, or // to an entirely new root. if(changedNode == root || (changedNode == null && ((changedPath == null && treeModel != null && treeModel.getRoot() == null) || (changedPath != null && changedPath.getPathCount() == 1)))) { rebuild(true); } else if(changedNode != null) { int nodeIndex, oldRow; TreeStateNode newNode, parent; boolean wasExpanded, wasVisible; int newIndex; wasExpanded = changedNode.isExpanded(); wasVisible = (changedNode.getRow() != -1); /* Remove the current node and recreate a new one. */ parent = (TreeStateNode)changedNode.getParent(); nodeIndex = parent.getIndex(changedNode); if(wasVisible && wasExpanded) { changedNode.collapse(false); } if(wasVisible) visibleNodes.removeElement(changedNode); changedNode.removeFromParent(); createNodeAt(parent, nodeIndex); newNode = (TreeStateNode)parent.getChildAt(nodeIndex); if(wasVisible && wasExpanded) newNode.expand(false); newIndex = newNode.getRow(); if(!isFixedRowHeight() && wasVisible) { if(newIndex == 0) updateYLocationsFrom(newIndex); else updateYLocationsFrom(newIndex - 1); this.visibleNodesChanged(); } else if(wasVisible) this.visibleNodesChanged(); } } }
Example 13
Source File: FixedHeightLayoutCache.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * <p>Invoked after the tree has drastically changed structure from a * given node down. If the path returned by e.getPath() is of length * one and the first element does not identify the current root node * the first element should become the new root of the tree. * * <p>e.path() holds the path to the node.</p> * <p>e.childIndices() returns null.</p> */ public void treeStructureChanged(TreeModelEvent e) { if(e != null) { TreePath changedPath = SwingUtilities2.getTreePath(e, getModel()); FHTreeStateNode changedNode = getNodeForPath (changedPath, false, false); // Check if root has changed, either to a null root, or // to an entirely new root. if (changedNode == root || (changedNode == null && ((changedPath == null && treeModel != null && treeModel.getRoot() == null) || (changedPath != null && changedPath.getPathCount() <= 1)))) { rebuild(true); } else if(changedNode != null) { boolean wasExpanded, wasVisible; FHTreeStateNode parent = (FHTreeStateNode) changedNode.getParent(); wasExpanded = changedNode.isExpanded(); wasVisible = changedNode.isVisible(); int index = parent.getIndex(changedNode); changedNode.collapse(false); parent.remove(index); if(wasVisible && wasExpanded) { int row = changedNode.getRow(); parent.resetChildrenRowsFrom(row, index, changedNode.getChildIndex()); changedNode = getNodeForPath(changedPath, false, true); changedNode.expand(); } if(treeSelectionModel != null && wasVisible && wasExpanded) treeSelectionModel.resetRowSelection(); if(wasVisible) this.visibleNodesChanged(); } } }
Example 14
Source File: BasicTreeUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void treeNodesChanged(TreeModelEvent e) { if(treeState != null && e != null) { TreePath parentPath = SwingUtilities2.getTreePath(e, getModel()); int[] indices = e.getChildIndices(); if (indices == null || indices.length == 0) { // The root has changed treeState.treeNodesChanged(e); updateSize(); } else if (treeState.isExpanded(parentPath)) { // Changed nodes are visible // Find the minimum index, we only need paint from there // down. int minIndex = indices[0]; for (int i = indices.length - 1; i > 0; i--) { minIndex = Math.min(indices[i], minIndex); } Object minChild = treeModel.getChild( parentPath.getLastPathComponent(), minIndex); TreePath minPath = parentPath.pathByAddingChild(minChild); Rectangle minBounds = getPathBounds(tree, minPath); // Forward to the treestate treeState.treeNodesChanged(e); // Mark preferred size as bogus. updateSize0(); // And repaint Rectangle newMinBounds = getPathBounds(tree, minPath); if (minBounds == null || newMinBounds == null) { return; } if (indices.length == 1 && newMinBounds.height == minBounds.height) { tree.repaint(0, minBounds.y, tree.getWidth(), minBounds.height); } else { tree.repaint(0, minBounds.y, tree.getWidth(), tree.getHeight() - minBounds.y); } } else { // Nodes that changed aren't visible. No need to paint treeState.treeNodesChanged(e); } } }
Example 15
Source File: VariableHeightLayoutCache.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Invoked after the tree has drastically changed structure from a * given node down. If the path returned by <code>e.getPath</code> * is of length one and the first element does not identify the * current root node the first element should become the new root * of the tree. * * <p><code>e.path</code> holds the path to the node. * <p><code>e.childIndices</code> returns <code>null</code>. * * @param e the <code>TreeModelEvent</code> of interest */ public void treeStructureChanged(TreeModelEvent e) { if(e != null) { TreePath changedPath = SwingUtilities2.getTreePath(e, getModel()); TreeStateNode changedNode; changedNode = getNodeForPath(changedPath, false, false); // Check if root has changed, either to a null root, or // to an entirely new root. if(changedNode == root || (changedNode == null && ((changedPath == null && treeModel != null && treeModel.getRoot() == null) || (changedPath != null && changedPath.getPathCount() == 1)))) { rebuild(true); } else if(changedNode != null) { int nodeIndex, oldRow; TreeStateNode newNode, parent; boolean wasExpanded, wasVisible; int newIndex; wasExpanded = changedNode.isExpanded(); wasVisible = (changedNode.getRow() != -1); /* Remove the current node and recreate a new one. */ parent = (TreeStateNode)changedNode.getParent(); nodeIndex = parent.getIndex(changedNode); if(wasVisible && wasExpanded) { changedNode.collapse(false); } if(wasVisible) visibleNodes.removeElement(changedNode); changedNode.removeFromParent(); createNodeAt(parent, nodeIndex); newNode = (TreeStateNode)parent.getChildAt(nodeIndex); if(wasVisible && wasExpanded) newNode.expand(false); newIndex = newNode.getRow(); if(!isFixedRowHeight() && wasVisible) { if(newIndex == 0) updateYLocationsFrom(newIndex); else updateYLocationsFrom(newIndex - 1); this.visibleNodesChanged(); } else if(wasVisible) this.visibleNodesChanged(); } } }
Example 16
Source File: FixedHeightLayoutCache.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * <p>Invoked after the tree has drastically changed structure from a * given node down. If the path returned by e.getPath() is of length * one and the first element does not identify the current root node * the first element should become the new root of the tree. * * <p>e.path() holds the path to the node.</p> * <p>e.childIndices() returns null.</p> */ public void treeStructureChanged(TreeModelEvent e) { if(e != null) { TreePath changedPath = SwingUtilities2.getTreePath(e, getModel()); FHTreeStateNode changedNode = getNodeForPath (changedPath, false, false); // Check if root has changed, either to a null root, or // to an entirely new root. if (changedNode == root || (changedNode == null && ((changedPath == null && treeModel != null && treeModel.getRoot() == null) || (changedPath != null && changedPath.getPathCount() <= 1)))) { rebuild(true); } else if(changedNode != null) { boolean wasExpanded, wasVisible; FHTreeStateNode parent = (FHTreeStateNode) changedNode.getParent(); wasExpanded = changedNode.isExpanded(); wasVisible = changedNode.isVisible(); int index = parent.getIndex(changedNode); changedNode.collapse(false); parent.remove(index); if(wasVisible && wasExpanded) { int row = changedNode.getRow(); parent.resetChildrenRowsFrom(row, index, changedNode.getChildIndex()); changedNode = getNodeForPath(changedPath, false, true); changedNode.expand(); } if(treeSelectionModel != null && wasVisible && wasExpanded) treeSelectionModel.resetRowSelection(); if(wasVisible) this.visibleNodesChanged(); } } }
Example 17
Source File: BasicTreeUI.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public void treeNodesChanged(TreeModelEvent e) { if(treeState != null && e != null) { TreePath parentPath = SwingUtilities2.getTreePath(e, getModel()); int[] indices = e.getChildIndices(); if (indices == null || indices.length == 0) { // The root has changed treeState.treeNodesChanged(e); updateSize(); } else if (treeState.isExpanded(parentPath)) { // Changed nodes are visible // Find the minimum index, we only need paint from there // down. int minIndex = indices[0]; for (int i = indices.length - 1; i > 0; i--) { minIndex = Math.min(indices[i], minIndex); } Object minChild = treeModel.getChild( parentPath.getLastPathComponent(), minIndex); TreePath minPath = parentPath.pathByAddingChild(minChild); Rectangle minBounds = getPathBounds(tree, minPath); // Forward to the treestate treeState.treeNodesChanged(e); // Mark preferred size as bogus. updateSize0(); // And repaint Rectangle newMinBounds = getPathBounds(tree, minPath); if (minBounds == null || newMinBounds == null) { return; } if (indices.length == 1 && newMinBounds.height == minBounds.height) { tree.repaint(0, minBounds.y, tree.getWidth(), minBounds.height); } else { tree.repaint(0, minBounds.y, tree.getWidth(), tree.getHeight() - minBounds.y); } } else { // Nodes that changed aren't visible. No need to paint treeState.treeNodesChanged(e); } } }
Example 18
Source File: BasicTreeUI.java From Java8CN with Apache License 2.0 | 4 votes |
public void treeNodesChanged(TreeModelEvent e) { if(treeState != null && e != null) { TreePath parentPath = SwingUtilities2.getTreePath(e, getModel()); int[] indices = e.getChildIndices(); if (indices == null || indices.length == 0) { // The root has changed treeState.treeNodesChanged(e); updateSize(); } else if (treeState.isExpanded(parentPath)) { // Changed nodes are visible // Find the minimum index, we only need paint from there // down. int minIndex = indices[0]; for (int i = indices.length - 1; i > 0; i--) { minIndex = Math.min(indices[i], minIndex); } Object minChild = treeModel.getChild( parentPath.getLastPathComponent(), minIndex); TreePath minPath = parentPath.pathByAddingChild(minChild); Rectangle minBounds = getPathBounds(tree, minPath); // Forward to the treestate treeState.treeNodesChanged(e); // Mark preferred size as bogus. updateSize0(); // And repaint Rectangle newMinBounds = getPathBounds(tree, minPath); if (minBounds == null || newMinBounds == null) { return; } if (indices.length == 1 && newMinBounds.height == minBounds.height) { tree.repaint(0, minBounds.y, tree.getWidth(), minBounds.height); } else { tree.repaint(0, minBounds.y, tree.getWidth(), tree.getHeight() - minBounds.y); } } else { // Nodes that changed aren't visible. No need to paint treeState.treeNodesChanged(e); } } }
Example 19
Source File: VariableHeightLayoutCache.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Invoked after the tree has drastically changed structure from a * given node down. If the path returned by <code>e.getPath</code> * is of length one and the first element does not identify the * current root node the first element should become the new root * of the tree. * * <p><code>e.path</code> holds the path to the node. * <p><code>e.childIndices</code> returns <code>null</code>. * * @param e the <code>TreeModelEvent</code> of interest */ public void treeStructureChanged(TreeModelEvent e) { if(e != null) { TreePath changedPath = SwingUtilities2.getTreePath(e, getModel()); TreeStateNode changedNode; changedNode = getNodeForPath(changedPath, false, false); // Check if root has changed, either to a null root, or // to an entirely new root. if(changedNode == root || (changedNode == null && ((changedPath == null && treeModel != null && treeModel.getRoot() == null) || (changedPath != null && changedPath.getPathCount() == 1)))) { rebuild(true); } else if(changedNode != null) { int nodeIndex, oldRow; TreeStateNode newNode, parent; boolean wasExpanded, wasVisible; int newIndex; wasExpanded = changedNode.isExpanded(); wasVisible = (changedNode.getRow() != -1); /* Remove the current node and recreate a new one. */ parent = (TreeStateNode)changedNode.getParent(); nodeIndex = parent.getIndex(changedNode); if(wasVisible && wasExpanded) { changedNode.collapse(false); } if(wasVisible) visibleNodes.removeElement(changedNode); changedNode.removeFromParent(); createNodeAt(parent, nodeIndex); newNode = (TreeStateNode)parent.getChildAt(nodeIndex); if(wasVisible && wasExpanded) newNode.expand(false); newIndex = newNode.getRow(); if(!isFixedRowHeight() && wasVisible) { if(newIndex == 0) updateYLocationsFrom(newIndex); else updateYLocationsFrom(newIndex - 1); this.visibleNodesChanged(); } else if(wasVisible) this.visibleNodesChanged(); } } }
Example 20
Source File: VariableHeightLayoutCache.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Invoked after the tree has drastically changed structure from a * given node down. If the path returned by <code>e.getPath</code> * is of length one and the first element does not identify the * current root node the first element should become the new root * of the tree. * * <p><code>e.path</code> holds the path to the node. * <p><code>e.childIndices</code> returns <code>null</code>. * * @param e the <code>TreeModelEvent</code> of interest */ public void treeStructureChanged(TreeModelEvent e) { if(e != null) { TreePath changedPath = SwingUtilities2.getTreePath(e, getModel()); TreeStateNode changedNode; changedNode = getNodeForPath(changedPath, false, false); // Check if root has changed, either to a null root, or // to an entirely new root. if(changedNode == root || (changedNode == null && ((changedPath == null && treeModel != null && treeModel.getRoot() == null) || (changedPath != null && changedPath.getPathCount() == 1)))) { rebuild(true); } else if(changedNode != null) { int nodeIndex, oldRow; TreeStateNode newNode, parent; boolean wasExpanded, wasVisible; int newIndex; wasExpanded = changedNode.isExpanded(); wasVisible = (changedNode.getRow() != -1); /* Remove the current node and recreate a new one. */ parent = (TreeStateNode)changedNode.getParent(); nodeIndex = parent.getIndex(changedNode); if(wasVisible && wasExpanded) { changedNode.collapse(false); } if(wasVisible) visibleNodes.removeElement(changedNode); changedNode.removeFromParent(); createNodeAt(parent, nodeIndex); newNode = (TreeStateNode)parent.getChildAt(nodeIndex); if(wasVisible && wasExpanded) newNode.expand(false); newIndex = newNode.getRow(); if(!isFixedRowHeight() && wasVisible) { if(newIndex == 0) updateYLocationsFrom(newIndex); else updateYLocationsFrom(newIndex - 1); this.visibleNodesChanged(); } else if(wasVisible) this.visibleNodesChanged(); } } }