本文整理汇总了Java中javafx.collections.SetChangeListener类的典型用法代码示例。如果您正苦于以下问题:Java SetChangeListener类的具体用法?Java SetChangeListener怎么用?Java SetChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SetChangeListener类属于javafx.collections包,在下文中一共展示了SetChangeListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VertexSelectionModel
import javafx.collections.SetChangeListener; //导入依赖的package包/类
/**
* Constructor
*
* @param items 0 or more items
*/
@SafeVarargs
public VertexSelectionModel(T... items) {
this.items = Arrays.copyOf(items, items.length); // use copy for safety
selectedIndices = FXCollections.observableSet();
// setup unmodifiable lists
{
// first setup observable array lists that listen for changes of the selectedIndices set
final ObservableList<Integer> selectedIndicesAsList = FXCollections.observableArrayList();
final ObservableList<T> selectedItems = FXCollections.observableArrayList();
selectedIndices.addListener((SetChangeListener<Integer>) c -> {
if (c.wasAdded()) {
selectedIndicesAsList.add(c.getElementAdded());
selectedItems.add(getItems()[c.getElementAdded()]);
} else if (c.wasRemoved()) {
selectedIndicesAsList.remove(c.getElementRemoved());
selectedItems.remove(getItems()[c.getElementRemoved()]);
}
});
// wrap a unmodifiable observable list around the observable arrays lists
unmodifiableSelectedIndices = FXCollections.unmodifiableObservableList(selectedIndicesAsList);
unmodifiableSelectedItems = FXCollections.unmodifiableObservableList(selectedItems);
}
}
示例2: TimeGraphDrawnEventLayer
import javafx.collections.SetChangeListener; //导入依赖的package包/类
public TimeGraphDrawnEventLayer(TimeGraphWidget widget, Group parentGroup) {
super(widget, parentGroup);
ObservableSet<TimeGraphDrawnEventProvider> providers = TimeGraphDrawnEventProviderManager.instance().getRegisteredProviders();
/* Populate with the initial values */
providers.forEach(this::trackEventProvider);
/* Add listeners to track registered/deregistered providers */
providers.addListener((SetChangeListener<TimeGraphDrawnEventProvider>) change -> {
if (change == null) {
return;
}
TimeGraphDrawnEventProvider addedProvider = change.getElementAdded();
if (addedProvider != null) {
trackEventProvider(addedProvider);
}
TimeGraphDrawnEventProvider removedProvider = change.getElementRemoved();
if (removedProvider != null) {
untrackEventProvider(removedProvider);
}
});
filterListener = new DrawnEventFilterListener(getWidget());
}
示例3: addFileChoosers
import javafx.collections.SetChangeListener; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public WizardStepBuilder addFileChoosers(final String fieldName, final String fileChooseLabel,
final String startDir, final FileChooser.ExtensionFilter... filters)
{
final WizardStep current = this.current;
final HBox box = new HBox();
final JFXButton button = new JFXButton(fileChooseLabel);
button.setStyle("-fx-text-fill: BLACK;-fx-font-size: 18px;-fx-opacity: 0.7;");
final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(fileChooseLabel);
fileChooser.setInitialDirectory(new File(startDir));
fileChooser.getExtensionFilters().addAll(filters);
this.current.getData().put(fieldName, new SimpleSetProperty<File>());
button.setOnAction(e -> current.getData().get(fieldName)
.setValue(fileChooser.showOpenMultipleDialog(MineIDE.primaryStage)));
final Label label = new Label(fieldName);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setHalignment(button, HPos.LEFT);
this.current.add(label, 0, this.current.getData().size() - 1);
final JFXTextField text = new JFXTextField();
text.setEditable(false);
((SimpleSetProperty<File>) this.current.getData().get(fieldName))
.addListener((SetChangeListener<File>) change ->
{
text.setText("");
change.getSet().forEach(file -> text.appendText(file.getAbsolutePath() + ", "));
text.setText(text.getText().substring(0, text.getText().length() - 2));
});
box.getChildren().addAll(text, button);
this.current.add(box, 1, this.current.getData().size() - 1);
return this;
}
示例4: init
import javafx.collections.SetChangeListener; //导入依赖的package包/类
private void init() {
editableState = false;
Platform.runLater(this::updateVisibleText);
// Register listeners and binds
editableLabel.getPseudoClassStates().addListener( (SetChangeListener<PseudoClass>) e -> {
if (e.getSet().contains(PseudoClass.getPseudoClass("editable"))) {
if ( !editableState ) {
// editableState change to editable
editableState = true;
updateVisibleText();
}
} else {
if ( editableState ) {
// editableState change to not editable
editableState = false;
updateVisibleText();
}
}
});
editableLabel.widthProperty().addListener( observable -> updateVisibleText() );
editableLabel.baseTextProperty().addListener( observable -> updateVisibleText() );
}
示例5: mergeSet
import javafx.collections.SetChangeListener; //导入依赖的package包/类
@SafeVarargs
public static <T, E> void mergeSet(Function<? super E, ? extends T> mapper,
ObservableSet<T> into, ObservableSet<E>... sets) {
final ObservableSet<T> set = into;
for (ObservableSet<E> s : sets) {
for (E item : s) {
set.add(mapper.apply(item));
}
s.addListener((SetChangeListener<E>) c -> {
if (c.wasAdded()) {
set.add(mapper.apply(c.getElementAdded()));
}
if (c.wasRemoved()) {
set.remove(mapper.apply(c.getElementRemoved()));
}
});
}
}
示例6: ArmaDisplay
import javafx.collections.SetChangeListener; //导入依赖的package包/类
public ArmaDisplay() {
controlsMerged.add(getBackgroundControls());
controlsMerged.add(getControls());
displayProperties.add(iddProperty);
displayProperties.addListener(new SetChangeListener<DisplayProperty>() {
@Override
public void onChanged(Change<? extends DisplayProperty> change) {
if (change.wasRemoved() && change.getElementRemoved().getPropertyLookup() == DisplayPropertyLookup.IDD) {
throw new IllegalStateException("can't remove idd from display");
}
}
});
}
示例7: DisplayPropertiesEditorPane
import javafx.collections.SetChangeListener; //导入依赖的package包/类
/**
@param display display to edit
*/
public DisplayPropertiesEditorPane(@NotNull ArmaDisplay display) {
initRootPane();
initAddDisplayPropertyMB();
this.display = display;
addPropertyEditors();
display.getDisplayProperties().addListener(new SetChangeListener<DisplayProperty>() {
@Override
public void onChanged(Change<? extends DisplayProperty> change) {
if (change.wasAdded()) {
addPropertyEditor(change.getElementAdded());
} else if (change.wasRemoved()) {
removePropertyEditor(change.getElementRemoved());
}
}
});
}
示例8: onChanged
import javafx.collections.SetChangeListener; //导入依赖的package包/类
@Override
public void onChanged(SetChangeListener.Change<? extends E> change)
{
final Set<T> set = setRef.get();
if (set == null)
{
change.getSet().removeListener(this);
}
else
{
if (change.wasRemoved())
{
set.remove(converter.convert(change.getElementRemoved()));
}
else
{
set.add(converter.convert(change.getElementAdded()));
}
}
}
示例9: getModpackTreeItem
import javafx.collections.SetChangeListener; //导入依赖的package包/类
private TreeItem<Object> getModpackTreeItem(Modpack modpack) {
TreeItem<Object> item = new TreeItem<>(modpack);
for (ModReference mod : modpack.getMods()) {
item.getChildren().add(getModTreeItem(mod));
}
modpack.getMods().addListener((SetChangeListener<ModReference>) change -> {
if (change.wasAdded()) {
Platform.runLater(() -> item.getChildren().add(getModTreeItem(change.getElementAdded())));
} else if (change.wasRemoved()) {
Platform.runLater(() -> {
item.getChildren().stream().filter(item2 -> item2.getValue() == change.getElementRemoved()).findAny().ifPresent(item3 -> item.getChildren().remove(item3));
});
}
});
return item;
}
示例10: onChange
import javafx.collections.SetChangeListener; //导入依赖的package包/类
@SuppressWarnings("unused")
private void onChange(SetChangeListener.Change<? extends String> change) {
slices.getChildren().clear();
if (styles.isEmpty()) {
return;
}
int start = 0;
int delta = FULLCIRCLE / styles.size();
for (String style : styles) {
Arc arc = new Arc(0, 0, radius, radius, start, delta);
arc.setType(ArcType.ROUND);
arc.getStyleClass().add(style);
slices.getChildren().add(arc);
start += delta;
}
}
示例11: SearchResultPane
import javafx.collections.SetChangeListener; //导入依赖的package包/类
public SearchResultPane(final ImportPgpKeyFromServerData importPgpKeyFromServerData) {
this.importPgpKeyFromServerData = assertNotNull(importPgpKeyFromServerData, "importPgpKeyFromServerData"); //$NON-NLS-1$
loadDynamicComponentFxml(SearchResultPane.class, this);
pgpKeyTreePane.getCheckBoxVisibleForPgpKeyTreeItemClasses().add(PgpKeyPgpKeyTreeItem.class);
pgpKeyTreePane.getCheckedTreeItems().addListener(new SetChangeListener<PgpKeyTreeItem<?>>() {
@Override
public void onChanged(SetChangeListener.Change<? extends PgpKeyTreeItem<?>> change) {
final PgpKeyTreeItem<?> elementAdded = change.getElementAdded();
if (elementAdded instanceof PgpKeyPgpKeyTreeItem)
importPgpKeyFromServerData.getSelectedPgpKeyIds().add(((PgpKeyPgpKeyTreeItem)elementAdded).getPgpKey().getPgpKeyId());
final PgpKeyTreeItem<?> elementRemoved = change.getElementRemoved();
if (elementRemoved instanceof PgpKeyPgpKeyTreeItem)
importPgpKeyFromServerData.getSelectedPgpKeyIds().remove(((PgpKeyPgpKeyTreeItem)elementRemoved).getPgpKey().getPgpKeyId());
}
});
importPgpKeyFromServerData.getSelectedPgpKeyIds().addListener((InvalidationListener) observable -> updateComplete());
}
示例12: PgpKeyTreePane
import javafx.collections.SetChangeListener; //导入依赖的package包/类
public PgpKeyTreePane() {
loadDynamicComponentFxml(PgpKeyTreePane.class, this);
treeTableView.setShowRoot(false);
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
nameTreeTableColumn.setCellFactory(new Callback<TreeTableColumn<PgpKeyTreeItem<?>,String>, TreeTableCell<PgpKeyTreeItem<?>,String>>() {
@Override
public TreeTableCell<PgpKeyTreeItem<?>, String> call(TreeTableColumn<PgpKeyTreeItem<?>, String> param) {
return new NameCell();
}
});
checkedTreeItems.addListener(new SetChangeListener<PgpKeyTreeItem<?>>() {
@Override
public void onChanged(SetChangeListener.Change<? extends PgpKeyTreeItem<?>> change) {
final PgpKeyTreeItem<?> elementAdded = change.getElementAdded();
if (elementAdded != null)
elementAdded.setChecked(true);
final PgpKeyTreeItem<?> elementRemoved = change.getElementRemoved();
if (elementRemoved != null)
elementRemoved.setChecked(false);
}
});
}
示例13: ValueSetAttribute
import javafx.collections.SetChangeListener; //导入依赖的package包/类
public ValueSetAttribute(Class<T> itemType) {
super(null);
this.itemType = itemType;
final ObservableSet<T> observableSet = FXCollections.observableSet(new HashSet<>());
value= observableSet;
observableSet.addListener((SetChangeListener<T>) change -> {
updateListeners(get());
});
}
示例14: RelatedAnimeFinderService
import javafx.collections.SetChangeListener; //导入依赖的package包/类
/**
* @param cache
* Instance of the cache.
* @param app
* Instance of the manami app.
* @param list
* List which being checked for related anime.
* @param observer
* Observer which is being notified about the progress. It also
* gets the result as a list through notification.
*/
public RelatedAnimeFinderService(final Cache cache, final Manami app, final List<? extends MinimalEntry> list, final Observer observer) {
this.app = app;
this.cache = cache;
this.list = list;
addObserver(observer);
myAnime = newArrayList();
relatedAnime = newHashMap();
animeToCheck = new Stack<>();
checkedAnime = new ObservableSetWrapper<>(newHashSet());
checkedAnime.addListener((SetChangeListener<InfoLink>) event -> {
setChanged();
notifyObservers(new ProgressState(checkedAnime.size() + 1, animeToCheck.size()));
});
}
示例15: onChanged
import javafx.collections.SetChangeListener; //导入依赖的package包/类
@Override
public void onChanged(final SetChangeListener.Change<? extends User> c) {
final User userAdded = c.getElementAdded();
if (userAdded != null) {
addTreeItemsViewCallback(Collections.singleton(userAdded));
selectUser(userAdded);
}
final User userRemoved = c.getElementRemoved();
if (userRemoved != null)
removeTreeItemsViewCallback(Collections.singleton(userRemoved));
}