PIRL

PIRL.Database
Class Connect_View

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by PIRL.Database.Connect_View
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class Connect_View
extends JDialog

Connect_View provides a dialog used to interactively obtain the information needed to make a connection to a Database.

A Connect_View dialog, which may be modal or non-modal, may contain a user supplied decorative icon on the left side of the panel. The right side of the panel contains a list of label fields used to gather the database connection parameters. Buttons across the bottom allow the user to Connect - accept the current connection parameters and close the dialog - Clear - clear all connection parameters - or Cancel - reject all parameters and close the dialog.

A user supplied Configuration provides an initial source of database connection parameters. If no Configuration is supplied, an attempt is made to read the default configuration file. If this fails the user is offered the opportunity to browse for a configuration file to read. If this is rejected an empty Configuration is used.

A specific set of Server configuration parameters is assembled from the connection parameter fields of the dialog. There are two categories of fields:

Required Fields

The fields for the required parameters will always be present. They are drawn from the user supplied Configuration:

Server
The database Server parameters. This field is a drop-down list of each valid Server group; the user is notified when a Server list name does not have a corresponding group of parameters in the Configuration. Selecting an entry in the Server list results in the parameters of the Server group being used to set the values of all other fields, both required and additional, from each parameter that has a name matching one of the field names. The first Server name is used by default.

Note: When a parameter name in a selected Server group matches an additional field name, the parameter value is used to set the field value only when the field is currently empty or its value is not the user specified value.

Note: When the Server field is cleared the required fields are also cleared, but not any additional fields.

Type
The type of database server. This is used to select the appropriate Data_Port for managing the connection to the database server. A typical database type is MySQL. An entry in this field is required.
Host
The hostname of the computer system where the database server can be contacted. An entry in this field is required.
User
The username to supply when making a connection to the database server. Depending on the database connection requirements, this may be left empty.
Password
The password to supply when making a connection to the database server. The entry in this field will be masked. Depending on the database connection requirements, this may be left empty.

Additional Fields

An optional list containing the names of additional connection parameters to be obtained may be specified. Each field name may optionally be paired with an initial value for the field. All duplicate field names, including names that are the same (ignoring case) as any of the required field names, are removed leaving only the first unique name.

Buttons

Connect
Completion of user connection parameter entries. The field values are assembled into a server specific Configuration suitable for configuring a Database object. This Configuration will be named for the selected Server. N.B.: If the Server field is empty the Server name will be "unnamed". The Configuration will contain a Server parameter with a value that is the selected Server name and a group with the same name containing a parameter for each field where the name of each parameter is the field name and its value is the contents of the field. The Connect_View dialog will be closed (setVisible (false)).

N.B.: If the Type or Host field is empty a notice dialog will be preseted, the server specific Configuration will not be assembled, and the Connect_View dialog will not close.

Reset
Reset the additional, non-required fields to their original values. If there are noe user specified additional fields this button will not be present.
Clear
All fields, both required and any additional, are cleared.
Cancel
The server configuration is set to null to indicate that the database connection was canceled and the Connect_View dialog is closed.

Connect_View is a reusable dialog. Once constructed it only needs to be setVisible to be activated. If it had been used previously the previous field values will remain. The current server configuration is renewed after each use unless the Type or Host fields are empty when Connect is pressed.

Version:
1.11
Author:
Bradford Castalia, UA/PIRL
See Also:
Database, Configuration, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
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
static String ID
          Class name and version identification.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
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, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Connect_View()
          Constructs a default Connect_View.
Connect_View(Configuration configuration, boolean modal)
          Constructs a Database Connect_View dialog.
Connect_View(String title, boolean modal)
          Constructs a Database Connect_View dialog.
Connect_View(String title, Configuration configuration, boolean modal)
          Constructs a Database Connect_View dialog.
Connect_View(String title, Configuration configuration, Icon icon, boolean modal)
          Constructs a Database Connect_View dialog.
Connect_View(String title, Configuration configuration, Icon icon, Vector additional_field_names, boolean modal)
          Constructs a Database Connect_View dialog.
Connect_View(String title, Configuration configuration, Icon icon, Vector additional_field_names, Frame owner, boolean modal)
          Constructs a Database Connect_View dialog.
 
Method Summary
 Configuration Database_Configuration()
          Gets the current database server connection parameters.
static Configuration Get_Database_Configuration(String title, Configuration configuration, Icon icon, Vector additional_field_names, JFrame parent)
          Gets a Database Configuration.
static void main(String[] arguments)
           
 Configuration Server_Configuration(String server)
          Gets the Configuration for a specific Server.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
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, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, remove, 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
 

Field Detail

ID

public static final String ID
Class name and version identification.

See Also:
Constant Field Values
Constructor Detail

Connect_View

public Connect_View(String title,
                    Configuration configuration,
                    Icon icon,
                    Vector additional_field_names,
                    Frame owner,
                    boolean modal)
Constructs a Database Connect_View dialog.

