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:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXClearSubDep3ListPane.java

public void setJavaFXDataCollection(Collection<ICFBamClearSubDep3Obj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//from  w  w  w . j  ava  2 s .c  o m
    observableListOfClearSubDep3 = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamClearSubDep3Obj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfClearSubDep3.add(iter.next());
        }
        observableListOfClearSubDep3.sort(compareClearSubDep3ByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfClearSubDep3);
        // 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:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXDelDepListPane.java

public void setJavaFXDataCollection(Collection<ICFBamDelDepObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//w w w.  j av  a  2s .co m
    observableListOfDelDep = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamDelDepObj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfDelDep.add(iter.next());
        }
        observableListOfDelDep.sort(compareDelDepByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfDelDep);
        // 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:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXPopDepListPane.java

public void setJavaFXDataCollection(Collection<ICFBamPopDepObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//from  w  ww.j a  va 2  s.  co  m
    observableListOfPopDep = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamPopDepObj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfPopDep.add(iter.next());
        }
        observableListOfPopDep.sort(comparePopDepByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfPopDep);
        // 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:aajavafx.VisitorScheduleController.java

public ObservableList<String> getVisitor() throws IOException, JSONException {

    ObservableList<String> visitorStrings = FXCollections.observableArrayList();
    //customers.add(new CustomerProperty(1, "Johny", "Walker", "London", "1972-07-01", "7207012222"));
    Visitors visitor = new Visitors();
    //Managers manager = new Managers();
    Gson gson = new Gson();
    ObservableList<CustomerProperty> customersProperty = FXCollections.observableArrayList();
    JSONObject jo = new JSONObject();
    JSONArray jsonArray = new JSONArray(IOUtils
            .toString(new URL("http://localhost:8080/MainServerREST/api/visitors"), Charset.forName("UTF-8")));
    System.out.println(jsonArray);
    for (int i = 0; i < jsonArray.length(); i++) {
        jo = (JSONObject) jsonArray.getJSONObject(i);
        visitor = gson.fromJson(jo.toString(), Visitors.class);
        visitors.add(visitor);/* w w w.  j ava  2  s  . c  om*/
        System.out.println(visitor.getVisId());
        String s = visitor.getVisId() + ". " + visitor.getVisFirstname() + " " + visitor.getVisLastname();
        visitorStrings.add(s);

    }
    visStrings = visitorStrings;
    return visitorStrings;
}

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

public void setJavaFXDataCollection(Collection<ICFBamClearTopDepObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//from  w  ww  .j  av a2 s. c o  m
    observableListOfClearTopDep = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        if (javafxSortByChain) {
            Iterator<ICFBamClearTopDepObj> iter = javafxDataCollection.iterator();
            ICFBamClearTopDepObj 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");
            }
            ICFBamClearTopDepObj cur = head;
            while (cur != null) {
                observableListOfClearTopDep.add(cur);
                cur = cur.getOptionalLookupNext();
            }
        } else {
            Iterator<ICFBamClearTopDepObj> iter = javafxDataCollection.iterator();
            while (iter.hasNext()) {
                observableListOfClearTopDep.add(iter.next());
            }
            observableListOfClearTopDep.sort(compareClearTopDepByQualName);
        }
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfClearTopDep);
        // 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:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXClearDepListPane.java

public void setJavaFXDataCollection(Collection<ICFBamClearDepObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;/* w ww . j a  v a 2 s . c o m*/
    observableListOfClearDep = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamClearDepObj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfClearDep.add(iter.next());
        }
        observableListOfClearDep.sort(compareClearDepByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfClearDep);
        // 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:gov.va.isaac.gui.ConceptNode.java

/**
 * If, for some reason, you want a concept node selection box that is completely disabled - call this method after constructing
 * the concept node.  Though one wonders, why you wouldn't just use a label in this case....
 *//*from www  . ja v  a2s  .  c o m*/
public void disableEdit() {
    AppContext.getService(DragRegistry.class).removeDragCapability(cb_);
    cb_.setEditable(false);
    dropDownOptions_.removeListener(listChangeListener_);
    listChangeListener_ = null;
    cb_.setItems(FXCollections.observableArrayList());
    cb_.setBackground(new Background(new BackgroundFill(Color.LIGHTGRAY, new CornerRadii(0), new Insets(0))));
}

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

public void setJavaFXDataCollection(Collection<ICFBamSchemaRefObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//from   w w  w.j a v  a  2  s  .c  om
    observableListOfSchemaRef = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        if (javafxSortByChain) {
            Iterator<ICFBamSchemaRefObj> iter = javafxDataCollection.iterator();
            ICFBamSchemaRefObj 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");
            }
            ICFBamSchemaRefObj cur = head;
            while (cur != null) {
                observableListOfSchemaRef.add(cur);
                cur = cur.getOptionalLookupNext();
            }
        } else {
            Iterator<ICFBamSchemaRefObj> iter = javafxDataCollection.iterator();
            while (iter.hasNext()) {
                observableListOfSchemaRef.add(iter.next());
            }
            observableListOfSchemaRef.sort(compareSchemaRefByQualName);
        }
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfSchemaRef);
        // 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:frontend.GUIController.java

public void fillTable(String fileName) {
    System.out.println("Filling table using: " + fileName);
    String prefixName;//  www.jav a  2s  .  co m
    prefixName = FilenameUtils.getBaseName(fileName);
    personData = FXCollections.observableArrayList();
    at.addTweets(at.outputDir + "/original/" + prefixName + ".tsv", personData);
    featureTable.setItems(personData);
}

From source file:memoryaid.SetReminderController.java

