edu.neu.ccs.console
Class ConsoleWindow

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byedu.neu.ccs.gui.JPTFrame
                          extended byedu.neu.ccs.console.ConsoleWindow
All Implemented Interfaces:
Accessible, ImageObserver, JPTConstants, MenuContainer, RootPaneContainer, Serializable, SwingConstants, WindowConstants

final class ConsoleWindow
extends JPTFrame
implements JPTConstants, Serializable

A floating window containing a console text pane, with a menu providing access to functionality for the "activated" console object.

This class is used internally by the JPT and should not need to be used outside of the JPT console package.

In 2.6.0, fixed a bug in the close() method that was pointed out by Frantisek Galcik. As part of this fix, the constructor was changed from a default constructor to one that passes in the ConsoleGateway object that constructs this window.

This class no longer implements the interface ConsoleAware since that is now unnecessary.

Since:
1.0
Version:
2.6.0
See Also:
ConsoleTextPane, ConsoleGateway

Nested Class Summary
 
Nested classes inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  Hashtable actions
          Table of available actions for the GUI.
static int ERR
          Constant index for the error stream.
private  ConsoleGateway gateway
          The ConsoleGateway that constructed this ConsoleWindow.
private static int heightDeduction
          The amount to deduct from the screen height when sizing.
static int IN
          Constant index for the input stream.
private  Object inputmode_mutex
          Mutex that is used to prevent input mode changes while fireConsoleInputPerformed is activated.
private static int maxFontSize
          The maximum font size for the font menu.
private static int minFontSize
          The minimum font size for the font menu.
static int OUT
          Constant index for the output stream.
private  Action save
          The "save transcript" action.
private  File scriptFile
          The file object for an open transcript record.
private  FileOutputStream scriptStream
          The output stream for an open transcript record.
private  JScrollPane scroll
          Scroll pane housing the console pane.
private  ConsoleTextPane tablet
          Pane used for rendering console input and output.
private  Action transcript
          The "start transcript record" action.
private static int widthDeduction
          The amount to deduct from the screen width when sizing.
 
Fields inherited from class edu.neu.ccs.gui.JPTFrame
closeOperation, counter, DEFAULT_CLOSE_OPERATION, EXIT_ON_CLOSE, EXIT_ON_CLOSE_IF_LAST, screen_insets
 
Fields inherited from class javax.swing.JFrame
accessibleContext, 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 edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
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
ConsoleWindow(ConsoleGateway gateway)
          Constructs a console window.
 
Method Summary
 void close()
          Performs the housekeeping necessary to close the window, then disposes of the window resources.
 void consoleInputPerformed(String text)
          Handles input gathered from the console visualization.
 void consoleOutputPerformed(String text, int stream)
          Handles output for the text console.
private  Hashtable createActionsTable()
          Creates and returns the table of available GUI actions.
private  JMenu createEditMenu()
          Returns the edit menu.
private  JMenu createFileMenu()
          Returns the file menu.
private  JMenu createFontMenu()
          Returns the font menu.
private  JMenuBar createMenuBar()
          Creates a menubar containing the available GUI actions.
private  void fireConsoleInputPerformed(String text)
          Notifies registered listeners that an input String was gathered by console input.
private  Action getAction(String name)
          Returns the action with the given name retrieved from the table of available actions.
 Color getErrorColor()
          Returns the error color for the console.
 String getFontFamilyName()
          Returns the font family name of the console font.
 int getFontSize()
          Returns the actual font size last set by the method setFontSize after any adjustments.
 Color getInputColor()
          Returns the input color for the console.
static int getMaximumFontSize()
          Get the maximum font size that may be set for the console window.
static int getMinimumFontSize()
          Get the minimum font size that may be set for the console window.
 Color getOutputColor()
          Returns the output color for the console.
(package private)  ConsoleTextPane getTextPane()
          Returns the text pane contained by this window.
private  void readObject(ObjectInputStream in)
          Extends the default deserialization process to restore transient data members upon instantiation.
private  void save()
          Saves a transcript of the console IO session.
 void setErrorColor(Color c)
          Sets the error color for the console to the given color.
private  SimpleAction setFontAction(int size)
          Returns a menu item action to set the console to the given size.
 void setFontSize(int size)
          Sets the font size for the console to the given size.
 void setInputColor(Color c)
          Sets the input color for the console to the given color.
 void setInputMode(boolean input)
          Sets whether or not the console is in input mode to the given value.
 void setOutputColor(Color c)
          Sets the output color for the console to the given color.
private  void transcript()
          Opens a transcript record file that is updated as IO operations are performed.
 
Methods inherited from class edu.neu.ccs.gui.JPTFrame
addNotify, center, createQuickJPTFrame, createQuickJPTFrame, createQuickJPTFrame, createQuickJPTFrame, createQuickJPTFrame, createQuickJPTFrame, createQuickJPTFrame, createQuickJPTFrame, decrementCounter, dispose, frame, frame, frame, frame, frame, frame, getCounter, getDefaultCloseOperation, getJPTFrameCount, getScreenInsets, iconify, incrementCounter, installWindowAdapter, maximize, normal, setDefaultCloseOperation, setLocation, setLocation, toggle
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
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, 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, setFont, 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

