/[classpath]/classpath/javax/swing/JTree.java
ViewVC logotype

Diff of /classpath/javax/swing/JTree.java

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

revision 1.14 by mkoch, Wed Dec 1 13:49:48 2004 UTC revision 1.15 by mkoch, Tue Dec 14 07:39:33 2004 UTC
# Line 1051  public class JTree extends JComponent Line 1051  public class JTree extends JComponent
1051            
1052      return 0;      return 0;
1053    }    }
1054      
1055      public void collapsePath(TreePath path)
1056      {
1057        setExpandedState(path, false);
1058      }
1059      
1060      public void collapseRow(int row)
1061      {
1062        if (row < 0 || row >= getRowCount())
1063          return;
1064    
1065        TreePath path = getPathForRow(row);
1066    
1067        if (path != null)
1068          collapsePath(path);
1069      }
1070    
1071      public void expandPath(TreePath path)
1072      {
1073        // Don't expand if last path component is a leaf node.
1074        if ((path == null)
1075            || (treeModel.isLeaf(path.getLastPathComponent())))
1076          return;
1077    
1078        setExpandedState(path, true);
1079      }
1080      
1081      public void expandRow(int row)
1082      {
1083        if (row < 0 || row >= getRowCount())
1084          return;
1085    
1086        TreePath path = getPathForRow(row);
1087    
1088        if (path != null)
1089          expandPath(path);
1090      }
1091    
1092    public boolean isCollapsed(TreePath path)    public boolean isCollapsed(TreePath path)
1093    {    {
# Line 1243  public class JTree extends JComponent Line 1280  public class JTree extends JComponent
1280      return null;      return null;
1281    }    }
1282    
1283      private void checkExpandParents(TreePath path)
1284        throws ExpandVetoException
1285      {
1286        TreePath parent = path.getParentPath();
1287    
1288        if (parent != null)
1289          checkExpandParents(parent);
1290    
1291        fireTreeWillExpand(path);
1292      }
1293    
1294      private void doExpandParents(TreePath path, boolean state)
1295      {
1296        TreePath parent = path.getParentPath();
1297    
1298        if (isExpanded(parent))
1299          return;
1300        
1301        if (parent != null)
1302          doExpandParents(parent, false);
1303    
1304        nodeStates.put(path, state ? EXPANDED : COLLAPSED);
1305      }
1306      
1307      protected void setExpandedState(TreePath path, boolean state)
1308      {
1309        if (path == null)
1310          return;
1311    
1312        TreePath parent = path.getParentPath();
1313    
1314        try
1315          {
1316            while (parent != null)
1317              checkExpandParents(parent);
1318          }
1319        catch (ExpandVetoException e)
1320          {
1321            // Expansion vetoed.
1322            return;
1323          }
1324    
1325        doExpandParents(path, state);
1326      }
1327    
1328    protected void clearToggledPaths()    protected void clearToggledPaths()
1329    {    {
1330      nodeStates.clear();      nodeStates.clear();
# Line 1288  public class JTree extends JComponent Line 1370  public class JTree extends JComponent
1370      return isExpanded(parent);      return isExpanded(parent);
1371    }    }
1372    
1373      public void makeVisible(TreePath path)
1374      {
1375        if (path == null)
1376          return;
1377    
1378        expandPath(path.getParentPath());
1379      }
1380    
1381    public boolean isPathEditable(TreePath path)    public boolean isPathEditable(TreePath path)
1382    {        {    
1383      return isEditable();      return isEditable();

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

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