@Override public void run() { MigPane root = new MigPane("wrap 2"); FieldSets.addNameField(root, model); FieldSets.addPeriodFieldSet(root, model); // // adding soil type label and field // Label soilTypeLabel = new Label(Bundle.new_field_view_label_soil_type()); root.add(soilTypeLabel); ComboBox<SoilType> soilTypeComboBox = new ComboBox<>(FXCollections.<SoilType>observableArrayList(SoilType.values())); soilTypeComboBox.setPrefWidth(150.0d); soilTypeComboBox.setCellFactory(descriptionCellFactory(SoilType.class)); root.add(soilTypeComboBox); JFXBinder.bind(Field.PROP_SOIL_TYPE).of(Model.withAt(model, Field.PROP_SOIL_TYPE)).to("value").of(soilTypeComboBox, EnumConverters.stringToEnum(SoilType.class)); JFXBinder.bind("value").of(soilTypeComboBox).to(Field.PROP_SOIL_TYPE).of(Model.withAt(model, Field.PROP_SOIL_TYPE), EnumConverters.enumToString()); Scene scene = new Scene(root, SCENE_WIDTH, SCENE_HEIGHT); StyleManager.Default.applyFormStyle(scene); fxPanel.setScene(scene); } });
soilTypeComboBox.setCellFactory(descriptionCellFactory(SoilType.class)); root.add(soilTypeComboBox); JFXBinder.bind(Field.PROP_SOIL_TYPE).of(Model.withAt(model, Field.PROP_SOIL_TYPE)).to("value").of(soilTypeComboBox, EnumConverters.stringToEnum(SoilType.class)); JFXBinder.bind("value").of(soilTypeComboBox).to(Field.PROP_SOIL_TYPE).of(model, EnumConverters.enumToString());
countryComboBox.setCellFactory(nameCellFactory(Country.class)); root.add(countryComboBox); JFXBinder.bind(HasAddress.PROP_COUNTRY).of(Model.withAt(model, HasAddress.PROP_COUNTRY)).to("value").of(countryComboBox, EnumConverters.stringToEnum(Country.class)); JFXBinder.bind("value").of(countryComboBox).to(HasAddress.PROP_COUNTRY).of(model, EnumConverters.enumToString());