public class SQLQueryBuilderPane
extends javax.swing.JComponent
implements java.io.Serializable
Data for the GUI is retrieved from the system when load() is called. If load() is not called, the tables in the GUI will be empty.
If table names are provided, then the user is presented choices based on the fields within those tables. If userSelectTables is true, the user may modify the tables on which the query is built. tableSchemas and userSelectTableSchemas are used to determine the list of tables which the user can choose from, however the user is not prevented from using tables not in these schemas.
It is up to the user to register a JDBC driver when using this class. For example, the following code registers the IBM Toolbox for Java JDBC driver.
DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());
Most errors are reported by firing ErrorEvents, rather than throwing exceptions. Users should listen for ErrorEvents in order to diagnose and recover from error conditions.
SQLQueryBuilderPane objects generate the following events:
// Register JDBC driver. DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ()); // Set up table for result set contents. final SQLConnection connection = new SQLConnection("jdbc:as400://MySystem"); final SQLQueryBuilderPane pane = new SQLQueryBuilderPane(connection); // Set up window to hold table JFrame frame = new JFrame ("My Window"); WindowListener l = new WindowAdapter() { // Close the pane when window is closed. public void windowClosing(WindowEvent e) { pane.close(); connection.close(); } }; frame.addWindowListener(l); // Set up the error dialog adapter. pane.addErrorListener (new ErrorDialogAdapter (frame)); // Add the component and get data from system. frame.getContentPane().add(pane); pane.load(); // Display the window frame.setVisible(true)
javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
SQLQueryBuilderPane()
Deprecated.
Constructs a SQLQueryBuilderPane object.
|
SQLQueryBuilderPane(SQLConnection connection)
Deprecated.
Constructs a SQLQueryBuilderPane object.
|
SQLQueryBuilderPane(SQLConnection connection,
java.lang.String[] tables)
Deprecated.
Constructs a SQLQueryBuilderPane object.
|
Modifier and Type | Method and Description |
---|---|
void |
addErrorListener(ErrorListener listener)
Deprecated.
Adds a listener to be notified when an error occurs.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated.
Adds a listener to be notified when the value of any bound
property is changed.
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Deprecated.
Adds a listener to be notified when the value of any constrained
property is changed.
|
SQLConnection |
getConnection()
Deprecated.
Returns the SQL connection with which to access data for the GUI.
|
java.lang.String |
getQuery()
Deprecated.
Returns the SQL query that corresponds to the user's selections.
|
java.lang.String[] |
getTables()
Deprecated.
Returns the names of the tables used in the query.
|
java.lang.String[] |
getTableSchemas()
Deprecated.
Returns the schemas for which the tables will be listed for inclusion
in the query.
|
boolean |
getUserSelectTables()
Deprecated.
Returns true if the user is able to select and change the tables that
are included in the query.
|
boolean |
getUserSelectTableSchemas()
Deprecated.
Returns true if the user is able to select and change the schemas
for which tables are shown.
|
void |
load()
Deprecated.
Gets data from the system.
|
void |
removeErrorListener(ErrorListener listener)
Deprecated.
Removes a listener from being notified when an error occurs.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated.
Removes a listener from being notified when the value of any bound
property is changed.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Deprecated.
Removes a listener from being notified when the value of any constrained
property is changed.
|
void |
setConnection(SQLConnection connection)
Deprecated.
Sets the SQL connection with which to access data for the GUI.
|
void |
setTables(java.lang.String[] tables)
Deprecated.
Sets the table names for the query.
|
void |
setTableSchemas(java.lang.String[] tableSchemas)
Deprecated.
Sets the schemas for which the tables will be listed for inclusion
in the query.
|
void |
setUserSelectTables(boolean flag)
Deprecated.
Sets whether the user will be able to select and change the tables that
are included in the query.
|
void |
setUserSelectTableSchemas(boolean flag)
Deprecated.
Sets whether the user will be able to select and change the schemas
for which tables are shown.
|
addAncestorListener, addNotify, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, updateUI
add, add, add, add, add, addContainerListener, addImpl, 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
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, 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
public SQLQueryBuilderPane()
public SQLQueryBuilderPane(SQLConnection connection)
connection
- The SQL connection.public SQLQueryBuilderPane(SQLConnection connection, java.lang.String[] tables)
connection
- The SQL connection.tables
- The names of the tables to be used for the query.
Tables should be in the form of schema.table.public void addErrorListener(ErrorListener listener)
listener
- The listener.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in class java.awt.Container
listener
- The listener.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
addVetoableChangeListener
in class javax.swing.JComponent
listener
- The listener.public SQLConnection getConnection()
public java.lang.String getQuery()
public java.lang.String[] getTables()
public java.lang.String[] getTableSchemas()
public boolean getUserSelectTables()
public boolean getUserSelectTableSchemas()
public void load()
public void removeErrorListener(ErrorListener listener)
listener
- The listener.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in class java.awt.Component
listener
- The listener.public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
removeVetoableChangeListener
in class javax.swing.JComponent
listener
- The listener.public void setConnection(SQLConnection connection) throws java.beans.PropertyVetoException
connection
- The SQL connection.java.beans.PropertyVetoException
- If the change is vetoed.public void setTables(java.lang.String[] tables) throws java.beans.PropertyVetoException
tables
- The names of the tables used in the query.
Tables should be in the form of schema.table.java.beans.PropertyVetoException
- If the change is vetoed.public void setTableSchemas(java.lang.String[] tableSchemas) throws java.beans.PropertyVetoException
tableSchemas
- The schemas for which tables will be listed.java.beans.PropertyVetoException
- If the change is vetoed.public void setUserSelectTables(boolean flag) throws java.beans.PropertyVetoException
flag
- true if the user is allowed to change the tables in the
query; false otherwise.java.beans.PropertyVetoException
- If the change is vetoed.public void setUserSelectTableSchemas(boolean flag) throws java.beans.PropertyVetoException
flag
- true if the user is allowed to change the schemas
whose tables are shown; false otherwise.java.beans.PropertyVetoException
- If the change is vetoed.