Java 类javafx.collections.ObservableSet 实例源码

项目:lttng-scope    文件:TimeGraphDrawnEventLayer.java   
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());
}
项目:drd    文件:ObservableMergers.java   
@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()));
            }
        });
    }
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testObservableSet(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableSet<CustomObject> setEmpty = FXCollections.emptyObservableSet();
    ObservableSet<CustomObject> setOne = FXCollections.observableSet(one);
    ObservableSet<CustomObject> setTwo = FXCollections.observableSet(one, two);

    Function<WithObsSet, ObservableSet<CustomObject>> getter = o -> o.set;
    BiConsumer<WithObsSet, ObservableSet<CustomObject>> setter = (o, s) -> o.set = s;

    testValue(WithObsSet.class, null, "{\"set\":null}", getter, setter, gson);
    testValue(WithObsSet.class, setEmpty, "{\"set\":[]}", getter, setter, gson);
    testValue(WithObsSet.class, setOne, "{\"set\":[{\"name\":\"myObj1\"}]}", getter, setter, gson);
    // do not check a particular JSON because the order is non-deterministic
    testValue(WithObsSet.class, setTwo, null, getter, setter, gson);
}
项目:sankey-javafx    文件:SankeyChart.java   
public SankeyChart(ObservableSet<SankeyNode> nodes,
                   ObservableSet<SankeyLink> links) {
    this.nodes = nodes;
    this.nodes.addListener(nodesChangeListener);
    this.newNodes.addAll(nodes);
    this.nodes.stream()
            .forEach(node -> node.setChart(this));

    this.links = links;
    this.links.addListener(linksChangeListener);
    this.links.stream()
            .forEach(link -> link.setChart(this));

    getChartChildren().addAll(links);
    getChartChildren().addAll(nodes);
}
项目:LoliXL    文件:VersionTagResolverImpl.java   
@Override
public ObservableSet<VersionTag> resolveTags(Version version) {
    return new SetBinding<VersionTag>() {

        {
            bind(solutions.getServiceList());
        }

        @Override
        protected ObservableSet<VersionTag> computeValue() {
            Set<VersionTag> result = new TreeSet<>();
            solutions.getServiceList().forEach(solution -> solution.resolve(version, result));
            return FXCollections.unmodifiableObservableSet(FXCollections.observableSet(result));
        }
    };
}
项目:bridje-framework    文件:ExContentBinding.java   
public static void unbind(Object obj1, Object obj2)
{
    checkParameters(obj1, obj2);
    if ((obj1 instanceof List) && (obj2 instanceof ObservableList))
    {
        ((ObservableList) obj2).removeListener(new ListContentBinding((List) obj1, null));
    }
    else if ((obj1 instanceof Set) && (obj2 instanceof ObservableSet))
    {
        ((ObservableSet) obj2).removeListener(new SetContentBinding((Set) obj1, null));
    }
    /*
    else if ((obj1 instanceof Map) && (obj2 instanceof ObservableMap))
    {
        ((ObservableMap) obj2).removeListener(new MapContentBinding((Map) obj1, null));
    }*/
}
项目:subshare    文件:LocalRepoDirectoryPane.java   
private Collection<CollisionPrivateDto> getSelectedFileTreeCollisionPrivateDtos() {
    final ObservableSet<File> selectedFiles = fileTreePane.getSelectedFiles();
    final List<CollisionPrivateDto> collisionPrivateDtos = new ArrayList<>();
    final Set<Uid> collisionIds = new HashSet<>();
    for (final File file : selectedFiles) {
        final FileTreeItem<?> treeItem = fileTreePane.getRootFileTreeItem().findFirst(file);
        if (treeItem != null) {
            final CollisionPrivateDtoSet collisionPrivateDtoSet = fileTreePane.getCollisionDtoSet(treeItem);
            if (collisionPrivateDtoSet != null) {
                for (CollisionPrivateDto collisionPrivateDto : collisionPrivateDtoSet.getAllCollisionPrivateDtos()) {
                    if (collisionIds.add(collisionPrivateDto.getCollisionId()))
                        collisionPrivateDtos.add(collisionPrivateDto);
                }
            }
        }
    }
    return collisionPrivateDtos;
}
项目:reta    文件:BufferingManager.java   
/**
 * @param bean
 *            bean instance
 * @param propertyName
 *            bean set property name
 * @return {@link ObservableSetBuffering} for the property
 * @param <T>
 *            set element type
 */
