Class SelectionModel

java.lang.Object
org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl<IViewer>
org.eclipse.gef.mvc.fx.models.SelectionModel
All Implemented Interfaces:
IAdaptable.Bound<IViewer>, IDisposable

public class SelectionModel extends IAdaptable.Bound.Impl<IViewer> implements IDisposable
The SelectionModel is used to store the current viewer's selection. It represents the selection as an ordered list of IContentParts. Thereby, it supports a multi-selection and allows to identify a primary selection (the head element of the list) that may be treated specially.
  • Property Details

  • Field Details

  • Constructor Details

    • SelectionModel

      public SelectionModel()
  • Method Details

    • appendToSelection

      public void appendToSelection(IContentPart<? extends Node> toBeAppended)
      Updates the current selection by adding the given IContentPart to it, preserving already selected elements.

      If the given content part is not already selected, it will be added to the back of the given selection, otherwise it will be moved to the back. A member of the current selection that is not contained in the given list, will remain selected.

      Parameters:
      toBeAppended - The IContentPart to add to/move to the back of the current selection.
    • appendToSelection

      public void appendToSelection(List<? extends IContentPart<? extends Node>> toBeAppended)
      Updates the current selection by adding the given IContentParts to it, preserving already selected elements.

      A member of the given list that is not contained in the current selection, will be added to it. A member of the current selection that is not contained in the given list, will remain selected.

      The selection order will be adjusted, so that the members of the given list are added at the back (in the order they are given), preceded by the already selected elements not contained in the given list (preserving their relative order).

      Parameters:
      toBeAppended - The IContentParts to add to/move to the back of the current selection.
    • clearSelection

      public void clearSelection()
      Clears the current selection.
    • dispose

      public void dispose()
      Specified by:
      dispose in interface IDisposable
      Since:
      1.1
    • getSelectionUnmodifiable

      public ObservableList<IContentPart<? extends Node>> getSelectionUnmodifiable()
      Returns an unmodifiable observable list of the currently selected IContentParts.
      Returns:
      An unmodifiable observable list of the currently selected IContentParts.
    • isSelected

      public boolean isSelected(IContentPart<? extends Node> contentPart)
      Returns whether the given IContentPart is part of the current selection.
      Parameters:
      contentPart - The IContentPart which is checked for containment.
      Returns:
      true if the IContentPart is contained by the current selection.
    • prependToSelection

      public void prependToSelection(IContentPart<? extends Node> toBePrepended)
      Updates the current selection by adding the given IContentPart to it, preserving already selected elements.

      If the given content part is not already selected, it will be added to the front of the given selection, otherwise it will be moved to the front. A member of the current selection that is not contained in the given list, will remain selected.

      Parameters:
      toBePrepended - The IContentPart to add to/move to the front of the current selection.
    • prependToSelection

      public void prependToSelection(List<? extends IContentPart<? extends Node>> toBePrepended)
      Updates the current selection by adding the given IContentParts to it, preserving already selected elements.

      A member of the given list that is not contained in the current selection, will be added to it. A member of the current selection that is not contained in the given list, will remain selected.

      The selection order will be adjusted, so that the members of the given list are added in front (in the order they are given), followed by the already selected elements not contained in the given list (preserving their relative order).

      Parameters:
      toBePrepended - The IContentParts to add to/move to the front of the current selection.
    • removeFromSelection

      public void removeFromSelection(Collection<? extends IContentPart<? extends Node>> contentParts)
      Removes the given IContentParts from the current selection if they are contained. Ignores those that are not part of the current selection.
      Parameters:
      contentParts - The IContentParts which are removed from the selection.
    • removeFromSelection

      public void removeFromSelection(IContentPart<? extends Node> contentPart)
      Removes the given IContentPart from the current selection if it is currently selected. Will not change the current selection otherwise.
      Parameters:
      contentPart - The IContentPart that is to be removed from the selection.
    • selectionUnmodifiableProperty

      public ReadOnlyListProperty<IContentPart<? extends Node>> selectionUnmodifiableProperty()
      Returns an unmodifiable read-only list property that represents the current selection.
      See Also:
    • setAdaptable

      public void setAdaptable(IViewer adaptable)
      Specified by:
      setAdaptable in interface IAdaptable.Bound<IViewer>
      Overrides:
      setAdaptable in class IAdaptable.Bound.Impl<IViewer>
    • setSelection

      public void setSelection(IContentPart<? extends Node> newSelection)
      Replaces the current selection with the given IContentPart.
      Parameters:
      newSelection - The IContentPart constituting the new selection.
    • setSelection

      public void setSelection(List<? extends IContentPart<? extends Node>> selection)
      Replaces the current selection with the given list of IContentPart s.
      Parameters:
      selection - The list of IContentParts constituting the new selection.