com.mindbright.terminal
Class TerminalMenuHandlerFull

java.lang.Object
  extended by com.mindbright.terminal.TerminalMenuHandler
      extended by com.mindbright.terminal.TerminalMenuHandlerFull
All Implemented Interfaces:
TerminalOutputListener, TerminalPrinter, java.awt.event.ActionListener, java.awt.event.ItemListener, java.util.EventListener

public class TerminalMenuHandlerFull
extends TerminalMenuHandler
implements java.awt.event.ActionListener, java.awt.event.ItemListener, TerminalPrinter

The actual implementation of the standard terminal menus.

See Also:
TerminalWin

Field Summary
static int MENU_EDIT
           
static int MENU_FILE
           
static int MENU_SETTINGS
           
 
Constructor Summary
TerminalMenuHandlerFull()
           
TerminalMenuHandlerFull(java.lang.String titleName)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Called when a menu item was selected
 void addBasicMenus(TerminalWin terminal, javax.swing.JMenuBar mb)
          Install the standard menus on the given frame.
 boolean captureToFileDialog()
          Start capturing data to file.
 java.io.FileOutputStream chooseFileDialog(java.lang.String title)
          Shows a save dialog with the specified title.
 void endCapture()
          Stop capturing data in a file.
 void findDialog(java.lang.String title)
          Show the find dialog.
 javax.swing.JMenu getMenu(int idx)
           
 void handleMenuAction(int[] id)
          Actually handle the selection of all the menu elements.
 void itemStateChanged(java.awt.event.ItemEvent e)
          Called when a checkbox menu item has changed state
 void printBuffer()
           
 void printScreen()
          Print a dump of the current screen.
 void sendFileDialog()
          Show the send file dialog.
 void setPopupMenu(java.lang.Object menu)
          Registers a popup menu.
 void setReadOnlyMode(boolean readOnly)
          Configure these menus to possibly act as belonging to a read only terminal.
 void setTerminalMenuListener(TerminalMenuListener listener)
          Register a listener which is interested in menu events
 void setTerminalWin(TerminalWin term)
          Attach to a terminal window.
 void setTitleName(java.lang.String titleName)
          Set the name of this application.
 void showPopupMenu(int x, int y)
          Show the popup menu at the indicated position.
 void startPrinter()
          Start printing data to printer.
 void stopPrinter()
          Stop sending data to printer.
 void termSettingsDialog()
          Show the terminal settings dialog with the default title.
 void termSettingsDialog(java.lang.String title)
          Show the terminal settings dialog.
 void update()
          Gets called when the contents of the menus might need updating.
 void updateSelection(boolean selectionAvailable)
          Gets called when the selection state is changed
 void write(char c)
          Write a character to the printer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MENU_FILE

public static final int MENU_FILE
See Also:
Constant Field Values

MENU_EDIT

public static final int MENU_EDIT
See Also:
Constant Field Values

MENU_SETTINGS

public static final int MENU_SETTINGS
See Also:
Constant Field Values
Constructor Detail

TerminalMenuHandlerFull

public TerminalMenuHandlerFull()

TerminalMenuHandlerFull

public TerminalMenuHandlerFull(java.lang.String titleName)
Method Detail

setTitleName

public void setTitleName(java.lang.String titleName)
Description copied from class: TerminalMenuHandler
Set the name of this application. This name may be used in the title of any dialogs popped up etc.

Specified by:
setTitleName in class TerminalMenuHandler
Parameters:
titleName - the application name for window titles

setTerminalWin

public void setTerminalWin(TerminalWin term)
Description copied from class: TerminalMenuHandler
Attach to a terminal window.

Specified by:
setTerminalWin in class TerminalMenuHandler
Parameters:
term - terminal window to attach to

setReadOnlyMode

public void setReadOnlyMode(boolean readOnly)
Description copied from class: TerminalMenuHandler
Configure these menus to possibly act as belonging to a read only terminal.

