javafx.beans.property.MapProperty Java Examples

The following examples show how to use javafx.beans.property.MapProperty. 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: MapPropertyExTests.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<MapProperty<Integer, String>>() {

				@Override
				public MapProperty<Integer, String> get() {
					// Replacement for SimpleMapProperty which fixes
					// https://bugs.openjdk.java.net/browse/JDK-8136465)
					return new SimpleMapPropertyEx<>(FXCollections
							.observableMap(new HashMap<Integer, String>()));
				}
			} }, { new Provider<MapProperty<Integer, String>>() {

				@Override
				public MapProperty<Integer, String> get() {
					// Replacement for ReadOnlyMapWrapper which fixes
					// https://bugs.openjdk.java.net/browse/JDK-8136465)
					return new ReadOnlyMapWrapperEx<>(FXCollections
							.observableMap(new HashMap<Integer, String>()));
				}
			} } });
}
 
Example #2
Source File: MapPropertyExTests.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void changeListenerRegistrationAndDeregistration() {
	MapProperty<Integer, String> property = propertyProvider.get();

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

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

	ObservableMap<Integer, String> newValue = FXCollections
			.observableMap(new HashMap<Integer, String>());
	changeListener.addExpectation(property.get(), newValue);
	newValue.put(1, "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 MapProperty<?, ?> property) throws IllegalAccessException {
    if (visitCollectionProperty(property)) {
        for (Entry<?, ?> entry : property.entrySet()) {
            visit(entry.getKey());
            visit(entry.getValue());
        }
    }
}
 
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: ModularFeatureListRow.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public MapProperty<RawDataFile, ModularFeature> getFeatures() {
  return get(FeaturesType.class);
}
 
Example #7
Source File: FeaturesType.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MapProperty<RawDataFile, ModularFeature> createProperty() {
  return new SimpleMapProperty<RawDataFile, ModularFeature>();
}
 
Example #8
Source File: MapPropertyExTests.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public MapPropertyExTests(
		Provider<MapProperty<Integer, String>> propertyProvider) {
	this.propertyProvider = propertyProvider;
}
 
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 MapProperty}.
 * 
 * @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(MapProperty<?, ?> 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 MapProperty} if the parent of the current object is a {@link MapProperty}. If not or if
 *         this is the root element and therefore their is no parent {@code null} is returned.
 */
public MapProperty<?, ?> getParentMap() {
    return parent.peek().parentMap;
}
 
Example #11
Source File: Listeners.java    From SynchronizeFX with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Registers listeners on a property so that commands are created when changes in the property occur.
 * 
 * @param map
 *            The property to register the change listeners on.
 */
public void registerOn(final MapProperty<?, ?> map) {
    map.addListener(mapListener);
}