< prev index next >

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

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


1313                 JTable table = (JTable)c;
1314                 int[] rows = table.getSelectedRows();
1315                 if (rows != null) {
1316                     values = new Object[rows.length];
1317                     for (int i=0; i<rows.length; i++) {
1318                         values[i] = table.getValueAt(rows[i], 0);
1319                     }
1320                 }
1321             }
1322             if (values == null || values.length == 0) {
1323                 return null;
1324             }
1325 
1326             StringBuilder plainBuf = new StringBuilder();
1327             StringBuilder htmlBuf = new StringBuilder();
1328 
1329             htmlBuf.append("<html>\n<body>\n<ul>\n");
1330 
1331             for (Object obj : values) {
1332                 String val = ((obj == null) ? "" : obj.toString());
1333                 plainBuf.append(val + "\n");
1334                 htmlBuf.append("  <li>" + val + "\n");
1335             }
1336 
1337             // remove the last newline
1338             plainBuf.deleteCharAt(plainBuf.length() - 1);
1339             htmlBuf.append("</ul>\n</body>\n</html>");
1340 
1341             return new FileTransferable(plainBuf.toString(), htmlBuf.toString(), values);
1342         }
1343 
1344         public int getSourceActions(JComponent c) {
1345             return COPY;
1346         }
1347 
1348         static class FileTransferable extends BasicTransferable {
1349 
1350             Object[] fileData;
1351 
1352             FileTransferable(String plainData, String htmlData, Object[] fileData) {
1353                 super(plainData, htmlData);
1354                 this.fileData = fileData;




1313                 JTable table = (JTable)c;
1314                 int[] rows = table.getSelectedRows();
1315                 if (rows != null) {
1316                     values = new Object[rows.length];
1317                     for (int i=0; i<rows.length; i++) {
1318                         values[i] = table.getValueAt(rows[i], 0);
1319                     }
1320                 }
1321             }
1322             if (values == null || values.length == 0) {
1323                 return null;
1324             }
1325 
1326             StringBuilder plainBuf = new StringBuilder();
1327             StringBuilder htmlBuf = new StringBuilder();
1328 
1329             htmlBuf.append("<html>\n<body>\n<ul>\n");
1330 
1331             for (Object obj : values) {
1332                 String val = ((obj == null) ? "" : obj.toString());
1333                 plainBuf.append(val).append('\n');
1334                 htmlBuf.append("  <li>").append(val).append('\n');
1335             }
1336 
1337             // remove the last newline
1338             plainBuf.deleteCharAt(plainBuf.length() - 1);
1339             htmlBuf.append("</ul>\n</body>\n</html>");
1340 
1341             return new FileTransferable(plainBuf.toString(), htmlBuf.toString(), values);
1342         }
1343 
1344         public int getSourceActions(JComponent c) {
1345             return COPY;
1346         }
1347 
1348         static class FileTransferable extends BasicTransferable {
1349 
1350             Object[] fileData;
1351 
1352             FileTransferable(String plainData, String htmlData, Object[] fileData) {
1353                 super(plainData, htmlData);
1354                 this.fileData = fileData;


< prev index next >