/[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.79 by langel, Mon Sep 19 15:46:19 2005 UTC revision 1.80 by langel, Mon Sep 19 19:42:22 2005 UTC
# Line 678  public class BasicTreeUI Line 678  public class BasicTreeUI
678     */     */
679    public int getRowForPath(JTree tree, TreePath path)    public int getRowForPath(JTree tree, TreePath path)
680    {    {
681      int row = path.getPathCount();      int row = 0;
682      if (tree.isVisible(path))      Object dest = path.getLastPathComponent();
683        return row;      Object curr = treeModel.getRoot();
684        while (curr != null && !curr.equals(dest))
     path = path.getParentPath();  
     while (row > 0 && !tree.isVisible(path))  
685        {        {
686          path = path.getParentPath();          ++row;
687          row--;          curr = getNextVisibleNode(curr);
688        }        }
689      return row;      return row;
690    }    }
# Line 1616  public class BasicTreeUI Line 1614  public class BasicTreeUI
1614        {        {
1615          editingPath = path;          editingPath = path;
1616          editingRow = tree.getRowForPath(editingPath);          editingRow = tree.getRowForPath(editingPath);
1617    
1618          Object val = editingPath.getLastPathComponent();          Object val = editingPath.getLastPathComponent();
1619          cellEditor.addCellEditorListener(cellEditorListener);          cellEditor.addCellEditorListener(cellEditorListener);
1620          stopEditingInCompleteEditing = false;          stopEditingInCompleteEditing = false;
# Line 1674  public class BasicTreeUI Line 1673  public class BasicTreeUI
1673    {    {
1674      boolean cntlClick = false;      boolean cntlClick = false;
1675      int row = getRowForPath(tree, path);      int row = getRowForPath(tree, path);
1676        
1677      if (!isLeaf(row))      if (!isLeaf(row))
1678        {        {
1679          if (bounds == null)          if (bounds == null)
# Line 2305  public class BasicTreeUI Line 2305  public class BasicTreeUI
2305      public void mousePressed(MouseEvent e)      public void mousePressed(MouseEvent e)
2306      {      {
2307        Point click = e.getPoint();        Point click = e.getPoint();
       int row = Math.round(click.y / getRowHeight());  
2308        TreePath path = getClosestPathForLocation(tree, click.x, click.y);        TreePath path = getClosestPathForLocation(tree, click.x, click.y);
2309    
2310        if (path != null)        if (path != null)
2311          {          {
2312            bounds = getPathBounds(tree, path);            bounds = getPathBounds(tree, path);
2313              int row = getRowForPath(tree, path);
2314            boolean cntlClick = isLocationInExpandControl(path, click.x, click.y);            boolean cntlClick = isLocationInExpandControl(path, click.x, click.y);
2315                        
2316            if (tree.isExpanded(path) && expandedIcon != null)            if (isLeaf(row))
2317              {              {
2318                bounds.x -= expandedIcon.getIconWidth() - 4;                bounds.x -= rightChildIndent - 4;
2319                bounds.width += expandedIcon.getIconWidth() + 4;                bounds.width += rightChildIndent + 4;
2320              }              }
2321              else if (tree.isExpanded(path) && expandedIcon != null)
2322                  bounds.width += expandedIcon.getIconWidth() + 4;
2323            else if (collapsedIcon != null)            else if (collapsedIcon != null)
             {  
               bounds.x -= collapsedIcon.getIconWidth() - 4;  
2324                bounds.width += collapsedIcon.getIconWidth() + 4;                bounds.width += collapsedIcon.getIconWidth() + 4;
2325              }  
             
2326            boolean inBounds = bounds.contains(click.x, click.y);            boolean inBounds = bounds.contains(click.x, click.y);
2327            if ((inBounds || cntlClick) && tree.isVisible(path))            if ((inBounds || cntlClick) && tree.isVisible(path))
2328              {              {
# Line 2332  public class BasicTreeUI Line 2331  public class BasicTreeUI
2331                    toggleExpandState(path);                    toggleExpandState(path);
2332                                
2333                if (cntlClick)                if (cntlClick)
2334                  handleExpandControlClick(path, click.x, click.y);                  {
2335                      handleExpandControlClick(path, click.x, click.y);
2336                      if (cellEditor != null)
2337                        cellEditor.cancelCellEditing();
2338                    }
2339                else if (tree.isEditable())                else if (tree.isEditable())
2340                  startEditing(path, e);                  startEditing(path, e);
2341              }              }

Legend:
Removed from v.1.79  
changed lines
  Added in v.1.80

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