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:aajavafx.CustomerController.java

public ObservableList<CustomerProperty> getCustomer() throws IOException, JSONException {

    ObservableList<CustomerProperty> customers = FXCollections.observableArrayList();
    //customers.add(new CustomerProperty(1, "Johny", "Walker", "London", "1972-07-01", "7207012222"));
    Customers myCustomer = new Customers();
    //Managers manager = new Managers();
    Gson gson = new Gson();
    ObservableList<CustomerProperty> customersProperty = FXCollections.observableArrayList();
    JSONObject jo = new JSONObject();
    CredentialsProvider provider = new BasicCredentialsProvider();
    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("EMPLOYEE", "password");
    provider.setCredentials(AuthScope.ANY, credentials);
    HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();
    HttpGet get = new HttpGet("http://localhost:8080/MainServerREST/api/customers");
    HttpResponse response = client.execute(get);
    System.out.println("RESPONSE IS: " + response);
    JSONArray jsonArray = new JSONArray(
            IOUtils.toString(response.getEntity().getContent(), Charset.forName("UTF-8")));
    System.out.println(jsonArray);
    for (int i = 0; i < jsonArray.length(); i++) {
        jo = (JSONObject) jsonArray.getJSONObject(i);
        myCustomer = gson.fromJson(jo.toString(), Customers.class);
        System.out.println(myCustomer.getCuId());
        customersProperty.add(new CustomerProperty(myCustomer.getCuId(), myCustomer.getCuFirstname(),
                myCustomer.getCuLastname(), myCustomer.getCuBirthdate(), myCustomer.getCuAddress(),
                myCustomer.getCuPersonnummer()));
    }/*from   w w w  . ja v a 2s  . c o m*/
    return customersProperty;
}

From source file:statos2_0.MainA.java

private ObservableList<String> GetByTag(String tag, String price) {
    //    /* w  w  w  .j av a2 s  . c  o  m*/
    ObservableList<String> al = FXCollections.observableArrayList();
    //if(balance1.size()>=0){balanceadd();}
    if (price.matches("")) {
        for (int i = 0; i < prod.size(); i++) {
            al.add(prod.get(i).get(tag));
        }
    } else {
        // System.out.println("!!"+prod);

        for (int i = 0; i < prod.size(); i++) {
            if (prod.get(i).get("type").matches(price)) {
                al.add(prod.get(i).get(tag));

            }

        }

    }
    return al;
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXParamListPane.java

public void setJavaFXDataCollection(Collection<ICFBamParamObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;/*from  w ww . ja  v a  2  s .  com*/
    observableListOfParam = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        if (javafxSortByChain) {
            Iterator<ICFBamParamObj> iter = javafxDataCollection.iterator();
            ICFBamParamObj head = null;
            while ((head == null) && iter.hasNext()) {
                head = iter.next();
                if (null != head.getOptionalLookupPrev()) {
                    head = null;
                }
            }
            if ((head == null) && (javafxDataCollection.size() > 0)) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Could not locate head of object chain");
            }
            ICFBamParamObj cur = head;
            while (cur != null) {
                observableListOfParam.add(cur);
                cur = cur.getOptionalLookupNext();
            }
        } else {
            Iterator<ICFBamParamObj> iter = javafxDataCollection.iterator();
            while (iter.hasNext()) {
                observableListOfParam.add(iter.next());
            }
            observableListOfParam.sort(compareParamByQualName);
        }
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfParam);
        // Hack from stackoverflow to fix JavaFX TableView refresh issue
        ((TableColumn) dataTable.getColumns().get(0)).setVisible(false);
        ((TableColumn) dataTable.getColumns().get(0)).setVisible(true);
    }
}

From source file:com.rockhoppertech.symchords.fx.SymChordsController.java

void updatePatternList() {
    int limit = 7;
    int size = 6;
    List<int[]> patterns = null;

    if (this.model.getMIDITrack() != null) {
        size = model.getMIDITrack().size();
        patterns = PatternFactory.getPatterns(size, size);
    } else {//from  w  w w.j  a va 2s . c o  m
        patterns = PatternFactory.getPatterns(limit, size);
    }

    ObservableList<int[]> items = FXCollections.observableArrayList();
    this.patternListView.setItems(items);
    for (int[] a : patterns) {
        items.add(a);
    }
}

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 2  s  .  c  o  m
    }
    return strings;
}

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

