com.mindbright.terminal
Class TerminalMenuHandlerFull

java.lang.Object
  extended bycom.mindbright.terminal.TerminalMenuHandler
      extended bycom.mindbright.terminal.TerminalMenuHandlerFull
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.ItemListener, TerminalOutputListener, TerminalPrinter
Direct Known Subclasses:
TerminalMenuHandlerFullAWT, TerminalMenuHandlerFullSwing

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

The actual implementation of the standard terminal menus. Or rather the front-end to the actual implementation since this class depends on its two subclasses TerminalMenuHandlerFullAWT and TerminalMenuHandlerFullSwing for the actual handling. That means that this class, together with the suitable subclass, can handle bit AWT and Swing menus.

See Also:
TerminalWin, TerminalMenuHandlerFullAWT, TerminalMenuHandlerFullSwing

Field Summary
protected static java.lang.String[] ENCODINGS
           
protected static java.lang.String[] FONT_LIST
           
protected  SearchContext lastSearch
           
protected static java.lang.String LBL_BG_COLOR
           
protected static java.lang.String LBL_BTN_CANCEL
           
protected static java.lang.String LBL_BTN_FIND
           
protected static java.lang.String LBL_BTN_OK
           
protected static java.lang.String LBL_CASE_SENSITIVE
           
protected static java.lang.String LBL_COLUMNS
           
protected static java.lang.String LBL_CURS_COLOR
           
protected static java.lang.String LBL_CUSTOM_RGB
           
protected static java.lang.String LBL_ENCODING
           
protected static java.lang.String LBL_FG_COLOR
           
protected static java.lang.String LBL_FIND
           
protected static java.lang.String LBL_FIND_BACKWARDS
           
protected static java.lang.String LBL_FONT
           
protected static java.lang.String LBL_IGN_NULL
           
protected static java.lang.String LBL_PASTE_BUTTON
           
protected static java.lang.String LBL_ROWS
           
protected static java.lang.String LBL_SCROLLBACK_BUFFER
           
protected static java.lang.String LBL_SCROLLBAR_POS
           
protected static java.lang.String LBL_SELECT_DELIM
           
protected static java.lang.String LBL_SIZE
           
protected static java.lang.String LBL_TAB_COLORS
           
protected static java.lang.String LBL_TAB_GENERAL
           
protected static java.lang.String LBL_TAB_MISC
           
protected static java.lang.String LBL_TAB_VTOPTIONS1
           
protected static java.lang.String LBL_TAB_VTOPTIONS2
           
protected static java.lang.String LBL_TERMINAL_TYPE
           
static int MENU_EDIT
           
static int MENU_FILE
           
static int MENU_SETTINGS
           
protected  java.lang.Object[][] menuItems
           
protected static int[][] menuShortCuts
           
protected static java.lang.String[][] menuTexts
           
protected static int NO_SHORTCUT
           
protected static java.lang.String[] PASTE_BUTTON
           
protected  java.io.FileOutputStream printerOut
           
protected static java.lang.String[] SCROLLBAR_POS
           
protected  TerminalWin term
           
protected static java.lang.String[] TERMINAL_TYPES
           
protected  java.lang.String titleName
           
 
Constructor Summary
protected TerminalMenuHandlerFull()
           
protected 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, java.awt.Frame frame)
          Install the standard menus on the given frame.
protected abstract  void addBasicMenusInternal(java.awt.Frame frame)
           
 boolean captureToFileDialog()
          Start capturing data to file.
 java.io.FileOutputStream chooseFileDialog(java.lang.String title)
          Shows a save dialog with the specified title.
protected  void doFind(java.lang.String findStr, boolean caseSens, boolean revFind)
           
 void endCapture()
          Stop capturing data in a file.
abstract  void findDialog(java.lang.String title)
          Show the find dialog.
static TerminalMenuHandler getInstance(java.awt.Frame frame)
          Factory class which constructs a suitable instance.
abstract  java.lang.Object getMenu(int idx)
           
protected  java.lang.String getProperty(java.lang.String key)
           
protected abstract  boolean getState(int i, int j)
           
 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.
protected abstract  void setEnabled(int i, int j, boolean v)
           
protected  void setProperty(java.lang.String key, java.lang.String value)
           
protected abstract  void setState(int i, int j, boolean v)
           
 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 startPrinter()
          Start printing data to printer.
 void stopPrinter()
          Stop sending data to printer.
 void termSettingsDialog()
          Show the terminal settings dialog with the default title.
abstract  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 com.mindbright.terminal.TerminalMenuHandler
setPopupMenu, showPopupMenu
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

term

protected TerminalWin term

titleName

protected java.lang.String titleName

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

menuTexts

protected static final java.lang.String[][] menuTexts

NO_SHORTCUT

protected static final int NO_SHORTCUT
See Also:
Constant Field Values

menuShortCuts

protected static final int[][] menuShortCuts

PASTE_BUTTON

protected static final java.lang.String[] PASTE_BUTTON

SCROLLBAR_POS

protected static final java.lang.String[] SCROLLBAR_POS

