Example usage for javafx.beans.binding Bindings or

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

Introduction

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

Prototype

public static BooleanBinding or(final ObservableBooleanValue op1, final ObservableBooleanValue op2) 

Source Link

Document

Creates a BooleanBinding that calculates the conditional-OR operation on the value of two instance of javafx.beans.value.ObservableBooleanValue .

Usage

From source file:mesclasses.view.RapportEleveController.java

/**
 * Initializes the controller class.//from  w w  w .j  av a 2  s  .co  m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    name = "Rapport Classe Ctrl";
    super.initialize(url, rb);

    trimestreIndex = new SimpleIntegerProperty();
    selectedTrimestre = new SimpleStringProperty();
    selectedFileType = new SimpleStringProperty();
    selectBulletin();
    selectedFileType.addListener((observable, oldValue, newValue) -> {
        refreshGrid();
    });
    trimestreLabel.textProperty().bind(selectedTrimestre);

    previousBtn.disableProperty()
            .bind(Bindings.or(Bindings.size(trimestres).lessThan(2), trimestreIndex.isEqualTo(0)));
    Btns.makeLeft(previousBtn);
    nextBtn.disableProperty().bind(Bindings.or(Bindings.size(trimestres).lessThan(2),
            trimestreIndex.isEqualTo(trimestres.size() - 1)));
    Btns.makeRight(nextBtn);

    bulletinBtn.prefWidthProperty().bind(bulletinPane.widthProperty());
    vieScolaireBtn.prefWidthProperty().bind(vieScolairePane.widthProperty());
    orientationBtn.prefWidthProperty().bind(orientationPane.widthProperty());

}

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()/*from  www .  j ava 2  s. com*/
            .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);
            }
        }
    });
}

From source file:acmi.l2.clientmod.l2smr.Controller.java

private void initializeUsx() {
    staticMeshDirProperty().addListener((observable, oldValue, newValue) -> {
        smPane.setDisable(true);//from  ww w. ja v a2  s. c  o m

        usxChooser.getSelectionModel().clearSelection();
        usxChooser.getItems().clear();

        if (newValue == null) {
            return;
        }

        smPane.setDisable(false);
        usxChooser.getItems().addAll(Arrays.stream(newValue.listFiles(STATICMESH_FILE_FILTER))
                .map(File::getName).collect(Collectors.toList()));
        AutoCompleteComboBox.autoCompleteComboBox(usxChooser, AutoCompleteComboBox.AutoCompleteMode.CONTAINING);
    });
    this.usx.bind(Bindings.createObjectBinding(() -> {
        String selected = usxChooser.getSelectionModel().getSelectedItem();
        if (selected == null)
            return null;
        return new File(getStaticMeshDir(), selected);
    }, staticMeshDirProperty(), usxChooser.getSelectionModel().selectedItemProperty()));
    this.usx.addListener((observable, oldValue, newValue) -> {
        smChooser.getSelectionModel().clearSelection();
        smChooser.getItems().clear();
        smChooser.setDisable(true);
        if (newValue == null) {
            return;
        }

        try (UnrealPackage up = new UnrealPackage(newValue, true)) {
            smChooser.getItems().setAll(up.getExportTable().stream()
                    .filter(entry -> entry.getObjectClass().getObjectFullName().equals("Engine.StaticMesh"))
                    .map(UnrealPackage.ExportEntry::getObjectInnerFullName)
                    .sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList()));
            smChooser.setDisable(false);
            AutoCompleteComboBox.autoCompleteComboBox(smChooser,
                    AutoCompleteComboBox.AutoCompleteMode.CONTAINING);
        } catch (Exception e) {
            onException("Read failed", e);
        }
    });
    this.smView.disableProperty().bind(Bindings.isNull(smChooser.getSelectionModel().selectedItemProperty()));
    ObservableBooleanValue b = Bindings.or(
            Bindings.isNull(unrChooser.getSelectionModel().selectedItemProperty()),
            Bindings.isNull(smChooser.getSelectionModel().selectedItemProperty()));
    this.addToUnr.disableProperty().bind(b);
    this.createNew.disableProperty().bind(b);
}

From source file:org.sleuthkit.autopsy.timeline.ShowInTimelineDialog.java

/**
 * Constructor for file based dialog. Allows the user to choose an event
 * (MAC time) derived from the given file
 *
 * @param controller The controller for this Dialog.
 * @param file       The AbstractFile to configure this dialog for.
 *///w  ww  .jav  a2 s .  c o m
@NbBundle.Messages({ "# {0} - file path", "ShowInTimelineDialog.fileTitle=View {0} in timeline.",
        "ShowInTimelineDialog.eventSelectionValidator.message=You must select an event." })
ShowInTimelineDialog(TimeLineController controller, AbstractFile file) {
    this(controller, controller.getEventsModel().getEventIDsForFile(file, false));

    /*
     * since ValidationSupport does not support list selection, we will
     * manually apply and remove decoration in response to selection
     * property changes.
     */
    eventTable.getSelectionModel().selectedItemProperty().isNull()
            .addListener((selectedItemNullProperty, wasNull, isNull) -> {
                if (isNull) {
                    validationSupport.getValidationDecorator().applyValidationDecoration(ValidationMessage
                            .error(eventTable, Bundle.ShowInTimelineDialog_eventSelectionValidator_message()));
                } else {
                    validationSupport.getValidationDecorator().removeDecorations(eventTable);
                }
            });

    //require selection and validation of ammount spinner to enable show button
    getDialogPane().lookupButton(SHOW).disableProperty().bind(Bindings.or(validationSupport.invalidProperty(),
            eventTable.getSelectionModel().selectedItemProperty().isNull()));

    //set result converter that uses selection.
    setResultConverter(buttonType -> (buttonType == SHOW)
            ? makeEventInTimeRange(eventTable.getSelectionModel().getSelectedItem())
            : null);

    setTitle(Bundle.ShowInTimelineDialog_fileTitle(
            StringUtils.abbreviateMiddle(getContentPathSafe(file), " ... ", 50)));
}