public class ConnectionPanel extends JPanel implements CaretListener
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static String |
HISTORY_NAME
the name of the history.
|
protected JButton |
m_ButtonConnect
the button for connecting to the database.
|
protected JButton |
m_ButtonDatabase
the button for the DB-Dialog.
|
protected JButton |
m_ButtonHistory
the button for the history.
|
protected HashSet |
m_ConnectionListeners
the connection listeners.
|
protected DatabaseConnectionDialog |
m_DbDialog
the databae connection dialog.
|
protected DbUtils |
m_DbUtils
for connecting to the database.
|
protected DefaultListModel |
m_History
the history of connections.
|
protected HashSet |
m_HistoryChangedListeners
the history listeners.
|
protected JLabel |
m_LabelURL
the label for the URL.
|
protected JFrame |
m_Parent
the parent frame.
|
protected String |
m_Password
the password to use for connecting to the DB.
|
protected JTextField |
m_TextURL
the textfield for the URL.
|
protected String |
m_URL
the URL to use.
|
protected String |
m_User
the user to use for connecting to the DB.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
ConnectionPanel(JFrame parent)
initializes the panel.
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(ConnectionListener l)
adds the given listener to the list of listeners.
|
protected void |
addHistory(String s)
adds the given string to the history (removes duplicates).
|
void |
addHistoryChangedListener(HistoryChangedListener l)
adds the given listener to the list of listeners.
|
void |
caretUpdate(CaretEvent event)
Called when the caret position is updated.
|
void |
clear()
sets the parameters back to standard.
|
protected void |
connect()
connects to the database, notifies the listeners.
|
protected void |
createPanel()
builds the panel with all its components.
|
DefaultListModel |
getHistory()
returns the history.
|
String |
getPassword()
returns the current Password.
|
String |
getURL()
returns the current URL.
|
String |
getUser()
returns the current User.
|
protected void |
notifyConnectionListeners(int type)
notifies the connection listeners of the event.
|
protected void |
notifyConnectionListeners(int type,
Exception ex)
notifies the connection listeners of the event.
|
protected void |
notifyHistoryChangedListeners()
notifies the history listeners of the event.
|
void |
removeConnectionListener(ConnectionListener l)
removes the given listener from the list of listeners.
|
void |
removeHistoryChangedListener(HistoryChangedListener l)
removes the given listener from the list of listeners.
|
protected void |
setButtons()
sets the buttons according to the connected-state.
|
void |
setFocus()
sets the focus in a designated control.
|
void |
setHistory(DefaultListModel history)
sets the local history to the given one.
|
void |
setPassword(String pw)
sets the Password.
|
void |
setURL(String url)
sets the URL.
|
void |
setUser(String user)
sets the User.
|
protected void |
showDialog()
displays the database dialog.
|
void |
showHistory()
displays the query history.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, setVisible, unregisterKeyboardAction, update
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
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, 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, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final String HISTORY_NAME
protected JFrame m_Parent
protected DatabaseConnectionDialog m_DbDialog
protected String m_URL
protected String m_User
protected String m_Password
protected JLabel m_LabelURL
protected JTextField m_TextURL
protected JButton m_ButtonDatabase
protected JButton m_ButtonConnect
protected JButton m_ButtonHistory
protected HashSet m_ConnectionListeners
protected HashSet m_HistoryChangedListeners
protected DbUtils m_DbUtils
protected DefaultListModel m_History
public ConnectionPanel(JFrame parent)
parent
- the parent of this panelprotected void createPanel()
protected void setButtons()
public void clear()
public void setFocus()
public void setURL(String url)
url
- the new value of the URLpublic String getURL()
public void setUser(String user)
user
- the new value of the Userpublic String getUser()
public void setPassword(String pw)
pw
- the new value of the Passwordpublic String getPassword()
protected void addHistory(String s)
s
- the string to addpublic void setHistory(DefaultListModel history)
history
- the history to usepublic DefaultListModel getHistory()
protected void showDialog()
protected void connect()
public void showHistory()
public void addConnectionListener(ConnectionListener l)
l
- the listener to add to the listpublic void removeConnectionListener(ConnectionListener l)
l
- the listener to removeprotected void notifyConnectionListeners(int type)
type
- the type of the action, CONNECT or DISCONNECTprotected void notifyConnectionListeners(int type, Exception ex)
type
- the type of the action, CONNECT or DISCONNECTex
- an optional exception that happened (indicates failure!)public void addHistoryChangedListener(HistoryChangedListener l)
l
- the listener to add to the listpublic void removeHistoryChangedListener(HistoryChangedListener l)
l
- the listener to removeprotected void notifyHistoryChangedListeners()
public void caretUpdate(CaretEvent event)
caretUpdate
in interface CaretListener
event
- the event to processCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.