Example usage for javafx.collections ObservableList forEach

List of usage examples for javafx.collections ObservableList forEach

Introduction

In this page you can find the example usage for javafx.collections ObservableList forEach.

Prototype

default void forEach(Consumer<? super T> action) 

Source Link

Document

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

Usage

From source file:uk.ac.cam.cl.dtg.picky.client.analytics.Analytics.java

private static void fillProperties(Properties properties, ObservableList<TreeItem<String>> entrySelection) {
    if (entrySelection == null)
        return;/*w  ww . j a va 2  s .  c om*/

    entrySelection.forEach(e -> {
        properties.put(KEY_ENTRY_SELECTION + e.getValue(), "selected");
    });
}

From source file:de.ks.file.FileViewController.java

@FXML
public void removeFile(ActionEvent event) {
    ObservableList<File> selectedItems = fileList.getSelectionModel().getSelectedItems();
    log.info("Removing files {}", selectedItems);
    selectedItems.forEach(f -> files.remove(f));
}

From source file:edu.kit.trufflehog.model.configdata.FilterDataModelTest.java

/**
 * <p>//from   w ww .  j  a  v  a2s .  c om
 *     Tests the remove functionality of the database by adding 100 randomly generated FilterInputs and removing
 *     them again, making sure the database is up-to-date along the way.
 * </p>
 *
 * @throws Exception Passes any errors that occurred during the test on
 */
// FIXME fix this test, it randomly fails (Database file locked)
@Test
public void testRemoveFilterFromDatabase() throws Exception {
    List<FilterInput> filterInputs = new ArrayList<>();
    int size = (int) (Math.random() * 100);

    // Add X FilterInputs into the database
    for (int i = 0; i < size; i++) {
        FilterInput filterInput = generateRandomFilterInput();
        filterInputs.add(filterInput);
        filterDataModel.addFilterToDatabaseAsynchronous(filterInput);
    }

    // Wait for all threads to finish
    Thread.sleep(1000);

    // Retrieve them
    filterDataModel = new FilterDataModel(fileSystem);
    ObservableList<FilterInput> filterInputFromDB = filterDataModel.getAllFilters();

    Map<String, FilterInput> filterInputMap = new HashMap<>();

    filterInputFromDB.stream().forEach(fIn -> filterInputMap.put(fIn.getName(), fIn));

    // Make sure we could retrieve them all correctly
    for (FilterInput filterInput : filterInputs) {
        assertEquals(true, filterInputMap.containsKey(filterInput.getName()));
    }

    // Delete them
    filterInputFromDB.forEach((value) -> filterDataModel.removeFilterFromDatabaseAsynchronous(value));

    // Wait for all threads to finish
    Thread.sleep(5000);

    // Retrieve them
    filterDataModel = new FilterDataModel(fileSystem);
    filterInputFromDB = filterDataModel.getAllFilters();

    // Make sure none were found
    assertEquals(true, filterInputFromDB.isEmpty());
}