Example usage for javafx.beans.binding Bindings not

List of usage examples for javafx.beans.binding Bindings not

Introduction

In this page you can find the example usage for javafx.beans.binding Bindings not.

Prototype

public static BooleanBinding not(final ObservableBooleanValue op) 

Source Link

Document

Creates a BooleanBinding that calculates the inverse of the value of a javafx.beans.value.ObservableBooleanValue .

Usage

From source file:caillou.company.clonemanager.gui.customComponent.critere.CritereController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    mainModel.getCritereModel().getFormat().allProperty().bind(formatAllId.selectedProperty());
    mainModel.getCritereModel().getFormat().videoProperty().bind(
            Bindings.and(formatVideoId.selectedProperty(), Bindings.not(formatVideoId.disableProperty())));
    mainModel.getCritereModel().getFormat().audioProperty().bind(
            Bindings.and(formatAudioId.selectedProperty(), Bindings.not(formatAudioId.disableProperty())));
    mainModel.getCritereModel().getFormat().imageProperty().bind(
            Bindings.and(formatImageId.selectedProperty(), Bindings.not(formatImageId.disableProperty())));
    mainModel.getCritereModel().getFormat().archiveProperty().bind(
            Bindings.and(formatArchiveId.selectedProperty(), Bindings.not(formatArchiveId.disableProperty())));

    LongBinding minimumSizeComputationBinding = new LongBinding() {
        {//  w  w w.j  a  v  a2 s . co  m
            super.bind(minimumSizeFormatId.valueProperty(), sizeMinId.valueProperty());
        }

        @Override
        protected long computeValue() {
            if (minimumSizeFormatId.getValue().equals("octet")) {
                return (long) sizeMinId.valueProperty().get() * 1;
            }
            if (minimumSizeFormatId.getValue().equals("kilo octet")) {
                return (long) sizeMinId.valueProperty().get() * 1000;
            }
            if (minimumSizeFormatId.getValue().equals("mega octet")) {
                return (long) sizeMinId.valueProperty().get() * 1000000;
            }
            if (minimumSizeFormatId.getValue().equals("giga octet")) {
                return (long) sizeMinId.valueProperty().get() * 1000000000;
            }
            throw new IllegalArgumentException("Unkowned size format");
        }
    };

    mainModel.getCritereModel().getSize().minimalSizeProperty().bind(minimumSizeComputationBinding);

    LongBinding maximumSizeComputationBinding = new LongBinding() {
        {
            super.bind(maximumSizeFormatId.valueProperty(), sizeMaxId.valueProperty());
        }

        @Override
        protected long computeValue() {
            if (maximumSizeFormatId.getValue().equals("octet")) {
                return (long) sizeMaxId.valueProperty().get() * 1;
            }
            if (maximumSizeFormatId.getValue().equals("kilo octet")) {
                return (long) sizeMaxId.valueProperty().get() * 1000;
            }
            if (maximumSizeFormatId.getValue().equals("mega octet")) {
                return (long) sizeMaxId.valueProperty().get() * 1000000;
            }
            if (maximumSizeFormatId.getValue().equals("giga octet")) {
                return (long) sizeMaxId.valueProperty().get() * 1000000000;
            }
            throw new IllegalArgumentException("Unkowned size format");
        }
    };

    mainModel.getCritereModel().getSize().minimalSizeProperty().bind(minimumSizeComputationBinding);
    mainModel.getCritereModel().getSize().maximalSizeProperty().bind(maximumSizeComputationBinding);

    formatAllId.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            disableEnableCheckboxes(newValue);
            if (newValue) {
                formatVideoId.setSelected(false);
                formatAudioId.setSelected(false);
                formatImageId.setSelected(false);
                formatArchiveId.setSelected(false);
            }
        }
    });
}

From source file:caillou.company.clonemanager.gui.customComponent.search.SearchController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    MainApp app = MainApp.getInstance();
    app.getStage().sizeToScene();/*from w  ww.  j  a v a 2  s.c om*/
    app.getStage().hide();
    app.getStage().show();
    validerButton.disableProperty().bind(Bindings.not(Bindings
            .and(mainModel.getLocationsModel().validProperty(), mainModel.getCritereModel().validProperty())));
    StatisticsModel searchStatisticsModel = SpringFxmlLoader.getBean(StatisticsModel.class);
    mainModel.setSearchStatisticsModel(searchStatisticsModel);
}

From source file:org.kordamp.javatrove.example04.view.AppView.java

