Example usage for javafx.scene.control Tooltip Tooltip

List of usage examples for javafx.scene.control Tooltip Tooltip

Introduction

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

Prototype

public Tooltip(String text) 

Source Link

Document

Creates a tooltip with the specified text.

Usage

From source file:io.bitsquare.gui.main.funds.withdrawal.WithdrawalView.java

private void selectForWithdrawal(WithdrawalListItem item, boolean isSelected) {
    if (isSelected)
        selectedItems.add(item);/*from ww  w.  j  a va2s.c  o m*/
    else
        selectedItems.remove(item);

    fromAddresses = selectedItems.stream().map(WithdrawalListItem::getAddressString)
            .collect(Collectors.toSet());

    if (!selectedItems.isEmpty()) {
        amountOfSelectedItems = Coin
                .valueOf(selectedItems.stream().mapToLong(e -> e.getBalance().getValue()).sum());
        if (amountOfSelectedItems.isPositive()) {
            senderAmountAsCoinProperty.set(amountOfSelectedItems);
            amountTextField.setText(formatter.formatCoin(amountOfSelectedItems));
        } else {
            senderAmountAsCoinProperty.set(Coin.ZERO);
            amountOfSelectedItems = Coin.ZERO;
            amountTextField.setText("");
            withdrawFromTextField.setText("");
        }

        if (selectedItems.size() == 1) {
            withdrawFromTextField
                    .setText(selectedItems.stream().findAny().get().getAddressEntry().getAddressString());
            withdrawFromTextField.setTooltip(null);
        } else {
            String tooltipText = "Withdraw from multiple addresses:\n" + selectedItems.stream()
                    .map(WithdrawalListItem::getAddressString).collect(Collectors.joining(",\n"));
            int abbr = Math.max(10, 66 / selectedItems.size());
            String text = "Withdraw from multiple addresses ("
                    + selectedItems.stream().map(e -> StringUtils.abbreviate(e.getAddressString(), abbr))
                            .collect(Collectors.joining(", "))
                    + ")";
            withdrawFromTextField.setText(text);
            withdrawFromTextField.setTooltip(new Tooltip(tooltipText));
        }
    } else {
        reset();
    }
}

From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java

private void initializeSelectableModuleListView() {
    allModulesMarker.selectedProperty().set(true); // default only.  may be changed in getContent()
    selectableModuleListView.setCellFactory(CheckBoxListCell.forListView(SelectableModule::selectedProperty,
            new StringConverter<SelectableModule>() {
                @Override/*from   w ww.  ja v a2  s  .c  o m*/
                public String toString(SelectableModule object) {
                    return object.getDescription();
                }

                @Override
                public SelectableModule fromString(String string) {
                    return null;
                }
            }));
    selectableModuleListView.setTooltip(new Tooltip(
            "Select one or more modules to enable filtering for selected modules\nor deselect all to disable filtering by module.\nDefault module list is "
                    + Arrays.toString(getDefaultModules().toArray(new UUID[getDefaultModules().size()]))));
}

From source file:gov.va.isaac.gui.refexViews.refexEdit.AddSememePopup.java

public void finishInit(ViewFocus viewFocus, int focusNid, SememeView viewToRefresh) {
    callingView_ = viewToRefresh;/*w ww. java 2 s.c  om*/
    createRefexFocus_ = viewFocus;
    focusNid_ = focusNid;
    editRefex_ = null;
    st_ = SememeType.DYNAMIC; //TODO add to the GUI, the option to choose other types

    title_.setText("Create new sememe instance");

    if (createRefexFocus_ == ViewFocus.REFERENCED_COMPONENT) {
        gp_.add(unselectableComponentLabel_, 1, 0);
        unselectableComponentLabel_.setText(Get.conceptDescriptionText(focusNid_));
        gp_.add(selectableConcept_.getNode(), 1, 1);
        refexDropDownOptions.clear();
        refexDropDownOptions.addAll(buildAssemblageConceptList());
    } else {
        try {
            assemblageInfo_ = DynamicSememeUsageDescription.read(focusNid_);
            gp_.add(unselectableComponentLabel_, 1, 1);
            unselectableComponentLabel_.setText(Get.conceptDescriptionText(focusNid_));
            if (assemblageInfo_.getReferencedComponentTypeRestriction() != null
                    && ObjectChronologyType.CONCEPT != assemblageInfo_
                            .getReferencedComponentTypeRestriction()) {
                conceptNodeIsConceptType_ = false;
                gp_.add(selectableComponentNode_, 1, 0);
                selectableComponent_.setPromptText("UUID or NID of a "
                        + assemblageInfo_.getReferencedComponentTypeRestriction().toString());
                selectableComponent_.setTooltip(new Tooltip("UUID or NID of a "
                        + assemblageInfo_.getReferencedComponentTypeRestriction().toString()));
                selectableComponentNodeValid_.invalidate();
            } else {
                conceptNodeIsConceptType_ = true;
                gp_.add(selectableConcept_.getNode(), 1, 0);
            }
            refexDropDownOptions.clear();
            refexDropDownOptions
                    .addAll(AppContext.getService(CommonlyUsedConcepts.class).getObservableConcepts());
            assemblageIsValid_.set(true);
            buildDataFields(true, null);
        } catch (Exception e) {
            logger_.error("Unexpected", e);
            AppContext.getCommonDialogs().showErrorDialog("Unexpected Error reading Assembly concept", e);
        }
    }
}

