org.jminor.framework.client.ui
Class EntityPanel

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.jminor.framework.client.ui.EntityPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, MasterDetailPanel

public class EntityPanel
extends JPanel
implements MasterDetailPanel

A panel representing a Entity via a EntityModel, which facilitates browsing and editing of records. To lay out the panel components and initialize the panel you must call the method initializePanel().

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
static int DIALOG
           
static int EMBEDDED
           
static int HIDDEN
           
 
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
EntityPanel(EntityModel entityModel)
          Initializes a new EntityPanel instance.
EntityPanel(EntityModel entityModel, EntityEditPanel editPanel)
          Instantiates a new EntityPanel instance.
EntityPanel(EntityModel entityModel, EntityEditPanel editPanel, EntityTablePanel tablePanel)
          Instantiates a new EntityPanel instance.
EntityPanel(EntityModel entityModel, EntityTablePanel tablePanel)
          Instantiates a new EntityPanel instance.
EntityPanel(EntityModel entityModel, String caption)
          Initializes a new EntityPanel instance.
EntityPanel(EntityModel entityModel, String caption, EntityEditPanel editPanel)
          Instantiates a new EntityPanel instance.
EntityPanel(EntityModel entityModel, String caption, EntityEditPanel editPanel, EntityTablePanel tablePanel)
          Instantiates a new EntityPanel instance.
EntityPanel(EntityModel entityModel, String caption, EntityTablePanel tablePanel)
          Instantiates a new EntityPanel instance.
 
Method Summary
 void activatePanel()
          Activates this panel, showing it and preparing it for input
 EntityPanel addDetailPanel(EntityPanel detailPanel)
          Adds the given detail panel, and adds the detail model to the underlying model if it does not contain it already, and then sets includeDetailPanelTabPane to true
 EntityPanel addDetailPanels(EntityPanel... detailPanels)
           
 boolean containsEditPanel()
           
 boolean containsTablePanel()
           
 String getCaption()
           
 String getControlPanelConstraints()
           
 MasterDetailPanel getCurrentDetailPanel()
          
 EntityPanel getDetailPanel(String entityID)
          Returns the detail panel for the given entityID, if one is available
 List<EntityPanel> getDetailPanels()
          
 int getDetailPanelState()
           
 double getDetailSplitPaneResizeWeight()
           
 JPanel getEditControlPanel()
           
 EntityEditModel getEditModel()
           
 EntityEditPanel getEditPanel()
           
 int getEditPanelState()
           
 Collection<EntityPanel> getLinkedDetailPanels()
           
 MasterDetailPanel getMasterPanel()
          
 EntityModel getModel()
           
 MasterDetailPanel getNextPanel()
          
 MasterDetailPanel getPreviousPanel()
          
 EntityPanel getSelectedDetailPanel()
           
 EntityTableModel getTableModel()
           
 EntityTablePanel getTablePanel()
           
 Control getToggleDetailPanelControl()
           
 Control getToggleEditPanelControl()
           
 void handleException(Exception exception)
          By default this delegates to the edit panel
protected  boolean includeComponentSelectionProperty(String propertyID)
           
protected  void initialize()
          Override to add code that should be called during the initialization routine after the panel has been initialized
protected  void initializeAssociatedPanels()
          Called during initialization, before controls have been initialized
protected  void initializeControlPanels()
          Called during initialization, after controls have been initialized, use this method to initialize any application panels that rely on controls having been initialized
 EntityPanel initializePanel()
          Initializes this EntityPanel's UI, in case of some specific initialization code you can override the initialize() method and add your code there.
protected  void initializeUI()
          Initializes this EntityPanel's UI.
 boolean isCompactDetailLayout()
           
 boolean isIncludeControlPanel()
           
 boolean isIncludeDetailPanelTabPane()
           
 boolean isPanelInitialized()
           
 void prepareUI(boolean setInitialFocus, boolean clearUI)
          Prepares the UI, by clearing the input fields and setting the initial focus, if both parameters are set to false then there is no effect
 void resizePanel(int direction, int pixelAmount)
          Resizes this panel in the given direction
 EntityPanel setCompactDetailLayout(boolean compactDetailLayout)
           
 EntityPanel setControlPanelConstraints(String controlPanelConstraints)
           
 void setDetailPanelState(int state)
           
 EntityPanel setDetailSplitPanelResizeWeight(double detailSplitPanelResizeWeight)
           
 void setEditPanelState(int state)
           
 void setFilterPanelsVisible(boolean value)
          Hides or shows the active filter panels for this panel and all its child panels (detail panels and their detail panels etc.)
 EntityPanel setIncludeControlPanel(boolean includeControlPanel)
           
 EntityPanel setIncludeDetailPanelTabPane(boolean includeDetailPanelTabPane)
           
