| 523 | } |
| 524 | |
| 525 | DefaultTreeModel makeTreeModel( Collection packages ) |
| 526 | { |
| 527 | Map packageTree = new HashMap(); |
| 528 | |
| 529 | Iterator it=packages.iterator(); |
| 530 | while( it.hasNext() ) { |
| 531 | String pack = (String)(it.next()); |
| 532 | String [] sa = StringUtil.split( pack, "." ); |
| 533 | Map level=packageTree; |
| 534 | for (int i=0; i< sa.length; i++ ) { |
| 535 | String name = sa[i]; |
| 536 | Map map=(Map)level.get( name ); |
| 537 | |
| 538 | if ( map == null ) { |
| 539 | map=new HashMap(); |
| 540 | level.put( name, map ); |
| 541 | } |
| 542 | level = map; |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | root = makeNode( packageTree, "root" ); |
| 547 | mapNodes(root); |
| 548 | return new DefaultTreeModel( root ); |
| 549 | } |
| 550 | |
| 551 | |
| 552 | MutableTreeNode makeNode( Map map, String nodeName ) |