From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java

private void initializeStatusesToggleGroup() {
    statusesToggleGroup = new ToggleGroup();
    Tooltip statusButtonsTooltip = new Tooltip("Default Status(es) is " + getDefaultStatuses());
    activeStatusButton = new RadioButton();
    activeStatusButton.setText("Active");
    activeStatusButton.setTooltip(statusButtonsTooltip);
    statusesToggleGroup.getToggles().add(activeStatusButton);
    activeStatusButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            currentStatusesProperty.get().clear();
            currentStatusesProperty.add(Status.ACTIVE);
        }/*w w  w .  j  a va2s .c o m*/
    });
    statusesToggleGroupVBox.getChildren().add(activeStatusButton);

    inactiveStatusButton = new RadioButton();
    inactiveStatusButton.setText("Inactive");
    inactiveStatusButton.setTooltip(statusButtonsTooltip);
    statusesToggleGroup.getToggles().add(inactiveStatusButton);
    inactiveStatusButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            currentStatusesProperty.get().clear();
            currentStatusesProperty.add(Status.INACTIVE);
        }
    });
    statusesToggleGroupVBox.getChildren().add(inactiveStatusButton);

    activeAndInactiveStatusButton = new RadioButton();
    activeAndInactiveStatusButton.setText("All");
    activeAndInactiveStatusButton.setTooltip(statusButtonsTooltip);
    statusesToggleGroup.getToggles().add(activeAndInactiveStatusButton);
    activeAndInactiveStatusButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            currentStatusesProperty.get().clear();
            currentStatusesProperty.add(Status.ACTIVE);
            currentStatusesProperty.add(Status.INACTIVE);
        }
    });
    statusesToggleGroupVBox.getChildren().add(activeAndInactiveStatusButton);
}

From source file:gov.va.isaac.gui.refexViews.refexEdit.AddRefexPopup.java

public void finishInit(InputType setFromType, DynamicRefexView viewToRefresh) {
    callingView_ = viewToRefresh;/*from w  w  w . j a va 2 s  .co m*/
    createRefexFocus_ = setFromType;
    editRefex_ = null;

    title_.setText("Create new sememe instance");

    if (createRefexFocus_.getComponentNid() != null) {
        gp_.add(unselectableComponentLabel_, 1, 0);
        unselectableComponentLabel_.setText(OTFUtility.getDescription(createRefexFocus_.getComponentNid()));
        gp_.add(selectableConcept_.getNode(), 1, 1);
        refexDropDownOptions.clear();
        refexDropDownOptions.addAll(buildAssemblageConceptList());
    } else {
        try {
            assemblageInfo_ = RefexDynamicUsageDescriptionBuilder
                    .readRefexDynamicUsageDescriptionConcept(createRefexFocus_.getAssemblyNid());
            gp_.add(unselectableComponentLabel_, 1, 1);
            unselectableComponentLabel_.setText(OTFUtility.getDescription(createRefexFocus_.getAssemblyNid()));
            if (assemblageInfo_.getReferencedComponentTypeRestriction() != null
                    && ComponentType.CONCEPT != assemblageInfo_.getReferencedComponentTypeRestriction()
                    && ComponentType.CONCEPT_ATTRIBUTES != assemblageInfo_
                            .getReferencedComponentTypeRestriction()) {
                conceptNodeIsConceptType_ = false;
                gp_.add(selectableComponentNode_, 1, 0);
                selectableComponent_.setPromptText("UUID or NID of a "
                        + assemblageInfo_.getReferencedComponentTypeRestriction().toString());
                selectableComponent_.setTooltip(new Tooltip("UUID or NID of a "
                        + assemblageInfo_.getReferencedComponentTypeRestriction().toString()));
                selectableComponentNodeValid_.invalidate();
            } else {
                conceptNodeIsConceptType_ = true;
                gp_.add(selectableConcept_.getNode(), 1, 0);
            }
            refexDropDownOptions.clear();
            refexDropDownOptions
                    .addAll(AppContext.getService(CommonlyUsedConcepts.class).getObservableConcepts());
            assemblageIsValid_.set(true);
            buildDataFields(true, null);
        } catch (Exception e) {
            logger_.error("Unexpected", e);
            AppContext.getCommonDialogs().showErrorDialog("Unexpected Error reading Assembly concept", e);
        }
    }
}

