com.nqadmin.swingSet
Class SSDataNavigator

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.nqadmin.swingSet.SSDataNavigator
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class SSDataNavigator
extends javax.swing.JPanel

SSDataNavigator.java

SwingSet - Open Toolkit For Making Swing Controls Database-Aware

 Component that can be used for data navigation. It provides buttons for
 navigation, insertion, and deletion of records in a SSRowSet. The modification
 of a SSRowSet can be prevented using the setModificaton() method.  Any changes
 made to the columns of a record will be updated whenever there is a
 navigation.

 For example if you are displaying three columns using the JTextField and the
 user changes the text in the text fields then the columns will be updated to
 the new values when the user navigates the SSRowSet. If the user wants to revert
 the changes he made he can press the Undo button, however this must be done
 before any navigation.  Once navigation takes place changes can't be reverted
 using Undo button (has to be done manually by the user).

Version:
$Revision: 1.48 $
Author:
$Author: prasanth $
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JButton addButton
          Button to add a record to the SSRowSet.
protected  java.awt.Dimension buttonSize
          Navigator button dimensions.
protected  boolean callExecute
          Indicator to cause the navigator to skip the execute() function call on the specified SSRowSet.
protected  javax.swing.JButton commitButton
          Button to commit screen changes to the SSRowSet.
protected  boolean confirmDeletes
          Indicator to force confirmation of SSRowSet deletions.
protected  int currentRow
          Row number for current record in SSRowSet.
protected  SSDBNav dBNav
          Container (frame or internal frame) which contains the navigator.
protected  javax.swing.JButton deleteButton
          Button to delete the current record in the SSRowSet.
protected  boolean deletion
          Indicator to allow/disallow deletions from the SSRowSet.
protected  javax.swing.JButton firstButton
          Button to navigate to the first record in the SSRowSet.
protected  boolean insertion
          Indicator to allow/disallow insertions to the SSRowSet.
protected  javax.swing.JButton lastButton
          Button to navigate to the last record in the SSRowSet.
protected  javax.swing.JLabel lblRowCount
          Label to display the total number of records in the SSRowSet.
protected  boolean modification
          Indicator to allow/disallow changes to the SSRowSet.
protected  javax.swing.JButton nextButton
          Button to navigate to the next record in the SSRowSet.
protected  boolean onInsertRow
          Indicator used to determine if a row is being inserted into the SSRowSet.
protected  javax.swing.JButton previousButton
          Button to navigate to the previous record in the SSRowSet.
protected  javax.swing.JButton refreshButton
          Button to refresh the screen based on any changes to the SSRowSet.
protected  int rowCount
          Number of rows in SSRowSet.
protected  SSRowSet sSRowSet
          SSRowSet from which component will get/set values.
protected  javax.swing.JTextField txtCurrentRow
          Text field for viewing/changing the current record number.
protected  java.awt.Dimension txtFieldSize
          Current record text field dimensions.
protected  javax.swing.JButton undoButton
          Button to revert screen changes based on the SSRowSet.
 
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
SSDataNavigator()
          Creates a object of SSDataNavigator.
SSDataNavigator(SSRowSet _sSRowSet)
          Constructs a SSDataNavigator for the given SSRowSet
SSDataNavigator(SSRowSet _sSRowSet, java.awt.Dimension _buttonSize)
          Constructs the SSDataNavigator with the given SSRowSet and sets the size of the buttons on the navigator to the given size
 
Method Summary
protected  void addToolTips()
          Method to add tooltips and button graphics (or text) to navigator components.
 boolean containsRows()
          Returns true if the SSRowSet contains one or more rows, else false.
protected  void createPanel()
          Adds the navigator components to the navigator panel.
 void doAddButtonClick()
          Calls the doClick on Add Button.
 void doCommitButtonClick()
          Calls the doClick on Commit Button.
 void doDeleteButtonClick()
          Calls the doClick on Delete Button.
 void doFirstButtonClick()
          Calls the doClick on First Button.
 void doLastButtonClick()
          Calls the doClick on Last Button.
 void doNextButtonClick()
          Calls the doClick on Next Button.
 void doPreviousButtonClick()
          Calls the doClick on Previous Button.
 void doRefreshButtonClick()
          Calls the doClick on Refresh Button.
 void doUndoButtonClick()
          Calls the doClick on Undo Button.
 java.awt.Dimension getButtonSize()
          Returns the size of buttons on the data navigator.
 boolean getCallExecute()
          Indicates if the navigator will skip the execute function call on the underlying SSRowSet (needed for MySQL - see FAQ).
 boolean getConfirmDeletes()
          Returns true if deletions must be confirmed by user, else false.
 SSDBNav getDBNav()
          Returns any custom implementation of the SSDBNav interface, which is used when the insert button is pressed to perform custom actions.
 boolean getDeletion()
          Returns true if deletions are allowed, else false.
 boolean getInsertion()
          Returns true if insertions are allowed, else false.
 boolean getModification()
          Returns true if the user can modify the data in the SSRowSet, else false.
 SSRowSet getRowSet()
          Deprecated.  
 SSRowSet getSSRowSet()
          Returns the SSRowSet being used.
 void setButtonSize(java.awt.Dimension _buttonSize)
          Sets the preferredSize and the MinimumSize of the buttons to the specified size
