GWTApplication.client
Class SearchResultFormatter

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by GWTApplication.client.FaultDBForm
                  extended by GWTApplication.client.SearchResultFormatter
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, FaultListener

 class SearchResultFormatter
extends FaultDBForm
implements FaultListener

This class will be used to format the results of a search query and display them in a HTML table. Each of the faults will be displayed as a row in the table and associated with each row will be a panel which expands out to provide the full details of the fault to the user which includes all of the comments, the solution and the workaround which is associated with the fault.

This class is central to the displaying of the results of search queries throughout the system. It is used by the QuickViewReport class and the SearchForm class in order to display the results of the SQL queries which extract from the database faults pertinent to them specific views on the fault information.

Version:
$Id: SearchResultFormatter.java,v 1.17 2007/08/20 14:48:14 cb Exp $
Author:
Craige Bevil
See Also:
QuickViewReport, SearchForm

Nested Class Summary
(package private)  class SearchResultFormatter.CloseFaultClickListener
          An inner class which will allow the user to close down a fault.
private  class SearchResultFormatter.DisplayFullFault
          Inner class which will be used to display the full fault history as the user clicks on a disclosure widget header and opens it for the first time.
private  class SearchResultFormatter.DisplaySearchResultsIncrementalCommand
          This is an incremental command which is used to display the search results so that the browser does not simply lock up whilst the results are being displayed.
(package private)  class SearchResultFormatter.FaultLinkClickListener
          An inner class which is called when the user presses the link fault link which will result in a dialog being displayed within which the user can enter the id of a fault to link this fault to.
(package private)  class SearchResultFormatter.GetEmailUpdateClickListener
          An inner class which is called when the user presses the link which allows him to receive updates when the fault is updated in the database
(package private)  class SearchResultFormatter.ModifyFaultClickListener
          An inner class which is called when the user presses the modification link and will result in the modification panel being called and being set up with the details of the fault which has been selected being available to be modified.
(package private)  class SearchResultFormatter.PrintFaultClickListener
          Inner class which is used to allow the user to print out a fault should he wish to
 
Field Summary
private  boolean displayNewFaults
          Whether to add new faults which are entered into the database after this search result displayer has been initialised
private  java.util.HashMap faultDisplayers
          This is a has of all of the fault displayers which are associated with the disclosure panels
private  java.util.HashMap faultTableRowMapping
          This is a hashmap which contains for each faults, which row in the table that they reside in.
private  FaultUpdateMonitor faultUpdateMonitor
          Used to check the database intermittingly and report back to listeners which faults they are displaying have changed so that they may update their view accordingly.
private  boolean hasAdminPriviledge
          Whether the user has the privilege to perform admin type functions
(package private) static int HEADOFTABLE
          Indicates the first row in the search result table
private  int HighestDefectNoInTable
          This is the fault id with the highest defect number which is displayed in the table
(package private)  InternationalizationConstants internationalizationConstants
          This class will be used for internationalization so that we can flick between the locales of English and Spanish.
private  com.google.gwt.user.client.ui.TabPanel MainTabPanel
          This is the main tab panel for the application.
private  ModifyFormPanel ModifyFormPage
          This panel will be used to allow the user to modify the details of a fault
private  com.google.gwt.user.client.ui.FlexTable ResultsTable
          This is the widget into which the search results will be displayed.
private  com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter resultsTableCellFormatter
          This is used to format the main results table
private  com.google.gwt.user.client.ui.HTMLTable.RowFormatter resultsTableRowFormatter
          This is used to format the main results table
 RefreshSearchResultsListener searchResultUpdater
          This is an object which can be used to refresh the details of this search view.
private  FaultServiceAsync svc
          This is the service which will be used to access the servlet which is running in the tomcat container
private static int UNKNOWN
          A constant which is used to indicate something is UNKNOWN.
private  AuthenticationDetails UserAuthentication
          Contains the authentication data which is associated with the current user
private  boolean userCanModifyFaults
          Whether this user can modify the details of a fault if his priviledge level is high enough.
 
