Example usage for javafx.scene.control CheckBox setSelected

List of usage examples for javafx.scene.control CheckBox setSelected

Introduction

In this page you can find the example usage for javafx.scene.control CheckBox setSelected.

Prototype

public final void setSelected(boolean value) 

Source Link

Usage

From source file:ninja.javafx.smartcsv.fx.validation.ValidationEditorController.java

private void updateTextInputControl(TextInputControl rule, String value, CheckBox ruleEnabled) {
    if (value == null) {
        ruleEnabled.setSelected(false);
    } else {//from ww  w . j a  v  a2 s  . c  o  m
        ruleEnabled.setSelected(true);
        rule.setText(value);
    }
}

From source file:ninja.javafx.smartcsv.fx.validation.ValidationEditorController.java

private void updateCodeAreaControl(CodeArea rule, String value, CheckBox ruleEnabled) {
    if (value == null) {
        ruleEnabled.setSelected(false);
    } else {/*from w  w w .j a  v  a2 s. c o m*/
        ruleEnabled.setSelected(true);
        rule.replaceText(0, rule.getLength(), value);
    }
}

From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java

private void addCheckBox(String id, String name, String path, boolean selected, boolean delete) {
    HBox hbox = new HBox();
    hbox.setAlignment(Pos.CENTER_LEFT);/*from  www.j av a2 s  . c  o  m*/

    CheckBox chk = new CheckBox(name);
    chk.setId(id);
    chk.getStyleClass().add("checkreport");
    chk.setSelected(selected);
    chk.setEllipsisString(" ... ");
    chk.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
    chk.setTooltip(new Tooltip(path));
    hbox.getChildren().add(chk);

    // EDIT
    Button edit = new Button();
    edit.getStyleClass().addAll("edit-img", "action-img-16");
    edit.setCursor(Cursor.HAND);
    edit.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            String iso = chk.getId();
            String path = null;
            if (iso.startsWith("external")) {
                iso = chk.getText();
                path = iso;
            } else if (chk.getId().startsWith("config")) {
                iso = chk.getId().replace("config", "");
                path = DPFManagerProperties.getIsosDir() + "/" + iso;
            }
            controller.editIso(iso, path);
        }
    });
    hbox.getChildren().add(edit);
    HBox.setMargin(edit, new Insets(0, 0, 0, 10));

    // DELETE
    if (delete) {
        Button icon = new Button();
        icon.getStyleClass().addAll("delete-img", "action-img-16");
        icon.setCursor(Cursor.HAND);
        icon.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                if (chk.getId().startsWith("external")) {
                    // Only from gui
                    vboxRadios.getChildren().remove(hbox);
                } else if (chk.getId().startsWith("config")) {
                    // From system
                    String name = chk.getId().replace("config", "");
                    File file = new File(DPFManagerProperties.getIsosDir() + "/" + name);
                    if (file.exists() && file.isFile() && acceptDelete(file)) {
                        file.delete();
                        vboxRadios.getChildren().remove(hbox);
                    }
                }
            }
        });
        hbox.getChildren().add(icon);
        HBox.setMargin(icon, new Insets(0, 0, 0, 10));
    }

    vboxRadios.getChildren().add(hbox);
}

From source file:ninja.javafx.smartcsv.fx.validation.ValidationEditorController.java

private void updateTextInputControl(TextInputControl rule, List<String> values, CheckBox ruleEnabled) {
    if (values == null || values.isEmpty()) {
        ruleEnabled.setSelected(false);
    } else {/*from  w  ww  .ja  v  a2  s  . co  m*/
        ruleEnabled.setSelected(true);
        rule.setText(values.stream().collect(joining(", ")));
    }
}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