protected  void setButtonSizes()
          Sets the dimensions for the navigator components.
 void setCallExecute(boolean _callExecute)
          Method to cause the navigator to skip the execute() function call on the underlying SSRowSet.
 void setConfirmDeletes(boolean _confirmDeletes)
          Sets the confirm deletion indicator.
 void setDBNav(SSDBNav _dBNav)
          Function that passes the implementation of the SSDBNav interface.
 void setDeletion(boolean _deletion)
          Enables or disables the row deletion button.
 void setFocusable(boolean focusable)
          This will make all the components in the navigator to either focusable components or non focusable components.
 void setInsertion(boolean _insertion)
          Enables or disables the row insertion button.
 void setModification(boolean _modification)
          Enables or disables the modification-related buttons on the SSDataNavigator.
 void setRowSet(SSRowSet _sSRowSet)
          Deprecated.  
 void setSSRowSet(SSRowSet _sSRowSet)
          This method changes the SSRowSet to which the navigator is bound.
 boolean updatePresentRow()
          Writes the present row back to the SSRowSet.
 
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, 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, 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, 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

firstButton

protected javax.swing.JButton firstButton
Button to navigate to the first record in the SSRowSet.


previousButton

protected javax.swing.JButton previousButton
Button to navigate to the previous record in the SSRowSet.


txtCurrentRow

protected javax.swing.JTextField txtCurrentRow
Text field for viewing/changing the current record number.


nextButton

protected javax.swing.JButton nextButton
Button to navigate to the next record in the SSRowSet.


lastButton

protected javax.swing.JButton lastButton
Button to navigate to the last record in the SSRowSet.


commitButton

protected javax.swing.JButton commitButton
Button to commit screen changes to the SSRowSet.


undoButton

protected javax.swing.JButton undoButton
Button to revert screen changes based on the SSRowSet.


refreshButton

protected javax.swing.JButton refreshButton
Button to refresh the screen based on any changes to the SSRowSet.


addButton

protected javax.swing.JButton addButton
Button to add a record to the SSRowSet.


deleteButton

protected javax.swing.JButton deleteButton
Button to delete the current record in the SSRowSet.


lblRowCount

protected javax.swing.JLabel lblRowCount
Label to display the total number of records in the SSRowSet.


modification

protected boolean modification
Indicator to allow/disallow changes to the SSRowSet.


deletion

protected boolean deletion
Indicator to allow/disallow deletions from the SSRowSet.


insertion

protected boolean insertion
Indicator to allow/disallow insertions to the SSRowSet.


confirmDeletes

protected boolean confirmDeletes
Indicator to force confirmation of SSRowSet deletions.


callExecute

protected boolean callExecute
Indicator to cause the navigator to skip the execute() function call on the specified SSRowSet. Must be false for MySQL (see FAQ).


sSRowSet

protected SSRowSet sSRowSet
SSRowSet from which component will get/set values.


dBNav

protected SSDBNav dBNav
Container (frame or internal frame) which contains the navigator.


rowCount

protected int rowCount
Number of rows in SSRowSet. Set to zero if next() method returns false.


currentRow

protected int currentRow
Row number for current record in SSRowSet.


onInsertRow

protected boolean onInsertRow
Indicator used to determine if a row is being inserted into the SSRowSet.


buttonSize

protected java.awt.Dimension buttonSize
Navigator button dimensions.


txtFieldSize

protected java.awt.Dimension txtFieldSize
Current record text field dimensions.

Constructor Detail

SSDataNavigator

public SSDataNavigator()
Creates a object of SSDataNavigator. Note: you have to set the SSRowSet before you can start using it.


SSDataNavigator

public SSDataNavigator(SSRowSet _sSRowSet)
Constructs a SSDataNavigator for the given SSRowSet

Parameters:
_sSRowSet - The SSRowSet to which the SSDataNavigator has to be bound

SSDataNavigator

public SSDataNavigator(SSRowSet _sSRowSet,
                       java.awt.Dimension _buttonSize)
Constructs the SSDataNavigator with the given SSRowSet and sets the size of the buttons on the navigator to the given size

Parameters:
_sSRowSet - the SSRowSet to which the navigator is bound to
_buttonSize - the size to which the button on navigator have to be set
Method Detail

containsRows

public boolean containsRows()
Returns true if the SSRowSet contains one or more rows, else false.

Returns:
return true if SSRowSet contains data else false.

setCallExecute

public void setCallExecute(boolean _callExecute)
Method to cause the navigator to skip the execute() function call on the underlying SSRowSet. This is necessary for MySQL (see FAQ).

Parameters:
_callExecute - false if using MySQL database - otherwise true

getCallExecute

public boolean getCallExecute()
Indicates if the navigator will skip the execute function call on the underlying SSRowSet (needed for MySQL - see FAQ).

Returns:
value of execute() indicator

setButtonSize

