Пример #1
0
 public String getHtml(TreeItem items[]) throws XViewerException {
   StringBuffer sb = new StringBuffer("<html><body>"); // $NON-NLS-1$
   sb.append(HtmlUtil.beginMultiColumnTable(100, 1));
   List<XViewerColumn> columns = xViewer.getCustomizeMgr().getCurrentTableColumnsInOrder();
   List<String> headerStrs = new ArrayList<String>(50);
   List<XViewerColumn> showCols = new ArrayList<XViewerColumn>(50);
   xColToColumnIndex = xViewer.getCustomizeMgr().getCurrentTableColumnsIndex();
   for (XViewerColumn xCol : columns) {
     if (xCol.isShow()) {
       showCols.add(xCol);
       headerStrs.add(xCol.getName());
     }
   }
   sb.append(
       HtmlUtil.addHeaderRowMultiColumnTable(headerStrs.toArray(new String[headerStrs.size()])));
   // Get column widths and column name and setup the columns
   IXViewerLabelProvider labelProv = (IXViewerLabelProvider) xViewer.getLabelProvider();
   ArrayList<String[]> list = new ArrayList<String[]>();
   for (TreeItem item : items) {
     addRow(item, list, labelProv, showCols, 1);
   }
   for (String[] strs : list) {
     sb.append(HtmlUtil.addRowMultiColumnTable(strs));
   }
   sb.append(HtmlUtil.endMultiColumnTable());
   sb.append("</body></html>"); // $NON-NLS-1$
   return sb.toString();
 }
Пример #2
0
 private void addRow(
     TreeItem item,
     List<String[]> rowData,
     IXViewerLabelProvider labelProv,
     List<XViewerColumn> showCols,
     int level)
     throws XViewerException {
   List<String> cellData = new ArrayList<String>(showCols.size());
   boolean firstCell = true;
   for (XViewerColumn xCol : showCols) {
     StringBuffer str = new StringBuffer();
     if (firstCell) {
       for (int y = 1; y < level; y++) {
         str.append("__INSERT_TAB_HERE__"); // $NON-NLS-1$
       }
       firstCell = false;
     }
     str.append(labelProv.getColumnText(item.getData(), xColToColumnIndex.get(xCol)));
     String html = HtmlUtil.textToHtml(str.toString());
     html =
         html.replaceAll(
             "__INSERT_TAB_HERE__", "&nbsp;&nbsp;&nbsp;&nbsp;"); // $NON-NLS-1$ //$NON-NLS-2$
     cellData.add(html);
   }
   rowData.add(cellData.toArray(new String[cellData.size()]));
   if (item.getExpanded()) {
     for (TreeItem i : item.getItems()) {
       addRow(i, rowData, labelProv, showCols, level + 1);
     }
   }
 }