Search in sources :

Example 6 with ExcelColumnExpression

use of com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression in project Gargoyle by callakrsos.

the class FxExcelUtil method appendAllColumns.

/**
	 * 테이블뷰의 모든 컬럼을 찾기위한 재귀함수.
	 * 
	 * (( 설마 테이블컬럼이 무한대로 있는 화면은 없겠지. ))
	 * @작성자 : KYJ
	 * @작성일 : 2016. 9. 6. 
	 * @param parent 계층형 컬럼의 부모를 가리킴.
	 * @param pocket 컬럼이 일렬로 저정된다.
	 * @param index 트리레벨을 가리킴. 다른말로하면 컬럼의 순서를 가리킴.
	 * @param col
	 * @param level 계층형 컬럼의 현재 레벨을 가리킴.
	 * @param use 엑셀처리에 사용할 컬럼인지 처리여부
	 * @return 가장 Depth가 긴 레벨을 리턴.
	 */
static <T> int appendAllColumns(ExcelColumnExpression parent, List<ExcelColumnExpression> pocket, TableColumn<T, ?> col, int level, ITableColumnForExcel use) {
    int maxLevel = level;
    int myLevel = level;
    if (col == null)
        /*|| !col.isVisible()*/
        return maxLevel;
    if (use != null) {
        boolean test = use.test(col.getTableView(), col);
        if (!test)
            return maxLevel;
    }
    ExcelColumnExpression columnExpr = new ExcelColumnExpression();
    String text = ValueUtil.isEmpty(col.getText()) ? "-" : col.getText();
    boolean visible = col.isVisible();
    double width = col.getWidth();
    columnExpr.setRealText(text);
    columnExpr.setTableColumn(col);
    columnExpr.setIndex(pocket.isEmpty() ? 0 : pocket.get(pocket.size() - 1).getIndex() + 1);
    columnExpr.setLevel(myLevel);
    columnExpr.setVisible(visible);
    columnExpr.setParent(parent);
    LOGGER.debug("col : {} , isVisible : {} , level : {}, width : {} ", text, col.isVisible(), myLevel, width);
    pocket.add(columnExpr);
    if (parent != null) {
        parent.getChildrens().add(columnExpr);
    }
    List<TableColumn<T, ?>> columns = col.getColumns();
    if (columns == null || columns.isEmpty()) {
        return maxLevel;
    } else {
        int visibledColumnCount = 0;
        for (int i = 0; i < columns.size(); i++) {
            TableColumn<T, ?> subCol = columns.get(i);
            if (use.test(subCol.getTableView(), subCol)) {
                int _level = appendAllColumns(columnExpr, pocket, subCol, (myLevel + 1), use);
                if (maxLevel < _level)
                    maxLevel = _level;
                visibledColumnCount++;
            }
        }
        List<ExcelColumnExpression> subList = pocket.subList(pocket.size() - visibledColumnCount, pocket.size());
        //			if (parent != null) {
        //fix indexㅒ
        int idx = 0;
        for (ExcelColumnExpression c : subList) {
            //				if (c.isVisible()) {
            c.setIndex(columnExpr.getIndex() + idx);
            idx++;
        //				}
        }
        return maxLevel;
    }
}
Also used : TableColumn(javafx.scene.control.TableColumn) ExcelColumnExpression(com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression)

Aggregations

ExcelColumnExpression (com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression)6 ArrayList (java.util.ArrayList)4 TableColumn (javafx.scene.control.TableColumn)4 IExcelScreenHandler (com.kyj.fx.voeditor.visual.framework.excel.IExcelScreenHandler)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 ObservableList (javafx.collections.ObservableList)3 GargoyleException (com.kyj.fx.voeditor.visual.exceptions.GargoyleException)2 FileOutputStream (java.io.FileOutputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TableView (javafx.scene.control.TableView)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)2 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)2 DefautExcelDataSetHandler (com.kyj.fx.voeditor.visual.framework.excel.DefautExcelDataSetHandler)1 IExcelDataSetHandler (com.kyj.fx.voeditor.visual.framework.excel.IExcelDataSetHandler)1 ITableColumnForExcel (com.kyj.fx.voeditor.visual.framework.excel.ITableColumnForExcel)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1