aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/JTree.java
diff options
context:
space:
mode:
authorTom Tromey <tromey@gcc.gnu.org>2005-09-23 21:31:04 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-09-23 21:31:04 +0000
commit1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06 (patch)
tree3ca4b2e68dc14c3128b9c781d23f1d0b1f2bee49 /libjava/classpath/javax/swing/JTree.java
parent9b044d19517541c95681d35a92dbc81e6e21d94f (diff)
downloadgcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.zip
gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.gz
gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.bz2
Imported Classpath 0.18.
* sources.am, Makefile.in: Updated. * Makefile.am (nat_source_files): Removed natProxy.cc. * java/lang/reflect/natProxy.cc: Removed. * gnu/classpath/jdwp/VMFrame.java, gnu/classpath/jdwp/VMIdManager.java, gnu/classpath/jdwp/VMVirtualMachine.java, java/lang/reflect/VMProxy.java: New files. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC list. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/java/net/DefaultContentHandlerFactory.java (getContent): Remove ClasspathToolkit references. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/awt/xlib/XCanvasPeer.java: Add new peer methods. * gnu/awt/xlib/XFramePeer.java: Likewise. * gnu/awt/xlib/XGraphicsConfiguration.java: Likewise. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add classpath/native/jawt/jawt.c. * Makefile.in: Regenerate. * jawt.c: Remove file. * include/Makefile.am (tool_include__HEADERS): Remove jawt.h and jawt_md.h. Add ../classpath/include/jawt.h and ../classpath/include/jawt_md.h. * include/Makefile.in: Regenerate. * include/jawt.h: Regenerate. * include/jawt_md.h: Regenerate. From-SVN: r104586
Diffstat (limited to 'libjava/classpath/javax/swing/JTree.java')
-rw-r--r--libjava/classpath/javax/swing/JTree.java124
1 files changed, 58 insertions, 66 deletions
diff --git a/libjava/classpath/javax/swing/JTree.java b/libjava/classpath/javax/swing/JTree.java
index bccd983..bb24c7a 100644
--- a/libjava/classpath/javax/swing/JTree.java
+++ b/libjava/classpath/javax/swing/JTree.java
@@ -339,7 +339,6 @@ public class JTree
{
setModel(model);
setSelectionModel(EmptySelectionModel.sharedInstance());
- selectionModel.addTreeSelectionListener(selectionRedirector);
setCellRenderer(new DefaultTreeCellRenderer());
updateUI();
}
@@ -564,13 +563,13 @@ public class JTree
}
/**
- * Returns the preferred viewport size..
+ * Returns the preferred viewport size.
*
* @return the preferred size
*/
public Dimension getPreferredScrollableViewportSize()
{
- return null;
+ return new Dimension (getPreferredSize().width, getVisibleRowCount()*getRowHeight());
}
public int getScrollableUnitIncrement(Rectangle visibleRect,
@@ -585,15 +584,19 @@ public class JTree
return 1;
}
- public boolean getScrollableTracksViewportWidth()
- {
- return false;
- }
-
- public boolean getScrollableTracksViewportHeight()
- {
- return false;
- }
+ public boolean getScrollableTracksViewportWidth()
+ {
+ if (getParent() instanceof JViewport)
+ return ((JViewport) getParent()).getHeight() > getPreferredSize().height;
+ return false;
+ }
+
+ public boolean getScrollableTracksViewportHeight()
+ {
+ if (getParent() instanceof JViewport)
+ return ((JViewport) getParent()).getWidth() > getPreferredSize().width;
+ return false;
+ }
/**
* Adds a <code>TreeExpansionListener</code> object to the tree.
@@ -660,7 +663,7 @@ public class JTree
*/
public void addTreeSelectionListener(TreeSelectionListener listener)
{
- listenerList.add(TreeSelectionListener.class, listener);
+ listenerList.add(TreeSelectionListener.class, listener);
}
/**
@@ -692,7 +695,7 @@ public class JTree
protected void fireValueChanged(TreeSelectionEvent event)
{
TreeSelectionListener[] listeners = getTreeSelectionListeners();
-
+
for (int index = 0; index < listeners.length; ++index)
listeners[index].valueChanged(event);
}
@@ -775,16 +778,17 @@ public class JTree
{
if (treeModel == model)
return;
-
- TreeModel oldValue = treeModel;
- treeModel = model;
-
- firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
-
+
// add treeModelListener to the new model
if (treeModelListener == null)
treeModelListener = createTreeModelListener();
- model.addTreeModelListener(treeModelListener);
+ if (model != null) // as setModel(null) is allowed
+ model.addTreeModelListener(treeModelListener);
+
+ TreeModel oldValue = treeModel;
+ treeModel = model;
+
+ firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
}
/**
@@ -1276,9 +1280,17 @@ public class JTree
}
public void collapsePath(TreePath path)
- {
- setExpandedState(path, false);
- }
+ {
+ try
+ {
+ fireTreeWillCollapse(path);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
+ setExpandedState(path, false);
+ fireTreeCollapsed(path);
+ }
public void collapseRow(int row)
{
@@ -1292,13 +1304,22 @@ public class JTree
}
public void expandPath(TreePath path)
- {
- // Don't expand if last path component is a leaf node.
- if ((path == null) || (treeModel.isLeaf(path.getLastPathComponent())))
- return;
-
- setExpandedState(path, true);
- }
+ {
+ // Don't expand if last path component is a leaf node.
+ if ((path == null) || (treeModel.isLeaf(path.getLastPathComponent())))
+ return;
+
+ try
+ {
+ fireTreeWillExpand(path);
+ }
+ catch (ExpandVetoException ev)
+ {
+ }
+
+ setExpandedState(path, true);
+ fireTreeExpanded(path);
+ }
public void expandRow(int row)
{
@@ -1502,28 +1523,11 @@ public class JTree
return null;
}
- private void checkExpandParents(TreePath path) throws ExpandVetoException
- {
-
- TreePath parent = path.getParentPath();
-
- if (parent != null)
- checkExpandParents(parent);
-
- fireTreeWillExpand(path);
- }
-
private void doExpandParents(TreePath path, boolean state)
{
- TreePath parent = path.getParentPath();
-
- if (isExpanded(parent))
- {
- nodeStates.put(path, state ? EXPANDED : COLLAPSED);
- return;
- }
-
- if (parent != null)
+ TreePath parent = path.getParentPath();
+
+ if (!isExpanded(parent) && parent != null)
doExpandParents(parent, false);
nodeStates.put(path, state ? EXPANDED : COLLAPSED);
@@ -1533,20 +1537,8 @@ public class JTree
{
if (path == null)
return;
-
TreePath parent = path.getParentPath();
- try
- {
- if (parent != null)
- checkExpandParents(parent);
- }
- catch (ExpandVetoException e)
- {
- // Expansion vetoed.
- return;
- }
-
doExpandParents(path, state);
}
@@ -1729,8 +1721,8 @@ public class JTree
*
* @param prefix the prefix to search for in the cell values
* @param startingRow the index of the row where to start searching from
- * @param bias the search direction, either {@link Position.Bias.Forward} or
- * {@link Position.Bias.Backward}
+ * @param bias the search direction, either {@link Position.Bias#Forward} or
+ * {@link Position.Bias#Backward}
*
* @return the path to the found element or -1 if no such element has been
* found
@@ -1802,7 +1794,7 @@ public class JTree
* it will be removed too.
*
* @param path the path from which selected descendants are to be removed
- * @param includePath if <code>true</code> then <code>path</code> itself
+ * @param includeSelected if <code>true</code> then <code>path</code> itself
* will also be remove if it's selected
*
* @return <code>true</code> if something has been removed,