From source file:io.bitsquare.gui.main.funds.withdrawal.WithdrawalView.java

private void setAddressColumnCellFactory() {
    addressColumn//from   w w w.  j a  v a 2 s.co  m
            .setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    addressColumn.setCellFactory(
            new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem, WithdrawalListItem>>() {

                @Override
                public TableCell<WithdrawalListItem, WithdrawalListItem> call(
                        TableColumn<WithdrawalListItem, WithdrawalListItem> column) {
                    return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
                        private HyperlinkWithIcon hyperlinkWithIcon;

                        @Override
                        public void updateItem(final WithdrawalListItem item, boolean empty) {
                            super.updateItem(item, empty);

                            if (item != null && !empty) {
                                String address = item.getAddressString();
                                hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
                                hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
                                hyperlinkWithIcon.setTooltip(new Tooltip(
                                        "Open external blockchain explorer for " + "address: " + address));
                                setGraphic(hyperlinkWithIcon);
                            } else {
                                setGraphic(null);
                                if (hyperlinkWithIcon != null)
                                    hyperlinkWithIcon.setOnAction(null);
                            }
                        }
                    };
                }
            });
}

From source file:gov.va.isaac.gui.refexViews.refexEdit.AddSememePopup.java

private void buildDataFields(boolean assemblageValid, DynamicSememeDataBI[] currentValues) {
    if (assemblageValid) {
        for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) {
            allValid_.removeBinding(ssp);
        }//from w  ww. j  a va2 s .  com
        currentDataFieldWarnings_.clear();
        for (SememeGUIDataTypeNodeDetails nd : currentDataFields_) {
            nd.cleanupListener();
        }
        currentDataFields_.clear();

        GridPane gp = new GridPane();
        gp.setHgap(10.0);
        gp.setVgap(10.0);
        gp.setStyle("-fx-padding: 5;");
        int row = 0;
        boolean extraInfoColumnIsRequired = false;
        for (DynamicSememeColumnInfo ci : assemblageInfo_.getColumnInfo()) {
            SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("")
                    : null);
            SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null
                    && ci.getValidator() == null) ? null : new SimpleStringProperty());
            ComboBox<DynamicSememeDataType> polymorphicType = null;

            Label l = new Label(ci.getColumnName());
            l.getStyleClass().add("boldLabel");
            l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l));
            Tooltip.install(l, new Tooltip(ci.getColumnDescription()));
            int col = 0;
            gp.add(l, col++, row);

            if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) {
                polymorphicType = new ComboBox<>();
                polymorphicType.setEditable(false);
                polymorphicType.setConverter(new StringConverter<DynamicSememeDataType>() {

                    @Override
                    public String toString(DynamicSememeDataType object) {
                        return object.getDisplayName();
                    }

                    @Override
                    public DynamicSememeDataType fromString(String string) {
                        throw new RuntimeException("unecessary");
                    }
                });
                for (DynamicSememeDataType type : DynamicSememeDataType.values()) {
                    if (type == DynamicSememeDataType.POLYMORPHIC || type == DynamicSememeDataType.UNKNOWN) {
                        continue;
                    } else {
                        polymorphicType.getItems().add(type);
                    }
                }
                polymorphicType.getSelectionModel()
                        .select((currentValues == null ? DynamicSememeDataType.STRING
                                : (currentValues[row] == null ? DynamicSememeDataType.STRING
                                        : currentValues[row].getDynamicSememeDataType())));
            }

            SememeGUIDataTypeNodeDetails nd = SememeGUIDataTypeFXNodeBuilder.buildNodeForType(
                    ci.getColumnDataType(), ci.getDefaultColumnValue(),
                    (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip,
                    (polymorphicType == null ? null
                            : polymorphicType.getSelectionModel().selectedItemProperty()),
                    allValid_, ci.getValidator(), ci.getValidatorData());

            currentDataFieldWarnings_.addAll(nd.getBoundToAllValid());
            if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) {
                nd.addUpdateParentListListener(currentDataFieldWarnings_);
            }

            currentDataFields_.add(nd);

            gp.add(nd.getNodeForDisplay(), col++, row);

            Label colType = new Label(ci.getColumnDataType().getDisplayName());
            colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType));
            gp.add((polymorphicType == null ? colType : polymorphicType), col++, row);

            if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) {
                extraInfoColumnIsRequired = true;

                StackPane stackPane = new StackPane();
                stackPane.setMaxWidth(Double.MAX_VALUE);

                if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) {
                    ImageView information = Images.INFORMATION.createImageView();
                    Tooltip tooltip = new Tooltip();
                    tooltip.textProperty().bind(defaultValueTooltip);
                    Tooltip.install(information, tooltip);
                    tooltip.setAutoHide(true);
                    information.setOnMouseClicked(
                            event -> tooltip.show(information, event.getScreenX(), event.getScreenY()));
                    stackPane.getChildren().add(information);
                }

                if (ci.isColumnRequired()) {
                    ImageView exclamation = Images.EXCLAMATION.createImageView();

                    final BooleanProperty showExclamation = new SimpleBooleanProperty(
                            StringUtils.isNotBlank(valueIsRequired.get()));
                    valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue,
                            newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue)));

                    exclamation.visibleProperty().bind(showExclamation);
                    Tooltip tooltip = new Tooltip();
                    tooltip.textProperty().bind(valueIsRequired);
                    Tooltip.install(exclamation, tooltip);
                    tooltip.setAutoHide(true);

                    exclamation.setOnMouseClicked(
                            event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY()));
                    stackPane.getChildren().add(exclamation);
                }

                gp.add(stackPane, col++, row);
            }
            row++;
        }

        ColumnConstraints cc = new ColumnConstraints();
        cc.setHgrow(Priority.NEVER);
        gp.getColumnConstraints().add(cc);

        cc = new ColumnConstraints();
        cc.setHgrow(Priority.ALWAYS);
        gp.getColumnConstraints().add(cc);

        cc = new ColumnConstraints();
        cc.setHgrow(Priority.NEVER);
        gp.getColumnConstraints().add(cc);

        if (extraInfoColumnIsRequired) {
            cc = new ColumnConstraints();
            cc.setHgrow(Priority.NEVER);
            gp.getColumnConstraints().add(cc);
        }

        if (row == 0) {
            sp_.setContent(new Label("This assemblage does not allow data fields"));
        } else {
            sp_.setContent(gp);
        }
        allValid_.invalidate();
    } else {
        sp_.setContent(null);
    }
}

