@Override public void initialize(URL location, ResourceBundle resources) { commitButton.setOnAction(e -> { commitHandler.ifPresent(Runnable::run); getStage().close(); this.free(); }); commitButton.disableProperty().bind(validationSupport.invalidProperty()); Platform.runLater(() -> { typeId.bind(typeChoiceBox.getSelectionModel().selectedItemProperty()); typeChoiceBox.setConverter(DesignerUtil.stringConverter(PropertyTypeId::getStringId, PropertyTypeId::lookupMnemonic)); typeChoiceBox.getItems().addAll(PropertyTypeId.typeIdsToConstants().values()); FXCollections.sort(typeChoiceBox.getItems()); }); Platform.runLater(this::registerBasicValidators); typeIdProperty().values() .filter(Objects::nonNull) .subscribe(this::registerTypeDependentValidators); }
@Override public void initialize(URL location, ResourceBundle resources) { languageChoiceBox.getItems().addAll(DesignerUtil.getSupportedLanguageVersions() .stream() .map(LanguageVersion::getLanguage) .distinct() .collect(Collectors.toList())); languageChoiceBox.setConverter(new StringConverter<Language>() { @Override public String toString(Language object) { return object.getTerseName(); } @Override public Language fromString(String string) { return LanguageRegistry.findLanguageByTerseName(string); } }); languageChoiceBox.getSelectionModel().select(LanguageRegistry.getDefaultLanguage()); exportResultArea.setSyntaxHighlighter(new XmlSyntaxHighlighter()); registerListener(nameField.textProperty(), updateResultListener()); registerListener(messageField.textProperty(), updateResultListener()); registerListener(descriptionField.textProperty(), updateResultListener()); registerListener(prioritySlider.valueProperty(), updateResultListener()); registerListener(languageChoiceBox.getSelectionModel().selectedItemProperty(), updateResultListener()); registerListener(xpathExpression, updateResultListener()); updateResultListener().changed(null, null, null); }
private void updatePoolChoiceBox(final ChoiceBox<ProcessorPoolInfo> poolChoicebox, ProcessingEngineInfo newValue) { if (newValue != null) { poolChoicebox.getItems().clear(); poolChoicebox.getItems().add(null); for (ProcessorPoolInfo processorPoolInfo : newValue.getPools()) { poolChoicebox.getItems().add(processorPoolInfo); } model.selectedPool.set(null); if (!newValue.getPools().isEmpty()) { model.selectedPool.set(newValue.getPools().get(0)); } } } }
/** * Fills all ChoiceBoxes with values dependent on the selected sport type. */ private void fillSportTypeDependentChoiceBoxes() { cbSportSubtype.getItems().clear(); cbEquipment.getItems().clear(); cbSportSubtype.getItems().add(sportSubtypeAll); cbEquipment.getItems().add(equipmentAll); final SportType selectedSportType = cbSportType.getValue(); if (selectedSportType != null && !selectedSportType.equals(sportTypeAll)) { selectedSportType.getSportSubTypeList() .forEach(sportSubType -> cbSportSubtype.getItems().add(sportSubType)); selectedSportType.getEquipmentList().forEach(equipment -> cbEquipment.getItems().add(equipment)); } // select sport subtype and equipment "all" when the filter contains no sport subtype and equipment if (filterViewModel.sportSubtype.get() == null) { filterViewModel.sportSubtype.set(sportSubtypeAll); } if (filterViewModel.equipment.get() == null) { filterViewModel.equipment.set(equipmentAll); } }
/** * Fills all ChoiceBoxes with values dependent on the selected sport type. */ private void fillSportTypeDependentChoiceBoxes() { cbSportSubtype.getItems().clear(); cbEquipment.getItems().clear(); cbEquipment.getItems().add(equipmentNone); final SportType selectedSportType = cbSportType.getValue(); if (selectedSportType != null) { selectedSportType.getSportSubTypeList().forEach(sportSubType -> cbSportSubtype.getItems().add(sportSubType)); selectedSportType.getEquipmentList().forEach(equipment -> cbEquipment.getItems().add(equipment)); } // select equipment "none" when exercise contains no equipment if (exerciseViewModel.equipment.get() == null) { exerciseViewModel.equipment.set(equipmentNone); } // disable equipment ChoiceBox when no sport type selected cbEquipment.setDisable(selectedSportType == null); }
private void updateEngineChoicebox(final ChoiceBox<ProcessingEngineInfo> engineChoicebox, ProcessingEngineInfo newValue) { if (newValue != null) { for (ProcessingEngineInfo processingEngineInfo : engineChoicebox.getItems()) { if (processingEngineInfo.getId() != null && processingEngineInfo.getId().equals(newValue.getId())) { engineChoicebox.getSelectionModel().select(processingEngineInfo); } } } else { engineChoicebox.getSelectionModel().clearSelection(); } }
private void updatePoolChoicebox(final ChoiceBox<ProcessorPoolInfo> poolChoicebox, ProcessorPoolInfo newValue) { if (newValue != null) { for (ProcessorPoolInfo pool : poolChoicebox.getItems()) { if (pool != null && pool.getId() != null && pool.getId().equals(newValue.getId())) { poolChoicebox.getSelectionModel().select(pool); } } } else { poolChoicebox.getSelectionModel().clearSelection(); } }
cbEquipment.setConverter(new NameableStringConverter<>()); cbSportType.getItems().add(sportTypeAll); document.getSportTypeList().forEach(sportType -> cbSportType.getItems().add(sportType)); cbIntensity.getItems().add(new FilterViewModel.IntensityItem(null)); Stream.of(Exercise.IntensityType.values()).forEach( intensityType -> cbIntensity.getItems().add(new FilterViewModel.IntensityItem(intensityType))); cbSportSubtype.getItems().add(sportSubtypeAll); cbEquipment.getItems().add(equipmentAll);
cbAutomaticCalculation.getItems().add(autoCalculation));
} else if ("Choice".equals(fieldType)) { choiceBox = new ChoiceBox<String>(); choiceBox.getItems().addAll(field.getChoices().split(",")); control = choiceBox; } else if ("Boolean".equals(fieldType)) {
/** * Initializes all ChoiceBoxes by defining the String converters. ChoiceBoxes with fixed values * (SportType, Intensity) will be filled with possible values. */ private void setupChoiceBoxes() { cbSportType.setConverter(new NameableStringConverter<>()); cbSportSubtype.setConverter(new NameableStringConverter<>()); cbEquipment.setConverter(new NameableStringConverter<>()); document.getSportTypeList().forEach(sportType -> cbSportType.getItems().add(sportType)); cbIntensity.setConverter(new IntensityToStringConverter()); cbIntensity.getItems().addAll(List.of(IntensityType.values())); // update the sport type dependent choiceboxes on each sport type selection change cbSportType.addEventHandler(ActionEvent.ACTION, event -> fillSportTypeDependentChoiceBoxes()); // reset the previous exercise index for copying the comment on sport type / subtype changes cbSportSubtype.addEventHandler(ActionEvent.ACTION, event -> previousExerciseIndex = null); }
engineChoicebox.setTooltip(new Tooltip("ProcessingEngine")); for (ProcessingEngineInfo engineFilter : engineList) { engineChoicebox.getItems().add(engineFilter);
sectionChoiceBox.getItems().addAll(samplePage.getSections()); toolBar.getItems().add(sectionChoiceBox); setBottom(toolBar);
private void setupChoiceBoxes() { cbTimeRange.getItems().addAll(List.of(TimeRangeType.values())); cbTimeRange.getSelectionModel().select(TimeRangeType.LAST_12_MONTHS); cbDisplay.getItems().addAll(List.of(ValueType.values())); cbDisplay.getSelectionModel().select(ValueType.DISTANCE); cbSportTypeMode.getItems().addAll(List.of(OverviewType.values())); cbSportTypeMode.getSelectionModel().select(OverviewType.EACH_SPLITTED); document.getSportTypeList().forEach(sportType -> cbSportTypeList.getItems().add(sportType)); cbSportTypeList.getSelectionModel().select(0);
private <T> void keyPressed(KeyEvent event) { KeyCode code = event.getCode(); if (code.isLetterKey() || code.isDigitKey() || code == KeyCode.SPACE) { String letter = code.getChar(); if (event.getSource() instanceof ComboBox) { ComboBox<T> comboBox = (ComboBox<T>) event.getSource(); T item = getEntryWithKey(letter, comboBox.getConverter(), comboBox.getItems(), comboBox); if (item != null) { comboBox.setValue(item); } } else if (event.getSource() instanceof ChoiceBox) { ChoiceBox<T> choiceBox = (ChoiceBox<T>) event.getSource(); T item = getEntryWithKey(letter, choiceBox.getConverter(), choiceBox.getItems(), choiceBox); if (item != null) { choiceBox.setValue(item); } } } }