examples/contacts-example/src/main/java/de/saxsys/mvvmfx/examples/contacts/model/countries/DataFxCountrySelector.java
void loadCountries() {
		InputStream iso3166Resource = this.getClass().getResourceAsStream(ISO_3166_LOCATION);
		if (iso3166Resource == null) {
			throw new IllegalStateException("Can't find the list of countries! Expected location was:"
					+ ISO_3166_LOCATION);
		}

		XmlConverter<Country> countryConverter = new XmlConverter<>("iso_3166_entry", Country.class);

		try {
			DataReader<Country> dataSource = new InputStreamSource<>( iso3166Resource, countryConverter );

			ListDataProvider<Country> listDataProvider = new ListDataProvider<>(dataSource);

			listDataProvider.setResultObservableList(countries);

			Worker<ObservableList<Country>> worker = listDataProvider.retrieve();
			// when the countries are loaded we start the loading of the subdivisions.
			worker.stateProperty().addListener(obs -> {
				if (worker.getState() == Worker.State.SUCCEEDED) {
					loadSubdivisions();
				}
			});
		} catch (IOException e) {
			LOG.error("A problem was detected while loading the XML file with the available countries.", e);
		}
	}
void loadCountries() {
		InputStream iso3166Resource = this.getClass().getResourceAsStream(ISO_3166_LOCATION);
		if (iso3166Resource == null) {
			throw new IllegalStateException("Can't find the list of countries! Expected location was:"
					+ ISO_3166_LOCATION);
		}

		XmlConverter<Country> countryConverter = new XmlConverter<>("iso_3166_entry", Country.class);

		try {
			DataReader<Country> dataSource = new InputStreamSource<>( iso3166Resource, countryConverter );

			ListDataProvider<Country> listDataProvider = new ListDataProvider<>(dataSource);

			listDataProvider.setResultObservableList(countries);

			Worker<ObservableList<Country>> worker = listDataProvider.retrieve();
			// when the countries are loaded we start the loading of the subdivisions.
			worker.stateProperty().addListener(obs -> {
				if (worker.getState() == Worker.State.SUCCEEDED) {
					loadSubdivisions();
				}
			});
		} catch (IOException e) {
			LOG.error("A problem was detected while loading the XML file with the available countries.", e);
		}
	}
void loadCountries ( ) { InputStream iso3166Resource = this . getClass ( ) . getResourceAsStream ( ISO_3166_LOCATION ) ; if ( iso3166Resource == null ) { throw new IllegalStateException ( "Can't find the list of countries! Expected location was:" + ISO_3166_LOCATION ) ; } XmlConverter < Country > countryConverter = new XmlConverter <> ( "iso_3166_entry" , Country . class ) ; try { DataReader < Country > dataSource = new InputStreamSource <> ( iso3166Resource , countryConverter ) ; ListDataProvider < Country > listDataProvider = new ListDataProvider <> ( dataSource ) ; listDataProvider . setResultObservableList ( countries ) ; Worker < ObservableList < Country > > worker = listDataProvider . retrieve ( ) ; // when the countries are loaded we start the loading of the subdivisions. worker . stateProperty ( ) . addListener ( obs -> { if ( worker . getState ( ) == Worker . State . SUCCEEDED ) { loadSubdivisions ( ) ; } } ) ; } catch ( IOException e ) { LOG . error ( "A problem was detected while loading the XML file with the available countries." , e ) ; } }
Load all countries from the XML file source with DataFX.
Load all countries from the XML file source with DataFX .