< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java

Print this page
rev 10947 : 8055723: Replace concat String to append in StringBuilder parameters


3601                 TreePath[] paths = tree.getSelectionPaths();
3602 
3603                 if (paths == null || paths.length == 0) {
3604                     return null;
3605                 }
3606 
3607                 StringBuilder plainStr = new StringBuilder();
3608                 StringBuilder htmlStr = new StringBuilder();
3609 
3610                 htmlStr.append("<html>\n<body>\n<ul>\n");
3611 
3612                 TreeModel model = tree.getModel();
3613                 TreePath lastPath = null;
3614                 TreePath[] displayPaths = getDisplayOrderPaths(paths);
3615 
3616                 for (TreePath path : displayPaths) {
3617                     Object node = path.getLastPathComponent();
3618                     boolean leaf = model.isLeaf(node);
3619                     String label = getDisplayString(path, true, leaf);
3620 
3621                     plainStr.append(label + "\n");
3622                     htmlStr.append("  <li>" + label + "\n");
3623                 }
3624 
3625                 // remove the last newline
3626                 plainStr.deleteCharAt(plainStr.length() - 1);
3627                 htmlStr.append("</ul>\n</body>\n</html>");
3628 
3629                 tree = null;
3630 
3631                 return new BasicTransferable(plainStr.toString(), htmlStr.toString());
3632             }
3633 
3634             return null;
3635         }
3636 
3637         public int compare(TreePath o1, TreePath o2) {
3638             int row1 = tree.getRowForPath(o1);
3639             int row2 = tree.getRowForPath(o2);
3640             return row1 - row2;
3641         }
3642 




3601                 TreePath[] paths = tree.getSelectionPaths();
3602 
3603                 if (paths == null || paths.length == 0) {
3604                     return null;
3605                 }
3606 
3607                 StringBuilder plainStr = new StringBuilder();
3608                 StringBuilder htmlStr = new StringBuilder();
3609 
3610                 htmlStr.append("<html>\n<body>\n<ul>\n");
3611 
3612                 TreeModel model = tree.getModel();
3613                 TreePath lastPath = null;
3614                 TreePath[] displayPaths = getDisplayOrderPaths(paths);
3615 
3616                 for (TreePath path : displayPaths) {
3617                     Object node = path.getLastPathComponent();
3618                     boolean leaf = model.isLeaf(node);
3619                     String label = getDisplayString(path, true, leaf);
3620 
3621                     plainStr.append(label).append('\n');
3622                     htmlStr.append("  <li>").append(label).append('\n');
3623                 }
3624 
3625                 // remove the last newline
3626                 plainStr.deleteCharAt(plainStr.length() - 1);
3627                 htmlStr.append("</ul>\n</body>\n</html>");
3628 
3629                 tree = null;
3630 
3631                 return new BasicTransferable(plainStr.toString(), htmlStr.toString());
3632             }
3633 
3634             return null;
3635         }
3636 
3637         public int compare(TreePath o1, TreePath o2) {
3638             int row1 = tree.getRowForPath(o1);
3639             int row2 = tree.getRowForPath(o2);
3640             return row1 - row2;
3641         }
3642 


< prev index next >