protected  void setMasterPanel(EntityPanel masterPanel)
           
 void showDetailPanel(MasterDetailPanel detailPanel)
          Shows the given detail panel
 void toggleDetailPanelState()
          Toggles the detail panel state between DIALOG, HIDDEN and EMBEDDED
 void toggleEditPanelState()
          Toggles the edit panel state between DIALOG, HIDDEN and EMBEDDED
 String toString()
          
 
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, 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, 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
 

Field Detail

DIALOG

public static final int DIALOG
See Also:
Constant Field Values

EMBEDDED

public static final int EMBEDDED
See Also:
Constant Field Values

HIDDEN

public static final int HIDDEN
See Also:
Constant Field Values
Constructor Detail

EntityPanel

public EntityPanel(EntityModel entityModel)
Initializes a new EntityPanel instance. The Panel is not laid out and initialized until initialize() is called. The default caption of the underlying entity is used.

Parameters:
entityModel - the EntityModel

EntityPanel

public EntityPanel(EntityModel entityModel,
                   String caption)
Initializes a new EntityPanel instance. The Panel is not laid out and initialized until initialize() is called.

Parameters:
entityModel - the EntityModel
caption - the caption to use when presenting this entity panel

EntityPanel

public EntityPanel(EntityModel entityModel,
                   EntityEditPanel editPanel)
Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initialize() is called.

Parameters:
entityModel - the EntityModel
editPanel - the edit panel

EntityPanel

public EntityPanel(EntityModel entityModel,
                   EntityTablePanel tablePanel)
Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initialize() is called.

Parameters:
entityModel - the EntityModel
tablePanel - the table panel

EntityPanel

public EntityPanel(EntityModel entityModel,
                   String caption,
                   EntityEditPanel editPanel)
Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initialize() is called.

Parameters:
entityModel - the EntityModel
caption - the caption to use when presenting this entity panel
editPanel - the edit panel

EntityPanel

public EntityPanel(EntityModel entityModel,
                   String caption,
                   EntityTablePanel tablePanel)
Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initialize() is called.

Parameters:
entityModel - the EntityModel
caption - the caption to use when presenting this entity panel
tablePanel - the table panel

EntityPanel

public EntityPanel(EntityModel entityModel,
                   EntityEditPanel editPanel,
                   EntityTablePanel tablePanel)
Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initialize() is called.

Parameters:
entityModel - the EntityModel
editPanel - the edit panel
tablePanel - the table panel

EntityPanel

public EntityPanel(EntityModel entityModel,
                   String caption,
                   EntityEditPanel editPanel,
                   EntityTablePanel tablePanel)
Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initialize() is called.

Parameters:
entityModel - the EntityModel
caption - the caption to use when presenting this entity panel
editPanel - the edit panel
tablePanel - the table panel
Method Detail

getModel

public final EntityModel getModel()
Returns:
the EntityModel

getEditModel

public final EntityEditModel getEditModel()
Returns:
the EntityEditModel

getTableModel

public final EntityTableModel getTableModel()
Returns:
the EntityTableModel, null if none is available

getControlPanelConstraints

public final String getControlPanelConstraints()
Returns:
the control panel layout constraints (BorderLayout constraints)

setControlPanelConstraints

public final EntityPanel setControlPanelConstraints(String controlPanelConstraints)
Parameters:
controlPanelConstraints - the control panel layout constraints (BorderLayout constraints)
Returns:
this entity panel

isCompactDetailLayout

public final boolean isCompactDetailLayout()
Returns:
true if this entity panel is using a compact detail layout

setCompactDetailLayout

public final EntityPanel setCompactDetailLayout(boolean compactDetailLayout)
Parameters:
compactDetailLayout - true if this panel and it's detail panels should be laid out in a compact state
Returns:
this EntityPanel instance