private List<Triple<String, Node, String>> createConfigurationForm() {
    final List<Triple<String, Node, String>> formItems = new ArrayList<>();

    // Headline pattern
    final TextField textInput = new TextField(this.logReader.getHeadlinePattern());
    textInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        this.logReader.setHeadlinePattern(newValue);
        this.setChanged(true);
    });/*  w ww  .j  ava  2s. c  o  m*/
    textInput.setStyle("-fx-font-family: monospace");
    formItems.add(Triple.of("Headline Pattern", textInput,
            "The perl style regular expression is used to spot the beginning of"
                    + " log entries in the log file. If a log entry consists of multiple lines, this pattern must only match the first"
                    + " line, called \"head line\". Groups can intentionally be matched to spot values like timestamp or channel name."
                    + " All matching groups are removed from the payload before they are processed by an automaton."));

    // Index of timestamp
    Supplier<Integer> getter = () -> this.logReader.getHeadlinePatternIndexOfTimestamp();
    Consumer<Integer> setter = value -> this.logReader.setHeadlinePatternIndexOfTimestamp(value);
    final TextField indexOfTimestampInput = this.createIntegerInputField(textInput, getter, setter);
    formItems.add(Triple.of("Timestamp Group", indexOfTimestampInput,
            "Denotes which matching group in the headline pattern contains"
                    + " the timestamp. Index 0 references the whole pattern match, index 1 is the first matching group etc. The timestamp must"
                    + " always be a valid integer. Currently, this integer is always interpreted as milliseconds. If no value is set, no"
                    + " timestamp will be extracted and timing conditions cannot be used. If the referenced matching group is optional"
                    + " and does not match for a specific head line, the last recent timestamp will be used for the extracted log entry."));

    // Index of channel
    getter = () -> this.logReader.getHeadlinePatternIndexOfChannel();
    setter = value -> this.logReader.setHeadlinePatternIndexOfChannel(value);
    final TextField indexOfChannelInput = this.createIntegerInputField(textInput, getter, setter);
    formItems.add(Triple.of("Channel Group", indexOfChannelInput,
            "Denotes which matching group in the headline pattern contains"
                    + " the channel. If the value is empty or the matching group is optional and it did not match, the default channel is used"
                    + " for the extracted log entry."));

    // Trim payload
    CheckBox cb = new CheckBox();
    cb.setSelected(this.logReader.getTrimPayload());
    cb.selectedProperty().addListener((ChangeListener<Boolean>) (observable, oldValue, newValue) -> {
        this.logReader.setTrimPayload(BooleanUtils.toBoolean(newValue));
        this.setChanged(true);
    });
    formItems.add(Triple.of("Trim Payload", cb, "Only has effect on multiline payloads."
            + " If enabled, all leading and trailing whitespaces are removed from the payload"
            + " after the matching groups are removed. This allows for regular expressions in the automaton that match the beginning"
            + " and the end of the payload, without having to take care too much for whitespaces in the source log file."));

    // Handling of non headline lines
    this.createInputForHandlingOfNonHeadlineLines(formItems);

    // Trim payload
    cb = new CheckBox();
    cb.setSelected(this.logReader.getRemoveEmptyPayloadLinesFromMultilineEntry());
    cb.selectedProperty().addListener((ChangeListener<Boolean>) (observable, oldValue, newValue) -> {
        this.logReader.setRemoveEmptyPayloadLinesFromMultilineEntry(BooleanUtils.toBoolean(newValue));
        this.setChanged(true);
    });
    formItems.add(Triple.of("Remove Empty Lines", cb,
            "If enabled, empty lines will be removed from multiline payload entries."));

    // Charset
    final SortedMap<String, Charset> charsets = Charset.availableCharsets();
    final ChoiceBox<String> encodingInput = new ChoiceBox<>(
            FXCollections.observableArrayList(charsets.keySet()));
    encodingInput.getSelectionModel().select(this.logReader.getLogFileCharset().name());
    encodingInput.getSelectionModel().selectedItemProperty()
            .addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
                this.logReader.setLogFileCharset(charsets.get(newValue));
                this.setChanged(true);
            });
    formItems.add(Triple.of("Log File Encoding", encodingInput,
            "Encoding of the log file. Note that some of the encodings are"
                    + " platform specific such that reading the log on a different platform might fail. Usually, log files are written"
                    + " using UTF-8, UTF-16, ISO-8859-1 or ASCII."));

    return formItems;
}

From source file:com.github.drbookings.ui.controller.BookingDetailsController.java

