use of javafx.beans.property.SimpleStringProperty in project Smartcity-Smarthouse by TechnionYP5777.
the class UserInfoController method setCellsFactories.
private void setCellsFactories() {
nameColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().contact.getName()));
idColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().contact.getId()));
phoneColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().contact.getPhoneNumber()));
emailColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().contact.getEmailAddress()));
eLevelColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().eLevel + ""));
contactsTable.setEditable(true);
phoneColumn.setCellFactory(TextFieldTableCell.forTableColumn());
phoneColumn.setOnEditCommit(¢ -> ¢.getTableView().getItems().get(¢.getTablePosition().getRow()).contact.setPhoneNumber(¢.getNewValue()));
emailColumn.setCellFactory(TextFieldTableCell.forTableColumn());
emailColumn.setOnEditCommit(¢ -> ¢.getTableView().getItems().get(¢.getTablePosition().getRow()).contact.setEmailAddress(¢.getNewValue()));
eLevelColumn.setCellFactory(ComboBoxTableCell.<ContactGUI, String>forTableColumn(FXCollections.observableArrayList(EmergencyLevel.stringValues())));
eLevelColumn.setOnEditCommit(¢ -> getModel().getUser().setContactEmergencyLevel(¢.getTableView().getItems().get(¢.getTablePosition().getRow()).contact.getId(), ¢.getNewValue()));
}
use of javafx.beans.property.SimpleStringProperty in project jgnash by ccavanaugh.
the class BudgetGoalsDialogController method initialize.
@FXML
private void initialize() {
buttonBar.buttonOrderProperty().bind(Options.buttonOrderProperty());
endRowSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1));
startRowSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1));
periodComboBox.getItems().addAll(Period.values());
patternComboBox.getItems().addAll(Pattern.values());
patternComboBox.setValue(Pattern.EveryRow);
fillAllDecimalTextField.emptyWhenZeroProperty().set(false);
fillPatternAmountDecimalTextField.emptyWhenZeroProperty().set(false);
fillAllDecimalTextField.setDecimal(BigDecimal.ZERO);
fillPatternAmountDecimalTextField.setDecimal(BigDecimal.ZERO);
goalTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
goalTable.setEditable(true);
final TableColumn<BudgetPeriodDescriptor, String> periodColumn = new TableColumn<>(resources.getString("Column.Period"));
periodColumn.setEditable(false);
periodColumn.setCellValueFactory(param -> {
if (param != null) {
return new SimpleStringProperty(param.getValue().getPeriodDescription());
}
return new SimpleStringProperty("");
});
periodColumn.setSortable(false);
goalTable.getColumns().add(periodColumn);
final TableColumn<BudgetPeriodDescriptor, BigDecimal> amountColumn = new TableColumn<>(resources.getString("Column.Amount"));
amountColumn.setEditable(true);
amountColumn.setSortable(false);
amountColumn.setCellValueFactory(param -> {
if (param != null) {
final BudgetPeriodDescriptor descriptor = param.getValue();
final BigDecimal goal = budgetGoal.get().getGoal(descriptor.getStartPeriod(), descriptor.getEndPeriod());
return new SimpleObjectProperty<>(goal.setScale(accountProperty().get().getCurrencyNode().getScale(), MathConstants.roundingMode));
}
return new SimpleObjectProperty<>(BigDecimal.ZERO);
});
amountColumn.setCellFactory(cell -> new BigDecimalTableCell<>(numberFormat));
/// fTextFieldTableCell.forTableColumn()
amountColumn.setOnEditCommit(event -> {
final BudgetPeriodDescriptor descriptor = event.getTableView().getItems().get(event.getTablePosition().getRow());
budgetGoalProperty().get().setGoal(descriptor.getStartPeriod(), descriptor.getEndPeriod(), event.getNewValue());
});
goalTable.getColumns().add(amountColumn);
periodComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
budgetGoalProperty().get().setBudgetPeriod(newValue);
final List<BudgetPeriodDescriptor> descriptors = getDescriptors();
goalTable.getItems().setAll(descriptors);
descriptorSize.set(descriptors.size());
}
});
budgetGoalProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
periodComboBox.setValue(newValue.getBudgetPeriod());
}
});
// the spinner factory max values do not like being bound; Set value instead
descriptorSize.addListener((observable, oldValue, newValue) -> {
((SpinnerValueFactory.IntegerSpinnerValueFactory) endRowSpinner.getValueFactory()).setMax(newValue.intValue());
((SpinnerValueFactory.IntegerSpinnerValueFactory) startRowSpinner.getValueFactory()).setMax(newValue.intValue());
endRowSpinner.getValueFactory().setValue(newValue.intValue());
});
// account has changed; update currency related properties
accountProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
final CurrencyNode currencyNode = newValue.getCurrencyNode();
currencyLabel.setText(currencyNode.getSymbol());
fillAllDecimalTextField.scaleProperty().set(currencyNode.getScale());
fillAllDecimalTextField.minScaleProperty().set(currencyNode.getScale());
fillPatternAmountDecimalTextField.scaleProperty().set(currencyNode.getScale());
fillPatternAmountDecimalTextField.minScaleProperty().set(currencyNode.getScale());
final NumberFormat decimalFormat = NumberFormat.getInstance();
if (decimalFormat instanceof DecimalFormat) {
decimalFormat.setMinimumFractionDigits(currencyNode.getScale());
decimalFormat.setMaximumFractionDigits(currencyNode.getScale());
}
numberFormat.set(decimalFormat);
}
});
}
use of javafx.beans.property.SimpleStringProperty in project jgnash by ccavanaugh.
the class ReconcileDialogController method configureTableView.
private void configureTableView(final TableView<RecTransaction> tableView, final TableViewManager<RecTransaction> tableViewManager) {
tableView.setTableMenuButtonVisible(false);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
final TableColumn<RecTransaction, String> reconciledColumn = new TableColumn<>(resources.getString("Column.Clr"));
reconciledColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getReconciledState().toString()));
tableView.getColumns().add(reconciledColumn);
final TableColumn<RecTransaction, LocalDate> dateColumn = new TableColumn<>(resources.getString("Column.Date"));
dateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDate()));
dateColumn.setCellFactory(param -> new ShortDateTableCell<>());
tableView.getColumns().add(dateColumn);
final TableColumn<RecTransaction, String> numberColumn = new TableColumn<>(resources.getString("Column.Num"));
numberColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getNumber()));
tableView.getColumns().add(numberColumn);
final TableColumn<RecTransaction, String> payeeColumn = new TableColumn<>(resources.getString("Column.Payee"));
payeeColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPayee()));
tableView.getColumns().add(payeeColumn);
final TableColumn<RecTransaction, BigDecimal> amountColumn = new TableColumn<>(resources.getString("Column.Amount"));
amountColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(AccountBalanceDisplayManager.convertToSelectedBalanceMode(account.getAccountType(), param.getValue().getAmount(account))));
amountColumn.setCellFactory(param -> new BigDecimalTableCell<>(CommodityFormat.getShortNumberFormat(account.getCurrencyNode())));
tableView.getColumns().add(amountColumn);
// hide the horizontal scrollbar
tableView.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS);
tableViewManager.setColumnFormatFactory(param -> {
if (param == amountColumn && account != null) {
return CommodityFormat.getShortNumberFormat(account.getCurrencyNode());
}
return null;
});
final ChangeListener<Number> widthListener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (newValue != null && newValue.doubleValue() > 0) {
JavaFXUtils.runLater(tableViewManager::restoreLayout);
JavaFXUtils.runLater(tableViewManager::packTable);
tableView.widthProperty().removeListener(this);
}
}
};
tableView.widthProperty().addListener(widthListener);
}
use of javafx.beans.property.SimpleStringProperty in project Gargoyle by callakrsos.
the class SVNViewer method initialize.
@FXML
public void initialize() {
tvSvnView = new SVNTreeView();
tvSvnView.setOnAction(this::svnTreeViewOnAction);
tvSvnView.setOnKeyPressed(this::svnTreeVoewOnKeyPressed);
tvSvnView.load();
anTreePane.getChildren().set(0, tvSvnView);
AnchorPane.setLeftAnchor(tvSvnView, 0.0);
AnchorPane.setRightAnchor(tvSvnView, 0.0);
AnchorPane.setBottomAnchor(tvSvnView, 0.0);
AnchorPane.setTopAnchor(tvSvnView, 0.0);
colRevision.setCellValueFactory(v -> new SimpleObjectProperty<Long>(v.getValue().getRevision()));
colUser.setCellValueFactory(v -> new SimpleStringProperty(v.getValue().getAuthor()));
colComment.setCellValueFactory(v -> new SimpleStringProperty(v.getValue().getMessage()));
colDate.setCellValueFactory(v -> new SimpleStringProperty(DateUtil.getDateString(v.getValue().getDate().getTime(), "yyyy-MM-dd")));
javaTextAre = new JavaTextArea();
borSource.setCenter(javaTextAre);
lineHist = new LineChart<>(new CategoryAxis(), new CategoryAxis());
borChart.setCenter(lineHist);
tbRevision.getSelectionModel().setCellSelectionEnabled(true);
tbRevision.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
// FxClipboardUtil.installCopyPasteHandler(tbRevision);
// FxTableViewUtil.
FxUtil.installClipboardKeyEvent(tbRevision);
MenuItem menuDiff = new MenuItem("Diff");
menuDiff.setOnAction(this::menuDiffOnAction);
tbRevision.setContextMenu(new ContextMenu(menuDiff));
tvSvnView.svnGraphPropertyProperty().addListener((oba, oldView, newView) -> {
if (newView != null) {
Tab tabSvnGraph = new Tab("SVN Graph", newView);
if (tabPaneSVN.getTabs().size() <= TAB_INDEX_SVN_GRAPH) {
tabPaneSVN.getTabs().add(tabSvnGraph);
} else {
tabPaneSVN.getTabs().add(TAB_INDEX_SVN_GRAPH, tabSvnGraph);
}
}
});
displayLatestRevision();
}
use of javafx.beans.property.SimpleStringProperty in project Gargoyle by callakrsos.
the class AbstractTableColumnInformationController method initialize.
@FXML
public void initialize() {
colNumber.setCellValueFactory(new NumberingCellValueFactory<TableColumnMetaVO>(tbColumns));
colKeyType.setCellFactory(param -> new TableCell<TableColumnMetaVO, KEY_TYPE>() {
@Override
protected void updateItem(KEY_TYPE item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setGraphic(null);
} else {
ImageView image = null;
switch(item) {
case PRI:
image = getImage(PRIMAKRY_KEY_IMAGE_NAME);
image.setFitWidth(getPrefWidth());
setGraphic(image);
break;
case MULTI:
image = getImage(MULTI_KEY_IMAGE_NAME);
image.setFitWidth(getPrefWidth());
setGraphic(image);
break;
case FOREIGN:
image = getImage(FOREIGN_KEY_IMAGE_NAME);
image.setFitWidth(getPrefWidth());
setGraphic(image);
break;
default:
image = new ImageView();
}
setGraphic(image);
}
}
});
colReference.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<TableColumnMetaVO, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<TableColumnMetaVO, String> param) {
TableColumnMetaVO value = param.getValue();
SimpleStringProperty stringProperty = new SimpleStringProperty();
if (value != null && value.getRefs() != null) {
Optional<String> reduce = value.getRefs().stream().map(v -> v.getPkColumnName() + " -> [ " + v.getFkTableName() + "-" + v.getFkColumnName() + " ]").reduce((str1, str2) -> str1.concat("\n").concat(str2));
reduce.ifPresent(stringProperty::setValue);
}
return stringProperty;
}
});
colKeyType.setCellValueFactory(new PropertyValueFactory<>("keyType"));
colKeyType.setStyle("-fx-alignment:center");
this.tbColumns.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
FxUtil.installClipboardKeyEvent(this.tbColumns);
}
Aggregations