Example usage for javafx.scene.control Toggle getUserData

List of usage examples for javafx.scene.control Toggle getUserData

Introduction

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

Prototype

Object getUserData();

Source Link

Document

Returns a previously set Object property, or null if no such property has been set using the Node.setUserData(java.lang.Object) method.

Usage

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

private void loadStoredStatedInferredOption() {
    // Reload storedStatedInferredOption
    final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption();
    for (Toggle toggle : statedInferredToggleGroup.getToggles()) {
        if (toggle.getUserData() == storedStatedInferredOption) {
            toggle.setSelected(true);/*  www  . ja  va 2s  .c o  m*/
        }
    }
}

From source file:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java

/**
 * Called when the selected project is changed.
 *//*from  w  w w  .j  a va2s .co  m*/
private void changeSelectedProject(final FXICCWrapper pWrapper) {
    projectDatasetAccordion.setExpandedPane(tpDatasets);

    RoddyUITask.runTask(new RoddyUITask<Void>(UIConstants.UITASK_CHANGE_PROJECT) {
        List<String> analysesList = null;

        @Override
        public Void _call() throws Exception {
            long t1 = ExecutionService.measureStart();
            currentProjectWrapper = pWrapper;
            currentProject = pWrapper.getID();
            long t2 = ExecutionService.measureStart();

            ExecutionService.measureStop(t2, UIConstants.UITASK_MP_LOADCONFIGURATION);

            analysesList = currentProjectWrapper.getICC().getListOfAnalyses();

            cleanRMIPool();

            ExecutionService.measureStop(t2, UIConstants.UITASK_MP_LOAD_ANALYSIS_LIST);
            return null;
        }

        @Override
        public void _succeeded() {

            vboxAvailableAnalyses.getChildren().clear();
            ToggleGroup tgAnalyses = new ToggleGroup();

            for (String analysis : analysesList) {
                List fullAnalysisID = ProjectFactory.dissectFullAnalysisID(analysis);
                String id = analysis.split("[:][:]")[0];
                String plugin = fullAnalysisID.size() > 0 ? "\n - " + fullAnalysisID.get(0).toString() : "";

                RadioButton rb = new RadioButton(id + plugin);
                rb.setUserData(analysis);
                rb.setToggleGroup(tgAnalyses);
                vboxAvailableAnalyses.getChildren().add(rb);
            }
            tgAnalyses.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
                @Override
                public void changed(ObservableValue<? extends Toggle> observableValue, Toggle toggle,
                        Toggle toggle2) {
                    changeSelectedAnalysis((String) toggle2.getUserData());
                }
            });

            if (analysesList.size() == 1) {
                tgAnalyses.getToggles().get(0).setSelected(true);
            }
        }
    });
}

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