OUT

public static final int OUT
Constant index for the output stream.

See Also:
Constant Field Values

ERR

public static final int ERR
Constant index for the error stream.

See Also:
Constant Field Values

IN

public static final int IN
Constant index for the input stream.

See Also:
Constant Field Values

minFontSize

private static int minFontSize
The minimum font size for the font menu.


maxFontSize

private static int maxFontSize
The maximum font size for the font menu.


widthDeduction

private static int widthDeduction
The amount to deduct from the screen width when sizing.


heightDeduction

private static int heightDeduction
The amount to deduct from the screen height when sizing.


actions

private Hashtable actions
Table of available actions for the GUI.


save

private Action save
The "save transcript" action.


transcript

private Action transcript
The "start transcript record" action.


scriptStream

private transient FileOutputStream scriptStream
The output stream for an open transcript record.


gateway

private ConsoleGateway gateway
The ConsoleGateway that constructed this ConsoleWindow.


scriptFile

private File scriptFile
The file object for an open transcript record.


scroll

private JScrollPane scroll
Scroll pane housing the console pane.


tablet

private ConsoleTextPane tablet
Pane used for rendering console input and output.


inputmode_mutex

private Object inputmode_mutex
Mutex that is used to prevent input mode changes while fireConsoleInputPerformed is activated.

Constructor Detail

ConsoleWindow

public ConsoleWindow(ConsoleGateway gateway)
Constructs a console window.

Method Detail

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Extends the default deserialization process to restore transient data members upon instantiation.

Parameters:
in - the deserialization input stream
Throws:
IOException
ClassNotFoundException

consoleInputPerformed

public void consoleInputPerformed(String text)
Handles input gathered from the console visualization.

Parameters:
text - the input text gathered from the stream

consoleOutputPerformed

public void consoleOutputPerformed(String text,
                                   int stream)
Handles output for the text console.

Parameters:
text - the output text
stream - the output stream being "written"
See Also:
ConsoleInputListener

setInputMode

public void setInputMode(boolean input)

Sets whether or not the console is in input mode to the given value.

If the console is set to input mode, the console window is set to normal in case it had been iconified and the output streams are temporarily blocked.

Parameters:
input - whether or not the console is in input mode

setInputColor

public void setInputColor(Color c)
Sets the input color for the console to the given color.

Parameters:
c - the desired input color
See Also:
getInputColor()

getInputColor

public Color getInputColor()
Returns the input color for the console.

See Also:
setInputColor(Color)

setOutputColor

public void setOutputColor(Color c)
Sets the output color for the console to the given color.

Parameters:
c - the desired output color
See Also:
getOutputColor()

getOutputColor

public Color getOutputColor()
Returns the output color for the console.

See Also:
setOutputColor(Color)

setErrorColor

public void setErrorColor(Color c)
Sets the error color for the console to the given color.

Parameters:
c - the desired error color
See Also:
getErrorColor()

getErrorColor

public Color getErrorColor()
Returns the error color for the console.

See Also:
setErrorColor(Color)

getFontFamilyName

public final String getFontFamilyName()
Returns the font family name of the console font.


getFontSize

public final int getFontSize()

Returns the actual font size last set by the method setFontSize after any adjustments.


getMinimumFontSize

public static final int getMinimumFontSize()
Get the minimum font size that may be set for the console window.


getMaximumFontSize

public static final int getMaximumFontSize()
Get the maximum font size that may be set for the console window.


setFontSize

public final void setFontSize(int size)

Sets the font size for the console to the given size.

Point sizes smaller than 10 are set to 10 points.

Point sizes larger than 72 are set to 72 points.

Keep in mind that very large font sizes will lead to very few characters per line in the console window.

Parameters:
size - the desired font size

close

public void close()
Performs the housekeeping necessary to close the window, then disposes of the window resources.


getTextPane

ConsoleTextPane getTextPane()
Returns the text pane contained by this window.


fireConsoleInputPerformed

private void fireConsoleInputPerformed(String text)
Notifies registered listeners that an input String was gathered by console input.

Parameters:
text - the gathered input String
See Also:
ConsoleInputListener

createActionsTable

private Hashtable createActionsTable()
Creates and returns the table of available GUI actions.


getAction

private Action getAction(String name)
Returns the action with the given name retrieved from the table of available actions.

Parameters:
name - the name of the action to retrieve

createMenuBar

private JMenuBar createMenuBar()
Creates a menubar containing the available GUI actions.


createFileMenu

private JMenu createFileMenu()
Returns the file menu.


createEditMenu

private JMenu createEditMenu()
Returns the edit menu.


createFontMenu

private JMenu createFontMenu()
Returns the font menu.


setFontAction

private SimpleAction setFontAction(int size)
Returns a menu item action to set the console to the given size.

Parameters:
size - the desired font size for the font menu

save

private void save()
Saves a transcript of the console IO session.

See Also:
createMenuBar()

transcript

private void transcript()
Opens a transcript record file that is updated as IO operations are performed.

See Also:
createMenuBar()