public void setButtonSize(java.awt.Dimension _buttonSize)
Sets the preferredSize and the MinimumSize of the buttons to the specified size

Parameters:
_buttonSize - the required dimension of the buttons

getButtonSize

public java.awt.Dimension getButtonSize()
Returns the size of buttons on the data navigator.

Returns:
returns a Dimension object representing the size of each button on the data navigator.

setDBNav

public void setDBNav(SSDBNav _dBNav)
Function that passes the implementation of the SSDBNav interface. This interface can be implemented by the developer to perform custom actions when the insert button is pressed

Parameters:
_dBNav - implementation of the SSDBNav interface

getDBNav

public SSDBNav getDBNav()
Returns any custom implementation of the SSDBNav interface, which is used when the insert button is pressed to perform custom actions.

Returns:
any custom implementation of the SSDBNav interface

setModification

public void setModification(boolean _modification)
Enables or disables the modification-related buttons on the SSDataNavigator. If the user can only navigate through the records with out making any changes set this to false. By default, the modification-related buttons are enabled.

Parameters:
_modification - indicates whether or not the modification-related buttons are enabled.

getModification

public boolean getModification()
Returns true if the user can modify the data in the SSRowSet, else false.

Returns:
returns true if the user modifications are written back to the database, else false.

setDeletion

public void setDeletion(boolean _deletion)
Enables or disables the row deletion button. This method should be used if row deletions are not allowed. True by default.

Parameters:
_deletion - indicates whether or not to allow deletions

getDeletion

public boolean getDeletion()
Returns true if deletions are allowed, else false.

Returns:
returns true if deletions are allowed, else false.

setInsertion

public void setInsertion(boolean _insertion)
Enables or disables the row insertion button. This method should be used if row insertions are not allowed. True by default.

Parameters:
_insertion - indicates whether or not to allow insertions

getInsertion

public boolean getInsertion()
Returns true if insertions are allowed, else false.

Returns:
returns true if insertions are allowed, else false.

setConfirmDeletes

public void setConfirmDeletes(boolean _confirmDeletes)
Sets the confirm deletion indicator. If set to true, every time delete button is pressed, the navigator pops up a confirmation dialog to the user. Default value is true.

Parameters:
_confirmDeletes - indicates whether or not to confirm deletions

getConfirmDeletes

public boolean getConfirmDeletes()
Returns true if deletions must be confirmed by user, else false.

Returns:
returns true if a confirmation dialog is displayed when the user deletes a record, else false.

setSSRowSet

public void setSSRowSet(SSRowSet _sSRowSet)
This method changes the SSRowSet to which the navigator is bound. The execute() and next() methods MUST be called on the SSRowSet before you set the SSRowSet for the SSDataNavigator.

Parameters:
_sSRowSet - a SSRowSet object to which the navigator will be bound

getSSRowSet

public SSRowSet getSSRowSet()
Returns the SSRowSet being used.

Returns:
returns the SSRowSet being used.

updatePresentRow

public boolean updatePresentRow()
Writes the present row back to the SSRowSet. This is done automatically when any navigation takes place, but can also be called manually.

Returns:
returns true if update succeeds else false.

doFirstButtonClick

public void doFirstButtonClick()
Calls the doClick on First Button.


doPreviousButtonClick

public void doPreviousButtonClick()
Calls the doClick on Previous Button.


doNextButtonClick

public void doNextButtonClick()
Calls the doClick on Next Button.


doLastButtonClick

public void doLastButtonClick()
Calls the doClick on Last Button.


doRefreshButtonClick

public void doRefreshButtonClick()
Calls the doClick on Refresh Button.


doCommitButtonClick

public void doCommitButtonClick()
Calls the doClick on Commit Button.


doUndoButtonClick

public void doUndoButtonClick()
Calls the doClick on Undo Button.


doAddButtonClick

public void doAddButtonClick()
Calls the doClick on Add Button.


doDeleteButtonClick

public void doDeleteButtonClick()
Calls the doClick on Delete Button.


addToolTips

protected void addToolTips()
Method to add tooltips and button graphics (or text) to navigator components.


setFocusable

public void setFocusable(boolean focusable)
This will make all the components in the navigator to either focusable components or non focusable components. Set to false if you don't want any of the buttons or text fields in the navigator to receive the focus else true. The default value is true.

Overrides:
setFocusable in class java.awt.Component
Parameters:
focusable - - false if you don't want the navigator to receive focus else false.

setButtonSizes

protected void setButtonSizes()
Sets the dimensions for the navigator components.


createPanel

protected void createPanel()
Adds the navigator components to the navigator panel.


setRowSet

public void setRowSet(SSRowSet _sSRowSet)
Deprecated. 

Sets the new SSRowSet for the combo box.

Parameters:
_sSRowSet - SSRowSet to which the combo has to update values.
See Also:
setSSRowSet(com.nqadmin.swingSet.datasources.SSRowSet)

getRowSet

public SSRowSet getRowSet()
Deprecated. 

Returns the SSRowSet being used.

Returns:
returns the SSRowSet being used.
See Also:
getSSRowSet()