|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
com.billpringle.utils.wrputils.WrpEditValidationRules
public class WrpEditValidationRules
This class allows a user edit validation rules that are stored in a database.
In addition to editing the rules, the user can also compile them, and even execute them to validate a specified CSV line or all of the lines within a specified CSV file.
Nested Class Summary | |
---|---|
private class |
WrpEditValidationRules.RuleModel
Internal class that is the model for the rules table |
Nested classes/interfaces inherited from class javax.swing.JFrame |
---|
javax.swing.JFrame.AccessibleJFrame |
Nested classes/interfaces inherited from class java.awt.Frame |
---|
java.awt.Frame.AccessibleAWTFrame |
Nested classes/interfaces inherited from class java.awt.Window |
---|
java.awt.Window.AccessibleAWTWindow |
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 |
Field Summary | |
---|---|
(package private) javax.swing.JButton |
btnCompile
button to compile the validation rules |
(package private) javax.swing.JButton |
btnCsv
Button to specify a CSV string to parse |
(package private) javax.swing.JButton |
btnExecute
Button to validate one or more CSV strings |
(package private) javax.swing.JButton |
btnFile
Button to specify a CSV file to parse |
(package private) javax.swing.JButton |
btnGet
button to load validation rules |
(package private) javax.swing.JButton |
btnPrint
button to print validation rules |
(package private) javax.swing.JButton |
btnQuit
button to terminate the program |
(package private) javax.swing.JButton |
btnRenum
button to renumber statements |
(package private) javax.swing.JButton |
btnSave
button to save validation rules |
protected int[] |
colWidth
The width of the rules columns that was set by the user. |
protected int |
compileErrors
number of compile errors (-1 means no compile) |
protected WrpCsv |
csv
The CSV string that can be validated. |
protected java.io.File |
csvFile
The file containing CSV records that can be validated. |
protected int |
csvLine
the unique line number for this record |
protected WrpDb |
db
the connection to the database |
protected int |
execErrors
number of run-time errors (-1 means no execution) |
(package private) javax.swing.JFileChooser |
fc
a file chooser to select the CSV file |
(package private) javax.swing.JLabel |
lblTitle
label for title at top of page |
protected java.util.Vector<java.lang.Boolean> |
modified
vector indicating what rules have been modified |
(package private) javax.swing.JPanel |
pnlScroll
scroll panel for the validation rules |
(package private) javax.swing.JPanel |
pnlTop
panel at top of page |
(package private) javax.swing.JPanel |
pnlTopPage
wrapper panel to prevent top of page resizing |
(package private) javax.swing.JPopupMenu |
popup
pop up menu |
protected int |
rulesRead
The number of rules read from the database |
(package private) javax.swing.JScrollPane |
scroll
scroll pane for the validation rules |
(package private) static long |
serialVersionUID
unique serializing identifier |
(package private) javax.swing.JTable |
tblRules
table of validation rules |
(package private) java.awt.Dimension |
topSize
size of the top portion of the page |
(package private) javax.swing.JTextField |
txtHighSeq
optional upper sequence number to load a subset of the validation rules |
(package private) javax.swing.JTextField |
txtLowSeq
optional lower sequence number to load a subset of the validation rules |
(package private) javax.swing.JTextField |
txtTable
optional field to indicate stored procedure |
protected WrpValidateCsv |
Val
CSV validation object |
protected java.util.Vector<WrpValidateCsv.ValidationRule> |
validations
vector of validation rules |
protected java.lang.String |
ValTbl
the database table name containing validation rules |
protected WrpZipCode |
zipCodes
list of valid zip code combinations |
Fields inherited from class javax.swing.JFrame |
---|
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Frame |
---|
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
WrpEditValidationRules(WrpDb db)
Default (and only) constructor |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
|
void |
buildHtmlFooter(java.io.PrintStream prt)
Create the bottom part of the HTML rules file. |
void |
buildHtmlHeader(java.io.PrintStream prt)
Build the beginning of an HTML file for printing rules. |
void |
buildMenu()
Creates the main menu (e.g., File) |
void |
buildPage()
Creates the actual page content |
void |
compileRules()
Compile current set of rules, and display results. |
void |
componentHidden(java.awt.event.ComponentEvent e)
|
void |
componentMoved(java.awt.event.ComponentEvent e)
|
void |
componentResized(java.awt.event.ComponentEvent e)
|
void |
componentShown(java.awt.event.ComponentEvent e)
|
void |
deleteRule(WrpValidateCsv.ValidationRule v)
Delete the specified validation rule from the database |
void |
executeRules()
Execute the rules using the specified CSV string or file. |
java.util.Vector<WrpValidateCsv.ValidationRule> |
getRules()
Get the current collection of validation rules |
java.lang.String |
getValidationTable()
Get the name of the table containing the validation rules |
void |
ifPopup(java.awt.event.MouseEvent e)
|
void |
insertRule(WrpValidateCsv.ValidationRule v)
Insert a new rule into the database |
void |
loadCsv(int CsvLine)
Select a CSV file to load for validation. |
void |
loadRules()
Retrieve the rules for the current field from the database |
static void |
main(java.lang.String[] args)
This is a sample driver for this program. |
void |
mouseClicked(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
java.lang.String |
nbsp(java.lang.String str)
Substitute empty strings with This method is used when filling data cells within a column. |
void |
printHtmlRule(WrpValidateCsv.ValidationRule v,
java.io.PrintStream prt)
Format a rule for insertion into the HTML table. |
void |
printRules()
Allow the user to print the current rules. |
void |
renumberStatements()
Renumber the statements. |
private void |
renumberStatements(int incr)
Renumber statements using the specified increment. |
void |
resizeScroll()
Resize the window components |
boolean |
saveChanges()
If changes were not saved, ask user if they should be changed |
void |
saveRules()
Save any new or changed rules |
void |
selectOpenFile()
Select the CSV file to be validated. |
protected java.io.File |
selectSaveFile()
|
void |
setRules(java.util.Vector<WrpValidateCsv.ValidationRule> rules)
Define the current collection of validation rules |
void |
setValidationTable(java.lang.String valtbl)
Update the name of the database table containing validation rules |
void |
updateRule(WrpValidateCsv.ValidationRule v)
Update the specified validation rules |
void |
updateTable()
Save any changes to the current rules to the database. |
void |
validateFile(java.io.File f)
Validate a CSV file |
Methods inherited from class javax.swing.JFrame |
---|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update |
Methods inherited from class java.awt.Frame |
---|
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.awt.Window |
---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, 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 java.awt.MenuContainer |
---|
getFont, postEvent |
Field Detail |
---|
static final long serialVersionUID
protected WrpDb db
protected int csvLine
protected WrpCsv csv
When the "Execute" button is clicked, this string will be validated, provided the user hasn't specified a CSV file to validate.
protected java.io.File csvFile
If the user has specified a CSV file, it will be validated when the user clicks on the "Execute" button.
protected java.lang.String ValTbl
protected WrpValidateCsv Val
protected java.util.Vector<WrpValidateCsv.ValidationRule> validations
protected java.util.Vector<java.lang.Boolean> modified
protected int rulesRead
protected int[] colWidth
When rules are reloaded, these column widths will be retained.
protected int compileErrors
protected int execErrors
protected WrpZipCode zipCodes
javax.swing.JPopupMenu popup
javax.swing.JPanel pnlTop
javax.swing.JPanel pnlTopPage
javax.swing.JLabel lblTitle
javax.swing.JTable tblRules
javax.swing.JTextField txtLowSeq
javax.swing.JTextField txtHighSeq
javax.swing.JTextField txtTable
javax.swing.JButton btnGet
javax.swing.JButton btnSave
javax.swing.JButton btnCompile
javax.swing.JButton btnPrint
javax.swing.JButton btnCsv
javax.swing.JButton btnFile
javax.swing.JButton btnExecute
If the user has specified a CSV file, then all the lines in that file are validated using the current set of validation rules. If no CSV file is specified, then the specified CSV string is validated instead.
javax.swing.JButton btnRenum
javax.swing.JButton btnQuit
javax.swing.JPanel pnlScroll
javax.swing.JScrollPane scroll
java.awt.Dimension topSize
javax.swing.JFileChooser fc
Constructor Detail |
---|
public WrpEditValidationRules(WrpDb db)
Method Detail |
---|
public void buildMenu()
public void buildPage()
public void updateTable()
This routine loops through the validation rules and updates any modified rule to the database. It will also insert any new validation rules that were added since the previous load. It will also preserve the width of the columns in the form
public void resizeScroll()
This method is called when the window is resized or the list changes
public java.lang.String getValidationTable()
public void setValidationTable(java.lang.String valtbl)
valtbl
- the name of the database tablepublic void loadRules()
This method calls resizeScroll() to resize the page if needed
public java.util.Vector<WrpValidateCsv.ValidationRule> getRules()
public void setRules(java.util.Vector<WrpValidateCsv.ValidationRule> rules)
rules
- a vector of validation rulespublic boolean saveChanges()
This routine is called each time the user requests a save. If any changes were made but not saved, the user is asked if the changes should be save using a Confirmation Dialog box. The possible user responses are:
public void saveRules()
public void insertRule(WrpValidateCsv.ValidationRule v) throws java.sql.SQLException
v
- the valiation rule to be inserted
java.sql.SQLException
public void updateRule(WrpValidateCsv.ValidationRule v) throws java.sql.SQLException
The unique row identifier (primary key) from the database is used to update this specific rule in the database.
v
- the validation rule to be updated
java.sql.SQLException
public void deleteRule(WrpValidateCsv.ValidationRule v) throws java.sql.SQLException
v
- the validation rule to be deleted
java.sql.SQLException
public void loadCsv(int CsvLine)
This method uses an input dialog box to obtain a CSV line which can be parsed and validated when the user clicks on the "Execute" button.
public void selectOpenFile()
This method uses a file chooser to obtain a CSV line which can be parsed and validated when the user clicks on the "Execute" button.
protected java.io.File selectSaveFile()
public void renumberStatements()
This method is called if the user clicks on the "Renumber" button. It will ask the user for an increment, and then renumber all of the statements using that increment.
private void renumberStatements(int incr)
incr
- increment value for renumbering statementspublic void compileRules()
If any error messages were generated, display them as well.
public void executeRules() throws WrpValidateCsv.ValidationRuntimeException
If the rules haven't been compiled yet, or any compile-time errors were found, then nothing is done.
Assuming the rules were compiled without errors, then either the CSV string or the CSV file are validated. If a CSV has been specified, then it is validated; otherwise the specified CSV string is validated. If neither were specified, an error message is displayed.
If any run-time errors are found, report them using a wrpScrollFrame
WrpValidateCsv.ValidationRuntimeException
public void validateFile(java.io.File f)
Read each line from the file and run the validation commands against each line.
f
- the CSV file to be validatedpublic void printRules()
public void buildHtmlHeader(java.io.PrintStream prt)
prt
- the output stream for the HTML filepublic void buildHtmlFooter(java.io.PrintStream prt)
prt
- the output stream for the HTML rules filepublic void printHtmlRule(WrpValidateCsv.ValidationRule v, java.io.PrintStream prt)
v
- the validation rule to be printed in a tableprt
- the output stream for the HTML rules tablepublic java.lang.String nbsp(java.lang.String str)
str
- the string to test
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void ifPopup(java.awt.event.MouseEvent e)
public void componentHidden(java.awt.event.ComponentEvent e)
componentHidden
in interface java.awt.event.ComponentListener
public void componentMoved(java.awt.event.ComponentEvent e)
componentMoved
in interface java.awt.event.ComponentListener
public void componentResized(java.awt.event.ComponentEvent e)
componentResized
in interface java.awt.event.ComponentListener
public void componentShown(java.awt.event.ComponentEvent e)
componentShown
in interface java.awt.event.ComponentListener
public static void main(java.lang.String[] args)
args
- not used
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |