Class AbstractNamedHistoryPanel<T>

    • Field Detail

      • m_PanelList

        protected BasePanel m_PanelList
        the panel for the list.
      • m_List

        protected BaseList m_List
        the JList listing the history entries.
      • m_ListModel

        protected DefaultListModel m_ListModel
        the underlying list model.
      • m_ListModelFiltered

        protected DefaultListModel m_ListModelFiltered
        the filtered model.
      • m_PanelListButtons

        protected BasePanel m_PanelListButtons
        the panel for the list buttons.
      • m_ButtonDown

        protected BaseFlatButton m_ButtonDown
        the move down button.
      • m_ButtonRemove

        protected BaseFlatButton m_ButtonRemove
        the remove button.
      • m_ButtonRemoveAll

        protected BaseFlatButton m_ButtonRemoveAll
        the remove all button.
      • m_Entries

        protected Hashtable<String,​T> m_Entries
        stores the actual objects (name <-> object relation).
      • m_Payloads

        protected Hashtable<String,​Object> m_Payloads
        stores the optional payloads (name <-> object relation).
      • m_PanelSearch

        protected SearchPanel m_PanelSearch
        the panel for searching the entry names.
      • 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_AllowRemove

        protected boolean m_AllowRemove
        whether to allow removing of entries.
      • m_AllowRename

        protected boolean m_AllowRename
        whether to allow renaming of entries.
    • Constructor Detail

      • AbstractNamedHistoryPanel

        public AbstractNamedHistoryPanel()
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the members.
        Overrides:
        initialize in class BasePanel
      • initGUI

        protected void initGUI()
        Initializes the widgets.
        Overrides:
        initGUI in class BasePanel
      • finishInit

        protected void finishInit()
        Finishes the initialization.
        Overrides:
        finishInit in class BasePanel
      • moveUp

        public void moveUp()
        moves the selected items up by 1.
      • moveDown

        public void moveDown()
        moves the selected item down by 1.
      • moveTop

        public void moveTop()
        moves the selected items to the top.
      • moveBottom

        public void moveBottom()
        moves the selected items to the end.
      • canMoveUp

        public boolean canMoveUp()
        checks whether the selected items can be moved up.
        Returns:
        true if the selected items can be moved
      • canMoveDown

        public boolean canMoveDown()
        checks whether the selected items can be moved down.
        Returns:
        true if the selected items can be moved
      • setButtonPanelVisible

        public void setButtonPanelVisible​(boolean value)
        Sets whether the buttons are shown.
        Parameters:
        value - true if buttons are shown
      • isButtonPanelVisible

        public boolean isButtonPanelVisible()
        Returns whether the buttons are shown.
        Returns:
        true if buttons are shown
      • updateButtons

        protected void updateButtons()
        Updates the enabled state of the buttons.
      • setAllowRename

        public void setAllowRename​(boolean value)
        Sets whether entries can be renamed.
        Parameters:
        value - true if rename allowed
      • getAllowRename

        public boolean getAllowRename()
        Returns whether entries can be renamed.
        Returns:
        true if rename allowed
      • setAllowRemove

        public void setAllowRemove​(boolean value)
        Sets whether entries can be removed.
        Parameters:
        value - true if remove allowed
      • getAllowRemove

        public boolean getAllowRemove()
        Returns whether entries can be removed.
        Returns:
        true if remove allowed
      • showPopup

        protected void showPopup​(MouseEvent e)
        Generates and pops up the right-click menu on the JList.
        Parameters:
        e - the event that triggered the popup
        See Also:
        createPopup(MouseEvent)
      • createPopup

        protected BasePopupMenu createPopup​(MouseEvent e)
        Generates the right-click menu for the JList.

        Derived classes should override this method instead of making use of the PopupCustomizer.
        Parameters:
        e - the event that triggered the popup
        Returns:
        the generated menu
        See Also:
        showPopup(MouseEvent)
      • checkedRemoveAllEntries

        protected void checkedRemoveAllEntries()
        Prompts the user before removing all entries.
      • updateEntry

        protected abstract void updateEntry​(String name)
        Displays the specified entry.
        Parameters:
        name - the name of the entry, can be null to empty display
      • updateSearch

        protected void updateSearch()
        Updates the search, filters the entries if necessary.
      • hasSearch

        public boolean hasSearch()
        Checks whether a search term has been entered by the user.
        Returns:
        true if search term was entered
      • getListModel

        protected DefaultListModel getListModel()
        Returns the list model.
        Returns:
        the list model
      • clear

        public void clear()
        Removes all entries and payloads.
      • clear

        public void clear​(boolean update)
        Removes all entries and payloads.
        Parameters:
        update - if true, then updateEntry(String) is called
      • count

        public int count()
        Returns the number of entries in the list.
        Returns:
        the number of entries
      • entries

        public Enumeration<String> entries()
        Returns the all the currently stored entries.
        Returns:
        the names of the entries
      • hasEntry

        public boolean hasEntry​(String name)
        Checks whether the given named entry exists.
        Parameters:
        name - the name to look for
        Returns:
        true if the entry exists
      • hasPayload

        public boolean hasPayload​(String name)
        Checks whether there is a payload available for the name.
        Parameters:
        name - the name to check for payload
        Returns:
        true if entry exists and a payload is available
      • newEntryName

        public String newEntryName​(String name)
        Ensures that the name is unique, by appending an index.
        Parameters:
        name - the name to make unique
        Returns:
        the unique name
      • indexOfEntry

        public int indexOfEntry​(String name)
        Returns the index of the entry.
        Parameters:
        name - the name to look for
        Returns:
        the index or -1 if not found
      • getEntry

        public T getEntry​(String name)
        Returns the entry with the specified name.
        Parameters:
        name - the name of the entry
        Returns:
        the object or null if not found
      • getPayload

        public Object getPayload​(String name)
        Returns the payload with the specified name.
        Parameters:
        name - the name of the entry
        Returns:
        the object or null if not found or no payload available
      • getEntry

        public T getEntry​(int index)
        Returns the entry at the specified index.
        Parameters:
        index - the index of the entry
        Returns:
        the object or null if not found
      • getPayload

        public Object getPayload​(int index)
        Returns the payload at the specified index.
        Parameters:
        index - the index of the payload
        Returns:
        the object or null if not found
      • getEntryName

        public String getEntryName​(int index)
        Returns the name of the entry at the specified index.
        Parameters:
        index - the index of the entry
        Returns:
        the name
      • addEntry

        public T addEntry​(String name,
                          T entry)
        Adds the entry under the specified name.
        Parameters:
        name - the name of the entry
        entry - the object to store
        Returns:
        the entry previously stored under the same name or null if it is a new entry
      • addEntry

        public T addEntry​(String name,
                          T entry,
                          Object payload)
        Adds the entry under the specified name.
        Parameters:
        name - the name of the entry
        entry - the object to store
        payload - the payload to attach, can be null
        Returns:
        the entry previously stored under the same name or null if it is a new entry
      • setPayload

        public void setPayload​(String name,
                               Object payload)
        Set the payload for the specified entry.
        Parameters:
        name - the name of the entry
        payload - the payload object to store
      • insertEntryAt

        public void insertEntryAt​(String name,
                                  T entry,
                                  int index)
        Inserts the entry under the name at the specified location. Any previously existing entry with the same name will be removed.
        Parameters:
        name - the name of the entry
        entry - the object to store
        index - the index to store the entry at
      • insertEntryAt

        public void insertEntryAt​(String name,
                                  T entry,
                                  Object payload,
                                  int index)
        Inserts the entry under the name at the specified location. Any previously existing entry with the same name will be removed.
        Parameters:
        name - the name of the entry
        entry - the object to store
        payload - the payload to attach, can be null
        index - the index to store the entry at
      • removeEntry

        public T removeEntry​(String name)
        Removes the specified entry.
        Parameters:
        name - the name of the entry
        Returns:
        the entry that was stored under this name or null if no entry was stored with this name
      • removePayload

        public Object removePayload​(String name)
        Removes the specified payload.
        Parameters:
        name - the name of the entry to remove the payload for
        Returns:
        the payload object that was stored under this name or null if no payload was stored with this name
      • setSelectedIndex

        public void setSelectedIndex​(int value)
        Sets the index to be displayed as selected.
        Parameters:
        value - the index to select
      • copyEntryNames

        public void copyEntryNames​(int[] indices)
        Copies the entry names of the specified indices to the clipboard.
        Parameters:
        indices - the entries to remove
      • removeEntries

        public void removeEntries​(int[] indices)
        Removes the entries with the specified indices.
        Parameters:
        indices - the entries to remove
      • renameEntry

        public boolean renameEntry()
        Attempts to rename the current entry.
        Returns:
        true if renamed
        See Also:
        getAllowRename()
      • renameEntry

        public String renameEntry​(String oldName,
                                  String newName)
        Attempts to rename the entry.
        Parameters:
        oldName - the current name of the entry
        newName - the new name for the entry
        Returns:
        null if successful, otherwise error message
      • getSelectedIndex

        public int getSelectedIndex()
        Returns the currently selected index, the first if several selected.
        Returns:
        the selected index, -1 if none selected
      • setSelectedIndices

        public void setSelectedIndices​(int[] value)
        Sets the indices to be displayed as selected.
        Parameters:
        value - the indices to select
      • getSelectedIndices

        public int[] getSelectedIndices()
        Returns the currently selected indices.
        Returns:
        the selected indices
      • setSelectedEntry

        public void setSelectedEntry​(String value)
        Sets the entry to be displayed as selected.
        Parameters:
        value - the entry name
      • getSelectedEntry

        public String getSelectedEntry()
        Returns the currently selected entry, the first if several selected.
        Returns:
        the selected entry, null if none selected
      • setSelectedEntries

        public void setSelectedEntries​(String[] value)
        Sets the entries to be displayed as selected.
        Parameters:
        value - the entry names
      • getSelectedEntries

        public String[] getSelectedEntries()
        Returns the currently selected entries.
        Returns:
        the selected entries
      • addHistoryEntrySelectionListener

        public void addHistoryEntrySelectionListener​(AbstractNamedHistoryPanel.HistoryEntrySelectionListener l)
        Adds a listener to the internal list of listeners that get notified when a history entry gets selected.
        Parameters:
        l - the listener to add
      • removeHistoryEntrySelectionListener

        public void removeHistoryEntrySelectionListener​(AbstractNamedHistoryPanel.HistoryEntrySelectionListener l)
        Removes a listener from the internal list of listeners that get notified when a history entry gets selected.
        Parameters:
        l - the listener to remove
      • setAllowSearch

        public void setAllowSearch​(boolean value)
        Sets whether the entry list is searchable.
        Parameters:
        value - true if to make the list searchable
      • getAllowSearch

        public boolean getAllowSearch()
        Returns whether the entry list is searchable.
        Returns:
        true if list is searchable
      • getPreferredSize

        public Dimension getPreferredSize()
        Returns the preferred size for this component.
        Overrides:
        getPreferredSize in class JComponent
        Returns:
        the preferred size
      • serialize

        public Object serialize()
        Returns the history.
        Returns:
        the history
      • deserialize

        public void deserialize​(Object data,
                                MessageCollection errors)
        Restores the history.
        Parameters:
        data - the data to restore
        errors - for storing errors