The ChangeLog fully explains all changes to BasicTreeUI.
For DefaultTableCellRenderer, Roman suggested I fix it this way. Both
ways work, but this looks a bit more intuitive.
2005-11-03 Lillian Angel <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicTreeUI.java
(mousePressed): If the control icon is clicked, the
path selected should not be changed.
(paintRecursively): Moved call to getChildCount before
loop.
(paintRow): Added a check to prevent NPE.
(updateCurrentVisiblePath): Made this slightly more efficent.
Instead of checking each path, we can check the siblings if the
current node is not expanded.
* javax/swing/table/DefaultTableCellRenderer.java
(getTableCellRendererComponent): Fixed indentation, and changed
to set the background color if it is not an instance of
ColorUIResource. Prevents overriding a user-set color.
Index: javax/swing/plaf/basic/BasicTreeUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.105
diff -u -r1.105 BasicTreeUI.java
--- javax/swing/plaf/basic/BasicTreeUI.java 30 Oct 2005 23:15:11 -0000 1.105
+++ javax/swing/plaf/basic/BasicTreeUI.java 3 Nov 2005 21:56:11 -0000
@@ -2259,9 +2259,12 @@
boolean inBounds = bounds.contains(click.x, click.y);
if ((inBounds || cntlClick) && tree.isVisible(path))
{
- selectPath(tree, path);
- if (inBounds && e.getClickCount() == 2 && !isLeaf(row))
- toggleExpandState(path);
+ if (inBounds)
+ {
+ selectPath(tree, path);
+ if (e.getClickCount() == 2 && !isLeaf(row))
+ toggleExpandState(path);
+ }
if (cntlClick)
{
@@ -3162,9 +3165,9 @@
y0 += halfHeight;
}
- int max = mod.getChildCount(curr);
if (isExpanded)
{
+ int max = mod.getChildCount(curr);
for (int i = 0; i < max; i++)
{
int indent = indentation + rightChildIndent;
@@ -3739,8 +3742,10 @@
if (tree.isVisible(path))
{
- bounds.width = preferredSize.width;
+ if (!validCachedPreferredSize)
+ updateCachedPreferredSize();
bounds.x += gap;
+ bounds.width = preferredSize.width + bounds.x;
if (editingComponent != null && editingPath != null && isEditing(tree)
&& node.equals(editingPath.getLastPathComponent()))
@@ -3818,9 +3823,13 @@
else
current = current.pathByAddingChild(next);
do
- next = getNextNode(next);
- while (next != null &&
- !tree.isVisible(new TreePath(getPathToRoot(next, 0))));
+ {
+ TreePath path = new TreePath(getPathToRoot(next, 0));
+ if (tree.isVisible(path) && tree.isExpanded(path))
+ next = getNextNode(next);
+ else next = getNextSibling(next);
+ }
+ while (next != null && !tree.isVisible(new TreePath(getPathToRoot(next, 0))));
}
currentVisiblePath = current;
tree.setVisibleRowCount(getRowCount(tree));
Index: javax/swing/table/DefaultTableCellRenderer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/table/DefaultTableCellRenderer.java,v
retrieving revision 1.18
diff -u -r1.18 DefaultTableCellRenderer.java
--- javax/swing/table/DefaultTableCellRenderer.java 3 Nov 2005 20:27:47 -0000 1.18
+++ javax/swing/table/DefaultTableCellRenderer.java 3 Nov 2005 21:56:11 -0000
@@ -50,6 +50,7 @@
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
+import javax.swing.plaf.ColorUIResource;
/**
* Class to display every cells.
@@ -149,13 +150,14 @@
setForeground(table.getForeground());
}
- if (hasFocus)
- {
- setBackground(getBackground());
- setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
- }
- else
- setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
+ if (hasFocus)
+ {
+ if (!(getBackground() instanceof ColorUIResource))
+ setBackground(table.getBackground());
+ setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
+ }
+ else
+ setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
setEnabled(table.isEnabled());
setFont(table.getFont());
Index: javax/swing/plaf/basic/BasicTreeUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.105
diff -u -r1.105 BasicTreeUI.java
--- javax/swing/plaf/basic/BasicTreeUI.java 30 Oct 2005 23:15:11 -0000 1.105
+++ javax/swing/plaf/basic/BasicTreeUI.java 3 Nov 2005 21:56:11 -0000
@@ -2259,9 +2259,12 @@
boolean inBounds = bounds.contains(click.x, click.y);
if ((inBounds || cntlClick) && tree.isVisible(path))
{
- selectPath(tree, path);
- if (inBounds && e.getClickCount() == 2 && !isLeaf(row))
- toggleExpandState(path);
+ if (inBounds)
+ {
+ selectPath(tree, path);
+ if (e.getClickCount() == 2 && !isLeaf(row))
+ toggleExpandState(path);
+ }
if (cntlClick)
{
@@ -3162,9 +3165,9 @@
y0 += halfHeight;
}
- int max = mod.getChildCount(curr);
if (isExpanded)
{
+ int max = mod.getChildCount(curr);
for (int i = 0; i < max; i++)
{
int indent = indentation + rightChildIndent;
@@ -3739,8 +3742,10 @@
if (tree.isVisible(path))
{
- bounds.width = preferredSize.width;
+ if (!validCachedPreferredSize)
+ updateCachedPreferredSize();
bounds.x += gap;
+ bounds.width = preferredSize.width + bounds.x;
if (editingComponent != null && editingPath != null && isEditing(tree)
&& node.equals(editingPath.getLastPathComponent()))
@@ -3818,9 +3823,13 @@
else
current = current.pathByAddingChild(next);
do
- next = getNextNode(next);
- while (next != null &&
- !tree.isVisible(new TreePath(getPathToRoot(next, 0))));
+ {
+ TreePath path = new TreePath(getPathToRoot(next, 0));
+ if (tree.isVisible(path) && tree.isExpanded(path))
+ next = getNextNode(next);
+ else next = getNextSibling(next);
+ }
+ while (next != null && !tree.isVisible(new TreePath(getPathToRoot(next, 0))));
}
currentVisiblePath = current;
tree.setVisibleRowCount(getRowCount(tree));
Index: javax/swing/table/DefaultTableCellRenderer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/table/DefaultTableCellRenderer.java,v
retrieving revision 1.18
diff -u -r1.18 DefaultTableCellRenderer.java
--- javax/swing/table/DefaultTableCellRenderer.java 3 Nov 2005 20:27:47 -0000 1.18
+++ javax/swing/table/DefaultTableCellRenderer.java 3 Nov 2005 21:56:11 -0000
@@ -50,6 +50,7 @@
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
+import javax.swing.plaf.ColorUIResource;
/**
* Class to display every cells.
@@ -149,13 +150,14 @@
setForeground(table.getForeground());
}
- if (hasFocus)
- {
- setBackground(getBackground());
- setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
- }
- else
- setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
+ if (hasFocus)
+ {
+ if (!(getBackground() instanceof ColorUIResource))
+ setBackground(table.getBackground());
+ setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
+ }
+ else
+ setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
setEnabled(table.isEnabled());
setFont(table.getFont());
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches