sialcasa / mvvmFX

an Application Framework for implementing the MVVM Pattern with JavaFX
Apache License 2.0
489 stars 104 forks source link

ModelWrapper with methods field / immutableField that accept arguments of type Set and Map #531

Closed johandeschutter closed 5 years ago

johandeschutter commented 6 years ago

Hello,

Is possible to add to the ModelWrapper class the methods field / immutableField that accept arguments of type Set and Map .

Currently only the methods field / immutableField only accept collections of type List.

Something like this: public SetProperty field(SetGetter<M, E> getter, SetSetter<M, E> setter) { return add(new BeanSetPropertyField<>(this::propertyWasChanged, getter, (m, set) -> setter.accept(m, FXCollections.observableSet(set)), SimpleSetProperty::new)); }

public <E> MapProperty<E> field(MapGetter<M, E> getter, MapSetter<M, E> setter) {
    return add(new BeanMapPropertyField<>(this::propertyWasChanged, getter,
            (m, map) -> setter.accept(m, FXCollections.observableMap(map)), SimpleMapProperty::new));
}

Regards,

Johan

manuel-mauky commented 6 years ago

Hi johandeschutter, thanks for your request. At the moment this is not possible but it could be added. I don't see a reason why this would not work. It's missing because we hadn't had the need for this yet and based on my experience not many people are using SetProperty and MapProperty.

I don't know when I find the time to add this feature. However, I'm happy to accept a PullRequest for this. Thinks to do are:

manuel-mauky commented 5 years ago

I've implemented the first part of this issue: You can now use Sets with the Model-Wrapper. I will add support for Maps within the next days. It works the same way