java类javafx.collections.ObservableList的实例源码

CollatedTreeItem.java 文件源码 项目:marathonv5 阅读 16 收藏 0 点赞 0 评论 0
public CollatedTreeItem() {
    children = FXCollections.observableArrayList();
    filteredChildren = new FilteredList<>(children, new Predicate<TreeItem<T>>() {
        @Override public boolean test(TreeItem<T> t) {
            return filter.test(t.getValue());
        }
    });
    sortedChildren = new SortedList<>(filteredChildren);
    ObservableList<TreeItem<T>> original = super.getChildren();
    sortedChildren.addListener(new ListChangeListener<TreeItem<T>>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<T>> c) {
            while (c.next()) {
                original.removeAll(c.getRemoved());
                original.addAll(c.getFrom(), c.getAddedSubList());
            }
        }
    });
}
MainWindowController.java 文件源码 项目:dialog-tool 阅读 21 收藏 0 点赞 0 评论 0
protected void refreshListView () {

        this.questionList.getItems().clear();

        //create list with all questions
        ObservableList<String> questions = FXCollections.observableArrayList();

        //iterate through all questions
        for (Map.Entry<String,QuestionEntry> entry : this.questionMap.entrySet()) {
            //add question name to list
            questions.add(entry.getKey());
        }

        Collections.sort(questions);

        if (questions.size() <= 0) {
            //hide delete button
            this.deleteButton.setVisible(false);
        } else {
            //show delete button
            this.deleteButton.setVisible(true);
        }

        this.questionList.setItems(questions);
    }
