Example usage for javafx.collections FXCollections observableArrayList

List of usage examples for javafx.collections FXCollections observableArrayList

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public static <E> ObservableList<E> observableArrayList() 

Source Link

Document

Creates a new empty observable list that is backed by an arraylist.

Usage

From source file:com.cooksys.postmaster.PostmasterModelSingleton.java

public void createTransientPropertyInstances() {
    //instantiate our model objects
    incomingMessagesList = FXCollections.observableArrayList();
    savedResponsesList = FXCollections.observableArrayList();
    incomingMethod = new SimpleStringProperty();
    incomingUriPath = new SimpleStringProperty();
    incomingUriParams = FXCollections.observableArrayList();
    incomingHeaders = FXCollections.observableArrayList();
    incomingMessageBody = new SimpleStringProperty();
    messageConsole = new SimpleStringProperty();
}

From source file:account.management.controller.NewVoucherController.java

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

    Platform.runLater(() -> {// w  w w. ja  va2s . co m
        onAddNewFieldButtonClick(null);
    });

    account_list = FXCollections.observableArrayList();
    filter_party_rec = FXCollections.observableArrayList();
    filter_party_pay = FXCollections.observableArrayList();

    new AutoCompleteComboBoxListener<>(select_voucher_type);
    select_voucher_type.setOnHiding((e) -> {
        VoucherType a = select_voucher_type.getSelectionModel().getSelectedItem();
        select_voucher_type.setEditable(false);
        select_voucher_type.getSelectionModel().select(a);
    });
    select_voucher_type.setOnShowing((e) -> {
        select_voucher_type.setEditable(true);
    });
    new AutoCompleteComboBoxListener<>(select_location);
    select_location.setOnHiding((e) -> {
        Location a = select_location.getSelectionModel().getSelectedItem();
        select_location.setEditable(false);
        select_location.getSelectionModel().select(a);
    });
    select_location.setOnShowing((e) -> {
        select_location.setEditable(true);
    });

    new AutoCompleteComboBoxListener<>(select_type);
    select_type.setOnHiding((e) -> {
        Project a = select_type.getSelectionModel().getSelectedItem();
        select_type.setEditable(false);
        select_type.getSelectionModel().select(a);
    });
    select_type.setOnShowing((e) -> {
        select_type.setEditable(true);
    });

    new Thread(() -> {
        try {
            Thread.sleep(5000);
            this.button_submit.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() {
                public void handle(final KeyEvent keyEvent) {
                    if (keyEvent.getCode() == KeyCode.ENTER) {
                        System.out.println("attempting to submit new voucher");
                        //Stop letting it do anything else
                        keyEvent.consume();
                        onSubmitButtonClick(null);
                    }
                }
            });
        } catch (InterruptedException ex) {
            Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex);
        }

    }).start();

    /*
    *   voucher type
    */
    new Thread(() -> {
        try {
            HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "get/voucher/type").asJson();
            JSONArray type = res.getBody().getArray();
            for (int i = 0; i < type.length(); i++) {
                JSONObject obj = type.getJSONObject(i);
                int id = Integer.parseInt(obj.get("id").toString());
                String name = obj.get("type_name").toString();
                String note = obj.get("details").toString();
                this.select_voucher_type.getItems().add(new VoucherType(id, name, note));
            }
        } catch (UnirestException ex) {
            Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }).start();

    /*
    *   init locations in select_location combobox
    */
    locations = FXCollections.observableArrayList();
    new Thread(() -> {
        try {
            HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/locations").asJson();
            JSONArray location_array = response.getBody().getArray();
            for (int i = 0; i < location_array.length() - 1; i++) {
                String name = location_array.getJSONObject(i).getString("name");
                String details = location_array.getJSONObject(i).getString("details");
                int id = location_array.getJSONObject(i).getInt("id");
                locations.add(new Location(id, name, details));
            }
            select_location.getItems().addAll(locations);

        } catch (UnirestException ex) {
            System.out.println("exception in UNIREST");
        }
    }).start();

    this.button_submit.setDisable(true);

    field_container.setOnKeyReleased((KeyEvent event) -> {
        validateFields();
    });

    ToggleGroup tg = new ToggleGroup();
    this.project.setToggleGroup(tg);
    this.lc.setToggleGroup(tg);
    this.cnf.setToggleGroup(tg);

    /*
    *   init account name
    */
    new Thread(() -> {
        final ComboBox<Account> a = (ComboBox<Account>) this.field_row.getChildren().get(0);
        try {

            HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/accounts").asJson();
            JSONArray account = response.getBody().getArray();
            for (int i = 1; i < account.length(); i++) {
                JSONObject obj = account.getJSONObject(i);
                int id = Integer.parseInt(obj.get("id").toString());
                String name = obj.get("name").toString();
                String desc = obj.get("description").toString();
                int parent_id = Integer.parseInt(obj.get("parent").toString());

                account_list
                        .add(new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString()));
                if (parent_id == 21) {
                    this.filter_party_rec.add(
                            new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString()));
                }
                if (parent_id == 34) {
                    this.filter_party_pay.add(
                            new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString()));
                }
            }

            a.getItems().addAll(account_list);

        } catch (UnirestException ex) {
            Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            new AutoCompleteComboBoxListener<>(a);
            a.setOnHiding((e) -> {
                Account acc = a.getSelectionModel().getSelectedItem();
                a.setEditable(false);
                a.getSelectionModel().select(acc);
            });
            a.setOnShowing((e) -> {
                a.setEditable(true);
            });

            a.setOnAction((e) -> {
                if (!a.getSelectionModel().isEmpty() && a.getSelectionModel().getSelectedItem().getId() == 21) {
                    a.setPromptText("Select Party");
                    a.getItems().clear();
                    a.getItems().addAll(this.filter_party_rec);
                }
                if (!a.getSelectionModel().isEmpty() && a.getSelectionModel().getSelectedItem().getId() == 34) {
                    a.getItems().clear();
                    a.getItems().addAll(this.filter_party_pay);
                    a.setPromptText("Select Party");
                }
            });

        }
    }).start();

}