public <T> ObservableSetBuffering<T> bufferingSet(final Object bean, final String propertyName)
{
    ObservableSetBuffering<T> lb = null;
    @SuppressWarnings("unchecked")
    final Set<T> value = getPropertyValue(bean, propertyName, Set.class);
    if (value instanceof ObservableSet<?>)
    {
        lb = new ObservableSetBuffering<>(bean.getClass(), propertyName, (ObservableSet<T>) value);
    }
    else
    {
        lb = new ObservableSetBuffering<>(bean.getClass(), propertyName, FXCollections.observableSet(value));
    }
    add(lb);
    return lb;
}
项目:ReactFX    文件:Subscription.java   
/**
 * Dynamically subscribes to all elements of the given observable set.
 * When an element is added to the set, it is automatically subscribed to.
 * When an element is removed from the set, it is automatically unsubscribed
 * from.
 * @param elems observable set of elements that will be subscribed to
 * @param f function to subscribe to an element of the set.
 * @return An aggregate subscription that tracks elementary subscriptions.
 * When the returned subscription is unsubscribed, all elementary
 * subscriptions are unsubscribed as well, and no new elementary
 * subscriptions will be created.
 */
static <T> Subscription dynamic(
        ObservableSet<T> elems,
        Function<? super T, ? extends Subscription> f) {

    Map<T, Subscription> elemSubs = new HashMap<>();
    elems.forEach(t -> elemSubs.put(t, f.apply(t)));

    Subscription setSub = EventStreams.changesOf(elems).subscribe(ch -> {
        if(ch.wasRemoved()) {
            Subscription sub = elemSubs.remove(ch.getElementRemoved());
            assert sub != null;
            sub.unsubscribe();
        }
        if(ch.wasAdded()) {
            T elem = ch.getElementAdded();
            assert !elemSubs.containsKey(elem);
            elemSubs.put(elem, f.apply(elem));
        }
    });

    return () -> {
        setSub.unsubscribe();
        elemSubs.forEach((t, sub) -> sub.unsubscribe());
    };
}
项目:shuffleboard    文件:PluginLoader.java   
public ObservableSet<Plugin> getLoadedPlugins() {
  return FXCollections.unmodifiableObservableSet(loadedPlugins);
}
项目:drd    文件:ObservableMergers.java   
@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());
            }
        });
    }
}
项目:Java-9-Programming-Blueprints    文件:BeanPathAdapter.java   
/**
 * @see BeanPathAdapter.FieldBean#performOperation(String, String,
 *      Class, String, Observable, Class, SelectionModel, FieldProperty,
 *      FieldBeanOperation)
 */
public <T> FieldProperty<?, ?, ?> performOperation(
        final String fieldPath, final ObservableSet<T> observableSet,
        final Class<T> setValueClass, final String collectionItemPath,
        final Class<?> collectionItemPathType,
        final SelectionModel<T> selectionModel,
        final FieldProperty<?, ?, ?> itemMaster,
        final FieldBeanOperation operation) {
    return performOperation(fieldPath, fieldPath, setValueClass,
            collectionItemPath, (Observable) observableSet,
            collectionItemPathType, selectionModel, itemMaster,
            operation);
}
项目:fx-gson    文件:FxGsonBuilder.java   
/**
 * Creates a {@link GsonBuilder} instance pre-configured based on the current configuration. This method is NOT free
 * of side-effects to this {@code FxGsonBuilder} instance and hence should not be called multiple times.
 *
 * @return an instance of GsonBuilder configured with the options currently set in this builder
 */