SpriteCreationScreen.java 文件源码 项目:voogasalad-ltub 阅读 13 收藏 0 点赞 0 评论 0
private ComponentSelectorPane instantiateSelector() {
    List<Class<? extends Component>> basicComponents = new ArrayList<>();
    ObservableList<Class<? extends Component>> observableComponents = FXCollections.observableList(basicComponents);
    observableComponents.add(Cost.class);
    observableComponents.add(Attacker.class);
    observableComponents.add(Collidable.class);
    observableComponents.add(Health.class);
    observableComponents.add(Images.class);
    observableComponents.add(Owner.class);
    observableComponents.add(PathFollower.class);
    observableComponents.add(Range.class);
    observableComponents.add(RangeShootingAI.class);
    observableComponents.add(Selectable.class);
    observableComponents.add(SoundEffect.class);
    observableComponents.add(Speed.class);
    observableComponents.add(SkillSet.class);
    observableComponents.add(TowerDefenceTypeInformation.class);
    observableComponents.add(Upgrade.class);

    return new ComponentSelectorPane(myResources.getString("addComponents"), observableComponents, infoPane);
}
SalesStatusController.java 文件源码 项目:CNU_TermProject_SoftwareEngineering 阅读 106 收藏 0 点赞 0 评论 0
public ObservableList<TableRowDataModel> convertPaymentArrayListToObservableList(ArrayList Payments) {
    ObservableList<TableRowDataModel> tempList = FXCollections.observableArrayList();
    for (Object dateAndPrice : Payments) {
        String oldstring = (String) ((Pair) dateAndPrice).getKey();
        try {
            Date old = new SimpleDateFormat("yyyy-MM-dd").parse(oldstring);
            String newstring = new SimpleDateFormat("yyyy년MM월dd일").format(old);

        SimpleStringProperty date = new SimpleStringProperty(newstring);
        int price = (int) ((Pair) dateAndPrice).getValue();
        tempList.add(new TableRowDataModel(date, new SimpleStringProperty(price + "원")));
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    return tempList;
}
LayerBaseTreeCell.java 文件源码 项目:keyboard-light-composer 阅读 15 收藏 0 点赞 0 评论 0
private void droppedOnTreeItem(DragEvent event,
        TreeItem<LayerBaseContainer<? extends LayerBase>> currentlyDraggedLayerTreeItem,
        LayerBaseContainer<? extends LayerBase> targetItem) {
    LayerBase targetLayer = targetItem.getLayerBase();

    double y = event.getY();
    double height = getHeight();
    boolean above = y < height / 2;

    TreeItem<LayerBaseContainer<? extends LayerBase>> targetParent = this.getTreeItem().getParent();
    ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> targetParentChildren = targetParent
            .getChildren();

    TreeItem<LayerBaseContainer<? extends LayerBase>> draggedItem = currentlyDraggedLayerTreeItem;
    TreeItem<LayerBaseContainer<? extends LayerBase>> draggedParent = draggedItem.getParent();
    ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> draggedParentChildren = draggedParent != null
            ? draggedParent.getChildren() : null;

    if (targetLayer instanceof EffectGroupLayer && (y >= height / 4 && y < height * 3 / 4)) {
        // inside group
        ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> groupChildren = getTreeItem()
                .getChildren();
        if (!groupChildren.equals(draggedParentChildren)) {
            if (draggedParentChildren != null) {
                draggedParentChildren.remove(draggedItem);
            }
            DelayedExecuter.execute(100, () -> groupChildren.add(0, draggedItem));
        }
    } else {
        if (draggedParentChildren != null) {
            ListItemUtil.swapItemsJavaFxThread(draggedParentChildren, targetParentChildren, draggedItem, this.getTreeItem(),
                    above);
        } else {
            ListItemUtil.insertItem(targetParentChildren, draggedItem, this.getTreeItem(), above);
        }
    }
}
VirtualResourceTree.java 文件源码 项目:jmonkeybuilder 阅读 13 收藏 0 点赞 0 评论 0
/**
 * Fill the tree item.
 *
 * @param item the tree item.
 */
@FXThread
private void fill(@NotNull final TreeItem<VirtualResourceElement<?>> item) {

    final VirtualResourceElement<?> element = item.getValue();
    if(!element.hasChildren()) {
        return;
    }

    final ObservableList<TreeItem<VirtualResourceElement<?>>> items = item.getChildren();

    final Array<VirtualResourceElement<?>> children = element.getChildren();
    children.sort(NAME_COMPARATOR);
    children.forEach(child -> items.add(new TreeItem<>(child)));

    items.forEach(this::fill);
}
CustomTreeItem.java 文件源码 项目:Coconut-IDE 阅读 22 收藏 0 点赞 0 评论 0
@SneakyThrows(IOException.class)
private ObservableList<TreeItem<Path>> buildChildren() {
    if (Files.isDirectory(getValue())) {
        return Files.list(getValue())
                .map(e -> {
                    WatcherStructure watcherStructure = null;
                    if (Files.isDirectory(e)) {
                        watcherStructure = new WatcherStructure(e, project, tabUpdater, treeUpdater);
                    }

                    CustomTreeItem item = new CustomTreeItem(e, watcherStructure, project, tabUpdater, treeUpdater);

                    CustomIcons customIcons = new CustomIcons();
                    item.setGraphic(new ImageView(item.isDirectory() ? customIcons.getFolderCollapseImage() : customIcons.getFileImage()));
                    if (isDirectory()) {
                        item.expandedProperty().addListener(treeUpdater.expanderListener());
                    }

                    return item;
                })
                .collect(Collectors.toCollection(FXCollections::observableArrayList));
    }

    return FXCollections.emptyObservableList();
}
SpatialTreeNode.java 文件源码 项目:jmonkeybuilder 阅读 24 收藏 0 点赞 0 评论 0
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
                            @NotNull final ObservableList<MenuItem> items) {
    if (!(nodeTree instanceof ModelNodeTree)) return;

    final T element = getElement();
    final AssetLinkNode linkNode = findParent(element, AssetLinkNode.class::isInstance);

    if (linkNode == null) {
        final Menu createMenu = createCreationMenu(nodeTree);
        if (createMenu != null) items.add(createMenu);
        final Menu toolMenu = createToolMenu(nodeTree);
        if (toolMenu != null) items.add(toolMenu);
    }

    if (linkNode == null || element == linkNode) {
        items.add(new AddUserDataAction(nodeTree, this));
    }

    if (canRemove()) {
        items.add(new RemoveNodeAction(nodeTree, this));
    }

    super.fillContextMenu(nodeTree, items);
}
ZoomManager.java 文件源码 项目:Java-oscilloscope-project 阅读 19 收藏 0 点赞 0 评论 0
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
        final Collection<? extends XYChart.Data<X, Y>> data) {
    final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
    for (final Data<X, Y> i : data) {
        result.add(new Data<>(i.getXValue(), i.getYValue()));
    }
    return result;
}
ModalDialog.java 文件源码 项目:marathonv5 阅读 25 收藏 0 点赞 0 评论 0
private ObservableList<Node> getChildren(Node node) {
    if (node instanceof ButtonBar) {
        return ((ButtonBar) node).getButtons();
    }
    if (node instanceof ToolBar) {
        return ((ToolBar) node).getItems();
    }
    if (node instanceof Pane) {
        return ((Pane) node).getChildren();
    }
    if (node instanceof TabPane) {
        ObservableList<Node> contents = FXCollections.observableArrayList();
        ObservableList<Tab> tabs = ((TabPane) node).getTabs();
        for (Tab tab : tabs) {
            contents.add(tab.getContent());
        }
        return contents;
    }
    return FXCollections.observableArrayList();
}
PathSetter.java 文件源码 项目:voogasalad-ltub 阅读 19 收藏 0 点赞 0 评论 0
public PathSetter(ObservableList<Path> paths, String variableName){
    super(Path.class,variableName);
    this.myPaths=paths;     

    pathChoices= new ComboBox<>(myPaths);

    pathChoices.setCellFactory(new Callback<ListView<Path>, ListCell<Path>>(){
        @Override
        public ListCell<Path> call(ListView<Path> list){
            return new PathCell();
        }
    });
    pathChoices.setButtonCell(new PathButtonCell());

    this.getChildren().add(pathChoices);

}
SetAction.java 文件源码 项目:MythRedisClient 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 装载面板数据.
 *
 * @param key 数据库中的键
 */
