/** * 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); } }
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()); }
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() ); }
@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())); } }); } }
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"); } } }); }
/** @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()); } } }); }
@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())); } } }
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; }
@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; } }
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()); }
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); } }); }
@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; }
@SafeVarargs public static <T> void mergeSet(ObservableSet<T> into, ObservableSet<T>... sets) { final ObservableSet<T> set = into; for (ObservableSet<T> s : sets) { set.addAll(s); s.addListener((SetChangeListener<T>) c -> { if (c.wasAdded()) { set.add(c.getElementAdded()); } if (c.wasRemoved()) { set.remove(c.getElementRemoved()); } }); } }
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()); }); }
/** * @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())); }); }
@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)); }
public SelectKeyPane(final AssignOwnerTrustData assignOwnerTrustData) { this.assignOwnerTrustData = assertNotNull(assignOwnerTrustData, "assignOwnerTrustData"); loadDynamicComponentFxml(SelectKeyPane.class, this); assignOwnerTrustData.assignToAllPgpKeysProperty().addListener(assignToAllPgpKeysChangeListener); toggleGroup.selectedToggleProperty().addListener(toggleGroupSelectedToggleListener); assignOwnerTrustData.ownerTrustProperty().addListener(ownerTrustListener); pgpKeyTreePane.getCheckBoxVisibleForPgpKeyTreeItemClasses().add(PgpKeyPgpKeyTreeItem.class); final UserRootPgpKeyTreeItem root = new UserRootPgpKeyTreeItem(pgpKeyTreePane, assignOwnerTrustData.getUser()); pgpKeyTreePane.getTreeTableView().setRoot(root); for (TreeItem<PgpKeyTreeItem<?>> treeItem : root.getChildren()) { if (treeItem instanceof PgpKeyPgpKeyTreeItem) { PgpKeyPgpKeyTreeItem ti = (PgpKeyPgpKeyTreeItem) treeItem; ti.setChecked(assignOwnerTrustData.getPgpKeys().contains(ti.getPgpKey())); } } pgpKeyTreePane.getCheckedTreeItems().addListener(new SetChangeListener<PgpKeyTreeItem<?>>() { @Override public void onChanged(SetChangeListener.Change<? extends PgpKeyTreeItem<?>> change) { final PgpKeyTreeItem<?> elementAdded = change.getElementAdded(); if (elementAdded instanceof PgpKeyPgpKeyTreeItem) assignOwnerTrustData.getPgpKeys().add(((PgpKeyPgpKeyTreeItem)elementAdded).getPgpKey()); final PgpKeyTreeItem<?> elementRemoved = change.getElementRemoved(); if (elementRemoved instanceof PgpKeyPgpKeyTreeItem) assignOwnerTrustData.getPgpKeys().remove(((PgpKeyPgpKeyTreeItem)elementRemoved).getPgpKey()); assignToSelectedPgpKeysRadioButton.setSelected(true); updateComplete(); } }); }
@Override public void onChanged(final SetChangeListener.Change<? extends File> c) { assertFxApplicationThread(); if (c.getElementRemoved() != null) unselectTreeItemForUnselectedFile(c.getElementRemoved()); if (c.getElementAdded() != null) selectFileTreeItemForSelectedFile(c.getElementAdded()); updateDisable(); }
@Override public void readPersisted() { UserPayload persisted = storage.initAndGetPersistedWithFileName("UserPayload", 100); userPayload = persisted != null ? persisted : new UserPayload(); checkNotNull(userPayload.getPaymentAccounts(), "userPayload.getPaymentAccounts() must not be null"); checkNotNull(userPayload.getAcceptedLanguageLocaleCodes(), "userPayload.getAcceptedLanguageLocaleCodes() must not be null"); paymentAccountsAsObservable = FXCollections.observableSet(userPayload.getPaymentAccounts()); currentPaymentAccountProperty = new SimpleObjectProperty<>(userPayload.getCurrentPaymentAccount()); userPayload.setAccountId(String.valueOf(Math.abs(keyRing.getPubKeyRing().hashCode()))); // language setup if (!userPayload.getAcceptedLanguageLocaleCodes().contains(LanguageUtil.getDefaultLanguageLocaleAsCode())) userPayload.getAcceptedLanguageLocaleCodes().add(LanguageUtil.getDefaultLanguageLocaleAsCode()); String english = LanguageUtil.getEnglishLanguageLocaleCode(); if (!userPayload.getAcceptedLanguageLocaleCodes().contains(english)) userPayload.getAcceptedLanguageLocaleCodes().add(english); paymentAccountsAsObservable.addListener((SetChangeListener<PaymentAccount>) change -> { userPayload.setPaymentAccounts(new HashSet<>(paymentAccountsAsObservable)); persist(); }); currentPaymentAccountProperty.addListener((ov) -> { userPayload.setCurrentPaymentAccount(currentPaymentAccountProperty.get()); persist(); }); }
public static <T> EventStream<SetChangeListener.Change<? extends T>> changesOf(ObservableSet<T> set) { return new EventStreamBase<SetChangeListener.Change<? extends T>>() { @Override protected Subscription observeInputs() { SetChangeListener<T> listener = c -> emit(c); set.addListener(listener); return () -> set.removeListener(listener); } }; }
public void subscribe(final SetChangeListener<Status> tweetChangeListener) { loadedTweets.addListener(tweetChangeListener); }
/** * {@inheritDoc} */ @Override public final void onChanged( SetChangeListener.Change<? extends Object> change) { syncCollectionValues(getDirty(), true, false, null, change, null); }
private void setupModsListView() { listViewMods.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); listViewMods.setCellFactory(CheckBoxListCell.forListView(new Callback<ModRow, ObservableValue<Boolean>>() { @Override public ObservableValue<Boolean> call(ModRow item) { return item.onProperty(); } })); // Set up filtered data FilteredList<ModRow> filteredModsByText = new FilteredList<>(modList.getMods(), p -> true); FilteredList<ModRow> filteredModsByStatus = new FilteredList<>(filteredModsByText, p -> true); // filter with name textFieldModsFilter.textProperty().addListener((observable, oldValue, newValue) -> { filteredModsByText.setPredicate(modRow -> { // If filter text is empty, display all persons. if (newValue == null || newValue.isEmpty()) { return true; } // Compare first name and last name of every modRow with filter text. String lowerCaseFilter = newValue.toLowerCase(); if (modRow.getFile() != null && modRow.getFile().getName().toLowerCase().contains(lowerCaseFilter)) { return true; // Filter matches name. } return false; // Does not match. }); }); toggleGrooupMods.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { if (toggleGrooupMods.getSelectedToggle() != null) { System.out.println(toggleGrooupMods.getSelectedToggle()); if (radioButtonModsAll.isSelected()) { filteredModsByStatus.setPredicate(row -> { return true; }); } else if (radioButtonModsEnabled.isSelected()) { filteredModsByStatus.setPredicate(row -> { return row.isChecked(); }); } else if (radioButtonModsDisabled.isSelected()) { filteredModsByStatus.setPredicate(row -> { return !row.isChecked(); }); } else { log.error("what?"); } } } }); listViewMods.setItems(filteredModsByStatus); modList.getEnabled().addListener(new SetChangeListener<ModRow>() { @Override public void onChanged(Change<? extends ModRow> c) { log.debug("modified: c=" + c); labelEanbledModsCount.setText(ResStrings.get("label.enabled.mods") + ": " + modList.getEnabled().size()); } }); loadModList(); }
public void addListenerToBuyerSet(SetChangeListener<? super EconomicAgent> setChangeListener) { buyers.addListener(setChangeListener); }
public void addListenerToSellerSet(SetChangeListener<? super EconomicAgent> setChangeListener) { sellers.addListener(setChangeListener); }
public void removeListenerFromBuyerSet(SetChangeListener<? super EconomicAgent> setChangeListener) { buyers.removeListener(setChangeListener); }
public void removeListenerFromSellerSet(SetChangeListener<? super EconomicAgent> setChangeListener) { sellers.removeListener(setChangeListener); }
public GraphViewMXGraph(BiConsumer<MouseEvent, IBase> clickHandler) { this.clickHandler = clickHandler; mxGraph = new mxGraph(); mxGraphModel = mxGraph.getModel(); mxGraphView = mxGraph.getView(); mxGraphLayout = new mxHierarchicalLayout(mxGraph, SwingConstants.NORTH); graphPane = new Pane(); selectedItems.addListener((SetChangeListener<? super IBase>) change -> updateSelectedNodes()); }