Example usage for javafx.collections FXCollections observableList

List of usage examples for javafx.collections FXCollections observableList

Introduction

In this page you can find the example usage for javafx.collections FXCollections observableList.

Prototype

public static <E> ObservableList<E> observableList(List<E> list) 

Source Link

Document

Constructs an ObservableList that is backed by the specified list.

Usage

From source file:Main.java

public static void main(String[] args) {
    List<String> list = new ArrayList<String>();

    ObservableList<String> observableList = FXCollections.observableList(list);
    observableList.addListener(new ListChangeListener() {
        @Override/*w  ww  .j a va 2 s.c o m*/
        public void onChanged(ListChangeListener.Change change) {
            System.out.println("change!");
        }
    });
    observableList.add("item one");
    list.add("item two");
    System.out.println("Size: " + observableList.size());

}

From source file:Main.java

public static void main(String[] args) {
    List<String> list = new ArrayList<String>();

    ObservableList<String> observableList = FXCollections.observableList(list);
    observableList.addListener(new ListChangeListener() {

        @Override/*from   ww  w . j a  va  2  s.  c  o  m*/
        public void onChanged(ListChangeListener.Change change) {
            System.out.println("Detected a change! ");
            while (change.next()) {
                System.out.println("Was added? " + change.wasAdded());
                System.out.println("Was removed? " + change.wasRemoved());
                System.out.println("Was replaced? " + change.wasReplaced());
                System.out.println("Was permutated? " + change.wasPermutated());
            }
        }
    });
    observableList.add("item one");
    list.add("item two");
    System.out.println("Size: " + observableList.size());

}

From source file:caillou.company.clonemanager.gui.customComponent.locationContainer.LocationsModel.java

public LocationsModel() {
    observableLocations = FXCollections.observableList(new ArrayList<LocationModel>());
}

From source file:net.rptools.gui.listeners.fxml.ScriptController.java

@Override
@ThreadPolicy(ThreadPolicy.ThreadId.JFX)
public void initialize(final URL location, final ResourceBundle aResources) {
    scriptList.setItems(FXCollections.observableList(new ArrayList<AssetTableRow>()));
}

From source file:dev.archiecortez.jfacelog.employeemanager.EmployeeManagerPresenter.java

/**
 * Initializes the controller class.//from  w  w w .  j a  va  2s  . c o m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
    employees = FXCollections.observableList(employeeDTO.listEmployees());
    employeesListView.setItems(employees);
    employeesListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    employeesListView.setCellFactory(value -> {
        return new DTREmployeeItemCell();
    });
}

From source file:net.rptools.gui.listeners.fxml.AbstractURLController.java

@Override
protected void init() {
    getURLList().getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    final List<AssetTableRow> urlRows = stateToGui();
    getURLList().setItems(FXCollections.observableList(urlRows));
    final String prefix = BOX + StringUtils.capitalize(getPrefix());
    LOGGER.debug("prefix={}", prefix);
    final TextInputControl name = ((TextInputControl) lookup(prefix + "Name"));
    final TextInputControl location = ((TextInputControl) lookup(prefix + "Location"));
    final BooleanBinding empty = name.textProperty().isEmpty().or(location.textProperty().isEmpty());
    lookup(prefix + "New").disableProperty().bind(empty);
}

From source file:caillou.company.clonemanager.gui.service.task.impl.FullHashTask.java

@Override
protected List<GUIApplicationFile> call() throws CloneManagerException {
    workerMonitor.addWorker(WorkerMonitor.HASH_WORKER, this);
    List<GUIApplicationFile> results = new ArrayList<>();

    if (analyse != null && analyse.getFilesThatMigthMatch() != null) {
        for (Map.Entry<String, Set<ApplicationFile>> entry : analyse.getFilesThatMigthMatch().entrySet()) {
            for (ApplicationFile myFile : entry.getValue()) {
                bytesToTreat += myFile.getSize();
            }/* ww w  .  jav a2s  .  c  om*/
        }
    }

    if (bytesToTreat == null) {
        throw new CloneManagerArgumentException("bytesToTreat");
    }

    if (filterStrategy == null) {
        throw new CloneManagerArgumentException("filterStrategy");
    }

    HashClassifier hashClassifier = new HashClassifier();
    hashClassifier.setCallingThread(this);
    hashClassifier.setFilterStrategy(filterStrategy);
    hashClassifier.getEventBus().register(this);

    Analyse<String, ApplicationFile> analyseResult = hashClassifier.process(this.analyse);

    for (Map.Entry<String, Set<ApplicationFile>> entry : analyseResult.getFilesThatDoMatch().entrySet()) {
        for (ApplicationFile myFile : entry.getValue()) {
            GUIApplicationFile myFileFX = new MyFileFX(myFile);
            results.add(myFileFX);
        }
    }

    if (doCssStuff) {
        this.doCssStuff(results);
    }

    ObservableList<GUIApplicationFile> observableList = FXCollections.observableList(results);
    this.updateProgress(1, 1);
    workerMonitor.removeWorker(WorkerMonitor.HASH_WORKER, this);
    return observableList;
}

