com.jstatcom.table
Class JSCAbstractDataTable
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JTable
-
- com.jstatcom.table.BorderTable
-
- com.jstatcom.table.JSCAbstractDataTable
-
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ListSelectionListener, javax.swing.event.RowSorterListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable
- Direct Known Subclasses:
- JSCNArrayTable, JSCSArrayTable
public abstract class JSCAbstractDataTable extends BorderTable
Abstract table to be subclassed by tables for data arrays, likeJSCSArrayandJSCNArray. Subclasses must provide implementations for setting the model according to the displayed data type. They should also overwritecreateDefaultDataModelfor a default model.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JTable
javax.swing.JTable.DropLocation, javax.swing.JTable.PrintMode
-
-
Field Summary
-
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
-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor and Description JSCAbstractDataTable()Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidaddNotify()Overwrites supermethod to retrieve symbol table from component hierarchy if this table is displayed.voidcreateDefaultColumnsFromModel()This method will create default columns for the table from the data model.javax.swing.table.TableCellRenderergetCellRenderer()Gets the renderer for the cells.int[]getIntSelectionIndex()Gets a vector with lengthgetRowCountof zeros and ones representing the selection status for each row.JSCDatagetJSCData()Gets a reference (not a copy) to the data object displayed in this table.java.awt.event.MouseListenergetMouseListener()Gets the mouse listener.intgetRowSelectionMode()Gets the selection mode for table rows.java.lang.StringgetSymbolName()Gets the name of the symbol to display.java.lang.StringgetSymbolNameSelRows()Gets the symbol name for the data object with the index of selected rows.ScopegetSymbolScope()Gets the current scope, which defines which symbol table to use (local,globalorupper).SymbolTablegetSymbolTable()Gets the explicitely set symbol table used by this table to retrieve symbols by their name.javax.swing.JPopupMenugetTablePopup()Gets theRIGHTmouse popup for the table.booleanisEditable()Gets whether table is editable.voidsetCellRenderer(javax.swing.table.TableCellRenderer renderer)Sets the renderer for all cells.voidsetColEditable(boolean editable, int colIndex, boolean clearPreviousBefore)Sets a columns editable.voidsetEditable(boolean editable)Sets whether table is editable.voidsetJSCData(JSCData data)Sets the data object to be displayed in this table.voidsetModel(javax.swing.table.TableModel model)Overwrites supermethod to fire a "model" property change event.abstract voidsetModelForJSCData(JSCData data)Sets the table model for a data object.abstract voidsetModelForSymbolName(SymbolTable table, java.lang.String name)Sets the table model according to the symbol defined bytableandname.voidsetMouseListener(java.awt.event.MouseListener listener)Sets the mouse listener.voidsetRowEditable(boolean editable, int rowIndex, boolean clearPreviousBefore)Sets a rows editable.voidsetRowSelectionMode(int newRowSelMode)Sets the selection mode for rows.voidsetSymbolName(java.lang.String symbolName)Sets the name of the symbol to display.voidsetSymbolNameSelRows(java.lang.String symbolNameSelRows)Sets the name of the symbol with the index of selected table rows.voidsetSymbolScope(Scope scope)Sets the symbol scope, which defines which symbol table to use (local,globalorupper).voidsetSymbolTable(SymbolTable table)Sets the symbol table used by this table to retrieve symbols by their name and the corresponding type for the table.voidsetTablePopup(javax.swing.JPopupMenu menu)Sets theRIGHTmouse popup for the table.voidtableChanged(javax.swing.event.TableModelEvent e)Overwrites supermethod to configure ecnclosing scrollpane and update selection data.voidupdateUI()Notification from theUIManagerthat the L&F has changed.voidvalueChanged(javax.swing.event.ListSelectionEvent e)Invoked when the list selection changes.-
Methods inherited from class com.jstatcom.table.BorderTable
columnAtPoint, getCellRect, getColumnWidth, getMaximumColumnWidth, getMaximumSize, getMinimumColumnWidth, getMinimumSize, getPreferredSize, isDynamicColumnWidth, maxCellLength, rowAtPoint, setBorder, setColumnWidth, setDynamicColumnWidth, setIntercellSpacing, setMaximumColumnWidth, setMinimumColumnWidth, sizeColumnsToFit
-
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, 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, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, prepareEditor, prepareRenderer, print, print, print, print, print, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sorterChanged
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, getPeer, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
JSCAbstractDataTable
public JSCAbstractDataTable()
Default constructor. ThedynamicColumnWidthproperty is set totrue.
-
-
Method Detail
-
setColEditable
public void setColEditable(boolean editable, int colIndex, boolean clearPreviousBefore)Sets a columns editable.- Parameters:
editable-colIndex-clearPreviousBefore- clear previous editable states
-
setRowEditable
public void setRowEditable(boolean editable, int rowIndex, boolean clearPreviousBefore)Sets a rows editable.- Parameters:
editable-rowIndex-clearPreviousBefore- clear previous editable states
-
isEditable
public boolean isEditable()
Gets whether table is editable. Default isfalse.- Returns:
trueif editable
-
setEditable
public void setEditable(boolean editable)
Sets whether table is editable. Default isfalse.- Parameters:
editable-trueif editable
-
getSymbolName
public java.lang.String getSymbolName()
Gets the name of the symbol to display. The symbol is retrieved from the symbol table of the given scope.- Returns:
- name of the symbol
-
setSymbolName
public void setSymbolName(java.lang.String symbolName)
Sets the name of the symbol to display. The symbol is retrieved from the symbol table of the given scope.- Parameters:
symbolName- symbol name- Throws:
java.lang.IllegalArgumentException- ifsymbolNameis invalid
-
getSymbolScope
public Scope getSymbolScope()
Gets the current scope, which defines which symbol table to use (local,globalorupper).- Returns:
- symbol scope
-
setSymbolScope
public void setSymbolScope(Scope scope)
Sets the symbol scope, which defines which symbol table to use (local,globalorupper). This also sets a previously set symbol table tonull.- Parameters:
scope- the symbol scope- Throws:
java.lang.IllegalArgumentException-if (scope == null)
-
updateUI
public void updateUI()
Notification from theUIManagerthat the L&F has changed. Replaces the current UI object with the latest version from theUIManager.Reimplementation of superclass method.
- Overrides:
updateUIin classjavax.swing.JTable- See Also:
JComponent.updateUI()
-
getMouseListener
public java.awt.event.MouseListener getMouseListener()
Gets the mouse listener. Can be used to change table values by clicking on it. Default isnull.- Returns:
- a mouse listener
-
setMouseListener
public void setMouseListener(java.awt.event.MouseListener listener)
Sets the mouse listener. Can be used to change table values by clicking on it. Default isnull. An enumeration of mouse listeners is given inJSCMouseListenerTypes.- Parameters:
listener- a mouse listener
-
getCellRenderer
public javax.swing.table.TableCellRenderer getCellRenderer()
Gets the renderer for the cells. The default isJSCCellRendererTypes.DEFAULT.- Returns:
- cell renderer that is used for all cells
-
setCellRenderer
public void setCellRenderer(javax.swing.table.TableCellRenderer renderer)
Sets the renderer for all cells. The default isJSCCellRendererTypes.DEFAULT.- Parameters:
renderer- a cell renderer
-
getTablePopup
public javax.swing.JPopupMenu getTablePopup()
Gets theRIGHTmouse popup for the table.- Returns:
- a popup menu
-
setTablePopup
public void setTablePopup(javax.swing.JPopupMenu menu)
Sets theRIGHTmouse popup for the table. An enumeration of popups can be found inJSCPopupTypes.- Parameters:
menu- a popup menu
-
getJSCData
public JSCData getJSCData()
Gets a reference (not a copy) to the data object displayed in this table. If the underlying table model is not of typeJSCAbstractTableModel,nullis returned.Usage note:
The returned data is a reference to the underlyingJSCDataobject only until a new data object has been set. It should be used read only. Changes that should not affect this table must be made on a copy of the returned object.- Returns:
- table data
-
setJSCData
public void setJSCData(JSCData data)
Sets the data object to be displayed in this table. If this is set, then the symbol name be set tonull. Ifdata == null, then the table will be cleared and display zero rows and zero columns.- Parameters:
data- to display
-
addNotify
public void addNotify()
Overwrites supermethod to retrieve symbol table from component hierarchy if this table is displayed.- Overrides:
addNotifyin classjavax.swing.JTable
-
setModel
public void setModel(javax.swing.table.TableModel model)
Overwrites supermethod to fire a "model" property change event.- Overrides:
setModelin classjavax.swing.JTable- Parameters:
model- the new table model
-
getSymbolTable
public SymbolTable getSymbolTable()
Gets the explicitely set symbol table used by this table to retrieve symbols by their name. If non has been set before,nullis returned.- Returns:
- symbol table
-
setModelForJSCData
public abstract void setModelForJSCData(JSCData data)
Sets the table model for a data object. Implementations should throw anIllegalArgumentExceptionifdatais not of the correct type for the table. Anullargument should be allowed for to make it possible to clear the table model. The method is called bysetJSCData.- Parameters:
data- the new data for this table
-
setModelForSymbolName
public abstract void setModelForSymbolName(SymbolTable table, java.lang.String name)
Sets the table model according to the symbol defined bytableandname. The type of the symbol to retrieve must be set by the implementing table. The method is called bysetSymbolTableandsetSymbolName.The implementation should also handle
nullaguments. In this case, an empty model should be set.- Parameters:
table- the data table to retrieve the symbol fromname- the name of the symbol to get
-
setSymbolTable
public void setSymbolTable(SymbolTable table)
Sets the symbol table used by this table to retrieve symbols by their name and the corresponding type for the table. Iftable == nullthen the symbol will be retrieved from the symbol scope hierarchy.- Parameters:
table- a symbol table
-
createDefaultColumnsFromModel
public void createDefaultColumnsFromModel()
This method will create default columns for the table from the data model.This method will clear any exsiting columns before creating the new columns based on information from the model.
- Overrides:
createDefaultColumnsFromModelin classBorderTable- See Also:
JTable.getAutoCreateColumnsFromModel()
-
setRowSelectionMode
public void setRowSelectionMode(int newRowSelMode)
Sets the selection mode for rows.- Parameters:
newRowSelMode- one ofListSelectionModel.SINGLE_SELECTION,ListSelectionModel.SINGLE_INTERVALorListSelectionModel.MULTIPLE_INTERVAL_SELECTION
-
getRowSelectionMode
public int getRowSelectionMode()
Gets the selection mode for table rows.- Returns:
- one of
ListSelectionModel.SINGLE_SELECTION,ListSelectionModel.SINGLE_INTERVALorListSelectionModel.MULTIPLE_INTERVAL_SELECTION
-
getSymbolNameSelRows
public java.lang.String getSymbolNameSelRows()
Gets the symbol name for the data object with the index of selected rows.- Returns:
- the symbol name for the row selection index
-
setSymbolNameSelRows
public void setSymbolNameSelRows(java.lang.String symbolNameSelRows)
Sets the name of the symbol with the index of selected table rows. The contents of this data object are the results from the a call togetIntSelectionIndex. The symbol is updated everytime the table selection changes. Changes in this symbol do not change the selection in this table. The selection index will only be stored, if the symbol name is set and the symbol table has been set as well or can be retrieved for the symbol scope.- Parameters:
symbolNameSelRows- symbol name- Throws:
java.lang.IllegalArgumentException- ifsymbolNameSelRowsis invalid
-
tableChanged
public void tableChanged(javax.swing.event.TableModelEvent e)
Overwrites supermethod to configure ecnclosing scrollpane and update selection data. It fires a "columnWidth" property change event. The old value is always set to -1.- Specified by:
tableChangedin interfacejavax.swing.event.TableModelListener- Overrides:
tableChangedin classBorderTable- Parameters:
e- the table model event
-
valueChanged
public void valueChanged(javax.swing.event.ListSelectionEvent e)
Invoked when the list selection changes. Updates selection data.- Specified by:
valueChangedin interfacejavax.swing.event.ListSelectionListener- Overrides:
valueChangedin classjavax.swing.JTable- Parameters:
e- the list selection event
-
getIntSelectionIndex
public int[] getIntSelectionIndex()
Gets a vector with lengthgetRowCountof zeros and ones representing the selection status for each row. This is different fromgetSelectedRowswhich returns the selected indizes. In case of an empty selection, a zero vector with lengthgetRowCountis returned.- Returns:
- selection index for each row, 1 selects
-
-
DMelt 3.0 © DataMelt by jWork.ORG