@Override
public Region getContent() {
    if (hBox == null) {
        VBox statedInferredToggleGroupVBox = new VBox();
        statedInferredToggleGroupVBox.setSpacing(4.0);

        //Instantiate Everything
        pathComboBox = new ComboBox<>(); //Path
        statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred
        List<RadioButton> statedInferredOptionButtons = new ArrayList<>();
        datePicker = new DatePicker(); //Date
        timeSelectCombo = new ComboBox<Long>(); //Time

        //Radio buttons
        for (StatedInferredOptions option : StatedInferredOptions.values()) {
            RadioButton optionButton = new RadioButton();
            if (option == StatedInferredOptions.STATED) {
                optionButton.setText("Stated");
            } else if (option == StatedInferredOptions.INFERRED_THEN_STATED) {
                optionButton.setText("Inferred Then Stated");
            } else if (option == StatedInferredOptions.INFERRED) {
                optionButton.setText("Inferred");
            } else {
                throw new RuntimeException("oops");
            }/*ww  w  .  j a  v  a 2  s .  c  om*/
            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(new ChangeListener<Toggle>() {
            @Override
            public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue,
                    Toggle newValue) {
                currentStatedInferredOptionProperty.set((StatedInferredOptions) newValue.getUserData());
            }
        });

        //Path Combo Box
        pathComboBox.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() {
            @Override
            public ListCell<UUID> call(ListView<UUID> param) {
                final ListCell<UUID> cell = new ListCell<UUID>() {
                    @Override
                    protected void updateItem(UUID c, boolean emptyRow) {
                        super.updateItem(c, emptyRow);
                        if (c == null) {
                            setText(null);
                        } else {
                            String desc = OTFUtility.getDescription(c);
                            setText(desc);
                        }
                    }
                };
                return cell;
            }
        });

        pathComboBox.setButtonCell(new ListCell<UUID>() { // Don't know why this should be necessary, but without this the UUID itself is displayed
            @Override
            protected void updateItem(UUID c, boolean emptyRow) {
                super.updateItem(c, emptyRow);
                if (emptyRow) {
                    setText("");
                } else {
                    String desc = OTFUtility.getDescription(c);
                    setText(desc);
                }
            }
        });
        pathComboBox.setOnAction((event) -> {
            if (!pathComboFirstRun) {
                UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem();
                if (selectedPath != null) {
                    int path = OTFUtility.getConceptVersion(selectedPath).getPathNid();

                    StampBdb stampDb = Bdb.getStampDb();
                    NidSet nidSet = new NidSet();
                    nidSet.add(path);
                    //TODO: Make this multi-threaded and possibly implement setTimeOptions() here also
                    NidSetBI stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE);

                    pathDatesList.clear();
                    //                  disableTimeCombo(true);
                    timeSelectCombo.setValue(Long.MAX_VALUE);

                    for (Integer thisStamp : stamps.getAsSet()) {
                        try {
                            Position stampPosition = stampDb.getPosition(thisStamp);
                            this.stampDate = new Date(stampPosition.getTime());
                            stampDateInstant = stampDate.toInstant().atZone(ZoneId.systemDefault())
                                    .toLocalDate();
                            this.pathDatesList.add(stampDateInstant); //Build DatePicker
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    datePicker.setValue(LocalDate.now());
                }
            } else {
                pathComboFirstRun = false;
            }
        });

        pathComboBox.setTooltip(
                new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath()) + "\""));

        //Calendar Date Picker
        final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {
            @Override
            public DateCell call(final DatePicker datePicker) {
                return new DateCell() {
                    @Override
                    public void updateItem(LocalDate thisDate, boolean empty) {
                        super.updateItem(thisDate, empty);
                        if (pathDatesList != null) {
                            if (pathDatesList.contains(thisDate)) {
                                setDisable(false);
                            } else {
                                setDisable(true);
                            }
                        }
                    }
                };
            }
        };
        datePicker.setDayCellFactory(dayCellFactory);
        datePicker.setOnAction((event) -> {
            if (!datePickerFirstRun) {
                UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem();

                Instant instant = Instant.from(datePicker.getValue().atStartOfDay(ZoneId.systemDefault()));
                Long dateSelected = Date.from(instant).getTime();

                if (selectedPath != null && dateSelected != 0) {

                    int path = OTFUtility.getConceptVersion(selectedPath).getPathNid();
                    setTimeOptions(path, dateSelected);
                    try {
                        timeSelectCombo.setValue(times.first()); //Default Dropdown Value
                    } catch (Exception e) {
                        // Eat it.. like a sandwich! TODO: Create Read Only Property Conditional for checking if Time Combo is disabled
                        // Right now, Sometimes Time Combo is disabled, so we catch this and eat it
                        // Otherwise make a conditional from the Read Only Boolean Property to check first
                    }
                } else {
                    disableTimeCombo(false);
                    logger.debug("The path isn't set or the date isn't set. Both are needed right now");
                }
            } else {
                datePickerFirstRun = false;
            }
        });

        //Commit-Time ComboBox
        timeSelectCombo.setMinWidth(200);
        timeSelectCombo.setCellFactory(new Callback<ListView<Long>, ListCell<Long>>() {
            @Override
            public ListCell<Long> call(ListView<Long> param) {
                final ListCell<Long> cell = new ListCell<Long>() {
                    @Override
                    protected void updateItem(Long item, boolean emptyRow) {
                        super.updateItem(item, emptyRow);
                        if (item == null) {
                            setText("");
                        } else {
                            if (item == Long.MAX_VALUE) {
                                setText("LATEST TIME");
                            } else {
                                setText(timeFormatter.format(new Date(item)));
                            }
                        }
                    }
                };
                return cell;
            }
        });
        timeSelectCombo.setButtonCell(new ListCell<Long>() {
            @Override
            protected void updateItem(Long item, boolean emptyRow) {
                super.updateItem(item, emptyRow);
                if (item == null) {
                    setText("");
                } else {
                    if (item == Long.MAX_VALUE) {
                        setText("LATEST TIME");
                    } else {
                        setText(timeFormatter.format(new Date(item)));
                    }
                }
            }
        });

        try {
            currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); //Set Path Property
            currentTimeProperty.bind(timeSelectCombo.getSelectionModel().selectedItemProperty());
        } catch (Exception e) {
            e.printStackTrace();
        }

        // DEFAULT VALUES
        UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile();
        storedTimePref = loggedIn.getViewCoordinateTime();
        storedPathPref = loggedIn.getViewCoordinatePath();

        if (storedPathPref != null) {
            pathComboBox.getItems().clear(); //Set the path Dates by default
            pathComboBox.getItems().addAll(getPathOptions());
            final UUID storedPath = getStoredPath();
            if (storedPath != null) {
                pathComboBox.getSelectionModel().select(storedPath);
            }

            if (storedTimePref != null) {
                final Long storedTime = loggedIn.getViewCoordinateTime();
                Calendar cal = Calendar.getInstance();
                cal.setTime(new Date(storedTime));
                cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds
                Long storedTruncTime = cal.getTimeInMillis();

                if (!storedTime.equals(Long.MAX_VALUE)) { //***** FIX THIS, not checking default vc time value
                    int path = OTFUtility.getConceptVersion(storedPathPref).getPathNid();
                    setTimeOptions(path, storedTimePref);
                    timeSelectCombo.setValue(storedTruncTime);
                    //                  timeSelectCombo.getItems().addAll(getTimeOptions()); //The correct way, but doesen't work

                    Date storedDate = new Date(storedTime);
                    datePicker.setValue(storedDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
                } else {
                    datePicker.setValue(LocalDate.now());
                    timeSelectCombo.getItems().addAll(Long.MAX_VALUE); //The correct way, but doesen't work
                    timeSelectCombo.setValue(Long.MAX_VALUE);
                    //                  disableTimeCombo(false);
                }
            } else { //Stored Time Pref == null
                logger.error("ERROR: Stored Time Preference = null");
            }
        } else { //Stored Path Pref == null
            logger.error("We could not load a stored path, ISAAC cannot run");
            throw new Error("No stored PATH could be found. ISAAC can't run without a path");
        }

        GridPane gridPane = new GridPane();
        gridPane.setHgap(10);
        gridPane.setVgap(10);

        Label pathLabel = new Label("View Coordinate Path");
        gridPane.add(pathLabel, 0, 0); //Path Label - Row 0
        GridPane.setHalignment(pathLabel, HPos.LEFT);
        gridPane.add(statedInferredToggleGroupVBox, 1, 0, 1, 2); //--Row 0, span 2

        gridPane.add(pathComboBox, 0, 1); //Path Combo box - Row 2
        GridPane.setValignment(pathComboBox, VPos.TOP);

        Label datePickerLabel = new Label("View Coordinate Dates");
        gridPane.add(datePickerLabel, 0, 2); //Row 3
        GridPane.setHalignment(datePickerLabel, HPos.LEFT);
        gridPane.add(datePicker, 0, 3); //Row 4

        Label timeSelectLabel = new Label("View Coordinate Times");
        gridPane.add(timeSelectLabel, 1, 2); //Row 3
        GridPane.setHalignment(timeSelectLabel, HPos.LEFT);
        gridPane.add(timeSelectCombo, 1, 3); //Row 4

        // FOR DEBUGGING CURRENTLY SELECTED PATH, TIME AND POLICY
        /*         
                 UserProfile userProfile = ExtendedAppContext.getCurrentlyLoggedInUserProfile();
                 StatedInferredOptions chosenPolicy = userProfile.getStatedInferredPolicy();
                 UUID chosenPathUuid = userProfile.getViewCoordinatePath();
                 Long chosenTime = userProfile.getViewCoordinateTime();
                         
                 Label printSelectedPathLabel = new Label("Path: " + OTFUtility.getDescription(chosenPathUuid));
                 gridPane.add(printSelectedPathLabel, 0, 4);
                 GridPane.setHalignment(printSelectedPathLabel, HPos.LEFT);
                 Label printSelectedTimeLabel = null;
                 if(chosenTime != getDefaultTime()) {
                    printSelectedTimeLabel = new Label("Time: " + dateFormat.format(new Date(chosenTime)));
                 } else {
                    printSelectedTimeLabel = new Label("Time: LONG MAX VALUE");
                 }
                 gridPane.add(printSelectedTimeLabel, 1, 4);
                 GridPane.setHalignment(printSelectedTimeLabel, HPos.LEFT);
                 Label printSelectedPolicyLabel = new Label("Policy: " + chosenPolicy);
                 gridPane.add(printSelectedPolicyLabel, 2, 4);
                 GridPane.setHalignment(printSelectedPolicyLabel, HPos.LEFT);
                 */
        hBox = new HBox();
        hBox.getChildren().addAll(gridPane);

        allValid_ = new ValidBooleanBinding() {
            {
                bind(currentStatedInferredOptionProperty, currentPathProperty, currentTimeProperty);
                setComputeOnInvalidate(true);
            }

            @Override
            protected boolean computeValue() {
                if (currentStatedInferredOptionProperty.get() == null) {
                    this.setInvalidReason("Null/unset/unselected StatedInferredOption");
                    for (RadioButton button : statedInferredOptionButtons) {
                        TextErrorColorHelper.setTextErrorColor(button);
                    }
                    return false;
                } else {
                    for (RadioButton button : statedInferredOptionButtons) {
                        TextErrorColorHelper.clearTextErrorColor(button);
                    }
                }
                if (currentPathProperty.get() == null) {
                    this.setInvalidReason("Null/unset/unselected path");
                    TextErrorColorHelper.setTextErrorColor(pathComboBox);

                    return false;
                } else {
                    TextErrorColorHelper.clearTextErrorColor(pathComboBox);
                }
                if (OTFUtility.getConceptVersion(currentPathProperty.get()) == null) {
                    this.setInvalidReason("Invalid path");
                    TextErrorColorHelper.setTextErrorColor(pathComboBox);

                    return false;
                } else {
                    TextErrorColorHelper.clearTextErrorColor(pathComboBox);
                }
                //               if(currentTimeProperty.get() == null && currentTimeProperty.get() != Long.MAX_VALUE)
                //               {
                //                  this.setInvalidReason("View Coordinate Time is unselected");
                //                  TextErrorColorHelper.setTextErrorColor(timeSelectCombo);
                //                  return false;
                //               }
                this.clearInvalidReason();
                return true;
            }
        };
    }
    //      createButton.disableProperty().bind(saveButtonValid.not()));

    // Reload persisted values every time
    final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption();
    for (Toggle toggle : statedInferredToggleGroup.getToggles()) {
        if (toggle.getUserData() == storedStatedInferredOption) {
            toggle.setSelected(true);
        }
    }

    //      pathComboBox.setButtonCell(new ListCell<UUID>() {
    //         @Override
    //         protected void updateItem(UUID c, boolean emptyRow) {
    //            super.updateItem(c, emptyRow); 
    //            if (emptyRow) {
    //               setText("");
    //            } else {
    //               String desc = OTFUtility.getDescription(c);
    //               setText(desc);
    //            }
    //         }
    //      });
    //      timeSelectCombo.setButtonCell(new ListCell<Long>() {
    //         @Override
    //         protected void updateItem(Long item, boolean emptyRow) {
    //            super.updateItem(item, emptyRow); 
    //            if (emptyRow) {
    //               setText("");
    //            } else {
    //               setText(timeFormatter.format(new Date(item)));
    //            }
    //         }
    //      });

    //      datePickerFirstRun = false;
    //      pathComboFirstRun = false;

    return hBox;
}

