java类javafx.collections.ObservableSet的实例源码

TimeGraphDrawnEventLayer.java 文件源码 项目:lttng-scope 阅读 20 收藏 0 点赞 0 评论 0
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());
}
ObservableMergers.java 文件源码 项目:drd 阅读 18 收藏 0 点赞 0 评论 0
@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()));
            }
        });
    }
}
FxGsonTest.java 文件源码 项目:fx-gson 阅读 38 收藏 0 点赞 0 评论 0
@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);
}
SankeyChart.java 文件源码 项目:sankey-javafx 阅读 19 收藏 0 点赞 0 评论 0
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);
}
VersionTagResolverImpl.java 文件源码 项目:LoliXL 阅读 20 收藏 0 点赞 0 评论 0
@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));
        }
    };
}
ExContentBinding.java 文件源码 项目:bridje-framework 阅读 19 收藏 0 点赞 0 评论 0
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));
    }*/
}
LocalRepoDirectoryPane.java 文件源码 项目:subshare 阅读 18 收藏 0 点赞 0 评论 0
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;
}
BufferingManager.java 文件源码 项目:reta 阅读 21 收藏 0 点赞 0 评论 0
/**
 * @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;
}
Subscription.java 文件源码 项目:ReactFX 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 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());
    };
}
PluginLoader.java 文件源码 项目:shuffleboard 阅读 30 收藏 0 点赞 0 评论 0
public ObservableSet<Plugin> getLoadedPlugins() {
  return FXCollections.unmodifiableObservableSet(loadedPlugins);
}
ObservableMergers.java 文件源码 项目:drd 阅读 18 收藏 0 点赞 0 评论 0
@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());
            }
        });
    }
}
BeanPathAdapter.java 文件源码 项目:Java-9-Programming-Blueprints 阅读 21 收藏 0 点赞 0 评论 0
/**
 * @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);
}
FxGsonBuilder.java 文件源码 项目:fx-gson 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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;
}
FxGsonTest.java 文件源码 项目:fx-gson 阅读 28 收藏 0 点赞 0 评论 0
@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);
}
SearchCell.java 文件源码 项目:javaone2016 阅读 16 收藏 0 点赞 0 评论 0
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;
            }
        }
    }
}
ValueSetAttribute.java 文件源码 项目:factoryfx 阅读 20 收藏 0 点赞 0 评论 0
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());
    });
}
BiSetContentBinding.java 文件源码 项目:bridje-framework 阅读 19 收藏 0 点赞 0 评论 0
@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;
}
EventStreams.java 文件源码 项目:ReactFX 阅读 21 收藏 0 点赞 0 评论 0
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);
        }
    };
}
EventStreams.java 文件源码 项目:ReactFX 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 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));
        }
    };
}
EventStreams.java 文件源码 项目:ReactFX 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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));
        }
    };
}
BeanPathAdapter.java 文件源码 项目:Java-9-Programming-Blueprints 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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);
}
BeanPathAdapter.java 文件源码 项目:Java-9-Programming-Blueprints 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 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;
    }
}
BeanPathAdapter.java 文件源码 项目:Java-9-Programming-Blueprints 阅读 19 收藏 0 点赞 0 评论 0
/**
 * @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());
}
SetPropertyTypeAdapter.java 文件源码 项目:fx-gson 阅读 20 收藏 0 点赞 0 评论 0
@NotNull
@Override
protected SetProperty<T> createProperty(ObservableSet<T> deserializedValue) {
    return new SimpleSetProperty<>(deserializedValue);
}
ObservableSetCreator.java 文件源码 项目:fx-gson 阅读 41 收藏 0 点赞 0 评论 0
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();
}
TestClassesWithProp.java 文件源码 项目:fx-gson 阅读 41 收藏 0 点赞 0 评论 0
WithObsSet(ObservableSet<CustomObject> value) {
    this.set = value;
}
TestClassesWithProp.java 文件源码 项目:fx-gson 阅读 21 收藏 0 点赞 0 评论 0
WithSetProp(ObservableSet<CustomObject> value) {
    this.prop = new SimpleSetProperty<>(value);
}
ArmaDisplay.java 文件源码 项目:arma-dialog-creator 阅读 23 收藏 0 点赞 0 评论 0
@NotNull
public ObservableSet<DisplayProperty> getDisplayProperties() {
    return displayProperties;
}
DisplayPropertiesEditorPane.java 文件源码 项目:arma-dialog-creator 阅读 17 收藏 0 点赞 0 评论 0
@NotNull
public ObservableSet<DisplayPropertyEditor> getEditorsReadOnlySet() {
    return editorPanesRO;
}
ThreadElement.java 文件源码 项目:jstackfx 阅读 20 收藏 0 点赞 0 评论 0
public ObservableSet<ThreadReference> getLockedSynchronizers() {
    return lockedSynchronizers.get();
}


问题


面经


文章

微信
公众号

扫码关注公众号