Search in sources :

Example 6 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class SimpleSQLResultView method createColumns.

private void createColumns(List<TableModelDVO> columns) {
    ObservableList<TableColumn<Map<String, Object>, ?>> tableColumns = tbResult.getColumns();
    for (TableModelDVO column : columns) {
        String databaseColumnName = column.getDatabaseColumnName();
        TableColumn e = new TableColumn(databaseColumnName);
        e.setCellValueFactory(new MapValueFactory<Object>(databaseColumnName));
        tableColumns.add(e);
    }
}
Also used : TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) TableColumn(javafx.scene.control.TableColumn)

Example 7 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class MergedTableViewExam method start.

/**
	 * @inheritDoc
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    MergedTableView<String> root = new MergedTableView<>();
    TableColumn<String, String> e = new TableColumn<>("sample");
    e.setCellValueFactory(param -> {
        String value = param.getValue();
        return new SimpleStringProperty(value);
    });
    e.setCellFactory(MergedTextFieldTableCell.forTableColumn());
    root.getColumns().add(e);
    Random random = new Random(10);
    for (int i = 0; i < 100; i++) {
        root.getItems().add(String.valueOf(random.nextInt(10)));
    }
    //		
    primaryStage.setScene(new Scene(root));
    primaryStage.show();
}
Also used : Random(java.util.Random) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) MergedTableView(com.kyj.fx.voeditor.visual.component.grid.MergedTableView)

Example 8 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class FxExcelUtil method getDataSource.

/**
	 * UI 및 TableView로부터 Excel데이터생성을 위한 체계화된 데이터 
	 * LinkedHashMap객체를 리턴.
	 * @작성자 : KYJ
	 * @작성일 : 2016. 9. 7. 
	 * @param screen
	 * @param table
	 * @param allColumnsList 
	 *    계층형 테이블컬럼들을 일렬로 찾아낸 리스트
	 * @return
	 */
@SuppressWarnings({ "rawtypes" })
static /**
	 * UI 및 TableView로부터 Excel데이터생성을 위한 체계화된 데이터 
	 * @작성자 : KYJ
	 * @작성일 : 2016. 9. 19. 
	 * @param mapper
	 * @param table
	 * @param allColumnsList
	 * @return
	 */
LinkedHashMap<ExcelColumnExpression, List<Object>> getDataSource(IExcelScreenHandler mapper, TableView table, ArrayList<ExcelColumnExpression> allColumnsList) {
    LinkedHashMap<ExcelColumnExpression, List<Object>> dataSet = new LinkedHashMap<>();
    //ExcelColumnExpression :: 계층형 테이블컬럼들을 일렬로 찾아낸 리스트
    //		List<ExcelColumnExpression> allColumnsList = new ArrayList<ExcelColumnExpression>();
    @SuppressWarnings("unchecked") ObservableList<TableColumn> items = table.getItems();
    int size = items.size();
    //특화 헤더를 매핑.
    for (ExcelColumnExpression c : allColumnsList) {
        //			if (!c.isVisible())
        //				continue;
        String columnHeaderMapper = mapper.columnHeaderMapper(table, c.getTableColumn());
        c.setDisplayText(columnHeaderMapper);
        List<Object> values = new ArrayList<Object>();
        int columnIndex = c.getIndex();
        for (int rowIndex = 0; rowIndex < size; rowIndex++) {
            Object userValue = mapper.valueMapper(table, c.getTableColumn(), columnIndex, rowIndex);
            values.add(userValue);
        }
        dataSet.put(c, values);
    }
    return dataSet;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) TableColumn(javafx.scene.control.TableColumn) ExcelColumnExpression(com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression) LinkedHashMap(java.util.LinkedHashMap)

Example 9 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class FxExcelUtil method createExcel.