From source file:org.dataconservancy.packaging.gui.presenter.impl.PackageGenerationPresenterImpl.java

private void setViewToDefaults() {
    if (generationParams.getParam(GeneralParameterNames.COMPRESSION_FORMAT) != null
            && !generationParams.getParam(GeneralParameterNames.COMPRESSION_FORMAT).isEmpty()) {
        for (Toggle compressionToggle : view.getCompressionToggleGroup().getToggles()) {
            if (compressionToggle.getUserData()
                    .equals(generationParams.getParam(GeneralParameterNames.COMPRESSION_FORMAT).get(0))) {
                compressionToggle.setSelected(true);
                break;
            }/*from   www.j a  v  a  2s  .  c o m*/
        }
    }

    if (generationParams.getParam(GeneralParameterNames.ARCHIVING_FORMAT) != null
            && !generationParams.getParam(GeneralParameterNames.ARCHIVING_FORMAT).isEmpty()) {
        for (Toggle archivingToggle : view.getArchiveToggleGroup().getToggles()) {
            if (archivingToggle.getUserData()
                    .equals(generationParams.getParam(GeneralParameterNames.ARCHIVING_FORMAT).get(0))) {
                archivingToggle.setSelected(true);
                break;
            }
        }
    }

    if (generationParams.getParam(BagItParameterNames.CONTACT_EMAIL) != null
            && !generationParams.getParam(BagItParameterNames.CONTACT_EMAIL).isEmpty()) {
        view.getContactEmailTextField()
                .setText(generationParams.getParam(BagItParameterNames.CONTACT_EMAIL).get(0));
    }

    if (generationParams.getParam(BagItParameterNames.CONTACT_NAME) != null
            && !generationParams.getParam(BagItParameterNames.CONTACT_NAME).isEmpty()) {
        view.getContactNameTextField().setText(generationParams.getParam(BagItParameterNames.CONTACT_NAME, 0));
    }

    if (generationParams.getParam(BagItParameterNames.CONTACT_PHONE) != null
            && !generationParams.getParam(BagItParameterNames.CONTACT_PHONE).isEmpty()) {
        view.getContactPhoneTextField()
                .setText(generationParams.getParam(BagItParameterNames.CONTACT_PHONE, 0));
    }

    if (generationParams.getParam(BagItParameterNames.EXTERNAL_IDENTIFIER) != null
            && !generationParams.getParam(BagItParameterNames.EXTERNAL_IDENTIFIER).isEmpty()) {
        view.getExternalIdentifierTextField()
                .setText(generationParams.getParam(BagItParameterNames.EXTERNAL_IDENTIFIER, 0));
    }

    if (generationParams.getParam(BagItParameterNames.CHECKSUM_ALGORITHMS) != null
            && !generationParams.getParam(BagItParameterNames.CHECKSUM_ALGORITHMS).isEmpty()) {
        for (String checksumParam : generationParams.getParam(BagItParameterNames.CHECKSUM_ALGORITHMS)) {
            if (checksumParam.equalsIgnoreCase("md5")) {
                view.getMd5CheckBox().setSelected(true);
            } else if (checksumParam.equalsIgnoreCase("sha1")) {
                view.getSHA1CheckBox().setSelected(true);
            }
        }

    }

    if (generationParams.getParam(GeneralParameterNames.PACKAGE_LOCATION) != null
            && !generationParams.getParam(GeneralParameterNames.PACKAGE_LOCATION).isEmpty()) {
        String filePath = generationParams.getParam(GeneralParameterNames.PACKAGE_LOCATION, 0);
        if (filePath != null && !filePath.isEmpty()) {
            File outputDirectory = new File(filePath);
            if (!outputDirectory.exists()) {
                if (!outputDirectory.mkdirs()) {
                    // If the directory could not be created, reset outputDirectory, and display a warning
                    controller.setOutputDirectory(null);
                    view.getStatusLabel().setText(errors.get(ErrorKey.OUTPUT_DIR_NOT_CREATED_ERROR));
                    view.getStatusLabel().setTextFill(Color.RED);
                    view.getStatusLabel().setVisible(true);
                } else {
                    controller.setOutputDirectory(outputDirectory);
                }
            }
        }
    }

    setOutputDirectory(false);
}

