use of javafx.scene.control.TableView 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.TableView in project Gargoyle by callakrsos.
the class MacroBaseSkin method start.
/**
* Start 버튼을 클릭하면 결과가 리턴된다. param으로 입력받은 데이터는 textArea에서 적혀져있는 텍스트문자열.
*
* 2016-10-25 Skin클래스안으로 이동처리.
*
* @작성자 : KYJ
* @작성일 : 2016. 10. 25.
* @param tbResult
* @param param
* @throws Exception
*/
public void start(TableView<Map<String, String>> tbResult, String param) throws Exception {
Connection connection = getSkinnable().getConnectionSupplier().get();
tbResult.getItems().clear();
tbResult.getColumns().clear();
// try {
String[] split = param.split(";");
connection.setAutoCommit(false);
try {
for (String sql : split) {
String _sql = sql.trim();
if (_sql.isEmpty())
continue;
boolean dml = DbUtil.isDml(_sql);
if (dml) {
LOGGER.debug("do update : {}", _sql);
DbUtil.update(connection, _sql);
} else {
LOGGER.debug("do select : {}", _sql);
DbUtil.select(connection, _sql, 30, 1000, new BiFunction<ResultSetMetaData, ResultSet, List<Map<String, ObjectProperty<Object>>>>() {
@Override
public List<Map<String, ObjectProperty<Object>>> apply(ResultSetMetaData t, ResultSet rs) {
try {
int columnCount = t.getColumnCount();
for (int i = 1; i <= columnCount; i++) {
String columnName = t.getColumnName(i);
TableColumn<Map<String, String>, String> tbCol = new TableColumn<>(columnName);
tbCol.setCellFactory(new Callback<TableColumn<Map<String, String>, String>, TableCell<Map<String, String>, String>>() {
@Override
public TableCell<Map<String, String>, String> call(TableColumn<Map<String, String>, String> param) {
return new TableCell<Map<String, String>, String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setGraphic(null);
} else {
setGraphic(new Label(item));
}
}
};
}
});
tbCol.setCellValueFactory(param -> {
return new SimpleStringProperty(param.getValue().get(columnName));
});
tbResult.getColumns().add(tbCol);
}
while (rs.next()) {
Map<String, String> hashMap = new HashMap<>();
for (int i = 1; i <= columnCount; i++) {
String columnName = t.getColumnName(i);
String value = rs.getString(columnName);
hashMap.put(columnName, value);
}
tbResult.getItems().add(hashMap);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return Collections.emptyList();
}
});
}
}
connection.commit();
} catch (Exception e) {
connection.rollback();
throw new RuntimeException(e);
} finally {
DbUtil.close(connection);
}
}
use of javafx.scene.control.TableView in project Gargoyle by callakrsos.
the class SqlMultiplePane method addNewTabResult.
/********************************
* 작성일 : 2016. 4. 20. 작성자 : KYJ
*
*
* @return
********************************/
private Tab addNewTabResult() {
TableView<Map<String, Object>> tbResult = new TableView<>();
// Cell 단위로 선택
tbResult.getSelectionModel().setCellSelectionEnabled(true);
tbResult.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
tbResult.getItems().addListener((ListChangeListener<Map<String, Object>>) arg0 -> {
int size = arg0.getList().size();
lblStatus.textProperty().set(size + " row");
});
tbResult.setOnKeyPressed(this::tbResultOnKeyClick);
{
tcSelectRow = new TableColumn<>("↓");
tcSelectRow.setMaxWidth(20);
tcSelectRow.setSortable(false);
tcSelectRow.setCellFactory(cell -> {
return new DragSelectionCell(tbResult);
});
// Table Select Drag 처리
endRowIndexProperty.addListener(event -> tableSelectCell());
endColIndexProperty.addListener(event -> tableSelectCell());
}
BorderPane tbResultLayout = new BorderPane(tbResult);
lblStatus = new Label("Ready...");
lblStatus.setMaxHeight(50d);
tbResultLayout.setBottom(lblStatus);
createResultTableContextMenu(tbResult);
Tab tab = new Tab("Example", tbResultLayout);
return tab;
}
use of javafx.scene.control.TableView in project Gargoyle by callakrsos.
the class SqlMultiplePane method getSelectedTbResult.
/********************************
* 작성일 : 2016. 4. 20. 작성자 : KYJ
*
* 선택된 테이블 탭을 리턴함. 없는경우 null을 리턴
*
* @return
********************************/
@SuppressWarnings("unchecked")
private TableView<Map<String, Object>> getSelectedTbResult() {
Tab selectedItem = getSelectedTab();
selectedItem = (Tab) ValueUtil.decode(selectedItem, selectedItem, addNewTabResult());
BorderPane borderPane = (BorderPane) selectedItem.getContent();
TableView<Map<String, Object>> content = (TableView<Map<String, Object>>) borderPane.getCenter();
return content;
}
use of javafx.scene.control.TableView in project bisq-desktop by bisq-network.
the class BaseProposalView method createProposalColumns.
// /////////////////////////////////////////////////////////////////////////////////////////
// TableColumns
// /////////////////////////////////////////////////////////////////////////////////////////
protected void createProposalColumns(TableView<ProposalListItem> tableView) {
TableColumn<ProposalListItem, ProposalListItem> dateColumn = new AutoTooltipTableColumn<ProposalListItem, ProposalListItem>(Res.get("shared.dateTime")) {
{
setMinWidth(190);
setMaxWidth(190);
}
};
dateColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
dateColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {
@Override
public TableCell<ProposalListItem, ProposalListItem> call(TableColumn<ProposalListItem, ProposalListItem> column) {
return new TableCell<ProposalListItem, ProposalListItem>() {
@Override
public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(bsqFormatter.formatDateTime(item.getProposal().getProposalPayload().getCreationDate()));
else
setText("");
}
};
}
});
dateColumn.setComparator(Comparator.comparing(o3 -> o3.getProposal().getProposalPayload().getCreationDate()));
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
tableView.getColumns().add(dateColumn);
tableView.getSortOrder().add(dateColumn);
TableColumn<ProposalListItem, ProposalListItem> nameColumn = new AutoTooltipTableColumn<>(Res.get("shared.name"));
nameColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
nameColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {
@Override
public TableCell<ProposalListItem, ProposalListItem> call(TableColumn<ProposalListItem, ProposalListItem> column) {
return new TableCell<ProposalListItem, ProposalListItem>() {
@Override
public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(item.getProposal().getProposalPayload().getName());
else
setText("");
}
};
}
});
nameColumn.setComparator(Comparator.comparing(o2 -> o2.getProposal().getProposalPayload().getName()));
tableView.getColumns().add(nameColumn);
TableColumn<ProposalListItem, ProposalListItem> titleColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.title"));
titleColumn.setPrefWidth(100);
titleColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
titleColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {
@Override
public TableCell<ProposalListItem, ProposalListItem> call(TableColumn<ProposalListItem, ProposalListItem> column) {
return new TableCell<ProposalListItem, ProposalListItem>() {
@Override
public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(item.getProposal().getProposalPayload().getTitle());
else
setText("");
}
};
}
});
titleColumn.setComparator(Comparator.comparing(o2 -> o2.getProposal().getProposalPayload().getTitle()));
tableView.getColumns().add(titleColumn);
TableColumn<ProposalListItem, ProposalListItem> uidColumn = new AutoTooltipTableColumn<>(Res.get("shared.id"));
uidColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
uidColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {
@Override
public TableCell<ProposalListItem, ProposalListItem> call(TableColumn<ProposalListItem, ProposalListItem> column) {
return new TableCell<ProposalListItem, ProposalListItem>() {
private HyperlinkWithIcon field;
@Override
public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
final Proposal proposal = item.getProposal();
final ProposalPayload proposalPayload = proposal.getProposalPayload();
field = new HyperlinkWithIcon(proposalPayload.getShortId());
field.setOnAction(event -> {
new ProposalDetailsWindow(bsqFormatter, bsqWalletService, proposalPayload).show();
});
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
uidColumn.setComparator(Comparator.comparing(o -> o.getProposal().getProposalPayload().getUid()));
tableView.getColumns().add(uidColumn);
}
Aggregations