org.peace_tools.views
Class LogPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.peace_tools.views.LogPane
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, LogListener
Direct Known Subclasses:
ProgrammerLogPane, UserLogPane

public abstract class LogPane
extends javax.swing.JPanel
implements java.awt.event.ActionListener, LogListener

This is an abstract base class that provides the core features for displaying log entries. The logging system has been developed using the Model-View-Controller (MVC) pattern. This class represents the core component of the "View" that provides a graphical view of the logs using the data stored in the "Model" (the Log class). The top-level Frame that contains the views acts as the "Controller".

Specifically, this base class provides the following features:

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.lang.String CHANGE_LOG_FILE_NAME
          A string constant to ensure that the action command associated with a swing component and its action listener are consistently used without causing any issues.
private static java.lang.String CHANGE_LOG_LEVEL
          A string constant to ensure that the action command associated with a swing component and its action listener are consistently used without causing any issues.
private  javax.swing.JTextField fileNameDisplay
          This is an internal text field that is used to display the file to which the logs are being currently written.
private  int FONT_SIZE_CHANGE
          Constant to make the fonts in the controls in the tool bar a bit small because they look huge on Linux.
protected  Log log
          This instance variable holds a reference to the actual log class from which this log pane is displaying log entries.
private  javax.swing.JComboBox logLevelList
          A combo box to permit the user to set the level at which logs are to be saved by this logger.
private  javax.swing.JToggleButton saveLogsButton
          A toggle button that can be in "on" or "off" state to indicate if logs are to be saved to the specified fileName (if it is not null) or not.
private static long serialVersionUID
          A serialization UID to keep compiler happy.
private static java.lang.String TOGGLE_LOG_SAVING
          A string constant to ensure that the action command associated with a swing component and its action listener are consistently used without causing any issues.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
LogPane(Log log, boolean createLevelControl)
          A constructor for the LogPane.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          The event-callback handler for the "Choose..." button, the "SaveLogs" button, and the combo box.
private  void addLogFileNameControls(javax.swing.JToolBar toolBar)
          This is a refactored utility method that is used in the constructor to create the log file display area, the "Change..." button, and the toggle button to enable/disabling writing logs to the file.
private  void addLogLevelChanger(javax.swing.JToolBar toolBar)
          This is a utility method that is invoked just from the constructor to create a combo box that permits the user to change the log level.
protected  void finalize()
          This method overrides the default implementation in the base class to remove the log pane from the list of log listeners to receive updates.
 void logChanged(boolean logsChanged, boolean fileNameChanged, boolean levelChanged)
          This method implements the LogListener interface method to update the GUI to reflect the current state of the logger associated with this log pane.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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
 
Methods inherited from class java.awt.Container
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
 
Methods inherited from class java.awt.Component
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, hide, 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
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FONT_SIZE_CHANGE

private final int FONT_SIZE_CHANGE
Constant to make the fonts in the controls in the tool bar a bit small because they look huge on Linux.

See Also:
Constant Field Values

log

protected final Log log
This instance variable holds a reference to the actual log class from which this log pane is displaying log entries. This value is set in the constructor and is never changed during the life time of this object.


fileNameDisplay

private javax.swing.JTextField fileNameDisplay
This is an internal text field that is used to display the file to which the logs are being currently written. If the fileName is null, then this field displays "" and the toggle button to save data to the file is disabled.


saveLogsButton

private javax.swing.JToggleButton saveLogsButton
A toggle button that can be in "on" or "off" state to indicate if logs are to be saved to the specified fileName (if it is not null) or not. This button is disabled until the user chooses a valid log file name. When in the "on" state, new logs are written to the supplied file.


logLevelList

private javax.swing.JComboBox logLevelList
A combo box to permit the user to set the level at which logs are to be saved by this logger. Typically this facility is used only by the UserLog and not by the programmer log.


CHANGE_LOG_FILE_NAME

private static final java.lang.String CHANGE_LOG_FILE_NAME
A string constant to ensure that the action command associated with a swing component and its action listener are consistently used without causing any issues. Just a better programming practice and a coding convention.

See Also:
Constant Field Values

TOGGLE_LOG_SAVING

private static final java.lang.String TOGGLE_LOG_SAVING
A string constant to ensure that the action command associated with a swing component and its action listener are consistently used without causing any issues. Just a better programming practice and a coding convention.

See Also:
Constant Field Values

CHANGE_LOG_LEVEL

private static final java.lang.String CHANGE_LOG_LEVEL
A string constant to ensure that the action command associated with a swing component and its action listener are consistently used without causing any issues. Just a better programming practice and a coding convention.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
A serialization UID to keep compiler happy.

See Also:
Constant Field Values
Constructor Detail

LogPane

public LogPane(Log log,
               boolean createLevelControl)
A constructor for the LogPane. It performs the initial layout of the common elements in this panel.

Parameters:
log - The log from which entries are actually displayed by this log pane.
createLevelControl - If this flag is true, then a control to change the log level is created in the tool bar. This feature is used only by the user log.
Method Detail

addLogFileNameControls

private void addLogFileNameControls(javax.swing.JToolBar toolBar)
This is a refactored utility method that is used in the constructor to create the log file display area, the "Change..." button, and the toggle button to enable/disabling writing logs to the file.

Parameters:
toolBar - The tool bar to which the controls are to be added.

addLogLevelChanger

private void addLogLevelChanger(javax.swing.JToolBar toolBar)
This is a utility method that is invoked just from the constructor to create a combo box that permits the user to change the log level. This field is created only for the UserLog. This method was introduced to keep the code clutter in the constructor to a minimum.

Parameters:
toolBar - The tool bar to which the controls are to be added.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
The event-callback handler for the "Choose..." button, the "SaveLogs" button, and the combo box. This is an aggregate handler for all of the three controls in this class.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The action event to be processed by this method.

logChanged

public void logChanged(boolean logsChanged,
                       boolean fileNameChanged,
                       boolean levelChanged)
This method implements the LogListener interface method to update the GUI to reflect the current state of the logger associated with this log pane. Refer to the documentation in the interface for additional details.

Specified by:
logChanged in interface LogListener
Parameters:
logsChanged - This parameter is true if log entries were added or removed from the logs. Typically this is the common scenario for the call back to occur.
fileNameChanged - This parameter is true if the file name into which logs are written was changed by the user (via some view).
levelChanged - This parameter is true if the current logging level set for the log was changed by the user (via some view).

finalize

protected void finalize()
                 throws java.lang.Throwable
This method overrides the default implementation in the base class to remove the log pane from the list of log listeners to receive updates.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable