OSDN Git Service

Merged gcj-eclipse branch to trunk.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / javax / swing / tree / AbstractLayoutCache.java
index 8dbdd2f..4a6899f 100644 (file)
@@ -1,5 +1,5 @@
 /* AbstractLayoutCache.java --
-   Copyright (C) 2002, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,13 +38,10 @@ exception statement from your version. */
 
 package javax.swing.tree;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Rectangle;
 import java.util.Enumeration;
 
 import javax.swing.event.TreeModelEvent;
-import javax.swing.tree.VariableHeightLayoutCache.NodeRecord;
 
 /**
  * class AbstractLayoutCache
@@ -152,9 +149,11 @@ public abstract class AbstractLayoutCache
   protected Rectangle getNodeDimensions(Object value, int row, int depth,
                                         boolean expanded, Rectangle bounds)
   {
-    if (nodeDimensions == null)
-      throw new InternalError("The NodeDimensions are not set");
-    return nodeDimensions.getNodeDimensions(value, row, depth, expanded, bounds);
+    Rectangle d = null;
+    if (nodeDimensions != null)
+      d = nodeDimensions.getNodeDimensions(value, row, depth, expanded,
+                                          bounds);
+    return d;
   }
 
   /**
@@ -227,7 +226,12 @@ public abstract class AbstractLayoutCache
    */
   public void setSelectionModel(TreeSelectionModel model)
   {
+    if (treeSelectionModel != null)
+      treeSelectionModel.setRowMapper(null);
     treeSelectionModel = model;
+    if (treeSelectionModel != null)
+      treeSelectionModel.setRowMapper(this);
+    
   }
 
   /**
@@ -275,7 +279,7 @@ public abstract class AbstractLayoutCache
     for (int i = 0; i < n; i++)
       {
         TreePath path = getPathForRow(i);
-        r.setBounds(0,0,0,0);        
+        r.setBounds(0, 0, 0, 0);        
         r = getBounds(path, r);
         if (r.x + r.width > maximalWidth)
           maximalWidth = r.x + r.width;
@@ -340,7 +344,7 @@ public abstract class AbstractLayoutCache
    * 
    * @return Enumeration
    */
-  public abstract Enumeration getVisiblePathsFrom(TreePath path);
+  public abstract Enumeration<TreePath> getVisiblePathsFrom(TreePath path);
 
   /**
    * getVisibleChildCount
@@ -428,9 +432,13 @@ public abstract class AbstractLayoutCache
    */
   public int[] getRowsForPaths(TreePath[] paths)
   {
-    int[] rows = new int[paths.length];
-    for (int i = 0; i < rows.length; i++)
-      rows[i] = getRowForPath(paths[i]);
+    int[] rows = null;
+    if (paths != null)
+      {
+        rows = new int[paths.length];
+        for (int i = 0; i < rows.length; i++)
+          rows[i] = getRowForPath(paths[i]);
+      }
     return rows;
   }
 
@@ -443,6 +451,6 @@ public abstract class AbstractLayoutCache
    */
   protected boolean isFixedRowHeight()
   {
-    return false; 
+    return rowHeight > 0;
   }
 }