private void addRow5(final Pane content, final BookingBean be) {
    final HBox box = new HBox();
    box.setPadding(new Insets(4));
    box.setFillHeight(true);/*  www  . ja  v  a  2s  . co m*/
    final Text text = new Text("Welcome Mail sent: ");
    final CheckBox checkBox = new CheckBox();
    checkBox.setSelected(be.isWelcomeMailSend());
    booking2WelcomeMail.put(be, checkBox);
    final Text t1 = new Text(" \tPayment done: ");

    final CheckBox cb1 = new CheckBox();
    cb1.setSelected(be.isPaymentDone());

    //if (logger.isDebugEnabled()) {
    //   logger.debug("DateOfPayment for " + be + "(" + be.hashCode() + ") is " + be.getDateOfPayment());
    //}

    final DatePicker dp = new DatePicker();
    dp.setValue(be.getDateOfPayment());

    dp.setPrefWidth(140);
    booking2PaymentDate.put(be, dp);

    booking2Payment.put(be, cb1);
    final TextFlow tf = new TextFlow();
    tf.getChildren().addAll(text, checkBox, t1, cb1, dp);
    box.getChildren().add(tf);
    if (!be.isWelcomeMailSend() || !be.isPaymentDone()) {
        box.getStyleClass().addAll("warning", "warning-bg");
    } else {
        box.getStyleClass().removeAll("warning", "warning-bg");
    }

    HBox box2 = new HBox();
    box2.setPadding(new Insets(4));
    box2.setFillHeight(true);
    TextField newPayment = new TextField();
    Button addNewPaymentButton = new Button("Add payment");
    addNewPaymentButton.setOnAction(e -> {
        addNewPayment(newPayment.getText(), be);
    });
    box2.getChildren().addAll(newPayment, addNewPaymentButton);

    content.getChildren().addAll(box, box2);

}

From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java

private Node createCheckBoxInput(final String propertyName, final Boolean initialValue,
        final Consumer<Boolean> applyValue) {
    final CheckBox result = new CheckBox(propertyName);
    result.setSelected(BooleanUtils.isTrue(initialValue));
    result.setOnAction(event -> {/*  w w w  .j a  va 2 s . co m*/
        applyValue.accept(result.isSelected());
        this.getGraph().handleChange();
    });
    return result;
}

From source file:mesclasses.view.JourneeController.java

/**
 * dessine la grid travail//from   w  w w . jav  a2s.  c  om
 * @param eleve
 * @param rowIndex 
 */
private void drawTravail(Eleve eleve, int rowIndex) {

    EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve);
    drawEleveName(travailGrid, eleve, rowIndex);
    if (!eleve.isInClasse(currentDate.getValue())) {
        return;
    }
    CheckBox travailBox = new CheckBox();
    Bindings.bindBidirectional(travailBox.selectedProperty(), eleveData.travailPasFaitProperty());
    travailGrid.add(travailBox, 3, rowIndex, null);
    Label cumulTravail = new Label();
    travailBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
        writeAndMarkInRed(cumulTravail, stats.getNbTravailUntil(eleve, currentDate.getValue()), 3);
    });
    writeAndMarkInRed(cumulTravail, stats.getNbTravailUntil(eleve, currentDate.getValue()), 3);
    travailGrid.add(cumulTravail, 4, rowIndex, null);

    CheckBox devoirBox = new CheckBox();
    devoirBox.setSelected(model.getDevoirForSeance(eleve, seanceSelect.getValue()) != null);
    devoirBox.selectedProperty().addListener((ob, o, checked) -> {
        Devoir devoir = model.getDevoirForSeance(eleve, seanceSelect.getValue());
        if (checked && devoir == null) {
            model.createDevoir(eleve, seanceSelect.getValue());
        } else if (devoir != null) {
            model.delete(devoir);
        }
    });
    travailGrid.add(devoirBox, 5, rowIndex, null);

    TextField oubliMaterielField = new TextField();
    Bindings.bindBidirectional(oubliMaterielField.textProperty(), eleveData.oubliMaterielProperty());
    travailGrid.add(oubliMaterielField, 6, rowIndex, HPos.LEFT);
    Label cumulOubli = new Label();
    oubliMaterielField.textProperty().addListener((observable, oldValue, newValue) -> {
        writeAndMarkInRed(cumulOubli, stats.getNbOublisUntil(eleve, currentDate.getValue()), 3);
    });

    writeAndMarkInRed(cumulOubli, stats.getNbOublisUntil(eleve, currentDate.getValue()), 3);
    travailGrid.add(cumulOubli, 7, rowIndex, null);

}

From source file:mesclasses.view.JourneeController.java

/**
 * dessine la grid sanctions//from   www  .j  av  a  2  s.  c om
 * @param eleve
 * @param rowIndex 
 */