public GsonBuilder builder() {
    // serialization of nulls is necessary to have properties with null values deserialized properly
    builder.serializeNulls()
           .registerTypeAdapter(ObservableList.class, new ObservableListCreator())
           .registerTypeAdapter(ObservableSet.class, new ObservableSetCreator())
           .registerTypeAdapter(ObservableMap.class, new ObservableMapCreator())
           .registerTypeAdapterFactory(new JavaFxPropertyTypeAdapterFactory(strictProperties, strictPrimitives));
    if (includeExtras) {
        builder.registerTypeAdapterFactory(new JavaFxExtraTypeAdapterFactory());
    }
    return builder;
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testSetProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableSet<CustomObject> setEmpty = FXCollections.emptyObservableSet();
    ObservableSet<CustomObject> setOne = FXCollections.observableSet(one);
    ObservableSet<CustomObject> setTwo = FXCollections.observableSet(one, two);

    testProperty(WithSetProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithSetProp.class, setEmpty, "{\"prop\":[]}", o -> o.prop, gson);
    testProperty(WithSetProp.class, setOne, "{\"prop\":[{\"name\":\"myObj1\"}]}", o -> o.prop, gson);
    // do not check a particular JSON because the order is non-deterministic
    testProperty(WithSetProp.class, setTwo, null, o -> o.prop, gson);
}
项目:javaone2016    文件:SearchCell.java   
private void changePseudoClass(ObservableSet<PseudoClass> pseudoClassStates) {
    pseudoClassStateChanged(oldPseudoClass, false);
    if (pseudoClassStates != null) {
        for (PseudoClass pseudoClass : pseudoClassStates) {
            if (!COMMON_CELL_PSEUDO_CLASSES.contains(pseudoClass.getPseudoClassName())) {
                pseudoClassStateChanged(pseudoClass, true);
                oldPseudoClass = pseudoClass;
                break;
            }
        }
    }
}
项目:factoryfx    文件:ValueSetAttribute.java   
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());
    });
}
项目:bridje-framework    文件:BiSetContentBinding.java   
@Override
public int hashCode()
{
    final ObservableSet<E> set1 = propertyRef1.get();
    final ObservableSet<T> set2 = propertyRef2.get();
    final int hc1 = (set1 == null) ? 0 : set1.hashCode();
    final int hc2 = (set2 == null) ? 0 : set2.hashCode();
    return hc1 * hc2;
}
项目:ReactFX    文件:EventStreams.java   
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);
        }
    };
}
项目:ReactFX    文件:EventStreams.java   
/**
 * Returns an event stream that emits all the events emitted from any of
 * the event streams in the given observable set. When an event stream is
 * added to the set, the returned stream will start emitting its events.
 * When an event stream is removed from the set, its events will no longer
 * be emitted from the returned stream.
 */
public static <T> EventStream<T> merge(
        ObservableSet<? extends EventStream<T>> set) {
    return new EventStreamBase<T>() {
        @Override
        protected Subscription observeInputs() {
            return Subscription.dynamic(set, s -> s.subscribe(this::emit));
        }
    };
}
项目:ReactFX    文件:EventStreams.java   
/**
 * A more general version of {@link #merge(ObservableSet)} for a set of
 * arbitrary element type and a function to obtain an event stream from
 * the element.
 * @param set observable set of elements
 * @param f function to obtain an event stream from an element
 */
