use of javafx.scene.control.TableColumn in project jgnash by ccavanaugh.
the class ImportPageTwoController method buildTableView.
private void buildTableView() {
final TableColumn<ImportTransaction, ImportState> stateColumn = new TableColumn<>();
stateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getState()));
stateColumn.setCellFactory(param -> {
TableCell<ImportTransaction, ImportState> cell = new ImportStateTableCell();
cell.addEventFilter(MouseEvent.MOUSE_CLICKED, event -> {
if (event.getClickCount() > 1) {
final ImportTransaction t = tableView.getItems().get(((TableCell<?, ?>) event.getSource()).getTableRow().getIndex());
switch(t.getState()) {
case EQUAL:
t.setState(ImportState.NOT_EQUAL);
break;
case NOT_EQUAL:
t.setState(ImportState.EQUAL);
break;
case NEW:
t.setState(ImportState.IGNORE);
break;
case IGNORE:
t.setState(ImportState.NEW);
break;
}
JavaFXUtils.runLater(tableView::refresh);
}
});
return cell;
});
tableView.getColumns().add(stateColumn);
final TableColumn<ImportTransaction, LocalDate> dateColumn = new TableColumn<>(resources.getString("Column.Date"));
dateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDatePosted()));
dateColumn.setCellFactory(param -> new ShortDateTableCell<>());
tableView.getColumns().add(dateColumn);
final TableColumn<ImportTransaction, String> numberColumn = new TableColumn<>(resources.getString("Column.Num"));
numberColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getCheckNumber()));
tableView.getColumns().add(numberColumn);
final TableColumn<ImportTransaction, String> payeeColumn = new TableColumn<>(resources.getString("Column.Payee"));
payeeColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPayee()));
tableView.getColumns().add(payeeColumn);
final TableColumn<ImportTransaction, String> memoColumn = new TableColumn<>(resources.getString("Column.Memo"));
memoColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getMemo()));
tableView.getColumns().add(memoColumn);
final TableColumn<ImportTransaction, Account> accountColumn = new TableColumn<>(resources.getString("Column.Account"));
accountColumn.setCellValueFactory(param -> {
if (param.getValue() != null && param.getValue().getAccount() != null) {
return new SimpleObjectProperty<>(param.getValue().getAccount());
}
return null;
});
accountColumn.setCellFactory(param -> new AccountComboBoxTableCell<>());
accountColumn.setEditable(true);
accountColumn.setOnEditCommit(event -> {
event.getTableView().getItems().get(event.getTablePosition().getRow()).setAccount(event.getNewValue());
lastAccount = event.getNewValue();
JavaFXUtils.runLater(tableViewManager::packTable);
});
tableView.getColumns().add(accountColumn);
incomeAccountColumn = new TableColumn<>(resources.getString("Column.Income"));
incomeAccountColumn.setCellValueFactory(param -> {
if (param.getValue() != null && param.getValue().getGainsAccount() != null) {
return new SimpleObjectProperty<>(param.getValue().getGainsAccount());
}
return null;
});
incomeAccountColumn.setCellFactory(param -> new IncomeAccountComboBoxTableCell<>());
incomeAccountColumn.setEditable(true);
incomeAccountColumn.setOnEditCommit(event -> {
event.getTableView().getItems().get(event.getTablePosition().getRow()).setGainsAccount(event.getNewValue());
lastGainsAccount = event.getNewValue();
JavaFXUtils.runLater(tableViewManager::packTable);
});
tableView.getColumns().add(incomeAccountColumn);
expenseAccountColumn = new TableColumn<>(resources.getString("Column.Expense"));
expenseAccountColumn.setCellValueFactory(param -> {
if (param.getValue() != null && param.getValue().getFeesAccount() != null) {
if (param.getValue().getFees().compareTo(BigDecimal.ZERO) != 0) {
return new SimpleObjectProperty<>(param.getValue().getFeesAccount());
}
// nop account
return new SimpleObjectProperty<>(NOP_EXPENSE_ACCOUNT);
}
return null;
});
expenseAccountColumn.setCellFactory(param -> new ExpenseAccountComboBoxTableCell<>());
expenseAccountColumn.setEditable(true);
expenseAccountColumn.setOnEditCommit(event -> {
event.getTableView().getItems().get(event.getTablePosition().getRow()).setFeesAccount(event.getNewValue());
JavaFXUtils.runLater(tableViewManager::packTable);
});
tableView.getColumns().add(expenseAccountColumn);
final TableColumn<ImportTransaction, BigDecimal> amountColumn = new TableColumn<>(resources.getString("Column.Amount"));
amountColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getAmount()));
amountColumn.setCellFactory(param -> new BigDecimalTableCell<>(numberFormat));
amountColumn.setCellFactory(param -> {
final TableCell<ImportTransaction, BigDecimal> cell = new BigDecimalTableCell<>(numberFormat);
// add tool tip
cell.indexProperty().addListener((observable, oldValue, newValue) -> {
final int index = newValue.intValue();
if (index >= 0 && index < tableView.itemsProperty().get().size()) {
cell.setTooltip(new Tooltip(tableView.itemsProperty().get().get(index).getToolTip()));
}
});
return cell;
});
tableView.getColumns().add(amountColumn);
typeColumn = new TableColumn<>(resources.getString("Column.Type"));
typeColumn.setCellValueFactory(param -> {
TransactionType transactionType = TransactionType.SINGLENTRY;
if (param.getValue().isInvestmentTransaction()) {
transactionType = param.getValue().getTransactionType();
} else if (!param.getValue().getAccount().equals(baseAccount)) {
transactionType = TransactionType.DOUBLEENTRY;
}
return new SimpleStringProperty(transactionType.toString());
});
tableView.getColumns().add(typeColumn);
}
use of javafx.scene.control.TableColumn in project VocabHunter by VocabHunter.
the class FilterGridController method buildColumn.
private TableColumn<GridLine, GridCell> buildColumn(final FilterGridModel filterModel, final int index) {
TableColumn<GridLine, GridCell> column = new TableColumn<>(columnNameTool.columnName(index));
column.setSortable(false);
column.setCellValueFactory(features -> extractValue(features, index));
column.setCellFactory(c -> new FilterGridWordTableCell(filterModel.getColumnSelections().get(index)));
if (isScrollableColumnList(filterModel)) {
column.setPrefWidth(PREFERRED_COLUMN_WIDTH);
}
return column;
}
use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class ColorPickerExample method start.
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("DockFX");
TableView<Map<String, Object>> tableView = new TableView<Map<String, Object>>();
tableView.setEditable(true);
{
Map<String, Object> map = new HashMap<String, Object>();
map.put("color", Color.RED);
tableView.getItems().add(map);
}
{
Map<String, Object> map = new HashMap<String, Object>();
map.put("color", Color.GREEN);
tableView.getItems().add(map);
}
tableView.setEditable(true);
tableView.getColumns().add(new ColorPickerTableColumn<>(new TableColumn<>(), "color"));
tableView.setOnMouseClicked(event -> {
System.out.println("mouse click event");
});
Button btnAdd = new Button("추가");
btnAdd.setOnMouseClicked(event -> {
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("color", Color.RED);
tableView.getItems().add(hashMap);
});
BorderPane root = new BorderPane(tableView);
root.setTop(new BorderPane(btnAdd));
primaryStage.setScene(new Scene(root, 1100, 700));
// primaryStage.setScene(new Scene(new BorderPane(new
// MysqlPane("sample")), 1100, 700));
primaryStage.sizeToScene();
primaryStage.show();
Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
DockPane.initializeDefaultUserAgentStylesheet();
}
use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class ColumnExample method start.
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("DockFX");
TableView<ClassTypeCodeDVO> tableView = new TableView<ClassTypeCodeDVO>();
tableView.setEditable(true);
{
ClassTypeCodeDVO e = new ClassTypeCodeDVO();
e.setCommCode("코드1");
e.setCommCodeNm("데이터 1");
tableView.getItems().add(e);
}
{
ClassTypeCodeDVO e = new ClassTypeCodeDVO();
e.setCommCode("코드1");
e.setCommCodeNm("데이터 2123123123123123123123123112312312331232\n\n\n\n\n\n\n\34534958345093443850934583409583405934850349534095830534098");
tableView.getItems().add(e);
}
{
ClassTypeCodeDVO e = new ClassTypeCodeDVO();
e.setCommCode("코드3");
e.setCommCodeNm("데이터 3");
tableView.getItems().add(e);
}
{
ClassTypeCodeDVO e = new ClassTypeCodeDVO();
e.setCommCode("코드4");
e.setCommCodeNm("데이터 4");
tableView.getItems().add(e);
}
ObservableList<CodeDVO> observableArrayList = FXCollections.observableArrayList(Arrays.asList(new CodeDVO("출력용 코드명1", "코드1"), new CodeDVO("출력용코드명2", "코드2"), new CodeDVO("출력용코드명3", "코드3")));
tableView.getColumns().add(new ComboBoxTableColumn<>("commCode", observableArrayList, "code", "codeNm"));
TableColumn<ClassTypeCodeDVO, Object> e = new TableColumn<>("SAMPLE");
e.setCellValueFactory(new PropertyValueFactory<>("commCodeNm"));
tableView.getColumns().add(e);
tableView.getColumns().add(new TableColumn<>("emptyCol1"));
tableView.getColumns().add(new TableColumn<>("emptyCol2"));
tableView.getColumns().add(new TableColumn<>("emptyCol3"));
tableView.getColumns().add(new TableColumn<>("emptyCol4"));
tableView.getColumns().add(new TableColumn<>("emptyCol5"));
tableView.getColumns().add(new TableColumn<>("emptyCol6"));
tableView.setOnMouseClicked(event -> {
ClassTypeCodeDVO selectedItem = tableView.getSelectionModel().getSelectedItem();
System.out.println("유효성 체크입니다.");
System.out.println("코드 : 데이터 형태로 출력되야합니다.");
System.out.println(selectedItem.getCommCode() + " : " + selectedItem.getCommCodeNm());
});
primaryStage.setScene(new Scene(new BorderPane(tableView), 1100, 700));
// primaryStage.setScene(new Scene(new BorderPane(new
// MysqlPane("sample")), 1100, 700));
primaryStage.sizeToScene();
primaryStage.show();
Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
DockPane.initializeDefaultUserAgentStylesheet();
}
use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.
the class ColumnExample2 method start.
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("DockFX");
TableView<Map<String, String>> tableView = new TableView<Map<String, String>>();
tableView.setEditable(true);
{
Map<String, String> hashMap = new HashMap<String, String>();
hashMap.put("commCode", "코드1");
hashMap.put("commCodeNm", "데이터 1");
tableView.getItems().add(hashMap);
}
{
Map<String, String> hashMap = new HashMap<String, String>();
hashMap.put("commCode", "코드1");
hashMap.put("commCodeNm", "데이터 2");
tableView.getItems().add(hashMap);
}
{
Map<String, String> hashMap = new HashMap<String, String>();
hashMap.put("commCode", "코드3");
hashMap.put("commCodeNm", "데이터 3");
tableView.getItems().add(hashMap);
}
{
Map<String, String> hashMap = new HashMap<String, String>();
hashMap.put("commCode", "코드4");
hashMap.put("commCodeNm", "데이터 4");
tableView.getItems().add(hashMap);
}
ObservableList<CodeDVO> observableArrayList = FXCollections.observableArrayList(Arrays.asList(new CodeDVO("출력용 코드명1", "코드1"), new CodeDVO("출력용코드명2", "코드2"), new CodeDVO("출력용코드명3", "코드3")));
tableView.getColumns().add(new ComboBoxTableColumn<>("commCode", observableArrayList, "code", "codeNm"));
TableColumn<Map<String, String>, Object> e = new TableColumn<>("SAMPLE");
e.setCellValueFactory(new MapValueFactory("commCodeNm"));
tableView.getColumns().add(e);
tableView.setOnMouseClicked(event -> {
Map<String, String> selectedItem = tableView.getSelectionModel().getSelectedItem();
System.out.println("유효성 체크입니다.");
System.out.println("코드 : 데이터 형태로 출력되야합니다.");
System.out.println(selectedItem.get("commCode") + " : " + selectedItem.get("commCodeNm"));
});
primaryStage.setScene(new Scene(new BorderPane(tableView), 1100, 700));
// primaryStage.setScene(new Scene(new BorderPane(new
// MysqlPane("sample")), 1100, 700));
primaryStage.sizeToScene();
primaryStage.show();
Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
DockPane.initializeDefaultUserAgentStylesheet();
}
Aggregations