org.peace_tools.core
Class ViewFactory

java.lang.Object
  extended by org.peace_tools.core.ViewFactory
All Implemented Interfaces:
DnDTabListener
Direct Known Subclasses:
MainFrame.DefaultViewFactory

public abstract class ViewFactory
extends java.lang.Object
implements DnDTabListener

A factory to help with creation of views. This class provides a convenience mechanism to create and add a view to a given main frame. This class is a base class that is not meant to be instantiated. Instead ask MainFrame for a valid ViewFactory by calling mainFrame.getViewFactory() method.


Nested Class Summary
static class ViewFactory.ViewType
          Set of enumeration values to identify the different types of views that this factory can create.
 
Field Summary
private static java.lang.String CANT_MAKE_VIEW
          A static message that is to be displayed if a view could not be opened.
private  MainFrame mainFrame
          A convenient reference to the main frame that logically owns this view factory.
private  java.util.HashMap<ViewFactory.ViewType,DnDTabPos> staticViewPos
          The last saved positions for the various static views.
private  java.util.HashMap<ViewFactory.ViewType,javax.swing.JComponent> staticViews
          The list of static views associated with any main frame.
private static javax.swing.Icon[] TabIcons
          The array of icons that are displayed in a the tabs along with titles for each view.
private  java.util.HashMap<java.lang.String,java.util.ArrayList<javax.swing.JComponent>> views
          A hash map that maintains the list of views that are currently visible in this frame.
 
Constructor Summary
protected ViewFactory(MainFrame mf)
          The constructor.
 
Method Summary
private  void addView(javax.swing.JComponent view, java.lang.String dataFileName, ViewFactory.ViewType viewType)
          Utility method to add a newly created view to display and internal tables.
private  javax.swing.JComponent createDefaultView(java.lang.String estFileName, java.lang.String dataFileName, ViewFactory.ViewType viewType, java.lang.Object wsEntry)
          Helper method to create a default view for a given data type.
private  void createLogViews()
          This is a helper method that invoked from the constructor to create the programmer and user log panes.
 void createOverlapView(MSTClusterData cluster)
          Method to create a overlap view for a given entry.
private  void createStandardViews()
          This is a helper method that invoked from the constructor to create the standard views (tabs that display various information from the work space) .
 void createStaticViews()
          Method to create the standard set of static views.
 void createSummaryView(MSTClusterData cluster)
          Method to create a graph type of view for a given entry.
private  javax.swing.JComponent createTextView(java.lang.String fileName)
          Helper method to create a textual view for a given file.
 void createView(Job job, Server server)
          Method to create a graph type of view for a given entry.
 void createView(java.lang.Object wsEntry, boolean duplicate, boolean textView)
          Method to ease creation of a specific view.
 void createView(Server server, java.lang.String userID)
          Method to create a server job list view.
 void createView(java.lang.String dataFileName, java.lang.String estFileName, ViewFactory.ViewType viewType, boolean duplicate, boolean textView, java.lang.Object wsEntry)
          Method to create a specific view.
 void emphasize(javax.swing.JComponent component)
          A helper method to create thread to make a tab blink to emphasize its presence.
 void showStaticView(ViewFactory.ViewType view)
          Method to display a static view that is currently not visible.
 void tabDeleted(java.awt.Component component)
          Method to intercept events generated by DnDTabbedPane to report removal of views.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainFrame

private final MainFrame mainFrame
A convenient reference to the main frame that logically owns this view factory. This reference is used to add views to appropriate locations in the main frame.


CANT_MAKE_VIEW

private static final java.lang.String CANT_MAKE_VIEW
A static message that is to be displayed if a view could not be opened.

See Also:
Constant Field Values

views

private java.util.HashMap<java.lang.String,java.util.ArrayList<javax.swing.JComponent>> views
A hash map that maintains the list of views that are currently visible in this frame. Entries are added and removed by the ViewFactory class.


staticViews

private java.util.HashMap<ViewFactory.ViewType,javax.swing.JComponent> staticViews
The list of static views associated with any main frame. The static views are created only once for a given main frame. Each view is represented by a unique enumeration value.


staticViewPos

private java.util.HashMap<ViewFactory.ViewType,DnDTabPos> staticViewPos
The last saved positions for the various static views. This hash map saves the last saved positions for the various static views. This enables restoring static views (assuming they are visible) at appropriate positions.


TabIcons

private static final javax.swing.Icon[] TabIcons
The array of icons that are displayed in a the tabs along with titles for each view. The icons are arranged in the same order in which the views are enumerated so that the ordinal values of enumerations can be used to obtain icons for tab titles.

Constructor Detail

ViewFactory

protected ViewFactory(MainFrame mf)
The constructor. The constructor merely saves the reference to the owning main frame for future reference.

Parameters:
mf - The main frame that logically owns this view factory.
Method Detail

createStaticViews

public void createStaticViews()
Method to create the standard set of static views. This is an interface method that is used to create the set of static views associated with this view factory. This method is typically called only once from the main method. However, calling this method multiple times on the same view factory has no major side effects.


showStaticView

public void showStaticView(ViewFactory.ViewType view)
Method to display a static view that is currently not visible. This method can be used to re-display the view that is currently not visible. If a view is already visible then this method does not have any side effect.

Parameters:
view - The type of view to be displayed by this method.