public static <T, U> EventStream<U> merge(
        ObservableSet<? extends T> set,
        Function<? super T, ? extends EventStream<U>> f) {
    return new EventStreamBase<U>() {
        @Override
        protected Subscription observeInputs() {
            return Subscription.dynamic(
                    set,
                    t -> f.apply(t).subscribe(this::emit));
        }
    };
}
项目:Java-9-Programming-Blueprints    文件:BeanPathAdapter.java   
/**
 * Binds a {@link ObservableSet} by traversing the bean's field tree. An
 * additional item path can be specified when the path points to a
 * {@link Collection} that contains beans that also need traversed in order
 * to establish the final value. For example: If a field path points to
 * <code>phoneNumbers</code> (relative to the {@link #getBean()}) where
 * <code>phoneNumbers</code> is a {@link Collection} that contains
 * <code>PhoneNumber</code> instances which in turn have a field called
 * <code>areaCode</code> then an item path can be passed in addition to the
 * field path with <code>areaCode</code> as it's value.
 * 
 * @param fieldPath
 *            the <b><code>.</code></b> separated field paths relative to
 *            the {@link #getBean()} that will be traversed
 * @param itemFieldPath
 *            the <b><code>.</code></b> separated field paths relative to
 *            each item in the bean's underlying {@link Collection} that
 *            will be traversed (empty/null when each item value does not
 *            need traversed)
 * @param itemFieldPathType
 *            the {@link Class} of that the item path points to
 * @param set
 *            the {@link ObservableSet} to bind to the field class type of
 *            the property
 * @param setValueType
 *            the class type of the {@link ObservableSet} value
 * @param selectionModel
 *            the {@link SelectionModel} used to set the values within the
 *            {@link ObservableSet} <b>only applicable when the
 *            {@link ObservableSet} is used for selection(s) and therefore
 *            cannot be updated directly because it is read-only</b>
 * @param selectionModelItemMasterPath
 *            when binding to {@link SelectionModel} items, this will be the
 *            optional path to the collection field that contains all the
 *            items to select from
 */
public <E> void bindContentBidirectional(final String fieldPath,
        final String itemFieldPath, final Class<?> itemFieldPathType,
        final ObservableSet<E> set, final Class<E> setValueType,
        final SelectionModel<E> selectionModel,
        final String selectionModelItemMasterPath) {
    FieldProperty<?, ?, ?> itemMaster = null;
    if (selectionModelItemMasterPath != null
            && !selectionModelItemMasterPath.isEmpty()) {
        itemMaster = getRoot().performOperation(
                selectionModelItemMasterPath, set, setValueType,
                itemFieldPath, itemFieldPathType, null, null,
                FieldBeanOperation.CREATE_OR_FIND);
    }
    getRoot().performOperation(fieldPath, set, setValueType, itemFieldPath,
            itemFieldPathType, selectionModel, itemMaster,
            FieldBeanOperation.BIND);
}
项目:Java-9-Programming-Blueprints    文件:BeanPathAdapter.java   
/**
 * Adds/Removes the {@link FieldProperty} as a collection listener
 * 
 * @param observable
 *            the {@link Observable} collection/map to listen for
 *            changes on
 * @param add
 *            true to add, false to remove
 */
protected void addRemoveCollectionListener(final Observable observable,
        final boolean add) {
    final boolean isCol = getCollectionObservable() == observable;
    if (isCol
            && ((this.isCollectionListening && add) || (this.isCollectionListening && !add))) {
        return;
    }
    Boolean change = null;
    if (observable instanceof ObservableList) {
        final ObservableList<?> ol = (ObservableList<?>) observable;
        if (add) {
            ol.addListener(this);
            change = true;
        } else {
            ol.removeListener(this);
            change = false;
        }
    } else if (observable instanceof ObservableSet) {
        final ObservableSet<?> os = (ObservableSet<?>) observable;
        if (add) {
            os.addListener(this);
            change = true;
        } else {
            os.removeListener(this);
            change = false;
        }
    } else if (observable instanceof ObservableMap) {
        final ObservableMap<?, ?> om = (ObservableMap<?, ?>) observable;
        if (add) {
            om.addListener(this);
            change = true;
        } else {
            om.removeListener(this);
            change = false;
        }
    } else if (observable == null) {
        throw new IllegalStateException(String.format(
                "Observable collection/map bound to %1$s (item path: %2$s) "
                        + "has been garbage collected",
                this.fieldHandle.getFieldName(),
                this.collectionItemPath, observable,
                this.getFieldType()));
    } else {
        throw new UnsupportedOperationException(String.format(
                "%1$s (item path: %2$s) of type \"%4$s\" "
                        + "must be bound to a supported "
                        + "observable collection/map type... "
                        + "Found observable: %3$s",
                this.fieldHandle.getFieldName(),
                this.collectionItemPath, observable,
                this.getFieldType()));
    }
    if (isCol && change != null) {
        this.isCollectionListening = change;
    }
}
项目:Java-9-Programming-Blueprints    文件:BeanPathAdapter.java   
/**
 * @param observable
 *            the {@link Observable} to check
 * @return true when the {@link Observable} is an {@link ObservableSet}
 */
