Example usage for javafx.collections ObservableList addAll

List of usage examples for javafx.collections ObservableList addAll

Introduction

In this page you can find the example usage for javafx.collections ObservableList addAll.

Prototype

public boolean addAll(E... elements);

Source Link

Document

A convenience method for var-arg addition of elements.

Usage

From source file:herudi.controller.productController.java

private void displayManufacturer() {
    Service<ObservableList<Manufacturer>> service = new Service<ObservableList<Manufacturer>>() {
        @Override//from w  w w.ja  v  a 2 s  .  c o  m
        protected Task<ObservableList<Manufacturer>> createTask() {
            return new Task<ObservableList<Manufacturer>>() {
                @Override
                protected ObservableList<Manufacturer> call() throws Exception {
                    ObservableList<Manufacturer> listTask = FXCollections.observableArrayList();
                    if (listTask == null) {
                        listTask = FXCollections.observableArrayList(crud.selectManufacturerID());
                    } else {
                        listTask.clear();
                        listTask.addAll(crud.selectManufacturerID());
                    }
                    cbManufacturer.setItems(listTask);
                    return listTask;
                }
            };
        }
    };
    service.start();
}

From source file:pl.betoncraft.betonquest.editor.model.QuestPackage.java

/**
 * @return all NpcOptions from loaded conversations in this package, the ones from current conversation first
 *///from   w  w  w . j a  v  a  2 s  . c o  m
public ObservableList<NpcOption> getAllNpcOptions() {
    ObservableList<NpcOption> list = FXCollections.observableArrayList();
    list.addAll(ConversationController.getDisplayedConversation().getNpcOptions());
    conversations.forEach(conv -> {
        if (!conv.equals(ConversationController.getDisplayedConversation())) {
            list.addAll(conv.getNpcOptions());
        }
    });
    return list;
}

From source file:pl.betoncraft.betonquest.editor.model.QuestPackage.java

/**
 * @return all PlayerOptions from loaded conversations in this package, the ones from current conversation first
 *//*from  w w  w.  j  a v a2  s. c  o  m*/
public ObservableList<PlayerOption> getAllPlayerOptions() {
    ObservableList<PlayerOption> list = FXCollections.observableArrayList();
    list.addAll(ConversationController.getDisplayedConversation().getPlayerOptions());
    conversations.forEach(conv -> {
        if (!conv.equals(ConversationController.getDisplayedConversation())) {
            list.addAll(conv.getPlayerOptions());
        }
    });
    return list;
}

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);//from  w  ww .ja  va2  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:com.ggvaidya.scinames.ui.DatasetDiffController.java

private ObservableList<String> getComparisonStatRowHeaders() {
    ObservableList<String> rowHeader = FXCollections.observableArrayList();

    rowHeader.add("Number of rows");
    rowHeader.add("Number of columns");
    rowHeader.add("Number of names recognized");
    rowHeader.add("Number of names in rows");
    rowHeader.add("Number of binomial names recognized");
    rowHeader.add("Number of binomial names in rows");
    rowHeader.add("Number of changes");

    Project project = datasetDiffView.getProjectView().getProject();
    rowHeader.addAll(project.getChanges().map(ch -> ch.getType()).distinct().sorted()
            .map(type -> "Number of changes of type '" + type.getType() + "'").collect(Collectors.toList()));

    return rowHeader;
}

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