TERMINAL_TYPES

protected static final java.lang.String[] TERMINAL_TYPES

FONT_LIST

protected static final java.lang.String[] FONT_LIST

ENCODINGS

protected static final java.lang.String[] ENCODINGS

LBL_TERMINAL_TYPE

protected static final java.lang.String LBL_TERMINAL_TYPE
See Also:
Constant Field Values

LBL_COLUMNS

protected static final java.lang.String LBL_COLUMNS
See Also:
Constant Field Values

LBL_ROWS

protected static final java.lang.String LBL_ROWS
See Also:
Constant Field Values

LBL_FONT

protected static final java.lang.String LBL_FONT
See Also:
Constant Field Values

LBL_ENCODING

protected static final java.lang.String LBL_ENCODING
See Also:
Constant Field Values

LBL_SIZE

protected static final java.lang.String LBL_SIZE
See Also:
Constant Field Values

LBL_SCROLLBACK_BUFFER

protected static final java.lang.String LBL_SCROLLBACK_BUFFER
See Also:
Constant Field Values

LBL_SCROLLBAR_POS

protected static final java.lang.String LBL_SCROLLBAR_POS
See Also:
Constant Field Values

LBL_FG_COLOR

protected static final java.lang.String LBL_FG_COLOR
See Also:
Constant Field Values

LBL_BG_COLOR

protected static final java.lang.String LBL_BG_COLOR
See Also:
Constant Field Values

LBL_CURS_COLOR

protected static final java.lang.String LBL_CURS_COLOR
See Also:
Constant Field Values

LBL_PASTE_BUTTON

protected static final java.lang.String LBL_PASTE_BUTTON
See Also:
Constant Field Values

LBL_SELECT_DELIM

protected static final java.lang.String LBL_SELECT_DELIM
See Also:
Constant Field Values

LBL_IGN_NULL

protected static final java.lang.String LBL_IGN_NULL
See Also:
Constant Field Values

LBL_TAB_GENERAL

protected static final java.lang.String LBL_TAB_GENERAL
See Also:
Constant Field Values

LBL_TAB_MISC

protected static final java.lang.String LBL_TAB_MISC
See Also:
Constant Field Values

LBL_TAB_COLORS

protected static final java.lang.String LBL_TAB_COLORS
See Also:
Constant Field Values

LBL_TAB_VTOPTIONS1

protected static final java.lang.String LBL_TAB_VTOPTIONS1
See Also:
Constant Field Values

LBL_TAB_VTOPTIONS2

protected static final java.lang.String LBL_TAB_VTOPTIONS2
See Also:
Constant Field Values

LBL_CUSTOM_RGB

protected static final java.lang.String LBL_CUSTOM_RGB
See Also:
Constant Field Values

LBL_FIND

protected static final java.lang.String LBL_FIND
See Also:
Constant Field Values

LBL_CASE_SENSITIVE

protected static final java.lang.String LBL_CASE_SENSITIVE
See Also:
Constant Field Values

LBL_FIND_BACKWARDS

protected static final java.lang.String LBL_FIND_BACKWARDS
See Also:
Constant Field Values

LBL_BTN_OK

protected static final java.lang.String LBL_BTN_OK
See Also:
Constant Field Values

LBL_BTN_CANCEL

protected static final java.lang.String LBL_BTN_CANCEL
See Also:
Constant Field Values

LBL_BTN_FIND

protected static final java.lang.String LBL_BTN_FIND
See Also:
Constant Field Values

lastSearch

protected SearchContext lastSearch

menuItems

protected java.lang.Object[][] menuItems

printerOut

protected java.io.FileOutputStream printerOut
Constructor Detail

TerminalMenuHandlerFull

protected TerminalMenuHandlerFull()

TerminalMenuHandlerFull

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

setProperty

protected void setProperty(java.lang.String key,
                           java.lang.String value)

getProperty

protected java.lang.String getProperty(java.lang.String key)

getInstance

public static TerminalMenuHandler getInstance(java.awt.Frame frame)
Factory class which constructs a suitable instance. This will actually create an instance of one of the subclasses. Which subclass is used depends on wether the frame argument is actually a Frame or a JFrame

Parameters:
frame - top frame of window to handle menus of. But this is only used to select which implementation (AWT or Swing) to instantiate.
Returns:
a new instance suitable for the given frame

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

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,
                          java.awt.Frame frame)
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
frame - frame to install menus in

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 abstract 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 abstract void findDialog(java.lang.String title)
Show the find dialog.

Parameters:
title - desired title of dialog

doFind

protected void doFind(java.lang.String findStr,
                      boolean caseSens,
                      boolean revFind)

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().


setEnabled

protected abstract void setEnabled(int i,
                                   int j,
                                   boolean v)

setState

protected abstract void setState(int i,
                                 int j,
                                 boolean v)

getState

protected abstract boolean getState(int i,
                                    int j)

addBasicMenusInternal

protected abstract void addBasicMenusInternal(java.awt.Frame frame)

getMenu

public abstract java.lang.Object 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.


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()