JIDE 3.5.15

com.jidesoft.dialog
Class AbstractPage

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 com.jidesoft.dialog.AbstractPage
All Implemented Interfaces:
Laziness, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
AbstractDialogPage

public abstract class AbstractPage
extends JPanel
implements Laziness

AbstractPage is an abstract base class that provides functionality to defer populating a JPanel object until it is actually viewed. This is very useful when using CardLayout and tab panel views which have several pages. Delaying the construction means it will start up fast. Sometimes delay means never.

If subclasses choose to override any of the following methods, it is their responsibility to ensure their overridden methods call the parent's method first. The methods are:

By default, if any of the methods is called, the panel will be populated. However user can setInvokeCondition() to customize when the panel be populated. See javadoc of setInvokeContion() for details.

The idea of the lazy panel is from an article on JavaWorld at http://www.javaworld.com/javatips/jw-javatip90_p.html. The credit should be given to Mark Roulo. We modified the code he provided in the article to add additional things as we need. Things added are

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  PageEvent _pageEvent
          Only one DataChangeEvent is needed per model instance since the event's only (read-only) state is the source property.
static int INVOKE_ON_ALL
          Used by setInvokeCondition().
static int INVOKE_ON_NONE
          Used by setInvokeCondition().
static int INVOKE_ON_PAINT
          Used by setInvokeCondition().
static int INVOKE_ON_REPAINT
          Used by setInvokeCondition().
static int INVOKE_ON_UPDATE
          Used by setInvokeCondition().
static int INVOKE_ON_VALIDATE
          Used by setInvokeCondition().
 
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
protected AbstractPage()
          Creates an AbstractPage.
 
Method Summary
 void addPageListener(PageListener l)
          Adds a PageListener to the page.
 boolean allowClosing()
          Allow this document closing.
 void firePageEvent(int id)
          Runs each PageListener's pageEventFired method.
 void firePageEvent(Object source, int id)
          Runs each PageListener's pageEventFired method.
 int getInvokeCondition()
          Gets the invoke condition.
 PageListener[] getPageListeners()
          Returns an array of all the PageListeners added to this Page with addPageListener .
 void initialize()
          Force the lazyInitialize() method implemented in the child class to be called.
 void invalidate()
           
 void paint(Graphics g)
           
 void paintAll(Graphics g)
           
 void paintComponents(Graphics g)
           
 void removePageListener(PageListener l)
          Removes a PageListener from the page.
 void repaint()
           
 void repaint(int i1, int i2, int i3, int i4)
           
 void repaint(long l)
           
 void repaint(long l, int i1, int i2, int i3, int i4)
           
 void reset()
          Resets the page which will result all child components being removed and the method initialize() being invoked again.
 void revalidate()
           
 void setAllowClosing(boolean allowClosing)
          Sets allow closing.
 void setInvokeCondition(int invokeCondition)
          Sets the invoke condition.
 void update(Graphics g)
           
 
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, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, 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
 
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, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, 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, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
 
Methods inherited from interface com.jidesoft.dialog.Laziness
lazyInitialize
 

Field Detail

INVOKE_ON_ALL

public static int INVOKE_ON_ALL
Used by setInvokeCondition(). This value means initialize will be called in all paint/repaint/update methods.


INVOKE_ON_NONE

public static int INVOKE_ON_NONE
Used by setInvokeCondition(). This value means initialize will not be called. You have to call it manually.


INVOKE_ON_PAINT

public static int INVOKE_ON_PAINT
Used by setInvokeCondition(). This value means initialize will be called with paint() is called.


INVOKE_ON_REPAINT

public static int INVOKE_ON_REPAINT
Used by setInvokeCondition(). This value means initialize will be called with repaint() is called.


INVOKE_ON_UPDATE

public static int INVOKE_ON_UPDATE
Used by setInvokeCondition(). This value means initialize will be called with update() is called.


INVOKE_ON_VALIDATE

public static int INVOKE_ON_VALIDATE
Used by setInvokeCondition(). This value means initialize will be called with invalidate(), revalidate() is called.


_pageEvent

protected transient PageEvent _pageEvent
Only one DataChangeEvent is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".

Constructor Detail

AbstractPage

protected AbstractPage()
Creates an AbstractPage.

Method Detail

getInvokeCondition

public int getInvokeCondition()
Gets the invoke condition. Invoke condition defines how lazy the page is. By default, the lazyInitialize() will be called on any update, paint or repaint method. However you can change the invoke condition to INVOKE_ON_PAINT. If so, lazyInitialize() will be called only when paint() method is called. You can even set the invoke condition to INVOKE_ON_NONE. If so, you will be responsible to call lazyInitialize() since none of those methods methods mentioned above will call lazyInitialize().

Returns:
the invocation condition

setInvokeCondition

public void setInvokeCondition(int invokeCondition)
Sets the invoke condition.

Parameters:
invokeCondition - the invoke condition.

invalidate

public void invalidate()
Overrides:
invalidate in class Container

revalidate

public void revalidate()
Overrides:
revalidate in class JComponent

paint

public void paint(Graphics g)
Overrides:
paint in class JComponent

paintAll

public void paintAll(Graphics g)
Overrides:
paintAll in class Component

paintComponents

public void paintComponents(Graphics g)
Overrides:
paintComponents in class Container

repaint

public void repaint()
Overrides:
repaint in class Component

repaint

public void repaint(long l)
Overrides:
repaint in class Component

repaint

public void repaint(int i1,
                    int i2,
                    int i3,
                    int i4)
Overrides:
repaint in class Component

repaint

public void repaint(long l,
                    int i1,
                    int i2,
                    int i3,
                    int i4)
Overrides:
repaint in class JComponent

update

public void update(Graphics g)
Overrides:
update in class JComponent

initialize

public final void initialize()
Force the lazyInitialize() method implemented in the child class to be called. If this method is called more than once on a given object, all calls but the first do nothing.


reset

public void reset()
Resets the page which will result all child components being removed and the method initialize() being invoked again.

Since:
3.2.2

addPageListener

public void addPageListener(PageListener l)
Adds a PageListener to the page.

Parameters:
l - the PageListener to be added

removePageListener

public void removePageListener(PageListener l)
Removes a PageListener from the page.

Parameters:
l - the PageListener to be removed

getPageListeners

public PageListener[] getPageListeners()
Returns an array of all the PageListeners added to this Page with addPageListener .

Returns:
all of the PageListeners added, or an empty array if no listeners have been added

firePageEvent

public void firePageEvent(int id)
Runs each PageListener's pageEventFired method.

Parameters:
id - event id.

firePageEvent

public void firePageEvent(Object source,
                          int id)
Runs each PageListener's pageEventFired method.

Parameters:
source - of this event
id - event id.

setAllowClosing

public void setAllowClosing(boolean allowClosing)
Sets allow closing. If true, the document cannot be closed. user can change the value in documentClosing() to prevent document from being closed.

Parameters:
allowClosing - true or false.

allowClosing

public boolean allowClosing()
Allow this document closing. By default it return true. User can override this method to return based on condition. A typical user case is: add a DocumentComponentListener. In documentComponentClosing, make this method return to false to prevent it from being closed.

Returns:
whether allow closing

JIDE 3.5.15