@Override
public void setValue(String key) {
    ObservableList<TableEntity> values = FXCollections.observableArrayList();
    Set<String> sets = redisSet.getMembersSet(key);
    int i = 0;
    for (String set : sets) {
        TableEntity value = new TableEntity("" + i, key, set);
        values.add(value);
        i++;
    }
    this.dataTable.setItems(values);
    this.rowColumn.setCellValueFactory(cellData -> cellData.getValue().rowProperty());
    this.keyColumn.setCellValueFactory(cellData -> cellData.getValue().keyProperty());
    this.valueColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
}
SqlProviderTest.java 文件源码 项目:ABC-List 阅读 15 收藏 0 点赞 0 评论 0
@Test
public void testFindAllTermsWithTitle() {
    LoggerFacade.getDefault().own(SqlProviderTest.class, "testFindAllTermsWithTitle()"); // NOI18N

    // ---------------------------------------------------------------------
    try { Thread.sleep(15); } catch (InterruptedException e) { }

    Term term1 = ModelProvider.getDefault().getTerm("Term1");
    SqlProvider.getDefault().createTerm(term1);

    ObservableList<Term> terms = FXCollections.observableArrayList();
    terms.addAll(SqlProvider.getDefault().findAllTermsWithTitle("hello?"));
    assertTrue(terms.isEmpty());

    terms.clear();
    terms.addAll(SqlProvider.getDefault().findAllTermsWithTitle("Term1"));
    assertFalse(terms.isEmpty());
    assertTrue(terms.size() == 1);
    assertEquals("Term1", terms.get(0).getTitle());

    // ---------------------------------------------------------------------
    DatabaseFacade.getDefault()
            .getCrudService("testFindAllTerms()")
            .delete(Term.class, term1.getId());
}
JavaFXTargetLocator.java 文件源码 项目:marathonv5 阅读 17 收藏 0 点赞 0 评论 0
private Stage[] getValidWindows() {
    ObservableList<Stage> stages = StageHelper.getStages();
    List<Stage> valid = new ArrayList<Stage>();
    for (Stage window : stages) {
        if (window.isShowing()) {
            valid.add(window);
        }
    }
    return valid.toArray(new Stage[valid.size()]);
}
ChildSelector.java 文件源码 项目:marathonv5 阅读 13 收藏 0 点赞 0 评论 0
protected List<IJavaFXElement> found(List<IJavaFXElement> pElements, IJavaFXAgent driver) {
    List<IJavaFXElement> r = new ArrayList<IJavaFXElement>();
    for (IJavaFXElement je : pElements) {
        if (!(je.getComponent() instanceof Parent)) {
            continue;
        }
        JFXWindow topContainer = driver.switchTo().getTopContainer();
        ObservableList<Node> components = ((Parent) je.getComponent()).getChildrenUnmodifiable();
        for (Node c : components) {
            IJavaFXElement je2 = JavaFXElementFactory.createElement(c, driver, driver.switchTo().getTopContainer());
            List<IJavaFXElement> matched = child.matchesSelector(je2);
            for (IJavaFXElement javaElement : matched) {
                IJavaFXElement e = topContainer.addElement(javaElement);
                if (!r.contains(e)) {
                    r.add(e);
                }
            }
        }
    }
    return r;
}
AreaChartSample.java 文件源码 项目:marathonv5 阅读 22 收藏 0 点赞 0 评论 0
public AreaChartSample() {
    NumberAxis xAxis = new NumberAxis("X Values", 1.0d, 9.0d, 2.0d);
    xAxis.setTickLength(12.0f);
    NumberAxis yAxis = new NumberAxis("Y Values", 0.0d, 10.0d, 2.0d);
    ObservableList<AreaChart.Series> areaChartData = FXCollections.observableArrayList(
            new AreaChart.Series("Series 1",FXCollections.observableArrayList(
                new AreaChart.Data(0,4),
                new AreaChart.Data(2,5),
                new AreaChart.Data(4,4),
                new AreaChart.Data(6,2),
                new AreaChart.Data(8,6),
                new AreaChart.Data(10,8)
            )),
            new AreaChart.Series("Series 2", FXCollections.observableArrayList(
                new AreaChart.Data(0,8),
                new AreaChart.Data(2,2),
                new AreaChart.Data(4,9),
                new AreaChart.Data(6,7),
                new AreaChart.Data(8,5),
                new AreaChart.Data(10,7)
            )),
            new AreaChart.Series("Series 3", FXCollections.observableArrayList(
                new AreaChart.Data(0,2),
                new AreaChart.Data(2,5),
                new AreaChart.Data(4,8),
                new AreaChart.Data(6,6),
                new AreaChart.Data(8,9),
                new AreaChart.Data(10,7)
            ))
    );
    AreaChart chart = new AreaChart(xAxis, yAxis, areaChartData);
    getChildren().add(chart);
}
TimingDiagramView.java 文件源码 项目:stvs 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Instantiates a new Timing diagram view.
 *
 * @param xaxis the x axis
 * @param yaxis the y axis
 */