/**
	 * @작성자 : KYJ
	 * @작성일 : 2016. 9. 7. 
	 * @param screen
	 * @param exportExcelFile
	 * @param tableViewList
	 * @param overrite
	 * @throws Exception
	 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void createExcel(IExcelScreenHandler screen, File exportExcelFile, List<TableView> tableViewList, boolean overrite) throws Exception {
    IExcelScreenHandler screenHandler = screen;
    /*
		 * Key : Sheet
		 * Value - Key :  ExcelColumnExpression
		 * Value - Value :  Object
		 */
    LinkedHashMap<String, LinkedHashMap<ExcelColumnExpression, List<Object>>> dataSet = new LinkedHashMap<>();
    Map<String, Map<String, String>> metadata = new HashMap<>();
    int sheetIndex = 0;
    for (TableView table : tableViewList) {
        Predicate<TableView<?>> useTableViewForExcel = screenHandler.useTableViewForExcel();
        if (useTableViewForExcel != null) {
            if (!useTableViewForExcel.test(table)) {
                continue;
            }
        }
        //Sheet.
        String sheetName = screenHandler.toSheetName(table);
        if (sheetName == null) {
            sheetName = String.format(DEFAULT_SHEET_NAME_FORMAT, sheetIndex++);
        }
        ObservableList<TableColumn> columns = table.getColumns();
        //계층형 테이블컬럼의 모든 값을 찾아냄.
        ArrayList<ExcelColumnExpression> allColumnsList = new ArrayList<ExcelColumnExpression>();
        int maxLevel = getMaxLevel(columns, /*ExcelColumnExpression :: 계층형 테이블컬럼들을 일렬로 찾아낸 리스트 */
        allColumnsList, screenHandler.useTableColumnForExcel());
        dataSet.put(sheetName, getDataSource(screen, table, allColumnsList));
        HashMap<String, String> meta = new HashMap<String, String>();
        meta.put($$META_COLUMN_MAX_HEIGHT$$, String.valueOf(maxLevel));
        metadata.put(sheetName, meta);
    }
    if (dataSet.isEmpty())
        dataSet.put("empty", new LinkedHashMap<>());
    createExcel(screenHandler, exportExcelFile, dataSet, metadata, overrite);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IExcelScreenHandler(com.kyj.fx.voeditor.visual.framework.excel.IExcelScreenHandler) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) ExcelColumnExpression(com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TableView(javafx.scene.control.TableView)

Example 10 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class FxTableViewUtil method installPasteClipboard.

public static <K> void installPasteClipboard(TableView<K> tb, Class<K> clazz, Field targetField) {
    tb.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
        if (e.isControlDown() && e.getCode() == KeyCode.V) {
            Clipboard clip = Clipboard.getSystemClipboard();
            ObservableList<TableColumn<K, ?>> columns = tb.getColumns();
            if (columns.isEmpty())
                return;
            Object value = null;
            if (clip.hasFiles()) {
                value = clip.getFiles();
            } else if (clip.hasHtml()) {
                value = clip.getHtml();
            } else if (clip.hasImage()) {
                value = clip.getImage();
            } else if (clip.hasRtf()) {
                value = clip.getRtf();
            } else if (clip.hasString()) {
                value = clip.getString();
            } else if (clip.hasUrl()) {
                value = clip.getUrl();
            }
            if (value == null)
                return;
            try {
                K newInstance = clazz.newInstance();
                Field field = clazz.getField(targetField.getName());
                if (field != null) {
                    if (!field.isAccessible())
                        field.setAccessible(true);
                    field.set(newInstance, value);
                }
                tb.getItems().add(newInstance);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
}
Also used : Field(java.lang.reflect.Field) Clipboard(javafx.scene.input.Clipboard) TableColumn(javafx.scene.control.TableColumn)

Aggregations

TableColumn (javafx.scene.control.TableColumn)40 TableView (javafx.scene.control.TableView)13 BigDecimal (java.math.BigDecimal)11 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)10 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)9 LocalDate (java.time.LocalDate)8 Map (java.util.Map)8 Scene (javafx.scene.Scene)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 BorderPane (javafx.scene.layout.BorderPane)7 List (java.util.List)6 FXML (javafx.fxml.FXML)5 TableCell (javafx.scene.control.TableCell)5 ObjectProperty (javafx.beans.property.ObjectProperty)4 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)4 ObservableValue (javafx.beans.value.ObservableValue)4 ObservableList (javafx.collections.ObservableList)4 Button (javafx.scene.control.Button)4 SelectionMode (javafx.scene.control.SelectionMode)4