javafx.collections.ListChangeListener.Change Java Examples

The following examples show how to use javafx.collections.ListChangeListener.Change. 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: TableVisualisation.java    From constellation with Apache License 2.0 6 votes vote down vote up
public void populateTable(final List<C> items) {
    final ObservableList<C> tableData = FXCollections.observableArrayList(items);

    final FilteredList<C> filteredData = new FilteredList<>(tableData, predicate -> true);
    filteredData.addListener((Change<? extends C> change) -> table.refresh());
    tableFilter.textProperty().addListener((observable, oldValue, newValue) -> {
        filteredData.setPredicate(item -> {
            if (newValue == null || newValue.isEmpty()) {
                return true;
            }

            final String lowerCaseFilter = newValue.toLowerCase();
            return item.getIdentifier().toLowerCase().contains(lowerCaseFilter);
        });
    });

    final SortedList<C> sortedData = new SortedList<>(filteredData);
    sortedData.comparatorProperty().bind(table.comparatorProperty());

    table.setItems(sortedData);
}
 
Example #2
Source File: QuasiListModification.java    From ReactFX with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
}
 
Example #3
Source File: ListListenerHelperEx.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link ListListenerHelperEx.AtomicChange} for the
 * passed in source, based on the data provided in the passed-in change.
 * <p>
 * This is basically used to allow properties wrapping an
 * {@link ObservableList} to re-fire change events of their wrapped
 * {@link ObservableList} with themselves as source.
 *
 * @param source
 *            The new source {@link ObservableList}.
 * @param change
 *            The change to infer a new change from. It is expected that
 *            the change is in initial state. In either case it will be
 *            reset to initial state.
 */
@SuppressWarnings("unchecked")
public AtomicChange(ObservableList<E> source,
		ListChangeListener.Change<? extends E> change) {
	super(source);

	// copy previous contents
	this.previousContents = new ArrayList<>(
			CollectionUtils.getPreviousContents(change));

	// retrieve elementary sub-changes by iterating them
	// TODO: we could introduce an initialized field inside Change
	// already, so we could check the passed in change is not already
	// initialized
	List<ElementarySubChange<E>> elementarySubChanges = getElementaryChanges(
			change);
	this.elementarySubChanges = elementarySubChanges
			.toArray(new ElementarySubChange[] {});
}
 
Example #4
Source File: ListListenerHelperEx.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Infers the elementary changes constituting the change of the
 * {@link ObservableList}.
 *
 * @param <E>
 *            The element type of the {@link ObservableList} that was
 *            changed.
 * @param change
 *            The (atomic) change to infer elementary changes from.
 * @return A list of elementary changes.
 */
protected static <E> List<ElementarySubChange<E>> getElementaryChanges(
		ListChangeListener.Change<? extends E> change) {
	List<ElementarySubChange<E>> elementarySubChanges = new ArrayList<>();
	while (change.next()) {
		if (change.wasReplaced()) {
			elementarySubChanges.add(ElementarySubChange.replaced(
					change.getRemoved(), change.getAddedSubList(),
					change.getFrom(), change.getTo()));
		} else if (change.wasRemoved()) {
			elementarySubChanges.add(ElementarySubChange.removed(
					change.getRemoved(), change.getFrom(), change.getTo()));
		} else if (change.wasAdded()) {
			elementarySubChanges.add(ElementarySubChange.added(
					new ArrayList<>(change.getAddedSubList()),
					change.getFrom(), change.getTo()));
		} else if (change.wasPermutated()) {
			// find permutation
			int[] permutation = CollectionUtils.getPermutation(change);
			elementarySubChanges.add(ElementarySubChange.<E> permutated(
					permutation, change.getFrom(), change.getTo()));
		}
	}
	change.reset();
	return elementarySubChanges;
}
 
Example #5
Source File: ListListenerHelperEx.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Notifies the attached {@link ListChangeListener}s about the related
 * change.
 *
 * @param change
 *            The applied change.
 */