private void drawSanctions(Eleve eleve, int rowIndex) {
    EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve);

    drawEleveName(sanctionsGrid, eleve, rowIndex);
    if (!eleve.isInClasse(currentDate.getValue())) {
        return;
    }
    HBox punitionsBox = new HBox();
    punitionsBox.setAlignment(Pos.CENTER_LEFT);
    TextFlow nbPunitions = new TextFlow();
    Label nbPunitionLabel = new Label(
            "" + eleve.getPunitions().stream().filter(p -> p.getSeance() == seanceSelect.getValue()).count());
    nbPunitionLabel.setPrefHeight(20);
    nbPunitions.getChildren().add(new Label(" ("));
    nbPunitions.getChildren().add(nbPunitionLabel);
    nbPunitions.getChildren().add(new Label(")"));

    nbPunitions.visibleProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0"));
    nbPunitions.managedProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0"));

    Button punitionBtn = Btns.punitionBtn();
    punitionBtn.setOnAction((event) -> {
        if (openPunitionDialog(eleve)) {
            int nbPunition = Integer.parseInt(nbPunitionLabel.getText());
            nbPunitionLabel.setText("" + (nbPunition + 1));
        }
    });
    punitionsBox.getChildren().add(punitionBtn);
    punitionsBox.getChildren().add(nbPunitions);

    sanctionsGrid.add(punitionsBox, 3, rowIndex, HPos.LEFT);

    CheckBox motCarnet = new CheckBox();
    Label cumulMot = new Label();
    motCarnet.setSelected(model.getMotForSeance(eleve, seanceSelect.getValue()) != null);
    motCarnet.selectedProperty().addListener((ob, o, checked) -> {
        Mot mot = model.getMotForSeance(eleve, seanceSelect.getValue());
        if (checked && mot == null) {
            model.createMot(eleve, seanceSelect.getValue());
        } else if (mot != null) {
            model.delete(mot);
        }
        writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3);
    });
    sanctionsGrid.add(motCarnet, 4, rowIndex, null);
    writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3);
    sanctionsGrid.add(cumulMot, 5, rowIndex, null);

    CheckBox exclus = new CheckBox();
    TextField motif = new TextField();
    Bindings.bindBidirectional(exclus.selectedProperty(), eleveData.exclusProperty());
    sanctionsGrid.add(exclus, 6, rowIndex, null);
    exclus.selectedProperty().addListener((o, oldV, newV) -> {
        if (!newV && StringUtils.isNotBlank(motif.getText())
                && ModalUtil.confirm("Effacer le motif ?", "Effacer le motif ?")) {
            motif.clear();
        }
    });

    Bindings.bindBidirectional(motif.textProperty(), eleveData.MotifProperty());
    motif.textProperty().addListener((o, oldV, newV) -> {
        if (StringUtils.isNotBlank(newV)) {
            exclus.setSelected(true);
        }
    });
    GridPane.setMargin(motif, new Insets(0, 10, 0, 0));
    sanctionsGrid.add(motif, 7, rowIndex, HPos.LEFT);

}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param lstPano/*from w ww.j a  v a 2 s  .co m*/
 * @param numPano
 * @return
 */