From source file:org.dataconservancy.packaging.gui.presenter.impl.PackageGenerationPresenterImpl.java

/**
 * we use this method to get the compression toggle corresponding to None - have to set this
 * when zip archive format is selected./*from  w ww .  j av a2  s .  c  o  m*/
 * @return toggle
 */
private Toggle getNoCompressionToggle() {
    List<Toggle> compressionToggles = view.getCompressionToggleGroup().getToggles();
    for (Toggle toggle : compressionToggles) {
        String compressionExtension = (String) toggle.getUserData();
        if (compressionExtension.isEmpty()) {//"None"
            return toggle;
        }
    }
    return null;
}

From source file:pl.baczkowicz.mqttspy.ui.controllers.NewPublicationController.java

public void initialize(URL location, ResourceBundle resources) {
    timeBasedFilter = new TimeBasedKeyEventFilter(500);

    publicationTopicText.setItems(publicationTopics);
    formatGroup.getToggles().get(0).setUserData(ConversionMethod.PLAIN);
    formatGroup.getToggles().get(1).setUserData(ConversionMethod.HEX_DECODE);
    formatGroup.getToggles().get(2).setUserData(ConversionMethod.BASE_64_DECODE);
    formatGroup.selectToggle(formatGroup.getToggles().get(0));

    formatGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override/*  ww w .  j  a v  a  2  s.c  o m*/
        public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
            // If plain has been selected
            if (newValue != null) {
                switch ((ConversionMethod) formatGroup.getSelectedToggle().getUserData()) {
                case BASE_64_DECODE:
                    showAsBase64();
                    break;
                case HEX_DECODE:
                    showAsHex();
                    break;
                case PLAIN:
                    showAsPlain();
                    break;
                default:
                    break;
                }
            }
        }
    });

    publicationTopicText.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent keyEvent) {
            switch (keyEvent.getCode()) {
            case ENTER: {
                if (connected && timeBasedFilter.processEvent(keyEvent)) {
                    publish();
                    keyEvent.consume();
                }
                break;
            }
            case DIGIT0: {
                restoreFromKeypress(keyEvent, 0);
                break;
            }
            case DIGIT1: {
                restoreFromKeypress(keyEvent, 1);
                break;
            }
            case DIGIT2: {
                restoreFromKeypress(keyEvent, 2);
                break;
            }
            case DIGIT3: {
                restoreFromKeypress(keyEvent, 3);
                break;
            }
            case DIGIT4: {
                restoreFromKeypress(keyEvent, 4);
                break;
            }
            case DIGIT5: {
                restoreFromKeypress(keyEvent, 5);
                break;
            }
            case DIGIT6: {
                restoreFromKeypress(keyEvent, 6);
                break;
            }
            case DIGIT7: {
                restoreFromKeypress(keyEvent, 7);
                break;
            }
            case DIGIT8: {
                restoreFromKeypress(keyEvent, 8);
                break;
            }
            case DIGIT9: {
                restoreFromKeypress(keyEvent, 9);
                break;
            }
            default:
                break;
            }
        }
    });

    publicationData.setWrapText(true);
    publicationData.setOnKeyReleased(new EventHandler<Event>() {
        @Override
        public void handle(Event event) {
            final BaseMqttMessage values = readMessage(false, true);

            String payload = "";
            if (values != null) {
                payload = values.getPayload();
            }

            MqttMessageController.populatePayloadLength(lengthLabel, null, payload.length());

            lengthLabel.getStyleClass().removeAll("newLinesPresent", "noNewLines");
            if (payload.contains(ConversionUtils.LINE_SEPARATOR_LINUX)
                    || payload.contains(ConversionUtils.LINE_SEPARATOR_WIN)
                    || payload.contains(ConversionUtils.LINE_SEPARATOR_MAC)) {
                lengthLabel.getStyleClass().add("newLinesPresent");
            } else {
                lengthLabel.getStyleClass().add("noNewLines");
            }
        }
    });

    publishScript.getToggles().get(0).setUserData(null);
    publishScript.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override
        public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
            if (newValue.getUserData() == null) {
                publishButton.setText("Publish");
            } else {
                publishButton.setText(
                        "Publish" + System.lineSeparator() + "with" + System.lineSeparator() + "script");
            }
        }
    });

    publishButton.setTooltip(
            new Tooltip("Publish message [" + MqttViewManager.newPublication.getDisplayText() + "]"));
}