Package com.illumon.iris.gui.widget
Class FreezeColumnsManagerImpl
java.lang.Object
com.illumon.iris.gui.widget.FreezeColumnsManagerImpl
- All Implemented Interfaces:
FreezeColumnsManager
public class FreezeColumnsManagerImpl extends Object implements FreezeColumnsManager
Allows the user to "Freeze Columns". This takes a normal column and moves it to the left side of the table so that it
is always visible. This effect is done by maintaining two Tables with the same Table Model and moving columns between
them.
-
Field Summary
Fields Modifier and Type Field Description protected GuiTable
freezeTable
protected GuiTable
mainTable
-
Constructor Summary
Constructors Constructor Description FreezeColumnsManagerImpl(com.fishlib.io.logger.Logger log, GuiTable mainTable, JScrollPane scrollPane, Function<IrisTableModel,GuiTable> createTableFunction)
Creates a new FreezeColumnsManager.FreezeColumnsManagerImpl(com.fishlib.io.logger.Logger log, GuiTable mainTable, JScrollPane scrollPane, Function<IrisTableModel,GuiTable> createTableFunction, Runnable refresh)
Creates a new FreezeColumnsManager. -
Method Summary
Modifier and Type Method Description protected void
clearFreezeColumns()
Clears any current freeze columns that are not locked.void
close()
Close our changeListener(s)int
convertColumnIndexToModel(int viewColumnIndex)
Converts a view column index to a model column index taking into account both the freeze table and main table.void
freezeColumn(String columnName)
Freezes a column.void
freezeColumn(TableColumn column)
Freezes a column.boolean
freezeColumnsSupported()
Indicates if freeze columns are supported.String
getColumnName(int column)
Gets the column name at view column position taking into account both the freeze table and the main table.List<String>
getFreezeColumns()
Gets a list of the columns that are frozen.GuiTable
getFreezeTable()
Gets the freeze table.Set<String>
getFrozenColumnSet()
Gets the freeze columns as a set.Collection<TableColumn>
getHiddenColumns()
Gets all the hidden columns taking into account both the freeze table and the main table.GuiTable
getMainTable()
Gets the main table.Set<String>
getNormalColumnSet()
Gets the normal (unfrozen) columns as a set.int[]
getSelectedColumns()
Gets the selected columns taking into account both the freeze table and the main table.int
getTotalColumnCount()
Gets the total column count for both the freeze table and the main table.Collection<TableColumn>
getVisibleColumns()
Gets all the visible columns taking into account both the freeze table and the main table.void
hideAllColumns()
Hides all columns in both the freeze table and main table.void
hideFreezeTable()
Hides the freeze table.boolean
isFreezeTable(GuiTable table)
Indicates if a table is the freeze table.boolean
isModified()
Indicates if the freeze columns have been altered since the table was first created (e.g.boolean
mayHideOrFreezeColumn(TableColumn tableColumn)
Identifies if a specific column is eligible for hiding/freezing.protected void
onModelChanged()
Handles when the model of the main table changes.void
repaint()
Requests the freeze table to repaint.void
setFreezeColumns(Collection<String> columns)
Clears any previous freeze columns and sets them to the columns in a list.void
setModified(boolean modified)
Marks if the freeze columns have been modified.void
showColumn(TableColumn tableColumn)
Shows a column in the correct table (freeze table or main table)void
showFreezeTable()
Shows the freeze table.void
unfreezeColumn(String columnName)
Unfreezes a column.void
unfreezeColumn(TableColumn column)
Unfreezes a column.
-
Field Details
-
Constructor Details
-
FreezeColumnsManagerImpl
public FreezeColumnsManagerImpl(com.fishlib.io.logger.Logger log, GuiTable mainTable, JScrollPane scrollPane, Function<IrisTableModel,GuiTable> createTableFunction, Runnable refresh)Creates a new FreezeColumnsManager.- Parameters:
log
- the loggermainTable
- the main table that displays normal columnsscrollPane
- the scroll pane containing the main tablecreateTableFunction
- a callback to create a second GuiTable backed the model of the firstrefresh
- a callback to run any special code required to refresh the freeze table
-
FreezeColumnsManagerImpl
public FreezeColumnsManagerImpl(com.fishlib.io.logger.Logger log, GuiTable mainTable, JScrollPane scrollPane, Function<IrisTableModel,GuiTable> createTableFunction)Creates a new FreezeColumnsManager.- Parameters:
log
- the loggermainTable
- the main table that displays normal columnsscrollPane
- the scroll pane containing the main tablecreateTableFunction
- a callback to create a second GuiTable backed the model of the first
-
-
Method Details
-
freezeColumnsSupported
public boolean freezeColumnsSupported()Description copied from interface:FreezeColumnsManager
Indicates if freeze columns are supported.- Specified by:
freezeColumnsSupported
in interfaceFreezeColumnsManager
- Returns:
- true if freeze columns are supported, false otherwise
-
getFreezeColumns
Description copied from interface:FreezeColumnsManager
Gets a list of the columns that are frozen.- Specified by:
getFreezeColumns
in interfaceFreezeColumnsManager
- Returns:
- a list of freeze columns
-
getFrozenColumnSet
Description copied from interface:FreezeColumnsManager
Gets the freeze columns as a set.- Specified by:
getFrozenColumnSet
in interfaceFreezeColumnsManager
- Returns:
- the freeze columns
-
getNormalColumnSet
Description copied from interface:FreezeColumnsManager
Gets the normal (unfrozen) columns as a set.- Specified by:
getNormalColumnSet
in interfaceFreezeColumnsManager
- Returns:
- the normal columns
-
setFreezeColumns
Description copied from interface:FreezeColumnsManager
Clears any previous freeze columns and sets them to the columns in a list.- Specified by:
setFreezeColumns
in interfaceFreezeColumnsManager
- Parameters:
columns
- the list of columns to freeze
-
clearFreezeColumns
protected void clearFreezeColumns()Clears any current freeze columns that are not locked. -
getMainTable
Description copied from interface:FreezeColumnsManager
Gets the main table. This is useful for when we should operate on the main table, but the user clicks on the freeze table.- Specified by:
getMainTable
in interfaceFreezeColumnsManager
- Returns:
- the main table
-
getFreezeTable
Description copied from interface:FreezeColumnsManager
Gets the freeze table.- Specified by:
getFreezeTable
in interfaceFreezeColumnsManager
- Returns:
- the freeze table, null if freezing is not supported or no columns have been frozen
-
hideFreezeTable
public void hideFreezeTable()Description copied from interface:FreezeColumnsManager
Hides the freeze table.- Specified by:
hideFreezeTable
in interfaceFreezeColumnsManager
-
showFreezeTable
public void showFreezeTable()Description copied from interface:FreezeColumnsManager
Shows the freeze table.- Specified by:
showFreezeTable
in interfaceFreezeColumnsManager
-
isFreezeTable
Description copied from interface:FreezeColumnsManager
Indicates if a table is the freeze table.- Specified by:
isFreezeTable
in interfaceFreezeColumnsManager
- Parameters:
table
- the table to check- Returns:
- true if it is the freeze table, false otherwise
-
freezeColumn
Description copied from interface:FreezeColumnsManager
Freezes a column.- Specified by:
freezeColumn
in interfaceFreezeColumnsManager
- Parameters:
columnName
- the column to freeze
-
unfreezeColumn
Description copied from interface:FreezeColumnsManager
Unfreezes a column.- Specified by:
unfreezeColumn
in interfaceFreezeColumnsManager
- Parameters:
columnName
- the column to unfreeze
-
freezeColumn
Description copied from interface:FreezeColumnsManager
Freezes a column.- Specified by:
freezeColumn
in interfaceFreezeColumnsManager
- Parameters:
column
- the column to freeze
-
unfreezeColumn
Description copied from interface:FreezeColumnsManager
Unfreezes a column.- Specified by:
unfreezeColumn
in interfaceFreezeColumnsManager
- Parameters:
column
- the column to unfreeze
-
repaint
public void repaint()Description copied from interface:FreezeColumnsManager
Requests the freeze table to repaint.- Specified by:
repaint
in interfaceFreezeColumnsManager
-
isModified
public boolean isModified()Description copied from interface:FreezeColumnsManager
Indicates if the freeze columns have been altered since the table was first created (e.g. the freeze columns are different than what was specified in the layout hints)- Specified by:
isModified
in interfaceFreezeColumnsManager
- Returns:
- true if the columns have been modified, false otherwise
-
setModified
public void setModified(boolean modified)Description copied from interface:FreezeColumnsManager
Marks if the freeze columns have been modified.- Specified by:
setModified
in interfaceFreezeColumnsManager
- Parameters:
modified
- true if they have been modified, false otherwise
-
getTotalColumnCount
public int getTotalColumnCount()Description copied from interface:FreezeColumnsManager
Gets the total column count for both the freeze table and the main table.- Specified by:
getTotalColumnCount
in interfaceFreezeColumnsManager
- Returns:
- the total column count
-
getSelectedColumns
public int[] getSelectedColumns()Description copied from interface:FreezeColumnsManager
Gets the selected columns taking into account both the freeze table and the main table.- Specified by:
getSelectedColumns
in interfaceFreezeColumnsManager
- Returns:
- the selected columns
-
convertColumnIndexToModel
public int convertColumnIndexToModel(int viewColumnIndex)Description copied from interface:FreezeColumnsManager
Converts a view column index to a model column index taking into account both the freeze table and main table. Specifically, the input index for this method is one that is treating the two tables as one big table.- Specified by:
convertColumnIndexToModel
in interfaceFreezeColumnsManager
- Parameters:
viewColumnIndex
- the view column index- Returns:
- the model column index
-
getColumnName
Description copied from interface:FreezeColumnsManager
Gets the column name at view column position taking into account both the freeze table and the main table.- Specified by:
getColumnName
in interfaceFreezeColumnsManager
- Parameters:
column
- the view column index- Returns:
- the column name
-
getHiddenColumns
Description copied from interface:FreezeColumnsManager
Gets all the hidden columns taking into account both the freeze table and the main table.- Specified by:
getHiddenColumns
in interfaceFreezeColumnsManager
- Returns:
- a collection of hidden columns
-
getVisibleColumns
Description copied from interface:FreezeColumnsManager
Gets all the visible columns taking into account both the freeze table and the main table.- Specified by:
getVisibleColumns
in interfaceFreezeColumnsManager
- Returns:
- a collection of visible columns
-
hideAllColumns
public void hideAllColumns()Description copied from interface:FreezeColumnsManager
Hides all columns in both the freeze table and main table.- Specified by:
hideAllColumns
in interfaceFreezeColumnsManager
-
showColumn
Description copied from interface:FreezeColumnsManager
Shows a column in the correct table (freeze table or main table)- Specified by:
showColumn
in interfaceFreezeColumnsManager
- Parameters:
tableColumn
- the column to show
-
mayHideOrFreezeColumn
Description copied from interface:FreezeColumnsManager
Identifies if a specific column is eligible for hiding/freezing. We must not hide/freeze the final column in our mainTable, or we will have scrolling and viewport issues- Specified by:
mayHideOrFreezeColumn
in interfaceFreezeColumnsManager
- Parameters:
tableColumn
- a column within our table- Returns:
- true if the column may be hidden or frozen, else false
-
close
public void close()Close our changeListener(s)- Specified by:
close
in interfaceFreezeColumnsManager
-
onModelChanged
protected void onModelChanged()Handles when the model of the main table changes.
-