protected void notifyListChangeListeners(Change<? extends E> change) {
	if (listChangeListeners != null) {
		try {
			lockListChangeListeners = true;
			for (ListChangeListener<? super E> l : listChangeListeners) {
				change.reset();
				try {
					l.onChanged(change);
				} catch (Exception e) {
					Thread.currentThread().getUncaughtExceptionHandler()
							.uncaughtException(Thread.currentThread(), e);
				}
			}
		} finally {
			lockListChangeListeners = false;
		}
	}
}
 
Example #6
Source File: CollectionUtils.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Computes the permutation for the given {@link Change}.
 *
 * @param <E>
 *            The element type of the {@link ObservableList} that was
 *            changed.
 * @param change
 *            The change, for which {@link Change#wasPermutated()} has to
 *            return <code>true</code>.
 * @return An integer array mapping previous indexes to current ones.
 */
public static <E> int[] getPermutation(
		ListChangeListener.Change<? extends E> change) {
	if (!change.wasPermutated()) {
		throw new IllegalArgumentException(
				"Change is no permutation change.");
	}
	if (change instanceof AtomicChange) {
		return ((AtomicChange<?>) change).getPermutation();
	}
	int[] permutation = new int[change.getTo() - change.getFrom()];
	for (int oldIndex = change.getFrom(); oldIndex < change
			.getTo(); oldIndex++) {
		int newIndex = change.getPermutation(oldIndex);
		permutation[oldIndex] = newIndex;
	}
	return permutation;
}
 
Example #7
Source File: SuspendableListTest.java    From ReactFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void test() {
    javafx.collections.ObservableList<Integer> base = FXCollections.observableArrayList(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
    SuspendableList<Integer> wrapped = LiveList.suspendable(base);
    List<Integer> mirror = new ArrayList<>(wrapped);
    wrapped.addListener((Change<? extends Integer> change) -> {
        while(change.next()) {
            if(change.wasPermutated()) {
                List<Integer> newMirror = new ArrayList<>(mirror);
                for(int i = 0; i < mirror.size(); ++i) {
                    newMirror.set(change.getPermutation(i), mirror.get(i));
                }
                mirror.clear();
                mirror.addAll(newMirror);
            } else {
                List<Integer> sub = mirror.subList(change.getFrom(), change.getFrom() + change.getRemovedSize());
                sub.clear();
                sub.addAll(change.getAddedSubList());
            }
        }
    });

    wrapped.suspendWhile(() -> {
        base.addAll(2, Arrays.asList(12, 11, 13));
        base.remove(7, 9);
        base.subList(8,  10).replaceAll(i -> i + 20);
        base.subList(4, 9).clear();
        base.addAll(4, Arrays.asList(16, 18, 25));
        base.sort(null);
        assertEquals(Arrays.asList(10, 9, 8, 7, 6, 5, 4, 3, 2, 1), mirror);
    });

    assertEquals(Arrays.asList(1, 9, 10, 11, 12, 16, 18, 22, 25), mirror);
}
 
Example #8
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 #9
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;
}
 
Example #10
Source File: Canvas.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private void defineShapeListBindingOnRemoved(final @NotNull Change<? extends Shape> evt) {
	evt.getRemoved().forEach(sh -> {
		final ViewShape<?> toRemove = shapesToViewMap.remove(sh);
		shapesPane.getChildren().remove(toRemove);
		toRemove.flush();
	});
}
 
Example #11
Source File: Canvas.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private void defineShapeListBindingOnAdd(final @NotNull Change<? extends Shape> evt) {
	final List<? extends Shape> added = List.copyOf(evt.getAddedSubList());
	Platform.runLater(() -> added.forEach(sh -> viewFactory.createView(sh).ifPresent(v -> {
		final int index = drawing.getShapes().indexOf(sh);
		if(index != -1) {
			shapesToViewMap.put(sh, v);
			if(index == drawing.size()) {
				shapesPane.getChildren().add(v);
			}else {
				shapesPane.getChildren().add(index, v);
			}
		}
	})));
}
 
Example #12
Source File: Canvas.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private final void defineShapeListToViewBinding() {
	drawing.getShapes().addListener((Change<? extends Shape> evt) -> {
		while(evt.next()) {
			if(evt.wasAdded()) {
				defineShapeListBindingOnAdd(evt);
			}
			if(evt.wasRemoved()) {
				defineShapeListBindingOnRemoved(evt);
			}
		}
	});
}
 
Example #13
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 #14
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 #15
Source File: Deck.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * 艦隊が変更された時のリスナー
 */
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);
}
 