From source file:gov.va.isaac.gui.refexViews.refexEdit.AddRefexPopup.java

private void buildDataFields(boolean assemblageValid, RefexDynamicDataBI[] currentValues) {
    if (assemblageValid) {
        for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) {
            allValid_.removeBinding(ssp);
        }//from ww  w .  j  a va 2 s  . com
        currentDataFieldWarnings_.clear();
        for (RefexDataTypeNodeDetails nd : currentDataFields_) {
            nd.cleanupListener();
        }
        currentDataFields_.clear();

        GridPane gp = new GridPane();
        gp.setHgap(10.0);
        gp.setVgap(10.0);
        gp.setStyle("-fx-padding: 5;");
        int row = 0;
        boolean extraInfoColumnIsRequired = false;
        for (RefexDynamicColumnInfo ci : assemblageInfo_.getColumnInfo()) {
            SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("")
                    : null);
            SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null
                    && ci.getValidator() == null) ? null : new SimpleStringProperty());
            ComboBox<RefexDynamicDataType> polymorphicType = null;

            Label l = new Label(ci.getColumnName());
            l.getStyleClass().add("boldLabel");
            l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l));
            Tooltip.install(l, new Tooltip(ci.getColumnDescription()));
            int col = 0;
            gp.add(l, col++, row);

            if (ci.getColumnDataType() == RefexDynamicDataType.POLYMORPHIC) {
                polymorphicType = new ComboBox<>();
                polymorphicType.setEditable(false);
                polymorphicType.setConverter(new StringConverter<RefexDynamicDataType>() {

                    @Override
                    public String toString(RefexDynamicDataType object) {
                        return object.getDisplayName();
                    }

                    @Override
                    public RefexDynamicDataType fromString(String string) {
                        throw new RuntimeException("unecessary");
                    }
                });
                for (RefexDynamicDataType type : RefexDynamicDataType.values()) {
                    if (type == RefexDynamicDataType.POLYMORPHIC || type == RefexDynamicDataType.UNKNOWN) {
                        continue;
                    } else {
                        polymorphicType.getItems().add(type);
                    }
                }
                polymorphicType.getSelectionModel()
                        .select((currentValues == null ? RefexDynamicDataType.STRING
                                : (currentValues[row] == null ? RefexDynamicDataType.STRING
                                        : currentValues[row].getRefexDataType())));
            }

            RefexDataTypeNodeDetails nd = RefexDataTypeFXNodeBuilder.buildNodeForType(ci.getColumnDataType(),
                    ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]),
                    valueIsRequired, defaultValueTooltip,
                    (polymorphicType == null ? null
                            : polymorphicType.getSelectionModel().selectedItemProperty()),
                    allValid_, new SimpleObjectProperty<>(ci.getValidator()),
                    new SimpleObjectProperty<>(ci.getValidatorData()));

            currentDataFieldWarnings_.addAll(nd.getBoundToAllValid());
            if (ci.getColumnDataType() == RefexDynamicDataType.POLYMORPHIC) {
                nd.addUpdateParentListListener(currentDataFieldWarnings_);
            }

            currentDataFields_.add(nd);

            gp.add(nd.getNodeForDisplay(), col++, row);

            Label colType = new Label(ci.getColumnDataType().getDisplayName());
            colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType));
            gp.add((polymorphicType == null ? colType : polymorphicType), col++, row);

            if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) {
                extraInfoColumnIsRequired = true;

                StackPane stackPane = new StackPane();
                stackPane.setMaxWidth(Double.MAX_VALUE);

                if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) {
                    ImageView information = Images.INFORMATION.createImageView();
                    Tooltip tooltip = new Tooltip();
                    tooltip.textProperty().bind(defaultValueTooltip);
                    Tooltip.install(information, tooltip);
                    tooltip.setAutoHide(true);
                    information.setOnMouseClicked(
                            event -> tooltip.show(information, event.getScreenX(), event.getScreenY()));
                    stackPane.getChildren().add(information);
                }

                if (ci.isColumnRequired()) {
                    ImageView exclamation = Images.EXCLAMATION.createImageView();

                    final BooleanProperty showExclamation = new SimpleBooleanProperty(
                            StringUtils.isNotBlank(valueIsRequired.get()));
                    valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue,
                            newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue)));

                    exclamation.visibleProperty().bind(showExclamation);
                    Tooltip tooltip = new Tooltip();
                    tooltip.textProperty().bind(valueIsRequired);
                    Tooltip.install(exclamation, tooltip);
                    tooltip.setAutoHide(true);

                    exclamation.setOnMouseClicked(
                            event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY()));
                    stackPane.getChildren().add(exclamation);
                }

                gp.add(stackPane, col++, row);
            }
            row++;
        }

        ColumnConstraints cc = new ColumnConstraints();
        cc.setHgrow(Priority.NEVER);
        gp.getColumnConstraints().add(cc);

        cc = new ColumnConstraints();
        cc.setHgrow(Priority.ALWAYS);
        gp.getColumnConstraints().add(cc);

        cc = new ColumnConstraints();
        cc.setHgrow(Priority.NEVER);
        gp.getColumnConstraints().add(cc);

        if (extraInfoColumnIsRequired) {
            cc = new ColumnConstraints();
            cc.setHgrow(Priority.NEVER);
            gp.getColumnConstraints().add(cc);
        }

        if (row == 0) {
            sp_.setContent(new Label("This assemblage does not allow data fields"));
        } else {
            sp_.setContent(gp);
        }
        allValid_.invalidate();
    } else {
        sp_.setContent(null);
    }
}

