Example usage for javafx.collections ObservableList add

List of usage examples for javafx.collections ObservableList add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Appends the specified element to the end of this list (optional operation).

Usage

From source file:retsys.client.controller.CreditNoteController.java

@Override
protected void postSave(String response) {
    try {/*  w  ww .j a va2 s.  c  o  m*/
        System.out.println("response: " + response);
        CreditNote creditNote = (CreditNote) new JsonHelper().convertJsonStringToObject(response,
                new TypeReference<CreditNote>() {
                });
        creditNoteNo.setText(creditNote.getId().toString());

        Iterator<CreditNoteDetail> it = creditNote.getCreditNoteDetails().iterator();
        creditNoteDetail.setItems(null);
        ObservableList<CreditNoteItem> items = FXCollections.observableArrayList();
        while (it.hasNext()) {
            CreditNoteDetail creditNoteChild = it.next();

            items.add(
                    new CreditNoteItem(creditNoteChild.getId(),
                            creditNoteChild.getItem().getName() + " (ID:" + creditNoteChild.getItem().getId()
                                    + ")",
                            creditNoteChild.getAmount(), creditNoteChild.getReturnQuantity(),
                            creditNoteChild.isConfirm()));
        }

        creditNoteDetail.setItems(items);

    } catch (IOException ex) {
        Logger.getLogger(CreditNoteController.class.getName()).log(Level.SEVERE, null, ex);
    }

}

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

public void setBulkChangeEditor(BulkChangeEditor bce) {
    bulkChangeEditor = bce;/*from  ww w  . jav  a 2  s  .  co  m*/
    project = bce.getProjectView().getProject();

    List<DatasetColumn> columns = project.getDatasets().stream().flatMap(ds -> ds.getColumns().stream())
            .distinct().collect(Collectors.toList());
    comboBoxNameIdentifiers.setItems(FXCollections.observableArrayList(columns));

    comboBoxMethods.getSelectionModel().selectedItemProperty().addListener((a, b, c) -> {
        ChangeGenerator generator = comboBoxMethods.getSelectionModel().getSelectedItem();

        if (generator.needsDatasetColumn()) {
            // Activate it if this method needs a column
            comboBoxNameIdentifiers.setDisable(false);
        } else {
            // Otherwise 
            comboBoxNameIdentifiers.setDisable(true);
        }
    });

    ObservableList<Dataset> datasets = FXCollections.observableArrayList();
    datasets.add(ALL);
    datasets.addAll(project.getDatasets());
    datasetsComboBox.setItems(datasets);
    datasetsComboBox.getSelectionModel().clearAndSelect(0);

    setupChangesTableView();
    // findChanges();
}

From source file:musicmetadatak1009705.FolderTreeView.java

private TreeItem<File> createNode(final File f) {
    return new TreeItem<File>(f) {
        private boolean isLeaf;
        private boolean isFirstTimeChildren = true;
        private boolean isFirstTimeLeaf = true;

        @Override/* w w  w  . ja  va  2  s  .com*/
        public ObservableList<TreeItem<File>> getChildren() {
            if (isFirstTimeChildren) {
                isFirstTimeChildren = false;
                super.getChildren().setAll(buildChildren(this));
            }
            return super.getChildren();
        }

        @Override
        public boolean isLeaf() {
            if (isFirstTimeLeaf) {
                isFirstTimeLeaf = false;
                File f = (File) getValue();
                isLeaf = f.isFile();
            }
            return isLeaf;
        }

        private ObservableList<TreeItem<File>> buildChildren(TreeItem<File> TreeItem) {
            File f = TreeItem.getValue();
            if (f == null) {
                return FXCollections.emptyObservableList();
            }
            if (f.isFile()) {
                return FXCollections.emptyObservableList();
            }
            File[] files = f.listFiles();
            if (files != null) {
                ObservableList<TreeItem<File>> children = FXCollections.observableArrayList();
                for (File childFile : files) {
                    //System.out.println("Adding " + childFile.getAbsolutePath());
                    if (childFile.isDirectory()) {
                        children.add(createNode(childFile));
                    }
                }
                return children;
            }
            return FXCollections.emptyObservableList();
        }
    };
}

From source file:org.jacp.demo.components.ContactTreeViewComponent.java

/**
 * create dummy category list//from   w w  w  .  ja v  a 2  s  . com
 * 
 * @return
 */
