org.peace_tools.views
Class DetailView

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.DetailView
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible
Direct Known Subclasses:
JobDetailsView, ServerJobsView

abstract class DetailView
extends javax.swing.JPanel
implements java.awt.event.ActionListener, java.lang.Runnable

A common base class shared by JobDetailsView and ServerJobsView. This is a common base class that is shared between two very similar DetailView classes, namely JobDetailsView and ServerDetailsView. The base class houses several of the commonly used features of these two detail viewer classes, such as:


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
(package private)  javax.swing.JProgressBar progressBar
          The progress bar that is placed in indeterminate mode to indicate to the user that the job data is being download.
(package private)  javax.swing.JButton refreshButton
          The refresh button that the user can click to reload the job information.
private static javax.swing.text.StyleContext sc
          A shared style context that contains the various styles that are used to layout information in the DefaultStyledDocument objects created and used by this class.
private static long serialVersionUID
          A generated serialization UID just to keep the Java compiler happy.
protected  Server server
          The server from where the details are bing displayed.
(package private)  javax.swing.JLabel timestamp
          This label is used to display the time stamp when the job information was last updated.
 
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
DetailView(java.lang.String idTitle, java.lang.String idValue, Server server)
          The constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent arg0)
          Method to intercept clicks on "Refresh" button.
protected  javax.swing.JTabbedPane createOutputDocs(javax.swing.text.DefaultStyledDocument[] outputs, java.lang.String[] TabNames)
          Helper method to create styled documents.
private static void createStyles()
          Helper method to check and create styles.
private  javax.swing.JPanel createTopPanel(java.lang.String idTitle, java.lang.String idValue)
          Helper method to create the controls displayed at the top.
protected  void runCommand(ServerSession session, java.lang.String command, java.lang.String option, java.lang.String[] streams)
          Helper method to run the job runner on the server and return outputs.
protected  void updateDocument(javax.swing.text.DefaultStyledDocument doc, java.lang.String title, java.lang.String text, java.lang.String textStyle)
          Helper method to update information in a document.
 
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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

refreshButton

javax.swing.JButton refreshButton
The refresh button that the user can click to reload the job information.


progressBar

javax.swing.JProgressBar progressBar
The progress bar that is placed in indeterminate mode to indicate to the user that the job data is being download.


timestamp

javax.swing.JLabel timestamp
This label is used to display the time stamp when the job information was last updated.


server

protected final Server server
The server from where the details are bing displayed. The server reference is set when this class is created. This entry is used to connect to the server to obtain information.


sc

private static javax.swing.text.StyleContext sc
A shared style context that contains the various styles that are used to layout information in the DefaultStyledDocument objects created and used by this class. The StyleContext is created the first time createOutputDocs() method is called


serialVersionUID

private static final long serialVersionUID
A generated serialization UID just to keep the Java compiler happy.

See Also:
Constant Field Values
Constructor Detail

DetailView

public DetailView(java.lang.String idTitle,
                  java.lang.String idValue,
                  Server server)
The constructor. The constructor initializes the various instance variables and creates the different tabs and panels.

Parameters:
idTitle - The label or title to be displayed for the ID value. This value is "Job ID" or "User ID".
idValue - The actual value to be displayed for the label. This is typically a job ID or a user ID depending on the type of the detail view.
server - The server from where the details are to be displayed.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent arg0)
Method to intercept clicks on "Refresh" button. This method is invoked whenever the user clicks on the "Refresh" button (or from the constructor). This method launches a background thread that performs the task of obtaining and populating job information from the remote server.

Note: The derived class must implement the Runnable.run() method.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
arg0 - The action event associated with a button click. This event is not really used. So you can call this method with null as parameter.

updateDocument

protected void updateDocument(javax.swing.text.DefaultStyledDocument doc,
                              java.lang.String title,
                              java.lang.String text,
                              java.lang.String textStyle)
                       throws javax.swing.text.BadLocationException
Helper method to update information in a document. This is a helper method that is used to set/update/reset information in documents. This method is specifically used to update information in tabs such as: outputs, error, and scripts tabs.

Parameters:
doc - The document whose information is to be cleared and then updated.
title - The title for the document.
text - The actual content to be displayed in the document.
textStyle - A predefined style to be set for the text.
Throws:
javax.swing.text.BadLocationException - This method simply exposes the exception generated by the document.

runCommand

protected void runCommand(ServerSession session,
                          java.lang.String command,
                          java.lang.String option,
                          java.lang.String[] streams)
                   throws java.lang.Exception
Helper method to run the job runner on the server and return outputs. This method is invoked from the run method to actually run the job runner on the remote machine. This method execute the job runner on the remote machine with the given parameter as the command line parameter.

Parameters:
session - The server session to be used to execute the command. The command should include the complete path in it without the suffix. This method adds a ".sh" or ".bat" suffix to the command before executing it.
command - The command to be run to via the specified session.
option - The command line option to be passed to the job runner script as the command line parameter. If a command does not have any options then set the option to an empty string ("").
streams - The standard output and error streams that were returned by running the job runnser script with the specified option.
Throws:
java.lang.Exception

createStyles

private static void createStyles()
Helper method to check and create styles. This helper method is invoked from the createOutputDocs() method. This method creates the set of styles that are used to display information in the styled documents associated with this class. The styles are stored in a shared style context class. The styles are created only if the style context class does not exist. Therefore calling this method over and over has no side effects. Currently this method creates the following styles: stdout, stderr, scripts, title, subtitle.


createOutputDocs

protected javax.swing.JTabbedPane createOutputDocs(javax.swing.text.DefaultStyledDocument[] outputs,
                                                   java.lang.String[] TabNames)
Helper method to create styled documents. This helper method is invoked from the constructor to create the four tabs to display various information about a given job. This method creates four StyledDocuments with custom styles tagged with the names "stdout", "stderr", "scripts", "info", "title", and "subtitle". The styled documents are placed within scroll panes and added to different tabs.

Parameters:
outputs - The array that must contain the various styled documents to be created by this method.
TabNames - The titles for the various tabs to be created by this method. The number of titles must match the list of outputs -- that is, outputs.length == TabNames.length.
Returns:
This method returns the tabbed pane that contains all the styled documents where the outputs have been added.

createTopPanel

private javax.swing.JPanel createTopPanel(java.lang.String idTitle,
                                          java.lang.String idValue)
Helper method to create the controls displayed at the top. This is a refactored method that was introduced to streamline the constructor. This helper method performs the task of laying out the controls at the top of the job details tab. The creation and layout of all the controls is done using a GridBagLayout as it seems to work out the best in this situation.

Parameters:
idTitle - The label or title to be displayed for the ID value. This value is "Job ID" or "User ID".
idValue - The actual value to be displayed for the label. This is typically a job ID or a user ID depending on the type of the detail view.
Returns:
The panel to be displayed at the top of this view with all the necessary components.