org.objectweb.cjdbc.controller.console
Class GUIConsoleHelper

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byorg.objectweb.cjdbc.controller.console.GUIConsoleHelper
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, ConsoleHelperInterface, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class GUIConsoleHelper
extends javax.swing.JFrame
implements ConsoleHelperInterface, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.ActionListener

Graphical C-JDBC console that allows remote administration and monitoring of any C-JDBC controller.

This code has been inspired by the BeanShell Java Scripting project (http://www.beanshell.org/) by Patrick Niemeyer (pat@pat.net).

Version:
1.0
Author:
Mathieu Peltier, Emmanuel Cecchet
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.lang.String ADMIN_DISABLEALL
           
private static java.lang.String ADMIN_ENABLEALL
           
private static java.lang.String ADMIN_STATUS
           
private  int cmdStart
          Index for the command first character.
private  CommandCompletorInterface commandCompletor
          Command completor to use.
private static java.awt.Color COMPLETION_COLOR
          Completion possibilities Color.
private static java.lang.String CONTROLLER_ADD_DRIVER
           
private static java.lang.String CONTROLLER_CONNECT
           
private static java.lang.String CONTROLLER_GETDUMP
           
private static java.lang.String CONTROLLER_GETINFO
           
private static java.lang.String CONTROLLER_LOAD_CONFIG
           
private static java.lang.String COPY
           
private static java.lang.String CUT
          Popup menu command.
private  boolean echo
          true if the input must be displayed in the console.
private static java.awt.Color ERROR_COLOR
          Error message Color.
private static java.awt.Font FONT
          Console Font.
private  boolean gotUp
          Hack to prevent key repeat for some reason?
private static java.lang.String HELP
           
private  int histLine
           
private  java.util.ArrayList history
          Contains the historic of commands.
private  java.lang.String lastAcceptedLine
          Contains the last line entered in the console.
private  javax.swing.JPopupMenu menu
          Popu menu.
private  java.lang.StringBuffer password
          Contains the password entered in the console.
private static java.lang.String PASTE
           
private static java.awt.Color PROMPT_COLOR
          Console prompt Color.
private static java.lang.String QUIT
           
private static int SHOW_AMBIG_MAX
          Maximum number of the completion possibilities to display.
private static java.lang.String SQL_LOAD_FILE
          Popup menu command.
private static java.lang.String SQL_SHOW_TABLE
           
private  java.lang.String startedLine
           
private  javax.swing.JTextPane text
          Console panel.
 
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.Window
 
Fields inherited from class java.awt.Container
 
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
GUIConsoleHelper()
          Creates a new GUIConsoleHelper instance.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
private  void append(java.lang.String string)
           
(package private)  void doCommandCompletion(java.lang.String part)
           
private  void enter()
           
private  void forceCaretMoveToEnd()
           
private  void forceCaretMoveToStart()
           
private  java.lang.String getFilename(java.lang.String title)
           
private  java.lang.String getLine()
           
 javax.swing.text.AttributeSet getStyle()
          Gets the current style.
private  void historyDown()
           
private  void historyUp()
           
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent event)
           
 void mouseEntered(java.awt.event.MouseEvent event)
           
 void mouseExited(java.awt.event.MouseEvent event)
           
 void mousePressed(java.awt.event.MouseEvent event)
           
 void mouseReleased(java.awt.event.MouseEvent event)
           
 void print(java.lang.String string)
          Prints a String.
 void print(java.lang.String s, java.awt.Color color)
          Prints a given String in the console with the given color.
 void printError(java.lang.String message)
          Prints an error message followed by a new line.
 void println()
          Prints a new line.
 void println(java.lang.String string)
          Prints a String followed by a new line.
 java.lang.String readLine(java.lang.String prompt)
          Gets a command.
 java.lang.String readPassword(java.lang.String prompt)
          Gets a password.
private  java.lang.String replaceRange(java.lang.Object s, int start, int end)
           
