Package adams.gui.core
Class BaseTable
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JTable
-
- adams.gui.core.BaseTable
-
- All Implemented Interfaces:
SpreadSheetSupporter,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,CellEditorListener,ListSelectionListener,RowSorterListener,TableColumnModelListener,TableModelListener,Scrollable
- Direct Known Subclasses:
AttributeSummaryPanel.StatisticsTable,ContainerTable,DataTable,SortableAndSearchableTable
public class BaseTable extends JTable implements SpreadSheetSupporter
A specialized JTable that allows double-clicking on header for resizing to optimal width.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseTable.ColumnWidthApproachEnumeration of possible ways to calculate column width approach.-
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected HashSet<PopupMenuListener>m_CellPopupMenuListenersthe popup menu listeners for the cells.protected BaseTable.ColumnWidthApproachm_ColumnWidthApproachwhether to automatically set optimal column widths.protected SpreadSheetFileChooserm_FileChooserthe file chooser for saving the spreadsheet.protected HashSet<PopupMenuListener>m_HeaderPopupMenuListenersthe popup menu listeners for the header row.protected intm_MaxColumnOptimalColumnWidthCalcthe maximum number of columns for optimal column width calculation.protected intm_MaxColumnOptimalHeaderWidthCalcthe maximum number of columns for optimal header width calculation.protected HashSet<RemoveItemsListener>m_RemoveItemsListenersthe listeners for items to be removed.protected booleanm_ShowSimpleCellPopupMenuwhether to show a simple cell popup menu.protected booleanm_ShowSimpleHeaderPopupMenuwhether to show a simple header popup menu.protected PopupMenuListenerm_SimpleCellPopupMenuListenerthe simple cell popup menu listener.protected PopupMenuListenerm_SimpleHeaderPopupMenuListenerthe simple header popup menu listener.protected JTableHelperm_TableHelperfor setting the optimal column width.protected intm_TooManyColumnsDefaultWidththe column width to use when too many columns present.-
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description BaseTable()Constructs a defaultBaseTablethat is initialized with a default data model, a default column model, and a default selection model.BaseTable(int numRows, int numColumns)Constructs aBaseTablewithnumRowsandnumColumnsof empty cells usingDefaultTableModel.BaseTable(Object[][] rowData, Object[] columnNames)Constructs aBaseTableto display the values in the two dimensional array,rowData, with column names,columnNames.BaseTable(Vector rowData, Vector columnNames)Constructs aBaseTableto display the values in theVectorofVectors,rowData, with column names,columnNames.BaseTable(TableModel dm)Constructs aBaseTablethat is initialized withdmas the data model, a default column model, and a default selection model.BaseTable(TableModel dm, TableColumnModel cm)Constructs aBaseTablethat is initialized withdmas the data model,cmas the column model, and a default selection model.BaseTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)Constructs aBaseTablethat is initialized withdmas the data model,cmas the column model, andsmas the selection model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadaptiveOptimalColumnWidth()Adaptive way of setting the optimal column width for all columns.voidaddCellPopupMenuListener(PopupMenuListener l)Adds the popup menu listeners for the cell.voidaddHeaderPopupMenuListener(PopupMenuListener l)Adds the popup menu listeners for the header.voidaddRemoveItemsListener(RemoveItemsListener l)Adds the remove items listener to its internal list.voidcopyToClipboard()Copies either the selected rows to the clipboard.protected BasePopupMenucreateSimpleCellPopupMenu(MouseEvent e)Creates a simple cell popup menu.protected BasePopupMenucreateSimpleHeaderPopupMenu(MouseEvent e)Creates a simple header popup menu.protected intenterColumnWidth()Prompts the user to enter a column width.protected voidfinishInit()Finishes the initialization.BaseTable.ColumnWidthApproachgetColumnWidthApproach()Returns how to set the optimal column widths.int[]getColumnWidths()Returns the column widths.protected SpreadSheetFileChoosergetFileChooser()Returns the filechooser for saving the table as spreadsheet.intgetMaxColumnOptimalColumnWidthCalc()Returns the maximum number of columns before no longer attempting to calculate the optimal column width.intgetMaxColumnOptimalHeaderWidthCalc()Returns the maximum number of columns before no longer attempting to calculate the optimal header width.intgetSelectedRow()Returns the index of the first selected row, -1 if no row is selected.int[]getSelectedRows()Returns the indices of all selected rows.booleangetShowSimpleCellPopupMenu()Returns whether to show a simple cell popup menu.booleangetShowSimpleHeaderPopupMenu()Returns whether to show a simple header popup menu.protected JTableHelpergetTableHelper()Returns the table helper instance.intgetTooManyColumnsDefaultWidth()Returns the default width to use if there are too many column to neither calculate the optimal column or header width.protected voidinitGUI()Initializes some GUI-related things.protected BaseTable.ColumnWidthApproachinitialUseOptimalColumnWidths()Returns the initial setting of whether to set optimal column widths.voidinvertRowSelection()Inverts the selected rows.voidinvertSelection()Inverts the selection.protected SpreadSheetmodelToSpreadSheet()Returns the underlying sheet.protected voidnotifyCellPopupMenuListener(MouseEvent e)Notifies the popup menu listeners (cell).protected voidnotifyHeaderPopupMenuListener(MouseEvent e)Notifies the popup menu listeners (header).protected voidnotifyRemoveItemsListeners(int[] indices)Notifies the remove items listeners about the indices that are to be removed.voidremoveCellPopupMenuListener(PopupMenuListener l)Removes the popup menu listener for the cell from its internal list.voidremoveHeaderPopupMenuListener(PopupMenuListener l)Removes the popup menu listener for the header from its internal list.voidremoveRemoveItemsListener(RemoveItemsListener l)Removes the remove items listener from its internal list.protected voidsaveAs(TableRowRange range)Pops up a save dialog for saving the data to a file.voidscrollColumnToVisible(int col)Scrolls the column into view.voidscrollRowToVisible(int row)Scrolls the row into view.voidselectAll()Selects all rows.protected intselectionRowToModelRow(int index)Determines the actual row index.voidselectNone()Deselects all rows.voidsetColumnWidth(int column)Prompts the user for a col width value and sets the column width for the specified column.voidsetColumnWidth(int column, int width)Sets the specified column width for the specified column.voidsetColumnWidthApproach(BaseTable.ColumnWidthApproach value)Sets whether to automatically set optimal column widths.voidsetColumnWidths()Prompts the user for a col width value and sets the column width for all columns.voidsetColumnWidths(int width)Sets the specified column width for all columns.voidsetColumnWidths(int[] value)Sets the column widths.voidsetMaxColumnOptimalColumnWidthCalc(int value)Sets the maximum number of columns before no longer attempting to calculate the optimal column width.voidsetMaxColumnOptimalHeaderWidthCalc(int value)Sets the maximum number of columns before no longer attempting to calculate the optimal header width.voidsetOptimalColumnWidth()Sets the optimal column width for all columns.voidsetOptimalColumnWidth(int column)Sets the optimal column width for the specified column.voidsetOptimalColumnWidthBounded(int max)Sets the optimal column width for all columns.voidsetOptimalColumnWidthBounded(int column, int max)Sets the optimal column width for the specified column.voidsetOptimalColumnWidths(int[] columns)Sets the optimal column widths for the specified columns.voidsetOptimalColumnWidthsBounded(int[] columns, int max)Sets the optimal columns width for the specified columns.voidsetOptimalHeaderWidth()Sets the optimal header width for all columns.voidsetOptimalHeaderWidth(int column)Sets the optimal header width for the specified column.voidsetSelectedRow(int row)Sets the selected row (clears all others).voidsetSelectedRows(int[] rows)Sets the selected rows (clears all others).voidsetShowSimpleCellPopupMenu(boolean value)Sets whether to show a simple cell popup menu.voidsetShowSimpleHeaderPopupMenu(boolean value)Sets whether to show a simple header popup menu.voidsetShowSimplePopupMenus(boolean value)Sets whether to show a simple header/cell popup menu.voidsetTooManyColumnsDefaultWidth(int value)Sets the default width to use if there are too many column to neither calculate the optimal column or header width.voidshowCell(int row, int column)Displays the specified cell.protected voidshowSimpleCellPopupMenu(MouseEvent e)Pops up a simple cell menu.protected voidshowSimpleHeaderPopupMenu(MouseEvent e)Pops up a simple header menu.SpreadSheettoSpreadSheet()Returns the underlying sheet.SpreadSheettoSpreadSheet(TableRowRange range)Returns the underlying sheet.SpreadSheettoSpreadSheet(TableRowRange range, boolean view)Returns the underlying sheet.-
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRowCount, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, unconfigureEnclosingScrollPane, updateUI, valueChanged
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
m_TableHelper
protected JTableHelper m_TableHelper
for setting the optimal column width.
-
m_RemoveItemsListeners
protected HashSet<RemoveItemsListener> m_RemoveItemsListeners
the listeners for items to be removed.
-
m_HeaderPopupMenuListeners
protected HashSet<PopupMenuListener> m_HeaderPopupMenuListeners
the popup menu listeners for the header row.
-
m_CellPopupMenuListeners
protected HashSet<PopupMenuListener> m_CellPopupMenuListeners
the popup menu listeners for the cells.
-
m_ShowSimpleHeaderPopupMenu
protected boolean m_ShowSimpleHeaderPopupMenu
whether to show a simple header popup menu.
-
m_ShowSimpleCellPopupMenu
protected boolean m_ShowSimpleCellPopupMenu
whether to show a simple cell popup menu.
-
m_SimpleHeaderPopupMenuListener
protected PopupMenuListener m_SimpleHeaderPopupMenuListener
the simple header popup menu listener.
-
m_SimpleCellPopupMenuListener
protected PopupMenuListener m_SimpleCellPopupMenuListener
the simple cell popup menu listener.
-
m_FileChooser
protected SpreadSheetFileChooser m_FileChooser
the file chooser for saving the spreadsheet.
-
m_MaxColumnOptimalColumnWidthCalc
protected int m_MaxColumnOptimalColumnWidthCalc
the maximum number of columns for optimal column width calculation.
-
m_MaxColumnOptimalHeaderWidthCalc
protected int m_MaxColumnOptimalHeaderWidthCalc
the maximum number of columns for optimal header width calculation.
-
m_TooManyColumnsDefaultWidth
protected int m_TooManyColumnsDefaultWidth
the column width to use when too many columns present.
-
m_ColumnWidthApproach
protected BaseTable.ColumnWidthApproach m_ColumnWidthApproach
whether to automatically set optimal column widths.
-
-
Constructor Detail
-
BaseTable
public BaseTable()
Constructs a defaultBaseTablethat is initialized with a default data model, a default column model, and a default selection model.
-
BaseTable
public BaseTable(int numRows, int numColumns)Constructs aBaseTablewithnumRowsandnumColumnsof empty cells usingDefaultTableModel. The columns will have names of the form "A", "B", "C", etc.- Parameters:
numRows- the number of rows the table holdsnumColumns- the number of columns the table holds
-
BaseTable
public BaseTable(Object[][] rowData, Object[] columnNames)
Constructs aBaseTableto display the values in the two dimensional array,rowData, with column names,columnNames.rowDatais an array of rows, so the value of the cell at row 1, column 5 can be obtained with the following code:rowData[1][5];
All rows must be of the same length as
columnNames.- Parameters:
rowData- the data for the new tablecolumnNames- names of each column
-
BaseTable
public BaseTable(Vector rowData, Vector columnNames)
Constructs aBaseTableto display the values in theVectorofVectors,rowData, with column names,columnNames. TheVectorscontained inrowDatashould contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:((Vector)rowData.elementAt(1)).elementAt(5);
- Parameters:
rowData- the data for the new tablecolumnNames- names of each column
-
BaseTable
public BaseTable(TableModel dm)
Constructs aBaseTablethat is initialized withdmas the data model, a default column model, and a default selection model.- Parameters:
dm- the data model for the table
-
BaseTable
public BaseTable(TableModel dm, TableColumnModel cm)
Constructs aBaseTablethat is initialized withdmas the data model,cmas the column model, and a default selection model.- Parameters:
dm- the data model for the tablecm- the column model for the table
-
BaseTable
public BaseTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Constructs aBaseTablethat is initialized withdmas the data model,cmas the column model, andsmas the selection model. If any of the parameters arenullthis method will initialize the table with the corresponding default model. TheautoCreateColumnsFromModelflag is set to false ifcmis non-null, otherwise it is set to true and the column model is populated with suitableTableColumnsfor the columns indm.- Parameters:
dm- the data model for the tablecm- the column model for the tablesm- the row selection model for the table
-
-
Method Detail
-
getTableHelper
protected JTableHelper getTableHelper()
Returns the table helper instance. Instantiates it if necessary.- Returns:
- the table helper
-
initGUI
protected void initGUI()
Initializes some GUI-related things.
-
finishInit
protected void finishInit()
Finishes the initialization.
-
initialUseOptimalColumnWidths
protected BaseTable.ColumnWidthApproach initialUseOptimalColumnWidths()
Returns the initial setting of whether to set optimal column widths. Default implementation returns "false", since large tables might take too long to be displayed otherwise.- Returns:
- the approach
-
setColumnWidthApproach
public void setColumnWidthApproach(BaseTable.ColumnWidthApproach value)
Sets whether to automatically set optimal column widths.- Parameters:
value- if true then optimal column widths are used
-
getColumnWidthApproach
public BaseTable.ColumnWidthApproach getColumnWidthApproach()
Returns how to set the optimal column widths. Default implementation is initialized with "NONE".- Returns:
- the optimal column widths strategy
-
selectNone
public void selectNone()
Deselects all rows.
-
invertSelection
public void invertSelection()
Inverts the selection.
-
setSelectedRow
public void setSelectedRow(int row)
Sets the selected row (clears all others).- Parameters:
row- the row to select
-
setSelectedRows
public void setSelectedRows(int[] rows)
Sets the selected rows (clears all others).- Parameters:
rows- the rows to select
-
setMaxColumnOptimalColumnWidthCalc
public void setMaxColumnOptimalColumnWidthCalc(int value)
Sets the maximum number of columns before no longer attempting to calculate the optimal column width.- Parameters:
value- the maximum number of columns (incl)
-
getMaxColumnOptimalColumnWidthCalc
public int getMaxColumnOptimalColumnWidthCalc()
Returns the maximum number of columns before no longer attempting to calculate the optimal column width.- Returns:
- the maximum number of columns (incl)
- See Also:
adaptiveOptimalColumnWidth()
-
setMaxColumnOptimalHeaderWidthCalc
public void setMaxColumnOptimalHeaderWidthCalc(int value)
Sets the maximum number of columns before no longer attempting to calculate the optimal header width.- Parameters:
value- the maximum number of columns (incl)- See Also:
adaptiveOptimalColumnWidth()
-
getMaxColumnOptimalHeaderWidthCalc
public int getMaxColumnOptimalHeaderWidthCalc()
Returns the maximum number of columns before no longer attempting to calculate the optimal header width.- Returns:
- the maximum number of columns (incl)
- See Also:
adaptiveOptimalColumnWidth()
-
setTooManyColumnsDefaultWidth
public void setTooManyColumnsDefaultWidth(int value)
Sets the default width to use if there are too many column to neither calculate the optimal column or header width.- Parameters:
value- the default width- See Also:
adaptiveOptimalColumnWidth()
-
getTooManyColumnsDefaultWidth
public int getTooManyColumnsDefaultWidth()
Returns the default width to use if there are too many column to neither calculate the optimal column or header width.- Returns:
- the default width
- See Also:
adaptiveOptimalColumnWidth()
-
adaptiveOptimalColumnWidth
public void adaptiveOptimalColumnWidth()
Adaptive way of setting the optimal column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF. Approach: If less or equal tom_MaxColumnOptimalColumnWidthCalc, then calculate optimal column width. If less or equal tom_MaxColumnOptimalHeaderWidthCalc, then calculate optimal header width. Otherwise set the width of all columns tom_TooManyColumnsDefaultWidth.
-
setOptimalColumnWidth
public void setOptimalColumnWidth()
Sets the optimal column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.
-
setOptimalColumnWidthBounded
public void setOptimalColumnWidthBounded(int max)
Sets the optimal column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
max- the maximum width
-
setOptimalColumnWidth
public void setOptimalColumnWidth(int column)
Sets the optimal column width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
column- the column to resize
-
setOptimalColumnWidthBounded
public void setOptimalColumnWidthBounded(int column, int max)Sets the optimal column width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
column- the column to resizemax- the maximum width
-
setOptimalColumnWidths
public void setOptimalColumnWidths(int[] columns)
Sets the optimal column widths for the specified columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
columns- the columns to resize
-
setOptimalColumnWidthsBounded
public void setOptimalColumnWidthsBounded(int[] columns, int max)Sets the optimal columns width for the specified columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
columns- the columns to resizemax- the maximum width
-
setOptimalHeaderWidth
public void setOptimalHeaderWidth()
Sets the optimal header width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.
-
setOptimalHeaderWidth
public void setOptimalHeaderWidth(int column)
Sets the optimal header width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
column- the column to resize
-
enterColumnWidth
protected int enterColumnWidth()
Prompts the user to enter a column width.- Returns:
- the column width, -1 if not to proceed
-
setColumnWidths
public void setColumnWidths()
Prompts the user for a col width value and sets the column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.
-
setColumnWidths
public void setColumnWidths(int width)
Sets the specified column width for all columns. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
width- the width for all columns
-
setColumnWidth
public void setColumnWidth(int column)
Prompts the user for a col width value and sets the column width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
column- the column to resize
-
setColumnWidth
public void setColumnWidth(int column, int width)Sets the specified column width for the specified column. AutoResize must be set to BaseTable.AUTO_RESIZE_OFF.- Parameters:
column- the column to resizewidth- the width to use
-
scrollRowToVisible
public void scrollRowToVisible(int row)
Scrolls the row into view.- Parameters:
row- the row to scroll into view
-
scrollColumnToVisible
public void scrollColumnToVisible(int col)
Scrolls the column into view.- Parameters:
col- the column to scroll into view
-
addRemoveItemsListener
public void addRemoveItemsListener(RemoveItemsListener l)
Adds the remove items listener to its internal list.- Parameters:
l- the listener to add
-
removeRemoveItemsListener
public void removeRemoveItemsListener(RemoveItemsListener l)
Removes the remove items listener from its internal list.- Parameters:
l- the listener to remove
-
notifyRemoveItemsListeners
protected void notifyRemoveItemsListeners(int[] indices)
Notifies the remove items listeners about the indices that are to be removed.- Parameters:
indices- the indices that should get removed
-
addHeaderPopupMenuListener
public void addHeaderPopupMenuListener(PopupMenuListener l)
Adds the popup menu listeners for the header.- Parameters:
l- the listener to add
-
removeHeaderPopupMenuListener
public void removeHeaderPopupMenuListener(PopupMenuListener l)
Removes the popup menu listener for the header from its internal list.- Parameters:
l- the listener to remove
-
notifyHeaderPopupMenuListener
protected void notifyHeaderPopupMenuListener(MouseEvent e)
Notifies the popup menu listeners (header).- Parameters:
e- the mouse event
-
addCellPopupMenuListener
public void addCellPopupMenuListener(PopupMenuListener l)
Adds the popup menu listeners for the cell.- Parameters:
l- the listener to add
-
removeCellPopupMenuListener
public void removeCellPopupMenuListener(PopupMenuListener l)
Removes the popup menu listener for the cell from its internal list.- Parameters:
l- the listener to remove
-
notifyCellPopupMenuListener
protected void notifyCellPopupMenuListener(MouseEvent e)
Notifies the popup menu listeners (cell).- Parameters:
e- the mouse event
-
copyToClipboard
public void copyToClipboard()
Copies either the selected rows to the clipboard.
-
showCell
public void showCell(int row, int column)Displays the specified cell.- Parameters:
row- the row of the cellcolumn- the column of the cell
-
setShowSimplePopupMenus
public void setShowSimplePopupMenus(boolean value)
Sets whether to show a simple header/cell popup menu.- Parameters:
value- true if to show menus
-
setShowSimpleHeaderPopupMenu
public void setShowSimpleHeaderPopupMenu(boolean value)
Sets whether to show a simple header popup menu.- Parameters:
value- true if to show menu
-
getShowSimpleHeaderPopupMenu
public boolean getShowSimpleHeaderPopupMenu()
Returns whether to show a simple header popup menu.- Returns:
- true if to show menu
-
showSimpleHeaderPopupMenu
protected void showSimpleHeaderPopupMenu(MouseEvent e)
Pops up a simple header menu.- Parameters:
e- the trigger event
-
createSimpleHeaderPopupMenu
protected BasePopupMenu createSimpleHeaderPopupMenu(MouseEvent e)
Creates a simple header popup menu.- Parameters:
e- the trigger event- Returns:
- the popup menu
-
setShowSimpleCellPopupMenu
public void setShowSimpleCellPopupMenu(boolean value)
Sets whether to show a simple cell popup menu.- Parameters:
value- true if to show menu
-
getShowSimpleCellPopupMenu
public boolean getShowSimpleCellPopupMenu()
Returns whether to show a simple cell popup menu.- Returns:
- true if to show menu
-
showSimpleCellPopupMenu
protected void showSimpleCellPopupMenu(MouseEvent e)
Pops up a simple cell menu.- Parameters:
e- the trigger event
-
createSimpleCellPopupMenu
protected BasePopupMenu createSimpleCellPopupMenu(MouseEvent e)
Creates a simple cell popup menu.- Parameters:
e- the trigger event- Returns:
- the popup menu
-
modelToSpreadSheet
protected SpreadSheet modelToSpreadSheet()
Returns the underlying sheet.- Returns:
- the spread sheet
-
selectionRowToModelRow
protected int selectionRowToModelRow(int index)
Determines the actual row index.- Parameters:
index- the selected row- Returns:
- the actual model row
-
toSpreadSheet
public SpreadSheet toSpreadSheet()
Returns the underlying sheet.- Specified by:
toSpreadSheetin interfaceSpreadSheetSupporter- Returns:
- the spread sheet
-
toSpreadSheet
public SpreadSheet toSpreadSheet(TableRowRange range)
Returns the underlying sheet.- Parameters:
range- the type of rows to return- Returns:
- the spread sheet
-
toSpreadSheet
public SpreadSheet toSpreadSheet(TableRowRange range, boolean view)
Returns the underlying sheet.- Parameters:
range- the type of rows to returnview- whether to return only a view (ignored ifTableRowRange.ALL)- Returns:
- the spread sheet
-
invertRowSelection
public void invertRowSelection()
Inverts the selected rows.
-
getSelectedRow
public int getSelectedRow()
Returns the index of the first selected row, -1 if no row is selected.- Overrides:
getSelectedRowin classJTable- Returns:
- the index of the first selected row
-
getSelectedRows
public int[] getSelectedRows()
Returns the indices of all selected rows.- Overrides:
getSelectedRowsin classJTable- Returns:
- an array of integers containing the indices of all selected rows, or an empty array if no row is selected
- See Also:
getSelectedRow()
-
getColumnWidths
public int[] getColumnWidths()
Returns the column widths.- Returns:
- the current widths
-
setColumnWidths
public void setColumnWidths(int[] value)
Sets the column widths.- Parameters:
value- the widths
-
getFileChooser
protected SpreadSheetFileChooser getFileChooser()
Returns the filechooser for saving the table as spreadsheet.- Returns:
- the filechooser
-
saveAs
protected void saveAs(TableRowRange range)
Pops up a save dialog for saving the data to a file.- Parameters:
range- the type of data to save
-
-