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

public void setJavaFXDataCollection(Collection<ICFBamDelSubDep2Obj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//from   www . j  a v a  2 s.c o  m
    observableListOfDelSubDep2 = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamDelSubDep2Obj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfDelSubDep2.add(iter.next());
        }
        observableListOfDelSubDep2.sort(compareDelSubDep2ByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfDelSubDep2);
        // 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.CFBamJavaFXDelSubDep3ListPane.java

public void setJavaFXDataCollection(Collection<ICFBamDelSubDep3Obj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//from w ww.j  ava 2 s .  co  m
    observableListOfDelSubDep3 = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamDelSubDep3Obj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfDelSubDep3.add(iter.next());
        }
        observableListOfDelSubDep3.sort(compareDelSubDep3ByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfDelSubDep3);
        // 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.CFBamJavaFXPopSubDep2ListPane.java

public void setJavaFXDataCollection(Collection<ICFBamPopSubDep2Obj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//from w w  w .  j  a  va 2  s .  c o m
    observableListOfPopSubDep2 = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamPopSubDep2Obj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfPopSubDep2.add(iter.next());
        }
        observableListOfPopSubDep2.sort(comparePopSubDep2ByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfPopSubDep2);
        // 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.CFBamJavaFXPopSubDep3ListPane.java

public void setJavaFXDataCollection(Collection<ICFBamPopSubDep3Obj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;/*from   w  w  w .j av  a  2  s.  com*/
    observableListOfPopSubDep3 = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamPopSubDep3Obj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfPopSubDep3.add(iter.next());
        }
        observableListOfPopSubDep3.sort(comparePopSubDep3ByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfPopSubDep3);
        // 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