createLogViews

private void createLogViews()
This is a helper method that invoked from the constructor to create the programmer and user log panes. This method was introduced to keep the code clutter down in the constructor.


createStandardViews

private void createStandardViews()
This is a helper method that invoked from the constructor to create the standard views (tabs that display various information from the work space) . This method was mainly introduced to keep the code clutter down in the constructor.


createDefaultView

private javax.swing.JComponent createDefaultView(java.lang.String estFileName,
                                                 java.lang.String dataFileName,
                                                 ViewFactory.ViewType viewType,
                                                 java.lang.Object wsEntry)
                                          throws java.lang.Exception
Helper method to create a default view for a given data type.

Parameters:
estFileName - The EST file name from where the FASTA data is to be loaded.
dataFileName - The name of the file where the additional data for this view is stored.
viewType - The type of view to be displayed.
wsEntry - The workspace entry object for which the default view is to be created. This object is used by the views to reference the workspace entry as needed. Note that even though the workspace entry is passed in as an Object, it must be correspond to the type of view being created.
Returns:
A valid view if successfully created.
Throws:
java.lang.Exception - This method throws various exceptions when errors occur during view creation.

createTextView

private javax.swing.JComponent createTextView(java.lang.String fileName)
                                       throws java.lang.Exception
Helper method to create a textual view for a given file.

Parameters:
fileName - The text file whose contents is to be loaded and displayed
Returns:
A valid view if successfully created.
Throws:
java.lang.Exception - This method throws various exceptions when errors occur during view creation.

createSummaryView

public void createSummaryView(MSTClusterData cluster)
Method to create a graph type of view for a given entry. This method performs the actual loading process via a background thread so that the GUI does not become unresponsive as the data is loaded.

Parameters:
cluster - The MSTClusterDAta object for which a graphical summary view is to be created and added to the viewing area.

createOverlapView

public void createOverlapView(MSTClusterData cluster)
Method to create a overlap view for a given entry. This method performs the actual loading process via a background thread so that the GUI does not become unresponsive as the data is loaded.

Parameters:
cluster - The MSTClusterDAta object for which a graphical overlap view is to be created and added to the viewing area.

createView

public void createView(Job job,
                       Server server)
Method to create a graph type of view for a given entry. This method performs the actual loading process via a background thread so that the GUI does not become unresponsive as the data is loaded.


createView

public void createView(Server server,
                       java.lang.String userID)
Method to create a server job list view. This method performs the actual task of creating a server job list view. This method is used from the ServerMenuHelper.

Parameters:
server - The server whose jobs/processes are to be listed.
userID - The ID of the user whose jobs are to be listed. This parameter is optional and can be null.

addView

private void addView(javax.swing.JComponent view,
                     java.lang.String dataFileName,
                     ViewFactory.ViewType viewType)
Utility method to add a newly created view to display and internal tables. This is a refactored utility method that is used to add a view to the internal tables and to the main frame.

Parameters:
view - The newly created view to be added.
dataFileName - The data file from where the view was loaded.
viewType - The type of view that has been created.

createView

public void createView(java.lang.Object wsEntry,
                       boolean duplicate,
                       boolean textView)
Method to ease creation of a specific view. This method is a convenience method that can be used to automatically detect the type of object and appropriately use the default view type for the specified object. Note that this method currently handles only the following types of objects: DataSet (representing a FASTA file), MSTData (representing an MST file), and MSTClusterData (representing a cluster data file).

Parameters:
wsEntry - The work space entry for which a view must be created (if one does not exist).
duplicate - If this flag is true, then a duplicate view is created even if a view already exists.
textView - If this flag is true, then a textual view of the data is created.

createView

public void createView(java.lang.String dataFileName,
                       java.lang.String estFileName,
                       ViewFactory.ViewType viewType,
                       boolean duplicate,
                       boolean textView,
                       java.lang.Object wsEntry)
Method to create a specific view. This method is the preferred approach to creating and adding non-static views to the MainFrame. A view is a specific display of a given data file. This method creates and adds a view as needed.

Parameters:
dataFileName - The full path to the data file that is to be loaded and displayed in the specified view.
estFileName - An optional EST (FASTA) file that is associated with the data file. The EST file name is typically used to obtain additional information to be displayed to the user.
viewType - The type of view to be created. This value must be from one of the predefined enumerations. Note that the view type and the type of file must be coordinated with each other.
duplicate - If this flag is true, then a duplicate view is created even if a view already exists.
textView - If this flag is true, then a textual view of the data is created.
wsEntry - The workspace entry for which the view is to be created. This value is set for some of the views (like: ClusterTreeTableView and ClusterSummaryView).

emphasize

public void emphasize(javax.swing.JComponent component)
A helper method to create thread to make a tab blink to emphasize its presence. This method is called when a view needs to be emphasized to draw the attention of the user. This method creates a new daemon thread that changes the background of the component frequently drawing the attention of the user.

Parameters:
component - The component to which the user's attention is to be drawn.

tabDeleted

public void tabDeleted(java.awt.Component component)
Method to intercept events generated by DnDTabbedPane to report removal of views. This method removes the view from the list of views in the views hash map. This method is called from the DnDTabbedPane

Specified by:
tabDeleted in interface DnDTabListener
Parameters:
component - The component to be removed from the set of views managed by this factory..