Example #16
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 #17
Source File: ReadOnlyListWrapperEx.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void fireValueChangedEvent(
		ListChangeListener.Change<? extends E> change) {
	if (helper != null) {
		helper.fireValueChangedEvent(change);
	}
	if (readOnlyProperty != null) {
		readOnlyProperty.fireValueChangedEvent(change);
	}
}
 
Example #18
Source File: Flyout.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
    * 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);
       
   }
 
Example #19
Source File: JavaFXUtil.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
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);
    });
}
 
Example #20
Source File: ListListenerHelperEx.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Notifies all attached {@link InvalidationListener}s and
 * {@link ListChangeListener}s about the change.
 *
 * @param change
 *            The change to notify listeners about.
 */
public void fireValueChangedEvent(
		ListChangeListener.Change<? extends E> change) {
	notifyInvalidationListeners();
	if (change != null) {
		notifyListChangeListeners(change);
	}
}
 
Example #21
Source File: CollectionUtils.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Computes the previous contents of the source {@link ObservableList}
 * before the given {@link javafx.collections.ListChangeListener.Change} was
 * applied.
 *
 * @param <E>
 *            The element type of the {@link ObservableList}.
 * @param change
 *            The {@link javafx.collections.ListChangeListener.Change} for
 *            which to compute the previous contents.
 * @return A newly created {@link List} that resembles the state of the
 *         source {@link ObservableList} before the change.
 */
public static <E> List<E> getPreviousContents(
		ListChangeListener.Change<E> change) {
	if (change instanceof AtomicChange) {
		return ((AtomicChange<E>) change).getPreviousContents();
	}

	ObservableList<E> currentList = change.getList();
	ObservableList<E> previousList = FXCollections
			.observableArrayList(currentList);

	// walk over elementary changes and record them in a list
	change.reset();
	List<ElementarySubChange<E>> changes = ListListenerHelperEx
			.getElementaryChanges(change);

	// undo the changes in reverse order
	for (int i = changes.size() - 1; i >= 0; i--) {
		ElementarySubChange<E> c = changes.get(i);
		int from = c.getFrom();
		int to = c.getTo();
		if (ElementarySubChange.Kind.ADD.equals(c.getKind())
				|| ElementarySubChange.Kind.REPLACE.equals(c.getKind())) {
			// remove added elements
			for (int j = to - 1; j >= from; j--) {
				previousList.remove(j);
			}
		}
		if (ElementarySubChange.Kind.REMOVE.equals(c.getKind())
				|| ElementarySubChange.Kind.REPLACE.equals(c.getKind())) {
			// add removed elements
			List<E> removed = c.getRemoved();
			previousList.addAll(from, removed);
		}
		if (ElementarySubChange.Kind.PERMUTATE.equals(c.getKind())) {
			// create sub list with old permutation
			int[] permutation = c.getPermutation();
			List<E> subList = new ArrayList<>(to - from);
			for (int j = from; j < to; j++) {
				int k = permutation[j - from];
				subList.add(currentList.get(k));
			}
			// insert sub list at correct position
			previousList.remove(from, to);
			previousList.addAll(from, subList);
		}
	}
	return previousList;
}
 
Example #22
Source File: EditAxis.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
private void axesChangedHandler(@SuppressWarnings("unused") Change<? extends Axis> ch) { // parameter for EventHandler api
    removeMouseEventHandlers(null);
    addMouseEventHandlers(getChart());
}
 
Example #23
Source File: SimpleListPropertyEx.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void fireValueChangedEvent(Change<? extends E> change) {
	if (helper != null) {
		helper.fireValueChangedEvent(change);
	}
}
 
Example #24
Source File: ReadOnlyListPropertyBaseEx.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void fireValueChangedEvent(Change<? extends E> change) {
	if (helper != null) {
		helper.fireValueChangedEvent(change);
	}
}
 