@FXML
void initialize() {
    assert IntervalsTextField != null : "fx:id=\"IntervalsTextField\" was not injected: check your FXML file 'symchords.fxml'.";
    assert baseOctaveCombo != null : "fx:id=\"baseOctaveCombo\" was not injected: check your FXML file 'symchords.fxml'.";
    assert basePitchCombo != null : "fx:id=\"basePitchCombo\" was not injected: check your FXML file 'symchords.fxml'.";
    assert octavesSlider != null : "fx:id=\"octavesSlider\" was not injected: check your FXML file 'symchords.fxml'.";
    assert patternTextField != null : "fx:id=\"patternTextField\" was not injected: check your FXML file 'symchords.fxml'.";
    assert relationshipGroup != null : "fx:id=\"relationshipGroup\" was not injected: check your FXML file 'symchords.fxml'.";
    assert relativeRadio != null : "fx:id=\"relativeRadio\" was not injected: check your FXML file 'symchords.fxml'.";
    assert unitSlider != null : "fx:id=\"unitSlider\" was not injected: check your FXML file 'symchords.fxml'.";

    grandStaff.setFontSize(24d);/*from ww w .jav a  2  s. com*/
    grandStaff.drawShapes();
    patternStaff.setFontSize(24d);
    patternStaff.drawShapes();

    baseOctaveCombo.getSelectionModel().select(5);
    basePitchCombo.getSelectionModel().select(0);

    pitchProperty.bindBidirectional(pitchSlider.valueProperty());

    // sliderText.setText(Math.round(pitchSlider.getValue()) + "");
    PitchFormat.getInstance().setWidth(4);
    sliderText.setText(PitchFormat.getInstance().format((int) pitchSlider.getValue()));
    pitchSlider.valueProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number oldValue,
                Number newValue) {
            if (newValue == null) {
                sliderText.setText("");
                return;
            }
            basePitchCombo.setValue(PitchFormat.getPitchString(newValue.intValue()));
            baseOctaveCombo.setValue("" + newValue.intValue() / 12);
            sliderText.setText(PitchFormat.getInstance().format(newValue.intValue()));

            // sliderText.setText(Math.round(newValue.intValue()) + "");
        }
    });

    basePitchCombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue) {

            int pitch = PitchFactory.getPitch(newValue + "0").getMidiNumber();
            int oct = Integer.parseInt(baseOctaveCombo.getSelectionModel().getSelectedItem());
            pitchProperty.set(pitch + (oct * 12));
        }
    });
    baseOctaveCombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue) {
            int oct = Integer.parseInt(newValue);
            int pitch = PitchFactory.getPitch(basePitchCombo.getSelectionModel().getSelectedItem() + "0")
                    .getMidiNumber();
            pitchProperty.set(pitch + (oct * 12));
        }
    });

    // java 8
    // basePitchCombo.getSelectionModel().selectedItemProperty().addListener(
    // (ObservableValue<? extends String> ov, String oldValue, String
    // newValue) -> {
    // int pitch = Integer.parseInt(newValue);
    // int oct =
    // Integer.parseInt(baseOctaveCombo.getSelectionModel().getSelectedItem());
    // pitchProperty.set(pitch + oct);
    // });
    // baseOctaveCombo.getSelectionModel().selectedItemProperty().addListener(
    // (ObservableValue<? extends String> ov, String oldValue, String
    // newValue) -> {
    // int oct = Integer.parseInt(newValue);
    // int pitch =
    // Integer.parseInt(basePitchCombo.getSelectionModel().getSelectedItem());
    // pitchProperty.set(pitch + oct);
    // });

    model = new SymModel();

    model.absoluteProperty().bind(this.absoluteRadio.selectedProperty());
    // model.relativeProperty().bind(this.relativeRadio.selectedProperty());
    model.basePitchProperty().bind(this.pitchProperty);
    model.nOctavesProperty().bind(this.octavesSlider.valueProperty());
    model.unitProperty().bind(this.unitSlider.valueProperty());

    // set up initial value
    ObservableList<Integer> ol = FXCollections.observableArrayList();
    ol.add(1);
    setIntervals(ol);
    // now handle input. turn the string into an array.
    this.IntervalsTextField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue) {
            String[] a = newValue.split("\\s+");
            ObservableList<Integer> ol = FXCollections.observableArrayList();
            for (final String ss : a) {
                ol.add(Integer.parseInt(ss));
            }
            setIntervals(ol);
        }
    });
    model.intervalsProperty().bind(this.intervalsProperty);

    this.resetPattern();

    this.patternTextField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue) {
            logger.debug("new value '{}'", newValue);
            newValue = newValue.replaceAll("\\{", "");
            newValue = newValue.replaceAll("\\}", "");
            newValue = newValue.replaceAll(",", " ");
            logger.debug("new value '{}'", newValue);

            String[] a = newValue.split("\\s+");
            ObservableList<Integer> ol = FXCollections.observableArrayList();
            for (final String ss : a) {
                ol.add(Integer.parseInt(ss));
            }
            // setIntervals(ol);
        }
    });

    patternListView.setCellFactory(new Callback<ListView<int[]>, ListCell<int[]>>() {
        @Override
        public ListCell<int[]> call(ListView<int[]> list) {
            return new PatternListCell();
        }
    });
    updatePatternList();

    patternListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<int[]>() {
        @Override
        public void changed(ObservableValue<? extends int[]> observable, int[] oldValue, int[] newValue) {
            pattern = newValue;
            patternCalculate();
            patternTextField.setText(ArrayUtils.toString(pattern));
        }
    });

    setupDragonDrop();

    trackList.setCellFactory(new Callback<ListView<MIDITrack>, ListCell<MIDITrack>>() {
        @Override
        public ListCell<MIDITrack> call(ListView<MIDITrack> list) {
            return new TrackListCell();
        }
    });
    trackList.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<MIDITrack>() {

        @Override
        public void changed(ObservableValue<? extends MIDITrack> observable, MIDITrack oldValue,
                MIDITrack newValue) {

            model.setMIDITrack(newValue);

            // SymParams params = model.getParamsForTrack(newValue);
            SymParams params = (SymParams) newValue.getUserData();
            logger.debug("params {}", params);
            if (params != null) {
                int pitch = params.getBasePitch() % 12;
                String ps = PitchFormat.getPitchString(pitch);
                basePitchCombo.setValue(ps);

                String oct = "" + params.getBasePitch() / 12;
                baseOctaveCombo.setValue(oct);

                String intervals = ListUtils.asIntString(params.getIntervals());
                IntervalsTextField.setText(intervals);

                octavesSlider.setValue(params.getnOctaves());
                unitSlider.setValue(params.getUnit());
                relativeRadio.setSelected(params.isRelative());
                absoluteRadio.setSelected(!params.isRelative());

            }
        }
    });

    model.midiTrackProperty().addListener(new ChangeListener<MIDITrack>() {
        @Override
        public void changed(ObservableValue<? extends MIDITrack> arg0, MIDITrack arg1, MIDITrack newTrack) {

            if (durationModifierCB.isSelected()) {
                modifierValuesTextField.setText(MIDITrack.getDurationsAsString(newTrack));
            }
            if (pitchModifierCB.isSelected()) {
                modifierValuesTextField.setText(MIDITrack.getPitchesMIDINumbersAsString(newTrack));
            }
            if (startBeatModifierCB.isSelected()) {
                modifierValuesTextField.setText(MIDITrack.getStartBeatsAsString(newTrack));
            }

            logger.debug("midi track property changed {}", newTrack);
            grandStaff.setTrack(newTrack);
            grandStaff.drawShapes();
        }
    });

}

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

