Class TableColumnImpl

  • All Implemented Interfaces:
    TableColumn, TableColumnCore, java.util.Comparator<TableRowCore>
    Direct Known Subclasses:
    CoreTableColumn

    public class TableColumnImpl
    extends java.lang.Object
    implements TableColumnCore
    Table Column definition and modification routines. Implements both the plugin API and the core API.

    A column is defined in relation to a table. When one column is in multiple tables of different table ids, each table has it's own column instance

    See Also:
    TableColumnManager
    • Field Detail

      • CFG_SORTDIRECTION

        private static final java.lang.String CFG_SORTDIRECTION
        See Also:
        Constant Field Values
      • ATTRIBUTE_NAME_OVERIDE

        private static final java.lang.String ATTRIBUTE_NAME_OVERIDE
        See Also:
        Constant Field Values
      • intuitiveComparator

        private static java.util.Comparator<java.lang.String> intuitiveComparator
      • intiutiveSorting

        private static boolean intiutiveSorting
      • sName

        private java.lang.String sName
        Internal Name/ID of the column
      • sTitleLanguageKey

        private java.lang.String sTitleLanguageKey
        key of the displayed title for the column. If null, uses default calc
      • iAlignment

        private int iAlignment
      • iDefaultAlignment

        private int iDefaultAlignment
      • iType

        private int iType
      • iPosition

        private int iPosition
      • iWidth

        private int iWidth
      • iDefaultWidth

        private int iDefaultWidth
      • iInterval

        private int iInterval
      • lLastSortValueChange

        private long lLastSortValueChange
      • foregroundColor

        private int[] foregroundColor
      • backgroundColor

        private int[] backgroundColor
      • sTableID

        private java.lang.String sTableID
        Table the column belongs to
      • bColumnAdded

        private boolean bColumnAdded
      • bCoreDataSource

        private boolean bCoreDataSource
      • mapOtherCellListeners

        private java.util.Map<java.lang.String,​java.util.List<java.lang.Object>> mapOtherCellListeners
      • iConsecutiveErrCount

        private int iConsecutiveErrCount
      • bObfuscateData

        private boolean bObfuscateData
      • this_mon

        protected final AEMonitor this_mon
      • bSortValueLive

        private boolean bSortValueLive
      • lStatsRefreshTotalTime

        private long lStatsRefreshTotalTime
      • lStatsRefreshCount

        private long lStatsRefreshCount
      • lStatsRefreshZeroCount

        private long lStatsRefreshZeroCount
      • bSortAscending

        private boolean bSortAscending
      • bDefaultSortAscending

        private boolean bDefaultSortAscending
      • iMinWidth

        private int iMinWidth
      • iMaxWidth

        private int iMaxWidth
      • bVisible

        private boolean bVisible
      • iPreferredWidth

        private int iPreferredWidth
      • bPreferredWidthAuto

        private boolean bPreferredWidthAuto
      • iPreferredWidthMax

        private int iPreferredWidthMax
      • auto_tooltip

        private boolean auto_tooltip
      • userData

        private java.util.Map userData
      • removed

        private boolean removed
      • forPluginDataSourceTypes

        private java.util.List<java.lang.Class<?>> forPluginDataSourceTypes
      • iconID

        private java.lang.String iconID
      • firstLoad

        private boolean firstLoad
      • showOnlyImage

        private boolean showOnlyImage
      • postLoadConfig

        private boolean postLoadConfig
      • isDirty

        private boolean isDirty
    • Constructor Detail

      • TableColumnImpl

        public TableColumnImpl​(java.lang.String tableID,
                               java.lang.String columnID)
    • Method Detail

      • init

        private void init​(java.lang.String tableID,
                          java.lang.String columnID)
      • getNameOverride

        public java.lang.String getNameOverride()
        Description copied from interface: TableColumn
        Returns the user's column name override if it exists
        Specified by:
        getNameOverride in interface TableColumn
        Returns:
      • setNameOverride

        public void setNameOverride​(java.lang.String name)
        Specified by:
        setNameOverride in interface TableColumn
      • getType

        public int getType()
        Description copied from interface: TableColumn
        Returns the type of the contained data.
        Specified by:
        getType in interface TableColumn
        Returns:
        type TYPE_TEXT, or TYPE_GRAPHIC
      • setWidth

        public void setWidth​(int realPXWidth)
        Description copied from interface: TableColumn
        The column size.

        NOTE: This MUST be set BEFORE adding the column to a table.

        Specified by:
        setWidth in interface TableColumn
      • getWidth

        public int getWidth()
        Description copied from interface: TableColumn
        Returns the column's size
        Specified by:
        getWidth in interface TableColumn
        Returns:
        width in pixels
      • setPosition

        public void setPosition​(int position)
        Description copied from interface: TableColumn
        Location to put the column. When set before being added to the UI (see TableManager.addColumn(com.biglybt.pif.ui.tables.TableColumn)), the supplied value will be used as the default position. If the user has moved the column previously, the new position will be used, and the default position will be ignored. This function cannot be called after you have added the column to a UI table. In the future, setting the position after adding the column to the UI table will result in the column being moved.
        Specified by:
        setPosition in interface TableColumn
        Parameters:
        position - Column Number (0 based), POSITION_INVISIBLE or POSITION_LAST
      • getPosition

        public int getPosition()
        Description copied from interface: TableColumn
        Returns the position of the column
        Specified by:
        getPosition in interface TableColumn
        Returns:
        Column Number (0 based), POSITION_INVISIBLE or POSITION_LAST
      • setAlignment

        public void setAlignment​(int alignment)
        Description copied from interface: TableColumn
        Orientation of the columns text and header.

        NOTE: This MUST be set BEFORE adding the column to a table.

        Specified by:
        setAlignment in interface TableColumn
        Parameters:
        alignment - ALIGN_TRAIL, ALIGN_LEAD, or ALIGN_CENTER
      • getAlignment

        public int getAlignment()
        Description copied from interface: TableColumn
        Returns the alignment of the column
        Specified by:
        getAlignment in interface TableColumn
        Returns:
        ALIGN_TRAIL, ALIGN_LEAD, or ALIGN_CENTER
      • addCellRefreshListener

        public void addCellRefreshListener​(TableCellRefreshListener listener)
        Description copied from interface: TableColumn
        Adds a listener that triggers when a TableCell that belongs to this column needs refreshing.
        Specified by:
        addCellRefreshListener in interface TableColumn
        Parameters:
        listener - Listener Object to be called when refresh is needed.
      • setRefreshInterval

        public void setRefreshInterval​(int interval)
        Description copied from interface: TableColumn
        Set how often the cell receives a refresh() trigger
        Specified by:
        setRefreshInterval in interface TableColumn
        Parameters:
        interval - INTERVAL_GRAPHIC, INTERVAL_LIVE, INTERVAL_INVALID_ONLY constants, or an integer based on the user-configurable "GUI refresh interval". For example, specifying 4 will result in a refresh trigger every 4 "GUI refresh intervals"
      • getRefreshInterval

        public int getRefreshInterval()
        Description copied from interface: TableColumn
        Returns the refresh interval of the column. The default is INTERVAL_INVALID_ONLY
        Specified by:
        getRefreshInterval in interface TableColumn
        Returns:
        INTERVAL_* constant, or a number representing the # of GUI refresh cycles between each cell refresh call.
      • addCellAddedListener

        public void addCellAddedListener​(TableCellAddedListener listener)
        Description copied from interface: TableColumn
        Adds a listener that triggers when a TableCell that belongs to this column is being added.
        Specified by:
        addCellAddedListener in interface TableColumn
        Parameters:
        listener - Listener Object to be called when refresh is needed.
      • addCellOtherListener

        public void addCellOtherListener​(java.lang.String listenerID,
                                         java.lang.Object listener)
        Specified by:
        addCellOtherListener in interface TableColumnCore
      • getCellOtherListeners

        public java.lang.Object[] getCellOtherListeners​(java.lang.String listenerID)
        Specified by:
        getCellOtherListeners in interface TableColumnCore
        Returns:
      • getCellAddedListeners

        public java.util.List getCellAddedListeners()
        Description copied from interface: TableColumnCore
        Retreive all the Cell Added listeners
        Specified by:
        getCellAddedListeners in interface TableColumnCore
        Returns:
        cell added listeners for this cell
      • addCellDisposeListener

        public void addCellDisposeListener​(TableCellDisposeListener listener)
        Description copied from interface: TableColumn
        Adds a listener that triggers when a TableCell that belongs to this column is being disposed.
        Specified by:
        addCellDisposeListener in interface TableColumn
        Parameters:
        listener - Listener Object to be called when refresh is needed.
      • addCellToolTipListener

        public void addCellToolTipListener​(TableCellToolTipListener listener)
        Description copied from interface: TableColumn
        Adds a listener that triggers when a TableCell that belongs to this column has a tooltip action
        Specified by:
        addCellToolTipListener in interface TableColumn
        Parameters:
        listener - Listener Object to be called when refresh is needed.
      • invalidateCells

        public void invalidateCells()
        Description copied from interface: TableColumn
        Invalidate all cells in this column. The cells will be forced to update on the next refresh.
        Specified by:
        invalidateCells in interface TableColumn
      • invalidateCell

        public void invalidateCell​(java.lang.Object data_source)
        Description copied from interface: TableColumn
        Invalidates any cells which are linked to the given data source object.
        Specified by:
        invalidateCell in interface TableColumn
      • addListeners

        public void addListeners​(java.lang.Object listenerObject)
        Description copied from interface: TableColumn
        A listener is added for every type of cell listener the supplied object implements
        Specified by:
        addListeners in interface TableColumn
        Parameters:
        listenerObject - Object implementing some cell listeneters
      • setColumnAdded

        public void setColumnAdded()
        Description copied from interface: TableColumnCore
        Set the internal flag specifying whether the column has been added to the TableColumnManager. Some functions can not be run after a column has been added.
        Specified by:
        setColumnAdded in interface TableColumnCore
      • getColumnAdded

        public boolean getColumnAdded()
        Description copied from interface: TableColumnCore
        Retrieve whether the column has been added to the TableColumnManager
        Specified by:
        getColumnAdded in interface TableColumnCore
        Returns:
        true - Column has been added
        false - Column has not been added
      • setUseCoreDataSource

        public void setUseCoreDataSource​(boolean bCoreDataSource)
        Description copied from interface: TableColumnCore
        Changes what {@link TableCellCore.getDataSource()} and {@link TableRowCore.getDataSource()} return.
        Specified by:
        setUseCoreDataSource in interface TableColumnCore
        Parameters:
        bCoreDataSource - true - returns a core object
        false - returns a plugin object (if available)
      • getUseCoreDataSource

        public boolean getUseCoreDataSource()
        Description copied from interface: TableColumnCore
        Retrieve whether a core or plugin object is sent via getDataSource()
        Specified by:
        getUseCoreDataSource in interface TableColumnCore
        Returns:
        true - returns a core object
        false - returns a plugin object (if available)
      • invokeCellRefreshListeners

        public void invokeCellRefreshListeners​(TableCell cell,
                                               boolean fastRefresh)
                                        throws java.lang.Throwable
        Description copied from interface: TableColumnCore
        Send a refresh trigger to all listeners stored in TableColumn
        Specified by:
        invokeCellRefreshListeners in interface TableColumnCore
        Parameters:
        cell - the cell is being refreshed
        Throws:
        java.lang.Throwable
      • setPositionNoShift

        public void setPositionNoShift​(int position)
        Description copied from interface: TableColumnCore
        Sets the position of the column without adjusting the other columns. This will cause duplicate columns, and is only usefull if you are adjusting the positions of multiple columns at once.
        Specified by:
        setPositionNoShift in interface TableColumnCore
        Parameters:
        position - new position (0 based)
      • getUserData

        public java.lang.Object getUserData​(java.lang.String key)
        Specified by:
        getUserData in interface TableColumn
        Returns:
        data set via setUserData()
      • getUserDataString

        public java.lang.String getUserDataString​(java.lang.String key)
        Specified by:
        getUserDataString in interface TableColumn
      • setUserData

        public void setUserData​(java.lang.String key,
                                java.lang.Object value)
        Description copied from interface: TableColumn
        Associates custom data with the column, usually meant for column-specific settings and stores it across sessions
        Specified by:
        setUserData in interface TableColumn
        Parameters:
        key - the key under which the value will be stored and serialized
        value - should be BEncodable, otherwise it won't be serialized
      • removeUserData

        public void removeUserData​(java.lang.String key)
        Specified by:
        removeUserData in interface TableColumn
      • loadSettings

        public final void loadSettings​(java.util.Map mapSettings)
        Description copied from interface: TableColumnCore
        Load width and position settings from config.
        Specified by:
        loadSettings in interface TableColumnCore
        Parameters:
        mapSettings - map to place settings into
      • isFirstLoad

        public boolean isFirstLoad()
      • postConfigLoad

        public void postConfigLoad()
        Description copied from interface: TableColumn
        implement this method if you want to be notified when the stored column configuration such as user data or GUI-adjustable properties have been loaded
        Specified by:
        postConfigLoad in interface TableColumn
      • preAdd

        public void preAdd()
      • preConfigSave

        public void preConfigSave()
        Description copied from interface: TableColumn
        implement this method if you want to be notified when the column configuration is about to be serialized
        Specified by:
        preConfigSave in interface TableColumn
      • saveSettings

        public final void saveSettings​(java.util.Map mapSettings)
        Description copied from interface: TableColumnCore
        Save width and position settings to config.
        Specified by:
        saveSettings in interface TableColumnCore
        Parameters:
        mapSettings - map to place settings into
      • getTitleLanguageKey

        public java.lang.String getTitleLanguageKey()
        Description copied from interface: TableColumnCore
        Returns the key in the properties bundle that has the title of the column.
        Specified by:
        getTitleLanguageKey in interface TableColumnCore
        Returns:
        Title's language key
      • setConsecutiveErrCount

        public void setConsecutiveErrCount​(int iCount)
        Specified by:
        setConsecutiveErrCount in interface TableColumnCore
        Parameters:
        iCount - # of consecutive errors
      • addContextMenuItem

        public TableContextMenuItem addContextMenuItem​(java.lang.String key)
        Description copied from interface: TableColumn
        Adds a Context Menu item to data section of the column
        Specified by:
        addContextMenuItem in interface TableColumn
        Parameters:
        key - ID of the context menu, which is also used to retreieve the textual name from the plugin language file.
        Returns:
        a newly created menu item
      • addContextMenuItem

        public TableContextMenuItem addContextMenuItem​(java.lang.String key,
                                                       int menuStyle)
        Description copied from interface: TableColumn
        Adds a Context Menu item to the column
        Specified by:
        addContextMenuItem in interface TableColumn
        Parameters:
        key - ID of the context menu, which is also used to retreieve the textual name from the plugin language file.
        menuStyle - See MENU_STYLE_* constants (header or data)
        Returns:
        a newly created menu item
      • isObfuscated

        public boolean isObfuscated()
        Description copied from interface: TableColumn
        Returns whether the column's data will be obfuscated when screen capturing (for bug reports, etc).

        Currently not fully implemented for plugins

        Specified by:
        isObfuscated in interface TableColumn
        Returns:
        Obfuscated value
      • setObfuscation

        public void setObfuscation​(boolean hideData)
        Description copied from interface: TableColumn
        Sets whether the column's data will be obfuscated during a screen capture (for bug reports, etc).
        Specified by:
        setObfuscation in interface TableColumn
        Parameters:
        hideData - new state of obfuscation
      • getListCountString

        private java.lang.String getListCountString​(java.util.List<?> l)
      • setSortAscending

        public void setSortAscending​(boolean bAscending)
        Specified by:
        setSortAscending in interface TableColumnCore
        Parameters:
        bAscending - The bAscending to set.
      • getMinWidth

        public int getMinWidth()
        Description copied from interface: TableColumn
        Gets the minimum width that the column can be before other columns start collapsing.

        If not set, the width specified on initialize will be the minimum width

        Not all UIs may have this feature implemented.

        Specified by:
        getMinWidth in interface TableColumn
        Returns:
        minumum width of the column
      • setMinWidth

        public void setMinWidth​(int minwidth)
        Description copied from interface: TableColumn
        Sets the minimum width that the column can be before other columns start collapsing. This may not prevent the user from resizing the column smaller than specified.

        If not set, the width specified on initialize will be the minimum width

        Not all UIs may have this feature implemented.

        Specified by:
        setMinWidth in interface TableColumn
        Parameters:
        minwidth - new minumum width
      • getMaxWidth

        public int getMaxWidth()
        Description copied from interface: TableColumn
        Gets the maximum width the column can be

        Not all UIs may have this feature implemented.

        Specified by:
        getMaxWidth in interface TableColumn
        Returns:
        maximum width of column
      • setMaxWidth

        public void setMaxWidth​(int maxwidth)
        Description copied from interface: TableColumn
        Sets the maximum width that the column can be

        Not all UIs may have this feature implemented.

        Specified by:
        setMaxWidth in interface TableColumn
        Parameters:
        maxwidth - new maximum width
      • setWidthLimits

        public void setWidthLimits​(int min,
                                   int max)
        Description copied from interface: TableColumn
        Sets the minimum and maximum widths in one call

        Not all UIs may have this min and max limits implemented.

        Specified by:
        setWidthLimits in interface TableColumn
        Parameters:
        min - New minimum column width
        max - New maximum column width
      • isVisible

        public boolean isVisible()
        Description copied from interface: TableColumn
        Gets the visibility of the column

        Not all UIs may have this feature implemented.

        Specified by:
        isVisible in interface TableColumn
        Returns:
        Column visibility
      • setVisible

        public void setVisible​(boolean visible)
        Description copied from interface: TableColumn
        Sets the visibility of the column
        Specified by:
        setVisible in interface TableColumn
        Parameters:
        visible - New visibility state
      • getPreferredWidth

        public int getPreferredWidth()
        Description copied from interface: TableColumn
        Gets the preferred width of the coloumn.
        Specified by:
        getPreferredWidth in interface TableColumn
        Returns:
        preferred width
      • setPreferredWidthAuto

        public void setPreferredWidthAuto​(boolean auto)
        Description copied from interface: TableColumn
        Sets whether the preferred with is automatically calculated. An automatically calculated preferred width will be set to the largest text width known to that column
        Specified by:
        setPreferredWidthAuto in interface TableColumn
        Parameters:
        auto - Preferred Width Auto State
      • isPreferredWidthAuto

        public boolean isPreferredWidthAuto()
        Description copied from interface: TableColumn
        Retrieves whether the preferred width is automatically calculated.
        Specified by:
        isPreferredWidthAuto in interface TableColumn
        Returns:
        preferred width auto calculation state
      • setPreferredWidthMax

        public void setPreferredWidthMax​(int maxprefwidth)
      • getPreferredWidthMax

        public int getPreferredWidthMax()
      • setPreferredWidth

        public void setPreferredWidth​(int width)
        Description copied from interface: TableColumn
        Sets the preferred width of the column. When the UI is in auto-expand mode and space is made available, the columns will first fill to their preferred width, then to their maximum width.
        Specified by:
        setPreferredWidth in interface TableColumn
        Parameters:
        width - New preferred width
      • getForDataSourceTypes

        public java.lang.Class[] getForDataSourceTypes()
      • addDataSourceTypes

        public void addDataSourceTypes​(java.lang.Class[] datasourceTypes)
      • setIconReference

        public void setIconReference​(java.lang.String iconID,
                                     boolean showOnlyIcon)
        Specified by:
        setIconReference in interface TableColumn
      • setMinimumRequiredUserMode

        public void setMinimumRequiredUserMode​(int mode)
        Description copied from interface: TableColumn
        *since 4501
        Specified by:
        setMinimumRequiredUserMode in interface TableColumn
        Parameters:
        mode - from Parameter. constants
      • markDirty

        private void markDirty()