Fields inherited from class GWTApplication.client.FaultDBForm
busyIndicator, NOLENGTHCHECK, PrinterList
 
Constructor Summary
SearchResultFormatter(com.google.gwt.user.client.ui.FlexTable resultsTable, ModifyFormPanel modifyFormPage, AuthenticationDetails UserAuthentication, FaultServiceAsync svc, InternationalizationConstants internationalizationConstants, FaultUpdateMonitor faultUpdateMonitor)
          Constructor for the class
 
Method Summary
 void clearResultTable()
          This method will be used to clear out any existing results from the search result table
 void displaySearchResults(java.util.ArrayList searchResults, com.google.gwt.user.client.ui.TabPanel MainTabPanel)
          Formats the results of the search query and displays them in the table which was passed into the method.
 void faultsChanged(java.util.ArrayList faultsChanged)
          This is an obligation of the FaultListener interface and is called whenever one of the faults in the table that we are displaying is changed in the database and then we update the fault in the result displayer.
private  void putFaultIntoResultsTable(Fault fault, int rowToModify, boolean updateExistingRow, boolean insertAtHeadOfResults)
          Used to insert the details of a fault into results table at the row specified.
 void setDisclosurePanelState(boolean openAll)
          Will be used to set the state of the all of the disclosure panel states in the table to either open or closed.
 void setdisplayNewFaults(boolean displayNewFaults)
          Allows the caller to specify if whether to update search results when new faults are created.
 void setResultsTable(com.google.gwt.user.client.ui.FlexTable ResultsTable)
          This will be used to set the table into which the results will be displayed
 
Methods inherited from class GWTApplication.client.FaultDBForm
createEmailLink, fillListBoxWithCurrentInstruments, fillListBoxWithDutyTechnicians, fillListBoxWithFaultType, fillListBoxWithInstruments, fillListBoxWithSeverity, fillListBoxWithSites, fillListBoxWithStaffMembers, fillListBoxWithStates, fillListBoxWithSupportAstronomers, fillListBoxWithSystems, fillListBoxWithTelescopeOperators, getCurrentDate, getCurrentTime, getFullUserNameFromEmailAddress, selectDefaultListOption, setSelectedItemInListbox, stringContainsText, verifyDateFormat, verifyDateNotInFuture, verifyText, verifyTimeFormat
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
getElement, getWidget, initWidget, isAttached, onAttach, onDetach, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, onBrowserEvent, onLoad, onUnload, removeFromParent, setElement
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

faultUpdateMonitor

private FaultUpdateMonitor faultUpdateMonitor
Used to check the database intermittingly and report back to listeners which faults they are displaying have changed so that they may update their view accordingly.


searchResultUpdater

public RefreshSearchResultsListener searchResultUpdater
This is an object which can be used to refresh the details of this search view. The search formatter only displays the details of a search query, it does not know about how the results were deduced in the first instance. This object will allow the search result formatter to request that it's contents be refreshed.


UNKNOWN

private static final int UNKNOWN
A constant which is used to indicate something is UNKNOWN.

See Also:
Constant Field Values

HighestDefectNoInTable

private int HighestDefectNoInTable
This is the fault id with the highest defect number which is displayed in the table


HEADOFTABLE

static final int HEADOFTABLE
Indicates the first row in the search result table

See Also:
Constant Field Values

displayNewFaults

private boolean displayNewFaults
Whether to add new faults which are entered into the database after this search result displayer has been initialised


hasAdminPriviledge

private final boolean hasAdminPriviledge
Whether the user has the privilege to perform admin type functions


faultDisplayers

private final java.util.HashMap faultDisplayers
This is a has of all of the fault displayers which are associated with the disclosure panels


userCanModifyFaults

private boolean userCanModifyFaults
Whether this user can modify the details of a fault if his priviledge level is high enough.


resultsTableCellFormatter

private com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter resultsTableCellFormatter
This is used to format the main results table


resultsTableRowFormatter

private com.google.gwt.user.client.ui.HTMLTable.RowFormatter resultsTableRowFormatter
This is used to format the main results table


