Example usage for javafx.scene.control TextField setStyle

List of usage examples for javafx.scene.control TextField setStyle

Introduction

In this page you can find the example usage for javafx.scene.control TextField setStyle.

Prototype

public final void setStyle(String value) 

Source Link

Document

A string representation of the CSS style associated with this specific Node .

Usage

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 a  v  a  2  s.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:snpviewer.SnpViewer.java

public void refreshView(String chrom, boolean forceRedraw) {
    //if forceRedraw is false look for existing png files for each snpFile
    if (chrom == null) {
        /*if null is passed then select/reselect chromosome from 
         * chromosomeSelector, return and let chromosomeSelector's 
         * listener refire this method//  w  w w .j  ava  2  s  .  c  om
         */
        if (chromosomeSelector.getSelectionModel().isEmpty()) {
            chromosomeSelector.getSelectionModel().selectFirst();
        } else {
            int sel = chromosomeSelector.getSelectionModel().getSelectedIndex();
            chromosomeSelector.getSelectionModel().clearSelection();
            chromosomeSelector.getSelectionModel().select(sel);
        }
        return;
    }
    int totalFiles = affFiles.size() + unFiles.size();
    if (totalFiles < 1) {
        return;
    }
    ArrayList<Pane> panesToAdd = new ArrayList<>();
    ArrayList<ScrollPane> labelsToAdd = new ArrayList<>();
    clearSplitPanes();

    setProgressMode(true);
    nextChromMenu.setDisable(false);
    nextChromMenu.setDisable(false);
    for (final SnpFile f : affFiles) {
        Pane sPane = new Pane();
        sPane.setMinHeight(chromSplitPane.getHeight() / totalFiles);
        sPane.setMinWidth(chromSplitPane.getWidth());
        sPane.setVisible(true);
        panesToAdd.add(sPane);
        ScrollPane labelPane = new ScrollPane();
        Label fileLabel = new Label(f.inputFile.getName() + "\n(Affected)");
        fileLabel.setTextFill(Color.WHITE);
        labelPane.setMinHeight(labelSplitPane.getHeight() / totalFiles);
        labelPane.setPrefWidth(labelSplitPane.getWidth());
        labelPane.minHeightProperty().bind(labelSplitPane.heightProperty().divide(totalFiles));
        VBox vbox = new VBox();
        vbox.setSpacing(10);
        vbox.getChildren().add(fileLabel);
        final TextField textField = new TextField();
        textField.setStyle("-fx-text-fill: white; -fx-background-color: "
                + "rgba(90%,90%,90%,0.3); -fx-border-color:white");
        textField.setPromptText("Sample Name");
        if (f.getSampleName() != null) {
            textField.setText(f.getSampleName());
        }
        textField.setFocusTraversable(true);
        textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent ke) {
                if (ke.getCode().equals(KeyCode.ENTER)) {
                    if (!textField.getText().isEmpty()) {
                        String name = textField.getText().trim();
                        if (name.length() > 0) {
                            f.setSampleName(name);
                        }
                        textField.getParent().requestFocus();
                        saveProject();
                    }
                }
            }
        });
        textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue,
                    Boolean newValue) {
                if (!textField.isFocused()) {
                    if (!textField.getText().isEmpty()) {
                        String name = textField.getText().trim();
                        if (name.length() > 0) {
                            f.setSampleName(name);
                        }
                        saveProject();
                    }
                }
            }
        });
        vbox.getChildren().add(textField);
        Label noCalls = new Label();
        if (f.getPercentNoCall() != null) {
            noCalls.setText("No Calls: " + DecimalFormat.getInstance().format(f.getPercentNoCall()) + " %");
        } else {
            noCalls.setText("No Calls: none");
        }
        Label meanQual = new Label();
        if (f.getMeanQuality() != null) {
            meanQual.setText("Av. Call Conf: "
                    + DecimalFormat.getInstance().format(100 - (f.getMeanQuality() * 100)) + " %");
        } else {
            meanQual.setText("No Call Confidence Data");
        }
        vbox.getChildren().add(noCalls);
        vbox.getChildren().add(meanQual);
        labelPane.setContent(vbox);
        //            labelPane.getChildren().add(fileLabel);
        //            labelPane.getChildren().add(new TextField());
        labelsToAdd.add(labelPane);
    }
    for (final SnpFile f : unFiles) {
        Pane sPane = new Pane();
        sPane.setMinHeight(chromSplitPane.getHeight() / totalFiles);
        sPane.setMinWidth(chromSplitPane.getWidth());
        sPane.setVisible(true);
        panesToAdd.add(sPane);
        ScrollPane labelPane = new ScrollPane();
        Label fileLabel = new Label(f.inputFile.getName() + "\n(Unaffected)");
        fileLabel.setStyle("-fx-text-fill: black");
        labelPane.setMinHeight(labelSplitPane.getHeight() / totalFiles);
        labelPane.setPrefWidth(labelSplitPane.getWidth());
        labelPane.minHeightProperty().bind(labelSplitPane.heightProperty().divide(totalFiles));
        VBox vbox = new VBox();
        vbox.setSpacing(10);
        vbox.getChildren().add(fileLabel);
        final TextField textField = new TextField();
        textField.setStyle("-fx-text-fill: black; " + "-fx-background-color: rgba(90%,90%,90%,0.3);"
                + " -fx-border-color:white");
        textField.setPromptText("Sample Name");
        if (f.getSampleName() != null) {
            textField.setText(f.getSampleName());
        }
        textField.setFocusTraversable(true);
        textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent ke) {
                if (ke.getCode().equals(KeyCode.ENTER)) {
                    if (!textField.getText().isEmpty()) {
                        f.setSampleName(textField.getText());
                        textField.getParent().requestFocus();
                        saveProject();
                    }
                }
            }
        });
        textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue,
                    Boolean newValue) {
                if (!textField.isFocused()) {
                    if (!textField.getText().isEmpty()) {
                        f.setSampleName(textField.getText());
                        saveProject();
                    }
                }
            }
        });
        vbox.getChildren().add(textField);
        Label noCalls = new Label();
        if (f.getPercentNoCall() != null) {
            noCalls.setText("No Calls: " + DecimalFormat.getInstance().format(f.getPercentNoCall()) + " %");
        } else {
            noCalls.setText("No Calls: none");
        }
        Label meanQual = new Label();
        if (f.getMeanQuality() != null) {
            meanQual.setText("Av. Call Conf: "
                    + DecimalFormat.getInstance().format(100 - (f.getMeanQuality() * 100)) + " %");
        } else {
            meanQual.setText("No Call Confidence Data");
        }
        vbox.getChildren().add(noCalls);
        vbox.getChildren().add(meanQual);
        labelPane.setContent(vbox);
        //            labelPane.getChildren().add(fileLabel);
        labelsToAdd.add(labelPane);
    }
    if (panesToAdd.size() > 0) {
        chromSplitPane.getItems().addAll(panesToAdd);
        labelSplitPane.getItems().addAll(labelsToAdd);

        ArrayList<SnpFile> bothFiles = new ArrayList<>(affFiles);
        bothFiles.addAll(unFiles);
        final Iterator<SnpFile> fileIter = bothFiles.iterator();
        final Iterator<Pane> paneIter = panesToAdd.iterator();
        SnpFile firstFileToProcess = fileIter.next();
        Pane firstPaneToProcess = paneIter.next();
        String pngPath = null;
        if (qualityFilter != null) {
            Integer percent = new Integer(100 - (int) (qualityFilter * 100));
            pngPath = percent.toString();
        }
        drawWithIterator(firstFileToProcess, firstPaneToProcess, pngPath, fileIter, paneIter, 1, totalFiles,
                chrom, forceRedraw, chromSplitPane);
    } else {
        setProgressMode(false);
    }
}