Java Code Examples for javafx.collections.ListChangeListener.Change#next()

The following examples show how to use javafx.collections.ListChangeListener.Change#next() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListChange.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
public ListChange(ObservableList<ObjectTag> property, Change<? extends ObjectTag> change) {
   this.property = property;
   if (change.next()) {
      if (change.wasRemoved()) {
         target = change.getRemoved().get(0);
         added = false;
      }
      else if (change.wasAdded()) {
         target = change.getAddedSubList().get(0);
         added = true;
      }
      index = change.getFrom();
   }
}
 
Example 2
Source File: Java9.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void sourceChanged(Change<? extends F> c) {
    beginChange();
    while (c.next()) {
        if (c.wasPermutated()) {
            int from = c.getFrom();
            int to = c.getTo();
            int[] perm = new int[to - from];
            for (int i = from; i < to; i++) {
                perm[i] = c.getPermutation(i);
            }
            nextPermutation(from, to, perm);
        } else if (c.wasUpdated()) {
            for (int pos = c.getFrom(); pos < c.getTo(); pos++)
                nextUpdate(pos);
        } else {
            if (c.wasAdded())
                nextAdd(c.getFrom(), c.getTo());
            if (c.wasRemoved()) {
                nextRemove(c.getFrom(), c.getRemoved().stream().map((f) -> {
                    return (E) f;
                }).collect(Collectors.toList()));
            }
        }
    }
    endChange();
}
 
Example 3
Source File: BallotListService.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void onChanged(Change<? extends ProposalPayload> change) {
    change.next();
    if (change.wasAdded()) {
        List<? extends ProposalPayload> addedPayloads = change.getAddedSubList();
        addedPayloads.stream()
                .map(ProposalPayload::getProposal)
                .filter(this::isNewProposal)
                .forEach(this::registerProposalAsBallot);
        persist();
    }
}
 
Example 4
Source File: ListCombinationBinding.java    From EasyBind with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void sourceChanged(
        Change<? extends ObservableValue<? extends T>> ch) {
    while(ch.next()) {
        ch.getRemoved().forEach(elem -> elem.removeListener(weakElemListener));
        ch.getAddedSubList().forEach(elem -> elem.addListener(weakElemListener));
        invalidate();
    }
}
 
Example 5
Source File: QuasiListChange.java    From ReactFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
static <E> QuasiListChange<E> from(Change<? extends E> ch) {
    QuasiListChangeImpl<E> res = new QuasiListChangeImpl<>();
    while(ch.next()) {
        res.add(QuasiListModification.fromCurrentStateOf(ch));
    }
    return res;
}