org.formaria.swing.pojo
Class PojoDialog

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.formaria.swing.layer.LayerManager
                      extended by org.formaria.swing.Page
                          extended by org.formaria.swing.Dialog
                              extended by org.formaria.swing.pojo.PojoDialog
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, AnnotatedPage, ContentPane, DialogSupport, ExceptionHandler, ILayerManager, PageSupport, PageSupport.IDialog, PersistentState

public class PojoDialog
extends Dialog
implements AnnotatedPage

A dialog wrapper than encapsulates a PojoPanel and provides common operations. A custom class can be used to back this dialog by overloading the getImplementingClass method.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Nested classes/interfaces inherited from interface org.formaria.aria.PageSupport
PageSupport.IDialog
 
Field Summary
static int CREATE_ACTION
           
protected  java.lang.Object[] data
           
static int DELETE_ACTION
           
protected  DialogValidationSupport dvs
           
static int FIND_ACTION
           
protected  Image logoImage
           
protected  int mode
           
protected static java.lang.String nextClassName
           
protected  PojoPanel pojoPanel
           
static int READ_ACTION
           
protected  Label titleText
           
static int UPDATE_ACTION
           
 
Fields inherited from class org.formaria.swing.Dialog
bIsModal, BUTTON_SIZE, CANCEL_CLICKED, CLOSE_CLICKED, closeButtonID, contentPanel, DEFAULT_PADDING, focusComponent, lastReturnValue, NO_CLICKED, NOTHING_CLICKED_YET, OK_CLICKED, padding, returnObject, returnValue, saveOnClose, trueField
 
Fields inherited from class org.formaria.swing.Page
adapter, componentFactory, pageHelper, pageMgr, project, rootModel
 
Fields inherited from class org.formaria.swing.layer.LayerManager
BACKGROUND
 
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 org.formaria.aria.PageSupport
ACTIVATED, ANNOTATEDIMAGE, ARIA_AWT_PACKAGE, ARIA_HTML_PACKAGE, ARIA_SWING_PACKAGE, ARIA_SWT_PACKAGE, BORDER_LAYOUT, BOX_LAYOUT, BUTTON, CARD_LAYOUT, CHECK, COLUMN_LAYOUT, COMBO, CREATED, DEACTIVATED, DISCARDED, DISPLAYED, EDIT, FLOW_LAYOUT, GRID_LAYOUT, GRIDBAG_LAYOUT, GROUP, GUIDE_LAYOUT, HOTSPOTIMAGE, IMAGE, IMAGEMAP, LABEL, LAYER_LAYOUT, LIST, LOADED, MENU, MENUBAR, MENUITEM, METACONTENT, NULL_LAYOUT, PANEL, PASSWORD, RADIO, SCALE_LAYOUT, SCROLLABLEMETACONTENT, SCROLLPANE, SPLITPANE, SPRING_LAYOUT, TABLE, TABPANEL, TEXTAREA, UNKNOWN, UNKNOWN_PAGE_STATE, WMF
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PojoDialog()
           
 
Method Summary
 void closeDlg()
          Close the dialog and restore focus
static PojoDialog createDialog(java.lang.Class implementingClass, int action, java.lang.String path, java.lang.String title)
          Create a PojoDialog using the PojoDialogTemplate
static PojoDialog createDialog(int action, java.lang.String path, java.lang.String title)
          Create a PojoDialog using the PojoDialogTemplate
protected  void doCloseAction()
          Overload this method to take some action when the dialog is closed.
