@Override protected void seriesChanged(Change<? extends MultiAxisChart.Series<X, Y>> c) { // Update style classes for all series lines and symbols // Note: is there a more efficient way of doing this? for (int i = 0; i < getDataSize(); i++) { final MultiAxisChart.Series<X, Y> s = getData().get(i); Path seriesLine = (Path) ((Group) s.getNode()).getChildren().get(1); Path fillPath = (Path) ((Group) s.getNode()).getChildren().get(0); seriesLine.getStyleClass().setAll("chart-series-area-line", "series" + i, s.defaultColorStyleClass); fillPath.getStyleClass().setAll("chart-series-area-fill", "series" + i, s.defaultColorStyleClass); for (int j = 0; j < s.getData().size(); j++) { final Data<X, Y> item = s.getData().get(j); final Node node = item.getNode(); if (node != null) node.getStyleClass().setAll("chart-area-symbol", "series" + i, "data" + j, s.defaultColorStyleClass); } } }
/** * Generates a bidirectional binding between the {@link ObservableList} and the application store * value identified by the {@code key} {@link String}. * * @param observableList {@link ObservableList} to bind * @param key unique application store key */ public void bind(final ObservableList<String> observableList, String key) { String value = prefs.get(validateKey(key), null); if (value != null && value.length() > 1) { for (String v : value.split("\u001e")) { if (v != null && v.trim().length() > 0 && !observableList.contains(v.trim())) { observableList.add(v.trim()); } } } observableList.addListener((Change<? extends CharSequence> c) -> { if (c.next()) { String joined = c.getList().stream().collect(Collectors.joining("\u001e")); prefs.put(key, joined); } }); }
/** * Constructs a new {@code Flyout} using the specified "anchor" * as the location from which the specified "contents" will * fly out. * * @param anchor Node used to define the start point of the flyout animation * @param contents Node containing the "control" to fly out */ public Flyout(Node anchor, Node contents) { this.anchor = anchor; this.flyoutContents = contents; userNodeContainer = new Pane(); getChildren().addListener((Change<? extends Node> c) -> { if(getChildren().size() > 1) { throw new IllegalStateException("May only add one child to a Flyout"); } }); layoutBoundsProperty().addListener((v, o, n) -> { if(getChildren().size() < 1) return; if(getChildren().size() > 1) { throw new IllegalStateException("May only add one child to a Flyout"); } }); getChildren().add(anchor); popup = new Stage(); }
@Override protected void sourceChanged(Change<? extends E> c) { if (elementComparator != null) { beginChange(); while (c.next()) { if (c.wasPermutated()) { updatePermutationIndexes(c); } else if (c.wasUpdated()) { update(c); } else { addRemove(c); } } endChange(); } else { updateUnsorted(c); fireChange(new SourceAdapterChange<>(this, c)); } }
private void addRemove(Change<? extends E> c) { if (c.getFrom() == 0 && c.getRemovedSize() == size) { removeAllFromMapping(); } else { for (int i = 0, sz = c.getRemovedSize(); i < sz; ++i) { removeFromMapping(c.getFrom(), c.getRemoved().get(i)); } } if (size == 0) { setAllToMapping(c.getList(), c.getTo()); // This is basically equivalent to getAddedSubList // as size is 0, only valid "from" is also 0 } else { for (int i = c.getFrom(), to = c.getTo(); i < to; ++i) { insertToMapping(c.getList().get(i), i); } } }
protected void permute(Change<? extends F> c) { int from = c.getFrom(); int to = c.getTo(); if (to > from) { List<E> clone = new ArrayList<E>(mappedValues); int[] perm = IntStream.range(0, size()).toArray(); for (int i = from; i < to; ++i) { perm[i] = c.getPermutation(i); mappedValues.set(i, clone.get(c.getPermutation(i))); } nextPermutation(from, to, perm); } }
public ListProperty<AtomicRight> rightsProperty() { if ( rightsProperty == null ) { rightsProperty = new SimpleListProperty<>(FXCollections.observableList(rights)); rightsProperty.get().addListener(new ListChangeListener<AtomicRight>() { @Override public void onChanged(Change<? extends AtomicRight> change) { while (change.next()) { if ( !change.wasAdded() ) continue; for (AtomicRight addedRight : change.getAddedSubList()) { for (Persona persona : personas) { if ( persona.getPersonaRights().contains(addedRight) ) { change.getList().remove(addedRight); } } if ( containsMoreThanOnce(rights, addedRight) ) { change.getList().remove(addedRight); } } } } }); } return rightsProperty; }
public ListProperty<Persona> personasProperty() { if ( personasProperty == null ) { personasProperty = new SimpleListProperty<>(FXCollections.observableList(personas)); personasProperty.get().addListener(new ListChangeListener<Persona>() { @Override public void onChanged(Change<? extends Persona> change) { while (change.next()) { if ( change.wasAdded() ) { for (Persona persona : change.getAddedSubList()) { // Remove local duplicates for (AtomicRight personaRight : persona.getPersonaRights()) { if ( getRights().contains(personaRight) ) { remove(personaRight); } } } } } } }); } return personasProperty; }
private void selectNewTab(Change<View> change) { while (change.next()) { if (change.wasAdded()) { List<View> added = change.getAddedSubList(); View lastAdded = added.get(added.size() - 1); selectedTabProperty.set(lastAdded); } else if (change.wasRemoved()) { int newIndex = tabsProperty.indexOf(selectedTabProperty.get()) - 1; if (newIndex < 0) { newIndex = 0; } View selectedTab = change.getList().get(newIndex); selectedTabProperty.set(selectedTab); } } }
private void setupEventHandlers() { this.setUpEventHandler(this.topCenterNodeProperty); this.setUpEventHandler(this.topRightNodeProperty); this.setUpEventHandler(this.centerRightNodeProperty); this.setUpEventHandler(this.bottomRightNodeProperty); this.setUpEventHandler(this.bottomCenterNodeProperty); this.setUpEventHandler(this.bottomLeftNodeProperty); this.setUpEventHandler(this.centerLeftNodeProperty); this.setUpEventHandler(this.topLeftNodeProperty); this.setUpEventHandler(this.wrappedControlProperty); this.contextMenuActions.addListener( (final Change<? extends Action> change) -> this .getWrappedControl() .contextMenuProperty() .set(ActionUtils.createContextMenu( this.contextMenuActions()))); }
static <E, F extends E> QuasiListModification<E> fromCurrentStateOf( Change<F> ch) { List<F> list = ch.getList(); int from = ch.getFrom(); int addedSize = ch.getTo() - from; // use (to - from), because // ch.getAddedSize() is 0 on permutation List<F> removed; if(ch.wasPermutated()) { removed = new ArrayList<>(addedSize); for(int i = 0; i < addedSize; ++i) { int pi = ch.getPermutation(from + i); removed.add(list.get(pi)); } } else { removed = ch.getRemoved(); } return new QuasiListModificationImpl<>(from, removed, addedSize); }
@Test public void listInsertionTest() { final ObservableList<Integer> list1 = FXCollections.observableArrayList(0, 1, 2); final ObservableList<Integer> list2 = FXCollections.observableArrayList(4, 5); final ObservableListAggregation<Integer> listAggregation = new ObservableListAggregation<>(list1, list2); final AtomicReference<Change<? extends Integer>> change = new AtomicReference<>(null); listAggregation.addListener((ListChangeListener<Integer>) c -> { change.set(c); }); listAggregation.getLists().add(1, FXCollections.observableArrayList(3)); 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", 3, change.get().getFrom()); assertEquals("to", 4, change.get().getTo()); assertEquals("Added sub-list", Arrays.asList(3), change.get().getAddedSubList()); assertFalse("Has more change", change.get().next()); assertEquals("size", 6, listAggregation.size()); assertEquals("get(0)", Integer.valueOf(0), listAggregation.get(0)); assertEquals("get(1)", Integer.valueOf(1), listAggregation.get(1)); assertEquals("get(2)", Integer.valueOf(2), listAggregation.get(2)); assertEquals("get(3)", Integer.valueOf(3), listAggregation.get(3)); assertEquals("get(4)", Integer.valueOf(4), listAggregation.get(4)); assertEquals("get(5)", Integer.valueOf(5), listAggregation.get(5)); }
@Test public void listRemoveTest() { final ObservableList<Integer> list1 = FXCollections.observableArrayList(0, 1, 2); final ObservableList<Integer> list2 = FXCollections.observableArrayList(3); final ObservableList<Integer> list3 = FXCollections.observableArrayList(4, 5); final ObservableListAggregation<Integer> listAggregation = new ObservableListAggregation<>(list1, list2, list3); final AtomicReference<Change<? extends Integer>> change = new AtomicReference<>(null); listAggregation.addListener((ListChangeListener<Integer>) c -> { change.set(c); }); listAggregation.getLists().remove(1); assertNotNull("Change event", change.get()); assertTrue("Has change", change.get().next()); assertFalse("Was added", change.get().wasAdded()); assertTrue("Was removed", change.get().wasRemoved()); assertFalse("Was update", change.get().wasUpdated()); assertFalse("Was permuted", change.get().wasPermutated()); assertEquals("from", 3, change.get().getFrom()); assertEquals("to", 3, change.get().getTo()); assertEquals("Removed", Arrays.asList(3), change.get().getRemoved()); assertFalse("Has more change", change.get().next()); assertEquals("size", 5, listAggregation.size()); assertEquals("get(0)", Integer.valueOf(0), listAggregation.get(0)); assertEquals("get(1)", Integer.valueOf(1), listAggregation.get(1)); assertEquals("get(2)", Integer.valueOf(2), listAggregation.get(2)); assertEquals("get(3)", Integer.valueOf(4), listAggregation.get(3)); assertEquals("get(4)", Integer.valueOf(5), listAggregation.get(4)); }
@Test public void listReplaceTest() { final ObservableList<Integer> list1 = FXCollections.observableArrayList(0, 1, 2); final ObservableList<Integer> list2 = FXCollections.observableArrayList(3); final ObservableList<Integer> list3 = FXCollections.observableArrayList(4, 5); final ObservableList<Integer> list2bis = FXCollections.observableArrayList(6, 7); final ObservableListAggregation<Integer> listAggregation = new ObservableListAggregation<>(list1, list2, list3); final AtomicReference<Change<? extends Integer>> change = new AtomicReference<>(null); listAggregation.addListener((ListChangeListener<Integer>) c -> { change.set(c); }); listAggregation.getLists().set(1, list2bis); assertNotNull("Change event", change.get()); assertTrue("Has change", change.get().next()); assertTrue("Was added", change.get().wasAdded()); assertTrue("Was removed", change.get().wasRemoved()); assertFalse("Was update", change.get().wasUpdated()); assertFalse("Was permuted", change.get().wasPermutated()); assertEquals("from", 3, change.get().getFrom()); assertEquals("to", 5, change.get().getTo()); assertEquals("Added sub-list", Arrays.asList(6, 7), change.get().getAddedSubList()); assertEquals("Removed", Arrays.asList(3), change.get().getRemoved()); assertFalse("Has more change", change.get().next()); assertEquals("size", 7, listAggregation.size()); assertEquals("get(0)", Integer.valueOf(0), listAggregation.get(0)); assertEquals("get(1)", Integer.valueOf(1), listAggregation.get(1)); assertEquals("get(2)", Integer.valueOf(2), listAggregation.get(2)); assertEquals("get(3)", Integer.valueOf(6), listAggregation.get(3)); assertEquals("get(4)", Integer.valueOf(7), listAggregation.get(4)); assertEquals("get(5)", Integer.valueOf(4), listAggregation.get(5)); assertEquals("get(6)", Integer.valueOf(5), listAggregation.get(6)); }
@Test public void addElementsTest() { final ObservableList<Integer> list1 = FXCollections.observableArrayList(0, 1, 2); final ObservableList<Integer> list2 = FXCollections.observableArrayList(3); final ObservableList<Integer> list3 = FXCollections.observableArrayList(4, 5); final ObservableListAggregation<Integer> listAggregation = new ObservableListAggregation<>(list1, list2, list3); final AtomicReference<Change<? extends Integer>> change = new AtomicReference<>(null); listAggregation.addListener((ListChangeListener<Integer>) c -> { change.set(c); }); list2.addAll(6, 7); 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", 4, change.get().getFrom()); assertEquals("to", 6, change.get().getTo()); assertEquals("Added sub-list", Arrays.asList(6, 7), change.get().getAddedSubList()); assertFalse("Has more change", change.get().next()); assertEquals("size", 8, listAggregation.size()); assertEquals("get(0)", Integer.valueOf(0), listAggregation.get(0)); assertEquals("get(1)", Integer.valueOf(1), listAggregation.get(1)); assertEquals("get(2)", Integer.valueOf(2), listAggregation.get(2)); assertEquals("get(3)", Integer.valueOf(3), listAggregation.get(3)); assertEquals("get(4)", Integer.valueOf(6), listAggregation.get(4)); assertEquals("get(5)", Integer.valueOf(7), listAggregation.get(5)); assertEquals("get(6)", Integer.valueOf(4), listAggregation.get(6)); assertEquals("get(7)", Integer.valueOf(5), listAggregation.get(7)); }
@Test public void removeElementsTest() { final ObservableList<Integer> list1 = FXCollections.observableArrayList(0, 1, 2); final ObservableList<Integer> list2 = FXCollections.observableArrayList(3); final ObservableList<Integer> list3 = FXCollections.observableArrayList(4, 5); final ObservableListAggregation<Integer> listAggregation = new ObservableListAggregation<>(list1, list2, list3); final AtomicReference<Change<? extends Integer>> change = new AtomicReference<>(null); listAggregation.addListener((ListChangeListener<Integer>) c -> { change.set(c); }); list3.remove(1); assertNotNull("Change event", change.get()); assertTrue("Has change", change.get().next()); assertFalse("Was added", change.get().wasAdded()); assertTrue("Was removed", change.get().wasRemoved()); assertFalse("Was update", change.get().wasUpdated()); assertFalse("Was permuted", change.get().wasPermutated()); assertEquals("from", 5, change.get().getFrom()); assertEquals("to", 5, change.get().getTo()); assertEquals("Removed", Arrays.asList(5), change.get().getRemoved()); assertFalse("Has more change", change.get().next()); assertEquals("size", 5, listAggregation.size()); assertEquals("get(0)", Integer.valueOf(0), listAggregation.get(0)); assertEquals("get(1)", Integer.valueOf(1), listAggregation.get(1)); assertEquals("get(2)", Integer.valueOf(2), listAggregation.get(2)); assertEquals("get(3)", Integer.valueOf(3), listAggregation.get(3)); assertEquals("get(4)", Integer.valueOf(4), listAggregation.get(4)); }
@Test public void replaceElementsTest() { final ObservableList<Integer> list1 = FXCollections.observableArrayList(0, 1, 2); final ObservableList<Integer> list2 = FXCollections.observableArrayList(3); final ObservableList<Integer> list3 = FXCollections.observableArrayList(4, 5); final ObservableListAggregation<Integer> listAggregation = new ObservableListAggregation<>(list1, list2, list3); final AtomicReference<Change<? extends Integer>> change = new AtomicReference<>(null); listAggregation.addListener((ListChangeListener<Integer>) c -> { change.set(c); }); list1.setAll(6, 7, 8); assertNotNull("Change event", change.get()); assertTrue("Has change", change.get().next()); assertTrue("Was added", change.get().wasAdded()); assertTrue("Was removed", change.get().wasRemoved()); assertFalse("Was update", change.get().wasUpdated()); assertFalse("Was permuted", change.get().wasPermutated()); assertEquals("from", 0, change.get().getFrom()); assertEquals("to", 3, change.get().getTo()); assertEquals("Added sub-list", Arrays.asList(6, 7, 8), change.get().getAddedSubList()); assertEquals("Removed", Arrays.asList(0, 1, 2), change.get().getRemoved()); assertFalse("Has more change", change.get().next()); assertEquals("size", 6, listAggregation.size()); assertEquals("get(0)", Integer.valueOf(6), listAggregation.get(0)); assertEquals("get(1)", Integer.valueOf(7), listAggregation.get(1)); assertEquals("get(2)", Integer.valueOf(8), listAggregation.get(2)); assertEquals("get(3)", Integer.valueOf(3), listAggregation.get(3)); assertEquals("get(4)", Integer.valueOf(4), listAggregation.get(4)); assertEquals("get(5)", Integer.valueOf(5), listAggregation.get(5)); }
@Test public void permuteElementsTest() { final ObservableList<Integer> list1 = FXCollections.observableArrayList(1, 2, 0); final ObservableList<Integer> list2 = FXCollections.observableArrayList(3); final ObservableList<Integer> list3 = FXCollections.observableArrayList(4, 5); final ObservableListAggregation<Integer> listAggregation = new ObservableListAggregation<>(list1, list2, list3); final AtomicReference<Change<? extends Integer>> change = new AtomicReference<>(null); listAggregation.addListener((ListChangeListener<Integer>) c -> { change.set(c); }); list1.sort(Integer::compareTo); assertNotNull("Change event", change.get()); assertTrue("Has change", change.get().next()); assertFalse("Was added", change.get().wasAdded()); assertFalse("Was removed", change.get().wasRemoved()); assertFalse("Was update", change.get().wasUpdated()); assertTrue("Was permuted", change.get().wasPermutated()); assertEquals("from", 0, change.get().getFrom()); assertEquals("to", 3, change.get().getTo()); assertEquals("permitation(0)", 1, change.get().getPermutation(0)); assertEquals("permitation(1)", 2, change.get().getPermutation(1)); assertEquals("permitation(2)", 0, change.get().getPermutation(2)); assertFalse("Has more change", change.get().next()); assertEquals("size", 6, listAggregation.size()); assertEquals("get(0)", Integer.valueOf(0), listAggregation.get(0)); assertEquals("get(1)", Integer.valueOf(1), listAggregation.get(1)); assertEquals("get(2)", Integer.valueOf(2), listAggregation.get(2)); assertEquals("get(3)", Integer.valueOf(3), listAggregation.get(3)); assertEquals("get(4)", Integer.valueOf(4), listAggregation.get(4)); assertEquals("get(5)", Integer.valueOf(5), listAggregation.get(5)); }
@Override protected void seriesChanged(Change<? extends MultiAxisChart.Series<X, Y>> c) { // Update style classes for all series lines and symbols // Note: is there a more efficient way of doing this? for (int i = 0; i < getDataSize(); i++) { final Series<X, Y> s = getData().get(i); Node seriesNode = s.getNode(); if (seriesNode != null) seriesNode.getStyleClass().setAll("chart-series-line", "series" + i, s.defaultColorStyleClass); } }
public Browser() { browser.getChildrenUnmodifiable().addListener((Change<? extends Node> change) -> { final Set<Node> deadSeaScrolls = browser.lookupAll(".scroll-bar"); deadSeaScrolls.stream().forEach((scroll) -> { scroll.setVisible(false); }); }); getChildren().add(browser); }
/** * Method to handle the change in selection of the {@link uk.dangrew.jtt.javafx.tree.structure.Tree}. * @param change the {@link javafx.collections.ListChangeListener.Change} made. */ private void handleSelection( Change< ? extends TreeItem< UserAssignmentsTreeItem > > change ) { ObservableList< TreeItem< UserAssignmentsTreeItem > > selection = tree.getSelectionModel().getSelectedItems(); if ( selection.size() != 1 ) { area.setAssignment( null ); return; } if ( selection.get( 0 ).getValue() == null ) { area.setAssignment( null ); return; } area.setAssignment( selection.get( 0 ).getValue().getAssignment() ); }
/** * Constructs a new {@link SplitPaneDividerPositionListener}. * @param subject the {@link SplitPane} subject to monitor. * @param callBack the {@link DividerPositionsChangedCallBack} to trigger. */ public SplitPaneDividerPositionListener( SplitPane subject, DividerPositionsChangedCallBack callBack ) { this.subject = subject; this.positionDividers = new HashSet<>(); this.commonListener = ( source, old, updated ) -> callBack.dividerPositionsChanged(); this.subject.getDividers().addListener( ( Change< ? extends Divider > change ) -> updateDividerRegistrations() ); updateDividerRegistrations(); }
public void addAlwaysOneSelectedSupport(final ToggleGroup toggleGroup) { toggleGroup.getToggles().addListener((Change<? extends Toggle> c) -> { while (c.next()) { for (final Toggle addedToggle : c.getAddedSubList()) { addConsumeMouseEventfilter(addedToggle); } } }); toggleGroup.getToggles().forEach(t -> { addConsumeMouseEventfilter(t); }); }
TMATableModel() { useSelectedProperty.addListener((v, o, n) -> refreshList()); table.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<TreeItem<TMAEntry>>() { @Override public void onChanged(ListChangeListener.Change<? extends TreeItem<TMAEntry>> c) { if (useSelectedProperty.get()) refreshList(); } }); refreshList(); }
/** * Do initialization after fx components have been generated. */ @FXML private void initialize() { this.reportSpecObservableValue = new ObservableReportSpec(); // If we detect the user deleted a tab, then make our observable report spec no longer depend on that tab this.reportSectionsTabPane.getTabs().addListener((final Change<? extends Tab> c) -> { while (c.next()) { if (c.wasRemoved()) { for (final Tab t : c.getRemoved()) { this.reportSpecObservableValue.unbindTab(t); } } } }); this.saveManager = new ReportSpecSaveManager(this, this.analysisSerializer); newEntity(); this.saveManager.syncSavedEntity(); ControllerUtils.performWithStage(this.reportSectionsTabPane, stage -> { stage.setOnCloseRequest(e -> { final boolean safeToProceed = this.saveManager .promptSave("Save changes to current report before closing? Otherwise your current changes will be lost."); if (!safeToProceed) e.consume(); }); }); }
/** * Callback when blacklistitems changed * * @param changeEvent */ private void onBlacklistedCellValuesChanged(Change<? extends T> changeEvent) { List<Integer> addedIndexes = new ArrayList<>(); List<Integer> removedIndexes = new ArrayList<>(); while (changeEvent.next()) { for (T addedItem : changeEvent.getAddedSubList()) { addedIndexes.addAll(mapCellValuesToRowIndexes.get(addedItem)); } for (T removedItem : changeEvent.getRemoved()) { removedIndexes.addAll(mapCellValuesToRowIndexes.get(removedItem)); } } blacklistedRowIndexes.addAll(addedIndexes); blacklistedRowIndexes.removeAll(removedIndexes); }
/** * Constructs a new {@code Flyout} using the specified "anchor" * as the location from which the specified "contents" will * fly out. * * @param anchor Node used to define the start point of the flyout animation * @param contents Node containing the "control" to fly out */ @SuppressWarnings("restriction") public Flyout(Node anchor, Node contents, MainScene mainScene) { this.mainScene = mainScene; this.anchor = anchor; this.flyoutContents = contents; userNodeContainer = new Pane(); getChildren().addListener((Change<? extends Node> c) -> { if(getChildren().size() > 1) { throw new IllegalStateException("May only add one child to a Flyout"); } }); layoutBoundsProperty().addListener((v, o, n) -> { if(getChildren().size() < 1) return; if(getChildren().size() > 1) { throw new IllegalStateException("May only add one child to a Flyout"); } }); getChildren().add(anchor); popup = new Stage(); popup.setResizable(true); }
public JFXListViewSkin(final JFXListView<T> listView) { super(listView); JFXDepthManager.setDepth(flow, listView.depthProperty().get()); listView.depthProperty().addListener((o, oldVal, newVal) -> JFXDepthManager.setDepth(flow, newVal)); listView.getItems().addListener((Change<? extends T> change) -> new Thread(() -> { try { Thread.sleep(20); } catch (InterruptedException intEx) { intEx.printStackTrace(); } Platform.runLater(() -> getSkinnable().requestLayout()); }).start()); }
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(); } }
private void updateUnsorted(Change<? extends E> c) { while (c.next()) { if (c.wasPermutated()) { Element[] sortedTmp = new Element[sorted.length]; for (int i = 0; i < size; ++i) { if (i >= c.getFrom() && i < c.getTo()) { sortedTmp[c.getPermutation(i)] = sorted[i]; } else { sortedTmp[i] = sorted[i]; } } sorted = sortedTmp; } if (c.wasRemoved()) { final int removedTo = c.getFrom() + c.getRemovedSize(); System.arraycopy(sorted, removedTo, sorted, c.getFrom(), size - removedTo); size -= c.getRemovedSize(); updateIndices(removedTo, -c.getRemovedSize()); } if (c.wasAdded()) { ensureSize(size + c.getAddedSize()); updateIndices(c.getFrom(), c.getAddedSize()); System.arraycopy(sorted, c.getFrom(), sorted, c.getTo(), size - c.getFrom()); size += c.getAddedSize(); for (int i = c.getFrom(); i < c.getTo(); ++i) { sorted[i] = new Element<E>(c.getList().get(i), i); } } } }
private void update(Change<? extends E> c) { int[] perm = helper.sort(sorted, 0, size, elementComparator); nextPermutation(0, size, perm); for (int i = c.getFrom(), to = c.getTo(); i < to; ++i) { nextUpdate(findPosition(i, c.getList().get(i))); } }
/** * Invoked if the list of children in the {@link Pane} changes. * * @param pChange the changes. */ private void onPaneChildrenListChanged(Change<? extends Node> pChange) { if (!pane.isIgnoreChildrenListEvents()) { updateActiveWindow(); } }
private void onTournamentRoundListChanged( Change<? extends TournamentRound> change) { if (change.next()) { this.refreshBreadcrumbs(); if (this.loadedTournament != null) { this.setSelectedRound(this.loadedTournament.getRounds().size() - 1); } } }
/** * Listener that is being attached to registered lists. * * @param change * the change that occurred on the list */ @SuppressWarnings("unchecked") private <T> void listChangeListener(Change<? extends T> change) { if (!this.isPerformingAction && !this.sleeping) { this.addUndoAction(new ListUndoAction<>((Change<T>) change)); } }
protected void update(Change<? extends F> c) { int from = c.getFrom(); int to = c.getTo(); if (to > from) { for (int i = from; i < to; ++i) { mappedValues.set(i, mapper.apply(getSource().get(i))); nextUpdate(i); } } }
protected void addRemove(Change<? extends F> c) { int from = c.getFrom(); int to = c.getTo(); for (int index = from + c.getRemovedSize() - 1; index >= from; index--) { nextRemove(index, mappedValues.remove(index)); } for (int index = from; index < from + c.getAddedSize(); index++) { mappedValues.add(index, mapper.apply(getSource().get(index))); nextAdd(index, index + 1); } }
/** * 艦隊が変更された時のリスナー */ private void changeDeckFleet(Change<?> change) { this.fleetList.getItems().clear(); for (Node node : this.fleets.getChildren()) { if (node instanceof DeckFleetPane) { DeckFleetPane fleet = (DeckFleetPane) node; this.fleetList.getItems().add(fleet); } } this.modified.set(true); }
public void onTabsChanged(Change change) { if (tabsProperty.size() == 0) { selectedTabProperty.set(null); updateTabButtons(); } else if (!change.getList().contains(selectedTabProperty.get())) { // TODO selectNewTab(change); } else { updateTabButtons(); } }
public void onTabsChanged(Change change) { if (tabsProperty.size() == 0) { selectedTabProperty.set(null); } else { selectNewTab(change); } }