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:de.halirutan.spectralis.examples.sloexporter.Controller.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    listViewItems = FXCollections.observableArrayList();
    listView.setItems(listViewItems);
}

From source file:gmailclientfx.controllers.InboxController.java

public void fetchInbox() {
    ObservableList<MyMessage> data = FXCollections.observableArrayList();
    stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId"));
    stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject"));
    stupacPosiljatelj.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender"));
    stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived"));

    Platform.runLater(() -> {//from w  ww  . j  a v  a2  s.  c o  m
        inboxTable.setItems(data);
    });
    inboxTable.setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
                MyMessage selectedMsg = inboxTable.getSelectionModel().getSelectedItem();
                PregledEmailaHelper.setMsg(selectedMsg);
                try {
                    Parent root;
                    FXMLLoader loader = new FXMLLoader();
                    loader.setLocation(
                            getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml"));
                    root = loader.load();
                    Stage stage = new Stage();
                    stage.setScene(new Scene(root));
                    stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - "
                            + PregledEmailaHelper.getMsg().getSender());
                    stage.show();
                    PregledEmailaController pgec = loader.getController();
                    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                        @Override
                        public void handle(WindowEvent event) {
                            pgec.bodyWebViewEngine.load(null);
                            System.out.println("Closing form!");
                        }

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

    });

    try {
        IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(),
                GmailClient.getAccesToken(), true);
        Folder inbox = store.getFolder("INBOX");
        inbox.open(Folder.READ_WRITE);
        int getSeenCount = inbox.getMessageCount();
        FetchProfile fp = new FetchProfile();
        fp.add(FetchProfile.Item.ENVELOPE);
        fp.add(FetchProfileItem.FLAGS);
        fp.add(FetchProfileItem.CONTENT_INFO);
        fp.add("X-mailer");

        MimeMessage[] seenMessages = (MimeMessage[]) inbox
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true));
        for (int i = 0; i < seenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "INBOX");
            data.add(msg);
        }

        MimeMessage[] unseenMessages = (MimeMessage[]) inbox
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
        for (int i = 0; i < unseenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "INBOX");
            data.add(msg);
        }

        inbox.close(false);
        store.close();
    } catch (Exception ex) {
        Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:testclientside.implement.implPerson.java

@Override
public ObservableList<Person> search(String a) {
    ObservableList<Person> listData = FXCollections.observableArrayList();
    JSONArray arr;/*www. jav a2 s .co m*/
    String jsonStr = Service.ServiceGet("search.php?nama=" + a);
    if (jsonStr != null) {
        try {
            JSONObject jsonObj = new JSONObject(jsonStr);
            arr = jsonObj.getJSONArray("hobi");
            for (int i = 0; i < arr.length(); i++) {
                JSONObject c = arr.getJSONObject(i);
                Person p = new Person();
                p.setId(c.getString("id"));
                p.setNama(c.getString("nama"));
                p.setHobi(c.getString("hobi"));
                listData.add(p);
            }
        } catch (JSONException e) {
        }
    } else {
        System.err.println("No Data");
    }
    return listData;
}

From source file:io.dacopancm.socketdcm.net.StreamSocket.java

public ObservableList<StreamFile> getStreamList() {
    ObservableList<StreamFile> list = FXCollections.observableArrayList();
    try {/*from www  .j av  a2s .  co m*/

        if (ConectType.GET_STREAMLIST.name().equalsIgnoreCase(method)) {
            logger.log(Level.INFO, "get stream list call");
            sock = new Socket(ip, port);

            DataOutputStream dOut = new DataOutputStream(sock.getOutputStream());
            DataInputStream dIn = new DataInputStream(sock.getInputStream());

            dOut.writeUTF(ConectType.STREAM.name());//send stream type
            dOut.writeUTF("uncompressed");//send comprimido o no

            dOut.writeUTF(ConectType.GET_STREAMLIST.toString()); //send type
            dOut.writeUTF("mayra");
            dOut.flush(); // Send off the data
            System.out.println("Request list send");
            String resp = dIn.readUTF();
            dOut.close();
            logger.log(Level.INFO, "resp get streamlist: {0}", resp);
            List<StreamFile> files = HelperUtil.fromJSON(resp);
            list.addAll(files);

        }
    } catch (IOException ex) {
        HelperUtil.showErrorB("No se pudo establecer conexin");
        logger.log(Level.INFO, "get streamlist error no connect:{0}", ex.getMessage());
        try {
            if (sock != null) {
                sock.close();
            }
        } catch (IOException e) {
        }

    }
    return list;
}

From source file:herudi.controller.microMarketController.java

/**
 * Initializes the controller class.//from  w ww  .  j a  v  a 2 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(interMicro.class);
        listData = FXCollections.observableArrayList();
        status = 0;
        config2.setModelColumn(colAreaLength, "areaLength");
        config2.setModelColumn(colAreaWidth, "areaWidth");
        config2.setModelColumn(colRadius, "radius");
        config2.setModelColumn(colZip, "zipCode");
        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();
    });
    // TODO
}

From source file:com.cyberlogix.mist6020biometrics.RosterController.java

public void seedTable() {
    System.out.println("Seeding Table");
    students = new ArrayList<>();
    ObjectMapper jackson = new ObjectMapper();
    try {/* ww w  . j av  a  2 s  . co m*/
        String url = ServerConnect.STUDENTS_URL + "/all";
        ServerConnect sc = new ServerConnect();
        ServerResponse msg = sc.processRequest("", url, ServerConnect.METHOD_GET);
        if (msg.getStatusCode() == 200 || msg.getStatusCode() == 201) {
            JSONArray payload = msg.getResponse().getJSONArray("payload");
            System.err.println(payload);
            if (payload.length() > 0) {
                for (int i = 0; i < payload.length(); i++) {
                    Student student = jackson.readValue(payload.getJSONObject(i).toString(), Student.class);
                    students.add(student);
                }
                ObservableList<Student> data = FXCollections.observableArrayList();
                data.addAll(students);

                //add Data to table
                colRegNo.setCellValueFactory(new PropertyValueFactory<Student, String>("regNo"));
                colName.setCellValueFactory(new PropertyValueFactory<Student, String>("name"));
                colSignedIn.setCellValueFactory(new PropertyValueFactory<Student, String>("signedIn"));
                colSignedIn.setStyle("-fx-text-fill: green; -fx-font-weight: bold;");
                tblRoster.setItems(data);
            }
        } else {
            //                Dialogs.showErrorDialog(new Stage(), msg.getResponse().getString("message"), "Error " + msg.getStatusCode(), "Error");
            alertBox.setText(msg.getResponse().getString("message"));
            alertBox.setStyle("-fx-text-fill: red; -fx-font-weight: bold;");
        }
    } catch (JSONException | IOException e) {
        UtilHelper.debugTrace(e);
    }
}

