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.Schedule1Controller.java

public ObservableList<EmployeeProperty> getEmployee() throws IOException, JSONException {
    Employees myEmployee = new Employees();

    Gson gson = new Gson();
    ObservableList<EmployeeProperty> employeesProperty = 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/employees");
    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);
        myEmployee = gson.fromJson(jo.toString(), Employees.class);
        if (myEmployee.getEmpRegistered() == true) {
            employeesProperty.add(new EmployeeProperty(myEmployee.getEmpId(), myEmployee.getEmpFirstname(),
                    myEmployee.getEmpLastname(), myEmployee.getEmpUsername()));
        }/*from  w ww  . ja  v  a 2s  .  c o  m*/
    }
    return employeesProperty;
}

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

public void addItem(ActionEvent event) {

    ObservableList<DCItem> list = dcDetail.getItems();
    if (list == null) {
        list = FXCollections.observableArrayList();
    }//from   www . j  a  v  a 2s.co m

    DCItem item = new DCItem((int) txt_name.getUserData(), txt_name.getText(), txt_brand.getText(),
            txt_model.getText(), Double.valueOf(txt_rate.getText()).intValue(),
            Integer.parseInt(txt_qty.getText()), txt_units.getText(),
            Double.valueOf(txt_amount.getText()).intValue());
    list.add(item);
    dcDetail.setItems(list);
}

From source file:aajavafx.CustomerMedicineController.java

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

    ObservableList<Customers> customers = FXCollections.observableArrayList();
    Customers myCustomer = new Customers();
    Gson gson = new Gson();
    JSONObject jo = new JSONObject();
    // SSL update..........
    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(new URL(CustomersRootURL), Charset.forName("UTF-8")));
    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);
        customers.add(myCustomer);/*from  w w w.j a  v a2s.c om*/

    }
    return customers;
}

From source file:aajavafx.DevicesController.java

public ObservableList<DevicesCustomerProperty> getDevicesCustomer() throws IOException, JSONException {

    ObservableList<DevicesCustomerProperty> devicesCustomers = FXCollections.observableArrayList();

    Gson gson = new Gson();
    JSONObject jo = new JSONObject();
    // SSL update .......
    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/devicescustomers");
    HttpResponse response = client.execute(get);
    System.out.println("RESPONSE IS: " + response);

    JSONArray jsonArray = new JSONArray(
            IOUtils.toString(response.getEntity().getContent(), Charset.forName("UTF-8")));
    // ...........
    //JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL(DevicesCustomerRootURL), Charset.forName("UTF-8")));
    System.out.println(jsonArray);
    for (int i = 0; i < jsonArray.length(); i++) {
        jo = (JSONObject) jsonArray.getJSONObject(i);
        JSONObject jObj = (JSONObject) jo.get("customersCuId");
        Customers customer = gson.fromJson(jObj.toString(), Customers.class);
        System.out.println("JSON OBJECT #" + i + " " + jo);
        String cuDevId = jo.getString("devId");
        String cuDevName = jo.getString("devName");
        devicesCustomers.add(new DevicesCustomerProperty(customer.getCuId(), customer.getCuFirstname(),
                customer.getCuLastname(), customer.getCuBirthdate(), customer.getCuAddress(),
                customer.getCuPersonnummer(), cuDevId, cuDevName));

    }/*from ww w  .  jav a 2s.c o m*/
    return devicesCustomers;
}

From source file:aajavafx.Schedule1Controller.java

public ObservableList<CustomerProperty> getUnsignedCustomers() throws IOException, JSONException {
    //Customers customers = new Customers();
    EmployeeSchedule mySchedule = new EmployeeSchedule();
    singleton = Singleton.getInstance();
    Gson gson = new Gson();

    ObservableList<CustomerProperty> customerPropertyCustomersSigned = FXCollections.observableArrayList();
    ObservableList<CustomerProperty> customerPropertyAllCustomers = this.getCustomer();
    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/employeeschedule/date/" + getDate());
    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("1 " + jsonArray);

    for (int i = 0; i < jsonArray.length(); i++) {
        jo = (JSONObject) jsonArray.getJSONObject(i);

        mySchedule = gson.fromJson(jo.toString(), EmployeeSchedule.class);

        customerPropertyCustomersSigned.add(new CustomerProperty(mySchedule.getCustomersCuId().getCuId(),
                mySchedule.getCustomersCuId().getCuFirstname(), mySchedule.getCustomersCuId().getCuLastname(),
                mySchedule.getCustomersCuId().getCuPersonnummer()));

    }//from w  ww  .j av a2s.co m

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

        for (int j = 0; j < customerPropertyCustomersSigned.size(); j++) {

            if (customerPropertyAllCustomers.get(i).getPersonnumer()
                    .equals(customerPropertyCustomersSigned.get(j).getPersonnumer())) {

                customerPropertyAllCustomers.remove(i);
            }
        }
    }

    singleton.setList(customerPropertyAllCustomers);
    return customerPropertyAllCustomers;
}

