@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); scene.setFill(Color.ALICEBLUE); stage.setScene(scene); stage.show(); stage.setTitle("ChoiceBox Sample"); stage.setWidth(300); stage.setHeight(200); label.setFont(Font.font("Arial", 25)); label.setLayoutX(40); final String[] greetings = new String[]{"Hello", "Hola", "Привет", "你好", "こんにちは"}; final ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList( "English", "Español", "Русский", "简体中文", "日本語") ); cb.getSelectionModel().selectedIndexProperty().addListener( (ObservableValue<? extends Number> ov, Number old_val, Number new_val) -> { label.setText(greetings[new_val.intValue()]); }); cb.setTooltip(new Tooltip("Select the language")); cb.setValue("English"); HBox hb = new HBox(); hb.getChildren().addAll(cb, label); hb.setSpacing(30); hb.setAlignment(Pos.CENTER); hb.setPadding(new Insets(10, 0, 0, 10)); ((Group) scene.getRoot()).getChildren().add(hb); }
private void setFormConstraints(Node field) { if (field instanceof ISetConstraints) { ((ISetConstraints) field).setFormConstraints(this); } else if (field instanceof Button) { _setFormConstraints((Button) field); } else if (field instanceof TextField) { _setFormConstraints((TextField) field); } else if (field instanceof TextArea) { _setFormConstraints((TextArea) field); } else if (field instanceof ComboBox<?>) { _setFormConstraints((ComboBox<?>) field); } else if (field instanceof ChoiceBox<?>) { _setFormConstraints((ChoiceBox<?>) field); } else if (field instanceof CheckBox) { _setFormConstraints((CheckBox) field); } else if (field instanceof Spinner<?>) { _setFormConstraints((Spinner<?>) field); } else if (field instanceof VBox) { _setFormConstraints((VBox) field); } else if (field instanceof Label) { _setFormConstraints((Label) field); } else { LOGGER.info("FormPane.setFormConstraints(): unknown field type: " + field.getClass().getName()); } }
@Test public void htmlOptionSelect() { @SuppressWarnings("unchecked") ChoiceBox<String> choiceBox = (ChoiceBox<String>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); String text = "This is a test text"; final String htmlText = "<html><font color=\"RED\"><h1><This is also content>" + text + "</h1></html>"; Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getItems().add(htmlText); choiceBox.getSelectionModel().select(htmlText); rfxChoiceBox.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals(text, recording.getParameters()[0]); }
@Test public void getText() { ChoiceBox<?> choiceBox = (ChoiceBox<?>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); List<String> text = new ArrayList<>(); Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getSelectionModel().select(1); rfxChoiceBox.focusLost(null); text.add(rfxChoiceBox._getText()); }); new Wait("Waiting for choice box text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("Cat", text.get(0)); }
public CadastroAlocacaoController() { ObservableList<Integer> horarios = FXCollections.observableArrayList(); for(int i = 8; i < 22; i++) { if(i%2 == 0) { horarios.add(i); //escolhaHora.add } } ObservableList<String> dias = FXCollections.observableArrayList(); dias.add("Segunda e Quarta"); dias.add("Ter�a e Quinta"); dias.add("Quarta e Sexta"); escolhaHora = new ChoiceBox(horarios); escolhaDia = new ChoiceBox(dias); //escolhaHora.getItems().addAll(horarios); //escolhaDia.getItems().addAll(dias); //escolhaHora.setItems(horarios); //escolhaDia.setItems(dias); }
private static ChoiceBox<EyeTracker> buildEyeTrackerConfigChooser(Configuration configuration, ConfigurationContext configurationContext) { ChoiceBox<EyeTracker> choiceBox = new ChoiceBox<>(); choiceBox.getItems().addAll(EyeTracker.values()); EyeTracker selectedEyeTracker = findSelectedEyeTracker(configuration); choiceBox.getSelectionModel().select(selectedEyeTracker); choiceBox.setPrefWidth(prefWidth); choiceBox.setPrefHeight(prefHeight); choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<EyeTracker>() { @Override public void changed(ObservableValue<? extends EyeTracker> observable, EyeTracker oldValue, EyeTracker newValue) { final String newPropertyValue = newValue.name(); ConfigurationBuilder.createFromPropertiesResource().withEyeTracker(newPropertyValue) .saveConfigIgnoringExceptions(); } }); return choiceBox; }
static <T> void updateItem(final Cell<T> cell, final StringConverter<T> converter, final HBox hbox, final Node graphic, final ChoiceBox<T> choiceBox ) { if (cell.isEmpty()) { cell.setText(null); cell.setGraphic(null); } else if (cell.isEditing()) { if (choiceBox != null) { choiceBox.getSelectionModel().select(cell.getItem()); } cell.setText(null); if (graphic != null) { hbox.getChildren().setAll(graphic, choiceBox); cell.setGraphic(hbox); } else { cell.setGraphic(choiceBox); } } else { cell.setText(getItemText(cell, converter)); cell.setGraphic(graphic); } }
public CommonsChoiceBoxTableCell(ObservableList<CodeDVO> codes, StringConverter<CodeDVO> stringConverter) { this.codes = codes; this.stringConverter = stringConverter; choiceBox = new ChoiceBox<>(codes); choiceBox.setConverter(stringConverter); choiceBox.setOnAction(event -> { CodeDVO value = choiceBox.getValue(); if (value == null) return; ObservableValue<String> cellObservableValue = getTableColumn().getCellObservableValue(getIndex()); WritableStringValue writableStringValue = (WritableStringValue) cellObservableValue; if (cellObservableValue instanceof WritableStringValue) { writableStringValue.set(value.getCode()); } event.consume(); }); }
/** * Initialises the macro dropdown. * @return * A choicebox representing the macro dropdown. */ private ChoiceBox<String> macroDropdownSetup() { ChoiceBox<String> macroDropdown = new ChoiceBox<String>(); macroDropdown.getSelectionModel().selectedIndexProperty() .addListener(new ChangeListener<Number>() { public void changed( ObservableValue<? extends Number> observable, Number value, Number newValue) { if ((int) newValue >= 0) { taskViewerController.runTaskMacro(macroDropdown .getItems().get((int) newValue)); macroDropdown.getSelectionModel().select(-1); } } }); return macroDropdown; }
private ChoiceBox<String> agentSelectorSetup() { workerList = new ArrayList<Agent>(); ChoiceBox<String> dropdown = new ChoiceBox<String>( controller.getAgentList(tasks.get(0), workerList)); dropdown.getSelectionModel().selectedIndexProperty() .addListener(new ChangeListener<Number>() { public void changed( ObservableValue<? extends Number> observable, Number value, Number newValue) { if ((int) newValue >= 0) { controller.setWorkerForTasks(tasks, workerList.get((int) newValue)); } } }); return dropdown; }
@Ignore public void testUpScalingQuality() throws Exception { for (EScalingAlgorithm algo : EScalingAlgorithm.getAllEnabled()) { if (algo.getSupportedForType().contains(EScalingAlgorithm.Type.UPSCALING)) { ChoiceBox choiceBox = (ChoiceBox) scene.lookup("#choiceUpScale"); //choiceBox.getSelectionModel(). for (Object o : choiceBox.getItems()) { if (o.toString().equals(algo.toString())) { } } clickOn("#choiceUpScale").clickOn(algo.toString()); assertEquals("arguments should match", defaultBuilder.upScaleAlgorithm(algo).build(), controller.getFromUI(false)); } } }
public ObjectPropertyValueSetter(Property listeningProperty, BindingType btype, Object testedControl, List values) { try { ChoiceBox cb = new ChoiceBox(); cb.setMaxWidth(175.0); cb.setId(createId(listeningProperty, btype)); cb.setItems(FXCollections.observableArrayList(values)); cb.getSelectionModel().selectFirst(); leadingControl = cb; this.leadingProperty = cb.valueProperty(); this.listeningProperty = listeningProperty; propertyValueType = PropertyValueType.OBJECTENUM; initialValue1 = !values.isEmpty() ? values.get(0) : null; bindComponent(btype, testedControl); } catch (Throwable ex) { log(ex); } }
/** * For all controls except menu. * * @param actionName title on button. * @param handler action, which will be called, when button will be clicked * and selected node will be given as argument. * @param additionalNodes nodes between ChoiceBox with different controls * and action button. You can add and process them, when action happens. */ public NodesChoserFactory(String actionName, final NodeAction<Node> handler, Node additionalNodes) { final ChoiceBox<NodeFactory> cb = new ChoiceBox<NodeFactory>(); cb.setId(NODE_CHOSER_CHOICE_BOX_ID); cb.getItems().addAll(ControlsFactory.filteredValues()); cb.getItems().addAll(Shapes.values()); cb.getItems().addAll(Panes.values()); Button actionButton = new Button(actionName); actionButton.setId(NODE_CHOOSER_ACTION_BUTTON_ID); actionButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { handler.execute(cb.getSelectionModel().getSelectedItem().createNode()); } }); this.getChildren().add(cb); this.getChildren().add(additionalNodes); this.getChildren().add(actionButton); }
/** * Only for menu * * @param actionName title on button. * @param handler action, which will be called, when button will be clicked * and selected menu/menuItem instance will be given as argument. * @param additionalNodes nodes between ChoiceBox with different controls * and action button. You can add and process them, when action happens. */ public NodesChoserFactory(String actionName, final NodeAction<MenuItem> handler, Node... additionalNodes) { final ChoiceBox<MenusFactory> cb = new ChoiceBox<MenusFactory>(); cb.setId(MENU_CHOOSER_ACTION_BUTTON_ID); cb.getItems().addAll(MenusFactory.values()); Button actionButton = new Button(actionName); actionButton.setId(MENU_CHOOSER_ACTION_BUTTON_ID); actionButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { handler.execute(cb.getSelectionModel().getSelectedItem().createNode()); } }); this.getChildren().add(cb); for (Node node : additionalNodes) { this.getChildren().add(node); } this.getChildren().add(actionButton); }
public static void setUpVars() throws Exception { scene = Root.ROOT.lookup().wrap(); sceneAsParent = scene.as(Parent.class, Node.class); object = container = (MenuButtonWrap) sceneAsParent.lookup(new LookupCriteria<Node>() { public boolean check(Node cntrl) { return MenuButton.class.isAssignableFrom(cntrl.getClass()); } }).wrap(); contentPane = sceneAsParent.lookup(new ByID<Node>(MenuButtonApp.TEST_PANE_ID)).wrap(); clearBtn = sceneAsParent.lookup(new ByText(MenuButtonApp.CLEAR_BTN_ID)).wrap(); resetBtn = sceneAsParent.lookup(new ByText(MenuButtonApp.RESET_BTN_ID)).wrap(); addPosBtn = sceneAsParent.lookup(new ByText(MenuButtonApp.ADD_SINGLE_AT_POS_BTN_ID)).wrap(); removePosBtn = sceneAsParent.lookup(new ByText(MenuButtonApp.REMOVE_SINGLE_AT_POS_BTN_ID)).wrap(); check = (Wrap<? extends Label>) sceneAsParent.lookup(new ByID(MenuButtonApp.LAST_SELECTED_ID)).wrap(); sideCB = sceneAsParent.lookup(ChoiceBox.class).wrap(); menuButtonAsStringMenuOwner = container.as(StringMenuOwner.class, Menu.class); menuButtonAsParent = container.as(Parent.class, MenuItem.class); }
public FontPane() { super(); setSpacing(5); fNames = new ChoiceBox(); fNames.getItems().addAll(Font.getFontNames()); fFamily = new Label(); fSize = new TextField(); fStyle = new Label(); HBox fNamesBox = new HBox(); fNamesBox.getChildren().addAll(new Label("Name:"), fNames); HBox fFamiliesBox = new HBox(); fFamiliesBox.getChildren().addAll(new Label("Family:"), fFamily); HBox fSizeBox = new HBox(); fSizeBox.getChildren().addAll(new Label("Size:"), fSize); HBox fStyleBox = new HBox(); fStyleBox.getChildren().addAll(new Label("Style:"), fStyle); getChildren().addAll(fNamesBox, fFamiliesBox, fSizeBox, fStyleBox); }
/** * Initializes a new instance of the {@link JrdsAdapterDialog} class. * * @param owner the owner window for the dialog */ public JrdsAdapterDialog(Node owner) { super(owner, Mode.URL); this.parent.setHeaderText("Connect to a JRDS source"); this.tabsChoiceBox = new ChoiceBox<>(); tabsChoiceBox.getItems().addAll(JrdsTreeViewTab.values()); this.extraArgumentTextField = new TextField(); HBox.setHgrow(extraArgumentTextField, Priority.ALWAYS); HBox hBox = new HBox(tabsChoiceBox, extraArgumentTextField); hBox.setSpacing(10); GridPane.setConstraints(hBox, 1, 2, 1, 1, HPos.LEFT, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS, new Insets(4, 0, 4, 0)); tabsChoiceBox.getSelectionModel().select(JrdsTreeViewTab.HOSTS_TAB); Label tabsLabel = new Label("Sorted By:"); GridPane.setConstraints(tabsLabel, 0, 2, 1, 1, HPos.LEFT, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS, new Insets(4, 0, 4, 0)); this.paramsGridPane.getChildren().addAll(tabsLabel, hBox); extraArgumentTextField.visibleProperty().bind(Bindings.createBooleanBinding(() -> this.tabsChoiceBox.valueProperty().get().getArgument() != null, this.tabsChoiceBox.valueProperty())); }
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents markdownRendererLabel = new Label(); markdownRendererChoiceBox = new ChoiceBox<>(); markdownExtensionsLabel = new Label(); markdownExtensionsPane = new MarkdownExtensionsPane(); //======== this ======== setLayout("insets dialog"); setCols("[][grow,fill]"); setRows("[]para[][grow,fill]"); //---- markdownRendererLabel ---- markdownRendererLabel.setText(Messages.get("MarkdownOptionsPane.markdownRendererLabel.text")); add(markdownRendererLabel, "cell 0 0"); add(markdownRendererChoiceBox, "cell 1 0,alignx left,growx 0"); //---- markdownExtensionsLabel ---- markdownExtensionsLabel.setText(Messages.get("MarkdownOptionsPane.markdownExtensionsLabel.text")); add(markdownExtensionsLabel, "cell 0 1 2 1"); add(markdownExtensionsPane, "pad 0 indent 0 0,cell 0 2 2 1"); // JFormDesigner - End of component initialization //GEN-END:initComponents }
public void montarSelectCategoria(ChoiceBox<Categoria> Choice){ try{ Choice.getItems().clear(); T Todas = instanciar("todas", idioma.getMensagem("todas")); Choice.getItems().add(Todas); this.select(idCategoria, nome).orderByAsc(nome); ResultSet rs = this.query(); if(rs != null){ while(rs.next()){ Choice.getItems().add(instanciar(rs)); } } Choice.getSelectionModel().selectFirst(); }catch(SQLException ex){ Janela.showException(ex); } }
public void montarSelectItem(ChoiceBox<Item> Choice){ try{ Choice.getItems().clear(); T Todas = instanciar("todas", idioma.getMensagem("todas")); Choice.getItems().add(Todas); this.select(idItem, idCategoria, nome, nomeCategoria).inner(idCategoria, idCategoriaInner).orderByAsc(nome); ResultSet rs = this.query(); if(rs != null){ while(rs.next()){ Choice.getItems().add(instanciar(rs)); } } Choice.getSelectionModel().selectFirst(); }catch(SQLException ex){ Janela.showException(ex); } }
@Override public void start(Stage primaryStage) { ChoiceBox<String> seasons = new ChoiceBox<String>(); seasons.getItems().addAll("Spring", "Summer", "Fall", "Winter"); // Get the selected value // String selectedValue = seasons.getValue(); // Set a new value // seasons.setValue("Fall"); BorderPane root = new BorderPane(); root.setCenter(seasons); Scene scene = new Scene(root, 350, 75); URL url = this.getClass().getResource("../resource/fxribbon.css"); if (url == null) { System.out.println("Resource not found. Aborting."); System.exit(-1); } String css = url.toExternalForm(); scene.getStylesheets().add(css); primaryStage.setScene(scene); primaryStage.show(); }
public FXMLMainViewController() { tcmns.add(new TableColumn("ID")); tcmns.add(new TableColumn("Category")); tcmns.add(new TableColumn("Message")); tcmns.add(new TableColumn("Priority")); messTextArea = new TextArea(); descTextArea = new TextArea(); dlblEntry = new Label(); dlbCategory = new Label(); dlbPriority = new Label(); tableView = new TableView(); todoImageView = new ImageView(); dbsUrl = new TextField(); dbsType = new ChoiceBox(); dirLabel = new Label(); listView = new ListView(); chburl = new Button(); chbtype = new Button(); removeBtn = new Button(); removeAllBtn = new Button(); JDBCConnBtn = new Button(); }
/** * @param socket An input socket where the domain contains all of the possible values to choose * from. */ @Inject SelectInputSocketController(SocketHandleView.Factory socketHandleViewFactory, GripPlatform platform, @Assisted InputSocket<T> socket) { super(socketHandleViewFactory, socket); this.platform = platform; final Object[] domain = socket.getSocketHint().getDomain().get(); @SuppressWarnings("unchecked") ObservableList<T> domainList = (ObservableList<T>) FXCollections.observableList( Arrays.asList(domain)); this.choiceBox = new ChoiceBox<>(domainList); this.choiceBox.setValue(socket.getValue().get()); this.updateSocketFromChoiceBox = o -> this.getSocket().setValue(this.choiceBox.getValue()); }
/** Set parameters of the class. * @param _word_list list of words in the dictionary (ListView) * @param _query_text_string field with a user search text query * @param _native_lang */ public void initialize(WordList _word_list, QueryTextString _query_text_string, LangChoice _lang_choice, LanguageType _native_lang ) { native_lang = _native_lang; word_list = _word_list; query_text_string = _query_text_string; lang_choice = _lang_choice; choicebox = new ChoiceBox(); choicebox.setTooltip(new Tooltip( "Select the language (language code,\n" + "number of entries (POS), number of translations).")); fillChoiceBoxByLanguages(); }
/** * creates a {@link javafx.scene.layout.HBox} with the information from the * learning parameter if it is a {@link TerminationCriteria} * * @param param * @param root * @param position */ @SuppressWarnings({ "unchecked", "rawtypes" }) private void addEnumParameterHBox(LearningParameter param, GridPane root, int position) { Label parameterLabel = new Label(param.getName()); ChoiceBox cb = new ChoiceBox(); cb.setItems(FXCollections.observableArrayList(getEnumArrayList((Class<Enum>) param.getClazz()))); cb.setValue(param.getValue()); cb.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Enum>() { public void changed(ObservableValue ov, Enum value, Enum new_value ){ param.setValue(new_value.toString()); } }); root.add(parameterLabel, 0, position); root.add(cb, 1, position); }
public final void initializePreprocessedCorpusList(){ preprocessedCorpusList = new ChoiceBox(); UIUtils.setSize(preprocessedCorpusList, Main.columnWidthRIGHT, 24); preprocessedCorpusList.setItems(AppParameters.dataset.preprocessedCorpusList); preprocessedCorpusList.valueProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue ov, String t, String t1) { clearFilterUI(); if(t1 != null){ LogUI.addLogEntry("Loading '"+AppParameters.dataset.id+"' ("+t1+")... "); AppParameters.dataset.corpus.loadFrequencies(t1); AppParameters.timeSliceA = 0; AppParameters.timeSliceB = AppParameters.dataset.corpus.messageDistribution.length; LogUI.addLogEntry("Done."); resizeSlider.setMin(0); resizeSlider.setLowValue(0); resizeSlider.setMax(AppParameters.dataset.corpus.getLength()); resizeSlider.setHighValue(AppParameters.dataset.corpus.getLength()); } } }); }
private ChoiceBox<Parking> createParkingNumberChoiceBox() { ChoiceBox<Parking> parkingNumberChoiceBox = new ChoiceBox<>(); parkingNumberChoiceBox.setPrefWidth(150); parkingNumberChoiceBox.setConverter(new StringConverter<Parking>() { @Override public String toString(Parking object) { return "(" + object.getId() + ") " + object.getName(); } @Override public Parking fromString(String string) { Integer id = Integer.valueOf(string.substring(1, string.indexOf(')'))); try { return ParkingApplicationManager.getInstance().getParkingById(id); } catch (ParkingNotPresentException e) { new Alert(Alert.AlertType.ERROR, "Vous avez sélectionné un parking inexistant. \n" + e); } return null; } }); return parkingNumberChoiceBox; }
public MyPopView(Stage stage){ super(stage,800d,500d); super.setPopUpTitle("Title"); final Stage par = super.getStage(); final ChoiceBox cb = (ChoiceBox)ChoiceBoxElement.getNode(); Button closeBtn = new Button(); closeBtn.setId("window-close"); closeBtn.setTranslateX(150); closeBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { //Platform.exit(); //par.hide(); //par.close(); cb.hide(); par.hide(); } }); Group gp = new Group(); // TODO : Add the form node. getRoot().getChildren().addAll( cb,closeBtn,gp); }
@SuppressWarnings({ "rawtypes", "unchecked"}) public static Node getNode(){ final ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList("New Document", "Open ", new Separator(), "Save", "Save as")); cb.setTooltip(new Tooltip("Select the language")); cb.getStyleClass().add("my-choice-box"); cb.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue arg0, Number arg1, Number arg2) { if(arg2.intValue()==1){ cb.getSelectionModel().clearSelection(); } } }); return cb; }
/** * Initialize method for subclasses which have grouping-related controls, which will be managed by this superclass. * This method must be called by such subclasses in their FXML initialize(). It should provide the controller-local * UI nodes needed by the AbstractViewController. * <p> * * @param threadGroupingLabel the label next to the {@link ThreadGrouping} {@link ChoiceBox} * @param threadGrouping the {@link ThreadGrouping} {@link ChoiceBox} * @param frameGroupingLabel the label next to the {@link FrameGrouping} {@link ChoiceBox} * @param frameGrouping the {@link FrameGrouping} {@link ChoiceBox} */ protected void initializeGrouping(Label threadGroupingLabel, ChoiceBox<ThreadGrouping> threadGrouping, Label frameGroupingLabel, ChoiceBox<FrameGrouping> frameGrouping) { this.threadGroupingLabel = threadGroupingLabel; this.threadGrouping = threadGrouping; this.frameGroupingLabel = frameGroupingLabel; this.frameGrouping = frameGrouping; // Model initialization grouping = new SimpleObjectProperty<>(); setVisibility( false, threadGroupingLabel, threadGrouping, frameGroupingLabel, frameGrouping); }
public static <T> void selectChoice(FxRobot robot, T choice, String fxId, String contextId) { if (!isHeadless()) { robot.clickOn(fxId).clickOn(choice.toString()); return; } ChoiceBox<T> choiceBox; if (contextId == null) { choiceBox = robot.lookup(fxId).query(); } else { javafx.scene.Node context = getContext(robot, contextId); choiceBox = robot.from(context).lookup(fxId).query(); } waitUntil(() -> choiceBox.isVisible() && !choiceBox.isDisabled()); waitUntil(asyncFx(() -> choiceBox.getSelectionModel().select(choice))); }
public static void getSelectCOMPorts(ChoiceBox selectPort) { String[] ports = SerialUtils.getOpenCOMPorts(); int portsSize=ports.length; if (portsSize==0) { selectPort.getItems().add(LN.getString("settingsPage.noCOMPort")); selectPort.setValue(LN.getString("settingsPage.noCOMPort")); } else if(portsSize==1) { selectPort.getItems().add(ports[0]); selectPort.setValue(ports[0]); } else { for(int i=0;i<portsSize;i++) { selectPort.getItems().add(ports[i]); } selectPort.getItems().add(LN.getString("settingsPage.selectCOMPort")); selectPort.setValue(LN.getString("settingsPage.selectCOMPort")); } }
public static void getSelectModelEntries(ChoiceBox selectModel,String brandName) { selectModel.getItems().clear(); selectModel.getItems().add(LN.getString("general.selectModel")); if(!brandName.equals(LN.getString("general.selectBrand"))&&!brandName.equals(LN.getString("general.notavailable"))) { String[] models = sortArray(getAvailableEntries(ObdqProperties.workingDirectoryPath+ObdqProperties.carManufacturersPath+brandName+".csv" )); int modelsSize=models.length; for(int i=0;i<modelsSize;i++) { selectModel.getItems().add(models[i]); } selectModel.setDisable(false); } else { selectModel.setDisable(true); } selectModel.setValue(LN.getString("general.selectModel")); }
/** * This test will set the value of {@link LoggingSettingsViewController} {@link ChoiceBox} to value to different * from the current {@link Level}. * <p> * The {@link LoggingSettingsViewController#onLogLevelChanged(ActionEvent)} method * will be called which creates a new {@link Runnable} containing the command to update the {@link Level}. * <p> * The {@link Runnable} will be added to the {@link Settings} using {@link Settings#addRunnable(Runnable)}. * {@link Settings} has been mocked and and a {@link ArgumentCaptor} has been added to intercept the runnable. After * then runnable has been intercepted it can be invoked. * <p> * This test will then succeed if the log {@link Level} has been changed accordingly. */ @Test void testChangeLogLevelRunnable() { final ChoiceBox<String> choiceBox = new ChoiceBox<>(); String currentLevel = LogManager.getRootLogger().getLevel().toString(); final String newLevel; if (currentLevel.equals("ERROR")) { choiceBox.setValue("DEBUG"); newLevel = "DEBUG"; } else { choiceBox.setValue("ERROR"); newLevel = "ERROR"; } assertThat(currentLevel).isNotEqualTo(newLevel); loggingSettingsViewController.setChoiceBox(choiceBox); final ActionEvent event = new ActionEvent(); interact(() -> loggingSettingsViewController.onLogLevelChanged(event)); final ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class); verify(settingsMock).addRunnable(captor.capture()); final Runnable command = captor.getValue(); command.run(); currentLevel = LogManager.getRootLogger().getLevel().toString(); assertThat(currentLevel).isEqualTo(newLevel); }
@Test void testInitializationLogLevels() { final ChoiceBox<String> choiceBox = new ChoiceBox<>(); loggingSettingsViewController.setChoiceBox(choiceBox); loggingSettingsViewController.initialize(null, null); assertThat(choiceBox.getItems()).isEqualTo(LoggingSettingsViewController.getLogLevels()); }
@Test void testInitializationCurrentLogLevel() { final ChoiceBox<String> choiceBox = new ChoiceBox<>(); final String currentLevel = LogManager.getRootLogger().getLevel().toString(); loggingSettingsViewController.setChoiceBox(choiceBox); loggingSettingsViewController.initialize(null, null); assertThat(choiceBox.getValue()).isEqualTo(currentLevel); }
public ChoiceBoxSample() { super(150,100); ChoiceBox cb = new ChoiceBox(); cb.getItems().addAll("Dog", "Cat", "Horse"); cb.getSelectionModel().selectFirst(); getChildren().add(cb); }
public String getChoiceBoxText(ChoiceBox<?> choiceBox, int index) { if (index == -1) { return null; } String original = getChoiceBoxItemText(choiceBox, index); String itemText = original; int suffixIndex = 0; for (int i = 0; i < index; i++) { String current = getChoiceBoxItemText(choiceBox, i); if (current.equals(original)) { itemText = String.format("%s(%d)", original, ++suffixIndex); } } return itemText; }
@SuppressWarnings("unchecked") private String getChoiceBoxItemText(@SuppressWarnings("rawtypes") ChoiceBox choiceBox, int index) { @SuppressWarnings("rawtypes") StringConverter converter = choiceBox.getConverter(); String text = null; if (converter == null) { text = choiceBox.getItems().get(index).toString(); } else { text = converter.toString(choiceBox.getItems().get(index)); } return stripHTMLTags(text); }
public String[][] getContent(ChoiceBox<?> choiceBox) { int nOptions = choiceBox.getItems().size(); String[][] content = new String[1][nOptions]; for (int i = 0; i < nOptions; i++) { content[0][i] = getChoiceBoxText(choiceBox, i); } return content; }