addDetailPanels

public final EntityPanel addDetailPanels(EntityPanel... detailPanels)
Parameters:
detailPanels - the detail panels
Returns:
this entity panel

addDetailPanel

public final EntityPanel addDetailPanel(EntityPanel detailPanel)
Adds the given detail panel, and adds the detail model to the underlying model if it does not contain it already, and then sets includeDetailPanelTabPane to true

Parameters:
detailPanel - the detail panel to add
Returns:
this entity panel

initializePanel

public final EntityPanel initializePanel()
Initializes this EntityPanel's UI, in case of some specific initialization code you can override the initialize() method and add your code there. This method marks this panel as initialized which prevents it from running again, whether or not an exception occurs.

Returns:
this EntityPanel instance
See Also:
initialize(), isPanelInitialized()

isPanelInitialized

public final boolean isPanelInitialized()
Returns:
true if the method initializePanel() has been called on this EntityPanel instance
See Also:
initializePanel()

getEditPanel

public final EntityEditPanel getEditPanel()
Returns:
the edit panel

containsEditPanel

public final boolean containsEditPanel()
Returns:
true if this panel contains a edit panel.

getTablePanel

public final EntityTablePanel getTablePanel()
Returns:
the EntityTablePanel used by this EntityPanel

containsTablePanel

public final boolean containsTablePanel()
Returns:
true if this panel contains a table panel.

getEditControlPanel

public final JPanel getEditControlPanel()
Returns:
the edit control panel

getLinkedDetailPanels

public final Collection<EntityPanel> getLinkedDetailPanels()
Returns:
the currently visible/linked detail EntityPanel, if any

getSelectedDetailPanel

public final EntityPanel getSelectedDetailPanel()
Returns:
the detail panel selected in the detail tab pane. If no detail panels are defined a RuntimeException is thrown.

getDetailPanel

public final EntityPanel getDetailPanel(String entityID)
Returns the detail panel for the given entityID, if one is available

Parameters:
entityID - the entiy ID of the detail panel to retrieve
Returns:
the detail panel of the given type
Throws:
IllegalArgumentException - in case the panel was not found

toString

public final String toString()

Overrides:
toString in class Component

getCaption

public final String getCaption()
Returns:
the caption to use when presenting this entity panel

activatePanel

public final void activatePanel()
Activates this panel, showing it and preparing it for input

Specified by:
activatePanel in interface MasterDetailPanel

getMasterPanel

public final MasterDetailPanel getMasterPanel()

Specified by:
getMasterPanel in interface MasterDetailPanel
Returns:
the parent master panel, if one exists

getCurrentDetailPanel

public final MasterDetailPanel getCurrentDetailPanel()

Specified by:
getCurrentDetailPanel in interface MasterDetailPanel
Returns:
a detail panel, if one exists, which child panel exactly is up the implementation

getPreviousPanel

public final MasterDetailPanel getPreviousPanel()

Specified by:
getPreviousPanel in interface MasterDetailPanel
Returns:
the previous detail panel, if one exists, with wrap around

getNextPanel

public final MasterDetailPanel getNextPanel()

Specified by:
getNextPanel in interface MasterDetailPanel
Returns:
the nex detail panel, if one exists, with wrap around

getDetailPanels

public final List<EntityPanel> getDetailPanels()

Specified by:
getDetailPanels in interface MasterDetailPanel
Returns:
the detail panels, an empty list if no detail panels exist

showDetailPanel

public final void showDetailPanel(MasterDetailPanel detailPanel)
Shows the given detail panel

Specified by:
showDetailPanel in interface MasterDetailPanel
Parameters:
detailPanel - the detail panel to show

getToggleEditPanelControl

public final Control getToggleEditPanelControl()
Returns:
a control for toggling the edit panel

getToggleDetailPanelControl

public final Control getToggleDetailPanelControl()
Returns:
a control for toggling the detail panel

handleException

public final void handleException(Exception exception)
By default this delegates to the edit panel

Parameters:
exception - the exception to handle

getDetailSplitPaneResizeWeight

public final double getDetailSplitPaneResizeWeight()
Returns:
the resize weight value to use when initializing the left/right split pane, which controls the initial divider placement (0 - 1). Override to control the initial divider placement

setDetailSplitPanelResizeWeight