From source file:org.opendolphin.mvndemo.clientlazy.DemoController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    //Sending Command and get list with column names in the response.
    DemoApp.clientDolphin.send(CMD_GETLAZYCOLUMNS, new OnFinishedHandlerAdapter() {
        @Override/*from w w  w  . j a v  a 2s  .co m*/
        public void onFinishedData(List<Map> data) {
            if (data != null && data.size() == 1) {
                //Create lazy table with colums from the response
                createTableLazy(data);
            }
        }

    });
    //
    // when starting, first fill the table with pm ids
    DemoApp.clientDolphin.send(CMD_LAZYTABLELOAD, new OnFinishedHandlerAdapter() {
        @Override
        public void onFinishedData(List<Map> data) {
            for (Map map : data) {
                lazyRows.addAll(map.values());
            }
            unused.setValue(lazyRows.size());
        }
    });
    //
    ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
    PieChart.Data usedData = new PieChart.Data("Used", 23);
    usedData.pieValueProperty().bind(used);
    pieChartData.add(usedData);
    PieChart.Data unusedData = new PieChart.Data("unused", 100 - 23);
    unusedData.pieValueProperty().bind(unused);
    pieChartData.add(unusedData);
    pieLazyUse.setData(pieChartData);
    //
    used.addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            pieLabel.setText(String.format("Zeilen: %d / %d ", newValue, lazyRows.size()));
        }
    });
    //
    DemoApp.clientDolphin.getClientConnector().setUiThreadHandler(new JavaFXUiThreadHandler());
}

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

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

    new AutoCompleteComboBoxListener<>(select_location);
    select_location.setOnHiding((e) -> {
        Location a = select_location.getSelectionModel().getSelectedItem();
        select_location.setEditable(false);
        select_location.getSelectionModel().select(a);
    });//  ww w  .j  a v a 2s .  com
    select_location.setOnShowing((e) -> {
        select_location.setEditable(true);
    });

    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);
    });

    account_list = FXCollections.observableArrayList();
    this.account_list = this.getAccounts();
    c_id.setCellValueFactory(new PropertyValueFactory("id"));
    c_date.setCellValueFactory(new PropertyValueFactory("date"));
    c_location.setCellValueFactory(new PropertyValueFactory("location"));
    c_narration.setCellValueFactory(new PropertyValueFactory("narration"));
    c_voucher_type.setCellValueFactory(new PropertyValueFactory("voucher_type"));

    table.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent mouseEvent) {
            if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
                if (mouseEvent.getClickCount() == 2) {
                    try {
                        JSONArray res = Unirest.get(MetaData.baseUrl + "get/voucher/with/date")
                                .queryString("start_date", start_date.getValue().toString())
                                .queryString("end_date", end_date.getValue().toString())
                                .queryString("id", table.getSelectionModel().getSelectedItem().getId()).asJson()
                                .getBody().getArray();
                        Voucher v = table.getSelectionModel().getSelectedItem();
                        gerReport("VN" + String.format("%03d", Integer.parseInt(v.getId())), v.getDate(),
                                v.getNarration(), v.getVoucher_type(), v.getLocation(), res.toString());
                        System.out.println(res);
                    } catch (UnirestException ex) {
                        Logger.getLogger(ViewVouchersController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    });

    locations = FXCollections.observableArrayList();
    new Thread(() -> {
        try {
            HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/locations").asJson();
            JSONArray location_array = response.getBody().getArray();
            locations.add(new Location(0, "All", ""));
            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();

    new Thread(() -> {
        try {
            HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "get/voucher/type").asJson();
            JSONArray type = res.getBody().getArray();
            this.select_voucher_type.getItems().add(new VoucherType(0, "All", ""));
            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();
}

From source file:com.eby.admin.register.RegisterForAdminController.java

public void addcbLvl() {
    //menambah item pada cbLevel
    ObservableList list = FXCollections.observableArrayList();
    list.addAll("admin", "operator");
    cbLvl.setItems(list);/*from   w  ww.  j  a v  a  2 s . com*/
}

From source file:herudi.controller.productController.java

/**
 * Initializes the controller class.//from w  w  w .jav  a  2s . 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(interProduct.class);
        listData = FXCollections.observableArrayList();
        status = 0;
        available = "";
        config2.setModelColumn(colAvailable, "available");
        config2.setModelColumn(colDescription, "description");
        config2.setModelColumn(colManufacturerIid, "manufacturerId");
        config2.setModelColumn(colMarkup, "markup");
        config2.setModelColumn(colProductCode, "productCode");
        config2.setModelColumn(colProductId, "productId");
        config2.setModelColumn(colPurchaseCost, "formatCost");
        config2.setModelColumn(colQuantityOnHand, "quantityOnHand");
        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();
        displayManufacturer();
        displayProductCode();
    });
    // TODO
}