public Pane affichageHS(String lstPano, int numPano) {

    Pane panneauHotSpots = new Pane();
    panneauHotSpots.setTranslateY(10);
    panneauHotSpots.setTranslateX(30);
    VBox vb1 = new VBox(5);
    panneauHotSpots.getChildren().add(vb1);
    Label lblPoint;
    Label sep = new Label(" ");
    Label sep1 = new Label(" ");
    int o;
    for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspots(); o++) {
        VBox vbPanneauHS = new VBox();
        double deplacement = 20;
        vbPanneauHS.setLayoutX(deplacement);
        Pane pannneauHS = new Pane(vbPanneauHS);
        pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;");
        panneauHotSpots.setId("HS" + o);
        lblPoint = new Label("Point n" + (o + 1));
        lblPoint.setPadding(new Insets(5, 10, 5, 5));
        lblPoint.setTranslateX(-deplacement);
        lblPoint.setStyle("-fx-background-color : #333;");
        lblPoint.setTextFill(Color.WHITE);
        Separator sp = new Separator(Orientation.HORIZONTAL);
        sp.setTranslateX(-deplacement);
        sp.setPrefWidth(300);

        pannneauHS.setPrefWidth(300);
        pannneauHS.setTranslateX(5);
        vbPanneauHS.getChildren().addAll(lblPoint, sp);
        if (lstPano != null) {
            Label lblLien = new Label("Panoramique de destination");
            ComboBox cbDestPano = new ComboBox();
            String[] liste = lstPano.split(";");
            cbDestPano.getItems().addAll(Arrays.asList(liste));
            cbDestPano.valueProperty().addListener(new ChangeListener<String>() {
                @Override
                public void changed(ObservableValue ov, String t, String t1) {
                    valideHS();
                }
            });
            cbDestPano.setTranslateX(60);
            cbDestPano.setId("cbpano" + o);

            String f1XML = panoramiquesProjet[numPano].getHotspot(o).getFichierXML();
            if (f1XML != null) {
                cbDestPano.setValue(f1XML.split("\\.")[0]);
            }
            int num = cbDestPano.getSelectionModel().getSelectedIndex();
            vbPanneauHS.getChildren().addAll(lblLien, cbDestPano, sep);
        }
        Label lblTexteHS = new Label("Texte du Hotspot");
        TextArea txtTexteHS = new TextArea();
        if (panoramiquesProjet[numPano].getHotspot(o).getInfo() != null) {
            txtTexteHS.setText(panoramiquesProjet[numPano].getHotspot(o).getInfo());
        }
        txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable,
                final String oldValue, final String newValue) -> {
            valideHS();
        });

        txtTexteHS.setId("txtHS" + o);
        txtTexteHS.setPrefSize(200, 25);
        txtTexteHS.setMaxSize(200, 20);
        txtTexteHS.setTranslateX(60);
        CheckBox cbAnime = new CheckBox("HostSpot Anim");
        cbAnime.setId("anime" + o);
        cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable,
                final Boolean oldValue, final Boolean newValue) -> {
            valideHS();
        });
        if (panoramiquesProjet[numPano].getHotspot(o).isAnime()) {
            cbAnime.setSelected(true);
        }
        cbAnime.setPadding(new Insets(5));
        cbAnime.setTranslateX(60);
        vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1);
        vb1.getChildren().addAll(pannneauHS, sep);
    }
    int nbHS = o;
    for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspotImage(); o++) {
        VBox vbPanneauHS = new VBox();
        Pane pannneauHS = new Pane(vbPanneauHS);
        pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;");
        panneauHotSpots.setId("HSImg" + o);
        lblPoint = new Label("Image n" + (o + 1));
        lblPoint.setPadding(new Insets(5, 10, 5, 5));
        lblPoint.setStyle("-fx-background-color : #666;");
        lblPoint.setTextFill(Color.WHITE);
        Separator sp = new Separator(Orientation.HORIZONTAL);
        sp.setPrefWidth(300);

        pannneauHS.setPrefWidth(300);
        pannneauHS.setTranslateX(5);
        vbPanneauHS.getChildren().addAll(lblPoint, sp);
        Label lblLien = new Label("Image choisie :");
        String f1XML = panoramiquesProjet[numPano].getHotspotImage(o).getLienImg();
        ImageView IMChoisie = new ImageView(
                new Image("file:" + repertTemp + File.separator + "images" + File.separator + f1XML, 100, -1,
                        true, true));
        IMChoisie.setTranslateX(100);
        vbPanneauHS.getChildren().addAll(lblLien, IMChoisie, sep);
        Label lblTexteHS = new Label("Texte du Hotspot");
        TextArea txtTexteHS = new TextArea();
        if (panoramiquesProjet[numPano].getHotspotImage(o).getInfo() != null) {
            txtTexteHS.setText(panoramiquesProjet[numPano].getHotspotImage(o).getInfo());
        }
        txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable,
                final String oldValue, final String newValue) -> {
            valideHS();
        });

        txtTexteHS.setId("txtHSImage" + o);
        txtTexteHS.setPrefSize(200, 25);
        txtTexteHS.setMaxSize(200, 20);
        txtTexteHS.setTranslateX(60);
        CheckBox cbAnime = new CheckBox("HostSpot Anim");
        cbAnime.setId("animeImage" + o);
        cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable,
                final Boolean oldValue, final Boolean newValue) -> {
            valideHS();
        });
        if (panoramiquesProjet[numPano].getHotspotImage(o).isAnime()) {
            cbAnime.setSelected(true);
        }
        cbAnime.setPadding(new Insets(5));
        cbAnime.setTranslateX(60);
        vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1);
        vb1.getChildren().addAll(pannneauHS, sep);
    }
    valideHS();
    nbHS += o;
    //        if (nbHS == 0) {
    //        } else {
    //            btnValider.setVisible(true);
    //        }
    return panneauHotSpots;
}