private ObservableList<Contact> getCategoryList() {
    final ObservableList<Contact> categories = FXCollections.<Contact>observableArrayList();
    final Contact privateContact = new Contact();
    privateContact.setFirstName("private");
    final Contact publicContact = new Contact();
    publicContact.setFirstName("public");
    final Contact officeContact = new Contact();
    officeContact.setFirstName("office");
    categories.add(privateContact);
    categories.add(publicContact);
    categories.add(officeContact);
    return categories;
}

From source file:org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile.java

public ObservableList<Pair<DrawableAttribute<?>, ? extends Object>> getAttributesList() {
    final ObservableList<Pair<DrawableAttribute<?>, ? extends Object>> attributeList = FXCollections
            .observableArrayList();//from w  w w. j a  v a2s.c om
    for (DrawableAttribute<?> attr : DrawableAttribute.getValues()) {
        attributeList.add(new Pair<>(attr, attr.getValue(this)));
    }
    return attributeList;
}

From source file:aajavafx.CustomerMedicineController.java

public ObservableList<String> objectToStrings(ObservableList list) {
    ObservableList<String> strings = FXCollections.observableArrayList();
    for (Object obj : list) {
        strings.add(obj.toString());// w  w w  .j a  va  2s.co m
    }
    return strings;
}

From source file:statos2_0.StatOS2_0.java

private ObservableList<String> GetByTag() {
    JSONArray product = null;/*from  w  w w  .j av a  2 s.c  o m*/

    JSONParser jP = new JSONParser();
    ArrayList<HashMap<String, String>> prod = new ArrayList<HashMap<String, String>>();
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    //  JSON   URL
    JSONObject jsons = null;
    jsons = jP.makeHttpRequest(url_getstores, "GET", params);
    int success = jsons.getInt("success");

    if (success == 1) {
        //  
        //    
        product = jsons.getJSONArray("products");

        //   
        for (int i = 0; i < product.length(); i++) {
            JSONObject c = product.getJSONObject(i);

            //   json   
            String id = c.getString("id");
            String name = c.getString("name");
            //   HashMap
            HashMap<String, String> map = new HashMap<String, String>();

            //     HashMap  => 
            map.put("id", id);
            map.put("name", name);
            //  HashList  ArrayList
            prod.add(map);

            //System.out.println("prod="+prod);
        }
    }
    //    
    ObservableList<String> al = FXCollections.observableArrayList();
    //if(balance1.size()>=0){balanceadd();}

    // System.out.println("!!"+prod);

    for (int i = 0; i < prod.size(); i++) {

        al.add(prod.get(i).get("name"));
    }

    return al;
}

From source file:aajavafx.VisitorScheduleController.java