From source file:aajavafx.VisitorScheduleController.java

public ObservableList<VisitorScheduleProperty> getVisitorSchedules() throws IOException, JSONException {
    VisitorSchedule vs = new VisitorSchedule();
    VisitorSchedulePK VisitorSchedulePK = new VisitorSchedulePK();
    Gson gson = new Gson();
    ObservableList<VisitorScheduleProperty> vsProperty = FXCollections.observableArrayList();
    JSONObject jo = new JSONObject();
    JSONArray jsonArray = new JSONArray(
            IOUtils.toString(new URL(VisitorScheduleRootURL), Charset.forName("UTF-8")));
    System.out.println(jsonArray);
    for (int i = 0; i < jsonArray.length(); i++) {
        jo = (JSONObject) jsonArray.getJSONObject(i);
        vs = gson.fromJson(jo.toString(), VisitorSchedule.class);
        System.out.println("VIS ID: " + vs.getVisitorSchedulePK().getVisitorsVisId());
        vsProperty.add(new VisitorScheduleProperty(vs.getVisitorSchedulePK().getVisSchId(),
                vs.getVisitorSchedulePK().getVisitorsVisId(), vs.getVisitorSchedulePK().getCustomersCuId(),
                vs.getVisitStartDate(), vs.getVisitStartTime(), vs.getVisitEndTime(),
                vs.getVisRepetitionCircle(), vs.getVisitHash()));
    }//from  w  ww  . ja va2 s.  c o m
    return vsProperty;
}

From source file:org.nmrfx.processor.gui.PropertyManager.java

void setPropSheet(int scriptIndex, String op) {
    currentIndex = -1;//w w w .ja  va2 s  .  c  o m
    String trimOp = OperationInfo.trimOp(op);
    Pattern pattern = null;
    String opPars = "";
    if (!op.equals("")) {
        opPars = op.substring(op.indexOf('(') + 1, op.length() - 1);
        pattern = Pattern.compile(patternString);
    }
    //System.out.println("set prop sheet " + scriptIndex + " " + op);
    ObservableList<PropertySheet.Item> newItems = FXCollections.observableArrayList();
    for (PropertySheet.Item item : propItems) {
        if (item == null) {
            System.out.println("item null");
        } else if (item.getCategory().equals(trimOp) && (pattern != null)) {
            boolean foundIt = false;
            Matcher matcher = pattern.matcher(opPars);
            while (matcher.find()) {
                if (matcher.groupCount() > 1) {
                    String parName = matcher.group(1);
                    if (item.getName().equals(parName)) {
                        String parValue = matcher.group(2);
                        foundIt = true;
                        ((OperationItem) item).setFromString(parValue);
                    }
                }
            }
            if (!foundIt) {
                ((OperationItem) item).setToDefault();
            }
            newItems.add(item);
        }
    }
    currentIndex = scriptIndex;
    currentOp = trimOp;
    propertySheet.getItems().setAll(newItems);

}

From source file:aajavafx.CustomerMedicineController.java

public ObservableList<Medicines> getMedicines() throws IOException, JSONException {

    ObservableList<Medicines> medicines = FXCollections.observableArrayList();
    //Managers manager = new Managers();
    Gson gson = new Gson();
    JSONObject jo = new JSONObject();

    //........SSL Update
    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/medicines");

    HttpResponse response = client.execute(get);
    System.out.println("RESPONSE IS: " + response);
    //...................
    // JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL(MedicineRootURL), Charset.forName("UTF-8")));
    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);
        Medicines medicine = gson.fromJson(jo.toString(), Medicines.class);
        System.out.println("JSON OBJECT #" + i + " " + jo);
        medicines.add(medicine);/*from  w  ww . j  a va  2  s .c  om*/

    }
    return medicines;
}

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

public void addItem(ActionEvent event) {
    sno++;//w w w  .j a v  a 2 s .c  o m
    ObservableList<POItem> list = poDetail.getItems();
    if (list == null) {
        list = FXCollections.observableArrayList();
    }

    POItem item = new POItem((int) txt_location.getUserData(), txt_location.getText(), txt_name.getText(),
            txt_brand.getText(), txt_model.getText(), Integer.parseInt(txt_qty.getText()), false, null);
    list.add(item);
    poDetail.setItems(list);
}

From source file:jduagui.Controller.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  ww . j  av  a2  s.c  om*/
        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 && f.isDirectory() && (!f.getAbsolutePath().equals("/proc/"))) {
                File[] files = f.listFiles();
                if (files != null) {
                    ObservableList<TreeItem<File>> children = FXCollections.observableArrayList();
                    for (File childFile : files) {
                        children.add(createNode(childFile));
                    }
                    return children;
                }
            }
            return FXCollections.emptyObservableList();
        }
    };
}