Example #25
Source File: ReadOnlyListWrapperEx.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
private void fireValueChangedEvent(Change<? extends E> change) {
	if (helper == null) {
		helper = new ListExpressionHelperEx<>(this);
	}
	helper.fireValueChangedEvent(change);
}
 
Example #26
Source File: GenericStyledArea.java    From RichTextFX with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Highlights the line that the main caret is on.<br>
 * Line highlighting automatically follows the caret.
 */
public void setLineHighlighterOn( boolean show )
{
    if ( show )
    {
        if ( lineHighlighter != null ) return;
        
        lineHighlighter = new SelectionImpl<>( "line-highlighter", this, path ->
        {
            if ( lineHighlighterFill == null ) path.setHighlightFill( Color.YELLOW );
            else path.highlightFillProperty().bind( lineHighlighterFill );
            
            path.getElements().addListener( (Change<? extends PathElement> chg) -> 
            {
                if ( chg.next() && chg.wasAdded() || chg.wasReplaced() ) {
                    double width = getLayoutBounds().getWidth();
                    // The path is limited to the bounds of the text, so here it's altered to the area's width
                    chg.getAddedSubList().stream().skip(1).limit(2).forEach( ele -> ((LineTo) ele).setX( width ) );
                    // The path can wrap onto another line if enough text is inserted, so here it's trimmed
                    if ( chg.getAddedSize() > 5 ) path.getElements().remove( 5, 10 );
                    // Highlight masks the downward selection of text on the last line, so move it behind
                    path.toBack();
                }
            } );
        } );
        
        Runnable adjustHighlighterRange = () ->
        {
            if ( lineHighlighter != null )
            {
                int p = getCurrentParagraph();
                int start = getCurrentLineStartInParargraph();
                int end = getCurrentLineEndInParargraph();
                if (end == 0) end++;// +1 for empty lines
                lineHighlighter.selectRange( p, start, p, end );
            }
        };
        
        Consumer<Bounds> caretListener = b -> 
        {
            if ( b.getMinY() != caretPrevY || getCaretColumn() == 1 ) {
            	adjustHighlighterRange.run();
                caretPrevY = b.getMinY();
            }
        };
        
        widthProperty().addListener( (ob,ov,nv) -> Platform.runLater( adjustHighlighterRange ) );
        caretBoundsProperty().addListener( (ob,ov,nv) -> nv.ifPresent( caretListener ) );
        getCaretBounds().ifPresent( caretListener );
        selectionSet.add( lineHighlighter );
    }
    else if ( lineHighlighter != null ) {
        selectionSet.remove( lineHighlighter );
        lineHighlighter.deselect();
        lineHighlighter = null;
        caretPrevY = -1;
    }
}
 
Example #27
Source File: MappedList.java    From EasyBind with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected void sourceChanged(Change<? extends F> c) {
    fireChange(new Change<E>(this) {

        @Override
        public boolean wasAdded() {
            return c.wasAdded();
        }

        @Override
        public boolean wasRemoved() {
            return c.wasRemoved();
        }

        @Override
        public boolean wasReplaced() {
            return c.wasReplaced();
        }

        @Override
        public boolean wasUpdated() {
            return c.wasUpdated();
        }

        @Override
        public boolean wasPermutated() {
            return c.wasPermutated();
        }

        @Override
        public int getPermutation(int i) {
            return c.getPermutation(i);
        }

        @Override
        protected int[] getPermutation() {
            // This method is only called by the superclass methods
            // wasPermutated() and getPermutation(int), which are
            // both overriden by this class. There is no other way
            // this method can be called.
            throw new AssertionError("Unreachable code");
        }

        @Override
        public List<E> getRemoved() {
            ArrayList<E> res = new ArrayList<>(c.getRemovedSize());
            for(F e: c.getRemoved()) {
                res.add(mapper.apply(e));
            }
            return res;
        }

        @Override
        public int getFrom() {
            return c.getFrom();
        }

        @Override
        public int getTo() {
            return c.getTo();
        }

        @Override
        public boolean next() {
            return c.next();
        }

        @Override
        public void reset() {
            c.reset();
        }
    });
}
 
