Class EmfListSelectionBinding<V>

java.lang.Object
com.amalgamasimulation.desktop.binding.EmfListSelectionBinding<V>
Type Parameters:
V - the type of the list elements

public class EmfListSelectionBinding<V> extends Object
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

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAll(Collection<V> elements)
    Adds the elements that are not in the list yet, with one command.
    void
    Calls the action for each element that is added to the list or removed from it.
    boolean
    isSelected(V element)
    Checks whether the list contains the element.
    void
    Removes all elements from the list with one command.
    void
    toggle(V element)
    Removes the element from the list if it is selected.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 feature
      feature - the many-valued feature with elements of type V
  • Method Details

    • isSelected

      public boolean isSelected(V element)
      Checks whether the list contains the element.
      Parameters:
      element - the element
      Returns:
      true if the element is selected
    • toggle

      public void toggle(V element)
      Removes the element from the list if it is selected. Otherwise adds it.
      Parameters:
      element - the element
    • addAll

      public void addAll(Collection<V> elements)
      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

      public void addChangeListener(Consumer<V> action)
      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