Class AbstractContainerManager<T extends AbstractContainer>

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractContainerManager()
      Initializes the manager.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(T c)
      Adds the given container to the list.
      void addAll​(Collection<T> c)
      Adds all containers from the given collection.
      void addDataChangeListener​(DataChangeListener l)
      Adds the listener to the internal list.
      void clear()
      Clears the container list.
      void clearSearch()
      Clears any previous search settings.
      boolean contains​(T o)
      Checks whether the container is already in the list.
      int count()
      Returns the number of containers currently stored.
      int countFiltered()
      Returns the number of filtered containers.
      void finishUpdate()
      Finishes the update.
      void finishUpdate​(boolean notify)
      Finishes the update.
      T get​(int index)
      Returns the container at the specified location.
      List<T> getAll()
      Returns (a copy of) all currently stored containers.
      boolean getAllowRemoval()
      Returns whether containers can be removed.
      T getFiltered​(int index)
      Returns the nth filtered container.
      int[] getFilteredIndices()
      Returns the indices of all filtered containers.
      int indexOf​(T c)
      Determines the index of the container.
      int indexOfFiltered​(T c)
      Determines the index of the filtered container.
      boolean isFiltered()
      Returns whether a search filter has been appplied.
      boolean isFiltered​(int index)
      Returns whether the container at the specified position is filtered (= visibile).
      protected abstract boolean isMatch​(T cont, String search, boolean regExp)
      Returns whether the container matches the current search.
      boolean isUpdating()
      Returns whether an update is currently in progress.
      abstract T newContainer​(Comparable o)
      Returns a new container containing the given payload.
      void notifyDataChangeListeners​(DataChangeEvent e)
      Sends all listeners the specified event.
      void postAdd​(T c)
      A post-hook for the add-method, after the container got added to the internal list and the notifications got sent.
      protected void postSet​(int index, T c, T old)
      A post-hook for the set method, after the container replaced the item previously occupying the position.
      protected T preAdd​(T c)
      A pre-hook for the add method, before a container gets added to the internal list.
      protected T preSet​(int index, T c)
      A pre-hook for the set method, before the container replaces the item currently occupying the position.
      T remove​(int index)
      Removes the container at the specified position.
      void removeDataChangeListener​(DataChangeListener l)
      Removes the listener from the internal list.
      void search​(String search, boolean regExp)
      Triggers the search.
      T set​(int index, T c)
      Replaces the container at the given position.
      void setAllowRemoval​(boolean value)
      Sets whether containers can be removed.
      void startUpdate()
      Initiates the start of a larger update.
      String toString()
      Returns a string representation of the handler, i.e., all currently stored containers.
      protected void updateSearch()
      Updates the search.
      protected boolean updateSearchOnUpdate()
      Whether to update the search whenever the content changes.
    • Field Detail

      • m_AllowRemoval

        protected boolean m_AllowRemoval
        whether to allow deletes.
      • m_Updating

        protected boolean m_Updating
        whether an update is currently in progress and notifications are suppressed.
      • m_SearchString

        protected String m_SearchString
        the current search term.
      • m_SearchRegexp

        protected boolean m_SearchRegexp
        whether the current search is using regular expressions.
      • m_FilteredList

        protected gnu.trove.list.array.TIntArrayList m_FilteredList
        the filtered containers.
    • Constructor Detail

      • AbstractContainerManager

        protected AbstractContainerManager()
        Initializes the manager.
    • Method Detail

      • setAllowRemoval

        public void setAllowRemoval​(boolean value)
        Sets whether containers can be removed.
        Parameters:
        value - true if to allow removal
      • getAllowRemoval

        public boolean getAllowRemoval()
        Returns whether containers can be removed.
        Returns:
        true if removal allowed
      • isFiltered

        public boolean isFiltered()
        Returns whether a search filter has been appplied.
        Returns:
        true if search filter applied
      • updateSearchOnUpdate

        protected boolean updateSearchOnUpdate()
        Whether to update the search whenever the content changes.
        Returns:
        true if to update whenever data changes
      • startUpdate

        public void startUpdate()
        Initiates the start of a larger update.
        See Also:
        isUpdating()
      • finishUpdate

        public void finishUpdate()
        Finishes the update.
        See Also:
        isUpdating()
      • finishUpdate

        public void finishUpdate​(boolean notify)
        Finishes the update.
        Parameters:
        notify - whether to notify the listeners about the update
        See Also:
        isUpdating()
      • isUpdating

        public boolean isUpdating()
        Returns whether an update is currently in progress.
        Returns:
        true if an update is currently happening
      • clear

        public void clear()
        Clears the container list.
      • newContainer

        public abstract T newContainer​(Comparable o)
        Returns a new container containing the given payload.
        Parameters:
        o - the payload to encapsulate
        Returns:
        the new container
      • contains

        public boolean contains​(T o)
        Checks whether the container is already in the list. Filling in the preAdd-hook, one can avoid clashes.
        Parameters:
        o - the container to look for
        Returns:
        true if the container is already stored
      • preAdd

        protected T preAdd​(T c)
        A pre-hook for the add method, before a container gets added to the internal list.
        Parameters:
        c - the container to process
        Returns:
        the processed container
      • add

        public void add​(T c)
        Adds the given container to the list.
        Parameters:
        c - the container to add
      • postAdd

        public void postAdd​(T c)
        A post-hook for the add-method, after the container got added to the internal list and the notifications got sent.

        Default implementation does nothing.
        Parameters:
        c - the container that got added
      • addAll

        public void addAll​(Collection<T> c)
        Adds all containers from the given collection.
        Parameters:
        c - the collection to add
      • get

        public T get​(int index)
        Returns the container at the specified location.
        Parameters:
        index - the index of the container
        Returns:
        the container
      • getAll

        public List<T> getAll()
        Returns (a copy of) all currently stored containers. Those containers have no manager.
        Returns:
        all containers
      • preSet

        protected T preSet​(int index,
                           T c)
        A pre-hook for the set method, before the container replaces the item currently occupying the position.
        Parameters:
        index - the position to place the container
        c - the container to set
        Returns:
        the processed container
      • set

        public T set​(int index,
                     T c)
        Replaces the container at the given position.
        Parameters:
        index - the position to replace
        c - the replacement
        Returns:
        the old container
      • postSet

        protected void postSet​(int index,
                               T c,
                               T old)
        A post-hook for the set method, after the container replaced the item previously occupying the position.

        Default implementation does nothing.
        Parameters:
        index - the position to place the container
        c - the container that was set set
        old - the previous container
      • remove

        public T remove​(int index)
        Removes the container at the specified position.
        Parameters:
        index - the index of the container to remove
        Returns:
        the container that got removed, null if nothing removed, e.g. if no remove allowed or currently updating
      • count

        public int count()
        Returns the number of containers currently stored.
        Returns:
        the number of containers
      • indexOf

        public int indexOf​(T c)
        Determines the index of the container.
        Parameters:
        c - the container to look for
        Returns:
        the index of the container or -1 if not found
      • search

        public void search​(String search,
                           boolean regExp)
        Triggers the search.
        Parameters:
        search - the search string
        regExp - whether to perform regexp matching
      • clearSearch

        public void clearSearch()
        Clears any previous search settings.
      • isMatch

        protected abstract boolean isMatch​(T cont,
                                           String search,
                                           boolean regExp)
        Returns whether the container matches the current search.
        Parameters:
        cont - the container to check
        search - the search string
        regExp - whether to perform regular expression matching
      • updateSearch

        protected void updateSearch()
        Updates the search.
      • getFilteredIndices

        public int[] getFilteredIndices()
        Returns the indices of all filtered containers.
        Returns:
        all containers
      • isFiltered

        public boolean isFiltered​(int index)
        Returns whether the container at the specified position is filtered (= visibile).
        Parameters:
        index - the container's position
        Returns:
        true if the container is filtered
      • getFiltered

        public T getFiltered​(int index)
        Returns the nth filtered container.
        Parameters:
        index - the index (relates only to the filtered containers!)
        Returns:
        the container, null if index out of range
      • indexOfFiltered

        public int indexOfFiltered​(T c)
        Determines the index of the filtered container.
        Parameters:
        c - the container to look for
        Returns:
        the index of the container or -1 if not found
      • countFiltered

        public int countFiltered()
        Returns the number of filtered containers.
        Returns:
        the number of filtered containers
      • addDataChangeListener

        public void addDataChangeListener​(DataChangeListener l)
        Adds the listener to the internal list.
        Parameters:
        l - the listener to add
      • removeDataChangeListener

        public void removeDataChangeListener​(DataChangeListener l)
        Removes the listener from the internal list.
        Parameters:
        l - the listener to remove
      • notifyDataChangeListeners

        public void notifyDataChangeListeners​(DataChangeEvent e)
        Sends all listeners the specified event. Ignored if an update is currently in progress.
        Parameters:
        e - the event to send
        See Also:
        isUpdating()
      • toString

        public String toString()
        Returns a string representation of the handler, i.e., all currently stored containers.
        Overrides:
        toString in class Object
        Returns:
        a string representation