Specified by:
setReadOnlyMode in class TerminalMenuHandler
Parameters:
readOnly - true if the menus should be configured for read only mode.

setTerminalMenuListener

public void setTerminalMenuListener(TerminalMenuListener listener)
Description copied from class: TerminalMenuHandler
Register a listener which is interested in menu events

Specified by:
setTerminalMenuListener in class TerminalMenuHandler
Parameters:
listener - the interested listener

addBasicMenus

public void addBasicMenus(TerminalWin terminal,
                          javax.swing.JMenuBar mb)
Description copied from class: TerminalMenuHandler
Install the standard menus on the given frame. There is no need to call setTerminalWin before calling this since the actual terminal window is passed here as well.

Specified by:
addBasicMenus in class TerminalMenuHandler
Parameters:
terminal - terminal window to attach to
mb - menu bar to add menus to

updateSelection

public void updateSelection(boolean selectionAvailable)
Description copied from class: TerminalMenuHandler
Gets called when the selection state is changed

Specified by:
updateSelection in class TerminalMenuHandler
Parameters:
selectionAvailable - true if some text is selected

update

public void update()
Description copied from class: TerminalMenuHandler
Gets called when the contents of the menus might need updating.

Specified by:
update in class TerminalMenuHandler

termSettingsDialog

public void termSettingsDialog(java.lang.String title)
Show the terminal settings dialog.

Parameters:
title - desired title of dialog

termSettingsDialog

public void termSettingsDialog()
Show the terminal settings dialog with the default title.


findDialog

public void findDialog(java.lang.String title)
Show the find dialog.

Parameters:
title - desired title of dialog

sendFileDialog

public final void sendFileDialog()
Show the send file dialog.


chooseFileDialog

public final java.io.FileOutputStream chooseFileDialog(java.lang.String title)
Shows a save dialog with the specified title. The selected file is returned as an opened FileOutputStream

Parameters:
title - title of dialog
Returns:
the opened file or null if the user aborted or an error ocurred.

captureToFileDialog

public final boolean captureToFileDialog()
Start capturing data to file. This function will cause a save dialog to appear and if a file was successfully specified then a log of the terminal session from now on will be stored in the file.


endCapture

public void endCapture()
Stop capturing data in a file. Capturing is started by calling captureToFileDialog().


getMenu

public javax.swing.JMenu getMenu(int idx)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Called when a menu item was selected

Specified by:
actionPerformed in interface java.awt.event.ActionListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Called when a checkbox menu item has changed state

Specified by:
itemStateChanged in interface java.awt.event.ItemListener

handleMenuAction

public void handleMenuAction(int[] id)
Actually handle the selection of all the menu elements.


setPopupMenu

public void setPopupMenu(java.lang.Object menu)
Description copied from class: TerminalMenuHandler
Registers a popup menu.

Specified by:
setPopupMenu in class TerminalMenuHandler
Parameters:
menu - the popup menu. This is passed as an Object since it may be either a PopupMenu or JPopupMenu.

showPopupMenu

public void showPopupMenu(int x,
                          int y)
Description copied from class: TerminalMenuHandler
Show the popup menu at the indicated position.

Specified by:
showPopupMenu in class TerminalMenuHandler
Parameters:
x - x-coordinate of position to show menu ay
y - y-coordinate of position to show menu ay

write

public void write(char c)
Write a character to the printer.

Specified by:
write in interface TerminalOutputListener
Parameters:
c - charcter to write

startPrinter

public void startPrinter()
Start printing data to printer. That is currently it only saves data in a file.

Specified by:
startPrinter in interface TerminalPrinter

stopPrinter

public void stopPrinter()
Stop sending data to printer.

Specified by:
stopPrinter in interface TerminalPrinter

printScreen

public void printScreen()
Description copied from interface: TerminalPrinter
Print a dump of the current screen.

Specified by:
printScreen in interface TerminalPrinter

printBuffer

public void printBuffer()