public void setJavaFXDataCollection(Collection<ICFBamDelTopDepObj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;/*from   w  w w  .j  av a  2 s.  co  m*/
    observableListOfDelTopDep = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        if (javafxSortByChain) {
            Iterator<ICFBamDelTopDepObj> iter = javafxDataCollection.iterator();
            ICFBamDelTopDepObj 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");
            }
            ICFBamDelTopDepObj cur = head;
            while (cur != null) {
                observableListOfDelTopDep.add(cur);
                cur = cur.getOptionalLookupNext();
            }
        } else {
            Iterator<ICFBamDelTopDepObj> iter = javafxDataCollection.iterator();
            while (iter.hasNext()) {
                observableListOfDelTopDep.add(iter.next());
            }
            observableListOfDelTopDep.sort(compareDelTopDepByQualName);
        }
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfDelTopDep);
        // 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.CreateJobDialogController.java

@FXML
private void saveJobFired(ActionEvent event) {

    nrun = Integer.parseInt(sampleNumText.getText().trim());
    if (nrun == 0) {
        return;/*from  ww w .  jav a2 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++;
            //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();

}

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

public void setJavaFXDataCollection(Collection<ICFBamClearSubDep1Obj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;//from   w ww .  j  a  va 2  s. com
    observableListOfClearSubDep1 = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamClearSubDep1Obj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfClearSubDep1.add(iter.next());
        }
        observableListOfClearSubDep1.sort(compareClearSubDep1ByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfClearSubDep1);
        // 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.CFBamJavaFXClearSubDep2ListPane.java

public void setJavaFXDataCollection(Collection<ICFBamClearSubDep2Obj> value) {
    final String S_ProcName = "setJavaFXDataCollection";
    javafxDataCollection = value;// w  ww.  j  av  a  2s.c om
    observableListOfClearSubDep2 = FXCollections.observableArrayList();
    if (javafxDataCollection != null) {
        Iterator<ICFBamClearSubDep2Obj> iter = javafxDataCollection.iterator();
        while (iter.hasNext()) {
            observableListOfClearSubDep2.add(iter.next());
        }
        observableListOfClearSubDep2.sort(compareClearSubDep2ByQualName);
    }
    if (dataTable != null) {
        dataTable.setItems(observableListOfClearSubDep2);
        // Hack from stackoverflow to fix JavaFX TableView refresh issue
        ((TableColumn) dataTable.getColumns().get(0)).setVisible(false);
        ((TableColumn) dataTable.getColumns().get(0)).setVisible(true);
    }
}