当前位置: 首页>>代码示例>>Java>>正文


Java SetChangeListener类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:jmueller95,项目名称:CORNETTO,代码行数:30,代码来源:VertexSelectionModel.java

示例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());
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:26,代码来源:TimeGraphDrawnEventLayer.java

示例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;
}
 
开发者ID:Leviathan-Studio,项目名称:MineIDE,代码行数:37,代码来源:WizardStepBuilder.java

示例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() );
}
 
开发者ID:vibridi,项目名称:fxutils,代码行数:25,代码来源:EditableLabelSkin.java

示例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()));
            }
        });
    }
}
 
开发者ID:stechy1,项目名称:drd,代码行数:19,代码来源:ObservableMergers.java

示例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");
			}
		}
	});

}
 
开发者ID:kayler-renslow,项目名称:arma-dialog-creator,代码行数:17,代码来源:ArmaDisplay.java

示例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());
			}
		}
	});
}
 
开发者ID:kayler-renslow,项目名称:arma-dialog-creator,代码行数:20,代码来源:DisplayPropertiesEditorPane.java

示例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()));
        }
    }
}
 
开发者ID:touwolf,项目名称:bridje-framework,代码行数:21,代码来源:SetContentBinding.java

示例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;
}
 
开发者ID:narrowtux,项目名称:SmartModInserter,代码行数:17,代码来源:ModpackTabController.java

示例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;
	}
}
 
开发者ID:ProgrammingLife2015,项目名称:dnainator,代码行数:19,代码来源:Pie.java

示例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());
}
 
开发者ID:subshare,项目名称:subshare,代码行数:21,代码来源:SearchResultPane.java

示例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);
		}
	});
}
 
开发者ID:subshare,项目名称:subshare,代码行数:27,代码来源:PgpKeyTreePane.java

示例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());
    });
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:11,代码来源:ValueSetAttribute.java

示例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()));
    });
}
 
开发者ID:manami-project,项目名称:manami,代码行数:26,代码来源:RelatedAnimeFinderService.java

示例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));
}
 
开发者ID:subshare,项目名称:subshare,代码行数:13,代码来源:UserListMainTreeItem.java


注:本文中的javafx.collections.SetChangeListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。