Example usage for javafx.beans.binding Bindings isNull

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

Introduction

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

Prototype

public static BooleanBinding isNull(final ObservableObjectValue<?> op) 

Source Link

Document

Creates a new javafx.beans.binding.BooleanBinding that holds true if the value of an javafx.beans.value.ObservableObjectValue is null .

Usage

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

@Override
public void initialize(URL location, ResourceBundle resources) {
    interfaceResources = resources;/*  w  w w . ja va 2  s.  c o  m*/

    Node scriptingTab = loadScriptTabContent();

    initialDirectory.addListener((observable, oldVal, newVal) -> {
        if (newVal != null)
            XdatEditor.getPrefs().put("initialDirectory", newVal.getPath());
    });
    editor.xdatClassProperty().addListener((ob, ov, nv) -> {
        log.log(Level.INFO, String.format("XDAT class selected: %s", nv.getName()));

        tabs.getTabs().clear();

        for (Iterator<InvalidationListener> it = xdatListeners.iterator(); it.hasNext();) {
            editor.xdatObjectProperty().removeListener(it.next());
            it.remove();
        }

        editor.setXdatObject(null);

        if (scriptingTab != null) {
            Tab tab = new Tab("script console");
            tab.setContent(scriptingTab);
            tabs.getTabs().add(tab);
        }

        Arrays.stream(nv.getDeclaredFields()).filter(field -> List.class.isAssignableFrom(field.getType()))
                .forEach(field -> {
                    field.setAccessible(true);
                    tabs.getTabs().add(createTab(field));
                });
    });
    progressBar.visibleProperty().bind(editor.workingProperty());
    open.disableProperty().bind(Bindings.isNull(editor.xdatClassProperty()));
    BooleanBinding nullXdatObject = Bindings.isNull(editor.xdatObjectProperty());
    tabs.disableProperty().bind(nullXdatObject);
    save.disableProperty().bind(nullXdatObject);
    saveAs.disableProperty().bind(nullXdatObject);

    xdatFile.addListener((observable, oldValue, newValue) -> {
        if (newValue == null)
            return;

        Collection<File> files = FileUtils.listFiles(newValue.getParentFile(),
                new WildcardFileFilter("SysString-*.dat"), null);
        if (!files.isEmpty()) {
            File file = files.iterator().next();
            log.info("sysstring file: " + file);
            try (InputStream is = L2Crypt.decrypt(new FileInputStream(file), file.getName())) {
                SysstringPropertyEditor.strings.clear();
                int count = IOUtil.readInt(is);
                for (int i = 0; i < count; i++) {
                    SysstringPropertyEditor.strings.put(IOUtil.readInt(is), IOUtil.readString(is));
                }
            } catch (Exception ignore) {
            }
        }

        File file = new File(newValue.getParentFile(), "L2.ini");
        try {
            TexturePropertyEditor.environment = new Environment(file);
            TexturePropertyEditor.environment.getPaths().forEach(s -> log.info("environment path: " + s));
        } catch (Exception ignore) {
        }
    });
}

From source file:mesclasses.view.JourneeController.java

/**
 * Initializes the controller class./*  w w  w .  j a v a2 s  .  c o  m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    LogUtil.logStart();
    name = "Journee Ctrl";
    super.initialize(url, rb);
    LOG.debug("Initialisation de " + name);
    initTabs();
    Btns.makeLeft(previousDayBtn);
    Btns.makeRight(nextDayBtn);
    Btns.makeLeft(seanceSelect.getBtnLeft());
    Btns.makeRight(seanceSelect.getBtnRight());

    Btns.makeAdd(addCoursBtn);
    Btns.makeDelete(remCoursBtn);

    Btns.tooltip(previousDayBtn, "Jour prcdent");
    Btns.tooltip(nextDayBtn, "Jour suivant");
    Btns.tooltip(seanceSelect.getBtnLeft(), "Sance prcdente");
    Btns.tooltip(seanceSelect.getBtnRight(), "Sance suivante");
    Btns.tooltip(addCoursBtn, "Ajouter une sance ponctuelle");
    Btns.tooltip(remCoursBtn, "Supprimer la sance ponctuelle");
    Btns.tooltip(switchNonActifsBtn, "active/dsactive l'affichage des lves inactifs");
    Btns.tooltip(rapportsBtn, "Ouvre la page des rapports trimestriels pour la classe");
    Btns.tooltip(punitionsBtn, "Ouvre le suivi des punitions, devoirs et mots pour la classe");
    Btns.tooltip(postItBtn, "ouvre le postIt de la classe");
    Btns.tooltip(ramasserBtn, "ouvre la fentre des actions  faire pour la classe");

    currentDate.setDayCellFactory(new TunedDayCellFactory().setAllowSundays(false));
    currentDate.setConverter(NodeUtil.DATE_WITH_DAY_NAME);

    currentDate.valueProperty().addListener(dateListener);

    displayNonActifs = new SimpleBooleanProperty(false);
    switchNonActifsBtn.setText("Afficher inactifs");
    displayNonActifs.addListener((observable, oldValue, newValue) -> {

        LOG.debug("Switch actifs/inactifs");
        switchNonActifsBtn.setText(displayNonActifs.get() ? "Masquer inactifs" : "Afficher inactifs");
        refreshGrid();
    });

    seanceSelect.addChangeListener((ob, o, n) -> {
        LOG.debug("seanceSelect changed --> reloading");
        loadCurrentSeance();
    });
    // activation du bouton remCours si besoin
    rapportsBtn.disableProperty().bind(Bindings.isNull(seanceSelect.valueProperty()));
    punitionsBtn.disableProperty().bind(Bindings.isNull(seanceSelect.valueProperty()));
    postItBtn.disableProperty().bind(Bindings.isNull(seanceSelect.valueProperty()));

    // on ne change que la date, le listener sur currentDate se charge du reste
    LocalDate today = LocalDate.now();
    if (today.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
        today = today.minusDays(1);
    }
    LOG.debug("Initializing with today's date");
    currentDate.setValue(today);
    LogUtil.logEnd();
}

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

private void initializeUsx() {
    staticMeshDirProperty().addListener((observable, oldValue, newValue) -> {
        smPane.setDisable(true);/*  w w w  .j av  a2s . 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);
}