/**
 * Initializes the controller class.//from ww  w. j  av a  2s . co  m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    //instead of invisible, make the text fields locked for editing at first
    schIdField.setEditable(false);
    startHours.setEditable(false);
    startMins.setEditable(false);
    startSecs.setEditable(false);
    endHours.setEditable(false);
    endHours.setEditable(false);
    endHours.setEditable(false);
    customerBox.setDisable(true);
    visitorBox.setDisable(true);
    datePicker.setDisable(true);
    repeatingBox.setDisable(true);

    schIdColumn.setCellValueFactory(cellData -> cellData.getValue().visSchIdProperty().asObject());
    custIdColumn.setCellValueFactory(cellData -> cellData.getValue().customersCuIdProperty().asObject());
    visitorIdColumn.setCellValueFactory(cellData -> cellData.getValue().visitorsVisIdProperty());
    dateColumn.setCellValueFactory(cellData -> cellData.getValue().visitStartDateProperty());
    startTimeColumn.setCellValueFactory(cellData -> cellData.getValue().visitStartTimeProperty());
    endTimeColumn.setCellValueFactory(cellData -> cellData.getValue().visitEndTimeProperty());
    repeatingColumn.setCellValueFactory(cellData -> cellData.getValue().visRepetitionCircleProperty());
    hashColumn.setCellValueFactory(cellData -> cellData.getValue().visitHashProperty());

    try {
        //Populate table

        tableVisitorSchedule.setItems(getVisitorSchedules());
        ObservableList<String> repetition = FXCollections.observableArrayList();
        repetition.add("NONE");
        repetition.add("DAILY");
        repetition.add("WEEKLY");
        repetition.add("MONTHLY");
        repeatingBox.setItems(repetition);
        customerBox.setItems(getCustomer());
        customerBox.getItems().add("Add customer");
        visitorBox.setItems(getVisitor());
        visitorBox.getItems().add("Add visitor");
    } catch (IOException ex) {
        Logger.getLogger(VisitorController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception ex) {
        Logger.getLogger(VisitorController.class.getName()).log(Level.SEVERE, null, ex);
    }

    tableVisitorSchedule.getSelectionModel().selectedItemProperty()
            .addListener((obs, oldSelection, newSelection) -> {
                if (newSelection != null) {
                    schIdField.setText("" + newSelection.getVisSchId());
                    String custId = newSelection.customersCuIdProperty().getValue() + ".";
                    customerBox.setValue(getCustomerStringFromID(custId));
                    String visId = newSelection.getVisitorsVisId() + ".";
                    visitorBox.setValue(getVisitorStringFromID(visId));
                    String[] parts = newSelection.getVisitStartDate().split("-");
                    LocalDate ld = LocalDate.of(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]),
                            Integer.parseInt(parts[2]));
                    datePicker.setValue((ld));
                    String[] startParts = newSelection.getVisitStartTime().split(":");
                    startHours.setText(startParts[0]);
                    startMins.setText(startParts[1]);
                    startSecs.setText(startParts[2]);
                    String[] endParts = newSelection.getVisitEndTime().split(":");
                    endHours.setText(endParts[0]);
                    endMins.setText(endParts[1]);
                    endSecs.setText(endParts[2]);
                    repeatingBox.setValue(newSelection.getVisRepetitionCircle());
                }
            });
}

From source file:aajavafx.VisitorController.java

/**
 * Initializes the controller class./*from ww  w. j a v a2s  . c om*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    //instead of invisible, make the text fields locked for editing at first
    visitorIDField.setEditable(false);
    firstNameField.setEditable(false);
    lastNameField.setEditable(false);
    emailField.setEditable(false);
    phoneNumberField.setEditable(false);
    companyBox.setDisable(true);
    errorLabel.setVisible(false);

    visitorIDColumn.setCellValueFactory(cellData -> cellData.getValue().visIdProperty());
    firstNameColumn.setCellValueFactory(cellData -> cellData.getValue().visFirstnameProperty());
    lastNameColumn.setCellValueFactory(cellData -> cellData.getValue().visLastnameProperty());
    emailColumn.setCellValueFactory(cellData -> cellData.getValue().visEmailProperty());
    phoneColumn.setCellValueFactory(cellData -> cellData.getValue().visPhoneProperty());
    companyIDColumn.setCellValueFactory(cellData -> cellData.getValue().companyCompIdProperty().asObject());

    try {
        //Populate table
        getCompanyList();
        tableVisitors.setItems(getVisitors());
        ObservableList<String> companyList = FXCollections.observableArrayList();
        for (Company c : companies) {
            companyList.add(c.getCompName());
        }
        companyBox.setItems(companyList);
        companyBox.getItems().add("Add company");
    } catch (IOException ex) {
        Logger.getLogger(VisitorController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception ex) {
        Logger.getLogger(VisitorController.class.getName()).log(Level.SEVERE, null, ex);
    }

    tableVisitors.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
        if (newSelection != null) {
            visitorIDField.setText("" + newSelection.visIdProperty().getValue());
            firstNameField.setText(newSelection.getVisFirstname());
            lastNameField.setText(newSelection.getVisLastname());
            emailField.setText(newSelection.getVisEmail());
            phoneNumberField.setText(newSelection.getVisPhone());
            companyBox.setValue(getCompanyNameFromID(newSelection.getCompanyCompId()));
        }
    });

}

From source file:org.mskcc.shenkers.control.alignment.AlignmentOverlay.java

private void populateGridPane() {
    ObservableList<Node> children = this.getChildren();
    children.clear();//from ww  w.j a v  a  2  s  .  c o  m
    int l = nodes.size();
    boolean flip = flipProperty.get();

    for (int i = 0; i < l; i++) {
        Node n = nodes.get(i);
        GridPane.setHalignment(n, HPos.CENTER);
        GridPane.setValignment(n, VPos.CENTER);
        GridPane.setHgrow(n, Priority.ALWAYS);
        GridPane.setVgrow(n, Priority.ALWAYS);
        GridPane.setRowIndex(n, 0);
        GridPane.setColumnIndex(n, flip ? l - i - 1 : i);
        children.add(n);
    }
}