public Scene createScene() {
    String basename = getClass().getPackage().getName().replace('.', '/') + "/app";
    URL fxml = getClass().getClassLoader().getResource(basename + ".fxml");
    FXMLLoader fxmlLoader = new FXMLLoader(fxml);
    fxmlLoader.setControllerFactory(param -> AppView.this);
    Parent root = null;/* www . j a  v a2 s  .  c  om*/
    try {
        root = (Parent) fxmlLoader.load();
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }

    organization.textProperty().addListener((observable, oldValue, newValue) -> {
        model.setState(isBlank(newValue) ? DISABLED : READY);
    });

    model.stateProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> {
        switch (newValue) {
        case DISABLED:
            enabled.setValue(false);
            running.setValue(false);
            break;
        case READY:
            enabled.setValue(true);
            running.setValue(false);
            break;
        case RUNNING:
            enabled.setValue(false);
            running.setValue(true);
            break;
        }
    }));

    ObservableList<Repository> items = createJavaFXThreadProxyList(model.getRepositories().sorted());

    repositories.setItems(items);
    EventStreams.sizeOf(items).subscribe(v -> total.setText(String.valueOf(v)));
    organization.textProperty().bindBidirectional(model.organizationProperty());
    bindBidirectional(limit.textProperty(), model.limitProperty(), new NumberStringConverter());
    loadButton.disableProperty().bind(Bindings.not(enabled));
    cancelButton.disableProperty().bind(Bindings.not(running));
    progress.visibleProperty().bind(running);

    Scene scene = new Scene(root);
    scene.getStylesheets().addAll(basename + ".css", "bootstrapfx.css");
    return scene;
}

From source file:com.wineshop.client.Home.java

@Override
public void initialize(URL url, ResourceBundle bundle) {
    // Setup of the table view
    vineyards.setSortAdapter(new TableViewSortAdapter<Vineyard>(tableVineyards, Vineyard.class));
    vineyards.getFilter().nameProperty().bindBidirectional(fieldSearch.textProperty());

    // Setup of the creation/edit form
    labelFormVineyard.textProperty()//  ww  w .j av a  2 s .co m
            .bind(Bindings.when(vineyard.savedProperty()).then("Edit vineyard").otherwise("Create vineyard"));

    vineyard.instanceProperty().addListener(new ChangeListener<Vineyard>() {
        @Override
        public void changed(ObservableValue<? extends Vineyard> observable, Vineyard oldValue,
                Vineyard newValue) {
            if (oldValue != null) {
                fieldName.textProperty().unbindBidirectional(oldValue.nameProperty());
                fieldAddress.textProperty().unbindBidirectional(oldValue.getAddress().addressProperty());
                listWines.setItems(null);
            }
            if (newValue != null) {
                fieldName.textProperty().bindBidirectional(newValue.nameProperty());
                fieldAddress.textProperty().bindBidirectional(newValue.getAddress().addressProperty());
                listWines.setItems(newValue.getWines());
            }
        }
    });

    // Define the cell factory for the list of wines 
    listWines.setCellFactory(new Callback<ListView<Wine>, ListCell<Wine>>() {
        public ListCell<Wine> call(ListView<Wine> listView) {
            return new WineListCell();
        }
    });

    buttonDelete.visibleProperty().bind(vineyard.savedProperty());
    buttonDelete.disableProperty().bind(Bindings.not(identity.ifAllGranted("ROLE_ADMIN")));
    buttonSave.disableProperty().bind(Bindings.not(vineyard.dirtyProperty()));
    buttonCancel.disableProperty()
            .bind(Bindings.not(Bindings.or(vineyard.savedProperty(), vineyard.dirtyProperty())));

    // Link the table selection and the entity instance in the form 
    select(null);
    tableVineyards.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Vineyard>() {
        @Override
        public void changed(ObservableValue<? extends Vineyard> property, Vineyard oldSelection,
                Vineyard newSelection) {
            select(newSelection);
        }
    });

    formVineyard.addEventHandler(ValidationResultEvent.INVALID, new EventHandler<ValidationResultEvent>() {
        @Override
        public void handle(ValidationResultEvent event) {
            ((Node) event.getTarget()).setStyle("-fx-border-color: red");
            if (event.getTarget() instanceof TextInputControl && event.getErrorResults() != null
                    && event.getErrorResults().size() > 0) {
                Tooltip tooltip = new Tooltip(event.getErrorResults().get(0).getMessage());
                tooltip.setAutoHide(true);
                ((TextInputControl) event.getTarget()).setTooltip(tooltip);
            }
        }
    });
    formVineyard.addEventHandler(ValidationResultEvent.VALID, new EventHandler<ValidationResultEvent>() {
        @Override
        public void handle(ValidationResultEvent event) {
            ((Node) event.getTarget()).setStyle("-fx-border-color: null");
            if (event.getTarget() instanceof TextInputControl) {
                Tooltip tooltip = ((TextInputControl) event.getTarget()).getTooltip();
                if (tooltip != null && tooltip.isActivated())
                    tooltip.hide();
                ((TextInputControl) event.getTarget()).setTooltip(null);
            }
        }
    });
}