public TimingDiagramView(NumberAxis xaxis, Axis<A> yaxis) {
  super(xaxis, yaxis);
  this.xaxis = xaxis;
  this.yaxis = yaxis;

  setPrefHeight(80);

  getPlotChildren().addAll(cycleSelectionPane, durationLinesPane, dataPane);
  ViewUtils.setupView(this);

  ObservableList<Series<Number, A>> seriesObservableList = FXCollections.observableArrayList();
  setData(seriesObservableList);
  seriesObservableList.addListener((InvalidationListener) change -> {
    Platform.runLater(TimingDiagramView.this::requestRelayout);
  });
}
UIController.java 文件源码 项目:attics 阅读 23 收藏 0 点赞 0 评论 0
public void initialize() {
    // populate year list
    List<Year> years = Database.getInstance().getYearsWithCollection(collection);

    ObservableList<Year> yearList = FXCollections.observableArrayList();
    yearList.addAll(years);

    // add the set to the list view
    yearsListView.setItems(yearList);
    yearsListView.setCellFactory(param -> new YearListViewCell());

    initializeListeners();

}
SpeedGuideViewController.java 文件源码 项目:Example.EMA.Java.SpeedGuide 阅读 19 收藏 0 点赞 0 评论 0
public void updateStatus(String status, StatusIndicator indicator, String item)
  {
// This will avoid a InvalidState Exception to ensure we are within the JavaFX thread
    Platform.runLater(new Runnable()
{
    @Override
    public void run()
    {
        if ( !item.isEmpty() )
            ric.setText(item);

        ObservableList<Node> nodes = statusText.getChildren();

        Text time = new Text();
        time.setId("status-time");      // Defined in CSS
        time.setText(new SimpleDateFormat("HH.mm.ss: ").format(new java.util.Date()));

        Text txt = new Text();
        txt.setText(status + SpeedGuide.NEWLINE);

        switch (indicator)
        {
            case REQUEST:
                txt.setId("status-request");            // Defined in CSS
                break;
            case RESPONSE_SUCCESS:
                txt.setId("status-response-success");   // Defined in CSS
                break;
            case RESPONSE_ERROR:
                txt.setId("status-response-error");     // Defined in CSS
                break;
        }

        nodes.add(0, txt);
        nodes.add(0, time);
    }
});
  }
