Class EmfListSelectionBinding<V>
java.lang.Object
com.amalgamasimulation.desktop.binding.EmfListSelectionBinding<V>
- Type Parameters:
V- the type of the list elements
A selection of elements that is stored in a list feature of an EMF object. An element is selected
if the list contains it. All changes go through the command stack of CommandsManager as commands,
so the user can undo them. If the container gets another object, the binding works with the list
of the new object.
- Author:
- Ionov Ivan
-
Constructor Summary
ConstructorsConstructorDescriptionEmfListSelectionBinding(org.eclipse.core.databinding.observable.value.IObservableValue<? extends org.eclipse.emf.ecore.EObject> container, org.eclipse.emf.ecore.EStructuralFeature feature) Creates a selection for the feature of the object in the container. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAll(Collection<V> elements) Adds the elements that are not in the list yet, with one command.voidaddChangeListener(Consumer<V> action) Calls the action for each element that is added to the list or removed from it.booleanisSelected(V element) Checks whether the list contains the element.voidRemoves all elements from the list with one command.voidRemoves the element from the list if it is selected.
-
Constructor Details
-
EmfListSelectionBinding
public EmfListSelectionBinding(org.eclipse.core.databinding.observable.value.IObservableValue<? extends org.eclipse.emf.ecore.EObject> container, org.eclipse.emf.ecore.EStructuralFeature feature) Creates a selection for the feature of the object in the container.- Parameters:
container- the observable value with the object that has the featurefeature- the many-valued feature with elements of type V
-
-
Method Details
-
isSelected
Checks whether the list contains the element.- Parameters:
element- the element- Returns:
- true if the element is selected
-
toggle
Removes the element from the list if it is selected. Otherwise adds it.- Parameters:
element- the element
-
addAll
Adds the elements that are not in the list yet, with one command. If all elements are already selected, does nothing.- Parameters:
elements- the elements
-
removeAll
public void removeAll()Removes all elements from the list with one command. If the list is empty, does nothing. -
addChangeListener
Calls the action for each element that is added to the list or removed from it. There is no method that removes the listener.- Parameters:
action- the action that receives the element
-