private  void resetCommandStart()
           
 void setCommandCompletor(CommandCompletorInterface completor)
          Sets the command completor to use.
 void setFont(java.awt.Font font)
           
 void setStyle(javax.swing.text.AttributeSet attributes)
          Sets the new style attributes.
 void setStyle(javax.swing.text.AttributeSet attributes, boolean overWrite)
          Sets the new style attributes.
 javax.swing.text.AttributeSet setStyle(java.awt.Color color)
          Sets the text color.
private  void showHistoryLine()
           
private  int textLength()
           
private  void type(java.awt.event.KeyEvent e)
           
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, 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, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, 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, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, isOpaque, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

CUT

private static final java.lang.String CUT
Popup menu command.

See Also:
Constant Field Values

COPY

private static final java.lang.String COPY
See Also:
Constant Field Values

PASTE

private static final java.lang.String PASTE
See Also:
Constant Field Values

HELP

private static final java.lang.String HELP
See Also:
Constant Field Values

QUIT

private static final java.lang.String QUIT
See Also:
Constant Field Values

SQL_LOAD_FILE

private static final java.lang.String SQL_LOAD_FILE
Popup menu command.

See Also:
Constant Field Values

SQL_SHOW_TABLE

private static final java.lang.String SQL_SHOW_TABLE
See Also:
Constant Field Values

ADMIN_STATUS

private static final java.lang.String ADMIN_STATUS
See Also:
Constant Field Values

ADMIN_ENABLEALL

private static final java.lang.String ADMIN_ENABLEALL
See Also:
Constant Field Values

ADMIN_DISABLEALL

private static final java.lang.String ADMIN_DISABLEALL
See Also:
Constant Field Values

CONTROLLER_CONNECT

private static final java.lang.String CONTROLLER_CONNECT
See Also:
Constant Field Values

CONTROLLER_LOAD_CONFIG

private static final java.lang.String CONTROLLER_LOAD_CONFIG
See Also:
Constant Field Values

CONTROLLER_ADD_DRIVER

private static final java.lang.String CONTROLLER_ADD_DRIVER
See Also:
Constant Field Values

CONTROLLER_GETINFO

private static final java.lang.String CONTROLLER_GETINFO
See Also:
Constant Field Values

CONTROLLER_GETDUMP

private static final java.lang.String CONTROLLER_GETDUMP
See Also:
Constant Field Values

FONT

private static final java.awt.Font FONT
Console Font.


PROMPT_COLOR

private static final java.awt.Color PROMPT_COLOR
Console prompt Color.


ERROR_COLOR

private static final java.awt.Color ERROR_COLOR
Error message Color.


COMPLETION_COLOR

private static final java.awt.Color COMPLETION_COLOR
Completion possibilities Color.


SHOW_AMBIG_MAX

private static final int SHOW_AMBIG_MAX
Maximum number of the completion possibilities to display.

See Also:
Constant Field Values

commandCompletor

private CommandCompletorInterface commandCompletor
Command completor to use.


lastAcceptedLine

private java.lang.String lastAcceptedLine
Contains the last line entered in the console.


password

private java.lang.StringBuffer password
Contains the password entered in the console.


startedLine

private java.lang.String startedLine

cmdStart

private int cmdStart
Index for the command first character.


history

private java.util.ArrayList history
Contains the historic of commands.


histLine

private int histLine

menu

private javax.swing.JPopupMenu menu
Popu menu.


text

private javax.swing.JTextPane text
Console panel.


gotUp

private boolean gotUp
Hack to prevent key repeat for some reason?


echo

private boolean echo
true if the input must be displayed in the console.

Constructor Detail

GUIConsoleHelper

public GUIConsoleHelper()
Creates a new GUIConsoleHelper instance.

Method Detail

readLine

public java.lang.String readLine(java.lang.String prompt)
                          throws ConsoleHelperException
Description copied from interface: ConsoleHelperInterface
Gets a command.

Specified by:
readLine in interface ConsoleHelperInterface
Parameters:
prompt - the prompt to display
Returns:
a String instance
Throws:
ConsoleHelperException - if an error occurs.
See Also:
ConsoleHelperInterface.readLine(java.lang.String)

readPassword

