List of usage examples for javafx.collections ObservableListBase ObservableListBase
ObservableListBase
From source file:org.ado.musicdroid.view.AppPresenter.java
@Override public void initialize(URL location, ResourceBundle resources) { mediaConverterService = new MediaConverterService(); mediaConverterService.valueProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null) { conversionProcessLabel.setText(String.format("Processing \"%s\" ...", newValue.getName())); }//from ww w . ja va 2s . co m }); mediaConverterService.setOnSucceeded(event -> { conversionProcessLabel.setText("Conversion finished"); exportButton.setDisable(false); }); mediaConverterService.setOnFailed(event -> { conversionProcessLabel.setText("Conversion failed!"); exportButton.setDisable(false); LOGGER.error(event.getSource().exceptionProperty().getValue().toString()); }); final List<JadbDevice> devices = getJadbDevices(); LOGGER.info("Devices [{}]", devices); devicesComboBox.setItems(new ObservableListBase<JadbDevice>() { @Override public JadbDevice get(int index) { return devices.get(index); } @Override public int size() { return devices.size(); } }); devicesComboBox.setConverter(new StringConverter<JadbDevice>() { @Override public String toString(JadbDevice device) { return device.getSerial(); } @Override public JadbDevice fromString(String string) { return null; } }); if (!devicesComboBox.getItems().isEmpty()) { devicesComboBox.setValue(devices.get(0)); exportButton.setDisable(false); } loadAlbumList(); }
From source file:org.ado.musicdroid.view.AppPresenter.java
private ObservableListBase<AlbumDirectory> getAlbumObservableList(String searchSequence) { return new ObservableListBase<AlbumDirectory>() { private List<AlbumDirectory> list = getAlbumDirectories(); private List<AlbumDirectory> getAlbumDirectories() { if (StringUtils.isNotBlank(searchSequence)) { return getFilteredAlbumList(); } else { return albumList.stream().map(AlbumDirectory::new).collect(Collectors.toList()); }//from w w w. j a v a 2 s. c o m } private List<AlbumDirectory> getFilteredAlbumList() { return albumList.stream() .filter(file -> file.getAbsolutePath().toLowerCase().contains(searchSequence)) .map(AlbumDirectory::new).sorted((o1, o2) -> o1.getFile().getAbsolutePath() .compareTo(o2.getFile().getAbsolutePath())) .collect(Collectors.toList()); } @Override public AlbumDirectory get(int index) { try { return list.get(index); } catch (Exception e) { e.printStackTrace(); return null; } } @Override public int size() { return list.size(); } }; }