Package adams.gui.dialog
Class AbstractDatabaseConnectionPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.dialog.AbstractDatabaseConnectionPanel
-
- All Implemented Interfaces:
StatusMessageHandler
,DatabaseConnectionProvider
,DatabaseConnectionUser
,ImageObserver
,MenuContainer
,Serializable
,Comparable<AbstractDatabaseConnectionPanel>
,Accessible
- Direct Known Subclasses:
AbstractConfigDatabaseConnectionPanel
,DatabaseConnectionPanel
public abstract class AbstractDatabaseConnectionPanel extends BasePanel implements StatusMessageHandler, Comparable<AbstractDatabaseConnectionPanel>, DatabaseConnectionProvider
A panel for connecting to a database.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- 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
Fields Modifier and Type Field Description protected BaseButton
m_ButtonConnect
the button connecting/disconnecting the database.protected BaseButton
m_ButtonMakeDefault
the button for making a connection the default one.protected BaseButton
m_ButtonNew
the button for creating a new connection.protected BaseButton
m_ButtonRemove
the button removing the database connection.protected HashSet<ChangeListener>
m_ChangeListeners
the change listeners.protected BaseCheckBox
m_CheckBoxAutoCommit
the checkbox for auto-commit.protected BaseCheckBox
m_CheckBoxConnectOnStartUp
the checkbox for connecting on startup.protected BaseComboBox<ConnectionParameters>
m_ComboBoxConnections
the combobox with the available connections.protected BaseComboBox<LoggingLevel>
m_ComboBoxLoggingLevel
the combobox for the logging level.protected JLabel
m_LabelStatus
the label for status messages.protected ParameterPanel
m_PanelParameters
for the parameters.protected AbstractDatabaseConnectionPanel
m_Self
the panel itself.protected BasePasswordFieldWithButton
m_TextPassword
the edit field for the database password.protected BaseTextField
m_TextURL
the edit field for the database URL.protected BaseTextField
m_TextUser
the edit field for the database user.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Constructors Constructor Description AbstractDatabaseConnectionPanel()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(ChangeListener l)
Adds the listener for changes in the connection.int
compareTo(AbstractDatabaseConnectionPanel o)
Compares this object with the specified object for order.protected void
connectionParametersToFields(ConnectionParameters conn)
Updates the fields with the parameters.boolean
disconnectConnections()
Clears the connections.protected void
displayConnection(AbstractDatabaseConnection conn)
Displays the connection.protected void
displayConnection(ConnectionParameters params)
Displays the connection parameters.boolean
equals(Object o)
Checks whether this object is equal to the specified one.protected void
finishInit()
Finishes the initialization.protected AbstractDatabaseConnection
getActiveConnectionFor(ConnectionParameters params)
Returns the connection that is represented by the connection parameters.protected List<ConnectionParameters>
getAllConnectionParameters()
Returns all the connection parameters as sorted list.protected ConnectionParameters
getCurrentParameters()
Returns the current parameters as connection object.abstract AbstractDatabaseConnection
getDatabaseConnection()
Returns the currently used database connection object, can be null.protected abstract AbstractDatabaseConnection
getDefaultDatabaseConnection()
Returns the default database connection to use.protected abstract String
getTitle()
The title of the connection panel.protected void
initGUI()
Initializes the GUI.protected void
initialize()
For initializing members.protected void
makeDefault()
Makes the current parameters the default.protected void
newConnection()
Allows adding a new connection.protected ConnectionParameters
newConnectionParameters()
Returns a new instance of a ConnectionParameters object.protected void
notifyChangeListeners()
Notifies all listeners about a change in the connection.protected abstract void
performConnect()
Performs the connect.protected abstract void
performDisconnect()
Performs the disconnect.void
removeChangeListener(ChangeListener l)
Removes the listener for changes in the connection.protected void
removeConnection()
Removes the current parameters as available connection.void
showStatus(String msg)
Displays a message.void
update()
updates the enabled state content etc.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
m_Self
protected AbstractDatabaseConnectionPanel m_Self
the panel itself.
-
m_ComboBoxConnections
protected BaseComboBox<ConnectionParameters> m_ComboBoxConnections
the combobox with the available connections.
-
m_TextURL
protected BaseTextField m_TextURL
the edit field for the database URL.
-
m_TextUser
protected BaseTextField m_TextUser
the edit field for the database user.
-
m_TextPassword
protected BasePasswordFieldWithButton m_TextPassword
the edit field for the database password.
-
m_ComboBoxLoggingLevel
protected BaseComboBox<LoggingLevel> m_ComboBoxLoggingLevel
the combobox for the logging level.
-
m_CheckBoxConnectOnStartUp
protected BaseCheckBox m_CheckBoxConnectOnStartUp
the checkbox for connecting on startup.
-
m_CheckBoxAutoCommit
protected BaseCheckBox m_CheckBoxAutoCommit
the checkbox for auto-commit.
-
m_ButtonNew
protected BaseButton m_ButtonNew
the button for creating a new connection.
-
m_ButtonRemove
protected BaseButton m_ButtonRemove
the button removing the database connection.
-
m_ButtonMakeDefault
protected BaseButton m_ButtonMakeDefault
the button for making a connection the default one.
-
m_ButtonConnect
protected BaseButton m_ButtonConnect
the button connecting/disconnecting the database.
-
m_LabelStatus
protected JLabel m_LabelStatus
the label for status messages.
-
m_PanelParameters
protected ParameterPanel m_PanelParameters
for the parameters.
-
m_ChangeListeners
protected HashSet<ChangeListener> m_ChangeListeners
the change listeners.
-
-
Method Detail
-
initialize
protected void initialize()
For initializing members.- Overrides:
initialize
in classBasePanel
-
getDefaultDatabaseConnection
protected abstract AbstractDatabaseConnection getDefaultDatabaseConnection()
Returns the default database connection to use.- Returns:
- the database connection
-
getAllConnectionParameters
protected List<ConnectionParameters> getAllConnectionParameters()
Returns all the connection parameters as sorted list.- Returns:
- the sorted list
-
finishInit
protected void finishInit()
Finishes the initialization.- Overrides:
finishInit
in classBasePanel
-
getTitle
protected abstract String getTitle()
The title of the connection panel.- Returns:
- the title
-
connectionParametersToFields
protected void connectionParametersToFields(ConnectionParameters conn)
Updates the fields with the parameters.- Parameters:
conn
- the parameters to display
-
getActiveConnectionFor
protected AbstractDatabaseConnection getActiveConnectionFor(ConnectionParameters params)
Returns the connection that is represented by the connection parameters.- Parameters:
params
- the parameters to get the connection for (if any)- Returns:
- the connection, null if none active
-
displayConnection
protected void displayConnection(ConnectionParameters params)
Displays the connection parameters.- Parameters:
params
- the database connection to display
-
displayConnection
protected void displayConnection(AbstractDatabaseConnection conn)
Displays the connection.- Parameters:
conn
- the database connection to display
-
performConnect
protected abstract void performConnect()
Performs the connect.
-
performDisconnect
protected abstract void performDisconnect()
Performs the disconnect.
-
newConnection
protected void newConnection()
Allows adding a new connection.
-
removeConnection
protected void removeConnection()
Removes the current parameters as available connection.
-
makeDefault
protected void makeDefault()
Makes the current parameters the default.
-
newConnectionParameters
protected ConnectionParameters newConnectionParameters()
Returns a new instance of a ConnectionParameters object.- Returns:
- the empty parameters object
-
getCurrentParameters
protected ConnectionParameters getCurrentParameters()
Returns the current parameters as connection object.- Returns:
- the current setup
-
getDatabaseConnection
public abstract AbstractDatabaseConnection getDatabaseConnection()
Returns the currently used database connection object, can be null.- Specified by:
getDatabaseConnection
in interfaceDatabaseConnectionProvider
- Returns:
- the current object
-
update
public void update()
updates the enabled state content etc. of all the GUI elements, based on the DatabaseConnection object of the scripting engine.
-
showStatus
public void showStatus(String msg)
Displays a message.- Specified by:
showStatus
in interfaceStatusMessageHandler
- Parameters:
msg
- the message to display
-
compareTo
public int compareTo(AbstractDatabaseConnectionPanel o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Merely uses the title of the panels for comparison.- Specified by:
compareTo
in interfaceComparable<AbstractDatabaseConnectionPanel>
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
Checks whether this object is equal to the specified one.
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds the listener for changes in the connection.- Parameters:
l
- the listener to add
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes the listener for changes in the connection.- Parameters:
l
- the listener to remove
-
notifyChangeListeners
protected void notifyChangeListeners()
Notifies all listeners about a change in the connection.
-
disconnectConnections
public boolean disconnectConnections()
Clears the connections.- Returns:
- true if able to clear connections
-
-