Class GridController
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.compiere.swing.CPanel
-
- org.compiere.grid.GridController
-
- All Implemented Interfaces:
MouseListener
,ImageObserver
,MenuContainer
,PropertyChangeListener
,VetoableChangeListener
,Serializable
,EventListener
,Accessible
,ListSelectionListener
,DataStatusListener
,Evaluatee
public class GridController extends CPanel implements DataStatusListener, ListSelectionListener, Evaluatee, VetoableChangeListener, PropertyChangeListener, MouseListener
The Grid Controller is the panel for single and multi-row presentation and links to the Model Tab.UI Structure: this (BorderLayout) splitPane (JSplitPane) left graphicPanel right cardPanel JPanel (CardLayout) srPane JSplitPane vPane JScrollPane vPanel VPanel (GridBagLayout) vIncludedGC GridController mrPane JScrollPane vTable VTable DataBinding: - MultiRow - is automatic between VTable and MTable - SingleRow - from VEditors via fireVetoableChange(m_columnName, null, getText()); (vetoableChange) - to VEditors via updateSingleRow -> Editor.setValue(object) Event Chains -- Navigation -- (VTable selection -> GridController.valueChanged) (APanel selection) + MTab.navivate + MTab.setCurrentRow + Update all MFields + MField.setValue + setContext + fire PropertyChange "Value" + VEditor.propertyChange + VEditor.setValue + MTab.fireProperyChange "CurrentRow" + VTable.propertyChange (setRowSelectionInterval) + GridController.valueChange + GridController.dynamicDisplay(complete) + MTab.fireDataStatusChanged + APanel.statusChanged -- ValueChanges -- VEditor.fireVetoableChange + (VCellEditor.vetoableChange/getCellEditorValue) -- multi-row source + (GridController.vetoableChange) -- single-row source + MTable.setValueAt + MField.setValue + setContext + fire PropertyChange "Value" + VEditor.setValue + MTable.fireDataStatusChanged + MTab.dataStatusChanged + MTab.fireDataStatusChanged + APanel.statusChanged + GridController.dataStatusChanged + GridController.dynamicDisplay(selective)
- Version:
- $Id: GridController.java,v 1.8 2006/09/25 00:59:52 jjanke Exp $
- Author:
- Jorg Janke, Teo Sarca - BF [ 1742159 ], BF [ 1707876 ]
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
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 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 GridController()
Constructor - you need to call initGrid for instanciation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptEditorChanges()
Accept pending editor changes.void
activate()
Activate Grid Controller.void
addDataStatusListener(DataStatusListener l)
Add Data Status Listener - pass on to MTabvoid
dataStatusChanged(DataStatusEvent e)
Data Status Listener - for MTab events.void
dispose()
Displosevoid
dynamicDisplay(int col)
Dynamic DisplayGridController
findChild(GridTab gTab)
String
get_ValueAsString(String variableName)
Get Variable ValueString
getDisplayLogic()
Get Display LogicGridController
getGCParent()
GridTab
getMTab()
Get Model TabVTable
getTable()
Get VTableString
getTitle()
Get TitleVPanel
getvPanel()
boolean
includeTab(GridController gc, APanel aPanel, GridSynchronizer sync)
Include Tabboolean
initGrid(GridTab mTab, boolean onlyMultiRow, int WindowNo, APanel aPanel, GridWindow mWindow)
boolean
initGrid(GridTab mTab, boolean onlyMultiRow, int WindowNo, APanel aPanel, GridWindow mWindow, boolean lazy)
Init Grid.boolean
isCurrent()
Is controller data not staleboolean
isDetailGrid()
boolean
isInit()
boolean
isSingleRow()
Is Single Row presentationvoid
mouseClicked(MouseEvent e)
Mouse Clickedvoid
mouseEntered(MouseEvent e)
Mouse Enteredvoid
mouseExited(MouseEvent e)
Mouse Exitedvoid
mousePressed(MouseEvent e)
Mouse Pressedvoid
mouseReleased(MouseEvent e)
Mouse Releasedvoid
propertyChange(PropertyChangeEvent e)
PropertyChange Listener - Tree Panel - node selectionvoid
query(boolean onlyCurrentRows, int onlyCurrentDays, int maxRows)
Query Tab and resize Table (called from APanel)void
refreshMTab(GridController includedTab)
void
registerESCAction(AppsAction aIgnore)
Register ESC Actions - overwrite VTable's Keystrokes assignment for ESCvoid
removeDataStatusListener(DataStatusListener l)
Remove Listener - pass on to MTabvoid
rowChanged(boolean save, int keyID)
Row Changed - synchronize with Treeprotected void
saveMultipleRecords(Properties ctx, String tableName, String columnName, int recordId, Integer[] values, String trxName)
Save Multiple records - Clone a record and assign new values to each clone for a specific column.void
setDetailGrid(boolean value)
void
setGCParent(GridController gc)
void
setMnemonics(boolean set)
Set Window level Mnemonicsvoid
stopEditor(boolean saveValue)
Stop Table & SR Editors and move focus to graphPanelvoid
switchMultiRow()
Switch to MultiRow Presentationvoid
switchRowPresentation()
Switch from single to multi & vice versavoid
switchSingleRow()
Switch to SingleRow PresentationString
toString()
toStringvoid
valueChanged(ListSelectionEvent e)
List Selection Listener (VTable) - row changedvoid
vetoableChange(PropertyChangeEvent e)
Vetoable Change Listener.-
Methods inherited from class org.compiere.swing.CPanel
getBackgroundColor, getTabLevel, setBackground, setBackgroundColor, setTabLevel
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, 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, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, 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, doLayout, 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, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Method Detail
-
toString
public String toString()
toString
-
dispose
public void dispose()
Displose
-
initGrid
public boolean initGrid(GridTab mTab, boolean onlyMultiRow, int WindowNo, APanel aPanel, GridWindow mWindow)
-
initGrid
public boolean initGrid(GridTab mTab, boolean onlyMultiRow, int WindowNo, APanel aPanel, GridWindow mWindow, boolean lazy)
Init Grid.- Map table to model - Update (multi-row) table info with renderers/editors - build single-row panel - initialize display
- Parameters:
mTab
- tabonlyMultiRow
- only tableWindowNo
- window noaPanel
- optional Application Panel for adding button listenersmWindow
- parent Window Model- Returns:
- true if initialized
-
isInit
public boolean isInit()
- Returns:
- boolean
-
includeTab
public boolean includeTab(GridController gc, APanel aPanel, GridSynchronizer sync)
Include Tab- Parameters:
gc
- grid controller to add- Returns:
- GridSynchronizer
-
setDetailGrid
public void setDetailGrid(boolean value)
-
isDetailGrid
public boolean isDetailGrid()
-
getTitle
public String getTitle()
Get Title- Returns:
- title
-
activate
public void activate()
Activate Grid Controller. Called by APanel when GridController is displayed (foreground)
-
findChild
public GridController findChild(GridTab gTab)
-
registerESCAction
public void registerESCAction(AppsAction aIgnore)
Register ESC Actions - overwrite VTable's Keystrokes assignment for ESC- Parameters:
aIgnore
- ignore
-
query
public void query(boolean onlyCurrentRows, int onlyCurrentDays, int maxRows)
Query Tab and resize Table (called from APanel)- Parameters:
onlyCurrentRows
- only current rowsonlyCurrentDays
- how many days backmaxRows
- maximim rows or 0 for all
-
switchRowPresentation
public void switchRowPresentation()
Switch from single to multi & vice versa
-
switchSingleRow
public void switchSingleRow()
Switch to SingleRow Presentation
-
switchMultiRow
public void switchMultiRow()
Switch to MultiRow Presentation
-
isSingleRow
public boolean isSingleRow()
Is Single Row presentation- Returns:
- true if Single Row is displayed
-
removeDataStatusListener
public void removeDataStatusListener(DataStatusListener l)
Remove Listener - pass on to MTab- Parameters:
l
- listener
-
addDataStatusListener
public void addDataStatusListener(DataStatusListener l)
Add Data Status Listener - pass on to MTab- Parameters:
l
- listener
-
dataStatusChanged
public void dataStatusChanged(DataStatusEvent e)
Data Status Listener - for MTab events.Callouts are processed here for GUI changes - same as in MTab.setValue for batch changes
calls dynamicDisplay
- Specified by:
dataStatusChanged
in interfaceDataStatusListener
- Parameters:
e
- event
-
valueChanged
public void valueChanged(ListSelectionEvent e)
List Selection Listener (VTable) - row changed- Specified by:
valueChanged
in interfaceListSelectionListener
- Parameters:
e
- event
-
propertyChange
public void propertyChange(PropertyChangeEvent e)
PropertyChange Listener - Tree Panel - node selection- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
e
- event
-
dynamicDisplay
public void dynamicDisplay(int col)
Dynamic Display. - Single Row Screen layout and update of dynamic LookupsSingle Row layout: the components's name is the ColumnName; if it matches, the MField.isDisplayed(true) is used to determine if it is visible if the component is a VEditor, setEnabled is set from the MField
Multi Row layout is not changed: VCellRenderer calls JTable.isCellEditable -> checks MField.isEditable (Active, isDisplayed) VCellEditor.isCellEditable calls MField.isEditable(true)
If a column is not displayed, the width is set to 0 in dynInitDynamic update of data is handeled in VLookup.focusGained/Lost. When focus is gained the model is temporarily updated with the specific validated data, if lost, it is switched back to the unvalidated data (i.e. everything). This allows that the display methods have a lookup to display.
Here: if the changed field has dependents and the dependent is a Lookup and this lookup has a dynamic dependence of the changed field, the value of that field is set to null (in MTab.processDependencies - otherwise it would show an invalid value). As Editors listen for value changed of their MField, the display is updated.Called from GridController.valueChanged/dataStatusChanged, APane;.stateChanged/unlock/cmd_...
- Parameters:
col
- selective column number or 0 if all
-
rowChanged
public void rowChanged(boolean save, int keyID)
Row Changed - synchronize with Tree- Parameters:
save
- true the row was saved (changed/added), false if the row was deletedkeyID
- the ID of the row changed
-
saveMultipleRecords
protected void saveMultipleRecords(Properties ctx, String tableName, String columnName, int recordId, Integer[] values, String trxName) throws Exception
Save Multiple records - Clone a record and assign new values to each clone for a specific column.- Parameters:
ctx
- contexttableName
- Table NamecolumnName
- Column for which value need to be changedrecordId
- Record to clonevalues
- Values to be assigned to clones for the specified columntrxName
- Transaction- Throws:
Exception
- If error is occured when loading the PO or saving clones
-
vetoableChange
public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
Vetoable Change Listener. Called from VEditor- for Save Confirmation dialog - for Single Row from VEditor: Update MTable
- Specified by:
vetoableChange
in interfaceVetoableChangeListener
- Parameters:
e
- event- Throws:
PropertyVetoException
-
getMTab
public GridTab getMTab()
Get Model Tab- Returns:
- Model Tab
-
getDisplayLogic
public String getDisplayLogic()
Get Display Logic- Returns:
- Display Logic
-
getTable
public VTable getTable()
Get VTable- Returns:
- VTable
-
setMnemonics
public void setMnemonics(boolean set)
Set Window level Mnemonics- Parameters:
set
- true if set otherwise unregiser
-
stopEditor
public void stopEditor(boolean saveValue)
Stop Table & SR Editors and move focus to graphPanel- Parameters:
saveValue
- save value
-
mouseClicked
public void mouseClicked(MouseEvent e)
Mouse Clicked- Specified by:
mouseClicked
in interfaceMouseListener
- Parameters:
e
- event
-
mousePressed
public void mousePressed(MouseEvent e)
Mouse Pressed- Specified by:
mousePressed
in interfaceMouseListener
- Parameters:
e
- event
-
mouseReleased
public void mouseReleased(MouseEvent e)
Mouse Released- Specified by:
mouseReleased
in interfaceMouseListener
- Parameters:
e
- event
-
mouseEntered
public void mouseEntered(MouseEvent e)
Mouse Entered- Specified by:
mouseEntered
in interfaceMouseListener
- Parameters:
e
- event
-
mouseExited
public void mouseExited(MouseEvent e)
Mouse Exited- Specified by:
mouseExited
in interfaceMouseListener
- Parameters:
e
- event
-
get_ValueAsString
public String get_ValueAsString(String variableName)
Get Variable Value- Specified by:
get_ValueAsString
in interfaceEvaluatee
- Parameters:
variableName
- name- Returns:
- value
-
isCurrent
public boolean isCurrent()
Is controller data not stale- Returns:
- boolean
-
getvPanel
public VPanel getvPanel()
-
setGCParent
public void setGCParent(GridController gc)
-
getGCParent
public GridController getGCParent()
-
refreshMTab
public void refreshMTab(GridController includedTab)
-
acceptEditorChanges
public void acceptEditorChanges()
Accept pending editor changes.
-
-