org.tentackle.appworx
Class AppDbObjectPanel

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.tentackle.ui.FormPanel
                      extended by org.tentackle.appworx.AppDbObjectPanel
All Implemented Interfaces:
ContainerListener, ImageObserver, MenuContainer, Pageable, Printable, Serializable, EventListener, Accessible, FormContainer

public class AppDbObjectPanel
extends FormPanel
implements Printable, Pageable

Panel to view and/or edit an AppDbObject.

The panel is designed to used as a plugin by AppDbObjectDialog. Notice: the class should be abstract but most GUI-designers cannot handle abstract classes and need a bean to instantiate. Hence, some methods that should be abstract as well are non-abstract default implementations that *must* be overridden.

Author:
harald
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
protected  AppDbObjectDialog dialog
          the enclosing AppDbObjectDialog, null if none
 
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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AppDbObjectPanel()
           
 
Method Summary
 AppDbObjectDialog getAppDbObjectDialog()
          Gets the parent AppDbObjectDialog.
 int getNumberOfPages()
          Returns the number of pages in the set.
 AppDbObject getObject()
          Gets the currently displayed database object.
 Pageable getPageable(PrinterJob printJob)
          Gets the Pageable of this panel.
AppDbObjectDialog invokes this method if the "print" button is pressed.
 PageFormat getPageFormat(int pageIndex)
          Returns the PageFormat of the page specified by pageIndex.
 Printable getPrintable(int pageIndex)
          Returns the Printable instance responsible for rendering the page specified by pageIndex.
 Printable getPrintable(PrinterJob printJob)
          Gets the Printable of this panel.
AppDbObjectDialog invokes this method if the "print" button is pressed and getPageable() returned null.
 String getTitle()
          Gets the container's title.
 void markPrinted()
          Indicates a successful printout.
The default implementation does nothing.
 void pack()
          Packs the parent window.
 boolean prepareCancel()
          Prepares the cancel operation.
Invoked when the dialog is closed or the object is removed from the panel in general.
 boolean prepareDelete()
          Prepares to delete the current object.
Invoked when the user wants to delete the current object (presses the "delete" button, for example).
 boolean prepareNew()
          Prepares to create a new object.
Invoked when the user instantiates a new object (presses the "new" button, for example).
 boolean prepareSave()
          Checks the object for consistency before it is saved.
This method must *NOT* do any modifications to the database.
 boolean prepareSearch()
          Prepares to search for objects.
Invoked when the user wants to search for objects (presses the "search" button, for example).
 int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
          Prints the page at the specified index into the specified Graphics context in the specified format.
 void setAppDbObjectDialog(AppDbObjectDialog dialog)
          Sets the parent AppDbObjectDialog.
 void setInitialFocus()
          Sets the initial focus.
Usually requests the focus for the top left component.
 boolean setObject(AppDbObject object)
          Sets the database object and updates the view.
 List<InteractiveError> verifyObject()
          Verifies the data object.
 
Methods inherited from class org.tentackle.ui.FormPanel
addActionListener, areValuesChanged, componentAdded, componentRemoved, fireActionPerformed, getFormValues, getHelpURL, getParentWindow, invalidateParentInfo, isAllChangeable, isHonourAllChangeable, removeActionListener, saveValues, setAllChangeable, setFormValues, setFormValuesKeepChanged, setHelpURL, setHonourAllChangeable, setTitle, showHelp, triggerValuesChanged
 
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, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dialog

protected AppDbObjectDialog dialog
the enclosing AppDbObjectDialog, null if none

Constructor Detail

AppDbObjectPanel

public AppDbObjectPanel()
Method Detail

setObject

public boolean setObject(AppDbObject object)
Sets the database object and updates the view.

The default implementation returns false. Must be overridden!

Parameters:
object - the database object
Returns:
true if object accepted

getObject

public AppDbObject getObject()
Gets the currently displayed database object.

The default implementation returns null. Must be overridden!

Returns:
the database object

verifyObject

public List<InteractiveError> verifyObject()
Verifies the data object.

The default implementation invokes AppDbObject.verify().

Returns:
the list of errors, never null

prepareSave

public boolean prepareSave()
Checks the object for consistency before it is saved.
This method must *NOT* do any modifications to the database. It is invoked from AppDbObjectDialog within the transaction of saving the object.

The default implementation invokes verifyObject().

Returns:
true if continue tx, false if rollback tx

prepareCancel

