javafx.beans.property.SetProperty Java Examples

The following examples show how to use javafx.beans.property.SetProperty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SetPropertyExTests.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Parameters
public static Collection<Object[]> data() {
	return Arrays.asList(
			new Object[][] { { new Provider<SetProperty<Integer>>() {

				@Override
				public SetProperty<Integer> get() {
					return new SimpleSetPropertyEx<>(FXCollections
							.observableSet(new HashSet<Integer>()));
				}
			} }, { new Provider<SetProperty<Integer>>() {

				@Override
				public SetProperty<Integer> get() {
					// Replacement for ReadOnlySetWrapper which fixes
					// https://bugs.openjdk.java.net/browse/JDK-8136465)
					return new ReadOnlySetWrapperEx<>(FXCollections
							.observableSet(new HashSet<Integer>()));
				}
			} } });
}
 
Example #2
Source File: SetPropertyExTests.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void changeListenerRegistrationAndDeregistration() {
	SetProperty<Integer> property = propertyProvider.get();

	// register listener
	ChangeExpector<Integer> changeListener = null;
	changeListener = new ChangeExpector<>(property);
	property.addListener(changeListener);

	// add second listener (and remove again)
	ChangeExpector<Integer> changeListener2 = null;
	changeListener2 = new ChangeExpector<>(property);
	property.addListener(changeListener2);
	property.removeListener(changeListener2);

	ObservableSet<Integer> newValue = FXCollections
			.observableSet(new HashSet<Integer>());
	changeListener.addExpectation(property.get(), newValue);
	newValue.add(1);
	property.set(newValue);
	changeListener.check();
}
 
Example #3
Source File: PropertyVisitor.java    From SynchronizeFX with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 
 * @param object
 *            The object which fields should be visited.
 * @return {@code true} when the object was a observable object, {@code false} when it was a simple object.
 * @throws SecurityException
 *             If a {@link SecurityManager} is active and denies access to fields via reflection.
 * @throws IllegalAccessException
 *             If access modifiers like {@code private} are enforced even when the model is accessed via reflection.
 */
private boolean visitFields(final Object object) throws IllegalAccessException {
    boolean isObservableObject = false;
    for (final Field field : getInheritedFields(object.getClass())) {
        field.setAccessible(true);
        currentField = field;
        final Class<?> fieldClass = field.getType();

        if (!isObservableObject && classImplementsOrExtends(fieldClass, Property.class)) {
            startVisiting(object);
            isObservableObject = true;
        }

        if (classImplementsOrExtends(fieldClass, ListProperty.class)) {
            handle((ListProperty<?>) field.get(object));
        } else if (classImplementsOrExtends(fieldClass, SetProperty.class)) {
            handle((SetProperty<?>) field.get(object));
        } else if (classImplementsOrExtends(fieldClass, MapProperty.class)) {
            handle((MapProperty<?, ?>) field.get(object));
        } else if (classImplementsOrExtends(fieldClass, Property.class)) {
            handle((Property<?>) field.get(object));
        }
    }
    return isObservableObject;
}
 
Example #4
Source File: PropertyVisitor.java    From SynchronizeFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void handle(final SetProperty<?> property) throws IllegalAccessException {
    if (visitCollectionProperty(property)) {
        for (Object child : property) {
            visit(child);
        }
    }
}
 
Example #5
Source File: PropertyVisitor.java    From SynchronizeFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
Parent(final Property<?> parentProperty, final ListProperty<?> parentList, final SetProperty<?> parentSet,
        final MapProperty<?, ?> parentMap) {
    this.parentList = parentList;
    this.parentSet = parentSet;
    this.parentMap = parentMap;
    this.parentProperty = parentProperty;
}
 
Example #6
Source File: SetPropertyExTests.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public SetPropertyExTests(Provider<SetProperty<Integer>> propertyProvider) {
	this.propertyProvider = propertyProvider;
}
 
Example #7
Source File: PathItem.java    From PeerWasp with MIT License 4 votes vote down vote up
public void bindPermissionsTo(SetProperty<UserPermission> other){
	Set<UserPermission> oldPermissions = new HashSet<UserPermission>(getPermissions());
	getPermissionsSetProperty().bindContent(other);
	getPermissionsSetProperty().addAll(oldPermissions);
}
 
Example #8
Source File: PathItem.java    From PeerWasp with MIT License 4 votes vote down vote up
public SetProperty<UserPermission> getPermissionsSetProperty(){
	return permissions;
}
 
Example #9
Source File: PropertyVisitor.java    From SynchronizeFX with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Visit a field of type {@link SetProperty}.
 * 
 * @param fieldValue
 *            The value that is bound to the field.
 * @return {@code true} if the childs of this property should be visited, {@code false} if not.
 */
protected abstract boolean visitCollectionProperty(SetProperty<?> fieldValue);
 
Example #10
Source File: PropertyVisitor.java    From SynchronizeFX with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * @return The parent {@link SetProperty} if the parent of the current object is a {@link SetProperty}. If not or if
 *         this is the root element and therefore their is no parent {@code null} is returned.
 */
public SetProperty<?> getParentSet() {
    return parent.peek().parentSet;
}