@FXML
private void onSelectType(ActionEvent event) {
    filter_acc = FXCollections.observableArrayList();
    for (int i = 0; i < this.account_list.size(); i++) {
        if (this.account_list.get(i).getAccount_type()
                .equals(this.select_type.getSelectionModel().getSelectedItem().getId())
                && this.account_list.get(i).getId() > 57) {
            filter_acc.add(this.account_list.get(i));

        }//www  .j a va2s.  c  o  m
    }
    //this.account_list.clear();
    for (int i = 0; i < this.field_container.getChildren().size(); i++) {
        HBox row = (HBox) this.field_container.getChildren().get(i);
        ComboBox<Account> combo = (ComboBox<Account>) row.getChildren().get(0);
        combo.getItems().clear();
        combo.getItems().addAll(filter_acc);
    }
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXIndexColListPane.java

public void setJavaFXDataCollection(Collection<ICFBamIndexColObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//www  . j a va 2  s.com
    observableListOfIndexCol = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        if (javafxSortByChain) {
            Iterator<ICFBamIndexColObj> iter = javafxDataCollection.iterator();
            ICFBamIndexColObj head = null;
            while ((head == null) && iter.hasNext()) {
                head = iter.next();
                if (null != head.getOptionalLookupPrev()) {
                    head = null;
                }
            }
            if ((head == null) && (javafxDataCollection.size() > 0)) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Could not locate head of object chain");
            }
            ICFBamIndexColObj cur = head;
            while (cur != null) {
                observableListOfIndexCol.add(cur);
                cur = cur.getOptionalLookupNext();
            }
        } else {
            Iterator<ICFBamIndexColObj> iter = javafxDataCollection.iterator();
            while (iter.hasNext()) {
                observableListOfIndexCol.add(iter.next());
            }
            observableListOfIndexCol.sort(compareIndexColByQualName);
        }
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfIndexCol);
        // Hack from stackoverflow to fix JavaFX TableView refresh issue
        ((TableColumn) dataTable.getColumns().get(0)).setVisible(false);
        ((TableColumn) dataTable.getColumns().get(0)).setVisible(true);
    }
}

From source file:condorclient.MainFXMLController.java