From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java

private void initializeStatedInferredToggleGroup() {
    statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred

    for (StatedInferredOptions option : StatedInferredOptions.values()) {
        RadioButton optionButton = new RadioButton();
        if (option == StatedInferredOptions.STATED) {
            optionButton.setText("Stated");
        } else if (option == StatedInferredOptions.INFERRED) {
            optionButton.setText("Inferred");
        } else {/*  w w w . j a v  a2  s  .com*/
            throw new RuntimeException("oops");
        }
        optionButton.setUserData(option);
        optionButton
                .setTooltip(new Tooltip("Default StatedInferredOption is " + getDefaultStatedInferredOption()));
        statedInferredToggleGroup.getToggles().add(optionButton);
        statedInferredToggleGroupVBox.getChildren().add(optionButton);
        statedInferredOptionButtons.add(optionButton);
    }
    statedInferredToggleGroup.selectedToggleProperty()
            .addListener((observable, oldValue,
                    newValue) -> runLaterIfNotFXApplicationThread(() -> currentStatedInferredOptionProperty
                            .set((StatedInferredOptions) newValue.getUserData())));
}

From source file:dsfixgui.view.DSFGraphicsPane.java

private void initializeEventHandlers() {

    applySettingsButton.setOnAction(e -> {
        ui.applyDSFConfig();/*from   www .  j  a v a2 s .c o  m*/
    });

    restoreDefaultsButton.setOnAction(e -> {
        ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS,
                DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]);

        if (cD.show()) {
            config.restoreDefaultGraphicsOptions();
            ui.refreshUI();
        }
    });

    renderWidthField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldText, String newText) {
            try {
                if (!NumberUtils.isParsable(newText)
                        || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) {
                    renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true);
                    renderWidthField.setTooltip(new Tooltip(POSITIVE_INTEGER));
                } else if (Integer.parseInt(newText) >= 1280) {
                    if (NumberUtils.isParsable(presentWidthField.getText())
                            && (Integer.parseInt(newText) == Integer.parseInt(presentWidthField.getText()))) {
                        renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true);
                        renderWidthField.setTooltip(new Tooltip(SAME_RESOLUTIONS));
                    } else {
                        renderWidthField.pseudoClassStateChanged(INVALID_INPUT, false);
                        renderWidthField.setTooltip(new Tooltip(""));
                        config.setRenderWidth(Integer.parseInt(newText));
                        if (config.disableDOF) {
                            config.setPresentWidth(Integer.parseInt(newText));
                        }
                    }
                    //If input is a positive integer that is less than 1280, present width comes into play
                } else if (NumberUtils.isParsable(presentWidthField.getText())
                        && Integer.parseInt(presentWidthField.getText()) >= 1280) {
                    renderWidthField.pseudoClassStateChanged(INVALID_INPUT, false);
                    renderWidthField.setTooltip(new Tooltip(""));
                    config.setRenderWidth(Integer.parseInt(newText));
                } else {
                    renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true);
                    renderWidthField.setTooltip(new Tooltip(PRES_WIDTH_TOO_LOW));
                }
                recheckTextInput(presentWidthField);
            } catch (NumberFormatException nFE) {
                config.setRenderWidth(1920);
                ui.printConsole(INPUT_TOO_LARGE);
                renderWidthField.setText("");
                renderWidthField.appendText(config.getRenderWidth() + "");
            }

        }
    });

    renderHeightField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldText, String newText) {
            try {
                if (!NumberUtils.isParsable(newText)
                        || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) {
                    renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true);
                    renderHeightField.setTooltip(new Tooltip(POSITIVE_INTEGER));
                } else if (Integer.parseInt(newText) >= 720) {
                    if (NumberUtils.isParsable(presentHeightField.getText())
                            && (Integer.parseInt(newText) == Integer.parseInt(presentHeightField.getText()))) {
                        renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true);
                        renderHeightField.setTooltip(new Tooltip(SAME_RESOLUTIONS));
                    } else {
                        renderHeightField.pseudoClassStateChanged(INVALID_INPUT, false);
                        renderHeightField.setTooltip(new Tooltip(""));
                        config.setRenderHeight(Integer.parseInt(newText));
                        if (config.disableDOF) {
                            config.setPresentHeight(Integer.parseInt(newText));
                            config.setDOFOverride(Integer.parseInt(newText));
                        }
                    }
                    //If input is a positive integer that is less than 720, present height comes into play
                } else if (NumberUtils.isParsable(presentHeightField.getText())
                        && Integer.parseInt(presentHeightField.getText()) >= 720) {
                    renderHeightField.pseudoClassStateChanged(INVALID_INPUT, false);
                    renderHeightField.setTooltip(new Tooltip(""));
                    config.setRenderHeight(Integer.parseInt(newText));
                } else {
                    renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true);
                    renderHeightField.setTooltip(new Tooltip(PRES_HEIGHT_TOO_LOW));
                }
                recheckTextInput(presentHeightField);
            } catch (NumberFormatException nFE) {
                config.setRenderHeight(1080);
                ui.printConsole(INPUT_TOO_LARGE);
                renderHeightField.setText("");
                renderHeightField.appendText(config.getRenderHeight() + "");
            }
        }
    });

    setWindowsRenderRes.setOnAction(e -> {
        renderWidthField.setText("");
        renderHeightField.setText("");
        renderWidthField.appendText((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() + "");
        renderHeightField.appendText((int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() + "");
    });

    presentWidthField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldText, String newText) {
            try {
                if (!NumberUtils.isParsable(newText)
                        || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) {
                    presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true);
                    presentWidthField.setTooltip(new Tooltip(POSITIVE_INTEGER));
                } else if (Integer.parseInt(newText) < 1280) {
                    presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true);
                    presentWidthField.setTooltip(new Tooltip(INPUT_GREATER_THAN + 1280));
                } else if (Integer.parseInt(newText) >= 1280) {
                    if (NumberUtils.isParsable(renderWidthField.getText())
                            && (Integer.parseInt(newText) == Integer.parseInt(renderWidthField.getText()))) {
                        presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true);
                        presentWidthField.setTooltip(new Tooltip(SAME_RESOLUTIONS));
                    } else {
                        presentWidthField.pseudoClassStateChanged(INVALID_INPUT, false);
                        presentWidthField.setTooltip(null);
                        config.setPresentWidth(Integer.parseInt(newText));
                    }
                }
                recheckTextInput(renderWidthField);
            } catch (NumberFormatException nFE) {
                config.setPresentWidth(0);
                ui.printConsole(INPUT_TOO_LARGE);
                presentWidthField.setText("");
                presentWidthField.appendText(config.getPresentWidth() + "");
            }
        }
    });

    presentHeightField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldText, String newText) {
            try {
                if (!NumberUtils.isParsable(newText)
                        || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) {
                    presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true);
                    presentHeightField.setTooltip(new Tooltip(POSITIVE_INTEGER));
                } else if (Integer.parseInt(newText) < 720) {
                    presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true);
                    presentHeightField.setTooltip(new Tooltip(INPUT_GREATER_THAN + 720));
                } else if (Integer.parseInt(newText) >= 720) {
                    if (NumberUtils.isParsable(renderHeightField.getText())
                            && (Integer.parseInt(newText) == Integer.parseInt(renderHeightField.getText()))) {
                        presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true);
                        presentHeightField.setTooltip(new Tooltip(SAME_RESOLUTIONS));
                    } else {
                        presentHeightField.pseudoClassStateChanged(INVALID_INPUT, false);
                        presentHeightField.setTooltip(null);
                        config.setPresentHeight(Integer.parseInt(newText));
                    }
                }
                recheckTextInput(renderHeightField);
            } catch (NumberFormatException nFE) {
                config.setPresentHeight(0);
                ui.printConsole(INPUT_TOO_LARGE);
                presentHeightField.setText("");
                presentHeightField.appendText(config.getPresentHeight() + "");
            }
        }
    });

    setWindowsPresentRes.setOnAction(e -> {
        presentWidthField.setText("");
        presentHeightField.setText("");
        presentWidthField.appendText((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() + "");
        presentHeightField.appendText((int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() + "");
    });

    usePresentRes.setOnAction(e -> {

        presentWidthField.setDisable(false);
        presentHeightField.setDisable(false);
        setWindowsPresentRes.setDisable(false);
        presentWidthField.setText(presentRes[0]);
        presentHeightField.setText(presentRes[1]);
        recheckTextInput(presentWidthField);
        recheckTextInput(presentHeightField);
        recheckTextInput(renderWidthField);
        recheckTextInput(renderHeightField);
    });

    dontUsePresentRes.setOnAction(e -> {
        presentWidthField.setDisable(true);
        presentHeightField.setDisable(true);
        setWindowsPresentRes.setDisable(true);
        config.setPresentWidth(0);
        config.setPresentHeight(0);
        presentRes[0] = presentWidthField.getText();
        presentRes[1] = presentHeightField.getText();
        presentWidthField.setText(config.getPresentWidth() + "");
        presentHeightField.setText(config.getPresentHeight() + "");
        recheckTextInput(renderWidthField);
        recheckTextInput(renderHeightField);
        presentWidthField.pseudoClassStateChanged(INVALID_INPUT, false);
        presentWidthField.setTooltip(null);
        presentHeightField.pseudoClassStateChanged(INVALID_INPUT, false);
        presentHeightField.setTooltip(null);

    });

    aaQualityPicker.setOnAction(e -> {
        if (aaQualityPicker.getValue().equals(AAQUALITIES[0])) {
            config.aaQuality.set(0);
            aaTypePicker.setDisable(true);
        } else {
            aaTypePicker.setDisable(false);
            config.aaQuality.set(aaQualityPicker.getItems().indexOf(aaQualityPicker.getValue()));
        }
    });

    aaTypePicker.setOnAction(e -> {
        config.aaType.replace(0, config.aaType.length(), aaTypePicker.getValue());
    });

    ssaoStrengthPicker.setOnAction(e -> {
        if (ssaoStrengthPicker.getValue().equals(SSAOSTRENGTHS[0])) {
            config.ssaoStrength.set(0);
            ssaoScalePicker.setDisable(true);
            ssaoTypePicker.setDisable(true);
        } else {
            ssaoScalePicker.setDisable(false);
            ssaoTypePicker.setDisable(false);
            config.ssaoStrength.set(ssaoStrengthPicker.getItems().indexOf(ssaoStrengthPicker.getValue()));
        }
    });

    ssaoScalePicker.setOnAction(e -> {
        config.ssaoScale.set(ssaoScalePicker.getItems().indexOf(ssaoScalePicker.getValue()) + 1);
    });

    ssaoTypePicker.setOnAction(e -> {
        config.ssaoType.replace(0, config.ssaoType.length(), ssaoTypePicker.getValue());
    });

    //DOF Override picker is a special case with its own method
    setDOFOverrideEventHandler();

    dofScalingEnabled.setOnAction(e -> {
        config.disableDofScaling.set(0);
    });

    dofScalingDisabled.setOnAction(e -> {
        config.disableDofScaling.set(1);
    });

    dofAddPicker.setOnAction(e -> {
        config.dofBlurAmount.replace(0, config.dofBlurAmount.length(),
                DOF_ADDITIONAL_BLUR_OPTIONS[dofAddPicker.getItems().indexOf(dofAddPicker.getValue())]);
    });

    fpsLocked.setOnAction(e -> {
        config.unlockFPS.set(0);
        fpsLimitField.setDisable(true);
        recheckTextInput(fpsLimitField);
    });

    fpsUnlocked.setOnAction(e -> {
        config.unlockFPS.set(1);
        fpsLimitField.setDisable(false);
        recheckTextInput(fpsLimitField);
    });

    fpsFixKeyPicker.setOnAction(e -> {
        String fpsFixKeyNew = FPS_FIX_KEYS_HEX[FPS_FIX_KEYS_ARRAY_LIST.indexOf(fpsFixKeyPicker.getValue())]
                .substring(2);
        setFPSFixKey(fpsFixKeyNew);
        fpsFixKey = FPS_FIX_KEYS_HEX[FPS_FIX_KEYS_ARRAY_LIST.indexOf(fpsFixKeyPicker.getValue())].substring(2);
    });

    fpsLimitField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldText, String newText) {
            try {
                if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) {
                    fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, true);
                    fpsLimitField.setTooltip(new Tooltip(POSITIVE_INTEGER));
                } else if (Integer.parseInt(newText) > 70) {
                    fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, true);
                    fpsLimitField.setTooltip(new Tooltip(INPUT_FPS_TOO_HIGH));
                } else {
                    fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, false);
                    fpsLimitField.setTooltip(
                            new Tooltip(FPS_LIMIT_LABEL.substring(0, FPS_LIMIT_LABEL.length() - 2)));
                    config.FPSlimit.set(Integer.parseInt(newText));
                }
            } catch (NumberFormatException nFE) {
                ui.printConsole(INPUT_TOO_LARGE);
                fpsLimitField.setText("");
            }
        }
    });

    fpsThresholdField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldText, String newText) {
            try {
                if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) {
                    fpsThresholdField.pseudoClassStateChanged(INVALID_INPUT, true);
                    fpsThresholdField.setTooltip(new Tooltip(POSITIVE_INTEGER));
                } else {
                    fpsThresholdField.pseudoClassStateChanged(INVALID_INPUT, false);
                    fpsThresholdField.setTooltip(
                            new Tooltip(FPS_LIMIT_LABEL.substring(0, FPS_LIMIT_LABEL.length() - 2)));
                    config.FPSthreshold.set(Integer.parseInt(newText));
                }
            } catch (NumberFormatException nFE) {
                ui.printConsole(INPUT_TOO_LARGE);
                fpsThresholdField.setText("");
            }
        }
    });

    texOverridePicker.setOnAction(e -> {
        config.filteringOverride.set(texOverridePicker.getItems().indexOf(texOverridePicker.getValue()));
    });
}