From source file:app.order.OrderController.java

@Override
public void initialize(URL url, ResourceBundle resources) {

    genericInitializer(orderTable, resources);
    orderTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            //updateCheckTable(newValue);
            refreshPayments(newValue);/*from  ww  w.  j a va2s.c o  m*/

        }
    });
    checkTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            validateButton.setDisable(newValue.getPaymentState() == PaymentState.PAYE);
            setFieldsWithCheck(newValue);
            if (!checkPane.isExpanded()) {
                checkPane.setExpanded(true);
            }
        }
    });
    setCheckRowColor();

    customer.setItems(FXCollections.observableList(((IOrderMetier) metier).getCustomers()));
    checks = FXCollections.observableArrayList();

    if (!isEmpty()) {
        Order order = observableObjects.get(0);
        orderTable.getSelectionModel().select(order);
        refreshPayments(order);
    }
    setCellFactoryForCheck();
    checkTable.setItems(checks);
    checkBank.setItems(FXCollections.observableList(((IOrderMetier) metier).getBanks()));
}

From source file:com.bekwam.examples.javafx.memorytests.BigTableController.java

@FXML
public void loadTable() {

    ///*w  ww  .jav a 2 s .  c  o  m*/
    // load the data into domain objects
    //
    List<MyObject> objectsFromDataSource = fetchData();

    //
    // put in control
    //
    tblObjects.setItems(FXCollections.observableList(objectsFromDataSource));

    // Uncomment for "Scroll Time" blog post
    //      scrollEntireTable();
}

From source file:com.ggvaidya.scinames.ui.DataReconciliatorController.java

public void setDataReconciliatorView(DataReconciliatorView drv) {
    dataReconciliatorView = drv;//from  w  w  w.jav  a  2 s  .c o  m

    // Fill in the comboboxes.
    Project p = drv.getProjectView().getProject();

    namesToUseComboBox.getItems().addAll(USE_NAMES_IN_DATASET_ROWS, USE_ALL_REFERENCED_NAMES,
            USE_ALL_RECOGNIZED_NAMES);
    namesToUseComboBox.getSelectionModel().clearAndSelect(0);

    ArrayList<Dataset> ds_useNamesFrom = new ArrayList<>(p.getDatasets());
    ds_useNamesFrom.add(0, ALL); // Hee.
    ObservableList<Dataset> useNamesFrom = FXCollections.observableList(ds_useNamesFrom);
    useNamesFromComboBox.setItems(useNamesFrom);
    useNamesFromComboBox.getSelectionModel().select(0);

    ArrayList<Dataset> ds_includeDataFrom = new ArrayList<>(p.getDatasets());
    ds_includeDataFrom.add(0, ALL); // Hee.
    ds_includeDataFrom.add(0, NONE); // Also hee.
    includeDataFromComboBox.setItems(FXCollections.observableList(ds_includeDataFrom));
    includeDataFromComboBox.getSelectionModel().select(0);

    reconcileUsingComboBox.getItems().add(RECONCILE_BY_NAME);
    reconcileUsingComboBox.getItems().add(RECONCILE_BY_SPECIES_NAME);
    reconcileUsingComboBox.getItems().add(RECONCILE_BY_SPECIES_NAME_CLUSTER);
    reconcileUsingComboBox.getItems().add(RECONCILE_BY_NAME_CLUSTER);
    // reconcileUsingComboBox.getItems().add(RECONCILE_BY_SPECIES_TAXON_CONCEPT);
    // Using a new, UNTESTED algorithm now! Please test before using!
    reconcileUsingComboBox.getSelectionModel().select(RECONCILE_BY_SPECIES_NAME_CLUSTER);

    // Fill in the table with the defaults.
    // reconcileData();
}