#!/usr/share/sysman/bin/sysmansh
# 
# @DEC_COPYRIGHT@
#
# HISTORY
# $Log: evmviewer,v $
# Revision 1.1.1.1  2003/01/23 18:04:47  ajay
# Initial submit to CVS.
#
#
# Revision 1.1.17.3  2000/01/28  20:22:37  Anthony_Hoffman
# 	qars 72189 and 76738
#
# Revision 1.1.2.39  2000/01/27  20:49:11  Anthony_Hoffman
# 	add focus support, fix greying out in filter box
#
# Revision 1.1.2.38  1999/12/16  18:29:51  Anthony_Hoffman
# 	qar 71423
#
# Revision 1.1.2.37  1999/10/22  15:13:35  Anthony_Hoffman
# 	fix qars 73011, 73631 - remove dummy field, add left padding to button
#
# Revision 1.1.2.36  1999/10/12  20:38:12  Anthony_Hoffman
# 	change ok button to exit
#
# Revision 1.1.2.35  1998/12/07  19:32:22  Anthony_Hoffman
# 	fix qar 66363 - add double click to get event details
# 	[1998/12/07  19:31:47  Anthony_Hoffman]
#
# Revision 1.1.2.34  1998/10/27  20:04:35  Girish_Malangi
# 	-Added Refresh button on the main dialog. The "Refresh" option
# 	 has been moved from the "More Options" dialog to the main
# 	 dialog.
# 	[1998/10/27  19:04:46  Girish_Malangi]
# 
# Revision 1.1.2.33  1998/10/13  19:28:03  Girish_Malangi
# 	-renamed button Show to Customize.
# 	-removed the Number of Events to display dialog
# 	 and moved the same input to the Customize
# 	 dialog.
# 	-changed the Filter dialog according to
# 	 usability reports.
# 	[1998/10/13  19:19:04  Girish_Malangi]
# 
# Revision 1.1.2.32  1998/09/14  20:19:33  Girish_Malangi
# 	-FROM THIS VERSION ONWARDS THE MCL COMPONENT HAS BEEN
# 	 DEFUNCTED.
# 	-Removed paging control widgets.
# 	-No dataID's associated with any of the widgets.
# 	-Added dialog to set the number of events displayed
# 	 in the listbox.
# 	-Added widgets in wSource to enable retrieval of
# 	 events from a file.
# 	[1998/09/14  20:08:46  Girish_Malangi]
# 
# Revision 1.1.2.30  1998/07/14  21:23:07  Girish_Malangi
# 	-removed repeat count widgets since we will not be
# 	 using them anymore.
# 	-moved suitlet initialization code to callback
# 	 file.
# 	[1998/07/14  21:02:47  Girish_Malangi]
# 
# Revision 1.1.2.29  1998/05/20  22:14:13  Girish_Malangi
# 	-removed cleanup proc and signal catch statement. SUIT now
# 	 provides a proc which catches interrupt signals.
# 	-added code to catch invalid host names which are passed
# 	 through command line using the -host option.
# 	[1998/05/20  22:01:41  Girish_Malangi]
# 
# Revision 1.1.2.28  1998/04/23  21:41:22  Girish_Malangi
# 	*** empty log message ***
# 	[1998/04/23  21:40:12  Girish_Malangi]
# 
# 	-put in code so that the MCLDIR is set to the evmviewer
# 	 directory. This is so since the evmview.mcl file has now
# 	 been moved to the evmviewer directory from the mcl
# 	 directory.
# 	-changed the number of events per page to 100
# 	 for the CDE version. The number of events per page for
# 	 the curses version has been retained at 10.
# 	-removed the Apply buttons in the save dialogs i.e.
# 	 in the "Details Save" dialog box and "Save this page of
# 	 event summaries" dialog box.
# 	[1998/04/23  15:41:08  Girish_Malangi]
# 
# Revision 1.1.2.27  1998/04/10  14:19:23  Girish_Malangi
# 	*** empty log message ***
# 	[1998/04/10  14:17:54  Girish_Malangi]
# 
# Revision 1.1.2.26  1998/04/10  00:38:55  Girish_Malangi
# 	-removed the exiting flag since it is no longer needed after the
# 	 new implementation of initializing the filter attributes.
# 	[1998/04/10  00:38:11  Girish_Malangi]
# 
# 	-removed the call to set_default_values from the cleanup proc
# 	 since the initalization of the Filter attributes to default and
# 	 setting the source to local is now done during startup.
# 	[1998/04/04  00:16:02  Girish_Malangi]
# 
# Revision 1.1.2.25  1998/03/31  20:27:45  Girish_Malangi
# 	-moved the signal handler and the cleanup procedure from callback
# 	 file to evmviewer file. This is so that the cleanup procedure
# 	 is read before the first tmp files are created.
# 	-removed the Advanced Filter button since a separate Advanced Filter
# 	 dialog has now been implemented for Advanced Filter strings.
# 	-added windows for the Advanced Filter and associated dialogs.
# 	[1998/03/31  19:08:16  Girish_Malangi]
# 
# Revision 1.1.2.24  1998/03/16  22:47:26  Jovanna_Ignatowicz
# 	human factors changes in wOptions buttons
# 	[1998/03/16  22:45:54  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.23  1998/03/16  22:15:30  Girish_Malangi
# 	*** empty log message ***
# 	[1998/03/16  22:14:06  Girish_Malangi]
# 
# 		-changed the Filter Window widgets layout
# 		-moved the signal handler to the callback file
# 		-changed the widget's layout in the wSource
# 		-changed the size of wSource, wSummPrint and wSummSave
# 	[1998/03/13  21:00:31  Girish_Malangi]
# 
# Revision 1.1.2.22  1998/02/21  19:27:12  Jovanna_Ignatowicz
# 		-changed SummaryListLabel to Text widget only
# 	        -added apply button to wOptions dialog
# 	[1998/02/21  19:19:56  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.21  1998/01/30  20:00:28  Jovanna_Ignatowicz
# 		-QAR 57965 set SummaryNLines to 10 for the lowest resolution
# 	                possible
# 	        -QAR 57093 added a signal handler
# 	        -moved the Filters button to the main window
# 	        -added advanced filter field
# 	[1998/01/29  17:36:30  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.20  1998/01/08  20:30:57  Jovanna_Ignatowicz
# 		-QAR 57139 added code to check if there is no start-up
# 	                   filter or if no events are found (then
# 			   alert the user and create a filter if there
# 			   isn't one)
# 	[1998/01/08  20:19:08  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.19  1998/01/08  17:12:09  Jovanna_Ignatowicz
# 		-QAR 57121- added widgets to and reformatted wFilter
# 	[1998/01/08  17:04:27  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.18  1997/12/11  18:24:20  Jovanna_Ignatowicz
# 		-QAR 57095- (priority filter single value not supported)
# 		  -added widgets in wFilter
# 	[1997/12/11  18:17:08  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.17  1997/11/30  17:34:16  Jovanna_Ignatowicz
# 	QAR 56241- added save options dialog, messages and callbacks for summary and details save
# 	[1997/11/30  17:10:10  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.16  1997/10/29  20:02:49  Jovanna_Ignatowicz
# 		-QAR 56442  -changed # of lines displayed in details dialog from
# 	                     40 to 20
# 	        -QAR 56441  -added a label for the event summary listbox that
# 	                     states which host the events are retrieved from
# 	[1997/10/29  19:50:31  Jovanna_Ignatowicz]
# 
# 		-QAR 56300 host unknown is default
# 	           -added an enum for local and remote host
# 	             where local is the default
# 	        -QAR 56363 need wmclose
# 	           -added wmclose where missing in the dialogs
# 	[1997/10/27  17:49:19  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.15  1997/09/25  21:18:47  Jovanna_Ignatowicz
# 		-added a padTop to the "go to" widgets to line them up
# 	        -removed apply button from options dialog
# 		-changed the filter dialog layout
# 	[1997/09/25  21:18:00  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.14  1997/09/22  14:56:49  Jovanna_Ignatowicz
# 		-reduced size of details dialog to fit all widgets
# 		-added "go to page" dialog
# 		-reordered page and details next, prev, first & last buttons
# 		-removed otpions button and added list
# 	[1997/09/17  15:22:02  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.13  1997/08/22  18:51:00  Jovanna_Ignatowicz
# 		-human factors: added "first event" and "last event" buttons to
# 		   Event details dialog
# 	[1997/08/22  15:54:36  Jovanna_Ignatowicz]
# 
# 		-human factors: created Options button in main dialog and
# 	          options sub dialog. Moved funtions buttons (filters, host,
# 		  print, refresh, save) to subdialog
# 	[1997/08/15  17:51:49  Jovanna_Ignatowicz]
# 
# 		moved the page text label to the top of the list
# 		moved the page first, next, last, prev buttons to row
# 	           under the list (left all other buttons in the next row)
# 	        all changes result of usability review
# 	[1997/08/14  20:19:45  Jovanna_Ignatowicz]
# 
# Revision 1.1.2.12  1997/08/05  19:11:11  John_Hainsworth
# 	Incorporated suggestions from code review.
# 	[1997/08/05  19:08:33  John_Hainsworth]
# 
# Revision 1.1.2.11  1997/07/25  21:34:45  John_Hainsworth
# 	Removed default button from filter dialog box.
# 	Combined 2 page status fields into one non-editable text field.
# 	[1997/07/25  21:32:39  John_Hainsworth]
# 
# Revision 1.1.2.10  1997/07/21  21:42:33  John_Hainsworth
# 	Added file append/write options on save.
# 	[1997/07/21  21:41:49  John_Hainsworth]
# 
# Revision 1.1.2.9  1997/07/18  22:45:55  John_Hainsworth
# 	Added UI for page number and page count.
# 	[1997/07/18  22:45:08  John_Hainsworth]
# 
# Revision 1.1.2.8  1997/07/11  19:37:41  John_Hainsworth
# 	Changed wItem widget names to match those used by evmsort & evmshow.
# 	[1997/07/11  19:36:53  John_Hainsworth]
# 
# Revision 1.1.2.7  1997/07/07  15:17:58  John_Hainsworth
# 	Changed dIsAscending to dSortIsAscending.
# 	Added repeat count.
# 	Added manual padding to the Across widget in the wSummary window.
# 	[1997/07/07  15:14:46  John_Hainsworth]
# 
# Revision 1.1.2.6  1997/06/25  15:20:27  John_Hainsworth
# 	Disable sorting in sort-keys list.
# 	[1997/06/25  15:18:58  John_Hainsworth]
# 
# Revision 1.1.2.5  1997/06/18  18:34:57  John_Hainsworth
# 	Added default buttons.
# 	[1997/06/18  18:30:18  John_Hainsworth]
# 
# Revision 1.1.2.4  1997/05/28  22:18:49  John_Hainsworth
# 	Changed wOk,wCancel,wApply,wHelp --> ok,cancel,apply,help
# 	[1997/05/23  18:53:19  John_Hainsworth]
# 
# Revision 1.1.2.3  1997/05/19  20:50:53  John_Hainsworth
# 	Set list box height to 10 for char cell.
# 	[1997/05/19  20:48:34  John_Hainsworth]
# 
# Revision 1.1.2.2  1997/05/19  15:38:49  John_Hainsworth
# 	Created.
# 	[1997/05/19  15:38:10  John_Hainsworth]
# 
# $EndLog$
# 
# @(#)$RCSfile: evmviewer,v $ $Revision: 1.1.1.1 $ (DEC) $Date: 2003/01/23 18:04:47 $
##++ 
## MODULE:	evmviewer
##
## ABSTRACT:	SUIT user interface definition for EVM event viewer.
##--
## NOTES:	
## - Overview:
##
##   The primary function of the EVM viewer is to display a list of events
##   from the event log as directed the user.  The user can control the
##   following characteristics of this event list:
##	- The set of events selected for display (filtering)
##	- The order of the list (sorting)
##	- The location of the event log (remote host selection)
##	- The information displayed for each event (visible items)
##   The viewer also provides the following secondary features:
##	- Event details view
##	- Save: event list or event details
##	- Print: event list or event details
##	- Automatic save & restore of user preferences
##
## - Naming conventions:
##
##   Most of the widgets in this file have names beginning with a "w" followed
##   by a capital letter (for example: wSort).  They were named this way to
##   make them easier pick out in the callback code.
##   There are a few exceptions:
##     - standard buttons such as "ok" and "cancel":
##	These buttons have standard names to use shared generic button labels.
##     - item buttons such as "event_id" and "pid":
##	These button names match the input strings required by the EVM
##	command-line utilities.  This exception allowed this application to
##	avoid a lot of name-translation code.
##