public ObservableList<StreamFile> getStreamList() {
    ObservableList<StreamFile> list = FXCollections.observableArrayList();
    try {//w  w  w .ja  v a  2 s  .c  o  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:condorclient.CreateJobDialogController.java

@FXML
private void runJobFired(ActionEvent event) {

    nrun = Integer.parseInt(sampleNumText.getText().trim());
    if (nrun == 0) {
        return;//from  ww w .j  a  v  a  2  s .  c  o m
    }
    int eachrun = 0;

    // System.out.println("map:" + map.toString());
    ObservableList<String> slotname = FXCollections.observableArrayList();
    XMLHandler handler = new XMLHandler();
    if (allocMthod == 0) {//slot?

        if (!slotNumIsOk()) {
            return;
        }
        int i = 0;
        for (String s : map.keySet()) {
            if (i >= useslotnum) {
                break;
            }
            i = i + map.get(s).size();
            if (i <= useslotnum) {//?

                slotname.addAll(map.get(s));
            } else {
                i = i - map.get(s).size();
                for (String rest : map.get(s)) {
                    if (i >= useslotnum) {
                        break;
                    }
                    slotname.add(rest);
                    i++;
                }
            }
        } //slotname
          //??
          // System.out.println("allocMthod:" + allocMthod + "useslotnum:" + useslotnum + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 1) {//?
        //  
        if (!nodeNumInputIsOk()) {//???
            return;
        }
        int i = 0;
        for (String s : map.keySet()) {
            if (i >= usenodenum) {
                break;
            }
            i++;
            if (slotname.size() + map.get(s).size() <= nrun) {
                slotname.addAll(map.get(s));
            } else if (slotname.size() < nrun) {//??ip?
                for (String rs : map.get(s)) {

                    slotname.add(rs);
                    if (slotname.size() == nrun) {
                        break;
                    }
                }
                break;
            }
        }
        //System.out.println("allocMthod:" + allocMthod + "usenodenum:" + usenodenum + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 2) {//?
        int i = 0;
        for (String s : apponitmap.keySet()) {
            // slotname.addAll(map.get(s));//apponitmap?keylist
            if (i >= nrun) {
                break;
            }
            i++;
            //s
            if (slotname.size() + map.get(s).size() <= nrun) {
                slotname.addAll(map.get(s));
            } else if (slotname.size() < nrun) {//??machine?slot
                for (String rs : map.get(s)) {
                    slotname.add(rs);
                    if (slotname.size() == nrun) {
                        break;
                    }
                }
                break;
            }
        }
        if (slotname.size() == 0) {
            //System.out.println("+++++"+otherError.getText());
            otherError.setText("?");
            return;
        }

        //System.out.println("allocMthod:" + allocMthod + "zhi ding ge shu:" + apponitmap.keySet().size() + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 3) {//????????
        int aptNum = 0;
        if (slotNum <= nrun) {//??
            aptNum = slotNum;
        } else {
            aptNum = nrun;
        }
        for (int i = 0; i < aptNum; i++) {//slotNum
            slotname.add("");
        }
    }
    eachrun = nrun / slotname.size();
    int restrun = nrun - eachrun * slotname.size();//?slot
    //System.out.println("eachrun" + eachrun + "restrun" + restrun);

    URL url = null;

    String scheddStr = handler.getURL("schedd");
    try {

        url = new URL(scheddStr);
    } catch (MalformedURLException e3) {
        // TODO Auto-generated catch block
        e3.printStackTrace();
    }
    Schedd schedd = null;
    try {
        schedd = new Schedd(url);
    } catch (ServiceException e2) {
    }

    int j = 0;
    //
    String timestamp = (new SimpleDateFormat("yyyyMMddHHmmss")).format(new Date());
    String resultdirstr = resultFileText.getText().trim() + "\\" + jobNameText.getText().trim() + "\\"
            + timestamp;
    System.out.println(resultdirstr);
    try {
        FileUtils.forceMkdir(new File(resultdirstr));
    } catch (IOException ex) {
        Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
    }

    System.out.println(timestamp);
    //?
    File infoFile = new File(infoFileText.getText().trim());
    File expFile = new File(expFileText.getText().trim());

    File[] transfiles = { infoFile, expFile };

    Transaction xact = schedd.createTransaction();
    try {
        xact.begin(30);

    } catch (RemoteException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    int clusterId = 0;
    try {
        clusterId = xact.createCluster();

    } catch (RemoteException e) {
    }
    for (String name : slotname) {//3slot??
        j++;
        int jobId = 0;
        try {
            jobId = xact.createJob(clusterId);
        } catch (RemoteException e) {
        }
        String jobdirstr = resultdirstr + "\\" + jobId;
        File jobdir = new File(jobdirstr);
        try {
            FileUtils.forceMkdir(jobdir);//?job
        } catch (IOException ex) {
            Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
        }
        //??job
        /*  for (File f : transfiles) {
           try {
           FileUtils.copyFileToDirectory(f, jobdir);
           } catch (IOException ex) {
           Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
           }
                
           }*/

        if (j == slotname.size()) {
            eachrun = eachrun + restrun;
        }
        String eachrunstr = "" + eachrun;

        String argumentsStr = infoFile.getName() + " " + expFile.getName() + " " + eachrunstr;// null;//".exl .ixl nrun"
        String requirementsStr = "Name==\"" + name + "\"";//Name=slot1@Lenovo-PC;String req="Name==\"slot1@Lenovo-PC\"";
        if (name.equals("")) {
            requirementsStr = null;//??
        }
        System.out.println("requirementsStr:" + requirementsStr + "eachrunstr:" + eachrunstr);

        ClassAdStructAttr[] attributes = null;// {new ClassAdStructAttr()};

        // ClassAdStructAttr attribute =new ClassAdStructAttr("WhenToTransferOutput",ClassAdAttrType.value3,"ON_EXIT_OR_EVICT");
        //  attributes[0] = new ClassAdStructAttr("Iwd", ClassAdAttrType.value3, jobdirstr);
        // attributes[1] = new ClassAdStructAttr("JobLeaseDuration", ClassAdAttrType.value1,"1200");
        String commandStr = handler.getexecutableFile();//?

        try {
            xact.submit(clusterId, jobId, "htcondor", UniverseType.VANILLA, commandStr, argumentsStr,
                    requirementsStr, attributes, transfiles);

        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
    try {
        xact.commit();
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        schedd.requestReschedule();//
    } catch (RemoteException ex) {
        Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
    }
    String jobName = jobNameText.getText();
    handler.addJob(jobName, "" + clusterId, resultdirstr, expFileText.getText().trim(),
            infoFileText.getText().trim());//jobItem

    exeCreate = 1;
    stage.close();

}

From source file:condorclient.CreateJobDialogController.java

@FXML
private void saveJobFired(ActionEvent event) {

    nrun = Integer.parseInt(sampleNumText.getText().trim());
    if (nrun == 0) {
        return;/*  www  . j av  a  2  s. co m*/
    }
    int eachrun = 0;

    // System.out.println("map:" + map.toString());
    ObservableList<String> slotname = FXCollections.observableArrayList();
    XMLHandler handler = new XMLHandler();
    if (allocMthod == 0) {//slot?

        if (!slotNumIsOk()) {
            return;
        }

        int i = 0;
        for (String s : map.keySet()) {
            if (i >= useslotnum) {
                break;
            }

            i = i + map.get(s).size();
            if (i <= useslotnum) {//?

                slotname.addAll(map.get(s));
            } else {
                i = i - map.get(s).size();
                for (String rest : map.get(s)) {
                    if (i >= useslotnum) {
                        break;
                    }
                    slotname.add(rest);
                    i++;
                }
            }
        } //slotname
          //??
          // System.out.println("allocMthod:" + allocMthod + "useslotnum:" + useslotnum + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 1) {//?
        if (!nodeNumInputIsOk()) {
            return;
        }
        int i = 0;
        for (String s : map.keySet()) {
            if (i >= usenodenum) {
                break;
            }
            i++;
            //s
            if (slotname.size() + map.get(s).size() <= nrun) {
                slotname.addAll(map.get(s));
            } else if (slotname.size() < nrun) {//??ip?
                for (String rs : map.get(s)) {
                    slotname.add(rs);
                    if (slotname.size() == nrun) {
                        break;
                    }
                }
                break;
            }

        }

        //System.out.println("allocMthod:" + allocMthod + "usenodenum:" + usenodenum + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 2) {//?
        int i = 0;
        for (String s : apponitmap.keySet()) {
            // slotname.addAll(map.get(s));//apponitmap?keylist  
            ///eee
            if (i >= nrun) {
                break;
            }
            i++;
            //s
            if (slotname.size() + map.get(s).size() <= nrun) {
                slotname.addAll(map.get(s));
            } else if (slotname.size() < nrun) {//??machine?slot
                for (String rs : map.get(s)) {
                    slotname.add(rs);
                    if (slotname.size() == nrun) {
                        break;
                    }
                }
                break;
            }
            ///eee
        }
        if (slotname.size() == 0) {
            // System.out.println("+++++"+otherError.getText());
            otherError.setText("?");
            return;
        }

        //System.out.println("allocMthod:" + allocMthod + "zhi ding ge shu:" + apponitmap.keySet().size() + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 3) {//??
        //e
        int aptNum = 0;
        if (slotNum <= nrun) {//??
            aptNum = slotNum;
        } else {
            aptNum = nrun;
        }
        for (int i = 0; i < aptNum; i++) {//slotNum
            slotname.add("");
        }
        //e
    }
    eachrun = nrun / slotname.size();
    int restrun = nrun - eachrun * slotname.size();//?slot
    //System.out.println("eachrun" + eachrun + "restrun" + restrun);
    URL url = null;

    String scheddStr = handler.getURL("schedd");

    try {
        url = new URL(scheddStr);
        // url = new URL("http://localhost:9628");
    } catch (MalformedURLException e3) {
        // TODO Auto-generated catch block
        e3.printStackTrace();
    }
    Schedd schedd = null;
    try {
        schedd = new Schedd(url);
    } catch (ServiceException e2) {
    }
    //s
    String timestamp = (new SimpleDateFormat("yyyyMMddHHmmss")).format(new Date());
    String resultdirstr = resultFileText.getText().trim() + "\\" + jobNameText.getText().trim() + "\\"
            + timestamp;
    System.out.println(resultdirstr);
    try {
        FileUtils.forceMkdir(new File(resultdirstr));
    } catch (IOException ex) {
        Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
    }

    System.out.println(timestamp);
    //?
    File infoFile = new File(infoFileText.getText().trim());
    File expFile = new File(expFileText.getText().trim());
    // File testFile = new File("D:\\HTCondor\\test\\2\\inputfile.txt");
    File[] transfiles = { infoFile, expFile };

    //e
    Transaction xact = schedd.createTransaction();
    try {

        if (xact != null) {
            xact.begin(3000);
        }
    } catch (RemoteException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    int clusterId = 0;
    try {
        clusterId = xact.createCluster();

    } catch (RemoteException e) {
    }
    int j = 0;
    for (String name : slotname) {//3slot??
        j++;
        int jobId = 0;
        try {
            jobId = xact.createJob(clusterId);
        } catch (RemoteException e) {
        }
        //s
        String jobdirstr = resultdirstr + "\\" + jobId;

        File jobdir = new File(jobdirstr);
        try {
            FileUtils.forceMkdir(jobdir);//?job
        } catch (IOException ex) {
            Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
        }
        //??job
        /* for (File f : transfiles) {
          try {
          FileUtils.copyFileToDirectory(f, jobdir);
          } catch (IOException ex) {
          Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
          }
                
          }*/
        //e
        if (j == slotname.size()) {
            eachrun = eachrun + restrun;
        }
        String eachrunstr = "" + eachrun;

        String argumentsStr = infoFile.getName() + " " + expFile.getName() + " " + eachrunstr;// "" + eachrunstr;// null;//".exl .ixl nrun"
        String requirementsStr = "Name==\"" + name + "\"";//Name=slot1@Lenovo-PC;String req="Name==\"slot1@Lenovo-PC\"";

        if (name.equals("")) {
            requirementsStr = null;//??
        }
        ClassAdStructAttr[] attributes = null;// {new ClassAdStructAttr()};
        // ClassAdStructAttr attribute =new ClassAdStructAttr("WhenToTransferOutput",ClassAdAttrType.value3,"ON_EXIT_OR_EVICT");
        //attributes[0] = new ClassAdStructAttr("Iwd", ClassAdAttrType.value3, jobdirstr);
        //JobLeaseDuration
        //            attributes[1] = new ClassAdStructAttr("JobLeaseDuration", ClassAdAttrType.value1,"1200");
        String commandStr = handler.getexecutableFile();//?

        try {
            xact.submit(clusterId, jobId, "htcondor", UniverseType.VANILLA, commandStr, argumentsStr,
                    requirementsStr, attributes, transfiles);

        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            xact.holdJob(clusterId, jobId, "");//
        } catch (RemoteException ex) {
            Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    try {
        xact.commit();
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String jobName = jobNameText.getText();
    handler.addJob(jobName, "" + clusterId, resultdirstr, expFileText.getText().trim(),
            infoFileText.getText().trim());

    // System.out.print("createTransaction succeed haha!!\n");
    exeCreate = 1;
    stage.close();

}