/[classpath]/classpath/javax/swing/plaf/basic/BasicTreeUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicTreeUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.94 by roehrijn, Thu Oct 13 16:40:33 2005 UTC revision 1.95 by langel, Thu Oct 13 19:34:08 2005 UTC
# Line 229  public class BasicTreeUI Line 229  public class BasicTreeUI
229    /** Set to true if the editor has a different size than the renderer. */    /** Set to true if the editor has a different size than the renderer. */
230    protected boolean editorHasDifferentSize;    protected boolean editorHasDifferentSize;
231    
232      /** Leaf icon for the tree. */
233      Icon leafIcon;
234      
235    /** The action listener for the editor's Timer. */    /** The action listener for the editor's Timer. */
236    Timer editorTimer = new EditorUpdateTimer();    Timer editorTimer = new EditorUpdateTimer();
237    
# Line 281  public class BasicTreeUI Line 284  public class BasicTreeUI
284    
285      editingRow = -1;      editingRow = -1;
286      lastSelectedRow = -1;      lastSelectedRow = -1;
287        leafIcon = UIManager.getIcon("Tree.leafIcon");
288    }    }
289    
290    /**    /**
# Line 1209  public class BasicTreeUI Line 1213  public class BasicTreeUI
1213      setRowHeight(UIManager.getInt("Tree.rowHeight"));      setRowHeight(UIManager.getInt("Tree.rowHeight"));
1214      tree.requestFocusInWindow(false);      tree.requestFocusInWindow(false);
1215      tree.setScrollsOnExpand(UIManager.getBoolean("Tree.scrollsOnExpand"));      tree.setScrollsOnExpand(UIManager.getBoolean("Tree.scrollsOnExpand"));
1216      setExpandedIcon(UIManager.getIcon("Tree.expandedIcon"));      setExpandedIcon(UIManager.getIcon("Tree.openIcon"));
1217      setCollapsedIcon(UIManager.getIcon("Tree.collapsedIcon"));      setCollapsedIcon(UIManager.getIcon("Tree.closedIcon"));
1218    }    }
1219    
1220    /**    /**
# Line 1320  public class BasicTreeUI Line 1324  public class BasicTreeUI
1324      tree = (JTree) c;      tree = (JTree) c;
1325      prepareForUIInstall();      prepareForUIInstall();
1326      super.installUI(c);      super.installUI(c);
   
1327      installDefaults();      installDefaults();
1328    
1329      installComponents();      installComponents();
1330    
1331      setCellEditor(createDefaultCellEditor());      setCellEditor(createDefaultCellEditor());
# Line 1475  public class BasicTreeUI Line 1479  public class BasicTreeUI
1479    {    {
1480      // FIXME: checkConsistancy not implemented, c not used      // FIXME: checkConsistancy not implemented, c not used
1481      int maxWidth = 0;      int maxWidth = 0;
1482      int iconWidth = 0;      boolean isLeaf = false;
1483      if (currentVisiblePath != null)      if (currentVisiblePath != null)
1484        {        {
1485          Object[] path = currentVisiblePath.getPath();          Object[] path = currentVisiblePath.getPath();
# Line 1483  public class BasicTreeUI Line 1487  public class BasicTreeUI
1487            {            {
1488              TreePath curr = new TreePath(getPathToRoot(path[i], 0));              TreePath curr = new TreePath(getPathToRoot(path[i], 0));
1489              Rectangle bounds = getPathBounds(tree,              Rectangle bounds = getPathBounds(tree,
1490                          curr);                          curr);  
1491              iconWidth = 0;              if (treeModel != null)
1492                  isLeaf = treeModel.isLeaf(curr);
1493              if (hasControlIcons())              if (hasControlIcons())
1494                iconWidth = getCurrentControlIcon(curr).getIconWidth();                bounds.width += getCurrentControlIcon(curr).getIconWidth();
1495              maxWidth = Math.max(maxWidth, bounds.x + bounds.width              maxWidth = Math.max(maxWidth, bounds.x + bounds.width);
                                 + iconWidth);  
1496            }            }
1497          return new Dimension(maxWidth, (getRowHeight() * path.length));          return new Dimension(maxWidth, (getRowHeight() * path.length));
1498        }        }
# Line 1616  public class BasicTreeUI Line 1620  public class BasicTreeUI
1620          editingComponent.getParent().validate();          editingComponent.getParent().validate();
1621          tree.add(editingComponent.getParent());          tree.add(editingComponent.getParent());
1622          editingComponent.getParent().validate();          editingComponent.getParent().validate();
1623            tree.revalidate();
1624          ((JTextField) editingComponent).requestFocusInWindow(false);          ((JTextField) editingComponent).requestFocusInWindow(false);
1625          editorTimer.start();          editorTimer.start();
1626          return true;          return true;
# Line 2058  public class BasicTreeUI Line 2063  public class BasicTreeUI
2063        isEditing = false;        isEditing = false;
2064        tree.requestFocusInWindow(false);        tree.requestFocusInWindow(false);
2065        editorTimer.stop();        editorTimer.stop();
2066          tree.revalidate();
2067          tree.repaint();
2068      }      }
2069    
2070      /**      /**
# Line 2086  public class BasicTreeUI Line 2093  public class BasicTreeUI
2093        tree.requestFocusInWindow(false);        tree.requestFocusInWindow(false);
2094        editorTimer.stop();        editorTimer.stop();
2095        isEditing = false;        isEditing = false;
2096          tree.revalidate();
2097        tree.repaint();        tree.repaint();
2098      }      }
2099    }// CellEditorHandler    }// CellEditorHandler
# Line 2299  public class BasicTreeUI Line 2307  public class BasicTreeUI
2307                        
2308            if (isLeaf(row))            if (isLeaf(row))
2309                bounds.width += rightChildIndent + 4;                bounds.width += rightChildIndent + 4;
2310            else if (tree.isExpanded(path) && expandedIcon != null)            else if (hasControlIcons())
2311                bounds.width += expandedIcon.getIconWidth() + 4;              bounds.width += getCurrentControlIcon(path).getIconWidth() + 4;
           else if (collapsedIcon != null)  
               bounds.width += collapsedIcon.getIconWidth() + 4;  
2312    
2313            boolean inBounds = bounds.contains(click.x, click.y);            boolean inBounds = bounds.contains(click.x, click.y);
2314            if ((inBounds || cntlClick) && tree.isVisible(path))            if ((inBounds || cntlClick) && tree.isVisible(path))
# Line 3070  public class BasicTreeUI Line 3076  public class BasicTreeUI
3076      Rectangle bounds = getPathBounds(tree, path);      Rectangle bounds = getPathBounds(tree, path);
3077      Object root = mod.getRoot();      Object root = mod.getRoot();
3078      int iconWidth = 0;      int iconWidth = 0;
3079      if (hasControlIcons())      if (!isLeaf && hasControlIcons())
3080        iconWidth = getCurrentControlIcon(path).getIconWidth();              iconWidth += getCurrentControlIcon(path).getIconWidth();
3081        bounds.width += bounds.x + iconWidth;
3082            
3083      if (isLeaf)      if (isLeaf)
3084        {        {
         bounds.width += bounds.x;  
3085          paintRow(g, clip, null, bounds, path, row, true, false, true);          paintRow(g, clip, null, bounds, path, row, true, false, true);
3086          descent += getRowHeight();          descent += getRowHeight();
3087        }        }
3088      else      else
3089        {        {
         bounds.width += bounds.x + iconWidth;  
3090          if (depth > 0 || isRootVisible)          if (depth > 0 || isRootVisible)
3091            {            {
3092              paintRow(g, clip, null, bounds, path, row, isExpanded, false, false);              paintRow(g, clip, null, bounds, path, row, isExpanded, false, false);
# Line 3659  public class BasicTreeUI Line 3664  public class BasicTreeUI
3664        {        {
3665          if (editingComponent != null && editingPath != null && isEditing(tree)          if (editingComponent != null && editingPath != null && isEditing(tree)
3666              && node.equals(editingPath.getLastPathComponent()))              && node.equals(editingPath.getLastPathComponent()))
3667            {            {    
             if (hasControlIcons())  
               bounds.x += getCurrentControlIcon(path).getIconWidth() - 5;  
             bounds.width = editingComponent.getSize().width + bounds.x;  
3668              rendererPane.paintComponent(g, editingComponent.getParent(), null,              rendererPane.paintComponent(g, editingComponent.getParent(), null,
3669                                          bounds);                                          bounds);
3670            }            }
# Line 3671  public class BasicTreeUI Line 3673  public class BasicTreeUI
3673              TreeCellRenderer dtcr = tree.getCellRenderer();              TreeCellRenderer dtcr = tree.getCellRenderer();
3674              if (dtcr == null)              if (dtcr == null)
3675                dtcr = createDefaultCellRenderer();                dtcr = createDefaultCellRenderer();
   
3676              Component c = dtcr.getTreeCellRendererComponent(tree, node,              Component c = dtcr.getTreeCellRendererComponent(tree, node,
3677                                                              selected, isExpanded,                                       selected, isExpanded, isLeaf, row, false);
                                                             isLeaf, row, false);  
             // add padding between line and node  
3678              bounds.x += 4;              bounds.x += 4;
3679              rendererPane.paintComponent(g, c, c.getParent(), bounds);              rendererPane.paintComponent(g, c, c.getParent(), bounds);
3680            }            }

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.95

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26