@Test public void selectEditorOption() { Set<Node> comboBoxNodes = getPrimaryStage().getScene().getRoot().lookupAll(".combo-box"); List<Node> boxes = new ArrayList<>(comboBoxNodes); ComboBox<?> comboBox = (ComboBox<?>) boxes.get(1); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { RFXComboBox rfxComboBoxBase = new RFXComboBox(comboBox, null, null, lr); comboBox.getEditor().setText("Option 2"); rfxComboBoxBase.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Option 2", recording.getParameters()[0]); }
@Override public void focusLost(RFXComponent next) { ComboBox<?> comboBox = (ComboBox<?>) node; Object selectedItem = comboBox.getSelectionModel().getSelectedItem(); if (comboBox.isEditable() && comboBox.getEditor().getText() .equals(getComboBoxText(comboBox, comboBox.getItems().indexOf(prevSelectedItem), false))) { return; } else if (!comboBox.isEditable() && selectedItem != null && selectedItem.equals(prevSelectedItem)) { return; } if (!comboBox.isEditable()) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { String editorText = comboBox.getEditor().getText(); String selectedItemText = getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), false); if (editorText.equals(selectedItemText)) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { recorder.recordSelect(this, editorText); } } }
RFXComboBox extends RFXComponent { @Override public void focusLost(RFXComponent next) { ComboBox<?> comboBox = (ComboBox<?>) node; Object selectedItem = comboBox.getSelectionModel().getSelectedItem(); if (comboBox.isEditable() && comboBox.getEditor().getText() .equals(getComboBoxText(comboBox, comboBox.getItems().indexOf(prevSelectedItem), false))) { return; } else if (!comboBox.isEditable() && selectedItem != null && selectedItem.equals(prevSelectedItem)) { return; } if (!comboBox.isEditable()) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { String editorText = comboBox.getEditor().getText(); String selectedItemText = getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), false); if (editorText.equals(selectedItemText)) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { recorder.recordSelect(this, editorText); } } } }
RFXComboBox extends RFXComponent { @Override public void focusLost(RFXComponent next) { ComboBox<?> comboBox = (ComboBox<?>) node; Object selectedItem = comboBox.getSelectionModel().getSelectedItem(); if (comboBox.isEditable() && comboBox.getEditor().getText() .equals(getComboBoxText(comboBox, comboBox.getItems().indexOf(prevSelectedItem), false))) { return; } else if (!comboBox.isEditable() && selectedItem != null && selectedItem.equals(prevSelectedItem)) { return; } if (!comboBox.isEditable()) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { String editorText = comboBox.getEditor().getText(); String selectedItemText = getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), false); if (editorText.equals(selectedItemText)) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { recorder.recordSelect(this, editorText); } } } RFXComboBox(Node source, JSONOMapConfig omapConfig, Point2D point, IJSONRecorder recorder); }
RFXComboBox extends RFXComponent { @Override public void focusLost(RFXComponent next) { ComboBox<?> comboBox = (ComboBox<?>) node; Object selectedItem = comboBox.getSelectionModel().getSelectedItem(); if (comboBox.isEditable() && comboBox.getEditor().getText() .equals(getComboBoxText(comboBox, comboBox.getItems().indexOf(prevSelectedItem), false))) { return; } else if (!comboBox.isEditable() && selectedItem != null && selectedItem.equals(prevSelectedItem)) { return; } if (!comboBox.isEditable()) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { String editorText = comboBox.getEditor().getText(); String selectedItemText = getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), false); if (editorText.equals(selectedItemText)) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { recorder.recordSelect(this, editorText); } } } RFXComboBox(Node source, JSONOMapConfig omapConfig, Point2D point, IJSONRecorder recorder); @Override void focusGained(RFXComponent prev); @Override void focusLost(RFXComponent next); @Override String _getText(); }
RFXComboBox extends RFXComponent { @Override public void focusLost(RFXComponent next) { ComboBox<?> comboBox = (ComboBox<?>) node; Object selectedItem = comboBox.getSelectionModel().getSelectedItem(); if (comboBox.isEditable() && comboBox.getEditor().getText() .equals(getComboBoxText(comboBox, comboBox.getItems().indexOf(prevSelectedItem), false))) { return; } else if (!comboBox.isEditable() && selectedItem != null && selectedItem.equals(prevSelectedItem)) { return; } if (!comboBox.isEditable()) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { String editorText = comboBox.getEditor().getText(); String selectedItemText = getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), false); if (editorText.equals(selectedItemText)) { recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true)); } else { recorder.recordSelect(this, editorText); } } } RFXComboBox(Node source, JSONOMapConfig omapConfig, Point2D point, IJSONRecorder recorder); @Override void focusGained(RFXComponent prev); @Override void focusLost(RFXComponent next); @Override String _getText(); static final Logger LOGGER; }