Re: [cp-patches] FYI: BasicTreeUI fix
Noticed the expanded and collapsed icon defaults were set to the wrong icons. Fixed this and reworked mousePressed to work with these changes. 2005-10-18 Lillian Angel [EMAIL PROTECTED] * javax/swing/plaf/basic/BasicTreeUI.java: Removed leafIcon field. (BasicTreeUI): Removed leafIcon initialization. (installDefaults): Icon defaults were wrong, fixed. (isLocationInExpandControl): Fixed to incorporated gap. (mousePressed): Fixed to include correct icon widths. Sometimes the labels icon is different from what the tree's default icon is set to. Added a check for this. (getCellBounds): No need to include gap here. (getCurrentControlIcon): Fixed to use expandedIcon and collapsedIcon. (paintRow): No need paint beyond preferred width of tree here. (updateCurrentVisiblePath): If nothing is selected, the root should be selected without focus. * javax/swing/plaf/metal/MetalTreeUI.java (installDefaults): Fixed defaults for the expanded/collapsed icons. On Mon, 2005-10-17 at 14:46 -0400, Lillian Angel wrote: Now this is completely fixed. 2005-10-17 Lillian Angel [EMAIL PROTECTED] * javax/swing/plaf/basic/BasicTreeUI.java (installUI): Moved call to installKeyboardActions and Listeners to before expansion of root. (paint): Added check to make sure the cached visible path is updated. (treeExpanded): Added call to update visible path. (treeCollapsed): Likewise. (treeNodesChanged): Likewise. (treeNodesInserted): Likewise. (treeNodesRemoved): Likewise. (treeStructureChanged): Likewise. (paintRecursive): Moved code to paintRow. (paintControlIcons): Fixed to paint custom control icons properly. (paintExpandControl): Removed unneeded parameter. (paintRow): Added code to paint the row with the correct width. * javax/swing/plaf/metal/MetalTreeUI.java (installUI): Moved code to expand the root after all the listeners have been initialized. On Fri, 2005-10-14 at 17:42 -0400, Lillian Angel wrote: After testing some new apps, I noticed that there was a slight problem with some custom icons. I almost have it fixed completely. 2005-10-14 Lillian Angel [EMAIL PROTECTED] * javax/swing/LookAndFeel.java (makeIcon): Implemented. * javax/swing/plaf/basic/BasicTreeUI.java (updateCachedPreferredSize): Should only add with of control icon if not a leaf. (mousePressed): Fixed to use new gap field. (paintRecursive): Likewise. (paintRow): Likewise. (updateCurrentVisiblePath): Shouldn't include root if it is not of a valid size to be painted. ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches Index: javax/swing/plaf/basic/BasicTreeUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v retrieving revision 1.101 diff -u -r1.101 BasicTreeUI.java --- javax/swing/plaf/basic/BasicTreeUI.java 18 Oct 2005 15:02:42 - 1.101 +++ javax/swing/plaf/basic/BasicTreeUI.java 18 Oct 2005 17:38:54 - @@ -225,9 +225,6 @@ /** Set to true if the editor has a different size than the renderer. */ protected boolean editorHasDifferentSize; - - /** Leaf icon for the tree. */ - Icon leafIcon; /** The action listener for the editor's Timer. */ Timer editorTimer = new EditorUpdateTimer(); @@ -285,7 +282,6 @@ editingRow = -1; lastSelectedRow = -1; -leafIcon = UIManager.getIcon(Tree.leafIcon); } /** @@ -1233,8 +1229,8 @@ tree.setRowHeight(UIManager.getInt(Tree.rowHeight)); tree.requestFocusInWindow(false); tree.setScrollsOnExpand(UIManager.getBoolean(Tree.scrollsOnExpand)); -setExpandedIcon(UIManager.getIcon(Tree.openIcon)); -setCollapsedIcon(UIManager.getIcon(Tree.closedIcon)); +setExpandedIcon(UIManager.getIcon(Tree.expandedIcon)); +setCollapsedIcon(UIManager.getIcon(Tree.collapsedIcon)); } /** @@ -1673,11 +1669,10 @@ if (!isLeaf(row)) { -if (bounds == null) - bounds = getPathBounds(tree, path); +bounds = getPathBounds(tree, path); if (hasControlIcons() (mouseX bounds.x) - (mouseX (bounds.x - getCurrentControlIcon(path).getIconWidth( + (mouseX (bounds.x - getCurrentControlIcon(path).getIconWidth() - gap))) cntlClick = true; } return cntlClick; @@ -2310,13 +2305,29 @@
Re: [cp-patches] FYI: BasicTreeUI fix
Now this is completely fixed. 2005-10-17 Lillian Angel [EMAIL PROTECTED] * javax/swing/plaf/basic/BasicTreeUI.java (installUI): Moved call to installKeyboardActions and Listeners to before expansion of root. (paint): Added check to make sure the cached visible path is updated. (treeExpanded): Added call to update visible path. (treeCollapsed): Likewise. (treeNodesChanged): Likewise. (treeNodesInserted): Likewise. (treeNodesRemoved): Likewise. (treeStructureChanged): Likewise. (paintRecursive): Moved code to paintRow. (paintControlIcons): Fixed to paint custom control icons properly. (paintExpandControl): Removed unneeded parameter. (paintRow): Added code to paint the row with the correct width. * javax/swing/plaf/metal/MetalTreeUI.java (installUI): Moved code to expand the root after all the listeners have been initialized. On Fri, 2005-10-14 at 17:42 -0400, Lillian Angel wrote: After testing some new apps, I noticed that there was a slight problem with some custom icons. I almost have it fixed completely. 2005-10-14 Lillian Angel [EMAIL PROTECTED] * javax/swing/LookAndFeel.java (makeIcon): Implemented. * javax/swing/plaf/basic/BasicTreeUI.java (updateCachedPreferredSize): Should only add with of control icon if not a leaf. (mousePressed): Fixed to use new gap field. (paintRecursive): Likewise. (paintRow): Likewise. (updateCurrentVisiblePath): Shouldn't include root if it is not of a valid size to be painted. ___ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches Index: javax/swing/plaf/basic/BasicTreeUI.java === RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v retrieving revision 1.99 diff -u -r1.99 BasicTreeUI.java --- javax/swing/plaf/basic/BasicTreeUI.java 14 Oct 2005 22:37:07 - 1.99 +++ javax/swing/plaf/basic/BasicTreeUI.java 17 Oct 2005 18:38:45 - @@ -1187,7 +1187,6 @@ isLeaf = treeModel.isLeaf(path[i]); if (!isLeaf hasControlIcons()) bounds.width += getCurrentControlIcon(curr).getIconWidth(); - maxWidth = Math.max(maxWidth, bounds.x + bounds.width); } preferredSize = new Dimension(maxWidth, (getRowHeight() * path.length)); @@ -1347,7 +1346,9 @@ installDefaults(); installComponents(); - +installKeyboardActions(); +installListeners(); + setCellEditor(createDefaultCellEditor()); createdCellEditor = true; isEditing = false; @@ -1362,8 +1363,6 @@ } treeSelectionModel = tree.getSelectionModel(); -installKeyboardActions(); -installListeners(); completeUIInstall(); } @@ -1410,13 +1409,16 @@ public void paint(Graphics g, JComponent c) { JTree tree = (JTree) c; +if (currentVisiblePath == null) + updateCurrentVisiblePath(); + if (treeModel != null) { Object root = treeModel.getRoot(); paintRecursive(g, 0, 0, 0, tree, treeModel, root); if (hasControlIcons()) - paintControlIcons(g, 0, 0, 0, 0, tree, treeModel, root); + paintControlIcons(g, 0, 0, 0, tree, treeModel, root); } } @@ -2554,6 +2556,7 @@ public void treeExpanded(TreeExpansionEvent event) { validCachedPreferredSize = false; + updateCurrentVisiblePath(); tree.revalidate(); tree.repaint(); } @@ -2567,6 +2570,7 @@ public void treeCollapsed(TreeExpansionEvent event) { validCachedPreferredSize = false; + updateCurrentVisiblePath(); tree.revalidate(); tree.repaint(); } @@ -2750,6 +2754,7 @@ public void treeNodesChanged(TreeModelEvent e) { validCachedPreferredSize = false; + updateCurrentVisiblePath(); tree.revalidate(); tree.repaint(); } @@ -2765,6 +2770,7 @@ public void treeNodesInserted(TreeModelEvent e) { validCachedPreferredSize = false; + updateCurrentVisiblePath(); tree.revalidate(); tree.repaint(); } @@ -2783,6 +2789,7 @@ public void treeNodesRemoved(TreeModelEvent e) { validCachedPreferredSize = false; + updateCurrentVisiblePath(); tree.revalidate(); tree.repaint(); } @@ -2800,6 +2807,7 @@ public void treeStructureChanged(TreeModelEvent e) { validCachedPreferredSize = false; + updateCurrentVisiblePath(); tree.revalidate(); tree.repaint(); } @@ -3085,11 +3093,7 @@ boolean isLeaf = mod.isLeaf(curr); Rectangle bounds = getPathBounds(tree, path); Object root = mod.getRoot(); -int