From source file:com.eby.admin.edit.admin.EditAdminController.java

public void addcbLvl() {
    //mengisi item untuk cbLevel
    ObservableList list = FXCollections.observableArrayList();
    list.addAll("admin", "operator");
    cbLevel.setItems(list);/*from  w  w  w  .  ja v a2  s.  c  o m*/
}

From source file:herudi.controller.customerController.java

/**
 * Initializes the controller class.//from w  w w  .j av  a2  s .  c  o m
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    Platform.runLater(() -> {
        ApplicationContext ctx = config.getInstance().getApplicationContext();
        crud = ctx.getBean(interCustomer.class);
        listData = FXCollections.observableArrayList();
        status = 0;
        config2.setModelColumn(colAdderss1, "addressline1");
        config2.setModelColumn(colAddress2, "addressline2");
        config2.setModelColumn(colCity, "city");
        config2.setModelColumn(colCreditLimit, "creditLimit");
        config2.setModelColumn(colCustomerId, "customerId");
        config2.setModelColumn(colDiscountCode, "discountCode");
        config2.setModelColumn(colEmail, "email");
        config2.setModelColumn(colFax, "fax");
        config2.setModelColumn(colName, "name");
        config2.setModelColumn(colPhone, "phone");
        config2.setModelColumn(colState, "state");
        config2.setModelColumn(colZip, "zip");
        colAction.setCellValueFactory(
                new Callback<TableColumn.CellDataFeatures<Object, Boolean>, ObservableValue<Boolean>>() {
                    @Override
                    public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<Object, Boolean> p) {
                        return new SimpleBooleanProperty(p.getValue() != null);
                    }
                });
        colAction.setCellFactory(new Callback<TableColumn<Object, Boolean>, TableCell<Object, Boolean>>() {
            @Override
            public TableCell<Object, Boolean> call(TableColumn<Object, Boolean> p) {
                return new ButtonCell(tableData);
            }
        });
        selectWithService();
        displayDiscountCode();
        displayZip();
    });
    // TODO
}

From source file:Jigs_Desktop_Client.GUI.FXMLDocumentController.java

public FXMLDocumentController() {
    jc = new Jigs_client();
    messages = FXCollections.observableArrayList();
    circles = FXCollections.observableArrayList();
    users_available = FXCollections.observableArrayList();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 500, 250, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);/* w w w . j a v a2 s. c  o  m*/
    gridpane.setVgap(10);
    root.setCenter(gridpane);

    ObservableList<Person> leaders = getPeople();
    final ObservableList<Person> teamMembers = FXCollections.observableArrayList();

    ListView<Person> leaderListView = createLeaderListView(leaders);
    TableView<Person> employeeTableView = createEmployeeTableView(teamMembers);

    Label bossesLbl = new Label("Boss");
    GridPane.setHalignment(bossesLbl, HPos.CENTER);
    gridpane.add(bossesLbl, 0, 0);
    gridpane.add(leaderListView, 0, 1);

    Label emplLbl = new Label("Employees");
    GridPane.setHalignment(emplLbl, HPos.CENTER);
    gridpane.add(emplLbl, 2, 0);
    gridpane.add(employeeTableView, 2, 1);

    leaderListView.getSelectionModel().selectedItemProperty()
            .addListener((ObservableValue<? extends Person> observable, Person oldValue, Person newValue) -> {
                if (observable != null && observable.getValue() != null) {
                    teamMembers.clear();
                    teamMembers.addAll(observable.getValue().employeesProperty());
                }
            });
    primaryStage.setScene(scene);
    primaryStage.show();
}

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);//www.  j av a 2s  . 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:retsys.client.controller.PurchaseOrderConfirmController.java