@FXML
public void buildReminderTableData() throws SQLException {
    System.out.println("In builddata");

    DbConnection db = new DbConnection();
    Connection conn = db.connect();
    String SQL = "select RId,ReminderName,ReminderType,StartDate,EndDate,ReminderTime from reminders";
    ResultSet rs = conn.createStatement().executeQuery(SQL);

    TableColumn rIdCol = new TableColumn("RId");
    rIdCol.setCellValueFactory(new PropertyValueFactory<>("reminderId"));

    TableColumn reminderNameCol = new TableColumn("ReminderName");
    reminderNameCol.setCellValueFactory(new PropertyValueFactory<>("reminderName"));

    TableColumn reminderTypeCol = new TableColumn("ReminderType");
    reminderTypeCol.setCellValueFactory(new PropertyValueFactory<>("reminderType"));

    TableColumn startDateCol = new TableColumn("StartDate");
    startDateCol.setCellValueFactory(new PropertyValueFactory<>("startDate"));

    TableColumn endDateCol = new TableColumn("EndDate");
    endDateCol.setCellValueFactory(new PropertyValueFactory<>("endDate"));

    TableColumn reminderTimeCol = new TableColumn("ReminderTime");
    reminderTimeCol.setCellValueFactory(new PropertyValueFactory<>("reminderTime"));

    reminderTable.getColumns().add(rIdCol);
    reminderTable.getColumns().add(reminderNameCol);
    reminderTable.getColumns().add(reminderTypeCol);
    reminderTable.getColumns().add(startDateCol);
    reminderTable.getColumns().add(endDateCol);
    reminderTable.getColumns().add(reminderTimeCol);

    ObservableList<Object> data = FXCollections.observableArrayList();

    while (rs.next()) {
        String rId = String.valueOf(rs.getInt("RId"));

        data.add(new ReminderModel(rId, rs.getString("ReminderName"), rs.getString("ReminderType"),
                rs.getString("StartDate"), rs.getString("EndDate"), rs.getString("ReminderTime")));
    }/* w w w. jav a2  s  .  c  o m*/
    rs.close();
    conn.close();

    Callback<TableColumn<ReminderModel, String>, TableCell<ReminderModel, String>> cellFactory = (
            TableColumn<ReminderModel, String> p) -> new EditingCell();

    //Code For Reminder Name update

    reminderNameCol.setCellValueFactory(new PropertyValueFactory<>("reminderName"));
    reminderNameCol.setCellFactory(cellFactory);
    reminderNameCol.setOnEditCommit(new EventHandler<CellEditEvent<ReminderModel, String>>() {

        @Override
        public void handle(CellEditEvent<ReminderModel, String> t) {
            ((ReminderModel) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                    .setReminderName(t.getNewValue());

            System.out.println("*******" + t.getNewValue());
            ReminderModel selectedItem = (ReminderModel) reminderTable.getSelectionModel().getSelectedItem();
            System.out.println(selectedItem);
            String rIdToUpdate = selectedItem.getReminderId();
            Statement stmt = null;
            DbConnection db = new DbConnection();
            Connection conn = db.connect();

            try {
                stmt = conn.createStatement();

                String updateSql = "UPDATE Reminders set ReminderName = '" + t.getNewValue() + "'"
                        + "WHERE RId = '" + rIdToUpdate + "'";

                stmt.executeUpdate(updateSql);
            } catch (SQLException ex) {
                Logger.getLogger(SetReminderController.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

    });

    //For ReminderType Column Update

    reminderTypeCol.setCellValueFactory(new PropertyValueFactory<>("reminderType"));
    reminderTypeCol.setCellFactory(cellFactory);
    reminderTypeCol.setOnEditCommit(new EventHandler<CellEditEvent<ReminderModel, String>>() {

        @Override
        public void handle(CellEditEvent<ReminderModel, String> t) {
            ((ReminderModel) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                    .setReminderType(t.getNewValue());

            System.out.println("*******" + t.getNewValue());
            ReminderModel selectedItem = (ReminderModel) reminderTable.getSelectionModel().getSelectedItem();
            System.out.println(selectedItem);
            String rIdToUpdate = selectedItem.getReminderId();
            Statement stmt = null;
            DbConnection db = new DbConnection();
            Connection conn = db.connect();

            try {
                stmt = conn.createStatement();

                String updateSql = "UPDATE Reminders set ReminderType = '" + t.getNewValue() + "'"
                        + "WHERE RId = '" + rIdToUpdate + "'";

                stmt.executeUpdate(updateSql);
            } catch (SQLException ex) {
                Logger.getLogger(SetReminderController.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

    });

    //For reminderTime Column Update

    reminderTimeCol.setCellValueFactory(new PropertyValueFactory<>("reminderTime"));
    reminderTimeCol.setCellFactory(cellFactory);
    reminderTimeCol.setOnEditCommit(new EventHandler<CellEditEvent<ReminderModel, String>>() {

        @Override
        public void handle(CellEditEvent<ReminderModel, String> t) {
            ((ReminderModel) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                    .setReminderTime(t.getNewValue());

            System.out.println("*******" + t.getNewValue());
            ReminderModel selectedItem = (ReminderModel) reminderTable.getSelectionModel().getSelectedItem();
            System.out.println(selectedItem);
            String rIdToUpdate = selectedItem.getReminderId();
            Statement stmt = null;
            DbConnection db = new DbConnection();
            Connection conn = db.connect();

            try {
                stmt = conn.createStatement();

                String updateSql = "UPDATE Reminders set ReminderTime = '" + t.getNewValue() + "'"
                        + "WHERE RId = '" + rIdToUpdate + "'";

                stmt.executeUpdate(updateSql);
            } catch (SQLException ex) {
                Logger.getLogger(SetReminderController.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

    });

    reminderTable.setItems(data);

}