Compiere 3.1

org.compiere.grid
Class GridController

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.compiere.swing.CPanel
                      extended by 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)
      + GridTab.navivate
          + GridTab.setCurrentRow
              + Update all GridFields
                  + GridField.setValue
                      + setContext
                      + fire PropertyChange "Value"
                          + VEditor.propertyChange
                              + VEditor.setValue
              + GridTab.fireProperyChange "CurrentRow"
                  + VTable.propertyChange (setRowSelectionInterval)
                      + GridController.valueChange
                          + GridController.dynamicDisplay(complete)
              + GridTab.fireDataStatusChanged
                  + APanel.statusChanged

  -- ValueChanges --
  VEditor.fireVetoableChange
      + (VCellEditor.vetoableChange/getCellEditorValue)   -- multi-row source
      + (GridController.vetoableChange)                   -- single-row source
          + GridTable.setValueAt
              + GridField.setValue
                  + setContext
                  + fire PropertyChange "Value"
                      + VEditor.setValue
              + GridTable.fireDataStatusChanged
                  + GridTab.dataStatusChanged
                      + GridTab.fireDataStatusChanged
                          + APanel.statusChanged
                  + GridController.dataStatusChanged
                      + GridController.dynamicDisplay(selective)
  

Version:
$Id$
Author:
Jorg Janke
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
accessibleContext, 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
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
GridController(boolean withRowHeader)
          Constructor - you need to call initGrid for instanciation
 
Method Summary
 void activate()
          Activate Grid Controller.
 void addDataStatusListener(DataStatusListener l)
          Add Data Status Listener - pass on to MTab
 void dataStatusChanged(DataStatusEvent e)
          Data Status Listener - for MTab events.
 void dispose()
          Displose
 void dynamicDisplay(int col)
          Dynamic Display
 String get_ValueAsString(String variableName)
          Get Variable Value
 GridTab getMTab()
          Get Model Tab
 VTable getTable()
          Get VTable
 String getTitle()
          Get Title
 boolean includeTab(GridController gc)
          Include Tab
 boolean initGrid(GridTab mTab, boolean onlyMultiRow, int WindowNo, APanel aPanel, GridWindow mWindow)
          Init Grid.
 boolean isDisplayed()
          Is Tab displayed
 boolean isSingleRow()
          Is Single Row presentation
 void mouseClicked(MouseEvent e)
          Mouse Clicked
 void mouseEntered(MouseEvent e)
          Mouse Entered
 void mouseExited(MouseEvent e)
          Mouse Exited
 void mousePressed(MouseEvent e)
          Mouse Pressed
 void mouseReleased(MouseEvent e)
          Mouse Released
 void propertyChange(PropertyChangeEvent e)
          PropertyChange Listener - Tree Panel - node selection
 boolean query(int onlyCurrentDays, int maxRows, boolean created)
          Query Tab and resize Table (called from APanel)
 void registerESCAction(AppsAction aIgnore)
          Register ESC Actions - overwrite VTable's Keystroke assignment for ESC
 void removeDataStatusListener(DataStatusListener l)
          Remove Listener - pass on to MTab
 void requestFocus()
          Request Focus - cancel editors
 boolean requestFocusInWindow()
          Request Focus In Window
 void rowChanged(boolean save, int keyID)
          Row Changed - synchronize with Tree
 void setMnemonics(boolean set)
          Set Window level Mnemonics
 void stopEditor(boolean saveValue)
          Stop Table & SR Editors and move focus to graphPanel
 void switchMultiRow()
          Switch to MultiRow Presentation
 void switchRowPresentation()
          Switch from single to multi & vice versa
 void switchSingleRow()
          Switch to SingleRow Presentation
 String toString()
          toString
 void valueChanged(ListSelectionEvent e)
          List Selection Listener (VTable) - row changed
 void 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridController

public GridController(boolean withRowHeader)
Constructor - you need to call initGrid for instanciation

Parameters:
withRowHeader - with numbers in Front
Method Detail

toString

public String toString()
toString

Overrides:
toString in class CPanel
Returns:
string representation

dispose

public void dispose()
Displose


initGrid

public boolean initGrid(GridTab mTab,
                        boolean onlyMultiRow,
                        int WindowNo,
                        APanel aPanel,
                        GridWindow mWindow)
Init Grid.
  - Map table to model
  - Update (multi-row) table info with renderers/editors
  - build single-row panel
  - initialize display
  

Parameters:
mTab - tab
onlyMultiRow - only table
WindowNo - window no
aPanel - optional Application Panel for adding button listeners
mWindow - parent Window Model
Returns:
true if initialized

includeTab

public boolean includeTab(GridController gc)
Include Tab

Parameters:
gc - grod controller to add
Returns:
true if included

getTitle

public String getTitle()
Get Title

Returns:
title

activate

public void activate()
Activate Grid Controller. Called by APanel when GridController is displayed (foreground)


registerESCAction

public void registerESCAction(AppsAction aIgnore)
Register ESC Actions - overwrite VTable's Keystroke assignment for ESC

Parameters:
aIgnore - ignore

query

public boolean query(int onlyCurrentDays,
                     int maxRows,
                     boolean created)
Query Tab and resize Table (called from APanel)

Parameters:
onlyCurrentDays - how many days back
maxRows - maximum rows or 0 for all
created - query based on created if true otherwise updated

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

requestFocusInWindow

public boolean requestFocusInWindow()
Request Focus In Window

Overrides:
requestFocusInWindow in class JComponent
Returns:
focus request

requestFocus

public void requestFocus()
Request Focus - cancel editors

Overrides:
requestFocus in class JComponent

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 interface DataStatusListener
Parameters:
e - event

valueChanged

public void valueChanged(ListSelectionEvent e)
List Selection Listener (VTable) - row changed

Specified by:
valueChanged in interface ListSelectionListener
Parameters:
e - event

propertyChange

public void propertyChange(PropertyChangeEvent e)
PropertyChange Listener - Tree Panel - node selection

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
e - event

dynamicDisplay

public void dynamicDisplay(int col)
Dynamic Display. - Single Row Screen layout and update of dynamic Lookups

Single 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 dynInit

Dynamic 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 deleted
keyID - the ID of the row changed

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 interface VetoableChangeListener
Parameters:
e - event
Throws:
PropertyVetoException

getMTab

public GridTab getMTab()
Get Model Tab

Returns:
Model Tab

isDisplayed

public boolean isDisplayed()
Is Tab displayed

Returns:
true if displayed

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 interface MouseListener
Parameters:
e - event

mousePressed

public void mousePressed(MouseEvent e)
Mouse Pressed

Specified by:
mousePressed in interface MouseListener
Parameters:
e - event

mouseReleased

public void mouseReleased(MouseEvent e)
Mouse Released

Specified by:
mouseReleased in interface MouseListener
Parameters:
e - event

mouseEntered

public void mouseEntered(MouseEvent e)
Mouse Entered

Specified by:
mouseEntered in interface MouseListener
Parameters:
e - event

mouseExited

public void mouseExited(MouseEvent e)
Mouse Exited

Specified by:
mouseExited in interface MouseListener
Parameters:
e - event

get_ValueAsString

public String get_ValueAsString(String variableName)
Get Variable Value

Specified by:
get_ValueAsString in interface Evaluatee
Parameters:
variableName - name
Returns:
value

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.