Parameters:
title - The title String for the dialog window.
configuration - The Configuration containing default Database access parameters. If null the default configuration file will be used. If this can found or read the user will be offered the opportunity to browser for a configuration file. If rejected, an empty Configuration will be supplied.
icon - The Icon to be displayed on the dialog. If null no Icon is displayed.
additional_field_names - A Vector of String values (or any Object that can be converted to a String) which are the names of additional parameters that are to be obtained beyond the required parameters. Instead of a String entry a Vector containing a pair of String values (or any Objects that can be converted to Strings) may be used in which the first value is the parameter name and the second value is its initial value. The Vector may be empty or null.
owner - The Frame with which the dialog is associated, which may be null.
modal - If true, the dialog will be modal; if false, the dialog will not be modal.

Connect_View

public Connect_View(String title,
                    Configuration configuration,
                    Icon icon,
                    Vector additional_field_names,
                    boolean modal)
Constructs a Database Connect_View dialog.

Parameters:
title - The title String for the dialog window.
configuration - The Configuration containing default Database access parameters. If null the default configuration file will be used. If this can found or read the user will be offered the opportunity to browser for a configuration file. If rejected, an empty Configuration will be supplied.
icon - The Icon to be displayed on the dialog. If null no Icon is displayed.
additional_field_names - A Vector of String values (or any Object that can be converted to a String) which are the names of additional parameters that are to be obtained beyond the required parameters. Instead of a String entry a Vector containing a pair of String values (or any Objects that can be converted to Strings) may be used in which the first value is the parameter name and the second value is its initial value. The Vector may be empty or null.
modal - If true, the dialog will be modal; if false, the dialog will not be modal.

Connect_View

public Connect_View(String title,
                    Configuration configuration,
                    Icon icon,
                    boolean modal)
Constructs a Database Connect_View dialog.

Parameters:
title - The title String for the dialog window.
configuration - The Configuration containing default Database access parameters. If null the default configuration file will be used. If this can found or read the user will be offered the opportunity to browser for a configuration file. If rejected, an empty Configuration will be supplied.
icon - The Icon to be displayed on the dialog. If null no Icon is displayed.
modal - If true, the dialog will be modal; if false, the dialog will not be modal.

Connect_View

public Connect_View(String title,
                    Configuration configuration,
                    boolean modal)
Constructs a Database Connect_View dialog.

Parameters:
title - The title String for the dialog window.
configuration - The Configuration containing default Database access parameters. If null the default configuration file will be used. If this can found or read the user will be offered the opportunity to browser for a configuration file. If rejected, an empty Configuration will be supplied.
modal - If true, the dialog will be modal; if false, the dialog will not be modal.

Connect_View

public Connect_View(String title,
                    boolean modal)
Constructs a Database Connect_View dialog.

Parameters:
title - The title String for the dialog window.
modal - If true, the dialog will be modal; if false, the dialog will not be modal.

Connect_View

public Connect_View(Configuration configuration,
                    boolean modal)
Constructs a Database Connect_View dialog.

Parameters:
configuration - The Configuration containing default Database access parameters. If null the default configuration file will be used. If this can found or read the user will be offered the opportunity to browser for a configuration file. If rejected, an empty Configuration will be supplied.
modal - If true, the dialog will be modal; if false, the dialog will not be modal.

Connect_View

public Connect_View()
Constructs a default Connect_View.

Method Detail

Get_Database_Configuration

public static Configuration Get_Database_Configuration(String title,
                                                       Configuration configuration,
                                                       Icon icon,
                                                       Vector additional_field_names,
                                                       JFrame parent)
Gets a Database Configuration.

Parameters:
title - The title String for the dialog window.
configuration - The Configuration containing default Database access parameters. If null the default configuration file will be used. If this can found or read the user will be offered the opportunity to browser for a configuration file. If rejected, an empty Configuration will be supplied.
icon - The Icon to be displayed on the dialog. If null no Icon is displayed.
additional_field_names - A Vector of String values (or any Object that can be converted to a String) which are the names of additional parameters that are to be obtained beyond the required parameters. Instead of a String entry a Vector containing a pair of String values (or any Objects that can be converted to Strings) may be used in which the first value is the parameter name and the second value is its initial value. The Vector may be empty or null.
parent - The parent window that dialog is associated with, which may be null.
Returns:
A Configuration containing the parameters obtained, which should be suitable for configuring a Database to make the user defined connection. This will be null if the user Canelled the dialog.

Database_Configuration

public Configuration Database_Configuration()
Gets the current database server connection parameters.

Returns:
A Configuration containing the current database connection parameters. This may be null.

Server_Configuration

public Configuration Server_Configuration(String server)
Gets the Configuration for a specific Server.

Parameters:
server - The name of the group of parameters in the current Configuration that is expected to contain database server access parameters.
Returns:
The Configuration for the server group of parameters, or null if the server group was not found.

main

public static void main(String[] arguments)

PIRL

Copyright (C) \ 2003-2009 Bradford Castalia, University of Arizona