Utils.java 文件源码 项目:GazePlay 阅读 25 收藏 0 点赞 0 评论 0
/**
 * @return CSS files found in the styles folder
 */
public static void addStylesheets(ObservableList<String> styleSheets) {

    File F = new File(getStylesFolder());

    if (F.exists()) {

        File[] Tfiles = F.listFiles();
        for (int i = 0; i < Tfiles.length; i++) {

            if (Tfiles[i].toString().endsWith(".css"))
                styleSheets.add("file://" + Tfiles[i].toString());
        }
    }
}
ZoomInMailView.java 文件源码 项目:desktop-gmail-client 阅读 17 收藏 0 点赞 0 评论 0
public void goBack(){
    final WebHistory history = webEngine.getHistory();
    ObservableList<WebHistory.Entry> entryList = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            try {
                history.go(-1);
            }catch(Exception e){
                webEngine.loadContent(body);
            }
        }
    });
}
MiscUtil.java 文件源码 项目:OneClient 阅读 23 收藏 0 点赞 0 评论 0
public static <T> Collector<T, ?, ObservableList<T>> toObservableList() {
    return Collector.of(
        FXCollections::observableArrayList,
        ObservableList::add,
        (l1, l2) -> {
            l1.addAll(l2);
            return l1;
        });
}
DeleteSelectedAnnotationsBC.java 文件源码 项目:vars-annotation 阅读 24 收藏 0 点赞 0 评论 0
private void apply() {
    ObservableList<Annotation> annotations = toolBox.getData().getSelectedAnnotations();
    final int count = annotations.size();
    ResourceBundle i18n = toolBox.getI18nBundle();
    String content = i18n.getString("buttons.delete.dialog.content1") + " " +
            count + " " + i18n.getString("buttons.delete.dialog.content2");
    alert.setContentText(content);
    Optional<ButtonType> buttonType = alert.showAndWait();
    if (buttonType.get() == ButtonType.OK) {
        toolBox.getEventBus()
                .send(new DeleteAnnotationsCmd(annotations));
    }
}
ControllerLayoutRanking.java 文件源码 项目:ShowMilhaoPOOJava 阅读 22 收藏 0 点赞 0 评论 0
@FXML
private void limparRanking(ActionEvent e) {     

    jogadorDao.limparRanking();

    tblClmPosicao.setCellValueFactory(new PropertyValueFactory<ModelJogadorTable, Integer>("linhaTable"));        
    tblClmNome.setCellValueFactory(new PropertyValueFactory<ModelJogadorTable, String>("nomeTable"));
    tblClmPontuacao.setCellValueFactory(new PropertyValueFactory<ModelJogadorTable, Integer>("pontuacaoTable"));       

    ObservableList<ModelJogadorTable> jogadorTable = FXCollections.observableArrayList(mostrarRankingView());
    tblRanking.setItems(jogadorTable);
}
ClockControl.java 文件源码 项目:can4eve 阅读 17 收藏 0 点赞 0 评论 0
private static void calcNoOfNodes(Node node) {
    if (node instanceof Parent) {
        if (((Parent) node).getChildrenUnmodifiable().size() != 0) {
            ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable();
            noOfNodes += tempChildren.size();
            tempChildren.forEach(n -> calcNoOfNodes(n));
        }
    }
}
StudentsReports.java 文件源码 项目:gatepass 阅读 23 收藏 0 点赞 0 评论 0
private void initFilter() {
    txtsearch = TextFields.createSearchField();
    txtsearch.setStyle("-fx-background-radius:10;");
    txtsearch.setPromptText("Search The Records");
    txtsearch.setMinWidth(200);
    txtsearch.textProperty().addListener(new InvalidationListener() {
           @Override
    public void invalidated(Observable o) {
           if(txtsearch.textProperty().get().isEmpty()) {
               tableView.setItems(att);
               return;
           }
           ObservableList<Reports> tableItems = FXCollections.observableArrayList();
           ObservableList<TableColumn<Reports, ?>> cols = tableView.getColumns();
           for(int i=0; i<att.size(); i++) {

               for(int j=0; j<cols.size(); j++) {
                   TableColumn<Reports, ?> col = cols.get(j);
                   String cellValue = col.getCellData(att.get(i)).toString();
                   cellValue = cellValue.toLowerCase();
                   if(cellValue.contains(txtsearch.textProperty().get().toLowerCase())) {
                       tableItems.add(att.get(i));
                       break;
                   }                        
               }
           }
           tableView.setItems(tableItems);
       }
});
}
BrowserFX.java 文件源码 项目:sbc-qsystem 阅读 37 收藏 0 点赞 0 评论 0
public String goForward() {
    final WebHistory history = webEngine.getHistory();
    ObservableList<WebHistory.Entry> entryList = history.getEntries();
    int currentIndex = history.getCurrentIndex();
    //    Out("currentIndex = "+currentIndex);
    //    Out(entryList.toString().replace("],","]\n"));
    Platform.runLater(() -> {
        history.go(1);
    });
    return entryList
        .get(currentIndex < entryList.size() - 1 ? currentIndex + 1 : currentIndex)
        .getUrl();
}
WatcherWindow.java 文件源码 项目:WebPLP 阅读 20 收藏 0 点赞 0 评论 0
private ComboBox<String> createDisplayOptionsDropdown()
{
    ObservableList<String> options = FXCollections.observableArrayList();
    options.addAll(valueDisplayOptions.keySet());

    ComboBox<String> dropdown = new ComboBox<>(options);
    dropdown.getSelectionModel().select(0);
    return dropdown;
}
PatientGetway.java 文件源码 项目:Dr-Assistant 阅读 20 收藏 0 点赞 0 评论 0
public ObservableList<Patient> patients(Paginate paginate) {
    DBConnection connection = new DBConnection();
    Connection con = null;
    PreparedStatement pst = null;
    ResultSet rs = null;
    ObservableList<Patient> listData = FXCollections.observableArrayList();
    con = connection.geConnection();
    try {
        pst = con.prepareStatement("select * from patient limit " + paginate.getStart() + "," + paginate.getEnd());
        rs = pst.executeQuery();
        while (rs.next()) {
            listData.add(new Patient(
                    rs.getInt(1),
                    rs.getString(2),
                    rs.getString(3),
                    LocalDate.parse(rs.getString(4)),
                    rs.getInt(5),
                    rs.getString(6),
                    rs.getString(7),
                    rs.getString(8),
                    rs.getString(9),
                    totalPrescriptionByPatient(rs.getInt(1))
            ));
        }
        rs.close();
        pst.close();
        con.close();
        connection.con.close();
    } catch (SQLException ex) {
        Logger.getLogger(PatientGetway.class.getName()).log(Level.SEVERE, null, ex);
    }
    return listData;
}
IFXContentBindingTest.java 文件源码 项目:infxnity 阅读 20 收藏 0 点赞 0 评论 0
@Test
public void addElementsTest()
{
    final ObservableList<Model> collection1 = FXCollections.observableArrayList(new Model("value1"),
                                                                                new Model("value2"),
                                                                                new Model("value3"),
                                                                                new Model("value4"));
    final ObservableList<String> collection2 = FXCollections.observableArrayList();

    IFXContentBinding.bind(collection2, collection1, Model::getText);

    final AtomicReference<ListChangeListener.Change<? extends String>> change = new AtomicReference<>(null);
    collection2.addListener((ListChangeListener<String>) c -> {
        change.set(c);
    });

    collection1.addAll(2, Arrays.asList(new Model("value2bis"), new Model("value2ter")));

    assertNotNull("Change event", change.get());
    assertTrue("Has change", change.get().next());
    assertTrue("Was added", change.get().wasAdded());
    assertFalse("Was removed", change.get().wasRemoved());
    assertFalse("Was update", change.get().wasUpdated());
    assertFalse("Was permuted", change.get().wasPermutated());
    assertEquals("from", 2, change.get().getFrom());
    assertEquals("to", 4, change.get().getTo());
    assertEquals("Added sub-list", Arrays.asList("value2bis", "value2ter"), change.get().getAddedSubList());
    assertFalse("Has more change", change.get().next());

    assertEquals(Arrays.asList("value1", "value2", "value2bis", "value2ter", "value3", "value4"), collection2);
}


问题


面经


文章

微信
公众号

扫码关注公众号