static java.lang.String getImplementingClassName()
          Get the full class name of this dialog.
 void pack()
          Size the dialog to hold the largest components (i.e.
 void pageActivated()
          A method called once the page has been created and initialized but just prior to display.
 void pageCreated()
          Overload the Page XCreated event and set the caption of the dialog from the title attribute.
protected  void saveData()
           
 void setColWidth(int colWidth)
          Set the column width.
 void setData(java.lang.Object[] d)
          Set the object data displayed by this dialog
 void setDataPath(java.lang.String path)
          Set the path to the POJO instance
 void setEnabledByDefault(boolean enabledByDefault)
          Set the default enabled status
 void setExclude(java.lang.String attribValue)
          Set a comma separated list of excluded fields
 void setFieldOrder(java.lang.String fieldOrder)
          Set the order of the input fields.
 void setFieldValidationRule(java.lang.String fieldValidationRule)
          Set the name of the field validation rule
static void setImplementingClassName(java.lang.String className)
          Set the name of the backing class for the next instance of the PojoDialog
 void setIncludeByDefault(boolean includeByDefault)
          Flag that all fields are to be included by default
 void setInputEnabled(boolean inputEnabled)
           
 void setLabelWidth(int labelWidth)
          Set the label or prompt width in pixels.
 void setLogo(java.lang.String imagePath)
          Set the logo image
 void setMode(int mode, java.lang.String caption)
          Set the dialog mode
 void setNumCols(int numCols)
          Set the number of columns over which to display the inputs
 void setRowHeight(int rowHeight)
          Set the row height in pixels.
 void setSpacing(int spacing)
          Set the input field spacing
 void setTitle(java.lang.String title)
          Set the title text
 void setUseColumnOrder(boolean useColumnOrder)
          Set the column vs row input field traversal mode
 void setViewFile(java.lang.String fileName)
          Set the view file.
 void setViewPath(java.lang.String path)
          Read the view from a node in the data model
 int showDialog(java.lang.Object owner)
          Shows the dialog.
 int showDialog(java.lang.Object cbParent, java.lang.String cb)
          Shows the dialog.
 int showDialog(java.lang.Object owner, java.lang.String title, java.awt.Point location)
          Shows the dialog.
protected  void updateData()
           
 
Methods inherited from class org.formaria.swing.Dialog
add, cancelDlg, getContentPane, getFocusComponent, getLastReturnValue, getMinimumSize, getPreferredSize, getReturnObject, setBackground, setCaption, setFont, setForeground, setHideFrame, setLayout, setLocation, setLocation, setModal, setResizable, setSaveOnClose, setSize, setUseNativeHeaders, showModalWindow, wasMouseClicked
 
Methods inherited from class org.formaria.swing.Page
accumulateMessages, addBinding, addHandler, addHandler, addListener, addNestedPage, addNotify, addValidation, addValidation, addValidation, checkValidations, clearMouseClick, clearValidations, enterDataBindingContext, evaluateAttribute, evaluatePath, exitDataBindingContext, findComponent, findComponent, getAttribute, getAttribute, getAttributes, getBinding, getBinding, getBindings, getComponentFactory, getComponentName, getCurrentEvent, getDataBindingContext, getDataBindingContext, getEventAttribute, getEventHandler, getExtension, getGraphics, getOwner, getPageName, getPageSize, getProject, getStatus, getValidationHandler, handleEventHandlerException, handleException, isFocusChangeSuppressed, layout, pageAdded, pageDeactivated, paint, paintSuper, removeBinding, restoreState, saveBoundComponentValues, saveState, setAttribute, setClearPage, setComponentFactory, setEventHandler, setExceptionHandler, setExtension, setLayout, setPageName, setStatus, setValidationFactory, showComponents, showHandCursor, showMessage, showMessage, showPage, showPage, showPrevious, stripAttributeValues, translate, update, updateBinding, updateBindings, updateBoundComponentValues, updateChildLayouts, validationHandler, wasEnterPressed, wasMouseDoubleClicked, wasMouseRightClicked
 
Methods inherited from class org.formaria.swing.layer.LayerManager
add, add, add, add, addLayer, deleteLayer, getActiveLayer, getActiveLayerIndex, getComponent, getInputContext, getLayer, getLayer, getLayerNames, isEnabled, isFocusable, isLayerEnabled, isLayerEnabled, isLayerVisible, moveLayerDown, moveLayerUp, paintChildren, setActiveLayer, setBounds, setLayerEnabled, setLayerName, setLayerVisible, updateLayerSizes
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, 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, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, 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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setName, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.formaria.aria.PageSupport
accumulateMessages, addBinding, addHandler, addHandler, addListener, addNestedPage, addValidation, addValidation, addValidation, checkValidations, clearValidations, doLayout, enterDataBindingContext, evaluateAttribute, evaluatePath, exitDataBindingContext, findComponent, findComponent, getAttribute, getAttribute, getBinding, getBinding, getBindings, getComponentFactory, getComponentName, getCurrentEvent, getDataBindingContext, getDataBindingContext, getEventAttribute, getEventHandler, getExtension, getName, getOwner, getPageSize, getProject, getStatus, getValidationHandler, handleEventHandlerException, handleException, isFocusChangeSuppressed, pageAdded, pageDeactivated, removeBinding, saveBoundComponentValues, setAttribute, setClearPage, setComponentFactory, setEventHandler, setExceptionHandler, setExtension, setLayout, setName, setStatus, setValidationFactory, setVisible, showComponents, showHandCursor, showMessage, showMessage, stripAttributeValues, translate, updateBinding, updateBindings, updateBoundComponentValues, validate, validationHandler, wasMouseDoubleClicked, wasMouseRightClicked
 
Methods inherited from interface org.formaria.aria.PersistentState
restoreState, saveState
 

Field Detail

CREATE_ACTION

public static final int CREATE_ACTION
See Also:
Constant Field Values

READ_ACTION

public static final int READ_ACTION
See Also:
Constant Field Values

UPDATE_ACTION

public static final int UPDATE_ACTION
See Also:
Constant Field Values

DELETE_ACTION

public static final int DELETE_ACTION
See Also:
Constant Field Values

FIND_ACTION

public static final int FIND_ACTION
See Also:
Constant Field Values

data

protected java.lang.Object[] data

dvs

protected DialogValidationSupport dvs

mode

protected int mode

pojoPanel

@Find
protected PojoPanel pojoPanel

titleText

@Find
protected Label titleText

logoImage

@Find
protected Image logoImage

nextClassName

protected static java.lang.String nextClassName
Constructor Detail

PojoDialog

public PojoDialog()
Method Detail

createDialog

public static PojoDialog createDialog(int action,
                                      java.lang.String path,
                                      java.lang.String title)
Create a PojoDialog using the PojoDialogTemplate

Parameters:
action - the (CRUD) action to be taken by this dialog on close
path - the path to the POJO in the data model
title - the dialog title
Returns:
the new dialog (as yet undisplayed)

createDialog

public static PojoDialog createDialog(java.lang.Class implementingClass,
                                      int action,
                                      java.lang.String path,
                                      java.lang.String title)
Create a PojoDialog using the PojoDialogTemplate

Parameters:
implementingClass - the class that implements the next PojoDialog instance
action - the (CRUD) action to be taken by this dialog on close
path - the path to the POJO in the data model
title - the dialog title
Returns:
the new dialog (as yet undisplayed)

getImplementingClassName

public static java.lang.String getImplementingClassName()
Get the full class name of this dialog. Subclasses should overload this method or set the value of the class

Returns:
the className

setImplementingClassName

public static void setImplementingClassName(java.lang.String className)
Set the name of the backing class for the next instance of the PojoDialog

Parameters:
className -

showDialog

public int showDialog(java.lang.Object owner,
                      java.lang.String title,
                      java.awt.Point location)
Shows the dialog. This method calls showDialog( this ) after setting the title, location and after setting the dialog to a size just large enough to display all its content

Overrides:
showDialog in class Dialog
Parameters:
owner - The container to which the dialog is added.
title - The dialog title/caption
location - The location on screen to show the dialog
Returns:
the returnValue

showDialog

public int showDialog(java.lang.Object cbParent,
                      java.lang.String cb)
Shows the dialog. For modal dialog the showDialog method blocks till the dialog is dismissed or hidden. This method provides an alternative that does not block execution of the calling thread but instead calls back a method specified as an argument once the dialog has been dismissed. In some VMs such as the Microsoft VM it is not possible to gain access to the EventQueue so as to implement blocking unless the code is loaded from a signed CAB file. If this situtaion occurs an exception is thrown and a non-blocking strategy is used. When the dialog is shown it will attempt to gain focus and upon dismissal focus will be returned to the component that had focus prior to display of the dialog. A special case occurs when the dialog is displayed in response to a focus event handler. The focus event will be processed as normal, allowing transfer of focus but focus handler invocations related to the showing and hiding of the dialog will be suppressed.

Overrides:
showDialog in class Dialog
Parameters:
cbParent - The parent/owner for purposes of a callback.
cb - The name of a callback method in the parent (or null) to be invoked when the dialog is dismissed.

showDialog

public int showDialog(java.lang.Object owner)
Shows the dialog. For modal dialog this method blocks till the dialog is dismissed or hidden. A subclass can set the returnValue member to indicate the status of the dialog upon dismissal. When the dialog is shown it will attempt to gain focus and upon dismissal focus will be returned to the component that had focus prior to display of the dialog. A special case occurs when the dialog is displayed in response to a focus event handler. The focus event will be processed as normal, allowing transfer of focus but focus handler invocations related to the showing and hiding of the dialog will be suppressed.

Specified by:
showDialog in interface DialogSupport
Overrides:
showDialog in class Dialog
Parameters:
owner - The container to which the dialog is added.
Returns:
the returnValue

pack

public void pack()
Size the dialog to hold the largest components (i.e. children of the content panel) and force the panel to lay itself out (which populates the panel)

Specified by:
pack in interface DialogSupport
Overrides:
pack in class Dialog

pageCreated

public void pageCreated()
Description copied from class: Dialog
Overload the Page XCreated event and set the caption of the dialog from the title attribute. Call super if overloaded.

Specified by:
pageCreated in interface PageSupport
Overrides:
pageCreated in class Dialog

pageActivated

public void pageActivated()
Description copied from class: Page
A method called once the page has been created and initialized but just prior to display. Override this method if you need to add custom behavior when the page is activated or displayed.

Specified by:
pageActivated in interface PageSupport
Overrides:
pageActivated in class Page

closeDlg

public void closeDlg()
Close the dialog and restore focus

Overrides:
closeDlg in class Dialog

doCloseAction

protected void doCloseAction()
Overload this method to take some action when the dialog is closed. The dialog data is saved to the model prior to invoking this method.


updateData

protected void updateData()

saveData

protected void saveData()

setMode

public void setMode(int mode,
                    java.lang.String caption)
Set the dialog mode

Parameters:
mode - the mode or CRUD action
caption - the caption/caption key

setData

public void setData(java.lang.Object[] d)
Set the object data displayed by this dialog

Parameters:
d -

setTitle

public void setTitle(java.lang.String title)
Set the title text

Parameters:
title - the new title

setLogo

public void setLogo(java.lang.String imagePath)
Set the logo image

Parameters:
imagePath - the image name/path

setNumCols

public void setNumCols(int numCols)
Set the number of columns over which to display the inputs

Parameters:
numCols - the number of columns

setFieldOrder

public void setFieldOrder(java.lang.String fieldOrder)
Set the order of the input fields. A comma separated list of fields

Parameters:
fieldOrder -

setRowHeight

public void setRowHeight(int rowHeight)
Set the row height in pixels. The input field will be the height of the row less the row spacing

Parameters:
rowHeight - the row height

setLabelWidth

public void setLabelWidth(int labelWidth)
Set the label or prompt width in pixels. This width is fixes and does not relate to the panel size

Parameters:
labelWidth - the width in pixels

setColWidth

public void setColWidth(int colWidth)
Set the column width. The column width is fixed and does not relate to the size of the panel

Parameters:
colWidth - the width in pixels

setSpacing

public void setSpacing(int spacing)
Set the input field spacing

Parameters:
spacing - the spacing in pixels

setDataPath

public void setDataPath(java.lang.String path)
Set the path to the POJO instance


setEnabledByDefault

public void setEnabledByDefault(boolean enabledByDefault)
Set the default enabled status

Parameters:
enabledByDefault -

setInputEnabled

public void setInputEnabled(boolean inputEnabled)

setUseColumnOrder

public void setUseColumnOrder(boolean useColumnOrder)
Set the column vs row input field traversal mode

Parameters:
useColumnOrder - if true traverse the input fields column by column

setIncludeByDefault

public void setIncludeByDefault(boolean includeByDefault)
Flag that all fields are to be included by default

Parameters:
includeByDefault - true to include all fields

setFieldValidationRule

public void setFieldValidationRule(java.lang.String fieldValidationRule)
Set the name of the field validation rule

Parameters:
fieldValidationRule -

setExclude

public void setExclude(java.lang.String attribValue)
Set a comma separated list of excluded fields

Parameters:
attribValue - the list of fields

setViewFile

public void setViewFile(java.lang.String fileName)
Set the view file. The view customizes the display of the pojo

Parameters:
attribValue - the list of fields

setViewPath

public void setViewPath(java.lang.String path)
Read the view from a node in the data model

Parameters:
path - the name of the model path containing the view