protected static boolean isObservableSet(final Observable observable) {
    return observable != null
            && ObservableSet.class.isAssignableFrom(observable
                    .getClass());
}
项目:fx-gson    文件:SetPropertyTypeAdapter.java   
@NotNull
@Override
protected SetProperty<T> createProperty(ObservableSet<T> deserializedValue) {
    return new SimpleSetProperty<>(deserializedValue);
}
项目:fx-gson    文件:ObservableSetCreator.java   
public ObservableSet<?> createInstance(Type type) {
    // No need to use a parametrized set since the actual instance will have the raw type anyway.
    return FXCollections.observableSet();
}
项目:fx-gson    文件:TestClassesWithProp.java   
WithObsSet(ObservableSet<CustomObject> value) {
    this.set = value;
}
项目:fx-gson    文件:TestClassesWithProp.java   
WithSetProp(ObservableSet<CustomObject> value) {
    this.prop = new SimpleSetProperty<>(value);
}
项目:arma-dialog-creator    文件:ArmaDisplay.java   
@NotNull
public ObservableSet<DisplayProperty> getDisplayProperties() {
    return displayProperties;
}
项目:arma-dialog-creator    文件:DisplayPropertiesEditorPane.java   
@NotNull
public ObservableSet<DisplayPropertyEditor> getEditorsReadOnlySet() {
    return editorPanesRO;
}
项目:jstackfx    文件:ThreadElement.java   
public ObservableSet<ThreadReference> getLockedSynchronizers() {
    return lockedSynchronizers.get();
}
项目:jstackfx    文件:ThreadElement.java   
public void setLockedSynchronizers(ObservableSet<ThreadReference> lockedSynchronizers) {
    this.lockedSynchronizers.set(lockedSynchronizers);
}
项目:jstackfx    文件:ThreadElement.java   
public ObservableSet<ThreadReference> getHoldingLocks() {
    return holdingLocks.get();
}
项目:jstackfx    文件:ThreadElement.java   
public void setHoldingLocks(ObservableSet<ThreadReference> holdingLocks) {
    this.holdingLocks.set(holdingLocks);
}
项目:jstackfx    文件:ThreadElement.java   
public ObservableSet<ThreadReference> getWaitingToLock() {
    return waitingToLock.get();
}
项目:jstackfx    文件:ThreadElement.java   
public void setWaitingToLock(ObservableSet<ThreadReference> waitingToLock) {
    this.waitingToLock.set(waitingToLock);
}
项目:jstackfx    文件:ThreadElement.java   
public ObservableSet<ThreadReference> getParkingReasons() {
    return parkingReasons.get();
}
项目:jstackfx    文件:ThreadElement.java   
public void setParkingReasons(ObservableSet<ThreadReference> parkingReasons) {
    this.parkingReasons.set(parkingReasons);
}
项目:Capstone2016    文件:TraplineMonitorService.java   
public ObservableSet<Trap> getUnsentTraps () {
    return createdTraps;
}
项目:Capstone2016    文件:TraplineMonitorService.java   
public ObservableSet<Pair<Integer, Catch>> getUnsentCatchLogs () {
    return loggedCatches;
}
项目:opc-ua-client    文件:DataTreeNodeRowFactory.java   
public ObservableSet<T> getSubscribedItems() {
  return subscribedItems;
}