Search in sources :

Example 21 with InvalidationListener

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);
}
Also used : Button(javafx.scene.control.Button) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) javafx.scene.layout(javafx.scene.layout) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) InvalidationListener(javafx.beans.InvalidationListener) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Consumer(java.util.function.Consumer) ScrollPane(javafx.scene.control.ScrollPane) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) DetailsView(org.phoenicis.javafx.views.common.widgets.lists.DetailsView) PhoenicisFilteredList(org.phoenicis.javafx.views.common.lists.PhoenicisFilteredList) URI(java.net.URI) Tooltip(javafx.scene.control.Tooltip) ThemeManager(org.phoenicis.javafx.views.common.ThemeManager) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) URI(java.net.URI)

Example 22 with InvalidationListener

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));
}
Also used : MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) CustomerGenerator(eu.ggnet.dwoss.customer.ee.assist.gen.CustomerGenerator) InvalidationListener(javafx.beans.InvalidationListener)

Example 23 with InvalidationListener

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);
}
Also used : AddressLabel(eu.ggnet.dwoss.customer.ee.entity.projection.AddressLabel) InvoiceAddressLabelWithNullableShippingAddressLabel(eu.ggnet.dwoss.customer.ui.neo.PreferedAddressLabelsController.InvoiceAddressLabelWithNullableShippingAddressLabel) InvalidationListener(javafx.beans.InvalidationListener) Observable(javafx.beans.Observable)

Example 24 with InvalidationListener

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();
}
Also used : Button(javafx.scene.control.Button) OperatingSystem(org.phoenicis.entities.OperatingSystem) javafx.scene.layout(javafx.scene.layout) MappedList(org.phoenicis.javafx.collections.MappedList) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) Bindings(javafx.beans.binding.Bindings) InvalidationListener(javafx.beans.InvalidationListener) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) ScrollPane(javafx.scene.control.ScrollPane) URI(java.net.URI) Tooltip(javafx.scene.control.Tooltip) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) Value(org.graalvm.polyglot.Value) FilteredList(javafx.collections.transformation.FilteredList) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) ApplicationInformationPanel(org.phoenicis.javafx.components.application.control.ApplicationInformationPanel) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Platform(javafx.application.Platform) Installer(org.phoenicis.scripts.Installer) ImageView(javafx.scene.image.ImageView) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) OperatingSystemFetcher(org.phoenicis.tools.system.OperatingSystemFetcher) ObservableList(javafx.collections.ObservableList) Image(javafx.scene.image.Image) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) Observable(javafx.beans.Observable)

Example 25 with InvalidationListener

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;
}
Also used : EventHandler(javafx.event.EventHandler) MouseEvent(javafx.scene.input.MouseEvent) UnmodifiableListSet(com.sun.javafx.collections.UnmodifiableListSet) InvalidationListener(javafx.beans.InvalidationListener) ArrayList(java.util.ArrayList) BackgroundFill(javafx.scene.layout.BackgroundFill) Locale(java.util.Locale) BiConsumer(java.util.function.BiConsumer) Direction(com.sun.javafx.scene.traversal.Direction) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) Event(javafx.event.Event) Set(java.util.Set) KeyEvent(javafx.scene.input.KeyEvent) Background(javafx.scene.layout.Background) EventType(javafx.event.EventType) Consumer(java.util.function.Consumer) Duration(javafx.util.Duration) List(java.util.List) Region(javafx.scene.layout.Region) PauseTransition(javafx.animation.PauseTransition) Paint(javafx.scene.paint.Paint) ObservableValue(javafx.beans.value.ObservableValue) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) InvalidationListener(javafx.beans.InvalidationListener) PauseTransition(javafx.animation.PauseTransition)

Aggregations

InvalidationListener (javafx.beans.InvalidationListener)27 Button (javafx.scene.control.Button)14 Label (javafx.scene.control.Label)13 Node (javafx.scene.Node)12 FXCollections (javafx.collections.FXCollections)11 List (java.util.List)10 ObservableList (javafx.collections.ObservableList)10 Insets (javafx.geometry.Insets)8 Level (java.util.logging.Level)7 Image (javafx.scene.image.Image)7 ImageView (javafx.scene.image.ImageView)7 HBox (javafx.scene.layout.HBox)7 VBox (javafx.scene.layout.VBox)7 ButtonType (javafx.scene.control.ButtonType)6 Dialog (javafx.scene.control.Dialog)6 Priority (javafx.scene.layout.Priority)6 StackPane (javafx.scene.layout.StackPane)6 Widget (org.csstudio.display.builder.model.Widget)6 Collections (java.util.Collections)5 Consumer (java.util.function.Consumer)5