faultTableRowMapping

private java.util.HashMap faultTableRowMapping
This is a hashmap which contains for each faults, which row in the table that they reside in. This is used when updating the details of a fault should the fault be updated in the background by another user


svc

private final FaultServiceAsync svc
This is the service which will be used to access the servlet which is running in the tomcat container


UserAuthentication

private AuthenticationDetails UserAuthentication
Contains the authentication data which is associated with the current user


MainTabPanel

private com.google.gwt.user.client.ui.TabPanel MainTabPanel
This is the main tab panel for the application. We need this so that if the user clicks on the modify fault link we can select the entry in the tab panel which corresponds to the update fault page.


ModifyFormPage

private final ModifyFormPanel ModifyFormPage
This panel will be used to allow the user to modify the details of a fault


ResultsTable

private com.google.gwt.user.client.ui.FlexTable ResultsTable
This is the widget into which the search results will be displayed.


internationalizationConstants

InternationalizationConstants internationalizationConstants
This class will be used for internationalization so that we can flick between the locales of English and Spanish.

Constructor Detail

SearchResultFormatter

SearchResultFormatter(com.google.gwt.user.client.ui.FlexTable resultsTable,
                      ModifyFormPanel modifyFormPage,
                      AuthenticationDetails UserAuthentication,
                      FaultServiceAsync svc,
                      InternationalizationConstants internationalizationConstants,
                      FaultUpdateMonitor faultUpdateMonitor)
Constructor for the class

Parameters:
resultsTable - This is a FlexTable widget into which the results of the search will be displayed.
modifyFormPage - This is the page which can be used to modify the details of a fault.
UserAuthentication - Login credentials of the person that is using the system.
svc - This is object which will be used to execute operations on the tomcat servlet.
Method Detail

displaySearchResults

public void displaySearchResults(java.util.ArrayList searchResults,
                                 com.google.gwt.user.client.ui.TabPanel MainTabPanel)
Formats the results of the search query and displays them in the table which was passed into the method.

Parameters:
searchResults - This is a collection of the type Fault which will contain all of the data from the search query.
MainTabPanel - This is the main tab panel

putFaultIntoResultsTable

private void putFaultIntoResultsTable(Fault fault,
                                      int rowToModify,
                                      boolean updateExistingRow,
                                      boolean insertAtHeadOfResults)
Used to insert the details of a fault into results table at the row specified.

Parameters:
fault - The fault to insert into the table.
rowToModify - The row number in the ttable which are to modify should updateExistingRow be set to true.
updateExistingRow - True if we are to update an existing row in the table.
insertAtHeadOfResults - True if to insert the fault at the head of the table. Used for inserting new faults which are added after the initial search page is created.

setResultsTable

public void setResultsTable(com.google.gwt.user.client.ui.FlexTable ResultsTable)
This will be used to set the table into which the results will be displayed

Parameters:
ResultsTable - The flex table into which to pack the results

setDisclosurePanelState

public void setDisclosurePanelState(boolean openAll)
Will be used to set the state of the all of the disclosure panel states in the table to either open or closed.

Parameters:
openAll - Whether all of the faults should be opened

faultsChanged

public void faultsChanged(java.util.ArrayList faultsChanged)
This is an obligation of the FaultListener interface and is called whenever one of the faults in the table that we are displaying is changed in the database and then we update the fault in the result displayer.

Specified by:
faultsChanged in interface FaultListener
Parameters:
faultsChanged - This is an array of type Fault which contains the details of the faults which have changed in the database.
See Also:
FaultListener, FaultUpdateMonitor

setdisplayNewFaults

public void setdisplayNewFaults(boolean displayNewFaults)
Allows the caller to specify if whether to update search results when new faults are created. We don't do this in the case of the more selective search results (such as the outstanding faults) as that needs specialist SQL.

Parameters:
displayNewFaults - True if to add new faults to the table.

clearResultTable

public void clearResultTable()
This method will be used to clear out any existing results from the search result table