public final EntityPanel setDetailSplitPanelResizeWeight(double detailSplitPanelResizeWeight)
Parameters:
detailSplitPanelResizeWeight - the detail panel split size weight
Returns:
this entity panel

isIncludeDetailPanelTabPane

public final boolean isIncludeDetailPanelTabPane()
Returns:
true if the control panel should be included

setIncludeDetailPanelTabPane

public final EntityPanel setIncludeDetailPanelTabPane(boolean includeDetailPanelTabPane)
Parameters:
includeDetailPanelTabPane - true if the detail panel tab pane should be included
Returns:
this entity panel

isIncludeControlPanel

public final boolean isIncludeControlPanel()
Returns:
true if the control panel should be included

setIncludeControlPanel

public final EntityPanel setIncludeControlPanel(boolean includeControlPanel)
Parameters:
includeControlPanel - true if the control panel should be included
Returns:
this entity panel

toggleDetailPanelState

public final void toggleDetailPanelState()
Toggles the detail panel state between DIALOG, HIDDEN and EMBEDDED


toggleEditPanelState

public final void toggleEditPanelState()
Toggles the edit panel state between DIALOG, HIDDEN and EMBEDDED


getDetailPanelState

public final int getDetailPanelState()
Returns:
the detail panel state, either HIDDEN, EMBEDDED or DIALOG

getEditPanelState

public final int getEditPanelState()
Returns:
the edit panel state, either HIDDEN, EMBEDDED or DIALOG

setDetailPanelState

public final void setDetailPanelState(int state)
Parameters:
state - the detail panel state (HIDDEN or EMBEDDED, DIALOG)

setEditPanelState

public final void setEditPanelState(int state)
Parameters:
state - the edit panel state, either HIDDEN, EMBEDDED or DIALOG

setFilterPanelsVisible

public final void setFilterPanelsVisible(boolean value)
Hides or shows the active filter panels for this panel and all its child panels (detail panels and their detail panels etc.)

Parameters:
value - true if the active panels should be shown, false if they should be hidden

resizePanel

public final void resizePanel(int direction,
                              int pixelAmount)
Resizes this panel in the given direction

Parameters:
direction - the resize direction
pixelAmount - the resize amount

prepareUI

public final void prepareUI(boolean setInitialFocus,
                            boolean clearUI)
Prepares the UI, by clearing the input fields and setting the initial focus, if both parameters are set to false then there is no effect

Parameters:
setInitialFocus - if true the component defined as the initialFocusComponent gets the input focus, if none is defined the first child component of this EntityPanel is used, if no edit panel is available the table receives the focus
clearUI - if true the the input components are cleared
See Also:
ValueChangeMapEditPanel.setInitialFocusComponent(javax.swing.JComponent)

includeComponentSelectionProperty

protected boolean includeComponentSelectionProperty(String propertyID)
Parameters:
propertyID - the ID of the property
Returns:
true if the given property should be included when selecting a input component in the edit panel, returns true by default.

initializeUI

protected void initializeUI()
Initializes this EntityPanel's UI.
 The default layout is as follows:
 __________________________________
 |      edit panel        |control|
 |   (EntityEditPanel)    | panel | } edit control panel
 |________________________|_______|
 |                  |             |
 |   table panel    |   detail    |
 |(EntityTablePanel)|   panel     |
 |                  |             |
 |__________________|_____________|

 or in case of compact layout:
 __________________________________
 |  edit    |control|             |
 |  panel   | panel |             |
 |__________|_______|   detail    |
 |                  |   panel     |
 |   table panel    |             |
 |(EntityTablePanel)|             |
 |                  |             |
 |__________________|_____________|
 


initializeAssociatedPanels

protected void initializeAssociatedPanels()
Called during initialization, before controls have been initialized

See Also:
initializePanel()

initializeControlPanels

protected void initializeControlPanels()
Called during initialization, after controls have been initialized, use this method to initialize any application panels that rely on controls having been initialized

See Also:
initializePanel()

initialize

protected void initialize()
Override to add code that should be called during the initialization routine after the panel has been initialized

See Also:
initializePanel()

setMasterPanel

protected final void setMasterPanel(EntityPanel masterPanel)
Parameters:
masterPanel - the panel serving as master panel for this entity panel