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);
}
}
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();
}
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;
}
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);
}
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();
}
}
});
}
Aggregations