private void populateData(PurchaseOrder po) {
    po_no.setText(po.getId().toString());
    po_date.setValue(LocalDateTime.ofInstant(po.getDate().toInstant(), ZoneId.systemDefault()).toLocalDate());
    po_no.setText(po.getId().toString());
    delivery_address.setText(po.getDeliveryAddress());
    vendor.setText(po.getVendor().getName() + " (ID:" + po.getVendor().getId() + ")");
    project.setText(po.getProject().getName() + " (ID:" + po.getProject().getId() + ")");

    ObservableList<POItem> items = FXCollections.observableArrayList();
    Iterator detailsIt = po.getPurchaseOrderDetail().iterator();
    while (detailsIt.hasNext()) {
        PurchaseOrderDetail detail = (PurchaseOrderDetail) detailsIt.next();
        Item item = detail.getItem();//from  www  .ja v a  2 s .  c om
        int id = item.getId();
        String site = item.getSite();
        String name = item.getName();
        String brand = item.getBrand();
        String model = null;
        Double quantity = detail.getQuantity();
        Boolean confirm = "Y".equals(detail.getConfirm());

        items.add(new POItem(detail.getId(), site, name + " (ID:" + id + ")", brand, model, quantity, confirm,
                detail.getReceivedDate()));
    }
    poDetail.setItems(items);
    System.out.println(po.getAudit());
    populateAuditValues(po);
}

From source file:Main.java

private ObservableList<Map> generateDataInMap() {
    int max = 10;
    ObservableList<Map> allData = FXCollections.observableArrayList();
    for (int i = 1; i < max; i++) {
        Map<String, String> dataRow = new HashMap<>();

        String value1 = "A" + i;
        String value2 = "B" + i;

        dataRow.put(Column1MapKey, value1);
        dataRow.put(Column2MapKey, value2);

        allData.add(dataRow);/*from   w w w . ja v  a2 s  .c o  m*/
    }
    return allData;
}

From source file:aajavafx.VisitorScheduleController.java

/**
 * Initializes the controller class./*  ww  w .j  ava  2  s .c o 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());
                }
            });
}