Example #28
Source File: RefImplToolBar.java    From FXMaps with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates and returns the control for loading maps
 * @return  the control for loading stored maps
 */
public GridPane getRouteControl() {
    GridPane gp = new GridPane();
    gp.setPadding(new Insets(5, 5, 5, 5));
    gp.setHgap(5);
    gp.setVgap(5);
    
    newRouteField = new TextField();
    newRouteField.setDisable(true);
    newRouteField.setOnAction(e -> {
        newRouteField.setDisable(true);
        String text = newRouteField.getText();
        newRouteField.clear();
        if(routeCombo.getItems().contains(text)) return;
        routeCombo.getItems().add(text);
        routeCombo.getCheckModel().check(text);
        Route newRoute = new Route(text);
        map.addRoute(newRoute);
        map.selectRoute(newRoute);
    });
    
    Button addNew = new Button("New");
    addNew.setOnAction(e -> {
        newRouteField.requestFocus();
        newRouteField.setDisable(false);
    });
    
    HBox rsMode = new HBox();
    addWaypointBox = new CheckBox("Add Waypoints");
    addWaypointBox.setTextFill(Color.WHITE);
    addWaypointBox.setOnAction(e -> {
        map.setMode(addWaypointBox.isSelected() ? Mode.ADD_WAYPOINTS : Mode.NORMAL);
        
        if(map.getCurrentRoute() != null) {
            MarkerType.reset(map.getCurrentRoute());
        }
    });
    rsMode.getChildren().add(addWaypointBox);
    Label l = new Label("Select or enter route name:");
    l.setFont(Font.font(l.getFont().getFamily(), 12));
    l.setTextFill(Color.WHITE);
    routeCombo.getCheckModel().getCheckedItems().addListener((Change<? extends String> c) -> {
        // Set the current Route pointer in the map
        alterSelection(c);
        
        map.eraseMap();
        List<String> items = routeCombo.getCheckModel().getCheckedItems();
        List<Route> routes = null;
        PersistentMap selectedMap = map.getMapStore().getMap(map.getMapStore().getSelectedMapName());
        if(items != null && items.size() > 0) {
            routes = items.stream().map(s -> selectedMap.getRoute(s)).collect(Collectors.toList());
        }else{
            return;
        }
        map.displayRoutes(routes);
    });
    Button clr = new Button("Clear route");
    clr.setOnAction(e -> routeCombo.getCheckModel()
        .getCheckedItems().stream().forEach(s -> map.clearRoute(map.getRoute(s))));
    Button del = new Button("Delete route");
    del.setOnAction(e -> routeCombo.getCheckModel()
        .getCheckedItems().stream().forEach(s -> {
            Route r = map.getRoute(s);
            map.eraseRoute(r);
            map.removeRoute(r);
        }));
    
    gp.add(l, 0, 0, 2, 1);
    gp.add(newRouteField, 0, 1, 2, 1);
    gp.add(addNew, 2, 1, 1, 1);
    gp.add(new Separator(), 0, 2, 5, 1);
    gp.add(rsMode, 2, 0, 2, 1);
    gp.add(routeCombo, 0, 3, 2, 1);
    gp.add(clr, 2, 3);
    gp.add(del, 3, 3);
    
    return gp;
}
 
Example #29
Source File: Deck.java    From logbook-kai with MIT License 4 votes vote down vote up
/**
 * 編成記録のリストが変更された時のリスナー
 *
 */
private void changeDeckList(Change<?> change) {
    AppDeckCollection.get().getDecks().clear();
    AppDeckCollection.get().getDecks().addAll(this.deckList.getItems());
}
 
Example #30
Source File: PopupSelectboxContainer.java    From logbook-kai with MIT License 4 votes vote down vote up
void reset(Change<? extends T> change) {
    ObservableList<T> items = this.items.get();
    this.page.setPageCount((int) Math.max(Math.ceil(((double) items.size()) / this.maxPageItem.get()), 1));
    this.page.setCurrentPageIndex(0);
    this.page.setPageFactory(new PageFactory());
}