use of javafx.beans.value.ObservableValue in project SmartCity-Market by TechnionYP5777.
the class CustomerMainScreen method initialize.
@Override
public void initialize(URL location, ResourceBundle __) {
AbstractApplicationScreen.fadeTransition(customerMainScreenPane);
barcodeEventHandler.register(this);
customer = TempCustomerPassingData.customer;
filteredProductList = new FilteredList<>(productsObservableList, s -> true);
searchField.textProperty().addListener(obs -> {
String filter = searchField.getText();
filteredProductList.setPredicate((filter == null || filter.length() == 0) ? s -> true : s -> s.getCatalogProduct().getName().contains(filter));
});
productsListView.setItems(filteredProductList);
productsListView.setCellFactory(new Callback<ListView<CartProduct>, ListCell<CartProduct>>() {
@Override
public ListCell<CartProduct> call(ListView<CartProduct> __) {
return new CustomerProductCellFormat();
}
});
productsListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<CartProduct>() {
@Override
public void changed(ObservableValue<? extends CartProduct> __, CartProduct oldValue, CartProduct newValue) {
updateProductInfoPaine(newValue.getCatalogProduct(), newValue.getTotalAmount(), ProductInfoPaneVisibleMode.PRESSED_PRODUCT);
}
});
productsListView.depthProperty().set(1);
productsListView.setExpanded(true);
setAbilityAndVisibilityOfProductInfoPane(false);
}
use of javafx.beans.value.ObservableValue in project jgnash by ccavanaugh.
the class JasperViewerDialogController method initialize.
@FXML
private void initialize() {
busyPane = new BusyPane();
stackPane.getChildren().add(busyPane);
screenResolution = Screen.getPrimary().getDpi();
saveButton.disableProperty().bind(jasperPrint.isNull());
printButton.disableProperty().bind(jasperPrint.isNull());
reportFormatButton.disableProperty().bind(jasperPrint.isNull());
fontSizeSpinner.disableProperty().bind(jasperPrint.isNull());
firstButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(0)));
previousButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(0)));
nextButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(pageCount.subtract(1))));
lastButton.disableProperty().bind(jasperPrint.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(pageCount.subtract(1))));
fitPageButton.disableProperty().bind(jasperPrint.isNull());
fitHeightButton.disableProperty().bind(jasperPrint.isNull());
fitWidthButton.disableProperty().bind(jasperPrint.isNull());
zoomComboBox.disableProperty().bind(jasperPrint.isNull());
zoomInButton.disableProperty().bind(jasperPrint.isNull().or(zoomProperty.greaterThanOrEqualTo(DEFAULT_ZOOMS[DEFAULT_ZOOMS.length - 1] / 100)));
zoomOutButton.disableProperty().bind(jasperPrint.isNull().or(zoomProperty.lessThanOrEqualTo(DEFAULT_ZOOMS[0] / 100)));
fitPageButton.setSelected(true);
firstButton.prefHeightProperty().bind(saveButton.heightProperty());
previousButton.prefHeightProperty().bind(saveButton.heightProperty());
nextButton.prefHeightProperty().bind(saveButton.heightProperty());
lastButton.prefHeightProperty().bind(saveButton.heightProperty());
zoomInButton.prefHeightProperty().bind(saveButton.heightProperty());
zoomOutButton.prefHeightProperty().bind(saveButton.heightProperty());
fitHeightButton.prefHeightProperty().bind(saveButton.heightProperty());
fitWidthButton.prefHeightProperty().bind(saveButton.heightProperty());
fitPageButton.prefHeightProperty().bind(saveButton.heightProperty());
fontSizeSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(5, 15, 7));
report.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
jasperPrint.set(newValue.createJasperPrint(false));
fontSizeSpinner.valueFactoryProperty().get().setValue(newValue.getBaseFontSize());
newValue.refreshCallBackProperty().set(() -> createJasperPrint(newValue));
} else {
jasperPrint.set(null);
}
});
jasperPrint.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
pageCount.set(newValue.getPages().size());
} else {
pageCount.set(0);
}
Platform.runLater(this::refresh);
});
reportControllerPaneProperty.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
reportControllerPane.getChildren().addAll(newValue);
}
});
fontSizeSpinner.valueProperty().addListener((observable, oldValue, newValue) -> {
report.get().setBaseFontSize(newValue);
Platform.runLater(() -> createJasperPrint(report.get()));
});
pagePane.setSpacing(PAGE_BORDER);
pagePane.setPadding(new Insets(PAGE_BORDER));
pagePane.setAlignment(Pos.CENTER);
scrollPane.viewportBoundsProperty().addListener((observable, oldValue, newValue) -> {
if (fitWidthButton.isSelected()) {
handleFitPageWidthAction();
}
scrollPane.setFitToWidth(pagePane.prefWidth(-1) < newValue.getWidth());
scrollPane.setFitToHeight(pagePane.prefHeight(-1) < newValue.getHeight());
});
scrollPane.vvalueProperty().addListener((ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
final double interval = 1d / (double) pageCount.get();
double low = pageIndex.get() * interval;
double hi = low + interval;
int newPageIndex = pageIndex.get();
if (hi < newValue.doubleValue() && pageIndex.get() < pageCount.get()) {
while (hi < newValue.doubleValue()) {
newPageIndex++;
hi += interval;
}
// increase the page index to match the scroll position
setPageIndex(newPageIndex);
} else if (low > newValue.doubleValue() && pageIndex.get() > 0) {
while (low > newValue.doubleValue()) {
newPageIndex--;
low -= interval;
}
// decrease the page index to match the scroll position
setPageIndex(newPageIndex);
}
});
for (int zoom : DEFAULT_ZOOMS) {
zoomComboBox.getItems().add(zoom + "%");
}
zoomComboBox.getSelectionModel().select(DEFAULT_ZOOM_INDEX);
zoomComboBox.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
if (e.getCode() == KeyCode.ENTER) {
handleZoomChangedAction();
}
});
setZoomRatio(1);
}
use of javafx.beans.value.ObservableValue in project Gargoyle by callakrsos.
the class CheckBoxTableCellExam method start.
/*
* (non-Javadoc)
*
* @see javafx.application.Application#start(javafx.stage.Stage)
*/
@Override
public void start(Stage primaryStage) throws Exception {
TableView<SampleVO> center = new TableView<>();
center.setEditable(true);
TableColumn<SampleVO, Boolean> e = new TableColumn<SampleVO, Boolean>();
e.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<SampleVO, Boolean>, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(CellDataFeatures<SampleVO, Boolean> param) {
return param.getValue().checked;
}
});
e.setCellFactory(new Callback<TableColumn<SampleVO, Boolean>, TableCell<SampleVO, Boolean>>() {
@Override
public TableCell<SampleVO, Boolean> call(TableColumn<SampleVO, Boolean> param) {
return new CheckBoxTableCell<SampleVO, Boolean>() {
/*
* (non-Javadoc)
*
* @see
* javafx.scene.control.cell.CheckBoxTableCell#updateItem(
* java.lang.Object, boolean)
*/
@Override
public void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
}
/*
* (non-Javadoc)
*
* @see
* javafx.scene.control.Cell#isItemChanged(java.lang.Object,
* java.lang.Object)
*/
@Override
protected boolean isItemChanged(Boolean oldItem, Boolean newItem) {
System.out.println(oldItem + " : " + newItem);
return super.isItemChanged(oldItem, newItem);
}
};
}
});
e.setEditable(true);
TableColumn<SampleVO, String> e2 = new TableColumn<SampleVO, String>();
e2.setCellValueFactory(new PropertyValueFactory<SampleVO, String>("name"));
center.getColumns().add(e);
center.getColumns().add(e2);
center.getItems().add(new SampleVO(true, "kim"));
center.getItems().add(new SampleVO(true, "young"));
BorderPane borderPane = new BorderPane(center);
primaryStage.setScene(new Scene(borderPane));
primaryStage.show();
}
use of javafx.beans.value.ObservableValue 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);
}
use of javafx.beans.value.ObservableValue in project Gargoyle by callakrsos.
the class TextBaseDiffAppController method initialize.
@FXML
public void initialize() {
/* initControls */
ivReviced = new ImageView();
ivpReviced = new ImageViewPane(ivReviced);
ivpReviced.setPrefWidth(200);
ivpReviced.setPrefHeight(150);
ivOrigin = new ImageView();
ivpOrigin = new ImageViewPane(ivOrigin);
ivpOrigin.setPrefWidth(200);
ivpOrigin.setPrefHeight(150);
gpSnap.add(ivpReviced, 0, 0);
gpSnap.add(ivpOrigin, 1, 0);
lvOrinal.setCellFactory(param -> new DefaultTextFieldListCell(ORIGINAL));
lvRevice.setCellFactory(param -> new DefaultTextFieldListCell(REVICED));
fileCompareResultProperty.addListener(compareResultListener);
lvRevice.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
int movePosition = -1;
ChunkWrapper selectedItem = lvRevice.getSelectionModel().getSelectedItem();
Delta delta = selectedItem.getDelta();
if (delta != null && delta.getOriginal() != null) {
movePosition = selectedItem.getPosition();
lvOrinal.scrollTo(movePosition - 1);
lvOrinal.getSelectionModel().select(movePosition);
}
}
});
lvOrinal.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
int movePosition = -1;
ChunkWrapper selectedItem = lvOrinal.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
Delta delta = selectedItem.getDelta();
if (delta != null && delta.getRevised() != null) {
movePosition = delta.getRevised().getPosition();
lvRevice.scrollTo(movePosition - 1);
lvRevice.getSelectionModel().select(movePosition);
}
}
}
});
lvOrinal.addEventFilter(ScrollEvent.SCROLL, event -> {
snappOriginShot();
});
lvRevice.addEventFilter(ScrollEvent.SCROLL, event -> {
snappReviceShot();
});
btnCompare.setOnMouseClicked(event -> {
String ori = txtOrigin.getText();
String rev = txtRevice.getText();
if (!(ori.isEmpty() && rev.isEmpty())) {
clear();
try {
this.compare.setOriginal(ori);
this.compare.setRevised(rev);
CompareResult chunkResult = this.compare.getChunkResult();
this.fileCompareResultProperty.set(chunkResult);
snappOriginShot();
snappReviceShot();
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
}
});
colStatus.setCellValueFactory(new Callback<CellDataFeatures<ChunkWrapper, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<ChunkWrapper, String> param) {
TYPE type = param.getValue().getType();
StringProperty prop = new SimpleStringProperty();
if (type != null)
prop.set(type.name());
return prop;
}
});
colPosition.setCellValueFactory(param -> new SimpleIntegerProperty(new Integer(param.getValue().getPosition() + 1)));
colRevice.setCellValueFactory(param -> {
Delta delta = param.getValue().getDelta();
SimpleStringProperty prop = new SimpleStringProperty();
if (delta != null) {
Chunk c = delta.getRevised();
prop.setValue(c.getLines().toString());
}
return prop;
});
colOrigin.setCellValueFactory(param -> {
Delta delta = param.getValue().getDelta();
SimpleStringProperty prop = new SimpleStringProperty();
if (delta != null) {
Chunk c = delta.getOriginal();
prop.setValue(c.getLines().toString());
}
return prop;
});
}
Aggregations