use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class BaseColumnMapper method generateTableColumns.
/**
* 컬럼 제너레이터
*
* @Date 2015. 10. 8.
* @param classType
* @return
* @User KYJ
*/
@Override
public TableColumn<T, ?> generateTableColumns(Class<?> classType, String columnName, IOptions options) {
TableColumn tableColumn = new TableColumn<>();
// 2015.11.18 커스텀 컬럼은 cellFactory를 가져다 쓰지않음.
tableColumn.setCellFactory(cell -> {
TextFieldTableCell<T, Object> textFieldTableCell = new TextFieldTableCell<>();
textFieldTableCell.setConverter(converter(classType));
return textFieldTableCell;
});
// 2015.11.18 커스텀 컬럼값을 정의한경우 대체.
TableColumn<T, ?> customTableColumn = options.customTableColumn(columnName);
if (customTableColumn != null) {
tableColumn = customTableColumn;
}
// 2015.11.18 커스텀 컬럼은 ValueFactory는 기본적으로 사용
PropertyValueFactory<T, ?> value = new PropertyValueFactory<>(columnName);
tableColumn.setCellValueFactory(value);
tableColumn.setId(columnName);
// 컬럼의 속성을 정의
setColumnProperty(tableColumn, columnName, options);
tableColumn.setResizable(true);
tableColumn.setEditable(false);
tableColumn.setVisible(options.visible(columnName));
return tableColumn;
}
use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class MacroControl method tbResultOnKeyReleased.
public void tbResultOnKeyReleased() {
Skin<?> skin = this.getSkin();
if (!(skin instanceof MacroBaseSkin)) {
return;
}
MacroBaseSkin mskin = (MacroBaseSkin) skin;
TableView<Map<String, String>> tbResult = mskin.getTbResult();
int type = 1;
ObservableList<TablePosition> selectedCells = tbResult.getSelectionModel().getSelectedCells();
TablePosition tablePosition = selectedCells.get(0);
TableColumn tableColumn = tablePosition.getTableColumn();
int row = tablePosition.getRow();
int col = tbResult.getColumns().indexOf(tableColumn);
switch(type) {
case 1:
StringBuilder sb = new StringBuilder();
for (TablePosition cell : selectedCells) {
// 행변경시
if (row != cell.getRow()) {
sb.append("\n");
row++;
} else // 열 변경시
if (col != tbResult.getColumns().indexOf(cell.getTableColumn())) {
sb.append("\t");
}
Object cellData = cell.getTableColumn().getCellData(cell.getRow());
sb.append(ValueUtil.decode(cellData, cellData, "").toString());
}
FxClipboardUtil.putString(sb.toString());
break;
case 2:
Object cellData = tableColumn.getCellData(row);
FxClipboardUtil.putString(ValueUtil.decode(cellData, cellData, "").toString());
break;
}
}
use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class FxTableViewUtil method installCopyHandler.
@SuppressWarnings("rawtypes")
public static void installCopyHandler(TableView<?> table) {
table.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
if (e.isConsumed())
return;
int type = -1;
if (e.isControlDown() && e.getCode() == KeyCode.C) {
if (e.isShiftDown()) {
type = 2;
} else {
type = 1;
}
}
if (type == -1)
return;
TableViewSelectionModel<?> selectionModel = table.getSelectionModel();
SelectionMode selectionMode = selectionModel.getSelectionMode();
boolean cellSelectionEnabled = selectionModel.isCellSelectionEnabled();
if (!cellSelectionEnabled) {
Object selectedItem = table.getSelectionModel().getSelectedItem();
ObservableList<?> columns = table.getColumns();
Optional<String> reduce = columns.stream().filter(ob -> ob instanceof TableColumn).map(obj -> (TableColumn) obj).map(tc -> tc.getCellData(selectedItem)).filter(v -> v != null).map(v -> v.toString()).reduce((o1, o2) -> o1.toString().concat("\t").concat(o2.toString()));
reduce.ifPresent(str -> {
FxClipboardUtil.putString(str);
e.consume();
});
} else if (cellSelectionEnabled) {
ObservableList<TablePosition> selectedCells = selectionModel.getSelectedCells();
TablePosition tablePosition = selectedCells.get(0);
TableColumn tableColumn = tablePosition.getTableColumn();
int row = tablePosition.getRow();
int col = table.getColumns().indexOf(tableColumn);
switch(type) {
case 1:
StringBuilder sb = new StringBuilder();
for (TablePosition cell : selectedCells) {
if (row != cell.getRow()) {
sb.append("\n");
row++;
} else if (col != table.getColumns().indexOf(cell.getTableColumn())) {
sb.append("\t");
}
Object cellData = cell.getTableColumn().getCellData(cell.getRow());
sb.append(ValueUtil.decode(cellData, cellData, "").toString());
}
FxClipboardUtil.putString(sb.toString());
e.consume();
break;
case 2:
Object cellData = tableColumn.getCellData(row);
FxClipboardUtil.putString(ValueUtil.decode(cellData, cellData, "").toString());
e.consume();
break;
}
}
});
}
use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class FxTableViewUtil method installCopyPasteHandler.
/********************************
* 작성일 : 2016. 5. 12. 작성자 : KYJ
*
* 테이블뷰 클립보드 기능.
*
* @Deprecated COPY 기능과 PASTE 기능을 분리.
* installCopyHandler 사용할것
* @param table
********************************/
@SuppressWarnings("rawtypes")
@Deprecated
public static void installCopyPasteHandler(TableView<?> table) {
table.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
if (e.isConsumed())
return;
int type = -1;
if (e.isControlDown() && e.getCode() == KeyCode.C) {
if (e.isShiftDown()) {
type = 2;
} else {
type = 1;
}
}
if (type == -1)
return;
ObservableList<TablePosition> selectedCells = table.getSelectionModel().getSelectedCells();
TablePosition tablePosition = selectedCells.get(0);
TableColumn tableColumn = tablePosition.getTableColumn();
int row = tablePosition.getRow();
int col = table.getColumns().indexOf(tableColumn);
switch(type) {
case 1:
StringBuilder sb = new StringBuilder();
for (TablePosition cell : selectedCells) {
if (row != cell.getRow()) {
sb.append("\n");
row++;
} else if (col != table.getColumns().indexOf(cell.getTableColumn())) {
sb.append("\t");
}
Object cellData = cell.getTableColumn().getCellData(cell.getRow());
sb.append(ValueUtil.decode(cellData, cellData, "").toString());
}
FxClipboardUtil.putString(sb.toString());
e.consume();
break;
case 2:
Object cellData = tableColumn.getCellData(row);
FxClipboardUtil.putString(ValueUtil.decode(cellData, cellData, "").toString());
e.consume();
break;
}
});
}
use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class FxExcelUtil method getMaxLevel.
/**
* 다중헤더를 갖는 컬럼의 가장 높은 크기를 리턴하는 함수 +
* List<ExcelColumnExpression>배열에 헤더순서대로 값을 input해줌.
*
* @작성자 : KYJ
* @작성일 : 2016. 9. 7.
* @param columns
* @param allColumnsList
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private static int getMaxLevel(ObservableList<TableColumn> columns, List<ExcelColumnExpression> allColumnsList, ITableColumnForExcel use) {
int maxLevel = 0;
int SIZE = columns.size();
for (int i = 0; i < SIZE; i++) {
TableColumn col = columns.get(i);
if (!col.isVisible())
continue;
int level = appendAllColumns(null, allColumnsList, col, /*시작은 0레벨부터.*/
HEADER_ROW_INDEX, use);
if (maxLevel < level)
maxLevel = level;
}
return maxLevel;
}
Aggregations