private void configureTable() {
    //selected.setCellValueFactory(new PropertyValueFactory<>("selected"))
    //s// w  w  w.  j a va  2s  .c o  m

    table.getColumns().addAll(new TableColumn("??"), new TableColumn("ID"),
            new TableColumn("??"), new TableColumn(""),
            new TableColumn(""), new TableColumn(""), new TableColumn("?"),
            new TableColumn(""), new TableColumn("?"));

    //private 
    ObservableList<DisplayedClassAdStub> data = FXCollections.observableArrayList();

    ObservableList<TableColumn> observableList = table.getColumns();
    observableList.get(0).setCellValueFactory(new PropertyValueFactory(ColClusterNameMapKey));
    observableList.get(1).setCellValueFactory(new PropertyValueFactory(ColClusterIdMapKey));
    observableList.get(2).setCellValueFactory(new PropertyValueFactory(ColInfoFileNameMapKey));
    observableList.get(3).setCellValueFactory(new PropertyValueFactory(ColExpFileNameMapKey));
    observableList.get(4).setCellValueFactory(new PropertyValueFactory(ColTotalSampleNumMapKey));
    observableList.get(5).setCellValueFactory(new PropertyValueFactory(ColSubmittedTimeMapKey));
    observableList.get(6).setCellValueFactory(new PropertyValueFactory(ColRunTimeMapKey));
    observableList.get(7).setCellValueFactory(new PropertyValueFactory(ColProcessStatusMapKey));
    observableList.get(7).setCellFactory(ProgressBarTableCell.forTableColumn());
    observableList.get(8).setCellValueFactory(new PropertyValueFactory(ColJobStatusMapKey));

    table.setItems(tableContent);
    tablePane.getChildren().add(table);
    // table.setSelectionModel(null);
    //sampleTab
    sampleTab.getColumns().addAll(new TableColumn("?"), new TableColumn(""),
            new TableColumn("??"), new TableColumn("?"), new TableColumn(""),
            new TableColumn("?"), new TableColumn(""), new TableColumn("?"));
    ((TableColumn) sampleTab.getColumns().get(6)).setVisible(false);
    ((TableColumn) sampleTab.getColumns().get(2)).setPrefWidth(150);
    ((TableColumn) sampleTab.getColumns().get(5)).setPrefWidth(50);
    ((TableColumn) sampleTab.getColumns().get(7)).setPrefWidth(150);
    //private 
    ObservableList<DisplayedClassAdStub> sampleData = FXCollections.observableArrayList();

    ObservableList<TableColumn> sampleList = sampleTab.getColumns();
    sampleList.get(0).setCellValueFactory(new PropertyValueFactory(ColSampleIdMapKey));
    sampleList.get(1).setCellValueFactory(new PropertyValueFactory(ColEachRunMapKey));
    sampleList.get(2).setCellValueFactory(new PropertyValueFactory(ColSampleSubmittedTimeMapKey));
    sampleList.get(3).setCellValueFactory(new PropertyValueFactory(ColSampleRunTimeMapKey));
    sampleList.get(4).setCellValueFactory(new PropertyValueFactory(ColSampleProcessStatusMapKey));
    sampleList.get(4).setCellFactory(ProgressBarTableCell.forTableColumn());
    sampleList.get(5).setCellValueFactory(new PropertyValueFactory(ColSampleJobStatusMapKey));
    sampleList.get(6).setCellValueFactory(new PropertyValueFactory(ColCpuIdMapKey));
    sampleList.get(7).setCellValueFactory(new PropertyValueFactory(ColSlotIdMapKey));

    sampleTab.setItems(sampleContent);
    sampleBox.getChildren().add(sampleTab);

    //end sampleTab
    // ColConnectInfoMapKey  ColIpMapKey ColMachineIdMapKey ColMemMapKey ColDiskMapKey ColSlotNumMapKey
    //ColJobNameMapKey  ColJobCpuMapKey ColJobMemMapKey
    colConnectInfo.setCellValueFactory(new PropertyValueFactory<>(ColConnectInfoMapKey));
    colIp.setCellValueFactory(new PropertyValueFactory<>(ColIpMapKey));
    colMachineId.setCellValueFactory(new PropertyValueFactory<>(ColMachineIdMapKey));
    colMem.setCellValueFactory(new PropertyValueFactory<>(ColMemMapKey));
    colSlotNum.setCellValueFactory(new PropertyValueFactory<>(ColSlotNumMapKey));
    colDisk.setCellValueFactory(new PropertyValueFactory<>(ColDiskMapKey));
    colCpu.setCellValueFactory(new PropertyValueFactory<>(ColCpuMapKey));
    resourcesTab.setItems(resourcesContent);
    //resourcesTab.setSelectionModel(null);

    colJobName.setCellValueFactory(new PropertyValueFactory<>(ColJobNameMapKey));
    colJobCpu.setCellValueFactory(new PropertyValueFactory<>(ColJobCpuMapKey));
    colJobMem.setCellValueFactory(new PropertyValueFactory<>(ColJobMemMapKey));
    job_resourcesTab.setItems(jobContent);
    job_resourcesTab.setSelectionModel(null);

}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXRelationColListPane.java

public void setJavaFXDataCollection(Collection<ICFBamRelationColObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;/* w w w.  j  a v a 2s.c o  m*/
    observableListOfRelationCol = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        if (javafxSortByChain) {
            Iterator<ICFBamRelationColObj> iter = javafxDataCollection.iterator();
            ICFBamRelationColObj head = null;
            while ((head == null) && iter.hasNext()) {
                head = iter.next();
                if (null != head.getOptionalLookupPrev()) {
                    head = null;
                }
            }
            if ((head == null) && (javafxDataCollection.size() > 0)) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Could not locate head of object chain");
            }
            ICFBamRelationColObj cur = head;
            while (cur != null) {
                observableListOfRelationCol.add(cur);
                cur = cur.getOptionalLookupNext();
            }
        } else {
            Iterator<ICFBamRelationColObj> iter = javafxDataCollection.iterator();
            while (iter.hasNext()) {
                observableListOfRelationCol.add(iter.next());
            }
            observableListOfRelationCol.sort(compareRelationColByQualName);
        }
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfRelationCol);
        // Hack from stackoverflow to fix JavaFX TableView refresh issue
        ((TableColumn) dataTable.getColumns().get(0)).setVisible(false);
        ((TableColumn) dataTable.getColumns().get(0)).setVisible(true);
    }
}