public boolean prepareCancel()
Prepares the cancel operation.
Invoked when the dialog is closed or the object is removed from the panel in general.

The default implementation returns true.

Returns:
true if cancel is ok, false if not

prepareNew

public boolean prepareNew()
Prepares to create a new object.
Invoked when the user instantiates a new object (presses the "new" button, for example).

The default implementation returns true.

Returns:
true if creating new object is ok, false if not

prepareSearch

public boolean prepareSearch()
Prepares to search for objects.
Invoked when the user wants to search for objects (presses the "search" button, for example).

The default implementation returns true.

Returns:
true if search is ok, false if not

prepareDelete

public boolean prepareDelete()
Prepares to delete the current object.
Invoked when the user wants to delete the current object (presses the "delete" button, for example).

The default implementation returns true.

Returns:
true if delete is ok, false if not

setAppDbObjectDialog

public void setAppDbObjectDialog(AppDbObjectDialog dialog)
Sets the parent AppDbObjectDialog.

Invoked from AppDbObjectDialog when this panel is "plugged in".

Parameters:
dialog - the parent dialog

getAppDbObjectDialog

public AppDbObjectDialog getAppDbObjectDialog()
Gets the parent AppDbObjectDialog.

Returns:
the parent dialog, null if this panel is not a child of an AppDbObjectDialog.

setInitialFocus

public void setInitialFocus()
Sets the initial focus.
Usually requests the focus for the top left component. The default implementation does nothing. Must be overridden!


getTitle

public String getTitle()
Gets the container's title.

Overridden to generate the title from the current object if title is null.

Specified by:
getTitle in interface FormContainer
Overrides:
getTitle in class FormPanel
Returns:
the container's title, null if none

pack

public void pack()
Packs the parent window.


getPageable

public Pageable getPageable(PrinterJob printJob)
Gets the Pageable of this panel.
AppDbObjectDialog invokes this method if the "print" button is pressed. If this method returns null, getPrintable() will be invoked. The default implementation returns null.

Parameters:
printJob - the printer job
Returns:
the pageable, null if try getPrintable

getPrintable

public Printable getPrintable(PrinterJob printJob)
Gets the Printable of this panel.
AppDbObjectDialog invokes this method if the "print" button is pressed and getPageable() returned null. The default implementation returns this, which is simply a screendump of this panel.

Parameters:
printJob - the printer job
Returns:
the printable, null if printing is disabled

markPrinted

public void markPrinted()
Indicates a successful printout.
The default implementation does nothing. Can be used to set a printing date in an object or alike.


print

public int print(Graphics graphics,
                 PageFormat pageFormat,
                 int pageIndex)
Prints the page at the specified index into the specified Graphics context in the specified format. A PrinterJob calls the Printable interface to request that a page be rendered into the context specified by graphics. The format of the page to be drawn is specified by pageFormat. The zero based index of the requested page is specified by pageIndex. If the requested page does not exist then this method returns NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. The Graphics class or subclass implements the PrinterGraphics interface to provide additional information. If the Printable object aborts the print job then it throws a PrinterException.

The default implementation prints a screendump of this panel.

Specified by:
print in interface Printable
Parameters:
graphics - the context into which the page is drawn
pageFormat - the size and orientation of the page being drawn
pageIndex - the zero based index of the page to be drawn
Returns:
PAGE_EXISTS if the page is rendered successfully or NO_SUCH_PAGE if pageIndex specifies a non-existent page.

getPrintable

public Printable getPrintable(int pageIndex)
Returns the Printable instance responsible for rendering the page specified by pageIndex.

The default implementation returns this.

Specified by:
getPrintable in interface Pageable
Parameters:
pageIndex - the zero based index of the page whose Printable is being requested
Returns:
the Printable that renders the page.

getPageFormat

public PageFormat getPageFormat(int pageIndex)
Returns the PageFormat of the page specified by pageIndex.

The default implementation returns the default pageformat of the printjob.

Specified by:
getPageFormat in interface Pageable
Parameters:
pageIndex - the zero based index of the page whose PageFormat is being requested
Returns:
the PageFormat describing the size and orientation.

getNumberOfPages

public int getNumberOfPages()
Returns the number of pages in the set. To enable advanced printing features, it is recommended that Pageable implementations return the true number of pages rather than the UNKNOWN_NUMBER_OF_PAGES constant.

The default implementation returns UNKNOWN_NUMBER_OF_PAGES.

Specified by:
getNumberOfPages in interface Pageable
Returns:
the number of pages in this Pageable.


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de