Package com.portal.bas.comp
Class PIASpreadSheet
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
com.portal.bas.comp.PIASpreadSheet
- All Implemented Interfaces:
PAppComponent
,PAppFieldComponent
,PClientComponent
,PComponent
,PComponentAttribute
,PFieldBean
,PViewDataChangeListener
,ActionListener
,MouseListener
,ImageObserver
,MenuContainer
,Serializable
,Remote
,EventListener
,Accessible
,CellEditorListener
,ListSelectionListener
,RowSorterListener
,TableColumnModelListener
,TableModelListener
,Scrollable
- Direct Known Subclasses:
PIASpecSpreadSheet
,PNonCurrencyTable
public class PIASpreadSheet
extends JTable
implements PAppFieldComponent, MouseListener, ActionListener, ListSelectionListener, PComponentAttribute, Serializable
Swing compatible, Portal aware spreadsheet display class.
One of the powerful features of this component is that even while using the default renderers, the developer can specify the way the data is displayed on screen by using the
One of the powerful features of this component is that even while using the default renderers, the developer can specify the way the data is displayed on screen by using the
setIdxDisplayFieldFormat()
method. This means less work/code for the developer since they don't have
to implement their own renderers just to control the way the data is
displayed. Note that this spreadsheet contains an internal TableModel
so you should not have to explicitely set one. Besides, data will
typically be filled in automatically from the database via a call to
setModelHandle()
See the PTableCellEditor class for the set of default editors.- Author:
- Kapono Carter
- See Also:
-
Nested Class Summary
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
FieldsModifier and TypeFieldDescriptionprotected PropertyChangeSupport
protected Vector
<com.portal.app.util.CellVal> protected PComponentAttributeImpl
protected boolean
protected DefaultTableModel
protected PFieldDelegate
protected PIASelectionSupport
protected Vector
<PSpreadSheetListener> protected com.portal.bas.comp.PSpreadSheetModel
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Notify the given listener when the table row selection changesvoid
Overridden to add keyboard action listeners for the Enter invalid input: '&' Space keys.void
Used to append a row of data to the display.void
Notify the given listener when the user performs a gesturevoid
clear()
Removes all data from this table (and its model)protected Vector
convertToVector
(Object[][] data) Takes the given array and converts it to a Vector of Vectorsprotected void
void
Invoked when editing is finished.protected PTableCellEditor
An internal method used to determine the appropriate editor for the given Class typevoid
export
(BufferedWriter bw, String caption) Exports the table's data, as displayed on the screen, to the given FileOutputStream as HTML data.Returns the icon used for to indicate ascending sort.int
Returns the width for the ascending sort icon.Gets the associated class, if any, for this field.String[]
Retrieves the column names from the column modelRetrieves the class name of this component's controllerReturns the icon used for to indicate descending sort.int
Returns the width for the descending sort icon.Get the data field description used by the componentGets the display field format used by this componentgetExportHandler
(String caption) Retrieves an action listener that can be used to support an "export" command for this table.getExportHandler
(String caption, ExportTemplate h) Retrieves an action listener that can be used to support an "export" command for this table.getField()
Gets the value of the field referred to in thedisplayFieldDescription
.Get the current help id for this componentString[]
Retrieves the MessageFormat-compliant format pattern that should be used when rendering data in the table columnsgetIdxDisplayFieldFormat
(int col) Retrieves the MessageFormat-compliant format pattern that should be used when rendering data in the given columnGet the data field description used by the componentRetrieves the PModelHandle for this componentgetModelHandleAt
(int row) Retrieves the PModelHandle for a given row in this componentint
getModelIndex
(int row) Returns the table model index based upon the row index.protected PFieldComponentRenderer
getNewRenderer
(String pattern) Returns the new instance of PFieldComponentRenderer.Get a reference to the remote component for this object.Get the base resource name used in resource lookup.getRowPosition
(int row) Gets the screen position of the given row (at column 0).getRowPosition
(int row, int col) Gets the screen position of the given row (at column 0).int[]
Returns the saved selected rows.getTools()
Get a list of Actions supported by this component.void
hideColumn
(int modelIndex) Hides the specified column of data from the spreadsheetvoid
hideColumn
(int modelIndex, boolean saveToPref) Hides the specified column of data from the spreadsheet and stores in user prefrances so that it is hidden for next use also for the same userprotected String
void
Initialize layout of the column order and width based on saved preferences.void
Inserts a row of data to the table at the specified position regardless of the sort order.boolean
Determines if the component is displaying currency data.boolean
isDirty()
Determines if this component is currently in a DIRTY state.boolean
isError()
Used to determine if this component is currently in error stateboolean
Determines if this component allows data sorting by clicking on a column header.boolean
Determines if input tracking is enabled.boolean
isLight()
Determines if this is component defers PModelHandle knowledge to its parent container.boolean
Determines if this component is required in its current context.boolean
Determines if this table supports typed or untyped datavoid
void
void
void
void
void
removeColumn
(int col) Deletes the specified column of data from the spreadsheetvoid
Don't notify the given listener when the table row selection changesvoid
removeRow
(int row) Deletes the specified row of data from the spreadsheetvoid
Remove the given listener from the notification list when the user performs a gesturevoid
resetSortColumn
(int col) Resets the sort state for the specified column.void
Resets the component value to the original value (that which was established by callingsetDefault()
).void
revertToPrimary
(int primary) Causes the widget to display its data in the primary currencyvoid
Saves the column layout order and width to properties object mColProps.void
setAscendingSortIcon
(Icon icon) Sets the icon used for to indicate ascending sort.void
setAssociatedClass
(String name) Sets the associated class, if any, for this field.void
setClean()
Used to reset the component to the 'clean' state.void
setColumnData
(int column, Vector data) Used to specify the data that should be displayed in the given column.void
setColumnEditable
(int col, boolean editable) Determines if the end-user can click to edit data in the given column.void
setColumnIdentifiers
(String[] names) Establishes the header names for the table columnsvoid
setCurrencyDisplay
(boolean b) Used to determine if this component is displaying currency data.void
Replaces the current data displayed in the spreadsheet with the given data.void
Replaces the current data displayed in the spreadsheet with the given data.void
Establishes the current value (or element count, depending on the given component) as the default value.void
setDefaultEditor
(int col, TableCellEditor editor) Specifies the editor which should be used for the given column
Note that this editor takes precedence over the editor set by specifying the Class type.void
setDefaultRenderer
(int col, TableCellRenderer renderer) Specifies the renderer which should be used for the given column
Note that this renderer takes precedence over the renderer set by specifying the Class type.void
setDescendingSortIcon
(Icon icon) Sets the icon used for to indicate descending sort.void
setDisplayFieldDescription
(String fieldDisp) Set the description of the field(s) in the data model that this component will display.void
setDisplayFieldFormat
(String fieldForm) Sets the java.text.MessageFormat-type format used to display data in this component.void
setError
(boolean b) At this time, the entire table is marked.void
Sets the value of the field referred to in themodelFieldDescription
.void
setHeaderSortingSupported
(boolean b) Determines if this component allows data sorting by clicking on a column header.void
Set the help id for this component.void
setIdxDisplayFieldFormat
(int col, String pattern) Specifies the MessageFormat-compliant format pattern that should be used when rendering data in the given column.void
setIdxDisplayFieldFormat
(String[] pattern) Specifies the MessageFormat-compliant format pattern that should be used when rendering data in the table columns.void
setInputTracking
(boolean b) If input tracking is turned on, any changes made by the user to the component will be tracked and the component will be marked "dirty".void
setLayoutID
(String id) Specifies the unique id of this table when storing preferences.void
setModel
(TableModel newModel) Establish new data for the table.void
setModelFieldDescription
(String fieldDesc) Set the description of the field in the data model that this component is interested in.void
setModelHandle
(PModelHandle data) Establishes the PModelHandle for this componentvoid
setRequired
(boolean b) Marks this component as required in its current context.void
setResourceName
(String name) Set the base resource name used in resource lookup.void
Specifies the background color for the rows in this componentvoid
setRowBackground
(Color c1, Color c2) Specifies the alternating row color scheme for the componentvoid
setSelectedRows
(int[] selection) Convenience method that sets several selected rows.void
setUntypedData
(boolean b) Use this API to inform the table that the PModelHandle data it will receive from BAS will contain UNTYPED data (hand-generated FLists).protected void
void
setValueAt
(Object value, int row, int column) Override that maintains the selected rows in case the table is sorted and the view position of rows changes as a result of this call.void
setValueAt
(Object value, int row, int column, boolean dirtyTable) Override that maintains the selected rows in case the table is sorted and the view position of rows changes as a result of this call.void
showColumn
(int modelIndex) Shows the specified column of data in the spreadsheetvoid
showColumn
(int modelIndex, boolean saveToPref) Shows the specified column of data in the spreadsheet and stores in user prefrances so that it is displayed for next use also for the same uservoid
sortByColumn
(int column, boolean ascending) Causes the table to be sorted according to the specified column.void
Listener for tableChanged eventstogglePrimaryToSecondary
(int primary, int secondary) Causes the widget to convert its data using the BEIDManager.void
Used to disassociate this component from its delegate (controller)void
Implements the ListSelectionListener interface.void
Implements the PViewDataChangeListener interfaceMethods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, 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, 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, getSelectedRow, getSelectedRowCount, getSelectedRows, 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, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, unconfigureEnclosingScrollPane, updateUI
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 Details
-
mDataIsUntyped
protected boolean mDataIsUntyped -
dpyFldFmt
-
boundSupport
-
mTableModel
protected com.portal.bas.comp.PSpreadSheetModel mTableModel -
mDefaultModel
-
mImpl
-
mAttribImpl
-
mSelSup
-
mSpreadSheetListener
-
-
Constructor Details
-
PIASpreadSheet
public PIASpreadSheet()Creates a new Portal-aware spread sheet component. Selection of individual cells is allowed.
-
-
Method Details
-
addNotify
public void addNotify()Overridden to add keyboard action listeners for the Enter invalid input: '&' Space keys. -
unregister
Used to disassociate this component from its delegate (controller)- Specified by:
unregister
in interfacePClientComponent
- Throws:
RemoteException
-
setModelHandle
Establishes the PModelHandle for this component- Specified by:
setModelHandle
in interfacePComponent
- Parameters:
data
- The new PModelHandle from which information will be extracted.- Throws:
RemoteException
-
getModelHandle
Retrieves the PModelHandle for this component- Specified by:
getModelHandle
in interfacePComponent
- Returns:
- The PModelHandle associated with this component
- Throws:
RemoteException
-
getModelHandleAt
Retrieves the PModelHandle for a given row in this component- Returns:
- The PModelHandle associated with a row for this component
- Throws:
RemoteException
-
setUntypedData
public void setUntypedData(boolean b) Use this API to inform the table that the PModelHandle data it will receive from BAS will contain UNTYPED data (hand-generated FLists). This method is only really important if you are taking advantage of the BAS displayFieldDescription/modelFieldDescription stuff.
This method is necessary because when converting between FLists and PModelHandles, BAS will attempt to read Poid objects and refresh data if the FList contains such entities. However, if you have hand crafted FLists you typically don't want this to happen. You want the FList you created to be turned into a PModelHandle and that exact same FList returned when you ask for it. Call this method if that is the situation you find yourself in.
Something to consider. If you are getting FLists back from and Portal search opcode and displaying them in a table, you probably don't need to call this API - you will probably already have real Portal storable classes.- Parameters:
b
- If true, informs the table its data should be considered UNTYPED This is false by default
-
isUntypedData
public boolean isUntypedData()Determines if this table supports typed or untyped data- Returns:
- The state of this table's data
-
isLight
Determines if this is component defers PModelHandle knowledge to its parent container. If so, the parent container will pass the PModelHandle to this component on the server side (via the controller) saving a client/server roundtrip for data exchange. If you need to do specific processing of some kind when PModelHandle is called you'll need to subclass this component and override this method. OtherwisesetModelHandle()
will not be called.- Specified by:
isLight
in interfacePComponent
- Returns:
- false
- Throws:
RemoteException
-
getControllerClassName
Retrieves the class name of this component's controller- Specified by:
getControllerClassName
in interfacePComponent
- Returns:
- The name of the controller for this component
- Throws:
RemoteException
-
getTools
Get a list of Actions supported by this component. When subclassed, the overriding class should call its super class version, then add its actions to the retuned list. This preserves actions supplied by base classes. The default, supplied here, include Help for this component.- Specified by:
getTools
in interfacePClientComponent
- Returns:
- a Vector containing Action objects
-
setResourceName
Set the base resource name used in resource lookup. Basically, the resource name will be this base, followed by a dot, flowwed by the local name (label).- Specified by:
setResourceName
in interfacePClientComponent
- Parameters:
name
- The new base resource name.
-
getResourceName
Get the base resource name used in resource lookup.- Specified by:
getResourceName
in interfacePClientComponent
- Returns:
- The base resource name
- Throws:
RemoteException
-
getRemoteComponent
Get a reference to the remote component for this object. The remote component is used when interfacing with this component's controller.- Specified by:
getRemoteComponent
in interfacePAppComponent
- Returns:
- a RemoteComponent
-
setModelFieldDescription
Set the description of the field in the data model that this component is interested in.- Specified by:
setModelFieldDescription
in interfacePFieldBean
- Parameters:
fieldDesc
- A String describing the field used by this component.- Throws:
RemoteException
-
getModelFieldDescription
Get the data field description used by the component- Specified by:
getModelFieldDescription
in interfacePFieldBean
- Returns:
- a string description of the field used by this component
- Throws:
RemoteException
-
setDisplayFieldDescription
Set the description of the field(s) in the data model that this component will display.- Specified by:
setDisplayFieldDescription
in interfacePFieldBean
- Parameters:
fieldDisp
- aString
that describes the fieldfieldDesc
- A String describing the field displayed by this component.- Throws:
RemoteException
-
getDisplayFieldDescription
Get the data field description used by the component- Specified by:
getDisplayFieldDescription
in interfacePFieldBean
- Returns:
- a string description of the field used by this component
- Throws:
RemoteException
-
setDisplayFieldFormat
Sets the java.text.MessageFormat-type format used to display data in this component. This is typically (but not necessarily) directly tied to the DisplayFieldDescription. For example, the DisplayFieldDescriptio might be "FldNameinfo[any].FldFirstName, FldNameinfo[any].FldLastName" and the DisplayFieldFormat for that might be "{1}, {0}" to display the last name followed by a comma and then the first name.
This method is superceded bysetIdxDisplayFieldFormat()
which allows format specifications on a per/column basis.- Specified by:
setDisplayFieldFormat
in interfacePAppFieldComponent
- Parameters:
fieldForm
- the format used when displaying the data- Throws:
RemoteException
-
getDisplayFieldFormat
Gets the display field format used by this component- Specified by:
getDisplayFieldFormat
in interfacePAppFieldComponent
- Returns:
- a String representation of the display field format
- Throws:
RemoteException
-
setAssociatedClass
Description copied from interface:PFieldBean
Sets the associated class, if any, for this field.- Specified by:
setAssociatedClass
in interfacePFieldBean
- Parameters:
name
- the class name- Throws:
RemoteException
- thrown for errors
-
getAssociatedClass
Description copied from interface:PFieldBean
Gets the associated class, if any, for this field.- Specified by:
getAssociatedClass
in interfacePFieldBean
- Returns:
- The class name or null.
- Throws:
RemoteException
- thrown for errors
-
setField
Description copied from interface:PFieldBean
Sets the value of the field referred to in themodelFieldDescription
.- Specified by:
setField
in interfacePFieldBean
- Parameters:
field
- the field's value- Throws:
RemoteException
- thrown for errors
-
getField
Description copied from interface:PFieldBean
Gets the value of the field referred to in thedisplayFieldDescription
.- Specified by:
getField
in interfacePFieldBean
- Returns:
- the field's value
- Throws:
RemoteException
- thrown for errors
-
setHelpID
Set the help id for this component.- Specified by:
setHelpID
in interfacePAppFieldComponent
- Parameters:
id
- The new help id.
-
getHelpID
Get the current help id for this component- Specified by:
getHelpID
in interfacePAppFieldComponent
- Returns:
- A String help id
-
resetToDefault
public void resetToDefault()Resets the component value to the original value (that which was established by callingsetDefault()
). If no default value exists, the component data will be cleared.- Specified by:
resetToDefault
in interfacePComponentAttribute
-
clear
public void clear()Removes all data from this table (and its model)- Specified by:
clear
in interfacePComponentAttribute
-
isRequired
public boolean isRequired()Determines if this component is required in its current context. This is currently a visual indicator only - there is no policy to enforce that required fields get filled in.- Specified by:
isRequired
in interfacePComponentAttribute
- Returns:
- true if this field is required
-
setRequired
public void setRequired(boolean b) Marks this component as required in its current context. This is currently a visual indicator only - there is no policy to enforce that required fields get filled in. At this time, the entire table is marked. Eventually cell marking will be allowed.- Specified by:
setRequired
in interfacePComponentAttribute
- Parameters:
b
- the required flag
-
setError
public void setError(boolean b) At this time, the entire table is marked. Eventually cell marking will be allowed.- Specified by:
setError
in interfacePComponentAttribute
- Parameters:
b
- the new state of the Error attribute
-
isError
public boolean isError()Used to determine if this component is currently in error state- Specified by:
isError
in interfacePComponentAttribute
- Returns:
- the error state of this component
-
setInputTracking
public void setInputTracking(boolean b) If input tracking is turned on, any changes made by the user to the component will be tracked and the component will be marked "dirty". If the user modifies the data and returns it to its default/original state, the component will be marked "clean", or not "dirty".- Specified by:
setInputTracking
in interfacePComponentAttribute
- Parameters:
b
- the state of theinputTracking
property
-
isInputTracking
public boolean isInputTracking()Description copied from interface:PComponentAttribute
Determines if input tracking is enabled.- Specified by:
isInputTracking
in interfacePComponentAttribute
- Returns:
- the state of the input tracking flag
-
setClean
public void setClean()Used to reset the component to the 'clean' state. If the component was in dirty or error state, this method will remove those attributes. A required component will still be marked required after a call to this method.- Specified by:
setClean
in interfacePComponentAttribute
-
isDirty
public boolean isDirty()Description copied from interface:PComponentAttribute
Determines if this component is currently in a DIRTY state.- Specified by:
isDirty
in interfacePComponentAttribute
- Returns:
- true if the user has modified the data represented by this component, false otherwise. It also returns false if input tracking is off.
-
setDefault
public void setDefault()Establishes the current value (or element count, depending on the given component) as the default value. Any modifications after this method is called will result in a "dirty" component.- Specified by:
setDefault
in interfacePComponentAttribute
-
isCurrencyDisplay
public boolean isCurrencyDisplay()Determines if the component is displaying currency data.- Specified by:
isCurrencyDisplay
in interfacePComponentAttribute
- Returns:
- true if the widget is displaying currency data; false otherwise
-
setCurrencyDisplay
public void setCurrencyDisplay(boolean b) Used to determine if this component is displaying currency data. Widgets displaying currency data are capable of automatically toggling their data between 2 Portal currency types (primary invalid input: '&' secondary).- Specified by:
setCurrencyDisplay
in interfacePComponentAttribute
- Parameters:
b
- If true, indicates the widget is displaying currency data.
-
togglePrimaryToSecondary
Causes the widget to convert its data using the BEIDManager.- Specified by:
togglePrimaryToSecondary
in interfacePComponentAttribute
- Specified by:
togglePrimaryToSecondary
in interfacePFieldBean
- Parameters:
primary
-secondary
-- Returns:
- The converted value.
- Throws:
RemoteException
-
revertToPrimary
Causes the widget to display its data in the primary currency- Specified by:
revertToPrimary
in interfacePComponentAttribute
- Specified by:
revertToPrimary
in interfacePFieldBean
- Parameters:
primary
- The primary currency ID for an account- Throws:
RemoteException
-
tableChanged
Listener for tableChanged events- Specified by:
tableChanged
in interfaceTableModelListener
- Overrides:
tableChanged
in classJTable
- Parameters:
the
- change event
-
setModel
Establish new data for the table. Note that this will wipe out established renderers/editors if set on a per/column basis. -
editingStopped
Invoked when editing is finished. The changes are saved, the editor object is discarded, and the cell is rendered once again. Overridden to support marking of the table and/or cells.- Specified by:
editingStopped
in interfaceCellEditorListener
- Overrides:
editingStopped
in classJTable
- See Also:
-
setHeaderSortingSupported
public void setHeaderSortingSupported(boolean b) Determines if this component allows data sorting by clicking on a column header.- Parameters:
b
- If true, sorting will be allowed.
-
sortByColumn
public void sortByColumn(int column, boolean ascending) Causes the table to be sorted according to the specified column.- Parameters:
column
- the view index of the columnascending
- if true, the sort will be in ascending order
-
isHeaderSortingSupported
public boolean isHeaderSortingSupported()Determines if this component allows data sorting by clicking on a column header.- Returns:
- true if sorting is supported in this instance, false otherwise
-
getRowPosition
Gets the screen position of the given row (at column 0). Useful if you need to position dialogs at a given row.- Parameters:
row
- The row whose position you wish to retrieve- Returns:
- The screen position
-
getRowPosition
Gets the screen position of the given row (at column 0). Useful if you need to position dialogs at a given row.- Parameters:
row
- The row whose position you wish to retrievecol
- The col whose position you wish to retrieve- Returns:
- The screen position
-
setSelectedRows
public void setSelectedRows(int[] selection) Convenience method that sets several selected rows.- Parameters:
an
- array ofint
s containing the indices of rows to be selected.
-
setRowBackground
Specifies the background color for the rows in this component- Parameters:
c
- The (unselected) row background color
-
getRowBackground
- Returns:
- The background color for the rows in this component
-
setRowBackground
Specifies the alternating row color scheme for the component- Parameters:
c1
- The (unselected) row background color for odd rowsc2
- The (unselected) row background color for even rows
-
setColumnIdentifiers
Establishes the header names for the table columns- Parameters:
names
- The array of table column header names
-
getColumnIdentifiers
Retrieves the column names from the column model- Returns:
- The names of the columns
-
setColumnEditable
public void setColumnEditable(int col, boolean editable) Determines if the end-user can click to edit data in the given column.- Parameters:
col
- The column whose editability is being changed.editable
- The flag which determines if the column is editable
-
setDefaultEditor
Specifies the editor which should be used for the given column
Note that this editor takes precedence over the editor set by specifying the Class type.- Parameters:
col
- the spreadsheet column for which this editor should be usededitor
- the editor component for this column
-
setDefaultRenderer
Specifies the renderer which should be used for the given column
Note that this renderer takes precedence over the renderer set by specifying the Class type.- Parameters:
col
- the spreadsheet column for which this renderer should be usedrenderer
- the renderer component for this column
-
setData
Replaces the current data displayed in the spreadsheet with the given data. This method also attempts to type the data and create appropriate renderers/editors.- Parameters:
data
- The new data to display
-
setData
Replaces the current data displayed in the spreadsheet with the given data. This method also attempts to type the data and create appropriate renderers/editors.- Parameters:
data
- The new data to display
-
setColumnData
Used to specify the data that should be displayed in the given column. If there are fewer items in the data Vector than rows, the remaining rows are left unmodified (as-is). If there are more items in the data Vector than rows, the remaining data items are ignored.- Parameters:
column
- The column number which should contain the associated datadata
- The data that should be displayed in the given column
-
removeColumn
public void removeColumn(int col) Deletes the specified column of data from the spreadsheet- Parameters:
col
- the column index to delete
-
resetSortColumn
public void resetSortColumn(int col) Resets the sort state for the specified column.- Parameters:
col
- the sort column index to reset
-
hideColumn
public void hideColumn(int modelIndex) Hides the specified column of data from the spreadsheet- Parameters:
modelIndex
- the column index to hide- See Also:
-
hideColumn
public void hideColumn(int modelIndex, boolean saveToPref) Hides the specified column of data from the spreadsheet and stores in user prefrances so that it is hidden for next use also for the same user- Parameters:
modelIndex
- the model index of the column to hidesaveToPref
- true if its required to save in prefrances, false otherwise (if false the behaviour of this method will be same ashideColumn(int)
method- See Also:
-
showColumn
public void showColumn(int modelIndex) Shows the specified column of data in the spreadsheet- Parameters:
col
- the column index to show- See Also:
-
showColumn
public void showColumn(int modelIndex, boolean saveToPref) Shows the specified column of data in the spreadsheet and stores in user prefrances so that it is displayed for next use also for the same user- Parameters:
modelIndex
- the model index of the column to showsaveToPref
- true if its required to save in prefrances, false otherwise (if false the behaviour of this method will be same asshowColumn(int)
method- See Also:
-
removeRow
public void removeRow(int row) Deletes the specified row of data from the spreadsheet- Parameters:
row
- the row index to delete
-
addRow
Used to append a row of data to the display. If there are fewer items in the data Vector than columns, the remaining columns will be blanked out. If there are more items in the data Vector than columns, the remaining data items are ignored.- Parameters:
data
- The data that should be displayed in the given row
-
insertRow
Inserts a row of data to the table at the specified position regardless of the sort order. If there are fewer items in the data Vector than columns, the remaining columns will be blanked out. If there are more items in the data Vector than columns, the remaining data items are ignored.- Parameters:
row
- The row numberdata
- The data that should be displayed in the given row
-
getIdxDisplayFieldFormat
Retrieves the MessageFormat-compliant format pattern that should be used when rendering data in the table columns- Returns:
- the array of formats
-
getIdxDisplayFieldFormat
Retrieves the MessageFormat-compliant format pattern that should be used when rendering data in the given column- Returns:
- the column format
-
setIdxDisplayFieldFormat
public void setIdxDisplayFieldFormat(String[] pattern) throws IllegalArgumentException, RemoteException Specifies the MessageFormat-compliant format pattern that should be used when rendering data in the table columns. For example, given an IdxDisplayFieldDescription of
FldNameinfo[any].FldLastName,FldNameinfo[any].FldFirstName
the format could be
"{0} {1}" for last name followed by first, or "{1} {0}" for the reverse.
Likewise, it might be "{0} - {1}" for something like 'smith - john'.- Parameters:
pattern
- aMessageFormat
specific pattern- Throws:
RemoteException
- reIllegalArgumentException
- iae
-
setIdxDisplayFieldFormat
public void setIdxDisplayFieldFormat(int col, String pattern) throws IllegalArgumentException, RemoteException Specifies the MessageFormat-compliant format pattern that should be used when rendering data in the given column.- Parameters:
col
- the spreadsheet column this pattern should be applied topattern
- aMessageFormat
specific pattern- Throws:
RemoteException
- reIllegalArgumentException
- iae
-
getNewRenderer
Returns the new instance of PFieldComponentRenderer. This method can be overridden in subclass to return a customized renderer.- Parameters:
pattern
- format that should be applied to the renderer- Returns:
- instance of PSubFieldComponentRenderer
-
viewDataChange
Implements the PViewDataChangeListener interface- Specified by:
viewDataChange
in interfacePViewDataChangeListener
- Parameters:
event
- the data change event- Throws:
RemoteException
- e
-
valueChanged
Implements the ListSelectionListener interface. Called when row selection changes.
Care must be taken if this component is being fed data directly without a field specification being explicitely set. It becomes the responsibility of the encapsulating component to deal with selection and pass along a meaningful event if necessary.- Specified by:
valueChanged
in interfaceListSelectionListener
- Overrides:
valueChanged
in classJTable
- Parameters:
e
- the event indicating the selection changed
-
setValueAt
Override that maintains the selected rows in case the table is sorted and the view position of rows changes as a result of this call.- Overrides:
setValueAt
in classJTable
-
setValueAt
Override that maintains the selected rows in case the table is sorted and the view position of rows changes as a result of this call. Passing true in the last argument causes the table to be marked as dirty - if input tracking is turned on. -
getModelIndex
public int getModelIndex(int row) Returns the table model index based upon the row index. If the table model being used is an instance of PSorterModel, the model index row from PSorterModel is returned. Otherwise, the index row passed in is returned.- Parameters:
row
- Table row index.- Returns:
- the index from the table model.
-
addSpreadSheetListener
Notify the given listener when the user performs a gesture- Parameters:
l
- The selection listener
-
removeSpreadSheetListener
Remove the given listener from the notification list when the user performs a gesture- Parameters:
l
- The selection listener
-
addIASelectionListener
Notify the given listener when the table row selection changes- Parameters:
l
- The selection listener
-
removeIASelectionListener
Don't notify the given listener when the table row selection changes- Parameters:
l
- The selection listener
-
convertToVector
Takes the given array and converts it to a Vector of Vectors- Parameters:
data
- The array to be converted
-
createSSDefaultRenderers
protected void createSSDefaultRenderers() -
editorFromType
An internal method used to determine the appropriate editor for the given Class type- Parameters:
type
- the Class type- Returns:
- the cell editor component
-
setupDefaultModel
protected void setupDefaultModel() -
getSavedSelectedRows
public int[] getSavedSelectedRows()Returns the saved selected rows.- Returns:
- int[] mSavedSelectedRows
-
setLayoutID
Specifies the unique id of this table when storing preferences. It must be set for layout preferences (column width and order) to be saved and restored.- Parameters:
id
- Unique string identifier of this table- See Also:
-
saveColumnLayout
public void saveColumnLayout()Saves the column layout order and width to properties object mColProps. ThemColLayoutID
must be set for layout to be saved. Saves the following properties:table.mColLayoutID.colnum
: number of columstable.mColLayoutID.widthcol
: column col widthtable.mColLayoutID.indexcol
: column col index in the model, which basically says that column appearing in position col is really column x in the model
- See Also:
-
initColumnLayout
public void initColumnLayout()Initialize layout of the column order and width based on saved preferences. Should be called after table has been set up with columns, probably from addNotify(). For this to work, properties should have been saved into mColProps with saveColumnLayout() method and the mColLayoutID needs to be set to the same ID.- See Also:
-
getAscendingSortIconWidth
public int getAscendingSortIconWidth()Returns the width for the ascending sort icon. If the ascending sort icon is null, 0 is returned. -
getAscendingSortIcon
Returns the icon used for to indicate ascending sort. -
setAscendingSortIcon
Sets the icon used for to indicate ascending sort.- Parameters:
icon
- Icon to be used for ascending sort.
-
getDescendingSortIconWidth
public int getDescendingSortIconWidth()Returns the width for the descending sort icon. If the descending sort icon is null, 0 is returned. -
getDescendingSortIcon
Returns the icon used for to indicate descending sort. -
setDescendingSortIcon
Sets the icon used for to indicate descending sort.- Parameters:
icon
- Icon to be used for descending sort.
-
getExportHandler
Retrieves an action listener that can be used to support an "export" command for this table. The handler will be automatically invoked when your UI command element (button, menu item, etc) is selected.
The handler will display a file chooser through which the user can select a location and file name for saving the exported data. They will be forced to select a new file; they will not be allowed to choose a file that already exists.
This handler will generate a complete HTML "page" including beginning/ending tags. If you want more control over the output, or want to combine multiple tables into one page use theexport()
method explicitely instead.- Parameters:
caption
- A caption to display above the table. Can be used to to identify the table's contents.
-
getExportHandler
Retrieves an action listener that can be used to support an "export" command for this table. The handler will be automatically invoked when your UI command element (button, menu item, etc) is selected.
The handler will display a file chooser through which the user can select a location and file name for saving the exported data. They will be forced to select a new file; they will not be allowed to choose a file that already exists.
This handler will generate a complete HTML "page" including beginning/ending tags.
The ExportTemplate implementation will be called to retrieve data that will be written out above the table. This provides the caller an opportunity to write out "extra" data that might be useful for the users of this exported data. If this parameter is null it will be ignored.
If you want even more control over the output, or want to combine multiple tables into one page use theexport()
method explicitely instead.- Parameters:
caption
- A caption to display above the table. Can be used to to identify the table's contents.If
- not null, identifies a provider of HTML data exported along with (above) the table data. The purpose of this data is to provide context (name, date, etc.) of the exported data.
-
export
public void export(BufferedWriter bw, String caption) throws IOException, UnsupportedEncodingException Exports the table's data, as displayed on the screen, to the given FileOutputStream as HTML data. Note that this method will not write out the beginning/closing html tags; this enables the caller to export multiple tables on one stream, or to combine this data with HTML data from another source.- Parameters:
bw
- The stream to export the data tocaption
- A caption to display above the table. Can be used to to identify the table's contents.- Throws:
IOException
UnsupportedEncodingException
-
htmlProcess
-
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-