use of javafx.beans.InvalidationListener in project phoenicis by PhoenicisOrg.
the class ApplicationPanel method populateCenter.
private void populateCenter() {
this.appDescription = new WebView();
this.appDescription.getEngine().loadContent("<body>" + application.getDescription() + "</body>");
themeManager.bindWebEngineStylesheet(appDescription.getEngine().userStyleSheetLocationProperty());
this.installers = new Label(tr("Installers"));
this.installers.getStyleClass().add("descriptionTitle");
this.scriptGrid = new GridPane();
filteredScripts.addListener((InvalidationListener) change -> this.refreshScripts());
this.refreshScripts();
this.miniaturesPane = new HBox();
this.miniaturesPane.getStyleClass().add("appPanelMiniaturesPane");
this.miniaturesPaneWrapper = new ScrollPane(miniaturesPane);
this.miniaturesPaneWrapper.getStyleClass().add("appPanelMiniaturesPaneWrapper");
for (URI miniatureUri : application.getMiniatures()) {
Region image = new Region();
image.getStyleClass().add("appMiniature");
image.setStyle(String.format("-fx-background-image: url(\"%s\");", miniatureUri.toString()));
image.prefHeightProperty().bind(miniaturesPaneWrapper.heightProperty().multiply(0.8));
image.prefWidthProperty().bind(image.prefHeightProperty().multiply(1.5));
miniaturesPane.getChildren().add(image);
}
this.center = new VBox(appDescription, installers, scriptGrid, miniaturesPaneWrapper);
VBox.setVgrow(appDescription, Priority.ALWAYS);
this.setCenter(center);
}
use of javafx.beans.InvalidationListener in project dwoss by gg-net.
the class MandatorMetaDataController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
CustomerGenerator gen = new CustomerGenerator();
MandatorMetadata m = gen.makeMandatorMetadata();
defaultCustomerSalesdata = new DefaultCustomerSalesdata(m.getShippingCondition(), m.getPaymentCondition(), m.getPaymentMethod(), m.getAllowedSalesChannels(), new ArrayList(m.getAllowedSalesChannels()));
this.setDefaultValues(defaultCustomerSalesdata);
saveButton.setDisable(true);
shippingConditionComboBox.getItems().setAll(ShippingCondition.values());
paymentConditionComboBox.getItems().setAll(PaymentCondition.values());
paymentMethodComboBox.getItems().setAll(PaymentMethod.values());
shippingConditionComboBox.setConverter(new StringConverter<ShippingCondition>() {
@Override
public ShippingCondition fromString(String string) {
throw new UnsupportedOperationException("fromString is not supported");
}
@Override
public String toString(ShippingCondition myClassinstance) {
return myClassinstance.toString();
}
});
paymentConditionComboBox.setConverter(new StringConverter<PaymentCondition>() {
@Override
public PaymentCondition fromString(String string) {
throw new UnsupportedOperationException("fromString is not supported");
}
@Override
public String toString(PaymentCondition myClassinstance) {
return myClassinstance.getNote();
}
});
paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {
@Override
public PaymentMethod fromString(String string) {
throw new UnsupportedOperationException("fromString is not supported");
}
@Override
public String toString(PaymentMethod myClassinstance) {
return myClassinstance.getNote();
}
});
paymentConditionComboBox.setCellFactory(new Callback<ListView<PaymentCondition>, ListCell<PaymentCondition>>() {
@Override
public ListCell<PaymentCondition> call(ListView<PaymentCondition> l) {
return new ListCell<PaymentCondition>() {
@Override
public String toString() {
return this.toString();
}
@Override
protected void updateItem(PaymentCondition item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
} else {
setText(item.getNote());
}
}
};
}
});
paymentMethodComboBox.setCellFactory((ListView<PaymentMethod> l) -> new ListCell<PaymentMethod>() {
@Override
protected void updateItem(PaymentMethod item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
} else {
setText(item.getNote());
}
}
});
InvalidationListener saveButtonDisablingListener = new InvalidationListener() {
@Override
public void invalidated(javafx.beans.Observable observable) {
if (shippingConditionComboBox.getSelectionModel().isEmpty() && paymentConditionComboBox.getSelectionModel().isEmpty() && paymentMethodComboBox.getSelectionModel().isEmpty() && allowedSalesChannelCheckBoxList.stream().noneMatch(CheckBox::isSelected))
saveButton.setDisable(true);
else
saveButton.setDisable(false);
}
};
shippingConditionComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
paymentConditionComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
paymentMethodComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
allowedSalesChannelCheckBoxList.forEach(e -> e.selectedProperty().addListener(saveButtonDisablingListener));
}
use of javafx.beans.InvalidationListener in project dwoss by gg-net.
the class PreferedAddressLabelsController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
saveButton.setDisable(true);
invoiceAddressCompanyListView.setCellFactory(cb -> new CompanyListCell());
invoiceAddressContactListView.setCellFactory(cb -> new ContactListCell());
invoiceAddressAddressListView.setCellFactory(cb -> new AddressListCell());
shippingAddressCompanyListView.setCellFactory(cb -> new CompanyListCell());
shippingAddressContactListView.setCellFactory(cb -> new ContactListCell());
shippingAddressAddressListView.setCellFactory(cb -> new AddressListCell());
InvalidationListener invoiceWebViewListener = (Observable observable) -> {
if (!invoiceAddressAddressListView.getSelectionModel().isEmpty()) {
AddressLabel addressLabel = new AddressLabel(invoiceAddressCompanyListView.getSelectionModel().getSelectedItem(), invoiceAddressContactListView.getSelectionModel().getSelectedItem(), invoiceAddressAddressListView.getSelectionModel().getSelectedItem(), AddressType.INVOICE);
invoiceAddressWebView.getEngine().loadContent(addressLabel.toHtml());
} else
invoiceAddressWebView.getEngine().loadContent("");
};
this.invoiceAddressAddressListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
this.invoiceAddressCompanyListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
this.invoiceAddressContactListView.getSelectionModel().selectedIndexProperty().addListener(invoiceWebViewListener);
InvalidationListener shippingWebViewListener = (Observable observable) -> {
if (!shippingAddressAddressListView.getSelectionModel().isEmpty()) {
AddressLabel addressLabel = new AddressLabel(shippingAddressCompanyListView.getSelectionModel().getSelectedItem(), shippingAddressContactListView.getSelectionModel().getSelectedItem(), shippingAddressAddressListView.getSelectionModel().getSelectedItem(), AddressType.SHIPPING);
shippingAddressWebView.getEngine().loadContent(addressLabel.toHtml());
} else
shippingAddressWebView.getEngine().loadContent("");
};
this.shippingAddressAddressListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
this.shippingAddressCompanyListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
this.shippingAddressContactListView.getSelectionModel().selectedIndexProperty().addListener(shippingWebViewListener);
InvalidationListener saveButtonDisablingListener = (Observable observable) -> {
boolean isInvoiceAddressValid = (!invoiceAddressAddressListView.getSelectionModel().isEmpty()) && ((!invoiceAddressCompanyListView.getSelectionModel().isEmpty()) || (!invoiceAddressContactListView.getSelectionModel().isEmpty()));
boolean isShippingAddressValid = (shippingAddressAddressListView.getSelectionModel().isEmpty() && shippingAddressCompanyListView.getSelectionModel().isEmpty() && shippingAddressContactListView.getSelectionModel().isEmpty()) || ((!shippingAddressAddressListView.getSelectionModel().isEmpty()) && (!shippingAddressCompanyListView.getSelectionModel().isEmpty() || !shippingAddressContactListView.getSelectionModel().isEmpty()));
if (isInvoiceAddressValid && isShippingAddressValid)
saveButton.setDisable(false);
else
saveButton.setDisable(true);
};
invoiceAddressCompanyListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
invoiceAddressContactListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
invoiceAddressAddressListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
shippingAddressCompanyListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
shippingAddressContactListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
shippingAddressAddressListView.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
}
use of javafx.beans.InvalidationListener in project POL-POM-5 by PlayOnLinux.
the class ApplicationInformationPanelSkin method initialise.
/**
* {@inheritDoc}
*/
@Override
public void initialise() {
final WebView appDescription = new WebView();
appDescription.getEngine().userStyleSheetLocationProperty().bind(getControl().webEngineStylesheetProperty());
VBox.setVgrow(appDescription, Priority.ALWAYS);
getControl().applicationProperty().addListener((Observable invalidation) -> updateDescription(appDescription));
updateDescription(appDescription);
final Label installers = new Label(tr("Installers"));
installers.getStyleClass().add("descriptionTitle");
final GridPane scriptGrid = new GridPane();
filteredScripts.addListener((InvalidationListener) change -> updateScripts(scriptGrid));
getControl().showScriptSourceProperty().addListener((Observable invalidation) -> updateScripts(scriptGrid));
updateScripts(scriptGrid);
final HBox miniaturesPane = new HBox();
miniaturesPane.getStyleClass().add("appPanelMiniaturesPane");
Bindings.bindContent(miniaturesPane.getChildren(), miniatures);
final ScrollPane miniaturesPaneWrapper = new ScrollPane(miniaturesPane);
miniaturesPaneWrapper.getStyleClass().add("appPanelMiniaturesPaneWrapper");
miniatureHeight.bind(miniaturesPaneWrapper.heightProperty().multiply(0.8));
final VBox container = new VBox(appDescription, installers, scriptGrid, miniaturesPaneWrapper);
getChildren().add(container);
// ensure that the content of the details panel changes when the to be shown application changes
getControl().applicationProperty().addListener((Observable invalidation) -> updateApplication());
// initialise the content of the details panel correct
updateApplication();
}
use of javafx.beans.InvalidationListener in project JFoenix by jfoenixadmin.
the class JFXNodeUtils method addDelayedPropertyInvalidationListener.
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property, Duration delayTime, BiConsumer<T, InvalidationListener> consumer) {
Wrapper<T> eventWrapper = new Wrapper<>();
PauseTransition holdTimer = new PauseTransition(delayTime);
final InvalidationListener invalidationListener = observable -> {
eventWrapper.content = property.getValue();
holdTimer.playFromStart();
};
holdTimer.setOnFinished(event -> consumer.accept(eventWrapper.content, invalidationListener));
property.addListener(invalidationListener);
return invalidationListener;
}
Aggregations