public java.lang.String readPassword(java.lang.String prompt)
                              throws ConsoleHelperException
Description copied from interface: ConsoleHelperInterface
Gets a password. If possible the implementation class should not displayed the data entered by the user.

Specified by:
readPassword in interface ConsoleHelperInterface
Parameters:
prompt - the prompt to display
Returns:
a String instance
Throws:
ConsoleHelperException - if an error occurs.
See Also:
ConsoleHelperInterface.readPassword(java.lang.String)

println

public void println(java.lang.String string)
Description copied from interface: ConsoleHelperInterface
Prints a String followed by a new line.

Specified by:
println in interface ConsoleHelperInterface
Parameters:
string - the String to print.
See Also:
ConsoleHelperInterface.println(java.lang.String)

println

public void println()
Description copied from interface: ConsoleHelperInterface
Prints a new line.

Specified by:
println in interface ConsoleHelperInterface
See Also:
ConsoleHelperInterface.println()

print

public void print(java.lang.String string)
Description copied from interface: ConsoleHelperInterface
Prints a String.

Specified by:
print in interface ConsoleHelperInterface
Parameters:
string - the String to print.
See Also:
ConsoleHelperInterface.print(java.lang.String)

printError

public void printError(java.lang.String message)
Description copied from interface: ConsoleHelperInterface
Prints an error message followed by a new line.

Specified by:
printError in interface ConsoleHelperInterface
Parameters:
message - the error message to print.
See Also:
ConsoleHelperInterface.printError(java.lang.String)

print

public void print(java.lang.String s,
                  java.awt.Color color)
Prints a given String in the console with the given color.

Parameters:
s - the String to print.
color - the Color to use.

setCommandCompletor

public void setCommandCompletor(CommandCompletorInterface completor)
Description copied from interface: ConsoleHelperInterface
Sets the command completor to use.

Specified by:
setCommandCompletor in interface ConsoleHelperInterface
Parameters:
completor - a CommandCompletor instance.
See Also:
ConsoleHelperInterface.setCommandCompletor(org.objectweb.cjdbc.controller.console.CommandCompletorInterface)

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener
See Also:
KeyListener.keyPressed(java.awt.event.KeyEvent)

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener
See Also:
KeyListener.keyTyped(java.awt.event.KeyEvent)

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener
See Also:
KeyListener.keyReleased(java.awt.event.KeyEvent)

type

private void type(java.awt.event.KeyEvent e)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)
Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent event)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent event)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(java.awt.event.MouseEvent event)
Specified by:
mouseExited in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener
See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent)

doCommandCompletion

void doCommandCompletion(java.lang.String part)

resetCommandStart

private void resetCommandStart()

append

private void append(java.lang.String string)

replaceRange

private java.lang.String replaceRange(java.lang.Object s,
                                      int start,
                                      int end)

forceCaretMoveToEnd

private void forceCaretMoveToEnd()

forceCaretMoveToStart

private void forceCaretMoveToStart()

enter

private void enter()

getLine

private java.lang.String getLine()

historyUp

private void historyUp()

historyDown

private void historyDown()

showHistoryLine

private void showHistoryLine()

textLength

private int textLength()

setStyle

public javax.swing.text.AttributeSet setStyle(java.awt.Color color)
Sets the text color.

Parameters:
color - the color to set.
Returns:
the new updated style.

setStyle

public void setStyle(javax.swing.text.AttributeSet attributes)
Sets the new style attributes.

Parameters:
attributes - the attributes to set.

setStyle

public void setStyle(javax.swing.text.AttributeSet attributes,
                     boolean overWrite)
Sets the new style attributes.

Parameters:
attributes - the attributes to set.
overWrite - if the attributes must be overwritten.

getStyle

public javax.swing.text.AttributeSet getStyle()
Gets the current style.

Returns:
current style.

setFont

public void setFont(java.awt.Font font)
See Also:
Component.setFont(Font)

getFilename

private java.lang.String getFilename(java.lang.String title)


Copyright © 2002, 2003 - ObjectWeb Consortium - All Rights Reserved.