# This search path is required by SUIT WiP3.
# It should be unnecessary but harmless in BL11 or later versions of SUIT.
# Note: DO NOT install SUIT WiP3 on a BL11 or later system.
# SUIT WiP3 and a BL11 or later version of SUIT cannot coexist.
#global SysmanUi
# FUTURE: read SummaryNLines from an environment var (if it exists).

if {$SuitUi == "cui"} {
    set SummaryNLines 10
    set DetailsNLines 11
    set PagePadTop    0
    set SourceHostPadTop 2
    set FilterNamePadTop 0
    set FilterPriorityPadTop 0
    set FilterTimePadTop 1
    set FilterAgePadTop 0
} else { ;# gui or WWW
    set SummaryNLines 100
    set DetailsNLines 19
    set PagePadTop 1.1
    set SourceHostPadTop 2.5
    set FilterNamePadTop 1.5
    set FilterPriorityPadTop .5
    set FilterTimePadTop 2
    set FilterAgePadTop  2
}

#####################################
# the Main object name (evmviewer) will be used to pick up the following files:
#	evmviewer.cb.tcl = callbacks for widgets defined here
#	evmviewer.msg = message catalog
#
Main evmviewer {
    Window wSummary {

       	Text  wSummaryHostText \
	    -editable 0 \
	    -width 80

	List wList \
		-width  80 \
		-height 13 \
		-needSelection { } \
		-doubleClk wDetails \
		-buttons { wDetails  wRefresh wFilters wItems wSort wOptions  } \
		-autoSort 0 \
	# FUTURE: Across widget should have an option to equally
	# FUTURE: distribute its children across the available width.
#	Across {
#    Across { Button wDetails } -padLeft 1
#	    Across { Button wRefresh } -padLeft 1
#	    Across { Button wFilters } -padLeft 1
#	    Across { Button wItems } -padLeft 1
#	    Across { Button wSort } -padLeft 1
#	    Across { Button wOptions } -padLeft 1
#	}

    } \
	    -buttons { exit help } \
	    -wmclose exit \
	    -defaultb wRefresh \
	    -display 1

    Window wPage {
	Across {
	   Text wPageText \
	        -width 10
	}
    } \
	-buttons { ok apply cancel help } \
	-wmclose cancel \
	-defaultb ok

    Window wNotRoot {
	Label wMsgWindow 
	Boolean wShowNextTime
	} \
	-buttons { ok } \
	-wmclose ok \
	-defaultb ok

    Window wOptions {

	   List wList \
		-width  20 \
		-height 4 \
		-buttons { } \
                -needSelection { } \
		-autoSort 1 
           # FUTURE: A wSaveAppState button, if needed, would go here.
	
    } \
	    -buttons { ok apply cancel help } \
	    -wmclose cancel \
	    -defaultb ok

    Window wSource {
      global SourceHostPadTop
      Down {
        Enumerated    wEventSourceChoice \
	        -valueList { file host }
        Down {
               Text wFile \
	              	-width 35
        } -padTop 3.5

        global SourceHostPadTop
	Down {
                Enumerated    wSourceHostChoice \
	        	-valueList { local remote }
	        Down {
		        Text wHost \
		        	-width 35
		}
        } -padTop $SourceHostPadTop
      }
    } \
	    -buttons { ok apply cancel help } \
	    -wmclose cancel \
	    -defaultb ok

    Window wSummSave {
	Text wValue \
		-width 50
    } \
	    -buttons { ok cancel help } \
	    -wmclose cancel \
	    -defaultb ok

    Window wSummSaveOptions {
        Enumerated wAppend \
		-valueList { 0 1 }
    } \
	    -buttons { ok cancel help } \
	    -wmclose cancel \
            -defaultb ok
        
    # FUTURE: To implement Find, add the following dialog box:
    #Window wSummFind {
	#Text wValue \
		#-width 80 \
    #} \
	    #-buttons { ok apply cancel help } \
	    #-wmclose cancel \
	    #-defaultb apply

    Window wSummPrint {
	Text wValue \
		-width 45
    } \
	    -buttons { ok apply cancel help } \
	    -wmclose cancel \
	    -defaultb ok

    Window wNoOfEvents {
	Text wValue \
		-width 5
    } \
	    -buttons { ok apply cancel help } \
            -wmclose cancel \
            -defaultb ok

    Window wFilter {

       Across {
	       Boolean wNameFlag

		  Enumerated wNameEqualityChoice \
		  -valueList { equalto notequalto }
        global FilterNamePadTop
	Across {
               Text wName \
		    	-width 40
	       } -padLeft 2 -padTop $FilterNamePadTop
       } -padLeft 0 ; #end Across for wName

	Across {
	        Boolean wHostFlag
	
	        Enumerated wHostEqualityChoice \
		  -valueList { equalto notequalto }
          global FilterNamePadTop
          Across { 
	   	Text wHost \
		    	-width 40
		 } -padLeft 1.1 -padTop $FilterNamePadTop
	} -padTop 1 ; #end Across for wHost

        Across 	{ 

		Boolean wPriorityFlag

                Across {

		 Enumerated wPrioEqualityChoice \
		 -valueList { equalto notequalto }

		    Down {
		       Enumerated wPriorityChoice \
		         -valueList { range absolute min max }
	            }	

	            global FilterPriorityPadTop
		    Down {

		       Across {
			       Text wPriorityRangeMin \
				-width 3
			       Text wPriorityRangeMax \
				-width 3
		       }

		       Across { Text wPriorityAbsolute \
			          -width 3
		       }

		       Across { Text wPriorityMin \
				  -width 3
		       }
		
		       Across { Text wPriorityMax \
			          -width 3
		       }

		    } -padTop $FilterPriorityPadTop
              } -padLeft 3
	} -padTop 1 ; #end Across for wPriority

	 
	global FilterTimePadTop
	Across { 

		Boolean wBeforeFlag

	Down {
	Across {
	    Text wBeforeDay \
		    -width 2

            Enumerated wBeforeMon \
		    -valueList { 1 2 3 4 5 6 7 8 9 10 11 12 }

	    Text wBeforeYear \
		    -width 4

	} -padLeft 5.3


	Across {

	    Text wBeforeHour \
		    -width 2
	    Text wBeforeMin \
		    -width 2
	    Text wBeforeSec \
		    -width 2
	} -padLeft 5.3
	
        }
	} -padTop $FilterTimePadTop ; #end Across for wBefore ...

	global FilterTimePadTop
	Across {
	    
	   Boolean wSinceFlag

	Down {
	Across {
	    Text wSinceDay \
		    -width 2
	    Enumerated wSinceMon \
		    -valueList { 1 2 3 4 5 6 7 8 9 10 11 12 }
	    Text wSinceYear \
		    -width 4
	} -padLeft 6.5
        
	Across {

	    Text wSinceHour \
		    -width 2
	    Text wSinceMin \
		    -width 2
	    Text wSinceSec \
		    -width 2
	} -padLeft 6.5

	}

     } -padTop $FilterTimePadTop ; #end Across for wSince ...

	global FilterAgePadTop
	Across {

	Boolean wAgeFlag

	Down {
	Enumerated wAgeEqualityChoice \
	-valueList { lessthan morethan }
	} -padLeft 6.5

	Down {
	Text wAgeValue -width 3
	} 

	Down {

	Enumerated wAgeQualifer \
	-valueList { d w h m s }
	} -padLeft 2
	} -padTop $FilterAgePadTop

    } \
	    -buttons { ok apply cancel help } \
	    -wmclose cancel \
	    -defaultb ok

    Window wAdvFilter {

	Down {
	   	Text wAdvFltField \
		   -editable 50 \
		   -width 50
		} -padTop 1.5

	Across {
		    Across { Button wSaveFilter } -padLeft 15
		    Across { Button wLoadFilter } -padLeft 1.0
	       } -padTop 1.5
	} \
	    -buttons { ok apply cancel help } \
            -wmclose cancel \
            -defaultb ok

    Window wLoadAdvanced {

	List wSavedFiles \
		-width  30 \
		-height 4 \
		-needSelection { wDelete } \
		-autosort 0 \
		-buttons { wDelete }

    } \
	    -buttons { ok apply cancel help } \
	    -wmclose cancel \
	    -defaultb ok

   Window wSaveAdvanced {

        Down {
        Text wSaveAsFile \
                -editable 30 \
                -width 30 \
             } -padTop 1.5
    } \
            -buttons { ok cancel help } \
            -wmclose cancel \
            -defaultb ok

    Window wSort {
	List wItems \
		-width  10 \
		-height 10 \
		-autoSort 0 \
		-needSelection { } \
		-buttons { }

	Enumerated wIsAscending \
		-valueList { 1 0 }
    } \
	    -buttons { ok apply cancel help } \
	    -wmclose cancel \
	    -defaultb apply

    Window wItems {
       	Text  wItemsShowText \
	    -editable 0 \
	    -width 5
        Down {
	    # widget names of these items match those used by evmshow & evmsort
	    Boolean event_id
	    Boolean priority
	    Boolean timestamp
	    Boolean pid
	    Boolean user_name
	    Boolean host_name
	    Boolean cluster_name
	    Boolean name
	    Boolean format
	} -padTop 1

        Down {
        	Text wNumOfEvents \
                	-editable 1 \
                	-width 1 \
             } -padTop 2
    } \
	    -buttons { ok apply cancel help } \
	    -wmclose cancel \
	    -defaultb apply

    Window wDetails {
	global DetailsNLines

	# FUTURE: if a "Find" button is desired for details,
	# FUTURE: add "wDetFind" after "wDetPrev" in the -buttons{} clause.
	Text wText \
		-width  78 \
		-height $DetailsNLines \
		-editable 0

	Across { Button wDetNext
	         Button wDetPrev 
		 Button wDetFirst 
	         Button wDetLast }  
    } \
	    -buttons { ok wDetSave wDetPrint help } \
	    -wmclose ok \
	    -defaultb cancel

    Window wDetSave {
	Text wValue \
		-width 50
    } \
	    -buttons { ok cancel help } \
	    -wmclose cancel \
	    -defaultb ok

    Window wDetSaveOptions {
        Enumerated wAppend \
		-valueList { 0 1 }
    } \
	    -buttons { ok cancel help } \
	    -wmclose cancel \
            -defaultb ok


    # FUTURE: To implement Find, add the following dialog box:
    #Window wDetFind {
	#Text wValue \
		#-width 80 \
    #} \
	    #-buttons { ok apply cancel help } \
            #-wmclose cancel \
	    #-defaultb apply

    Window wDetPrint {
	Text wValue \
		-width 40
    } \
	    -buttons { ok apply cancel help } \
	    -wmclose cancel \
	    -defaultb ok
}
