1 /*****************************************************************************/
2 /* Software Testing Automation Framework (STAF)                              */
3 /* (C) Copyright IBM Corp. 2002, 2004, 2005                                  */
4 /*                                                                           */
5 /* This software is licensed under the Eclipse Public License (EPL) V1.0.    */
6 /*****************************************************************************/
7 
8 package com.ibm.staf.service.stax;
9 
10 import java.awt.*;
11 import java.awt.event.*;
12 import java.io.*;
13 import java.util.*;
14 import javax.swing.*;
15 import javax.swing.border.*;
16 import javax.swing.event.*;
17 import javax.swing.table.*;
18 import javax.swing.plaf.metal.*;
19 import com.ibm.staf.*;
20 import com.ibm.staf.service.*;
21 import java.text.SimpleDateFormat;
22 import java.text.ParsePosition;
23 import java.lang.reflect.*;
24 import java.util.jar.*;
25 import java.util.List;
26 import java.util.ArrayList;
27 import javax.swing.filechooser.FileFilter;
28 
29 public class STAXMonitor extends JFrame implements ActionListener,
30                                                    ItemListener,
31                                                    KeyListener,
32                                                    MouseListener,
33                                                    ListSelectionListener,
34                                                    ChangeListener,
35                                                    Runnable
36 {
37     // Set to the version of the STAX Monitor
38     static final String fVersion = "3.5.0 Beta 1";
39 
40     // Set to the version of STAF required by the STAX Monitor
41     static final String fSTAFRequiredVersion = "3.3.3";
42 
43     // Set to the version of the STAX service required by the STAX Monitor
44     static final String fServiceRequiredVersion = "3.5.0 Beta 1";
45 
46     // Set to the version of the Event service required by the STAX Monitor
47     static final String fEventRequiredVersion = "3.1.0";
48 
49     static final String sInterfaceSeparator = "://";
50     static final String sPortSeparator = "@";
51 
52     // This is the maximum queue size that the STAX Monitor will automatically
53     // increase the maxQueueSize to if less than this number
54     private static int MAXQUEUESIZE = 10000;
55 
56     public static final String DEFAULT_STRING = new String("Default");
57 
58     // These are the "pretty" versions of the Python Output combo box entries
59 
60     private static final String JOBUSERLOG_PRETTY = new String("Job User Log");
61     private static final String MESSAGE_PRETTY = new String("Message");
62     private static final String JOBUSERLOGANDMSG_PRETTY = new String(
63         "Job User Log & Message");
64     private static final String JVMLOG_PRETTY = new String("JVM Log");
65 
66     private static final String[] PYTHON_OUTPUTS_PRETTY =
67     {
68         JOBUSERLOG_PRETTY, MESSAGE_PRETTY, JOBUSERLOGANDMSG_PRETTY,
69         JVMLOG_PRETTY
70     };
71 
72     // These are the valid values for the "PYTHONOUTPUT" option
73 
74     public static final String JOBUSERLOG_STRING = new String("JobUserLog");
75     public static final String MESSAGE_STRING = new String("Message");
76     public static final String JOBUSERLOGANDMSG_STRING = new String(
77         "JobUserLogAndMsg");
78     public static final String JVMLOG_STRING = new String("JVMLog");
79 
80     /**
81      * Note: Extensions, etc should not use LOGLEVELS as we will
82      * probably move this static variable into JSTAF (e.g. STAFUtil.java)
83      * in the future.
84      */
85     public static final String[] LOGLEVELS =
86     {
87         "Info", "Fatal", "Error", "Warning", "Trace", "Trace2", "Trace3",
88         "Debug", "Debug2", "Debug3", "Start", "Stop", "Pass", "Fail", "Status",
89         "User1", "User2", "User3", "User4", "User5", "User6", "User7", "User8"
90     };
91 
92     // ToolTip text
93 
94     public static final String BREAKPOINT_LINE_NUMBER_TOOLTIP =
95         "Enter the line number for the STAX element where the breakpoint " +
96         "will be added.  The line number must " +
97         "match the first line of the STAX element.  This field " +
98         "is required.";
99 
100     public static final String BREAKPOINT_LINE_FILE_TOOLTIP =
101         "Enter the full path for the XML file where the breakpoint will " +
102         "be added.  This field is optional.  If not specified, the " +
103         "STAXJobXMLFile (i.e. the value of the FILE parameter on the " +
104         "STAX EXECUTE request) will be used.";
105 
106     public static final String BREAKPOINT_LINE_MACHINE_TOOLTIP =
107         "Enter the machine where the XML file is located.  This field " +
108         "is optional.  If not specified, the breakpoint will be added " +
109         "for the specified XML file located on any machine.";
110 
111     Vector fBreakpointTableColumnNames;
112 
113     STAFHandle fHandle;
114     String fFileSep;
115     String fLocalMachineName;
116     String fSTAXMonitorEndpoint;
117 
118     String fStaxMachineInterface = null;
119     String fStaxMachineIdentifier = null;
120     String fStaxMachinePort = null;
121 
122     String fStaxConfigMachine = "";
123     String fStaxInstanceUUID = "STAXInstanceUUID";
124     String fLocalInstanceUUID = "LocalInstanceUUID";
125     boolean fIsSTAXServiceLocal = false;
126 
127     String fMonitorFileDirectory;
128     String fExtensionsDirectory = null;
129     JDialog fPropertiesDialog;
130     boolean fPropertiesAtStartup = true;
131     String kMonitorPropertiesFileName = "monprp.ser";
132     String kMonitorLastJobDataFileName = "monljp.ser";
133     STAFCommandParser fArgsParser = new STAFCommandParser(0, false);
134     String fPropertiesFileName;
135     String fLastJobParmsFileName;
136     String fStaxMachineName = "";
137     String fStaxMachineNickname;
138     JTextField fStaxMachineNameField;
139     String fStaxServiceName = "";
140     JTextField fStaxServiceNameField;
141     String fEventMachineName = "";
142     JTextField fEventMachineNameField;
143     String fEventServiceName = "";
144     JTextField fEventServiceNameField;
145     JCheckBox fShowNoSTAXMonitorInformation = new
146         JCheckBox("Show Process <No STAX Monitor Information> message", false);
147     boolean fShowNoSTAXMonitorInformationBool = false;
148     JCheckBox fLimitMessages = new
149         JCheckBox("Limit number of Messages displayed to: ", true);
150     boolean fLimitMessagesBool = true;
151     JTextField fLimitMessagesField;
152 
153     static Boolean fDefaultShowNoSTAXMonitorInformation = new Boolean(false);
154     static Integer fDefaultAutoMonitorSubjobs = new Integer(
155         STAXMonitorFrame.AUTOMONITOR_RECOMMENDED);
156     static Boolean fDefaultLimitMessages = new Boolean(true);
157     static String fDefaultLimitMessagesText = "200";
158     static String fDefaultProcessMonitorSeconds = "60";
159     static String fDefaultElapsedTimeSeconds = "1";
160 
161     String fLimitMessagesFieldText = fDefaultLimitMessagesText;
162     JTextField fProcessMonitorSecondsField;
163     String fProcessMonitorSecondsFieldText = fDefaultProcessMonitorSeconds;
164     JTextField fElapsedTimeSecondsField;
165     String fElapsedTimeSecondsFieldText = fDefaultElapsedTimeSeconds;
166 
167     static String fDefaultMessageFontName = "Dialog";
168     static String fDefaultLogViewerFontName = "Dialog";
169     String fMessageFontName = fDefaultMessageFontName;
170     String fLogViewerFontName = fDefaultLogViewerFontName;
171     JComboBox fMessageFontNameCB = new JComboBox();
172     JComboBox fLogViewerFontNameCB = new JComboBox();
173 
174     String fSaveAsDirectory = null;
175     JTextField fSaveAsDirectoryField;
176     JButton fSaveAsDirectoryBrowseButton;
177 
178     JComboBox fTestcaseSortColumnCB = new JComboBox();
179     JComboBox fTestcaseSortOrderCB = new JComboBox();
180     JCheckBox fTestcaseNameCB;
181     JCheckBox fTestcasePassCB;
182     JCheckBox fTestcaseFailCB;
183     JCheckBox fTestcaseStartDateTimeCB;
184     JCheckBox fTestcaseStatusDateTimeCB;
185     JCheckBox fTestcaseDurationCB;
186     JCheckBox fTestcaseStartsCB;
187     JCheckBox fTestcaseInformationCB;
188     JCheckBox fTestcaseAutoResizeCB;
189     boolean fDisplayTestcaseName = true;
190     boolean fDisplayTestcasePass = true;
191     boolean fDisplayTestcaseFail = true;
192     boolean fDisplayTestcaseStartDateTime = true;
193     boolean fDisplayTestcaseStatusDateTime = true;
194     boolean fDisplayTestcaseDuration = true;
195     boolean fDisplayTestcaseStarts = true;
196     boolean fDisplayTestcaseInformation = true;
197     boolean fTestcaseAutoResize = true;
198     int fTestcaseSortColumn;
199     int fTestcaseSortOrder;
200 
201     JButton fPropertiesOKButton = new JButton("Save");
202     JButton fPropertiesCancelButton = new JButton("Cancel");
203     JButton fStartNewJobButton = new JButton("Submit New Job...");
204     JButton fSubmitLastJobButton = new JButton("Resubmit Previous Job");
205     JTable fActiveJobsTable;
206     STAXMonitorTableModel fActiveJobsTableModel;
207     STAXMonitorTableSorter fActiveJobsModelSorter;
208     Vector fActiveJobColumns;
209     JMenu fFileMenu;
210     JMenu fDisplayMenu;
211     JMenu fHelpMenu;
212     JMenuItem fHelpAbout;
213     JMenuItem fJobParametersMenuItem;
214     JMenuItem fStartNewJobMenuItem;
215     JMenuItem fFileProperties;
216     JMenuItem fFileExit;
217     JMenuItem fDisplayServiceLog;
218     JMenuItem fDisplaySTAXJVMLog;
219     JMenuItem fDisplayOtherJVMLog;
220     JMenuItem fDisplaySelectedJobLog;
221     JMenuItem fDisplaySelectedJobUserLog;
222     JMenu fDisplayRecentLogs;
223     JMenuItem fRecentLogsMenuItems[] = new JMenuItem[20];
224     Vector fRecentLogs = new Vector();
225     Vector fRecentLogsTooltips = new Vector();
226     JMenuItem fDisplayJobLog;
227     JMenuItem fDisplayJobUserLog;
228     JMenu fStartNewJobFileMenu;
229     JMenuItem fStartNewJobFileExit;
230     JMenuItem fStartNewJobFileOpen;
231     JMenuItem fStartNewJobFileSave;
232     JMenuItem fStartNewJobFileSaveAs;
233     Hashtable fPropertiesData;
234     JDialog fStartNewJobDialog;
235     String fLocalXmlFileName = "";
236     JTextField fLocalXmlFileNameField;
237     String fOtherXmlFileName = "";
238     JTextField fOtherXmlFileNameField;
239     String fOtherXmlFileMachineName = "";
240     JTextField fOtherXmlFileMachineField;
241     String fFunction = "";
242     JTextField fFunctionField;
243     JRadioButton fDefaultFunctionRB;
244     JRadioButton fOtherFunctionRB;
245     JRadioButton fMachineLocalRB;
246     JRadioButton fMachineOtherRB;
247     JRadioButton fMonitorYesRB;
248     JRadioButton fMonitorNoRB;
249     JRadioButton fClearLogsYesRB;
250     JRadioButton fClearLogsNoRB;
251     JRadioButton fClearLogsDefaultRB;
252     JTextArea fArguments;
253     JButton fClearArguments = new JButton("Clear");
254     boolean fArgumentsEnabled;
255     String fArgs = "";
256     String fJobName = "";
257     JTextField fJobNameField;
258     JButton fStartNewJobSubmitButton;
259     JButton fStartNewJobTestButton;
260     JButton fStartNewJobCancelButton;
261     JButton fStartNewJobClearButton;
262     JButton fBrowseButton;
263     JList fScriptList;
264     JButton fScriptAddButton;
265     JButton fScriptDeleteButton;
266     JButton fScriptDeleteAllButton;
267     JDialog fAddScriptDialog;
268     JTextArea fAddScriptTextArea;
269     JButton fAddScriptAddButton;
270     JButton fAddScriptCancelButton;
271     JDialog fEditScriptDialog;
272     JTextArea fEditScriptTextArea;
273     JButton fEditScriptSaveButton;
274     JButton fEditScriptCancelButton;
275     File fLastFileDirectory;
276     File fLastJobParmsFileDirectory;
277     Vector fScriptVector = new Vector();
278     Hashtable fMonitorTable = new Hashtable();
279     JPopupMenu fJobPopupMenu = new JPopupMenu();
280     JMenuItem fJobShowMonitorMenuItem = new JMenuItem("Show Monitor window");
281     JMenuItem fJobStartMonitorMenuItem = new JMenuItem("Start Monitoring");
282     JMenuItem fJobShowJobLogMenuItem = new JMenuItem("Display Job Log");
283     JMenuItem fJobShowJobUserLogMenuItem =
284         new JMenuItem("Display Job User Log");
285     JMenuItem fJobShowSTAXServiceLogMenuItem =
286         new JMenuItem("Display STAX Service Log");
287     JMenuItem fJobShowSTAXJVMLogMenuItem =
288         new JMenuItem("Display STAX JVM Log");
289     JMenuItem fJobShowOtherJVMLogMenuItem =
290         new JMenuItem("Display Other JVM Log");
291     JMenuItem fJobTerminateJobMenuItem = new JMenuItem("Terminate Job");
292     String fJobParmsID = "STAX/Job/Monitor/Parameters";
293     String fStartNewJobTitle = "STAX Job Parameters ";
294     String fCurrentJobParmsFile = "";
295     boolean fCurrentJobParmsNotSaved = false;
296     boolean fContinueElapsedTime = true;
297     MonitorElapsedTime fElapsedTime;
298     Hashtable fJobStartTimes = new Hashtable();
299     Hashtable fJobStartDateTimes = new Hashtable();
300     Vector fRecentFiles = new Vector();
301     String fRecentFilesName;
302     String kRecentFilesFileName = "monrcfl.ser";
303     JMenuItem fRecentFileMenuItems[] = new JMenuItem[10];
304     String fCloseOnEndJobID = "";
305     String fStartNewJobParmFileName = "";
306     boolean fStartNewJobCloseOnEnd = false;
307     Vector fLocalExtJarFiles;
308     Vector fUpdatedLocalExtJarFiles;
309     Vector fOldLocalExtJarFiles;
310     Map fMonitorExtensionMap = new TreeMap();
311 
312     Vector fBreakpointFunctionsVector = new Vector();
313     JButton fBreakpointFunctionAddButton;
314     JButton fBreakpointFunctionDeleteButton;
315     JButton fBreakpointFunctionDeleteAllButton;
316     JDialog fAddBreakpointFunctionDialog;
317     JTextField fAddBreakpointFunctionTextField;
318     JButton fAddBreakpointFunctionAddButton;
319     JButton fAddBreakpointFunctionCancelButton;
320     JDialog fEditBreakpointFunctionDialog;
321     JTextField fEditBreakpointFunctionTextField;
322     JButton fEditBreakpointFunctionSaveButton;
323     JButton fEditBreakpointFunctionCancelButton;
324 
325     JTable fBreakpointTable;
326     JButton fBreakpointLineAddButton;
327     JButton fBreakpointDeleteButton;
328     JButton fBreakpointDeleteAllButton;
329     JDialog fAddBreakpointLineDialog;
330     JTextField fAddBreakpointLineNumberTextField;
331     JTextField fAddBreakpointLineFileTextField;
332     JTextField fAddBreakpointLineMachineTextField;
333     JButton fAddBreakpointLineAddButton;
334     JButton fAddBreakpointLineCancelButton;
335     JDialog fEditBreakpointLineDialog;
336     JTextField fEditBreakpointLineNumberTextField;
337     JTextField fEditBreakpointLineFileTextField;
338     JTextField fEditBreakpointLineMachineTextField;
339     JButton fEditBreakpointLineSaveButton;
340     JButton fEditBreakpointLineCancelButton;
341 
342     JCheckBox fBreakpointFirstFunctionCB;
343     JCheckBox fBreakpointSubjobFirstFunctionCB;
344 
345     STAXMonitorTableModel fBreakpointsTableModel;
346     STAXMonitorTableSorter fBreakpointsModelSorter;
347 
348     // List of temporary extension jar files
349     Vector fTempLocalExtFiles = new Vector();
350 
351     JList fPluginJarsList;
352 
353     // List of monitor extension plugin classes to be loaded by each job
354     Vector fPluginClasses = new Vector();
355 
356     JButton fPluginJarsAddButton;
357     JButton fPluginJarsDeleteButton;
358     JButton fPluginJarsDeleteAllButton;
359     JDialog fAddPluginJarsDialog;
360     JTextField fAddPluginJarsTextField;
361     JButton fAddPluginJarsBrowseButton;
362     JButton fAddPluginJarsAddButton;
363     JButton fAddPluginJarsCancelButton;
364     JDialog fEditPluginJarsDialog;
365     JTextField fEditPluginJarsTextField;
366     JButton fEditPluginJarsSaveButton;
367     JButton fEditPluginJarsCancelButton;
368 
369     JTable fExtensionsTable;
370     Vector fExtensionsColumns;
371     STAXMonitorTableModel fExtensionsTableModel;
372     STAXMonitorTableSorter fExtensionsModelSorter;
373     static String EXT_COLUMN_NAME = "Name";
374     static String EXT_COLUMN_SOURCE = "Source";
375     static String EXT_COLUMN_VERSION = "Version";
376     static String EXT_COLUMN_JARFILE = "Jar File Name";
377     static String EXT_COLUMN_OVERRIDES = "Overrides";
378     static String EXT_COLUMN_PREREQ = "Prereq";
379     static String EXT_COLUMN_DESCRIPTION = "Description";
380 
381     String fOldStaxMachineName;
382     String fOldStaxServiceName;
383     String fOldEventMachineName;
384     String fOldEventServiceName;
385     Vector fScriptFilesVector;
386     JList fScriptFilesList;
387     JButton fScriptFilesAddButton;
388     JButton fScriptFilesDeleteButton;
389     JButton fScriptFilesDeleteAllButton;
390     JDialog fAddScriptFilesDialog;
391     JTextField fAddScriptFilesTextField;
392     JButton fAddScriptFilesBrowseButton;
393     JButton fAddScriptFilesAddButton;
394     JButton fAddScriptFilesCancelButton;
395     JDialog fEditScriptFilesDialog;
396     JTextField fEditScriptFilesTextField;
397     JButton fEditScriptFilesSaveButton;
398     JButton fEditScriptFilesCancelButton;
399     JTextField fScriptFilesMachineTextField;
400     String fScriptFilesMachineName;
401     JRadioButton fLocalScriptMachineRB;
402     JRadioButton fXMLJobFileScriptMachineRB;
403     JRadioButton fOtherScriptMachineRB;
404     JRadioButton fAutoMonitorSubjobsRB;
405     boolean fAutoMonitorSubjobs = false;
406     JRadioButton fAutoMonitorRecommendedSubjobsRB;
407     boolean fAutoMonitorRecommendedSubjobs = false;
408     JRadioButton fNeverAutoMonitorSubjobsRB;
409     boolean fNeverAutoMonitorSubjobs = false;
410     JButton fStartNewJobWizardButton;
411     JDialog fWizardDialog;
412     JButton fWizardSaveButton = new JButton("Save");
413     JButton fWizardPreviewXMLButton = new JButton("Preview XML...");
414     JButton fWizardCancelButton = new JButton("Cancel");
415     JPanel prologPanel;
416     JPanel fWizardFunctionArgsPanel;
417     HashMap fWizardFunctionMap;
418     HashMap fWizardFunctionTypeMap;
419     HashMap fWizardFunctionPrologMap;
420     HashMap fWizardFunctionEpilogMap;
421     HashMap fWizardFunctionArgTableMap;
422     HashMap fWizardFunctionArgDefaultsMap;
423     JList fWizardFunctionsList;
424     TitledBorder functionDescriptionBorder = new TitledBorder("");
425     TitledBorder functionArgumentBorder = new TitledBorder("");
426     JLabel fWizardNoArgsAllowedLabel;
427     JLabel fWizardNoArgsDefinedLabel;
428     JLabel fWizardSingleArgLabel;
429     JLabel fWizardListArgsLabel;
430     JLabel fWizardMapArgsLabel;
431     Object[] fWizardFunctionTableColumnNames =
432         {
433             "Name", "Description", "Required", "Value"
434         };
435 
436     JRadioButton fLogTCElapsedTimeYesRB;
437     JRadioButton fLogTCElapsedTimeNoRB;
438     JRadioButton fLogTCElapsedTimeDefaultRB;
439     JRadioButton fLogTCNumStartsYesRB;
440     JRadioButton fLogTCNumStartsNoRB;
441     JRadioButton fLogTCNumStartsDefaultRB;
442     JRadioButton fLogTCStartStopYesRB;
443     JRadioButton fLogTCStartStopNoRB;
444     JRadioButton fLogTCStartStopDefaultRB;
445 
446     JComboBox fPythonOutputCB = new JComboBox();
447     JComboBox fPythonLogLevelCB = new JComboBox();
448 
449     JTable fLogOptionsTable;
450     JEditorPane fWizardFunctionProlog;
451     JButton fWizardDetailsButton;
452 
453     // Used to compare if should assign saved function arg list for a function
454     // when using the Job Wizard
455     String fWizardSavedFunctionName = "";
456     String fWizardSavedFileName = "";
457     String fWizardSavedFileMachineName = "";
458     Vector fWizardSavedFunctionArgList = new Vector();
459     String fWizardFileName = "";
460     String fWizardFileMachineName = "";
461 
462     Color lightRed = new Color(255, 204, 204);
463     Color lightGreen = new Color(204, 255, 204);
464     Color lightYellow = new Color(255, 255, 153);
465 
466     String helpText = "\nSTAXMonitor Help\n\n" +
467         "-job <jobNumber> [-closeonend]\n" +
468         "-jobparms <jobParmsFile> [-closeonend]\n" +
469         "-extensions\n" +
470         "-properties [-staxMachine <machineName>] " +
471                     "[-staxServiceName <serviceName>]\n" +
472         //"            [-jobParmsDirectory <directoryName>]\n" +
473         "            [-noStart]\n" +
474         "-help\n" +
475         "-version\n";
476 
477     private static java.net.URL splashURL =
478         ClassLoader.getSystemClassLoader().
479         getSystemResource("images/splash.gif");
480 
481     final String kSplashText = "Version " + fVersion +
482         ", Copyright IBM Corp. 2003-2005";
483 
484     static final String STAX_MONITOR_EXTENSION =
485         new String("staf/staxmonitor/extension/");
486     static final String STAX_EXTENSION_INFO =
487         new String("staf/staxinfo/extension");
488     static final String NOT_APPLICABLE = new String("<N/A>");
489     static final String sNONE = new String("<None>");
490     static final int STAX_SERVICE_EXTENSION = 1;
491     static final int LOCAL_EXTENSION = 2;
492 
493     private STAFVersion fMonitorVersion = null;
494     STAFVersion fSTAXServiceVersion;
495 
STAXMonitor(String argv[])496     public STAXMonitor(String argv[])
497     {
498         String jobIDToMonitor = "";
499 
500         try
501         {
502             fHandle =
503                 STAXMonitorUtil.getNewSTAFHandle("STAX/JobMonitor/Controller");
504         }
505         catch(STAFException ex)
506         {
507             if (ex.rc == STAFResult.HandleAlreadyExists)
508             {
509                 System.out.println("Ensure that SET ALLOWMULTIREG is " +
510                                    "specified in the STAF.cfg file");
511             }
512             else
513             {
514                 System.out.println("STAX Job Monitor V" + fVersion +
515                                    " requires STAF V" + fSTAFRequiredVersion +
516                                    " or later to be running");
517             }
518 
519             System.exit(0);
520         }
521 
522         STAFResult result = new STAFResult();
523 
524         // Resolve the line separator variable for the local machine
525 
526         result = fHandle.submit2(
527             "local", "VAR", "RESOLVE STRING {STAF/Config/Sep/Line}");
528 
529         if (result.rc != STAFResult.Ok)
530         {
531             JOptionPane.showMessageDialog(
532                 this, "Error resolving {STAF/Config/Sep/Line} " +
533                 "variable\n\nRC: " + result.rc + "\nResult: " + result.result,
534                 "Error resolving variable", JOptionPane.ERROR_MESSAGE);
535 
536             System.exit(0);
537         }
538 
539         String lineSep = result.result;
540 
541         // Verify the required version of STAF is running on the STAX Monitor
542         // Note:  Method compareSTAFVersion was added in STAF V3.1.0
543 
544         try
545         {
546             result = STAFUtil.compareSTAFVersion(
547                 "local", fHandle, fSTAFRequiredVersion);
548 
549             if (result.rc != STAFResult.Ok)
550             {
551                 if (result.rc == STAFResult.InvalidSTAFVersion)
552                 {
553                     JOptionPane.showMessageDialog(
554                         this, "ERROR: Minimum required STAF version for " +
555                         "the STAX Monitor is not running." + lineSep +
556                         result.result, "Required STAF Version Not Running",
557                         JOptionPane.ERROR_MESSAGE);
558                 }
559                 else
560                 {
561                     JOptionPane.showMessageDialog(
562                         this, "Error verifying STAF version. RC: " +
563                         result.rc + ", Additional info: " + result.result,
564                         "Error verifying STAF version",
565                         JOptionPane.ERROR_MESSAGE);
566                 }
567 
568                 System.exit(0);
569             }
570         }
571         catch (Error err)
572         {
573             JOptionPane.showMessageDialog(
574                 this, "ERROR: The STAX Monitor requires STAF Version " +
575                 fSTAFRequiredVersion + " or later.",
576                 "Required STAF Version Not Running",
577                 JOptionPane.ERROR_MESSAGE);
578 
579             System.exit(0);
580         }
581 
582         // Verify that the version specified for the STAX Monitor is valid
583 
584         try
585         {
586             fMonitorVersion = new STAFVersion(fVersion);
587         }
588         catch (NumberFormatException e)
589         {
590             System.out.println("ERROR: " + fVersion +
591                                " is an invalid STAX monitor version.\n" +
592                                e.toString());
593             System.exit(0);
594         }
595 
596         // Resolve the {STAF/Config/Machine} variable
597 
598         result = fHandle.submit2(
599             "local", "VAR", "RESOLVE STRING {STAF/Config/Machine}");
600 
601         if (result.rc != 0)
602         {
603             JOptionPane.showMessageDialog(
604                 this, "Error resolving {STAF/Config/Machine} " +
605                 "variable\n\nRC: " + result.rc + "\nResult: " + result.result,
606                 "Error resolving variable", JOptionPane.ERROR_MESSAGE);
607         }
608         else
609         {
610             fLocalMachineName = result.result;
611         }
612 
613         fFileSep = File.separator;
614         String userHome = System.getProperty("user.home");
615 
616         if (!(userHome.endsWith(fFileSep)))
617         {
618             userHome += fFileSep;
619         }
620 
621         fMonitorFileDirectory = userHome + "staxmonitordata3";
622 
623         File dir = new File(fMonitorFileDirectory);
624 
625         if (!dir.exists())
626         {
627             if (!(dir.mkdirs()))
628             {
629                 JOptionPane.showMessageDialog(this,
630                                       "Error creating directory: " +
631                                       fMonitorFileDirectory,
632                                       "Error creating directory",
633                                       JOptionPane.ERROR_MESSAGE);
634             }
635         }
636 
637         fLastJobParmsFileName = fMonitorFileDirectory +
638                                 fFileSep + kMonitorLastJobDataFileName;
639         fPropertiesFileName = fMonitorFileDirectory +
640                               fFileSep + kMonitorPropertiesFileName;
641 
642         fRecentFilesName =  fMonitorFileDirectory + fFileSep +
643                             kRecentFilesFileName;
644 
645         fCurrentJobParmsFile = fLastJobParmsFileName;
646 
647         // Check if any arguments were specified
648 
649         if (argv.length > 0)
650         {
651             if (argv[0].equalsIgnoreCase("-HELP"))
652             {
653                 System.out.println(helpText);
654                 System.exit(0);
655             }
656             else if (argv[0].equalsIgnoreCase("-VERSION"))
657             {
658                 System.out.println(kSplashText);
659                 System.exit(0);
660             }
661             else if (argv[0].equalsIgnoreCase("-JOB"))
662             {
663                 jobIDToMonitor = resolveVar(argv[1], fHandle.getHandle());
664 
665                 if (jobIDToMonitor == null)
666                 {
667                     System.out.println("Invalid parameters");
668                     System.out.println(helpText);
669                     System.exit(0);
670                 }
671 
672                 if (argv.length > 2)
673                 {
674                     if (argv[2].equalsIgnoreCase("-CLOSEONEND"))
675                     {
676                         fCloseOnEndJobID = jobIDToMonitor;
677                     }
678                     else
679                     {
680                         System.out.println("Invalid parameters");
681                         System.out.println(helpText);
682                         System.exit(0);
683                     }
684                 }
685             }
686             else if (argv[0].equalsIgnoreCase("-JOBPARMS"))
687             {
688                 fStartNewJobParmFileName = resolveVar(
689                     argv[1], fHandle.getHandle());
690 
691                 if (argv.length > 2)
692                 {
693                     if (argv[2].equalsIgnoreCase("-CLOSEONEND"))
694                     {
695                         fStartNewJobCloseOnEnd = true;
696                     }
697                     else
698                     {
699                         System.out.println("Invalid parameters");
700                         System.out.println(helpText);
701                         System.exit(0);
702                     }
703                 }
704             }
705             else if (argv[0].equalsIgnoreCase("-EXTENSIONS"))
706             {
707                 // Handle later in the constructor
708             }
709             else if (argv[0].equalsIgnoreCase("-PROPERTIES"))
710             {
711                 boolean noStart = false;
712                 int numPropsSet = 0;
713                 String newStaxMachineName = "";
714                 String newStaxServiceName = "";
715                 String newEventMachineName = "";
716                 String newEventServiceName = "";
717                 String newJobParmsDirectory = "";
718 
719                 for (int i = 1; i < argv.length; i++)
720                 {
721                     if (argv[i].equalsIgnoreCase("-STAXMACHINE"))
722                     {
723                         if (!newStaxMachineName.equals(""))
724                         {
725                             System.out.println(
726                                 "Invalid parameters - " +
727                                 "Can specify -staxMachine property only once");
728                             System.out.println(helpText);
729                             System.exit(0);
730                         }
731 
732                         i++;
733 
734                         if (i < argv.length)
735                         {
736                             newStaxMachineName = resolveVar(
737                                 argv[i], fHandle.getHandle());
738                             numPropsSet++;
739                         }
740                         else
741                         {
742                             System.out.println(
743                                 "Invalid parameters - " +
744                                 "Must specify a value for -staxMachine");
745                             System.out.println(helpText);
746                             System.exit(0);
747                         }
748                     }
749                     else if (argv[i].equalsIgnoreCase("-STAXSERVICENAME"))
750                     {
751                         if (!newStaxServiceName.equals(""))
752                         {
753                             System.out.println(
754                                 "Invalid parameters - " +
755                                 "Can specify -staxServiceName property only once");
756                             System.out.println(helpText);
757                             System.exit(0);
758                         }
759 
760                         i++;
761 
762                         if (i < argv.length)
763                         {
764                             newStaxServiceName = resolveVar(
765                                 argv[i], fHandle.getHandle());
766                             numPropsSet++;
767                         }
768                         else
769                         {
770                             System.out.println(
771                                 "Invalid parameters - " +
772                                 "Must specify a value for -staxServiceName");
773                             System.out.println(helpText);
774                             System.exit(0);
775                         }
776                     }
777                     /*
778                     else if (argv[i].equalsIgnoreCase("-JOBPARMSDIRECTORY"))
779                     {
780                         if (!newJobParmsDirectory.equals(""))
781                         {
782                             System.out.println(
783                                 "Invalid parameters - " +
784                                 "Can specify -jobParmsDirectory property " +
785                                 "only once");
786                             System.out.println(helpText);
787                             System.exit(0);
788                         }
789 
790                         i++;
791 
792                         if (i < argv.length)
793                         {
794                             newJobParmsDirectory = resolveVar(
795                                 argv[i], fHandle.getHandle());
796                             numPropsSet++;
797                         }
798                         else
799                         {
800                             System.out.println(
801                                 "Invalid parameters - " +
802                                 "Must specify a value for -jobParmsDirectory");
803                             System.out.println(helpText);
804                             System.exit(0);
805                         }
806                     }
807                     */
808                     else if (argv[i].equalsIgnoreCase("-NOSTART"))
809                     {
810                         noStart = true;
811                     }
812                     else
813                     {
814                         System.out.println("Invalid parameters");
815                         System.out.println(helpText);
816                         System.exit(0);
817                     }
818                 }
819 
820                 if (numPropsSet > 0)
821                 {
822                     updateProperties(newStaxMachineName, newStaxServiceName,
823                                      newEventMachineName, newEventServiceName,
824                                      newJobParmsDirectory, !noStart);
825                 }
826                 else
827                 {
828                     System.out.println(
829                         "No properties specified to be updated");
830                 }
831 
832                 if (noStart)
833                 {
834                     System.exit(0);
835                 }
836             }
837             else
838             {
839                 System.out.println("Invalid parameters");
840                 System.out.println(helpText);
841                 System.exit(0);
842             }
843         }
844 
845         ImageIcon image = new ImageIcon(splashURL);
846         SplashScreen splash = new SplashScreen(image, "Initializing...   " +
847                                                kSplashText);
848         splash.run();
849         try
850         {
851             Thread.sleep(1000);
852         }
853         catch (InterruptedException ex)
854         {
855         }
856 
857         addWindowListener(new WindowAdapter()
858         {
859             public void windowClosing(WindowEvent e)
860             {
861                 exit();
862                 System.exit(0);
863             }
864         });
865 
866         File propertiesFile = new File(fPropertiesFileName);
867 
868         if (!propertiesFile.exists())
869         {
870             fStaxMachineName = "local";
871             fStaxServiceName = "STAX";
872             fIsSTAXServiceLocal = true;
873 
874             // Get Event machine/service based on STAX machine/service
875 
876             EventServiceInfo eventServiceInfo = new EventServiceInfo(
877                 fStaxMachineName, fStaxServiceName, this, true);
878 
879             fEventMachineName = eventServiceInfo.getMachine();
880             fEventServiceName = eventServiceInfo.getService();
881 
882             fPropertiesCancelButton.setEnabled(false);
883 
884             createPropertiesDialog();
885             fPropertiesDialog.setVisible(true);
886 
887             // At this point the user has clicked on "Save" in the properties
888             // dialog, so resolveMachineNames() and saveProperties() have
889             // already been called in the actionPerformed code
890         }
891         else
892         {
893             createPropertiesDialog();
894             loadProperties();
895             fPropertiesAtStartup = false;
896 
897             // This can be true if the properties file is corrupt and could
898             // not be read
899 
900             if (fStaxMachineName.equals(""))
901             {
902                 fStaxMachineName = "local";
903                 fStaxServiceName = "STAX";
904                 fIsSTAXServiceLocal = true;
905 
906                 // Get Event machine/service based on STAX machine/service
907 
908                 EventServiceInfo eventServiceInfo = new EventServiceInfo(
909                     fStaxMachineName, fStaxServiceName, this, true);
910 
911                 fEventMachineName = eventServiceInfo.getMachine();
912                 fEventServiceName = eventServiceInfo.getService();
913 
914                 resolveMachineNames();
915 
916                 saveProperties();
917             }
918         }
919 
920         getContentPane().setLayout(new BorderLayout());
921         getContentPane().setBackground(Color.white);
922 
923         JMenuBar mainMenuBar = new JMenuBar();
924         setJMenuBar(mainMenuBar);
925         fFileMenu = new JMenu("File");
926         mainMenuBar.add(fFileMenu);
927         fDisplayMenu = new JMenu("Display");
928         mainMenuBar.add(fDisplayMenu);
929         fHelpMenu = new JMenu("Help");
930         mainMenuBar.add(fHelpMenu);
931         fHelpAbout = new JMenuItem("About");
932         fHelpAbout.addActionListener(this);
933         fJobParametersMenuItem = new JMenuItem("Submit New Job...");
934         fJobParametersMenuItem.addActionListener(this);
935         fStartNewJobMenuItem = new JMenuItem("Resubmit Previous Job");
936         fStartNewJobMenuItem.addActionListener(this);
937         fFileProperties = new JMenuItem("Properties...");
938         fFileProperties.addActionListener(this);
939         fFileExit = new JMenuItem("Exit");
940         fFileExit.addActionListener(this);
941         fDisplayServiceLog = new JMenuItem("Display STAX Service Log");
942         fDisplayServiceLog.addActionListener(this);
943         fDisplaySelectedJobLog = new JMenuItem("Display Selected Job's Log");
944         fDisplaySelectedJobLog.addActionListener(this);
945         fDisplaySelectedJobLog.setEnabled(false);
946         fDisplaySelectedJobUserLog = new
947             JMenuItem("Display Selected Job's User Log");
948         fDisplaySelectedJobUserLog.addActionListener(this);
949         fDisplaySelectedJobUserLog.setEnabled(false);
950         fDisplayRecentLogs = new JMenu("Display Recent Logs");
951 
952         fDisplayJobLog = new JMenuItem("Display Job Log...");
953         fDisplayJobLog.addActionListener(this);
954         fDisplayJobUserLog = new JMenuItem("Display Job User Log...");
955         fDisplayJobUserLog.addActionListener(this);
956 
957         // Verify that STAF V3.2.1 or later is running on the STAX Monitor in
958         // order to allow the Display JVM Log options to be selectable (as
959         // the STAFJVMLogViewer was added in STAF V3.2.1.
960 
961         boolean jvmLogSupport = true;
962 
963         try
964         {
965             result = STAFUtil.compareSTAFVersion(
966                 "local", fHandle, "3.2.1");
967 
968             if (result.rc != STAFResult.Ok)
969             {
970                 if (result.rc == STAFResult.InvalidSTAFVersion)
971                 {
972                     // Minimum required STAF version for the STAX Monitor's
973                     // "Display JVM Log" options is not running
974                     jvmLogSupport = false;
975                 }
976                 else
977                 {
978                     JOptionPane.showMessageDialog(
979                         this, "Error verifying STAF version. RC: " +
980                         result.rc + ", Additional info: " + result.result,
981                         "Error verifying STAF version",
982                         JOptionPane.ERROR_MESSAGE);
983                 }
984             }
985         }
986         catch (Error err)
987         {
988             // Ignore as this error would have already been caught
989         }
990 
991         fDisplaySTAXJVMLog = new JMenuItem("Display STAX JVM Log");
992         fDisplaySTAXJVMLog.addActionListener(this);
993         fDisplayOtherJVMLog = new JMenuItem("Display Other JVM Log...");
994         fDisplayOtherJVMLog.addActionListener(this);
995 
996         if (!jvmLogSupport)
997         {
998             // Grey out these menu items
999             fDisplaySTAXJVMLog.setEnabled(false);
1000             fDisplayOtherJVMLog.setEnabled(false);
1001         }
1002 
1003         fHelpMenu.add(fHelpAbout);
1004         fFileMenu.add(fFileProperties);
1005         fFileMenu.insertSeparator(1);
1006         fFileMenu.add(fJobParametersMenuItem);
1007         fFileMenu.add(fStartNewJobMenuItem);
1008         fFileMenu.insertSeparator(4);
1009         fFileMenu.add(fFileExit);
1010         fDisplayMenu.add(fDisplayServiceLog);
1011         fDisplayMenu.insertSeparator(1);
1012         fDisplayMenu.add(fDisplaySelectedJobLog);
1013         fDisplayMenu.add(fDisplaySelectedJobUserLog);
1014         fDisplayMenu.insertSeparator(5);
1015         fDisplayMenu.add(fDisplayRecentLogs);
1016         fDisplayMenu.insertSeparator(6);
1017         fDisplayMenu.add(fDisplayJobLog);
1018         fDisplayMenu.add(fDisplayJobUserLog);
1019         fDisplayMenu.insertSeparator(9);
1020         fDisplayMenu.add(fDisplaySTAXJVMLog);
1021         fDisplayMenu.add(fDisplayOtherJVMLog);
1022 
1023         JPanel mainPanel = new JPanel();
1024         mainPanel.setLayout(new BorderLayout());
1025 
1026         JPanel jobsPanel = new JPanel();
1027         jobsPanel.setLayout(new BorderLayout());
1028         jobsPanel.setBorder(new TitledBorder("Active Jobs"));
1029 
1030         fActiveJobColumns = new Vector();
1031         fActiveJobColumns.addElement(" Job ID ");
1032         fActiveJobColumns.addElement(" Job Name ");
1033         fActiveJobColumns.addElement(" Monitored ");
1034         fActiveJobColumns.addElement(" Function ");
1035         fActiveJobColumns.addElement(" Status ");
1036         fActiveJobColumns.addElement(" Started ");
1037         fActiveJobColumns.addElement(" Elapsed Time ");
1038         fActiveJobColumns.addElement(" Result ");
1039 
1040         fActiveJobsTableModel =
1041             new STAXMonitorTableModel(fActiveJobColumns, 0);
1042 
1043         fActiveJobsModelSorter =
1044             new STAXMonitorTableSorter(fActiveJobsTableModel, 0);
1045         fActiveJobsTable = new JTable(fActiveJobsModelSorter);
1046         fActiveJobsModelSorter.
1047             addMouseListenerToHeaderInTable(fActiveJobsTable, 7);
1048         fActiveJobsTable.addMouseListener(this);
1049         fActiveJobsTable.getSelectionModel().addListSelectionListener(this);
1050 
1051         updateJobTableRenderers();
1052 
1053         fActiveJobsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
1054         fActiveJobsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1055         fActiveJobsTable.setRowSelectionAllowed(true);
1056 
1057         STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
1058 
1059         JScrollPane jobsScrollPane = new JScrollPane(fActiveJobsTable);
1060         jobsPanel.add(jobsScrollPane);
1061 
1062         JPanel startNewJobPanel = new JPanel();
1063         startNewJobPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
1064 
1065         fStartNewJobButton.addActionListener(this);
1066         startNewJobPanel.add(fStartNewJobButton);
1067         startNewJobPanel.add(Box.createHorizontalStrut(20));
1068         fSubmitLastJobButton.addActionListener(this);
1069         startNewJobPanel.add(fSubmitLastJobButton);
1070 
1071         mainPanel.add(BorderLayout.CENTER, jobsPanel);
1072         mainPanel.add(BorderLayout.SOUTH, startNewJobPanel);
1073 
1074         fJobPopupMenu.add(fJobShowMonitorMenuItem);
1075         fJobShowMonitorMenuItem.addActionListener(this);
1076         fJobPopupMenu.add(fJobStartMonitorMenuItem);
1077         fJobStartMonitorMenuItem.addActionListener(this);
1078         fJobPopupMenu.addSeparator();
1079         fJobPopupMenu.add(fJobShowSTAXServiceLogMenuItem);
1080         fJobShowSTAXServiceLogMenuItem.addActionListener(this);
1081         fJobPopupMenu.addSeparator();
1082         fJobPopupMenu.add(fJobShowJobLogMenuItem);
1083         fJobShowJobLogMenuItem.addActionListener(this);
1084         fJobPopupMenu.add(fJobShowJobUserLogMenuItem);
1085         fJobShowJobUserLogMenuItem.addActionListener(this);
1086         fJobPopupMenu.addSeparator();
1087         fJobPopupMenu.add(fJobTerminateJobMenuItem);
1088         fJobTerminateJobMenuItem.addActionListener(this);
1089 
1090         // Get STAX service version
1091 
1092         String versionRequest = "VERSION";
1093 
1094         STAFResult versionResult = fHandle.submit2(
1095             fStaxMachineName, fStaxServiceName, versionRequest);
1096 
1097         if (versionResult.rc == 0)
1098         {
1099             String staxServiceVersion = versionResult.result;
1100             fSTAXServiceVersion = new STAFVersion(staxServiceVersion);
1101 
1102             // Check if STAX service is at the required version
1103 
1104             STAFVersion requiredVersion1 = new STAFVersion(
1105                 fServiceRequiredVersion);
1106 
1107             if (fSTAXServiceVersion.compareTo(requiredVersion1) < 0)
1108             {
1109                 JOptionPane.showMessageDialog(this,
1110                     "WARNING: STAX service machine is not at STAX version " +
1111                     requiredVersion1 + " or later.\n" +
1112                     "machine=" + fStaxMachineName + ", service=" +
1113                     fStaxServiceName + ", version=" + fSTAXServiceVersion,
1114                     "Incorrect STAX service version",
1115                     JOptionPane.ERROR_MESSAGE);
1116             }
1117             else
1118             {
1119                 // Load the extensions before displaying the main STAX Monitor panel
1120                 loadExtensions();
1121             }
1122         }
1123 
1124         // Handle -extensions parameter
1125 
1126         if (argv.length > 0 && argv[0].equalsIgnoreCase("-EXTENSIONS"))
1127         {
1128             // Display the registered STAX Monitor Extensions
1129 
1130             displayMonitorExtensions();
1131         }
1132 
1133         // Get the endpoint for the STAX Monitor machine that the STAX service
1134         // machine will use when communicating with the STAX Monitor machine
1135 
1136         STAFResult whoamiResult = fHandle.submit2(
1137             fStaxMachineName, "MISC", "WHOAMI");
1138 
1139         if (whoamiResult.rc != 0)
1140         {
1141             System.out.println(
1142                 "Error submitting MISC WHOAMI request to the STAX " +
1143                 "service machine " + fStaxMachineName + ", RC: " +
1144                 whoamiResult.rc + ", Result: " + whoamiResult.result);
1145 
1146             // Default to using the local machine's name
1147             fSTAXMonitorEndpoint = fLocalMachineName;
1148         }
1149         else
1150         {
1151             Map whoamiMap = (HashMap)whoamiResult.resultObj;
1152             fSTAXMonitorEndpoint = (String)whoamiMap.get("endpoint");
1153 
1154             // Check if the STAX service machine is a remote machine, and if so,
1155             // get the current timestamp on the STAX service machine
1156 
1157             String isLocalRequest = (String)whoamiMap.get("isLocalRequest");
1158 
1159             if (isLocalRequest.equalsIgnoreCase("No"))
1160             {
1161                 STAFResult whoareyouResult = fHandle.submit2(
1162                     fStaxMachineName, "MISC", "WHOAREYOU");
1163 
1164                 long localCurrentMillis = System.currentTimeMillis();
1165 
1166                 if (whoareyouResult.rc == 0)
1167                 {
1168                     Map whoareyouMap = (HashMap)whoareyouResult.resultObj;
1169 
1170                     if (whoareyouMap.containsKey("currentTimestamp"))
1171                     {
1172                         String staxMachineCurrentTimestamp =
1173                             (String)whoareyouMap.get("currentTimestamp");
1174 
1175                         Date staxMachineDate =
1176                             STAXMonitorUtil.DATE_FORMAT.parse(
1177                                 staxMachineCurrentTimestamp,
1178                                 new ParsePosition(0));
1179 
1180                         Calendar staxMachineCalendar = Calendar.getInstance();
1181                         staxMachineCalendar.setTime(staxMachineDate);
1182 
1183                         long staxMachineCurrentMillis =
1184                             staxMachineCalendar.getTimeInMillis();
1185 
1186                         if (staxMachineCurrentMillis < localCurrentMillis)
1187                         {
1188                             STAXMonitorUtil.setTimeOffset(
1189                                 0 - (localCurrentMillis -
1190                                 staxMachineCurrentMillis));
1191                         }
1192                         else
1193                         {
1194                             STAXMonitorUtil.setTimeOffset(
1195                                 staxMachineCurrentMillis -
1196                                 localCurrentMillis);
1197                         }
1198                     }
1199                 }
1200                 else
1201                 {
1202                     System.out.println(
1203                         "Error submitting MISC WHOAREYOU request to the STAX " +
1204                         "service machine " + fStaxMachineName + ", RC: " +
1205                         whoareyouResult.rc + ", Result: " +
1206                         whoareyouResult.result);
1207                 }
1208             }
1209         }
1210 
1211         // Check what the maximum queue size is set to on the STAX Monitor
1212         // machine and if < MAXQUEUESIZE, increase the maximum queue size
1213         // so that the STAX Monitor handles' queues won't get full and lose
1214         // messages if lots of messages are received when running STAX jobs
1215 
1216         result = fHandle.submit2("local", "MISC", "LIST SETTINGS");
1217 
1218         if (result.rc != 0)
1219         {
1220             JOptionPane.showMessageDialog(
1221                 this, "Error listing STAF settings\n\nRC: " + result.rc +
1222                 "\nResult: " + result.result,
1223                 "Error listing STAF settings", JOptionPane.ERROR_MESSAGE);
1224         }
1225         else
1226         {
1227             try
1228             {
1229                 Map resultMap = (Map)result.resultObj;
1230                 String maxQueueSizeString = (String)resultMap.get(
1231                     "maxQueueSize");
1232 
1233                 int maxQueueSize =
1234                     (new Integer(maxQueueSizeString)).intValue();
1235 
1236                 if (maxQueueSize < MAXQUEUESIZE)
1237                 {
1238                     result = fHandle.submit2(
1239                         "local", "MISC", "SET MAXQUEUESIZE " + MAXQUEUESIZE);
1240 
1241                     if (result.rc != 0)
1242                     {
1243                         JOptionPane.showMessageDialog(
1244                             this, "Error Setting Maximum Queue Size",
1245                             "An error occurred increasing the maximum " +
1246                             "queue size to " + MAXQUEUESIZE +
1247                             "\n\nRC: " + result.rc +
1248                             "\nResult: " + result.result,
1249                             JOptionPane.ERROR_MESSAGE);
1250                     }
1251                 }
1252             }
1253             catch (Exception e)
1254             {
1255                 JOptionPane.showMessageDialog(
1256                     this, "Error Getting Maximum Queue Size",
1257                     "An error occurred getting the maximum queue size. " +
1258                     e.toString(),
1259                     JOptionPane.ERROR_MESSAGE);
1260             }
1261         }
1262 
1263         splash.close();
1264 
1265         fBreakpointTableColumnNames = new Vector();
1266         fBreakpointTableColumnNames.add("Function");
1267         fBreakpointTableColumnNames.add("Line #");
1268         fBreakpointTableColumnNames.add("XML File");
1269         fBreakpointTableColumnNames.add("Machine");
1270 
1271         getContentPane().add(mainPanel);
1272 
1273         ToolTipManager.sharedInstance().setDismissDelay(10000);
1274 
1275         setTitle("STAX 3 Job Monitor");
1276         pack();
1277         setSize(new Dimension(640, 300));
1278         setVisible(true);
1279 
1280         createStartNewJobDialog();
1281         loadJobParms(fLastJobParmsFileName);
1282 
1283         registerForJobEvents();
1284 
1285         Runnable runnable = new Runnable()
1286         {
1287             public void run()
1288             {
1289                 seedExistingJobs();
1290             }
1291         };
1292 
1293         try
1294         {
1295             SwingUtilities.invokeAndWait(runnable);
1296         }
1297         catch (InterruptedException e)
1298         {
1299         }
1300         catch (InvocationTargetException e)
1301         {
1302         }
1303 
1304         if (!jobIDToMonitor.equals(""))
1305         {
1306             repaint();
1307 
1308             synchronized(fActiveJobsModelSorter)
1309             {
1310                 int rows = fActiveJobsTable.getRowCount();
1311                 int rowIndex = -1;
1312 
1313                 for (int r = 0; r < rows; r++)
1314                 {
1315                     String jobNumber =
1316                         ((Integer)fActiveJobsTable.getValueAt
1317                         (r, 0)).toString();
1318 
1319                     if (jobNumber.equals(jobIDToMonitor))
1320                     {
1321                         rowIndex = r;
1322                         break;
1323                     }
1324                 }
1325 
1326                 if (rowIndex == -1)
1327                 {
1328                     STAXMonitorUtil.showErrorDialog(
1329                         this, "JobID " + jobIDToMonitor + " was not found.");
1330                 }
1331                 else
1332                 {
1333                     monitorExistingJob(jobIDToMonitor, rowIndex);
1334                 }
1335             }
1336             repaint();
1337         }
1338 
1339         fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
1340                                     fCurrentJobParmsFile);
1341 
1342         fStartNewJobFileSave.setEnabled(false);
1343 
1344         fWizardSaveButton.addActionListener(this);
1345         fWizardPreviewXMLButton.addActionListener(this);
1346         fWizardCancelButton.addActionListener(this);
1347 
1348         (new Thread(this)).start();
1349 
1350         fElapsedTime = new MonitorElapsedTime();
1351         fElapsedTime.start();
1352 
1353         if (!(fStartNewJobParmFileName.equals("")))
1354         {
1355             File jobParmsFile = new File(fStartNewJobParmFileName);
1356 
1357             if (!jobParmsFile.exists())
1358             {
1359                 STAXMonitorUtil.showErrorDialog(
1360                     this, "Job Parameters File does not exist\n" +
1361                     "File: " + fStartNewJobParmFileName);
1362 
1363                 exit();
1364                 System.exit(0);
1365             }
1366 
1367             if (!(loadJobParms(fStartNewJobParmFileName)))
1368             {
1369                 exit();
1370                 System.exit(0);
1371             }
1372 
1373             submitNewJob();
1374 
1375             fCurrentJobParmsNotSaved = false;
1376             fCurrentJobParmsFile = fStartNewJobParmFileName;
1377 
1378             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
1379                                         fStartNewJobParmFileName);
1380         }
1381     }
1382 
loadExtensions()1383     public void loadExtensions()
1384     {
1385         // Get, Validate, and Load Monitor Extensions before show main panel
1386 
1387         String errorText = "";
1388         STAFResult result;
1389 
1390         result = loadLocalExtensions();
1391 
1392         if (result.rc != 0)
1393         {
1394             if (!errorText.equals(""))
1395                 errorText += "\n\n";
1396 
1397             errorText += "Errors Validating Local Monitor Extensions:" +
1398                          result.result;
1399         }
1400 
1401         result = loadSTAXServiceExtensions();
1402 
1403         if (result.rc != 0)
1404         {
1405             if (!errorText.equals(""))
1406                 errorText += "\n\n";
1407 
1408             errorText += "Errors Validating STAX Service Monitor " +
1409                          "Extensions:" + result.result;
1410         }
1411 
1412         if (!errorText.equals(""))
1413         {
1414             STAXMonitorUtil.showErrorDialog(
1415                 this, errorText, "STAX Monitor Extension Errors");
1416         }
1417 
1418         // Load STAX Registered Monitor Extensions table information
1419 
1420         Iterator iter = fMonitorExtensionMap.entrySet().iterator();
1421 
1422         while (iter.hasNext())
1423         {
1424             Map.Entry entry = (Map.Entry)iter.next();
1425             String extName = (String)entry.getKey();
1426             ExtensionInfo extInfo = (ExtensionInfo)entry.getValue();
1427 
1428             Object rowData[] = new Object[fExtensionsColumns.size()];
1429             rowData[fExtensionsColumns.indexOf(EXT_COLUMN_NAME)] = extName;
1430             rowData[fExtensionsColumns.indexOf(EXT_COLUMN_VERSION)] =
1431                 extInfo.getVersion();
1432 
1433             if (extInfo.getSource() == STAX_SERVICE_EXTENSION)
1434             {
1435                 rowData[fExtensionsColumns.indexOf(EXT_COLUMN_SOURCE)] =
1436                     fStaxMachineName;
1437             }
1438             else
1439             {
1440                 rowData[fExtensionsColumns.indexOf(EXT_COLUMN_SOURCE)] =
1441                     extInfo.getSourceStr();
1442             }
1443 
1444             rowData[fExtensionsColumns.indexOf(EXT_COLUMN_JARFILE)] =
1445                 extInfo.getJarFileName();
1446             rowData[fExtensionsColumns.indexOf(EXT_COLUMN_OVERRIDES)] =
1447                 extInfo.getOverriddenJarFileName();
1448             rowData[fExtensionsColumns.indexOf(EXT_COLUMN_PREREQ)] =
1449                 extInfo.getRequiredMonitorVersion();
1450             rowData[fExtensionsColumns.indexOf(EXT_COLUMN_DESCRIPTION)] =
1451                 extInfo.getDescription();
1452 
1453             fExtensionsTableModel.addRow(rowData);
1454         }
1455 
1456         fExtensionsTable.updateUI();
1457         STAXMonitorUtil.updateRowHeights(fExtensionsTable, 1);
1458         STAXMonitorUtil.sizeColumnsToFitText(fExtensionsTable);
1459     }
1460 
displayMonitorExtensions()1461     public void displayMonitorExtensions()
1462     {
1463 
1464         // Display the registered STAX Monitor Extensions
1465 
1466         StringBuffer output = new StringBuffer(
1467             "\nRegistered STAX Monitor Extensions:\n\n");
1468 
1469         if (!fMonitorExtensionMap.isEmpty())
1470         {
1471             Iterator iter = fMonitorExtensionMap.entrySet().iterator();
1472 
1473             while (iter.hasNext())
1474             {
1475                 Map.Entry entry = (Map.Entry)iter.next();
1476                 String extName = (String)entry.getKey();
1477                 ExtensionInfo extInfo = (ExtensionInfo)entry.getValue();
1478 
1479                 String sourceMachine;
1480                 if (extInfo.getSource() == STAX_SERVICE_EXTENSION)
1481                     sourceMachine = fStaxMachineName;
1482                 else
1483                     sourceMachine = extInfo.getSourceStr();
1484 
1485                 output.append("Monitor Extension     : " + extName +
1486                     "\nVersion               : " + extInfo.getVersion() +
1487                     "\nSource Machine        : " + sourceMachine +
1488                     "\nJar File Name         : " + extInfo.getJarFileName() +
1489                     "\nOverridden Jar File   : " +
1490                     extInfo.getOverriddenJarFileName() +
1491                     "\nMonitor Version Prereq: " +
1492                     extInfo.getRequiredMonitorVersion() +
1493                     "\nDescription           : " + extInfo.getDescription() +
1494                     "\n\n");
1495             }
1496         }
1497         else
1498         {
1499             output.append("None\n\n");
1500         }
1501 
1502         System.out.println(output.toString());
1503     }
1504 
createPropertiesDialog()1505     public void createPropertiesDialog()
1506     {
1507         fPropertiesDialog = new JDialog(this, "STAX Monitor Properties", true);
1508         JPanel propertiesPanel = new JPanel();
1509         propertiesPanel.setLayout(new
1510             BoxLayout(propertiesPanel, BoxLayout.Y_AXIS));
1511 
1512         JTabbedPane propertiesTabbedPane = new JTabbedPane();
1513 
1514         JPanel staxMachinePanel = new JPanel();
1515         staxMachinePanel.setBorder(new TitledBorder("STAX Machine"));
1516         staxMachinePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1517         fStaxMachineNameField = new JTextField(19);
1518         fStaxMachineNameField.setText(fStaxMachineName);
1519         fStaxServiceNameField = new JTextField(7);
1520         fStaxServiceNameField.setText(fStaxServiceName);
1521 
1522         staxMachinePanel.add(Box.createHorizontalStrut(5));
1523         staxMachinePanel.add(new JLabel("Machine: "));
1524         staxMachinePanel.add(fStaxMachineNameField);
1525         staxMachinePanel.add(Box.createHorizontalStrut(5));
1526         staxMachinePanel.add(new JLabel("STAX Service Name: "));
1527         staxMachinePanel.add(fStaxServiceNameField);
1528         staxMachinePanel.add(Box.createHorizontalStrut(5));
1529 
1530         JPanel eventMachinePanel = new JPanel();
1531         eventMachinePanel.setBorder(new TitledBorder("Event Machine"));
1532         eventMachinePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1533         fEventMachineNameField = new JTextField(19);
1534         fEventMachineNameField.setText(fEventMachineName);
1535         fEventMachineNameField.setEditable(false);
1536         fEventServiceNameField = new JTextField(7);
1537         fEventServiceNameField.setText(fEventServiceName);
1538         fEventServiceNameField.setEditable(false);
1539 
1540         eventMachinePanel.add(Box.createHorizontalStrut(5));
1541         eventMachinePanel.add(new JLabel("Machine: "));
1542         eventMachinePanel.add(fEventMachineNameField);
1543         eventMachinePanel.add(Box.createHorizontalStrut(5));
1544         eventMachinePanel.add(new JLabel("Event Service Name: "));
1545         eventMachinePanel.add(fEventServiceNameField);
1546 
1547         JPanel propertiesButtonPanel = new JPanel();
1548         propertiesButtonPanel.setLayout(new
1549             FlowLayout(FlowLayout.CENTER, 0, 0));
1550         propertiesButtonPanel.add(fPropertiesOKButton);
1551         propertiesButtonPanel.add(Box.createHorizontalStrut(20));
1552         propertiesButtonPanel.add(fPropertiesCancelButton);
1553 
1554         fPropertiesOKButton.addActionListener(this);
1555         fPropertiesCancelButton.addActionListener(this);
1556 
1557         // Create Extensions panel
1558 
1559         JPanel extensionsPanel = new JPanel(new GridLayout(1,0));
1560         extensionsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1561         extensionsPanel.setBorder(new TitledBorder("STAX Monitor Extensions"));
1562         extensionsPanel.add(Box.createHorizontalStrut(10));
1563 
1564         fExtensionsColumns = new Vector();
1565         fExtensionsColumns.addElement(EXT_COLUMN_NAME);
1566         fExtensionsColumns.addElement(EXT_COLUMN_VERSION);
1567         fExtensionsColumns.addElement(EXT_COLUMN_SOURCE);
1568         fExtensionsColumns.addElement(EXT_COLUMN_JARFILE);
1569         fExtensionsColumns.addElement(EXT_COLUMN_OVERRIDES);
1570         fExtensionsColumns.addElement(EXT_COLUMN_PREREQ);
1571         fExtensionsColumns.addElement(EXT_COLUMN_DESCRIPTION);
1572 
1573         fExtensionsTableModel = new STAXMonitorTableModel(
1574             fExtensionsColumns, 0);
1575         fExtensionsModelSorter = new STAXMonitorTableSorter(
1576             fExtensionsTableModel, 0);
1577         fExtensionsTable = new JTable(fExtensionsModelSorter);
1578         fExtensionsModelSorter.addMouseListenerToHeaderInTable(
1579             fExtensionsTable, 1);
1580         fExtensionsTable.addMouseListener(this);
1581         fExtensionsTable.getSelectionModel().addListSelectionListener(this);
1582         updateExtensionsTableRenderers();
1583         fExtensionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
1584         fExtensionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1585         fExtensionsTable.setRowSelectionAllowed(true);
1586         STAXMonitorUtil.sizeColumnsToFitText(fExtensionsTable);
1587 
1588         JScrollPane extensionsScrollPane = new JScrollPane(fExtensionsTable);
1589         extensionsScrollPane.setPreferredSize(new Dimension(620,220));
1590         extensionsPanel.add(extensionsScrollPane);
1591 
1592         // Create Extension Jar Files Panel
1593 
1594         fLocalExtJarFiles = new Vector();
1595         JPanel pluginJarsPanel = new JPanel();
1596         pluginJarsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1597         pluginJarsPanel.setBorder(new TitledBorder(
1598             "Local Extension Jar Files"));
1599         pluginJarsPanel.add(Box.createHorizontalStrut(10));
1600 
1601         fPluginJarsList = new JList(fLocalExtJarFiles);
1602         fPluginJarsList.setModel(new DefaultListModel());
1603         fPluginJarsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1604         fPluginJarsList.setCellRenderer(new STAXJobListCellRenderer());
1605         fPluginJarsList.addMouseListener(this);
1606 
1607         JPanel pluginJarsButtonPanel = new JPanel();
1608         pluginJarsButtonPanel.setLayout(new
1609             BoxLayout(pluginJarsButtonPanel, BoxLayout.Y_AXIS));
1610         fPluginJarsAddButton = new JButton("Add...");
1611         fPluginJarsAddButton.addActionListener(this);
1612         fPluginJarsDeleteButton = new JButton("Delete");
1613         fPluginJarsDeleteButton.addActionListener(this);
1614         fPluginJarsDeleteAllButton = new JButton("Delete All");
1615         fPluginJarsDeleteAllButton.addActionListener(this);
1616         pluginJarsButtonPanel.add(fPluginJarsAddButton);
1617         pluginJarsButtonPanel.add(Box.createVerticalStrut(5));
1618         pluginJarsButtonPanel.add(fPluginJarsDeleteButton);
1619         pluginJarsButtonPanel.add(Box.createVerticalStrut(5));
1620         pluginJarsButtonPanel.add(fPluginJarsDeleteAllButton);
1621 
1622         JScrollPane fPluginJarsScrollPane = new JScrollPane(fPluginJarsList);
1623         fPluginJarsScrollPane.setPreferredSize(new Dimension(500,220));
1624 
1625         pluginJarsPanel.add(fPluginJarsScrollPane);
1626         pluginJarsPanel.add(Box.createHorizontalStrut(10));
1627         pluginJarsPanel.add(pluginJarsButtonPanel);
1628 
1629         fAddPluginJarsDialog = new JDialog(this,
1630             "Add Extension Jar File", true);
1631         fAddPluginJarsDialog.setSize(new Dimension(400, 115));
1632         JPanel addPluginJarsPanel = new JPanel();
1633         addPluginJarsPanel.setLayout(new BorderLayout());
1634         fAddPluginJarsTextField = new JTextField(15);
1635         fAddPluginJarsTextField.setBorder(new TitledBorder(
1636             "Enter extension jar file name here"));
1637         addPluginJarsPanel.add(BorderLayout.CENTER,
1638             new JScrollPane(fAddPluginJarsTextField));
1639 
1640         fAddPluginJarsBrowseButton = new JButton("Browse...");
1641         fAddPluginJarsAddButton = new JButton("Add");
1642         fAddPluginJarsCancelButton = new JButton("Cancel");
1643 
1644         JPanel addPluginJarsButtonPanel = new JPanel();
1645         addPluginJarsButtonPanel.setLayout(new
1646             FlowLayout(FlowLayout.CENTER, 0, 0));
1647         addPluginJarsButtonPanel.add(fAddPluginJarsBrowseButton);
1648         addPluginJarsButtonPanel.add(Box.createHorizontalStrut(20));
1649         addPluginJarsButtonPanel.add(fAddPluginJarsAddButton);
1650         addPluginJarsButtonPanel.add(Box.createHorizontalStrut(20));
1651         addPluginJarsButtonPanel.add(fAddPluginJarsCancelButton);
1652 
1653         addPluginJarsPanel.add(BorderLayout.SOUTH, addPluginJarsButtonPanel);
1654 
1655         fAddPluginJarsAddButton.addActionListener(this);
1656         fAddPluginJarsCancelButton.addActionListener(this);
1657         fAddPluginJarsBrowseButton.addActionListener(this);
1658 
1659         fAddPluginJarsDialog.getContentPane().add(addPluginJarsPanel);
1660 
1661         fEditPluginJarsDialog = new JDialog(this,
1662            "Edit Plugin Jar", true);
1663         fEditPluginJarsDialog.setSize(new Dimension(400, 115));
1664         JPanel editPluginJarsPanel = new JPanel();
1665         editPluginJarsPanel.setLayout(new BorderLayout());
1666         fEditPluginJarsTextField = new JTextField(15);
1667         fEditPluginJarsTextField.setBorder(new TitledBorder(
1668             "Update extension jar file name here"));
1669         editPluginJarsPanel.add(BorderLayout.CENTER,
1670                            new JScrollPane(fEditPluginJarsTextField));
1671 
1672         fEditPluginJarsSaveButton = new JButton("Save");
1673         fEditPluginJarsCancelButton = new JButton("Cancel");
1674 
1675         JPanel editPluginJarsButtonPanel = new JPanel();
1676         editPluginJarsButtonPanel.setLayout(new
1677             FlowLayout(FlowLayout.CENTER, 0, 0));
1678         editPluginJarsButtonPanel.add(fEditPluginJarsSaveButton);
1679         editPluginJarsButtonPanel.add(Box.createHorizontalStrut(20));
1680         editPluginJarsButtonPanel.add(fEditPluginJarsCancelButton);
1681 
1682         editPluginJarsPanel.add(BorderLayout.SOUTH, editPluginJarsButtonPanel);
1683 
1684         fEditPluginJarsSaveButton.addActionListener(this);
1685         fEditPluginJarsCancelButton.addActionListener(this);
1686 
1687         fEditPluginJarsDialog.getContentPane().add(editPluginJarsPanel);
1688 
1689         // Create Options panel
1690 
1691         JPanel optionsPanel = new JPanel();
1692         optionsPanel.setBorder(new TitledBorder("Options"));
1693         optionsPanel.setLayout(new BoxLayout(optionsPanel,
1694             BoxLayout.Y_AXIS));
1695 
1696         JPanel displayProcessMonitorPanel = new JPanel();
1697         displayProcessMonitorPanel.setLayout(
1698             new FlowLayout(FlowLayout.LEFT, 0, 0));
1699         JLabel processMonitor = new JLabel("Update Process Monitor "
1700             + "information every  ");
1701         processMonitor.setForeground(Color.black);
1702         displayProcessMonitorPanel.add(processMonitor);
1703 
1704         fProcessMonitorSecondsField = new JTextField(5);
1705         fProcessMonitorSecondsField.setText(fDefaultProcessMonitorSeconds);
1706         displayProcessMonitorPanel.add(fProcessMonitorSecondsField);
1707         JLabel secondsLabel = new JLabel("  seconds");
1708         secondsLabel.setForeground(Color.black);
1709         displayProcessMonitorPanel.add(secondsLabel);
1710 
1711         JPanel displayElapsedTimePanel = new JPanel();
1712         displayElapsedTimePanel.setLayout(
1713             new FlowLayout(FlowLayout.LEFT, 0, 0));
1714         JLabel elapsedTime = new JLabel("Update Elapsed Time " + "every  ");
1715         elapsedTime.setForeground(Color.black);
1716         displayElapsedTimePanel.add(elapsedTime);
1717 
1718         fElapsedTimeSecondsField = new JTextField(5);
1719         fElapsedTimeSecondsField.setText(fDefaultElapsedTimeSeconds);
1720         secondsLabel = new JLabel("  seconds");
1721         secondsLabel.setForeground(Color.black);
1722         displayElapsedTimePanel.add(fElapsedTimeSecondsField);
1723         displayElapsedTimePanel.add(secondsLabel);
1724 
1725         JPanel monitorInfoPanel = new JPanel();
1726         monitorInfoPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1727         monitorInfoPanel.add(fShowNoSTAXMonitorInformation);
1728 
1729         JPanel limitMessagesPanel = new JPanel();
1730         limitMessagesPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1731 
1732         fLimitMessagesField = new JTextField(5);
1733         fLimitMessagesField.setText(fDefaultLimitMessagesText);
1734 
1735         limitMessagesPanel.add(fLimitMessages);
1736         limitMessagesPanel.add(fLimitMessagesField);
1737 
1738         fMessageFontNameCB = new JComboBox();
1739         fLogViewerFontNameCB = new JComboBox();
1740 
1741         // Add the Dialog font name as the first item in the font combo box
1742         // as the first item is the default selection if no selection is made
1743 
1744         fMessageFontNameCB.addItem("Dialog");
1745         fLogViewerFontNameCB.addItem("Dialog");
1746 
1747         // Get the names of all available fonts and add to the font comboboxes
1748 
1749         GraphicsEnvironment env = GraphicsEnvironment.
1750             getLocalGraphicsEnvironment();
1751         String[] fontNames = env.getAvailableFontFamilyNames();
1752 
1753         for (int i = 0; i < fontNames.length; i++)
1754         {            if (!fontNames[i].equals("Dialog"))
1755             {
1756                 fMessageFontNameCB.addItem(fontNames[i]);
1757                 fLogViewerFontNameCB.addItem(fontNames[i]);
1758             }
1759         }
1760 
1761         JPanel messageFontNamePanel = new JPanel();
1762         messageFontNamePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1763         JLabel messageFontName = new JLabel("Messages Font Name:    ");
1764         fMessageFontNameCB.setFont(new Font("Dialog", Font.PLAIN, 12));
1765         fMessageFontNameCB.setBackground(Color.white);
1766         fMessageFontNameCB.addActionListener(this);
1767         messageFontNamePanel.add(messageFontName);
1768         messageFontNamePanel.add(fMessageFontNameCB);
1769 
1770         JPanel logViewerFontNamePanel = new JPanel();
1771         logViewerFontNamePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1772         JLabel logViewerFontName = new JLabel("Log Viewer Font Name:  ");
1773         fLogViewerFontNameCB.setFont(new Font("Dialog", Font.PLAIN, 12));
1774         fLogViewerFontNameCB.setBackground(Color.white);
1775         logViewerFontNamePanel.add(logViewerFontName);
1776         logViewerFontNamePanel.add(fLogViewerFontNameCB);
1777 
1778         JPanel saveAsDirectoryPanel = new JPanel();
1779         saveAsDirectoryPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1780         JLabel saveAsDirectoryLabel = new JLabel(
1781             "Log Viewer Save As Directory:  ");
1782         saveAsDirectoryLabel.setForeground(Color.black);
1783         saveAsDirectoryPanel.add(saveAsDirectoryLabel);
1784 
1785         fSaveAsDirectoryField = new JTextField(20);
1786 
1787         if (fSaveAsDirectory != null)
1788             fSaveAsDirectoryField.setText(fSaveAsDirectory);
1789 
1790         saveAsDirectoryPanel.add(fSaveAsDirectoryField);
1791 
1792         fSaveAsDirectoryBrowseButton = new JButton("Browse...");
1793         fSaveAsDirectoryBrowseButton.addActionListener(this);
1794         saveAsDirectoryPanel.add(Box.createHorizontalStrut(5));
1795         saveAsDirectoryPanel.add(fSaveAsDirectoryBrowseButton);
1796 
1797         JPanel testcasesPanel = new JPanel();
1798         testcasesPanel.setBorder(new TitledBorder("Testcase Options"));
1799         GridBagLayout gbl = new GridBagLayout();
1800         GridBagConstraints gbc = new GridBagConstraints();
1801         testcasesPanel.setLayout(gbl);
1802 
1803         JPanel testcaseDisplayColumnsPanel = new JPanel();
1804         testcaseDisplayColumnsPanel.setLayout(new
1805             FlowLayout(FlowLayout.LEFT));
1806         JLabel testcaseDisplayColumns =
1807             new JLabel("Select the columns that will appear on the " +
1808             "\"Testcase Info\" panel:  ",
1809             SwingConstants.LEFT);
1810         testcaseDisplayColumnsPanel.add(testcaseDisplayColumns);
1811 
1812         gbc.anchor = GridBagConstraints.NORTHWEST;
1813         gbc.gridwidth = 3;
1814         testcasesPanel.add(testcaseDisplayColumnsPanel, gbc);
1815         testcasesPanel.add(Box.createHorizontalStrut(3), gbc);
1816 
1817         JLabel tempLabel = new JLabel("");
1818 
1819         gbc.gridwidth = GridBagConstraints.REMAINDER;
1820         gbc.weightx = 1.0;
1821         testcasesPanel.add(tempLabel, gbc);
1822 
1823         gbc.weightx = 0;
1824         testcasesPanel.add(Box.createVerticalStrut(1), gbc);
1825 
1826         JPanel testcaseColumnsPanel1 = new JPanel();
1827         testcaseColumnsPanel1.setLayout(new
1828             BoxLayout(testcaseColumnsPanel1, BoxLayout.X_AXIS));
1829         fTestcaseNameCB = new JCheckBox("Name", true);
1830         testcaseColumnsPanel1.add(Box.createHorizontalStrut(30), gbc);
1831         testcaseColumnsPanel1.add(fTestcaseNameCB);
1832 
1833         fTestcaseStatusDateTimeCB = new JCheckBox("Status Date-Time", false);
1834         testcaseColumnsPanel1.add(Box.createHorizontalStrut(99), gbc);
1835         testcaseColumnsPanel1.add(fTestcaseStatusDateTimeCB);
1836 
1837         gbc.gridwidth = 1;
1838         gbc.gridwidth = GridBagConstraints.REMAINDER;
1839         testcasesPanel.add(testcaseColumnsPanel1, gbc);
1840         gbc.weightx = 0;
1841         testcasesPanel.add(Box.createVerticalStrut(2), gbc);
1842 
1843         JPanel testcaseColumnsPanel2 = new JPanel();
1844         testcaseColumnsPanel2.setLayout(new
1845             BoxLayout(testcaseColumnsPanel2, BoxLayout.X_AXIS));
1846         fTestcasePassCB = new JCheckBox("PASS", true);
1847         testcaseColumnsPanel2.add(Box.createHorizontalStrut(30), gbc);
1848         testcaseColumnsPanel2.add(fTestcasePassCB);
1849 
1850         fTestcaseDurationCB = new JCheckBox("Duration", true);
1851         testcaseColumnsPanel2.add(Box.createHorizontalStrut(100), gbc);
1852         testcaseColumnsPanel2.add(fTestcaseDurationCB);
1853 
1854         gbc.gridwidth = 1;
1855         gbc.gridwidth = GridBagConstraints.REMAINDER;
1856         testcasesPanel.add(testcaseColumnsPanel2, gbc);
1857         gbc.weightx = 0;
1858         testcasesPanel.add(Box.createVerticalStrut(2), gbc);
1859 
1860         JPanel testcaseColumnsPanel3 = new JPanel();
1861         testcaseColumnsPanel3.setLayout(new
1862             BoxLayout(testcaseColumnsPanel3, BoxLayout.X_AXIS));
1863 
1864         fTestcaseFailCB = new JCheckBox("FAIL", true);
1865         testcaseColumnsPanel3.add(Box.createHorizontalStrut(30), gbc);
1866         testcaseColumnsPanel3.add(fTestcaseFailCB);
1867 
1868         fTestcaseStartsCB = new JCheckBox("Starts", true);
1869         testcaseColumnsPanel3.add(Box.createHorizontalStrut(108), gbc);
1870         testcaseColumnsPanel3.add(fTestcaseStartsCB);
1871 
1872         gbc.gridwidth = 1;
1873         gbc.gridwidth = GridBagConstraints.REMAINDER;
1874         testcasesPanel.add(testcaseColumnsPanel3, gbc);
1875         gbc.weightx = 0;
1876         testcasesPanel.add(Box.createVerticalStrut(2), gbc);
1877 
1878         JPanel testcaseColumnsPanel4 = new JPanel();
1879         testcaseColumnsPanel4.setLayout(new
1880             BoxLayout(testcaseColumnsPanel4, BoxLayout.X_AXIS));
1881 
1882         fTestcaseStartDateTimeCB = new JCheckBox("Start Date-Time", true);
1883         testcaseColumnsPanel4.add(Box.createHorizontalStrut(30), gbc);
1884         testcaseColumnsPanel4.add(fTestcaseStartDateTimeCB);
1885 
1886         fTestcaseInformationCB = new JCheckBox("Information", true);
1887         testcaseColumnsPanel4.add(Box.createHorizontalStrut(43), gbc);
1888         testcaseColumnsPanel4.add(fTestcaseInformationCB);
1889 
1890         gbc.gridwidth = 1;
1891         gbc.gridwidth = GridBagConstraints.REMAINDER;
1892         testcasesPanel.add(testcaseColumnsPanel4, gbc);
1893         gbc.weightx = 0;
1894         testcasesPanel.add(Box.createVerticalStrut(3), gbc);
1895 
1896         fTestcaseNameCB.addActionListener(this);
1897         fTestcasePassCB.addActionListener(this);
1898         fTestcaseFailCB.addActionListener(this);
1899         fTestcaseStartDateTimeCB.addActionListener(this);
1900         fTestcaseStatusDateTimeCB.addActionListener(this);
1901         fTestcaseDurationCB.addActionListener(this);
1902         fTestcaseStartsCB.addActionListener(this);
1903         fTestcaseInformationCB.addActionListener(this);
1904 
1905         JPanel testcaseSortPanel = new JPanel();
1906         testcaseSortPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
1907 
1908         JLabel testcaseSortColumn = new JLabel("Default Sort Column:  ");
1909         fTestcaseSortColumnCB = new JComboBox();
1910         fTestcaseSortColumnCB.setFont(new Font("Dialog", Font.PLAIN, 12));
1911         fTestcaseSortColumnCB.setBackground(Color.white);
1912 
1913         JLabel testcaseSortOrder = new JLabel("  Sort Order:  ");
1914         fTestcaseSortOrderCB = new JComboBox();
1915         fTestcaseSortOrderCB.setFont(new Font("Dialog", Font.PLAIN, 12));
1916         fTestcaseSortOrderCB.setBackground(Color.white);
1917 
1918         fTestcaseSortColumnCB.addItem("Name");
1919         fTestcaseSortColumnCB.addItem("PASS");
1920         fTestcaseSortColumnCB.addItem("FAIL");
1921         fTestcaseSortColumnCB.addItem("Start Date-Time");
1922         fTestcaseSortColumnCB.addItem("Status Date-Time");
1923         fTestcaseSortColumnCB.addItem("Duration");
1924         fTestcaseSortColumnCB.addItem("Starts");
1925         fTestcaseSortColumnCB.addItem("Information");
1926         fTestcaseSortColumnCB.setSelectedIndex(3);
1927 
1928         fTestcaseSortOrderCB.addItem("Ascending");
1929         fTestcaseSortOrderCB.addItem("Descending");
1930 
1931         testcaseSortPanel.add(testcaseSortColumn);
1932         testcaseSortPanel.add(fTestcaseSortColumnCB);
1933         testcaseSortPanel.add(testcaseSortOrder);
1934         testcaseSortPanel.add(fTestcaseSortOrderCB);
1935 
1936         gbc.gridwidth = 1;
1937         gbc.gridwidth = GridBagConstraints.REMAINDER;
1938         testcasesPanel.add(testcaseSortPanel, gbc);
1939         gbc.weightx = 0;
1940         testcasesPanel.add(Box.createVerticalStrut(3), gbc);
1941 
1942         fTestcaseAutoResizeCB = new
1943             JCheckBox("Automatically resize table columns", true);
1944         gbc.gridwidth = 1;
1945         gbc.gridwidth = GridBagConstraints.REMAINDER;
1946         testcasesPanel.add(fTestcaseAutoResizeCB, gbc);
1947         gbc.weightx = 0;
1948         testcasesPanel.add(Box.createVerticalStrut(3), gbc);
1949 
1950         JPanel restoreTestcaseDefaultSettingsPanel = new JPanel();
1951         restoreTestcaseDefaultSettingsPanel.setLayout(new
1952             BoxLayout(restoreTestcaseDefaultSettingsPanel, BoxLayout.Y_AXIS));
1953         JButton restoreTestcaseDefaultSettingsButton =
1954             new JButton("Restore Default Settings");
1955         restoreTestcaseDefaultSettingsPanel.add(Box.createHorizontalStrut(475));
1956         restoreTestcaseDefaultSettingsPanel.add(
1957             restoreTestcaseDefaultSettingsButton);
1958         gbc.gridwidth = 1;
1959         gbc.gridwidth = GridBagConstraints.REMAINDER;
1960         testcasesPanel.add(restoreTestcaseDefaultSettingsPanel, gbc);
1961         gbc.weightx = 0;
1962 
1963         restoreTestcaseDefaultSettingsButton.addActionListener(
1964             new ActionListener()
1965             {
1966                 public void actionPerformed(ActionEvent e)
1967                 {
1968                     fTestcaseNameCB.setSelected(true);
1969                     fTestcasePassCB.setSelected(true);
1970                     fTestcaseFailCB.setSelected(true);
1971                     fTestcaseStartDateTimeCB.setSelected(true);
1972                     fTestcaseStatusDateTimeCB.setSelected(false);
1973                     fTestcaseDurationCB.setSelected(true);
1974                     fTestcaseStartsCB.setSelected(true);
1975                     fTestcaseInformationCB.setSelected(true);
1976                     fTestcaseSortColumnCB.setSelectedIndex(3);
1977                     fTestcaseSortOrderCB.setSelectedIndex(0);
1978                     fTestcaseAutoResizeCB.setSelected(true);
1979                 }
1980             }
1981         );
1982 
1983         optionsPanel.add(displayProcessMonitorPanel);
1984         optionsPanel.add(displayElapsedTimePanel);
1985         optionsPanel.add(monitorInfoPanel);
1986         optionsPanel.add(limitMessagesPanel);
1987         optionsPanel.add(messageFontNamePanel);
1988         optionsPanel.add(logViewerFontNamePanel);
1989         optionsPanel.add(saveAsDirectoryPanel);
1990 
1991         fShowNoSTAXMonitorInformation.addItemListener(this);
1992         fLimitMessages.addItemListener(this);
1993 
1994         JPanel machinePanel = new JPanel();
1995         machinePanel.setLayout(new BoxLayout(machinePanel, BoxLayout.Y_AXIS));
1996         machinePanel.add(staxMachinePanel);
1997         machinePanel.add(eventMachinePanel);
1998 
1999         JPanel subjobsPanel = new JPanel();
2000         subjobsPanel.setBorder(new TitledBorder("Sub-jobs"));
2001         subjobsPanel.setLayout(new BoxLayout(subjobsPanel,
2002             BoxLayout.Y_AXIS));
2003 
2004         fAutoMonitorSubjobsRB = new JRadioButton(
2005             "Automatically monitor sub-jobs", false);
2006         fAutoMonitorRecommendedSubjobsRB = new JRadioButton(
2007             "Automatically monitor recommended sub-jobs", true);
2008         fNeverAutoMonitorSubjobsRB = new JRadioButton(
2009             "Never automatically monitor sub-jobs", false);
2010         fAutoMonitorSubjobsRB.addItemListener(this);
2011         fAutoMonitorRecommendedSubjobsRB.addItemListener(this);
2012         fNeverAutoMonitorSubjobsRB.addItemListener(this);
2013         ButtonGroup monitorSubjobsGroup = new ButtonGroup();
2014         monitorSubjobsGroup.add(fAutoMonitorSubjobsRB);
2015         monitorSubjobsGroup.add(fAutoMonitorRecommendedSubjobsRB);
2016         monitorSubjobsGroup.add(fNeverAutoMonitorSubjobsRB);
2017 
2018         subjobsPanel.add(fAutoMonitorSubjobsRB);
2019         subjobsPanel.add(fAutoMonitorRecommendedSubjobsRB);
2020         subjobsPanel.add(fNeverAutoMonitorSubjobsRB);
2021 
2022         JPanel infoPanel = new JPanel();
2023         infoPanel.setBorder(new TitledBorder("STAX Monitor Info"));
2024         infoPanel.setLayout(new BoxLayout(infoPanel,
2025             BoxLayout.Y_AXIS));
2026 
2027         propertiesTabbedPane.addTab("Machine Info", machinePanel);
2028         propertiesTabbedPane.addTab("Options", optionsPanel);
2029         propertiesTabbedPane.addTab("Testcases", testcasesPanel);
2030         propertiesTabbedPane.addTab("Sub-jobs", subjobsPanel);
2031         propertiesTabbedPane.addTab("Extensions", extensionsPanel);
2032         propertiesTabbedPane.addTab("Extension Jars", pluginJarsPanel);
2033 
2034         // Set tab colors
2035         for (int i = 0; i < propertiesTabbedPane.getTabCount(); i++)
2036         {
2037             if (i == 0)
2038             {
2039                 propertiesTabbedPane.setBackgroundAt(i, Color.lightGray);
2040             }
2041             else
2042             {
2043                 propertiesTabbedPane.setBackgroundAt(i, Color.white);
2044                 propertiesTabbedPane.setForegroundAt(i, Color.darkGray);
2045             }
2046         }
2047 
2048         propertiesPanel.add(new JScrollPane(propertiesTabbedPane));
2049         propertiesPanel.add(propertiesButtonPanel);
2050 
2051         propertiesTabbedPane.addChangeListener(this);
2052 
2053         fPropertiesDialog.setSize(new Dimension(675, 370));
2054         fPropertiesDialog.getContentPane().add(
2055             new JScrollPane(propertiesPanel));
2056     }
2057 
actionPerformed(ActionEvent e)2058     public void actionPerformed(ActionEvent e)
2059     {
2060         if (e.getSource() == fPropertiesCancelButton)
2061         {
2062             fPropertiesDialog.setVisible(false);
2063         }
2064         else if (e.getSource() == fPropertiesOKButton)
2065         {
2066             if (validateProperties())
2067             {
2068                 fStaxMachineName = fStaxMachineNameField.getText();
2069                 fStaxServiceName = fStaxServiceNameField.getText();
2070                 fEventMachineName = fEventMachineNameField.getText();
2071                 fEventServiceName = fEventServiceNameField.getText();
2072 
2073                 fLimitMessagesFieldText = fLimitMessagesField.getText();
2074                 fProcessMonitorSecondsFieldText =
2075                     fProcessMonitorSecondsField.getText();
2076                 fElapsedTimeSecondsFieldText =
2077                     fElapsedTimeSecondsField.getText();
2078 
2079                 fMessageFontName = (String)fMessageFontNameCB.getSelectedItem();
2080 
2081                 fLogViewerFontName = (String)fLogViewerFontNameCB.
2082                     getSelectedItem();
2083 
2084                 fSaveAsDirectory = fSaveAsDirectoryField.getText();
2085 
2086                 fPropertiesDialog.setVisible(false);
2087 
2088                 Endpoint staxEndpoint = new Endpoint(fStaxMachineName);
2089                 fStaxMachineInterface = staxEndpoint.getInterface();
2090                 fStaxMachineIdentifier = staxEndpoint.getMachineIdentifier();
2091                 fStaxMachinePort = staxEndpoint.getPort();
2092 
2093                 resolveMachineNames();
2094 
2095                 fDisplayTestcaseName = fTestcaseNameCB.isSelected();
2096                 fDisplayTestcasePass = fTestcasePassCB.isSelected();
2097                 fDisplayTestcaseFail = fTestcaseFailCB.isSelected();
2098                 fDisplayTestcaseStartDateTime =
2099                     fTestcaseStartDateTimeCB.isSelected();
2100                 fDisplayTestcaseStatusDateTime =
2101                     fTestcaseStatusDateTimeCB.isSelected();
2102                 fDisplayTestcaseDuration = fTestcaseDurationCB.isSelected();
2103                 fDisplayTestcaseStarts = fTestcaseStartsCB.isSelected();
2104                 fDisplayTestcaseInformation =
2105                     fTestcaseInformationCB.isSelected();
2106                 fTestcaseAutoResize = fTestcaseAutoResizeCB.isSelected();
2107                 fTestcaseSortColumn = fTestcaseSortColumnCB.getSelectedIndex();
2108                 fTestcaseSortOrder = fTestcaseSortOrderCB.getSelectedIndex();
2109 
2110                 fAutoMonitorSubjobs = fAutoMonitorSubjobsRB.isSelected();
2111                 fAutoMonitorRecommendedSubjobs =
2112                     fAutoMonitorRecommendedSubjobsRB.isSelected();
2113                 fNeverAutoMonitorSubjobs =
2114                     fNeverAutoMonitorSubjobsRB.isSelected();
2115 
2116                 fLocalExtJarFiles.removeAllElements();
2117 
2118                 if (fUpdatedLocalExtJarFiles != null)
2119                 {
2120                     for (int i = 0; i < fUpdatedLocalExtJarFiles.size(); i++)
2121                     {
2122                         fLocalExtJarFiles.addElement(
2123                             fUpdatedLocalExtJarFiles.elementAt(i));
2124                     }
2125                 }
2126 
2127                 saveProperties();
2128 
2129                 // Check if need to restart Monitor due to a property change
2130 
2131                 boolean restart = false;
2132 
2133                 if (!(fStaxMachineName.equals(fOldStaxMachineName)))
2134                 {
2135                     restart = true;
2136                 }
2137 
2138                 if (!(fStaxServiceName.equals(fOldStaxServiceName)))
2139                 {
2140                     restart = true;
2141                 }
2142 
2143                 if (!(fEventMachineName.equals(fOldEventMachineName)))
2144                 {
2145                     restart = true;
2146                 }
2147 
2148                 if (!(fEventServiceName.equals(fOldEventServiceName)))
2149                 {
2150                     restart = true;
2151                 }
2152 
2153                 if (!(fLocalExtJarFiles.equals(fOldLocalExtJarFiles)))
2154                 {
2155                     restart = true;
2156                 }
2157 
2158                 if (!fPropertiesAtStartup && restart)
2159                 {
2160                     JOptionPane.showMessageDialog(this,
2161                          "You must now shutdown and restart the STAX\n" +
2162                          "Job Monitor to use the updated properties",
2163                          "STAX Monitor Properties Updated",
2164                          JOptionPane.WARNING_MESSAGE);
2165                 }
2166 
2167                 fOldStaxMachineName = fStaxMachineName;
2168                 fOldStaxServiceName = fStaxServiceName;
2169                 fOldEventMachineName = fEventMachineName;
2170                 fOldEventServiceName = fEventServiceName;
2171 
2172                 fOldLocalExtJarFiles = new Vector(fLocalExtJarFiles);
2173             }
2174         }
2175         else if (e.getSource() == fFileExit)
2176         {
2177             exit();
2178             System.exit(0);
2179         }
2180         else if (e.getSource() == fStartNewJobFileExit)
2181         {
2182             repaint();
2183             fStartNewJobDialog.dispose();
2184         }
2185         else if (e.getSource() == fFileProperties)
2186         {
2187             fStaxMachineNameField.setText(fStaxMachineName);
2188             fStaxServiceNameField.setText(fStaxServiceName);
2189             fEventMachineNameField.setText(fEventMachineName);
2190             fEventServiceNameField.setText(fEventServiceName);
2191             fProcessMonitorSecondsField.setText(
2192                 fProcessMonitorSecondsFieldText);
2193             fElapsedTimeSecondsField.setText(
2194                 fElapsedTimeSecondsFieldText);
2195             fShowNoSTAXMonitorInformation.setSelected(
2196                 fShowNoSTAXMonitorInformationBool);
2197             fLimitMessages.setSelected(fLimitMessagesBool);
2198 
2199             if (fLimitMessagesBool)
2200                 fLimitMessagesField.setText(fLimitMessagesFieldText);
2201 
2202             fMessageFontNameCB.setSelectedItem(fMessageFontName);
2203             fLogViewerFontNameCB.setSelectedItem(fLogViewerFontName);
2204 
2205             fTestcaseNameCB.setSelected(fDisplayTestcaseName);
2206             fTestcasePassCB.setSelected(fDisplayTestcasePass);
2207             fTestcaseFailCB.setSelected(fDisplayTestcaseFail);
2208             fTestcaseStartDateTimeCB.setSelected(fDisplayTestcaseStartDateTime);
2209             fTestcaseStatusDateTimeCB.setSelected(fDisplayTestcaseStatusDateTime);
2210             fTestcaseDurationCB.setSelected(fDisplayTestcaseDuration);
2211             fTestcaseStartsCB.setSelected(fDisplayTestcaseStarts);
2212             fTestcaseInformationCB.setSelected(fDisplayTestcaseInformation);
2213             fTestcaseAutoResizeCB.setSelected(fTestcaseAutoResize);
2214             fTestcaseSortColumnCB.setSelectedIndex(fTestcaseSortColumn);
2215             fTestcaseSortOrderCB.setSelectedIndex(fTestcaseSortOrder);
2216 
2217             fAutoMonitorSubjobsRB.setSelected(fAutoMonitorSubjobs);
2218             fAutoMonitorRecommendedSubjobsRB.setSelected(
2219                 fAutoMonitorRecommendedSubjobs);
2220             fNeverAutoMonitorSubjobsRB.setSelected(fNeverAutoMonitorSubjobs);
2221 
2222             DefaultListModel pluginJarsListModel = new DefaultListModel();
2223 
2224             for (int i = 0; i < fLocalExtJarFiles.size(); i++)
2225             {
2226                 pluginJarsListModel.addElement(fLocalExtJarFiles.elementAt(i));
2227             }
2228 
2229             fPluginJarsList.setModel(pluginJarsListModel);
2230 
2231             fSaveAsDirectoryField.setText(fSaveAsDirectory);
2232             fPropertiesCancelButton.setEnabled(true);
2233             fPropertiesDialog.setLocationRelativeTo(this);
2234             fPropertiesDialog.setVisible(true);
2235         }
2236         else if (e.getSource() == fHelpAbout)
2237         {
2238             ImageIcon image = new ImageIcon(splashURL);
2239             SplashScreen splash = new SplashScreen(image, 5000, kSplashText);
2240             splash.run();
2241         }
2242         else if (e.getSource() == fStartNewJobButton)
2243         {
2244             showStartNewJobDialog();
2245         }
2246         else if (e.getSource() == fJobParametersMenuItem)
2247         {
2248             // repaint is needed so that the JMenu will be removed
2249             repaint();
2250             showStartNewJobDialog();
2251         }
2252         else if (e.getSource() == fStartNewJobCancelButton)
2253         {
2254             repaint();
2255             fStartNewJobDialog.dispose();
2256         }
2257         else if ((e.getSource() == fStartNewJobSubmitButton) ||
2258                  (e.getSource() == fSubmitLastJobButton) ||
2259                  (e.getSource() == fStartNewJobMenuItem))
2260         {
2261             if (validateParms("submit"))
2262             {
2263                 fLocalXmlFileName = fLocalXmlFileNameField.getText();
2264                 fOtherXmlFileName = fOtherXmlFileNameField.getText();
2265                 fOtherXmlFileMachineName = fOtherXmlFileMachineField.getText();
2266                 fFunction = fFunctionField.getText();
2267                 fArgs = fArguments.getText();
2268                 fJobName = fJobNameField.getText();
2269                 fScriptFilesMachineName =
2270                     fScriptFilesMachineTextField.getText();
2271 
2272                 fStartNewJobDialog.setVisible(false);
2273 
2274                 if (!submitNewJob())
2275                 {
2276                     fStartNewJobDialog.setVisible(true);
2277                 }
2278             }
2279         }
2280         else if (e.getSource() == fStartNewJobTestButton)
2281         {
2282             if (validateParms("test"))
2283             {
2284                 fLocalXmlFileName = fLocalXmlFileNameField.getText();
2285                 fOtherXmlFileName = fOtherXmlFileNameField.getText();
2286                 fOtherXmlFileMachineName = fOtherXmlFileMachineField.getText();
2287                 fFunction = fFunctionField.getText();
2288                 fArgs = fArguments.getText();
2289                 fJobName = fJobNameField.getText();
2290                 fScriptFilesMachineName =
2291                     fScriptFilesMachineTextField.getText();
2292 
2293                 testJob();
2294             }
2295         }
2296         else if (e.getSource() == fStartNewJobWizardButton)
2297         {
2298             if (validateParms("read"))
2299             {
2300                 displayJobWizard();
2301             }
2302         }
2303         else if (e.getSource() == fStartNewJobClearButton)
2304         {
2305             fJobName = "";
2306             fJobNameField.setText(fJobName);
2307 
2308             fFunction = "";
2309             fFunctionField.setText(fFunction);
2310 
2311             fArgs = "";
2312             fArguments.setText(fArgs);
2313 
2314             fWizardSavedFunctionArgList = new Vector();
2315             fWizardSavedFileName = "";
2316             fWizardSavedFileMachineName = "";
2317 
2318             fLocalXmlFileName = "";
2319             fLocalXmlFileNameField.setText(fLocalXmlFileName);
2320 
2321             fOtherXmlFileMachineName = "";
2322             fOtherXmlFileMachineField.setText(fOtherXmlFileMachineName);
2323 
2324             fOtherXmlFileName = "";
2325             fOtherXmlFileNameField.setText(fOtherXmlFileName);
2326 
2327             fScriptFilesMachineName = "";
2328             fScriptFilesMachineTextField.setText(fScriptFilesMachineName);
2329 
2330             ((DefaultListModel)(fScriptList.getModel())).removeAllElements();
2331             ((DefaultListModel)(fScriptFilesList.getModel())).removeAllElements();
2332 
2333             fMonitorYesRB.setSelected(true);
2334             fMonitorNoRB.setSelected(false);
2335 
2336             fDefaultFunctionRB.setSelected(true);
2337             fOtherFunctionRB.setSelected(false);
2338 
2339             fMachineLocalRB.setSelected(true);
2340             fMachineOtherRB.setSelected(false);
2341 
2342             fLocalScriptMachineRB.setSelected(false);
2343             fXMLJobFileScriptMachineRB.setSelected(true);
2344             fOtherScriptMachineRB.setSelected(false);
2345 
2346             fClearLogsYesRB.setSelected(false);
2347             fClearLogsNoRB.setSelected(false);
2348             fClearLogsDefaultRB.setSelected(true);
2349 
2350             fLogTCElapsedTimeYesRB.setSelected(false);
2351             fLogTCElapsedTimeNoRB.setSelected(false);
2352             fLogTCElapsedTimeDefaultRB.setSelected(true);
2353 
2354             fLogTCNumStartsYesRB.setSelected(false);
2355             fLogTCNumStartsNoRB.setSelected(false);
2356             fLogTCNumStartsDefaultRB.setSelected(true);
2357 
2358             fLogTCStartStopYesRB.setSelected(false);
2359             fLogTCStartStopNoRB.setSelected(false);
2360             fLogTCStartStopDefaultRB.setSelected(true);
2361 
2362             fPythonOutputCB.setSelectedItem(DEFAULT_STRING);
2363             fPythonLogLevelCB.setSelectedItem(DEFAULT_STRING);
2364 
2365             int rowCount = fBreakpointsTableModel.getRowCount();
2366 
2367             for(int i = 0; i < rowCount; i++)
2368             {
2369                 fBreakpointsTableModel.removeRow(0);
2370             }
2371 
2372             fBreakpointFirstFunctionCB.setSelected(false);
2373             fBreakpointSubjobFirstFunctionCB.setSelected(false);
2374 
2375             fCurrentJobParmsNotSaved = true;
2376             fStartNewJobFileSave.setEnabled(true);
2377             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2378                                         fCurrentJobParmsFile + " *");
2379         }
2380         else if (e.getSource() == fBrowseButton)
2381         {
2382             showBrowseFileDialog();
2383         }
2384         else if (e.getSource() == fStartNewJobFileSave)
2385         {
2386             if (fCurrentJobParmsFile.equals(""))
2387             {
2388                 showSaveJobParmsFileDialog();
2389             }
2390             else
2391             {
2392                 saveJobParms(fCurrentJobParmsFile);
2393                 fStartNewJobFileSave.setEnabled(false);
2394                 updateRecentFiles(fCurrentJobParmsFile);
2395                 fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2396                                             fCurrentJobParmsFile);
2397             }
2398         }
2399         else if (e.getSource() == fStartNewJobFileSaveAs)
2400         {
2401             showSaveJobParmsFileDialog();
2402         }
2403         else if (e.getSource() == fStartNewJobFileOpen)
2404         {
2405             showOpenJobParmsFileDialog();
2406         }
2407         else if (e.getSource() == fScriptAddButton)
2408         {
2409             fAddScriptTextArea.setText("");
2410             fAddScriptTextArea.requestFocus();
2411             fAddScriptTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
2412             fAddScriptDialog.setLocationRelativeTo(fStartNewJobDialog);
2413             fAddScriptDialog.setFont(new Font("Monospaced", Font.PLAIN, 12));
2414             fAddScriptDialog.setVisible(true);
2415         }
2416         else if (e.getSource() == fAddScriptAddButton)
2417         {
2418             if (fAddScriptTextArea.getText().equals(""))
2419             {
2420                 JOptionPane.showMessageDialog(fStartNewJobDialog,
2421                                       "You must enter a value for the Script",
2422                                       "Error adding script",
2423                                       JOptionPane.ERROR_MESSAGE);
2424                 return;
2425             }
2426 
2427             ((DefaultListModel)(fScriptList.getModel())).
2428                 addElement(fAddScriptTextArea.getText());
2429             fAddScriptDialog.setVisible(false);
2430 
2431             fCurrentJobParmsNotSaved = true;
2432             fStartNewJobFileSave.setEnabled(true);
2433             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2434                                         fCurrentJobParmsFile + " *");
2435         }
2436         else if (e.getSource() == fAddScriptCancelButton)
2437         {
2438             fAddScriptDialog.setVisible(false);
2439         }
2440         else if (e.getSource() == fEditScriptSaveButton)
2441         {
2442             if (fEditScriptTextArea.getText().equals(""))
2443             {
2444                 JOptionPane.showMessageDialog(fStartNewJobDialog,
2445                                       "You must enter a value for the Script",
2446                                       "Error saving script",
2447                                       JOptionPane.ERROR_MESSAGE);
2448                 return;
2449             }
2450 
2451             int editIndex = fScriptList.getSelectedIndex();
2452             ((DefaultListModel)(fScriptList.getModel())).
2453                 setElementAt(fEditScriptTextArea.getText(), editIndex);
2454             fEditScriptDialog.setVisible(false);
2455 
2456             fCurrentJobParmsNotSaved = true;
2457             fStartNewJobFileSave.setEnabled(true);
2458             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2459                                         fCurrentJobParmsFile + " *");
2460         }
2461         else if (e.getSource() == fEditScriptCancelButton)
2462         {
2463             fEditScriptDialog.setVisible(false);
2464         }
2465         else if (e.getSource() == fScriptDeleteAllButton)
2466         {
2467             int confirmation = JOptionPane.showConfirmDialog(this,
2468                  "Are you certain that you\n" +
2469                  "want to delete all scripts?",
2470                  "Delete All Scripts",
2471                  JOptionPane.YES_NO_OPTION,
2472                  JOptionPane.QUESTION_MESSAGE);
2473 
2474             if (!(confirmation == JOptionPane.YES_OPTION))
2475             {
2476                 return;
2477             }
2478 
2479             ((DefaultListModel)(fScriptList.getModel())).removeAllElements();
2480             fScriptVector.removeAllElements();
2481 
2482             fCurrentJobParmsNotSaved = true;
2483             fStartNewJobFileSave.setEnabled(true);
2484             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2485                                         fCurrentJobParmsFile + " *");
2486         }
2487         else if (e.getSource() == fScriptDeleteButton)
2488         {
2489             int deleteIndex = fScriptList.getSelectedIndex();
2490             if (deleteIndex > -1)
2491             {
2492                 ((DefaultListModel)(fScriptList.getModel())).
2493                     removeElementAt(deleteIndex);
2494                 fScriptVector.removeElementAt(deleteIndex);
2495 
2496                 fCurrentJobParmsNotSaved = true;
2497                 fStartNewJobFileSave.setEnabled(true);
2498                 fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2499                                             fCurrentJobParmsFile + " *");
2500             }
2501         }
2502         else if (e.getSource() == fBreakpointFunctionAddButton)
2503         {
2504             fAddBreakpointFunctionTextField.setText("");
2505             fAddBreakpointFunctionTextField.requestFocus();
2506             fAddBreakpointFunctionTextField.setFont(
2507                 new Font("Dialog", Font.PLAIN, 12));
2508             fAddBreakpointFunctionDialog.setLocationRelativeTo(
2509                 fStartNewJobDialog);
2510             fAddBreakpointFunctionDialog.setFont(
2511                 new Font("Dialog", Font.PLAIN, 12));
2512             fAddBreakpointFunctionDialog.setVisible(true);
2513         }
2514         else if (e.getSource() == fAddBreakpointFunctionAddButton)
2515         {
2516             if (fAddBreakpointFunctionTextField.getText().equals(""))
2517             {
2518                 JOptionPane.showMessageDialog(fStartNewJobDialog,
2519                                       "You must enter a function name",
2520                                       "Error adding breakpoint function",
2521                                       JOptionPane.ERROR_MESSAGE);
2522                 return;
2523             }
2524 
2525             Vector newRow = new Vector();
2526             newRow.add(fAddBreakpointFunctionTextField.getText());
2527             newRow.add("");
2528             newRow.add("");
2529             newRow.add("");
2530 
2531             fBreakpointsTableModel.addRow(newRow);
2532             fAddBreakpointFunctionDialog.setVisible(false);
2533 
2534             STAXMonitorUtil.updateRowHeights(fBreakpointTable, 0);
2535             STAXMonitorUtil.sizeColumnsToFitText(fBreakpointTable);
2536 
2537             fCurrentJobParmsNotSaved = true;
2538             fStartNewJobFileSave.setEnabled(true);
2539             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2540                                         fCurrentJobParmsFile + " *");
2541         }
2542         else if (e.getSource() == fAddBreakpointFunctionCancelButton)
2543         {
2544             fAddBreakpointFunctionDialog.setVisible(false);
2545         }
2546         else if (e.getSource() == fEditBreakpointFunctionSaveButton)
2547         {
2548             if (fEditBreakpointFunctionTextField.getText().equals(""))
2549             {
2550                 JOptionPane.showMessageDialog(fStartNewJobDialog,
2551                                       "You must enter a function name",
2552                                       "Error saving breakpoint function",
2553                                       JOptionPane.ERROR_MESSAGE);
2554                 return;
2555             }
2556 
2557             int editRow = fBreakpointTable.getSelectedRow();
2558             fBreakpointsTableModel.
2559                 setValueAt(fEditBreakpointFunctionTextField.getText().trim(),
2560                            editRow, 0);
2561 
2562             STAXMonitorUtil.updateRowHeights(fBreakpointTable, 0);
2563             STAXMonitorUtil.sizeColumnsToFitText(fBreakpointTable);
2564 
2565             fEditBreakpointFunctionDialog.setVisible(false);
2566 
2567             fCurrentJobParmsNotSaved = true;
2568             fStartNewJobFileSave.setEnabled(true);
2569             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2570                                         fCurrentJobParmsFile + " *");
2571         }
2572         else if (e.getSource() == fEditBreakpointFunctionCancelButton)
2573         {
2574             fEditBreakpointFunctionDialog.setVisible(false);
2575         }
2576         else if (e.getSource() == fBreakpointLineAddButton)
2577         {
2578             fAddBreakpointLineNumberTextField.setText("");
2579             fAddBreakpointLineFileTextField.setText("");
2580             fAddBreakpointLineMachineTextField.setText("");
2581             fAddBreakpointLineNumberTextField.requestFocus();
2582             fAddBreakpointLineNumberTextField.setFont(
2583                 new Font("Dialog", Font.PLAIN, 12));
2584             fAddBreakpointLineDialog.setLocationRelativeTo(
2585                 fStartNewJobDialog);
2586             fAddBreakpointLineDialog.setFont(
2587                 new Font("Dialog", Font.PLAIN, 12));
2588             fAddBreakpointLineDialog.setVisible(true);
2589         }
2590         else if (e.getSource() == fAddBreakpointLineAddButton)
2591         {
2592             if (fAddBreakpointLineNumberTextField.getText().equals(""))
2593             {
2594                 JOptionPane.showMessageDialog(fStartNewJobDialog,
2595                                       "You must enter a line number",
2596                                       "Error adding breakpoint line",
2597                                       JOptionPane.ERROR_MESSAGE);
2598                 return;
2599             }
2600 
2601             Vector newRow = new Vector();
2602             newRow.add("");
2603             newRow.add(fAddBreakpointLineNumberTextField.getText().trim());
2604             newRow.add(fAddBreakpointLineFileTextField.getText().trim());
2605             newRow.add(fAddBreakpointLineMachineTextField.getText().trim());
2606 
2607             fBreakpointsTableModel.addRow(newRow);
2608             fAddBreakpointLineDialog.setVisible(false);
2609 
2610             STAXMonitorUtil.updateRowHeights(fBreakpointTable, 0);
2611             STAXMonitorUtil.sizeColumnsToFitText(fBreakpointTable);
2612 
2613             fCurrentJobParmsNotSaved = true;
2614             fStartNewJobFileSave.setEnabled(true);
2615             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2616                                         fCurrentJobParmsFile + " *");
2617         }
2618         else if (e.getSource() == fAddBreakpointLineCancelButton)
2619         {
2620             fAddBreakpointLineDialog.setVisible(false);
2621         }
2622         else if (e.getSource() == fEditBreakpointLineSaveButton)
2623         {
2624             if (fEditBreakpointLineNumberTextField.getText().equals(""))
2625             {
2626                 JOptionPane.showMessageDialog(fStartNewJobDialog,
2627                                       "You must enter a line number",
2628                                       "Error saving breakpoint line",
2629                                       JOptionPane.ERROR_MESSAGE);
2630                 return;
2631             }
2632 
2633             int editRow = fBreakpointTable.getSelectedRow();
2634             fBreakpointsTableModel.
2635                 setValueAt(fEditBreakpointLineNumberTextField.getText().trim(),
2636                            editRow, 1);
2637             fBreakpointsTableModel.
2638                 setValueAt(fEditBreakpointLineFileTextField.getText().trim(),
2639                            editRow, 2);
2640             fBreakpointsTableModel.
2641                 setValueAt(fEditBreakpointLineMachineTextField.getText().trim(),
2642                            editRow, 3);
2643 
2644             STAXMonitorUtil.updateRowHeights(fBreakpointTable, 0);
2645             STAXMonitorUtil.sizeColumnsToFitText(fBreakpointTable);
2646 
2647             fEditBreakpointLineDialog.setVisible(false);
2648 
2649             fCurrentJobParmsNotSaved = true;
2650             fStartNewJobFileSave.setEnabled(true);
2651             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2652                                         fCurrentJobParmsFile + " *");
2653         }
2654         else if (e.getSource() == fEditBreakpointLineCancelButton)
2655         {
2656             fEditBreakpointLineDialog.setVisible(false);
2657         }
2658         else if (e.getSource() == fBreakpointDeleteAllButton)
2659         {
2660             int confirmation = JOptionPane.showConfirmDialog(this,
2661                  "Are you certain that you\n" +
2662                  "want to delete all breakpoints?",
2663                  "Delete All Functions",
2664                  JOptionPane.YES_NO_OPTION,
2665                  JOptionPane.QUESTION_MESSAGE);
2666 
2667             if (!(confirmation == JOptionPane.YES_OPTION))
2668             {
2669                 return;
2670             }
2671 
2672             STAXMonitorTableSorter model =
2673                 (STAXMonitorTableSorter)fBreakpointTable.getModel();
2674 
2675             int rowCount = fBreakpointsTableModel.getRowCount();
2676 
2677             for(int i = 0; i < rowCount; i++)
2678             {
2679                 fBreakpointsTableModel.removeRow(0);
2680             }
2681 
2682             fCurrentJobParmsNotSaved = true;
2683             fStartNewJobFileSave.setEnabled(true);
2684             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2685                                         fCurrentJobParmsFile + " *");
2686         }
2687         else if (e.getSource() == fBreakpointDeleteButton)
2688         {
2689             int deleteRow = fBreakpointTable.getSelectedRow();
2690 
2691             if (deleteRow > -1)
2692             {
2693                 fBreakpointsTableModel.removeRow(deleteRow);
2694 
2695                 fCurrentJobParmsNotSaved = true;
2696                 fStartNewJobFileSave.setEnabled(true);
2697                 fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
2698                                             fCurrentJobParmsFile + " *");
2699 
2700                 STAXMonitorUtil.updateRowHeights(fBreakpointTable, 0);
2701                 STAXMonitorUtil.sizeColumnsToFitText(fBreakpointTable);
2702             }
2703         }
2704         else if (e.getSource() == fJobShowMonitorMenuItem)
2705         {
2706             synchronized(fMonitorTable)
2707             {
2708                 int rowIndex = fActiveJobsTable.getSelectedRow();
2709 
2710                 if (rowIndex != -1)
2711                 {
2712                     String jobNumber = ((Integer)fActiveJobsTable.getValueAt(
2713                         rowIndex, 0)).toString();
2714 
2715                     if (fMonitorTable.containsKey(jobNumber))
2716                     {
2717                         STAXMonitorFrame monitorFrame =
2718                             (STAXMonitorFrame)fMonitorTable.get(jobNumber);
2719                         monitorFrame.setState(Frame.NORMAL);
2720                         monitorFrame.toFront();
2721                         monitorFrame.requestFocus();
2722                     }
2723                 }
2724                 else
2725                 {
2726                     STAXMonitorUtil.showErrorDialog(
2727                         this, "System busy.  Try again shortly.",
2728                         "System Busy");
2729                 }
2730 
2731                 fJobPopupMenu.setVisible(false);
2732             }
2733         }
2734         else if (e.getSource() == fJobStartMonitorMenuItem)
2735         {
2736             fJobPopupMenu.setVisible(false);
2737 
2738             synchronized(fActiveJobsModelSorter)
2739             {
2740                 int rowIndex = fActiveJobsTable.getSelectedRow();
2741 
2742                 if (rowIndex != -1)
2743                 {
2744                     String jobNumber = ((Integer)fActiveJobsTable.getValueAt(
2745                         rowIndex, 0)).toString();
2746                     monitorExistingJob(jobNumber, rowIndex);
2747                 }
2748                 else
2749                 {
2750                     STAXMonitorUtil.showErrorDialog(
2751                         this, "System busy.  Try again shortly.",
2752                         "System Busy");
2753                 }
2754             }
2755             Dimension size = getSize();
2756             size.width = size.width + 1;
2757             setSize(size);
2758         }
2759         else if (e.getSource() == fJobShowJobLogMenuItem ||
2760                  e.getSource() == fDisplaySelectedJobLog)
2761         {
2762             fJobPopupMenu.setVisible(false);
2763 
2764             synchronized(fActiveJobsModelSorter)
2765             {
2766                 int rowIndex = fActiveJobsTable.getSelectedRow();
2767 
2768                 if (rowIndex != -1)
2769                 {
2770                     String jobNumber = ((Integer)fActiveJobsTable.getValueAt(
2771                         rowIndex, 0)).toString();
2772                     String[] showLogParms = new String[10];
2773                     showLogParms[0] = "-machine";
2774                     showLogParms[1] = fStaxMachineName;
2775                     showLogParms[2] = "-machineNickname";
2776                     showLogParms[3] = fStaxMachineNickname;
2777                     showLogParms[4] = "-name";
2778                     showLogParms[5] = fStaxServiceName.toUpperCase() +
2779                         "_Job_" + jobNumber;
2780                     showLogParms[6] = "-fontName";
2781                     showLogParms[7] = fLogViewerFontName;
2782                     showLogParms[8] = "-saveAsDirectory";
2783                     showLogParms[9] = fSaveAsDirectory;
2784 
2785                     STAXMonitorLogViewer logViewer = new STAXMonitorLogViewer(
2786                         this, fHandle, showLogParms);
2787                 }
2788                 else
2789                 {
2790                     STAXMonitorUtil.showErrorDialog(
2791                         this, "System busy.  Try again shortly.",
2792                         "System Busy");
2793                 }
2794             }
2795 
2796             fJobPopupMenu.setVisible(false);
2797             fJobPopupMenu.updateUI();
2798             getContentPane().invalidate();
2799             getContentPane().repaint();
2800             fJobPopupMenu.setVisible(false);
2801             Dimension size = getSize();
2802             size.width = size.width + 1;
2803             setSize(size);
2804         }
2805         else if (e.getSource() == fDisplayJobLog)
2806         {
2807             fJobPopupMenu.setVisible(false);
2808 
2809             synchronized(fActiveJobsModelSorter)
2810             {
2811                 String jobNumber = JOptionPane.showInputDialog(this,
2812                     "Enter the Job ID", "Display Job Log",
2813                     JOptionPane.QUESTION_MESSAGE);
2814 
2815                 if (jobNumber == null) return;
2816 
2817                 String[] showLogParms = new String[10];
2818                 showLogParms[0] = "-machine";
2819                 showLogParms[1] = fStaxMachineName;
2820                 showLogParms[2] = "-machineNickname";
2821                 showLogParms[3] = fStaxMachineNickname;
2822                 showLogParms[4] = "-name";
2823                 showLogParms[5] = fStaxServiceName.toUpperCase() +
2824                     "_Job_" + jobNumber;
2825                 showLogParms[6] = "-fontName";
2826                 showLogParms[7] = fLogViewerFontName;
2827                 showLogParms[8] = "-saveAsDirectory";
2828                 showLogParms[9] = fSaveAsDirectory;
2829 
2830                 STAXMonitorLogViewer logViewer =
2831                     new STAXMonitorLogViewer(this, fHandle, showLogParms);
2832             }
2833 
2834             fJobPopupMenu.setVisible(false);
2835             fJobPopupMenu.updateUI();
2836             getContentPane().invalidate();
2837             getContentPane().repaint();
2838             fJobPopupMenu.setVisible(false);
2839             Dimension size = getSize();
2840             size.width = size.width + 1;
2841             setSize(size);
2842         }
2843         else if (e.getSource() == fDisplayJobUserLog)
2844         {
2845             fJobPopupMenu.setVisible(false);
2846 
2847             synchronized(fActiveJobsModelSorter)
2848             {
2849                 String jobNumber = JOptionPane.showInputDialog(this,
2850                     "Enter the Job ID", "Display Job User Log",
2851                     JOptionPane.QUESTION_MESSAGE);
2852 
2853                 if (jobNumber == null) return;
2854 
2855                 String[] showLogParms = new String[10];
2856                 showLogParms[0] = "-machine";
2857                 showLogParms[1] = fStaxMachineName;
2858                 showLogParms[2] = "-machineNickname";
2859                 showLogParms[3] = fStaxMachineNickname;
2860                 showLogParms[4] = "-name";
2861                 showLogParms[5] = fStaxServiceName.toUpperCase() +
2862                     "_Job_" + jobNumber + "_User";
2863                 showLogParms[6] = "-fontName";
2864                 showLogParms[7] = fLogViewerFontName;
2865                 showLogParms[8] = "-saveAsDirectory";
2866                 showLogParms[9] = fSaveAsDirectory;
2867 
2868                 STAXMonitorLogViewer logViewer =
2869                     new STAXMonitorLogViewer(this, fHandle, showLogParms);
2870             }
2871 
2872             fJobPopupMenu.setVisible(false);
2873             fJobPopupMenu.updateUI();
2874             getContentPane().invalidate();
2875             getContentPane().repaint();
2876             fJobPopupMenu.setVisible(false);
2877             Dimension size = getSize();
2878             size.width = size.width + 1;
2879             setSize(size);
2880         }
2881         else if (e.getSource() == fJobShowJobUserLogMenuItem ||
2882                  e.getSource() == fDisplaySelectedJobUserLog)
2883         {
2884             fJobPopupMenu.setVisible(false);
2885 
2886             synchronized(fActiveJobsModelSorter)
2887             {
2888                 int rowIndex = fActiveJobsTable.getSelectedRow();
2889 
2890                 if (rowIndex != -1)
2891                 {
2892                     String jobNumber = ((Integer)fActiveJobsTable.getValueAt(
2893                         rowIndex, 0)).toString();
2894                     String[] showLogParms = new String[10];
2895                     showLogParms[0] = "-machine";
2896                     showLogParms[1] = fStaxMachineName;
2897                     showLogParms[2] = "-machineNickname";
2898                     showLogParms[3] = fStaxMachineNickname;
2899                     showLogParms[4] = "-name";
2900                     showLogParms[5] = fStaxServiceName.toUpperCase() +
2901                         "_Job_" + jobNumber + "_User";
2902                     showLogParms[6] = "-fontName";
2903                     showLogParms[7] = fLogViewerFontName;
2904                     showLogParms[8] = "-saveAsDirectory";
2905                     showLogParms[9] = fSaveAsDirectory;
2906 
2907                     STAXMonitorLogViewer logViewer = new STAXMonitorLogViewer(
2908                         this, fHandle, showLogParms);
2909                 }
2910                 else
2911                 {
2912                     STAXMonitorUtil.showErrorDialog(
2913                         this, "System busy.  Try again shortly.",
2914                         "System Busy");
2915                 }
2916             }
2917 
2918             fJobPopupMenu.setVisible(false);
2919             fJobPopupMenu.updateUI();
2920             Dimension size = getSize();
2921             size.width = size.width + 1;
2922             setSize(size);
2923         }
2924         else if (e.getSource() == fJobShowSTAXServiceLogMenuItem ||
2925                  e.getSource() == fDisplayServiceLog)
2926         {
2927             fJobPopupMenu.setVisible(false);
2928 
2929             synchronized(fActiveJobsModelSorter)
2930             {
2931                 String[] showLogParms = new String[10];
2932                 showLogParms[0] = "-machine";
2933                 showLogParms[1] = fStaxMachineName;
2934                 showLogParms[2] = "-machineNickname";
2935                 showLogParms[3] = fStaxMachineNickname;
2936                 showLogParms[4] = "-name";
2937                 showLogParms[5] = fStaxServiceName.toUpperCase() + "_Service";
2938                 showLogParms[6] = "-fontName";
2939                 showLogParms[7] = fLogViewerFontName;
2940                 showLogParms[8] = "-saveAsDirectory";
2941                 showLogParms[9] = fSaveAsDirectory;
2942 
2943                 STAXMonitorLogViewer logViewer =
2944                     new STAXMonitorLogViewer(this, fHandle, showLogParms);
2945             }
2946 
2947             fJobPopupMenu.setVisible(false);
2948             fJobPopupMenu.updateUI();
2949             Dimension size = getSize();
2950             size.width = size.width + 1;
2951             setSize(size);
2952         }
2953         else if (e.getSource() == fJobShowSTAXJVMLogMenuItem ||
2954                  e.getSource() == fDisplaySTAXJVMLog)
2955         {
2956             fJobPopupMenu.setVisible(false);
2957 
2958             synchronized(fActiveJobsModelSorter)
2959             {
2960                 // Display just the JVM log for the current JVM
2961                 boolean displayAll = false;
2962 
2963                 // Use Monospaced for the default font name instead of
2964                 // fLogViewerFontName.
2965 
2966                 STAFJVMLogViewer logViewer = new STAFJVMLogViewer(
2967                     this, fHandle, fStaxMachineName, fStaxServiceName,
2968                     displayAll, "Monospaced");
2969             }
2970 
2971             fJobPopupMenu.setVisible(false);
2972             fJobPopupMenu.updateUI();
2973             Dimension size = getSize();
2974             size.width = size.width + 1;
2975             setSize(size);
2976         }
2977         else if (e.getSource() == fJobShowOtherJVMLogMenuItem ||
2978                  e.getSource() == fDisplayOtherJVMLog)
2979         {
2980             fJobPopupMenu.setVisible(false);
2981 
2982             synchronized(fActiveJobsModelSorter)
2983             {
2984                 // Ask for the Machine where the service whose JVMLog you
2985                 // want to browse is located (defaults to local).
2986                 // If just whitespace for the machine, you're prompted again
2987                 // until you enter a machine name or press Cancel.
2988 
2989                 Object machineValue = new String("");
2990 
2991                 while (machineValue.toString().trim().length() == 0)
2992                 {
2993                     machineValue = JOptionPane.showInputDialog(
2994                         this,
2995                         "Enter the machine where the service whose " +
2996                         "JVM Log\n you want to display is registered",
2997                         "Enter the Java Service machine",
2998                         JOptionPane.INFORMATION_MESSAGE, null, null,
2999                         // Set initialValue parameter to fStaxMachineName
3000                         fStaxMachineName);
3001 
3002                     if (machineValue == null)
3003                         return;  // Cancel button was selected
3004                 }
3005 
3006                 String machine = (String)machineValue;
3007 
3008                 // Display a list of the Java services registered on the
3009                 // specified machine
3010                 String service = "";
3011 
3012                 // Display just the JVM log for the current JVM
3013                 boolean displayAll = false;
3014 
3015                 STAFJVMLogViewer logViewer = new STAFJVMLogViewer(
3016                     this, fHandle, machine, service,
3017                     displayAll, fLogViewerFontName);
3018             }
3019 
3020             fJobPopupMenu.setVisible(false);
3021             fJobPopupMenu.updateUI();
3022             Dimension size = getSize();
3023             size.width = size.width + 1;
3024             setSize(size);
3025         }
3026         else if (e.getSource() == fSaveAsDirectoryBrowseButton)
3027         {
3028             DirectoryFilter filter = new DirectoryFilter();
3029             JFileChooser fileChooser = new JFileChooser(fSaveAsDirectory);
3030             fileChooser.setFileFilter(filter);
3031             fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
3032             fileChooser.setAcceptAllFileFilterUsed(false);
3033 
3034             fileChooser.setDialogTitle("Select a Directory");
3035             int rc = fileChooser.showDialog(this, "Select this Directory");
3036 
3037             if (rc == JFileChooser.APPROVE_OPTION)
3038             {
3039                 try
3040                 {
3041                     fSaveAsDirectoryField.setText(
3042                         fileChooser.getSelectedFile().getCanonicalPath());
3043                 }
3044                 catch (IOException ex)
3045                 {
3046                     ex.printStackTrace();
3047                 }
3048             }
3049         }
3050         else if (e.getSource() == fJobTerminateJobMenuItem)
3051         {
3052             fJobPopupMenu.setVisible(false);
3053 
3054             synchronized(fActiveJobsModelSorter)
3055             {
3056                 int rowIndex = fActiveJobsTable.getSelectedRow();
3057 
3058                 if (rowIndex != -1)
3059                 {
3060                     String jobNumber = ((Integer)fActiveJobsTable.getValueAt(
3061                         rowIndex, 0)).toString();
3062 
3063                     int confirmation = JOptionPane.showConfirmDialog(
3064                         this, "Are you certain that you want\n" +
3065                         "to terminate Job ID " + jobNumber + " ?",
3066                         "Confirm Job Termination",
3067                         JOptionPane.YES_NO_OPTION,
3068                         JOptionPane.QUESTION_MESSAGE);
3069 
3070                     if (!(confirmation == JOptionPane.YES_OPTION))
3071                     {
3072                         return;
3073                     }
3074 
3075                     String request = "TERMINATE JOB " + jobNumber;
3076 
3077                     STAFResult result = fHandle.submit2(
3078                         fStaxMachineName, fStaxServiceName, request);
3079 
3080                     if (result.rc != 0)
3081                     {
3082                         STAXMonitorUtil.showErrorDialog(
3083                             this, "An error was encountered while " +
3084                             "attempting to terminate Job ID " + jobNumber +
3085                             ".\n\nRC: " + result.rc +
3086                             "\nResult: " + result.result);
3087                     }
3088                 }
3089                 else
3090                 {
3091                     STAXMonitorUtil.showErrorDialog(
3092                         this, "System busy.  Try again shortly.",
3093                         "System Busy");
3094                 }
3095             }
3096             Dimension size = getSize();
3097             size.width = size.width + 1;
3098             setSize(size);
3099         }
3100         else if (e.getSource() == fPluginJarsAddButton)
3101         {
3102             fAddPluginJarsTextField.setText("");
3103             fAddPluginJarsTextField.requestFocus();
3104             fAddPluginJarsDialog.setLocationRelativeTo(this);
3105             fAddPluginJarsDialog.setVisible(true);
3106         }
3107         else if (e.getSource() == fAddPluginJarsAddButton)
3108         {
3109             String pluginJarName = fAddPluginJarsTextField.getText();
3110             File pluginJarFile = new File(pluginJarName);
3111 
3112             // Make sure plugin jar file exists
3113 
3114             if (!(pluginJarFile.exists()))
3115             {
3116                 STAXMonitorUtil.showErrorDialog(
3117                     fAddPluginJarsDialog,
3118                     "Extension Jar File does not exist\n" +
3119                     "File: " + pluginJarName);
3120             }
3121 
3122             // Make sure plugin jar file not already present
3123             else if (fLocalExtJarFiles.contains(pluginJarName))
3124             {
3125                 STAXMonitorUtil.showErrorDialog(
3126                     fAddPluginJarsDialog,
3127                     "Extension Jar File cannot be added more than once\n" +
3128                     "File: " + pluginJarName);
3129             }
3130             else
3131             {
3132                 ((DefaultListModel)(fPluginJarsList.getModel())).
3133                     addElement(fAddPluginJarsTextField.getText());
3134 
3135                 fUpdatedLocalExtJarFiles.addElement(pluginJarName);
3136                 fAddPluginJarsDialog.setVisible(false);
3137             }
3138         }
3139         else if (e.getSource() == fAddPluginJarsCancelButton)
3140         {
3141             fAddPluginJarsDialog.setVisible(false);
3142         }
3143         else if (e.getSource() == fEditPluginJarsSaveButton)
3144         {
3145             int editIndex = fPluginJarsList.getSelectedIndex();
3146 
3147             String pluginJarName = fEditPluginJarsTextField.getText();
3148             File pluginJarFile = new File(pluginJarName);
3149 
3150             if (!(pluginJarFile.exists()))
3151             {
3152                 STAXMonitorUtil.showErrorDialog(
3153                     fEditPluginJarsDialog,
3154                     "Extension Jar File does not exist\n" +
3155                     "File: " + pluginJarName);
3156             }
3157             else
3158             {
3159                 ((DefaultListModel)(fPluginJarsList.getModel())).
3160                     setElementAt(fEditPluginJarsTextField.getText(),
3161                     editIndex);
3162 
3163                 fUpdatedLocalExtJarFiles.setElementAt(pluginJarName, editIndex);
3164                 fEditPluginJarsDialog.setVisible(false);
3165             }
3166         }
3167         else if (e.getSource() == fEditPluginJarsCancelButton)
3168         {
3169             fEditPluginJarsDialog.setVisible(false);
3170         }
3171         else if (e.getSource() == fPluginJarsDeleteAllButton)
3172         {
3173             int confirmation = JOptionPane.showConfirmDialog(this,
3174                  "Are you certain that you\n" +
3175                  "want to delete all plugin jar files?",
3176                  "Delete All Plugin Jar Files",
3177                  JOptionPane.YES_NO_OPTION,
3178                  JOptionPane.QUESTION_MESSAGE);
3179 
3180             if (!(confirmation == JOptionPane.YES_OPTION))
3181             {
3182                 return;
3183             }
3184 
3185             ((DefaultListModel)(fPluginJarsList.getModel())).
3186                 removeAllElements();
3187             fUpdatedLocalExtJarFiles.removeAllElements();
3188         }
3189         else if (e.getSource() == fPluginJarsDeleteButton)
3190         {
3191             int deleteIndex = fPluginJarsList.getSelectedIndex();
3192             if (deleteIndex > -1)
3193             {
3194                 ((DefaultListModel)(fPluginJarsList.getModel())).
3195                     removeElementAt(deleteIndex);
3196                 fUpdatedLocalExtJarFiles.removeElementAt(deleteIndex);
3197             }
3198         }
3199         else if (e.getSource() == fAddPluginJarsBrowseButton)
3200         {
3201             STAXMonitorFileFilter filter = new STAXMonitorFileFilter();
3202             filter.addExtension("jar");
3203             JFileChooser jarFileChooser = new JFileChooser(fLastFileDirectory);
3204             jarFileChooser.setFileFilter(filter);
3205             jarFileChooser.setDialogTitle("Select a Plugin Jar File");
3206             int rc = jarFileChooser.showDialog(this,
3207                 "Select this Plugin Jar File");
3208 
3209             if (rc == JFileChooser.APPROVE_OPTION)
3210             {
3211                 try
3212                 {
3213                     fAddPluginJarsTextField.setText(
3214                         jarFileChooser.getSelectedFile().getCanonicalPath());
3215                     fLastFileDirectory = jarFileChooser.getCurrentDirectory();
3216 
3217                 }
3218                 catch (IOException ex)
3219                 {
3220                     ex.printStackTrace();
3221                 }
3222             }
3223         }
3224         else if (e.getSource() == fScriptFilesAddButton)
3225         {
3226             fAddScriptFilesTextField.setText("");
3227             fAddScriptFilesTextField.requestFocus();
3228             fAddScriptFilesDialog.setLocationRelativeTo(this);
3229             fAddScriptFilesDialog.setVisible(true);
3230         }
3231         else if (e.getSource() == fAddScriptFilesAddButton)
3232         {
3233             if (fAddScriptFilesTextField.getText().equals(""))
3234             {
3235                 JOptionPane.showMessageDialog(fStartNewJobDialog,
3236                     "You must enter a value for the Script File name",
3237                     "Error adding script file", JOptionPane.ERROR_MESSAGE);
3238                 return;
3239             }
3240 
3241             ((DefaultListModel)(fScriptFilesList.getModel())).
3242                addElement(fAddScriptFilesTextField.getText());
3243             fScriptFilesVector.addElement(fAddScriptFilesTextField.getText());
3244             fAddScriptFilesDialog.setVisible(false);
3245         }
3246         else if (e.getSource() == fAddScriptFilesCancelButton)
3247         {
3248             fAddScriptFilesDialog.setVisible(false);
3249         }
3250         else if (e.getSource() == fEditScriptFilesSaveButton)
3251         {
3252             if (fEditScriptFilesTextField.getText().equals(""))
3253             {
3254                 JOptionPane.showMessageDialog(fStartNewJobDialog,
3255                     "You must enter a value for the Script File name",
3256                     "Error saving script file", JOptionPane.ERROR_MESSAGE);
3257                 return;
3258             }
3259 
3260             int editIndex = fScriptFilesList.getSelectedIndex();
3261             ((DefaultListModel)(fScriptFilesList.getModel())).
3262                 setElementAt(fEditScriptFilesTextField.getText(), editIndex);
3263             fEditScriptFilesDialog.setVisible(false);
3264 
3265         }
3266         else if (e.getSource() == fEditScriptFilesCancelButton)
3267         {
3268             fEditScriptFilesDialog.setVisible(false);
3269         }
3270         else if (e.getSource() == fScriptFilesDeleteAllButton)
3271         {
3272             int confirmation = JOptionPane.showConfirmDialog(this,
3273                  "Are you certain that you\n" +
3274                  "want to delete all script files?",
3275                  "Delete All Script Files",
3276                  JOptionPane.YES_NO_OPTION,
3277                  JOptionPane.QUESTION_MESSAGE);
3278 
3279             if (!(confirmation == JOptionPane.YES_OPTION))
3280             {
3281                 return;
3282             }
3283 
3284             ((DefaultListModel)(fScriptFilesList.getModel())).
3285                 removeAllElements();
3286             fScriptFilesVector.removeAllElements();
3287         }
3288         else if (e.getSource() == fScriptFilesDeleteButton)
3289         {
3290             int deleteIndex = fScriptFilesList.getSelectedIndex();
3291             if (deleteIndex > -1)
3292             {
3293                 ((DefaultListModel)(fScriptFilesList.getModel())).
3294                     removeElementAt(deleteIndex);
3295                 fScriptFilesVector.removeElementAt(deleteIndex);
3296             }
3297         }
3298         else if (e.getSource() == fAddScriptFilesBrowseButton)
3299         {
3300             JFileChooser scriptFilesChooser = new
3301                 JFileChooser(fLastFileDirectory);
3302             scriptFilesChooser.setDialogTitle("Select a Script File");
3303             int rc = scriptFilesChooser.showDialog(this,
3304                 "Select this Script File");
3305 
3306             if (rc == JFileChooser.APPROVE_OPTION)
3307             {
3308                 try
3309                 {
3310                     fAddScriptFilesTextField.setText(
3311                         scriptFilesChooser.getSelectedFile().
3312                         getCanonicalPath());
3313                     fLastFileDirectory =
3314                         scriptFilesChooser.getCurrentDirectory();
3315                 }
3316                 catch (IOException ex)
3317                 {
3318                     ex.printStackTrace();
3319                 }
3320             }
3321         }
3322         else if (e.getSource() == fWizardSaveButton)
3323         {
3324             String function = (String)
3325                 fWizardFunctionsList.getSelectedValue();
3326 
3327             if (function.indexOf("(default)") > -1)
3328             {
3329                 function = function.substring(0, function.indexOf(" "));
3330             }
3331 
3332             fWizardSavedFunctionName = function;
3333             fWizardSavedFileName = fWizardFileName;
3334             fWizardSavedFileMachineName = fWizardFileMachineName;
3335 
3336             String functionType = (String)
3337                 fWizardFunctionTypeMap.get(function);
3338 
3339             JTable table = (JTable)
3340                 fWizardFunctionArgTableMap.get(function);
3341 
3342             if (!verifyRequiredArguments(table))
3343             {
3344                 STAXMonitorUtil.showErrorDialog(
3345                     fWizardDialog, "A value must be specified " +
3346                     "for all required arguments");
3347                 return;
3348             }
3349 
3350             int confirmation = JOptionPane.showConfirmDialog(fWizardDialog,
3351                  "Are you certain that you want\n" +
3352                  "to save the job wizard options?\n" +
3353                  "This will overwrite existing\n" +
3354                  "options in the STAX Monitor.",
3355                  "Save Job Wizard Options",
3356                  JOptionPane.YES_NO_OPTION,
3357                  JOptionPane.QUESTION_MESSAGE);
3358 
3359             if (!(confirmation == JOptionPane.YES_OPTION))
3360             {
3361                 return;
3362             }
3363 
3364             int rows = table.getRowCount();
3365 
3366             fWizardDialog.dispose();
3367 
3368             fFunction = function;
3369             fFunctionField.setText(function);
3370             fOtherFunctionRB.setSelected(true);
3371 
3372             fWizardSavedFunctionArgList.removeAllElements();
3373 
3374             if (functionType.equalsIgnoreCase("None"))
3375             {
3376                 fArgs = "";
3377                 fArguments.setText("");
3378             }
3379             else if (functionType.equalsIgnoreCase("Undefined"))
3380             {
3381                 fWizardSavedFunctionArgList.removeAllElements();
3382 
3383                 String arguments = "";
3384 
3385                 String staxArgValue =
3386                     ((ArgumentValue)table.getValueAt(0, 3)).getString();
3387 
3388                 if (!staxArgValue.equals(""))
3389                 {
3390                     fWizardSavedFunctionArgList.add(staxArgValue);
3391                     arguments += staxArgValue;
3392                 }
3393 
3394                 fArgs = arguments;
3395                 fArguments.setText(arguments);
3396             }
3397             else if (functionType.equalsIgnoreCase("Single"))
3398             {
3399                 fWizardSavedFunctionArgList.removeAllElements();
3400 
3401                 String arguments = (String)table.getValueAt(0, 3);
3402                 fWizardSavedFunctionArgList.add(arguments);
3403 
3404                 fArgs = arguments;
3405                 fArguments.setText(arguments);
3406             }
3407             else if (functionType.equalsIgnoreCase("List"))
3408             {
3409                 fWizardSavedFunctionArgList.removeAllElements();
3410 
3411                 StringBuffer arguments = new StringBuffer("[\n  ");
3412 
3413                 Vector argDefaults = (Vector)
3414                 fWizardFunctionArgDefaultsMap.get(function);
3415 
3416                 // Determine the last item that will be specified in this list.
3417                 // All arguments prior to the last item must be included.
3418 
3419                 int lastindex = -1;
3420 
3421                 for (int i = 0; i < rows; i++)
3422                 {
3423                     String required =
3424                         ((ArgumentRequired)table.getValueAt(i, 2)).getString();
3425 
3426                     String value =
3427                         ((ArgumentValue)table.getValueAt(i, 3)).getString();
3428 
3429                     fWizardSavedFunctionArgList.add(value);
3430 
3431                     if ( (required.equals("Yes")) ||
3432                          (required.equals("No") &&
3433                           !(((String)argDefaults.get(i)).equals(value))) ||
3434                          (required.equals("Other") && !value.equals("")) )
3435                     {
3436                         lastindex = i;
3437                     }
3438                 }
3439 
3440                 for (int i = 0; i <= lastindex; i++)
3441                 {
3442                     String value =
3443                         ((ArgumentValue)table.getValueAt(i, 3)).getString();
3444 
3445                     if (i > 0)
3446                         arguments.append(",\n  ");
3447 
3448                     arguments.append(value);
3449                 }
3450 
3451                 arguments.append("\n]");
3452 
3453                 fArgs = arguments.toString();
3454                 fArguments.setText(fArgs);
3455             }
3456             else if (functionType.equalsIgnoreCase("Map"))
3457             {
3458                 fWizardSavedFunctionArgList.removeAllElements();
3459 
3460                 StringBuffer arguments = new StringBuffer("{\n  ");
3461                 int numArgs = 0;
3462 
3463                 Vector argDefaults = (Vector)
3464                     fWizardFunctionArgDefaultsMap.get(function);
3465 
3466                 for (int i = 0; i < rows; i++)
3467                 {
3468                     String required =
3469                         ((ArgumentRequired)table.getValueAt(i, 2)).getString();
3470 
3471                     String value =
3472                         ((ArgumentValue)table.getValueAt(i, 3)).getString();
3473 
3474                     fWizardSavedFunctionArgList.add(value);
3475 
3476                     if ( ( required.equals("Yes")) ||
3477                          ( required.equals("No") &&
3478                            !((String)argDefaults.get(i)).equals(value) ) ||
3479                          ( required.equals("Other") && !value.equals("") ) )
3480                     {
3481                         if (numArgs > 0) arguments.append(",\n  ");
3482 
3483                         if (!required.equals("Other"))
3484                         {
3485                             arguments.append("'");
3486                             arguments.append(table.getValueAt(i, 0));
3487                             arguments.append("': ");
3488                         }
3489 
3490                         arguments.append(value);
3491 
3492                         numArgs++;
3493                     }
3494                 }
3495 
3496                 arguments.append("\n}");
3497 
3498                 fArgs = arguments.toString();
3499                 fArguments.setText(fArgs);
3500             }
3501 
3502             if (!fArguments.getText().equals(""))
3503             {
3504                 fArguments.setEnabled(false);
3505                 fArgumentsEnabled = false;
3506             }
3507             else
3508             {
3509                 fArguments.setEnabled(true);
3510                 fArgumentsEnabled = true;
3511             }
3512 
3513             return;
3514         }
3515         else if (e.getSource() == fWizardPreviewXMLButton)
3516         {
3517             previewWizardXML();
3518         }
3519         else if (e.getSource() == fWizardCancelButton)
3520         {
3521             fWizardDialog.dispose();
3522         }
3523         else if (e.getSource() == fWizardDetailsButton)
3524         {
3525             displayJobWizardDetails();
3526         }
3527         else if (e.getSource() == fClearArguments)
3528         {
3529             fArguments.setEnabled(true);
3530             fArguments.setText("");
3531             fWizardSavedFunctionArgList = new Vector();
3532             fArgumentsEnabled = true;
3533         }
3534         else
3535         {
3536             for (int i=0; i< fRecentFiles.size(); i++)
3537             {
3538                 if (e.getSource() == fRecentFileMenuItems[i])
3539                 {
3540                     String fileName = fRecentFileMenuItems[i].getText();
3541                     loadJobParms(fileName);
3542                     fCurrentJobParmsNotSaved = false;
3543                     fCurrentJobParmsFile = fileName;
3544                     fStartNewJobFileSave.setEnabled(false);
3545                     fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
3546                         fileName);
3547                     updateRecentFiles(fileName);
3548                 }
3549             }
3550 
3551             for (int i=0; i< fRecentLogs.size(); i++)
3552             {
3553                 if (e.getSource() == fRecentLogsMenuItems[i])
3554                 {
3555                     String logName = fRecentLogsMenuItems[i].getText();
3556 
3557                     String[] showLogParms = new String[10];
3558                     showLogParms[0] = "-machine";
3559                     showLogParms[1] = fStaxMachineName;
3560                     showLogParms[2] = "-machineNickname";
3561                     showLogParms[3] = fStaxMachineNickname;
3562                     showLogParms[4] = "-name";
3563                     showLogParms[5] = logName;
3564                     showLogParms[6] = "-fontName";
3565                     showLogParms[7] = fLogViewerFontName;
3566                     showLogParms[8] = "-saveAsDirectory";
3567                     showLogParms[9] = fSaveAsDirectory;
3568 
3569                     STAXMonitorLogViewer logViewer =
3570                         new STAXMonitorLogViewer(this, fHandle, showLogParms);
3571                 }
3572             }
3573        }
3574     }
3575 
displayJobWizard()3576     public void displayJobWizard()
3577     {
3578         StringBuffer request = new StringBuffer();
3579 
3580         if (fMachineLocalRB.isSelected())
3581         {
3582             fWizardFileMachineName = "";
3583             fWizardFileName = fLocalXmlFileNameField.getText();
3584             request.append("EXECUTE FILE ").append(
3585                 STAFUtil.wrapData(fWizardFileName));
3586         }
3587         else
3588         {
3589             fWizardFileMachineName = fOtherXmlFileMachineField.getText();
3590             fWizardFileName = fOtherXmlFileNameField.getText();
3591             request.append("EXECUTE FILE ").append(
3592                 STAFUtil.wrapData(fWizardFileName));
3593             request.append(" MACHINE ").append(
3594                 STAFUtil.wrapData(fWizardFileMachineName));
3595         }
3596 
3597         request.append(" TEST RETURNDETAILS");
3598 
3599         // Submit the STAX EXECUTE request and display a "Please Wait" dialog
3600         // while the request is running
3601 
3602         STAXMonitorExecuteResult executeResult = submitExecuteRequest(
3603             request.toString());
3604 
3605         if (executeResult.getRC() != STAFResult.Ok)
3606         {
3607             STAXMonitorUtil.showErrorDialog(
3608                 fStartNewJobDialog,
3609                 executeResult.getResult().toString(),
3610                 new Font("Courier", Font.PLAIN, 12));
3611 
3612             return;
3613         }
3614 
3615         // A successful STAX EXECUTE TEST RETURNDETAILS request returns
3616         // a STAFMarshallingContext in the marshalled result that contains
3617         // detailed information about the functions in the xml file
3618 
3619         STAFMarshallingContext mc =
3620             (STAFMarshallingContext)executeResult.getResult();
3621 
3622         Map jobDetailsMap = (Map)mc.getRootObject();
3623 
3624         TreeSet functions = new TreeSet();
3625         fWizardFunctionMap = new HashMap();
3626         fWizardFunctionTypeMap = new HashMap();
3627         fWizardFunctionPrologMap = new HashMap();
3628         fWizardFunctionEpilogMap = new HashMap();
3629         fWizardFunctionArgTableMap = new HashMap();
3630         fWizardFunctionArgDefaultsMap = new HashMap();
3631         String kNoArgsDefined = "FUNCTION_DEFINES_NO_ARGS";
3632         String kNoArgsDefinedText = "Undefined";
3633         String kNoArgsAllowed = "FUNCTION_ALLOWS_NO_ARGS";
3634         String kNoArgsAllowedText = "None";
3635         String kSingleArg = "FUNCTION_DEFINES_ONE_ARG";
3636         String kSingleArgText = "Single";
3637         String kListArgs = "FUNCTION_DEFINES_LIST_ARGS";
3638         String kListArgsText = "List";
3639         String kMapArgs = "FUNCTION_DEFINES_MAP_ARGS";
3640         String kMapArgsText = "Map";
3641 
3642         String defaultCall = (String)jobDetailsMap.get("defaultCall");
3643 
3644         // Iterate through the list of functions in the job
3645 
3646         java.util.List functionList =
3647             (java.util.List)jobDetailsMap.get("functionList");
3648         Iterator functionIter = functionList.iterator();
3649 
3650         while (functionIter.hasNext())
3651         {
3652             Map functionMap = (Map)functionIter.next();
3653             String functionName = (String)functionMap.get("functionName");
3654 
3655             if (functionName.equals(defaultCall))
3656             {
3657                 functions.add(functionName + " (default)");
3658             }
3659             else
3660             {
3661                 functions.add(functionName);
3662             }
3663 
3664             String functionProlog = (String)functionMap.get("prolog");
3665 
3666             if (functionProlog != null && !functionProlog.equals(""))
3667             {
3668                 /* No changes */
3669             }
3670             else
3671             {
3672                 functionProlog = "N/A";
3673             }
3674 
3675             String functionEpilog = (String)functionMap.get("epilog");
3676 
3677             String argDefinition = (String)functionMap.get("argDefinition");
3678             if (argDefinition.equals(kNoArgsDefined))
3679                 argDefinition = kNoArgsDefinedText;
3680             else if (argDefinition.equals(kNoArgsAllowed))
3681                 argDefinition = kNoArgsAllowedText;
3682             else if (argDefinition.equals(kSingleArg))
3683                 argDefinition = kSingleArgText;
3684             else if (argDefinition.equals(kListArgs))
3685                 argDefinition = kListArgsText;
3686             else if (argDefinition.equals(kMapArgs))
3687                 argDefinition = kMapArgsText;
3688 
3689             fWizardFunctionPrologMap.put(functionName, functionProlog);
3690             fWizardFunctionEpilogMap.put(functionName, functionEpilog);
3691             fWizardFunctionTypeMap.put(functionName, argDefinition);
3692 
3693             // Iterate through the function argument list
3694 
3695             Vector functionArgs = new Vector();
3696             Vector functionArgDefaults = new Vector();
3697             java.util.List argList = (java.util.List)functionMap.get("argList");
3698             Iterator argIter = argList.iterator();
3699 
3700             while (argIter.hasNext())
3701             {
3702                 Map argMap = (Map)argIter.next();
3703                 Vector argInfo = new Vector();
3704 
3705                 String argName = (String)argMap.get("argName");
3706                 argInfo.add(argName);
3707 
3708                 String argDescription = (String)argMap.get("description");
3709 
3710                 if (argDescription != null && !argDescription.equals(""))
3711                 {
3712                     /* No changes */
3713                 }
3714                 else
3715                 {
3716                     argDescription = "N/A";
3717                 }
3718 
3719                 argInfo.add(argDescription);
3720 
3721                 String argType = (String)argMap.get("type");
3722 
3723                 if (argType.equals("ARG_REQUIRED"))
3724                     argType = "Yes";
3725                 else if (argType.equals("ARG_OPTIONAL"))
3726                     argType = "No";
3727                 else
3728                     argType = "Other";
3729 
3730                 argInfo.add(argType);
3731 
3732                 String argDefaultValue = (String)argMap.get("defaultValue");
3733 
3734                 if (argDefaultValue != null && !argDefaultValue.equals("N/A"))
3735                 {
3736                     /* No changes */
3737                 }
3738                 else
3739                 {
3740                     argDefaultValue = "";
3741                 }
3742 
3743                 argInfo.add(argDefaultValue);
3744 
3745                 functionArgDefaults.add(argDefaultValue);
3746 
3747                 functionArgs.add(argInfo);
3748             }
3749 
3750             if (argDefinition.equals(kNoArgsDefinedText))
3751             {
3752                 Vector argInfo = new Vector();
3753                 argInfo.add("STAXArg");
3754                 argInfo.add("Function Argument(s)");
3755                 argInfo.add("No");
3756                 argInfo.add("");
3757                 functionArgs.add(argInfo);
3758                 functionArgDefaults.add("");
3759             }
3760 
3761             fWizardFunctionMap.put(functionName, functionArgs);
3762             fWizardFunctionArgDefaultsMap.put(functionName,
3763                 functionArgDefaults);
3764         }
3765 
3766         fWizardDialog = new JDialog(this, "STAX Job Wizard - " +
3767             fWizardFileName, true);
3768         JPanel wizardPanel = new JPanel();
3769         wizardPanel.setLayout(new
3770             BoxLayout(wizardPanel, BoxLayout.Y_AXIS));
3771 
3772         JTabbedPane wizardTabbedPane = new JTabbedPane();
3773 
3774         JPanel outerFunctionsPanel = new JPanel();
3775         outerFunctionsPanel.setLayout(new BorderLayout());
3776 
3777         JPanel functionsPanel = new JPanel();
3778         functionsPanel.setBorder(new TitledBorder("Functions"));
3779         functionsPanel.setLayout(new BorderLayout());
3780 
3781         JPanel functionListandPrologPanel = new JPanel();
3782         functionListandPrologPanel.setLayout(new BorderLayout());
3783 
3784         fWizardFunctionProlog = new JEditorPane();
3785 
3786         fWizardFunctionProlog.setEditable(false);
3787 
3788         functionsPanel.add(BorderLayout.WEST, Box.createHorizontalStrut(10));
3789         fWizardFunctionsList = new JList(functions.toArray());
3790         fWizardFunctionsList.setBackground(Color.white);
3791         fWizardFunctionsList.setFont(new Font("Dialog", Font.BOLD, 12));
3792         JScrollPane functionsScrollPane = new
3793             JScrollPane(fWizardFunctionsList);
3794         functionsScrollPane.setPreferredSize(new Dimension(225, 100));
3795         functionsPanel.add(BorderLayout.CENTER, functionsScrollPane);
3796         functionsPanel.add(BorderLayout.EAST, Box.createHorizontalStrut(10));
3797         functionListandPrologPanel.add(BorderLayout.WEST, functionsPanel);
3798 
3799         prologPanel = new JPanel();
3800         functionDescriptionBorder.setTitle("Function Description");
3801         prologPanel.setBorder(functionDescriptionBorder);
3802         prologPanel.setLayout(new BorderLayout());
3803         prologPanel.add(BorderLayout.CENTER, new
3804             JScrollPane(fWizardFunctionProlog));
3805         fWizardFunctionProlog.setContentType("text/html");
3806 
3807         fWizardDetailsButton = new JButton("Details...");
3808         fWizardDetailsButton.addActionListener(this);
3809         JPanel detailsButtonPanel = new JPanel();
3810         detailsButtonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
3811         detailsButtonPanel.add(fWizardDetailsButton);
3812         prologPanel.add(BorderLayout.SOUTH, detailsButtonPanel);
3813 
3814         fWizardFunctionArgsPanel = new JPanel();
3815         functionArgumentBorder.setTitle("Function Arguments");
3816         fWizardFunctionArgsPanel.setBorder(functionArgumentBorder);
3817         fWizardFunctionArgsPanel.setLayout(new BorderLayout());
3818 
3819         functionListandPrologPanel.add(BorderLayout.CENTER, prologPanel);
3820 
3821         JPanel wizardFunctionArgsTypeLabelPanel = new JPanel();
3822         wizardFunctionArgsTypeLabelPanel.setLayout(new
3823             BoxLayout(wizardFunctionArgsTypeLabelPanel, BoxLayout.Y_AXIS));
3824 
3825         fWizardNoArgsAllowedLabel = new JLabel("None");
3826         fWizardNoArgsAllowedLabel.setForeground(Color.black);
3827         wizardFunctionArgsTypeLabelPanel.add(fWizardNoArgsAllowedLabel);
3828         wizardFunctionArgsTypeLabelPanel.add(Box.createVerticalStrut(10));
3829 
3830         fWizardSingleArgLabel = new JLabel("Single");
3831         fWizardSingleArgLabel.setForeground(Color.black);
3832         wizardFunctionArgsTypeLabelPanel.add(fWizardSingleArgLabel);
3833         wizardFunctionArgsTypeLabelPanel.add(Box.createVerticalStrut(10));
3834 
3835         fWizardListArgsLabel = new JLabel("List");
3836         fWizardListArgsLabel.setForeground(Color.black);
3837         wizardFunctionArgsTypeLabelPanel.add(fWizardListArgsLabel);
3838         wizardFunctionArgsTypeLabelPanel.add(Box.createVerticalStrut(10));
3839 
3840         fWizardMapArgsLabel = new JLabel("Map");
3841         fWizardMapArgsLabel.setForeground(Color.black);
3842         wizardFunctionArgsTypeLabelPanel.add(fWizardMapArgsLabel);
3843         wizardFunctionArgsTypeLabelPanel.add(Box.createVerticalStrut(10));
3844 
3845         fWizardNoArgsDefinedLabel = new JLabel("Undefined");
3846         fWizardNoArgsDefinedLabel.setForeground(Color.black);
3847         wizardFunctionArgsTypeLabelPanel.add(fWizardNoArgsDefinedLabel);
3848         wizardFunctionArgsTypeLabelPanel.add(Box.createVerticalStrut(10));
3849 
3850         fWizardFunctionArgsPanel.add(BorderLayout.NORTH,
3851             wizardFunctionArgsTypeLabelPanel);
3852 
3853         // Create all of the function argument tables
3854 
3855         Iterator iter = functions.iterator();
3856 
3857         while (iter.hasNext())
3858         {
3859             String function = (String)iter.next();
3860 
3861             if (function.indexOf("(default)") > -1)
3862             {
3863                 function = function.substring(0, function.indexOf(" "));
3864             }
3865 
3866             Vector functionVector =
3867                 (Vector)fWizardFunctionMap.get(function);
3868 
3869             int numRows = functionVector.size();
3870             Object[][] fObjectData = new Object[numRows][5];
3871 
3872             for (int i = 0; i < numRows; i++)
3873             {
3874                 Vector row = (Vector)functionVector.elementAt(i);
3875 
3876                 fObjectData[i][0] = new
3877                     ArgumentName((String)row.elementAt(0));
3878 
3879                 fObjectData[i][1] = new
3880                     ArgumentDescription((String)row.elementAt(1));
3881 
3882                 fObjectData[i][2] = new
3883                     ArgumentRequired((String)row.elementAt(2));
3884 
3885                 fObjectData[i][3] = new
3886                     ArgumentValue((String)row.elementAt(3));
3887             }
3888 
3889             WizardTableModel fWizardFunctionTableModel =
3890                 new WizardTableModel(fObjectData,
3891                 fWizardFunctionTableColumnNames);
3892 
3893             JTable fWizardFunctionTable = new
3894                 JTable(fWizardFunctionTableModel)
3895             {
3896                 public TableCellRenderer getCellRenderer(int row, int column)
3897                 {
3898                     Object cellObj = getModel().getValueAt(row, column);
3899                     String cellContent = (cellObj == null) ? "" :
3900                         String.valueOf(cellObj);
3901 
3902                     if ((cellObj instanceof ArgumentName) ||
3903                         (cellObj instanceof ArgumentDescription) ||
3904                         (cellObj instanceof ArgumentRequired) ||
3905                         (cellObj instanceof ArgumentValue))
3906                     {
3907                         return new STAXWizardFunctionTableCellRenderer();
3908                     }
3909                     else
3910                     {
3911                         return new DefaultTableCellRenderer();
3912                     }
3913                 }
3914 
3915                 public TableCellEditor getCellEditor(int row, int column)
3916                 {
3917                     Object cellObj = getModel().getValueAt(row, column);
3918                     String cellContent = (cellObj == null) ? "" :
3919                         String.valueOf(cellObj);
3920 
3921                     if ((cellObj instanceof ArgumentName) ||
3922                         (cellObj instanceof ArgumentDescription) ||
3923                         (cellObj instanceof ArgumentRequired) ||
3924                         (cellObj instanceof ArgumentValue))
3925                     {
3926                         return new STAXWizardFunctionTableCellEditor(new
3927                             JCheckBox());
3928                     }
3929                     else
3930                     {
3931                         return new DefaultCellEditor(new JTextField(cellContent));
3932                     }
3933                 }
3934             };
3935 
3936             updateWizardFunctionTableRenderers(fWizardFunctionTable);
3937 
3938             fWizardFunctionTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
3939             fWizardFunctionTable.setSelectionMode(
3940                 ListSelectionModel.SINGLE_SELECTION);
3941             fWizardFunctionTable.setRowSelectionAllowed(true);
3942             fWizardFunctionTable.setBackground(Color.white);
3943 
3944             for (int i = 0 ; i < fWizardFunctionTable.getRowCount() ; i++)
3945             {
3946                 fWizardFunctionTable.setRowHeight(i, 25);
3947             }
3948 
3949             fWizardFunctionTable.getColumnModel().getColumn(0).
3950                 setPreferredWidth(130);
3951 
3952             fWizardFunctionTable.getColumnModel().getColumn(1).
3953                 setPreferredWidth(480);
3954 
3955             fWizardFunctionTable.getColumnModel().getColumn(2).
3956                 setPreferredWidth(60);
3957 
3958             fWizardFunctionTable.getColumnModel().getColumn(3).
3959                 setPreferredWidth(300);
3960 
3961             fWizardFunctionArgTableMap.put(function, fWizardFunctionTable);
3962         }
3963 
3964         JPanel wizardButtonPanel = new JPanel();
3965         wizardButtonPanel.setLayout(new
3966             FlowLayout(FlowLayout.CENTER, 0, 0));
3967         wizardButtonPanel.add(fWizardSaveButton);
3968         wizardButtonPanel.add(Box.createHorizontalStrut(20));
3969         wizardButtonPanel.add(fWizardPreviewXMLButton);
3970         wizardButtonPanel.add(Box.createHorizontalStrut(20));
3971         wizardButtonPanel.add(fWizardCancelButton);
3972 
3973         JPanel functionPanel = new JPanel();
3974 
3975         GridBagLayout gbl = new GridBagLayout();
3976         GridBagConstraints gbc1 = new GridBagConstraints();
3977         GridBagConstraints gbc2 = new GridBagConstraints();
3978         functionPanel.setLayout(gbl);
3979 
3980         gbc1.gridwidth = GridBagConstraints.RELATIVE;
3981         gbc1.gridheight = 1;
3982         gbc1.fill = GridBagConstraints.BOTH;
3983         gbc1.anchor = GridBagConstraints.NORTHWEST;
3984         gbc1.gridx = 0;
3985         gbc1.gridy = 0;
3986         gbc1.weightx = 1.0;
3987         gbc1.weighty = 1.0;
3988         functionPanel.add(functionListandPrologPanel, gbc1);
3989 
3990         gbc2.gridwidth = GridBagConstraints.RELATIVE;
3991         gbc2.gridheight = 1;
3992         gbc2.fill = GridBagConstraints.BOTH;
3993         gbc2.anchor = GridBagConstraints.NORTHWEST;
3994         gbc2.gridx = 0;
3995         gbc2.gridy = 1;
3996         gbc2.weightx = 1.0;
3997         gbc2.weighty = 1.0;
3998         functionPanel.add(fWizardFunctionArgsPanel, gbc2);
3999 
4000         JPanel instructionsPanel = new JPanel();
4001         instructionsPanel.setLayout(new
4002             BoxLayout(instructionsPanel, BoxLayout.Y_AXIS));
4003         JTextPane instructions = new JTextPane();
4004         instructions.setForeground(Color.black);
4005         instructions.setEditable(false);
4006         instructions.setBackground(UIManager.getColor("Panel.background"));
4007         instructions.setFont(new Font("Dialog", Font.BOLD, 13));
4008         instructions.setText("Select a function from the Functions list, " +
4009             "fill in the values for the Function arguments as needed, and " +
4010             "then click on Save to return to the STAX Job Parameters " +
4011             "dialog.  Note that after you save the Function arguments " +
4012             "you will not be able to edit them directly in the STAX Job " +
4013             "Parameters dialog; you will need to reopen the Job Wizard " +
4014             "in order to edit the parameters, or click on the Clear button " +
4015             "in the STAX Job Parameters dialog.");
4016         instructionsPanel.add(Box.createVerticalStrut(7));
4017         instructionsPanel.add(instructions);
4018         instructionsPanel.add(Box.createVerticalStrut(7));
4019 
4020         outerFunctionsPanel.add(BorderLayout.NORTH, instructionsPanel);
4021         outerFunctionsPanel.add(BorderLayout.CENTER, functionPanel);
4022 
4023         wizardTabbedPane.addTab("Functions", outerFunctionsPanel);
4024 
4025         wizardPanel.add(wizardTabbedPane);
4026         wizardPanel.add(wizardButtonPanel);
4027 
4028         wizardTabbedPane.setBackgroundAt(0, Color.lightGray);
4029 
4030         wizardTabbedPane.addChangeListener(this);
4031 
4032         fWizardDialog.setSize(new Dimension(1025, 700));
4033         fWizardDialog.getContentPane().
4034             add(wizardPanel);
4035 
4036         if (fDefaultFunctionRB.isSelected() && !defaultCall.equals(""))
4037         {
4038             fWizardFunctionsList.setSelectedValue(defaultCall +
4039                 " (default)", true);
4040         }
4041         else if (fOtherFunctionRB.isSelected())
4042         {
4043             fWizardFunctionsList.setSelectedValue(fFunctionField.getText(),
4044                 true);
4045 
4046             if (fWizardFunctionsList.getSelectedIndex() == -1)
4047             {
4048                 fWizardFunctionsList.setSelectedValue(fFunctionField.getText()
4049                     + " (default)", true);
4050 
4051                 if (fWizardFunctionsList.getSelectedIndex() == -1)
4052                 {
4053                     fWizardFunctionsList.setSelectedIndex(0);
4054                 }
4055             }
4056         }
4057         else
4058         {
4059             fWizardFunctionsList.setSelectedIndex(0);
4060         }
4061 
4062         String function = (String)fWizardFunctionsList.getSelectedValue();
4063 
4064         if (function.indexOf("(default)") > -1)
4065         {
4066             function = function.substring(0, function.indexOf(" "));
4067         }
4068 
4069         // Assign Wizard's Saved Function Argument List if using same
4070         // xml file, machine, and function as was last saved via the Wizard.
4071 
4072         if (function.equals(fWizardSavedFunctionName) &&
4073             fWizardFileName.equals(fWizardSavedFileName) &&
4074             fWizardFileMachineName.equals(fWizardSavedFileMachineName))
4075         {
4076             String functionType = (String)
4077                 fWizardFunctionTypeMap.get(function);
4078 
4079             JTable table = (JTable)
4080                 fWizardFunctionArgTableMap.get(function);
4081 
4082             if (table.getRowCount() >= fWizardSavedFunctionArgList.size())
4083             {
4084                 if (functionType.equals("Single") ||
4085                     functionType.equals("Undefined") ||
4086                     functionType.equals("List") ||
4087                     functionType.equals("Map"))
4088                 {
4089                     for (int i = 0; i < fWizardSavedFunctionArgList.size(); i++)
4090                     {
4091                         table.setValueAt(new ArgumentValue(
4092                             (String)fWizardSavedFunctionArgList.elementAt(i)),
4093                             i, 3);
4094                     }
4095                 }
4096             }
4097         }
4098 
4099         updateWizardFunctionTable();
4100 
4101         fWizardFunctionsList.addListSelectionListener(this);
4102 
4103         fWizardDialog.setVisible(true);
4104     }
4105 
updateWizardFunctionTable()4106     public void updateWizardFunctionTable()
4107     {
4108         Object[][] fObjectData;
4109 
4110         String function = (String)fWizardFunctionsList.getSelectedValue();
4111 
4112         if (function.indexOf("(default)") > -1)
4113         {
4114             function = function.substring(0, function.indexOf(" "));
4115         }
4116 
4117         functionDescriptionBorder.setTitle("Description for function " +
4118             function);
4119 
4120         functionArgumentBorder.setTitle("Arguments for function " +
4121             function);
4122 
4123         Vector functionVector =
4124             (Vector)fWizardFunctionMap.get(function);
4125 
4126         fWizardFunctionArgsPanel.removeAll();
4127 
4128         updateWizardFunctionType((String)
4129             fWizardFunctionTypeMap.get(function));
4130 
4131         JPanel wizardFunctionArgsDetailsPanel = new JPanel();
4132         wizardFunctionArgsDetailsPanel.setLayout(new
4133             BoxLayout(wizardFunctionArgsDetailsPanel, BoxLayout.Y_AXIS));
4134 
4135         JPanel wizardFunctionArgsTypeLabelPanel = new JPanel();
4136         wizardFunctionArgsTypeLabelPanel.setLayout(new
4137             BoxLayout(wizardFunctionArgsTypeLabelPanel, BoxLayout.X_AXIS));
4138 
4139         wizardFunctionArgsTypeLabelPanel.add(fWizardNoArgsAllowedLabel);
4140         wizardFunctionArgsTypeLabelPanel.add(Box.createHorizontalStrut(10));
4141 
4142         wizardFunctionArgsTypeLabelPanel.add(fWizardSingleArgLabel);
4143         wizardFunctionArgsTypeLabelPanel.add(Box.createHorizontalStrut(10));
4144 
4145         wizardFunctionArgsTypeLabelPanel.add(fWizardListArgsLabel);
4146         wizardFunctionArgsTypeLabelPanel.add(Box.createHorizontalStrut(10));
4147 
4148         wizardFunctionArgsTypeLabelPanel.add(fWizardMapArgsLabel);
4149         wizardFunctionArgsTypeLabelPanel.add(Box.createHorizontalStrut(10));
4150 
4151         wizardFunctionArgsTypeLabelPanel.add(fWizardNoArgsDefinedLabel);
4152         wizardFunctionArgsTypeLabelPanel.add(Box.createHorizontalStrut(10));
4153 
4154         wizardFunctionArgsTypeLabelPanel.add(Box.createVerticalStrut(10));
4155 
4156         wizardFunctionArgsDetailsPanel.add(wizardFunctionArgsTypeLabelPanel);
4157         wizardFunctionArgsDetailsPanel.add(Box.createVerticalStrut(10));
4158 
4159         fWizardFunctionArgsPanel.add(BorderLayout.NORTH,
4160             wizardFunctionArgsDetailsPanel);
4161         fWizardFunctionArgsPanel.add(BorderLayout.CENTER,
4162             new JScrollPane((JTable)fWizardFunctionArgTableMap.get(function)));
4163 
4164         fWizardFunctionProlog.setText((String)
4165             fWizardFunctionPrologMap.get(function));
4166         fWizardFunctionProlog.setCaretPosition(0);
4167 
4168         fWizardFunctionArgsPanel.invalidate();
4169         fWizardFunctionArgsPanel.validate();
4170         fWizardFunctionArgsPanel.repaint();
4171         prologPanel.repaint();
4172     }
4173 
displayJobWizardDetails()4174     public void displayJobWizardDetails()
4175     {
4176         String function = (String)fWizardFunctionsList.getSelectedValue();
4177 
4178         if (function.indexOf("(default)") > -1)
4179         {
4180             function = function.substring(0, function.indexOf(" "));
4181         }
4182 
4183         final JDialog fWizardDetailsDialog = new JDialog(fWizardDialog,
4184             function + " Details", false);
4185         JPanel wizardDetailsPanel = new JPanel();
4186         wizardDetailsPanel.setLayout(new BorderLayout());
4187 
4188         JEditorPane fWizardFunctionDetails = new JEditorPane();
4189         fWizardFunctionDetails.setEditable(false);
4190         fWizardFunctionDetails.setContentType("text/html");
4191 
4192         fWizardFunctionDetails.setText((String)
4193             fWizardFunctionPrologMap.get(function) +
4194             (String)fWizardFunctionEpilogMap.get(function));
4195 
4196         fWizardFunctionDetails.setCaretPosition(0);
4197 
4198         wizardDetailsPanel.add(BorderLayout.CENTER,
4199             new JScrollPane(fWizardFunctionDetails));
4200 
4201         JButton wizardDetailsCloseButton = new JButton("Close");
4202 
4203         wizardDetailsCloseButton.addActionListener(new ActionListener()
4204         {
4205             public void actionPerformed(ActionEvent e)
4206             {
4207                 fWizardDetailsDialog.dispose();
4208             }
4209         });
4210 
4211         JPanel wizardDetailsButtonPanel = new JPanel();
4212         wizardDetailsButtonPanel.setLayout(new
4213             FlowLayout(FlowLayout.CENTER, 0, 0));
4214         wizardDetailsButtonPanel.add(wizardDetailsCloseButton);
4215 
4216         wizardDetailsPanel.add(BorderLayout.SOUTH, wizardDetailsButtonPanel);
4217 
4218         fWizardDetailsDialog.setSize(925, 600);
4219         fWizardDetailsDialog.setLocationRelativeTo(fWizardDialog);
4220         fWizardDetailsDialog.getContentPane().add(wizardDetailsPanel);
4221         fWizardDetailsDialog.setVisible(true);
4222     }
4223 
updateWizardFunctionType(String type)4224     public void updateWizardFunctionType(String type)
4225     {
4226         if (type.equals(fWizardNoArgsAllowedLabel.getText()))
4227         {
4228             fWizardNoArgsAllowedLabel.setForeground(Color.blue);
4229         }
4230         else
4231         {
4232             fWizardNoArgsAllowedLabel.setForeground(Color.darkGray);
4233         }
4234 
4235         if (type.equals(fWizardNoArgsDefinedLabel.getText()))
4236         {
4237             fWizardNoArgsDefinedLabel.setForeground(Color.blue);
4238         }
4239         else
4240         {
4241             fWizardNoArgsDefinedLabel.setForeground(Color.darkGray);
4242         }
4243 
4244         if (type.equals(fWizardSingleArgLabel.getText()))
4245         {
4246             fWizardSingleArgLabel.setForeground(Color.blue);
4247         }
4248         else
4249         {
4250             fWizardSingleArgLabel.setForeground(Color.darkGray);
4251         }
4252 
4253         if (type.equals(fWizardListArgsLabel.getText()))
4254         {
4255             fWizardListArgsLabel.setForeground(Color.blue);
4256         }
4257         else
4258         {
4259             fWizardListArgsLabel.setForeground(Color.darkGray);
4260         }
4261 
4262         if (type.equals(fWizardMapArgsLabel.getText()))
4263         {
4264             fWizardMapArgsLabel.setForeground(Color.blue);
4265         }
4266         else
4267         {
4268             fWizardMapArgsLabel.setForeground(Color.darkGray);
4269         }
4270     }
4271 
previewWizardXML()4272     public void previewWizardXML()
4273     {
4274         final JDialog previewXMLDialog = new JDialog(fWizardDialog,
4275             " Preview XML", false);
4276         JPanel previewXMLPanel = new JPanel();
4277         previewXMLPanel.setLayout(new BorderLayout());
4278 
4279         JTextArea previewXMLTextArea = new JTextArea();
4280         previewXMLTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
4281         previewXMLTextArea.setEditable(false);
4282 
4283         String function = (String)fWizardFunctionsList.getSelectedValue();
4284 
4285         if (function.indexOf("(default)") > -1)
4286         {
4287             function = function.substring(0, function.indexOf(" "));
4288         }
4289 
4290         String functionType = (String)
4291                 fWizardFunctionTypeMap.get(function);
4292 
4293         JTable table = (JTable)
4294             fWizardFunctionArgTableMap.get(function);
4295 
4296         int rows = table.getRowCount();
4297 
4298         if (!verifyRequiredArguments(table))
4299         {
4300             STAXMonitorUtil.showErrorDialog(
4301                 fWizardDialog, "A value must be specified " +
4302                 "for all required arguments");
4303             return;
4304         }
4305 
4306         if (function.indexOf("(default)") > -1)
4307         {
4308             function = function.substring(0, function.indexOf(" "));
4309         }
4310 
4311         StringBuffer args = new StringBuffer();
4312 
4313         if (functionType.equalsIgnoreCase("None"))
4314         {
4315             // Do nothing - args is already ""
4316         }
4317         else if (functionType.equalsIgnoreCase("Undefined"))
4318         {
4319             String staxArgValue =
4320                 ((ArgumentValue)table.getValueAt(0, 3)).getString();
4321 
4322             if (!staxArgValue.equals(""))
4323             {
4324                 args.append(staxArgValue);
4325             }
4326         }
4327         else if (functionType.equalsIgnoreCase("Single"))
4328         {
4329             args.append(table.getValueAt(0, 3));
4330         }
4331         else if (functionType.equalsIgnoreCase("List"))
4332         {
4333             args.append("[\n   ");
4334 
4335             Vector argDefaults = (Vector)
4336                 fWizardFunctionArgDefaultsMap.get(function);
4337 
4338             // Determine the last item that will be specified in this list.
4339             // All arguments prior to the last item must be included.
4340 
4341             int lastindex = -1;
4342 
4343             for (int i = 0; i < rows; i++)
4344             {
4345                 String required =
4346                     ((ArgumentRequired)table.getValueAt(i, 2)).getString();
4347 
4348                 String value =
4349                     ((ArgumentValue)table.getValueAt(i, 3)).getString();
4350 
4351                 if ( (required.equals("Yes")) ||
4352                      (required.equals("No") &&
4353                       !(((String)argDefaults.get(i)).equals(value))) ||
4354                      (required.equals("Other") && !value.equals("")) )
4355                 {
4356                     lastindex = i;
4357                 }
4358             }
4359 
4360             for (int i = 0; i <= lastindex; i++)
4361             {
4362                 String value =
4363                     ((ArgumentValue)table.getValueAt(i, 3)).getString();
4364 
4365                 if (i > 0)
4366                     args.append(",\n   ");
4367 
4368                 args.append(value);
4369             }
4370 
4371             args.append("\n  ]");
4372         }
4373         else if (functionType.equalsIgnoreCase("Map"))
4374         {
4375             args.append("{\n   ");
4376             int numArgs = 0;
4377 
4378             Vector argDefaults = (Vector)
4379                 fWizardFunctionArgDefaultsMap.get(function);
4380 
4381             for (int i = 0; i < rows; i++)
4382             {
4383                 String required =
4384                     ((ArgumentRequired)table.getValueAt(i, 2)).getString();
4385 
4386                 String value =
4387                     ((ArgumentValue)table.getValueAt(i, 3)).getString();
4388 
4389                 if ( ( required.equals("Yes")) ||
4390                      ( required.equals("No") &&
4391                        !((String)argDefaults.get(i)).equals(value) ) ||
4392                      ( required.equals("Other") && !value.equals("") ) )
4393                 {
4394                     if (numArgs > 0) args.append(",\n   ");
4395 
4396                     if (!required.equals("Other"))
4397                     {
4398                         args.append("'").append(table.getValueAt(i, 0)).
4399                              append("': ");
4400                     }
4401 
4402                     args.append(value);
4403 
4404                     numArgs++;
4405                 }
4406             }
4407 
4408             args.append("\n  }");
4409         }
4410 
4411         String callText = "";
4412 
4413         if (args.equals(""))
4414         {
4415             callText = "<call function=\"'" + function + "'\">\n</call>";
4416         }
4417         else
4418         {
4419             callText = "<call function=\"'" +
4420                 function + "'\">\n  " + args.toString() + "\n</call>";
4421         }
4422 
4423         previewXMLTextArea.setText(callText);
4424 
4425         previewXMLTextArea.setCaretPosition(0);
4426 
4427         previewXMLPanel.add(BorderLayout.CENTER,
4428             new JScrollPane(previewXMLTextArea));
4429 
4430         JButton previewXMLCloseButton = new JButton("Close");
4431 
4432         previewXMLCloseButton.addActionListener(new ActionListener()
4433         {
4434             public void actionPerformed(ActionEvent e)
4435             {
4436                 previewXMLDialog.dispose();
4437             }
4438         });
4439 
4440         JPanel previewXMLButtonPanel = new JPanel();
4441         previewXMLButtonPanel.setLayout(new
4442             FlowLayout(FlowLayout.CENTER, 0, 0));
4443         previewXMLButtonPanel.add(previewXMLCloseButton);
4444 
4445         previewXMLPanel.add(BorderLayout.SOUTH, previewXMLButtonPanel);
4446 
4447         previewXMLDialog.setSize(300, 200);
4448         previewXMLDialog.setLocationRelativeTo(fWizardDialog);
4449         previewXMLDialog.getContentPane().add(previewXMLPanel);
4450         previewXMLDialog.setVisible(true);
4451     }
4452 
verifyRequiredArguments(JTable table)4453     public boolean verifyRequiredArguments(JTable table)
4454     {
4455         int rows = table.getRowCount();
4456 
4457         for (int i = 0; i < rows; i++)
4458         {
4459             ArgumentRequired required =
4460                 (ArgumentRequired)table.getValueAt(i, 2);
4461 
4462             if (required.getString().equals("Yes"))
4463             {
4464                 ArgumentValue value =
4465                     (ArgumentValue)table.getValueAt(i, 3);
4466 
4467                 if (value.getString().equals(""))
4468                 {
4469                     return false;
4470                 }
4471             }
4472         }
4473 
4474         return true;
4475     }
4476 
updateWizardFunctionTableRenderers(JTable wizardFunctionTable)4477     public void updateWizardFunctionTableRenderers(JTable wizardFunctionTable)
4478     {
4479         wizardFunctionTable.getColumnModel().getColumn(0).setCellRenderer(
4480             new STAXWizardFunctionTableCellRenderer());
4481 
4482         wizardFunctionTable.getColumnModel().getColumn(0).
4483             setHeaderRenderer(new STAXWizardFunctionTableCellRenderer(
4484                 new Font("Dialog", Font.BOLD, 12), Color.lightGray));
4485 
4486         wizardFunctionTable.getColumnModel().getColumn(1).setCellRenderer(
4487             new STAXWizardFunctionTableCellRenderer());
4488 
4489         wizardFunctionTable.getColumnModel().getColumn(1).
4490             setHeaderRenderer(new STAXWizardFunctionTableCellRenderer(
4491                 new Font("Dialog", Font.BOLD, 12), Color.lightGray));
4492 
4493         wizardFunctionTable.getColumnModel().getColumn(2).setCellRenderer(
4494             new STAXWizardFunctionTableCellRenderer());
4495 
4496         wizardFunctionTable.getColumnModel().getColumn(2).
4497             setHeaderRenderer(new STAXWizardFunctionTableCellRenderer(
4498                 new Font("Dialog", Font.BOLD, 12), Color.lightGray));
4499 
4500         wizardFunctionTable.getColumnModel().getColumn(3).setCellRenderer(
4501             new STAXWizardFunctionTableCellRenderer(
4502                 new Font("Monospaced", Font.PLAIN, 12), Color.white));
4503 
4504         wizardFunctionTable.getColumnModel().getColumn(3).
4505             setHeaderRenderer(new STAXWizardFunctionTableCellRenderer(
4506                 new Font("Dialog", Font.BOLD, 12), Color.lightGray));
4507     }
4508 
4509     public class WizardTableModel extends javax.swing.table.DefaultTableModel
4510     {
WizardTableModel()4511         public WizardTableModel()
4512         {
4513             super();
4514         }
4515 
WizardTableModel(java.lang.Object[][] data, java.lang.Object[] columnNames)4516         public WizardTableModel(java.lang.Object[][] data,
4517                                 java.lang.Object[] columnNames)
4518         {
4519             super(data, columnNames);
4520         }
4521 
WizardTableModel(java.lang.Object[] columnNames, int numRows)4522         public WizardTableModel(java.lang.Object[] columnNames, int numRows)
4523         {
4524             super(columnNames, numRows);
4525         }
4526 
WizardTableModel(int numRows, int numColumns)4527         public WizardTableModel(int numRows, int numColumns)
4528         {
4529             super(numRows, numColumns);
4530         }
4531 
WizardTableModel(java.util.Vector columnNames, int numRows)4532         public WizardTableModel(java.util.Vector columnNames, int numRows)
4533         {
4534             super(columnNames, numRows);
4535         }
4536 
WizardTableModel(java.util.Vector data, java.util.Vector columnNames)4537         public WizardTableModel(java.util.Vector data,
4538                               java.util.Vector columnNames)
4539         {
4540             super(data, columnNames);
4541         }
4542 
isCellEditable(int row, int column)4543         public boolean isCellEditable(int row, int column)
4544         {
4545             switch(column)
4546             {
4547                 case 0  : return false;
4548                 case 1  : return true;
4549                 case 2  : return false;
4550                 case 3  : return true;
4551                 default : return false;
4552             }
4553         }
4554     }
4555 
4556     public class STAXWizardFunctionTableCellRenderer
4557              extends DefaultTableCellRenderer
4558     {
4559         public Hashtable rowHeights = new Hashtable();
4560         private boolean isHeader = true;
4561         private JTextField argumentNameField = new JTextField();
4562         private JTextField argumentDescriptionField = new JTextField();
4563         private JTextField argumentRequiredField = new JTextField();
4564         private JTextField argumentValueField = new JTextField();
4565         private JButton descriptionButton;
4566         private JButton editButton;
4567         private JButton resetButton;
4568         private JLabel headerLabel = new JLabel();
4569 
STAXWizardFunctionTableCellRenderer()4570         public STAXWizardFunctionTableCellRenderer()
4571         {
4572             this(new Font("Dialog", Font.PLAIN, 12), Color.white);
4573             isHeader = false;
4574         }
4575 
STAXWizardFunctionTableCellRenderer(Font font, Color background)4576         public STAXWizardFunctionTableCellRenderer(Font font, Color background)
4577         {
4578             headerLabel.setFont(font);
4579             headerLabel.setOpaque(true);
4580             headerLabel.setBackground(background);
4581             headerLabel.setForeground(Color.black);
4582 
4583             argumentNameField.setEditable(false);
4584             argumentNameField.setBackground(Color.white);
4585 
4586             argumentDescriptionField.setEditable(false);
4587             argumentDescriptionField.setBackground(Color.white);
4588 
4589             argumentRequiredField.setEditable(false);
4590             argumentRequiredField.setBackground(Color.white);
4591 
4592             argumentValueField.setEditable(false);
4593             argumentValueField.setBackground(Color.white);
4594         }
4595 
clearRowHeights()4596         public void clearRowHeights()
4597         {
4598             rowHeights.clear();
4599         }
4600 
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)4601         public Component getTableCellRendererComponent(JTable table,
4602                                                        Object value,
4603                                                        boolean isSelected,
4604                                                        boolean hasFocus,
4605                                                        int row, int col)
4606         {
4607             Color rowBackground = lightGreen;
4608 
4609             if (value instanceof WizardArgumentInterface)
4610             {
4611                 ArgumentRequired argReq =
4612                     (ArgumentRequired)table.getModel().getValueAt(row, 2);
4613 
4614                 if (argReq.getString().equals("Yes"))
4615                 {
4616                     ArgumentValue argValue =
4617                         (ArgumentValue)table.getModel().getValueAt(row, 3);
4618 
4619                     if (argValue.getString().equals(""))
4620                     {
4621                         rowBackground = lightRed;
4622                     }
4623                 }
4624                 else if (argReq.getString().equals("Other"))
4625                 {
4626                     ArgumentValue argValue =
4627                         (ArgumentValue)table.getModel().getValueAt(row, 3);
4628 
4629                     if (argValue.getString().equals(""))
4630                     {
4631                         rowBackground = lightYellow;
4632                     }
4633                 }
4634 
4635                 ArgumentName argName =
4636                     (ArgumentName)table.getModel().getValueAt(row, 0);
4637 
4638                 if (argName.getString().equals("STAXArg"))
4639                 {
4640                     ArgumentValue argValue =
4641                         (ArgumentValue)table.getModel().getValueAt(row, 3);
4642 
4643                     if (argValue.getString().equals(""))
4644                     {
4645                         rowBackground = lightYellow;
4646                     }
4647                 }
4648             }
4649 
4650             String cellContent = (value == null) ? "" :
4651                 String.valueOf(value);
4652 
4653             if (value instanceof ArgumentName)
4654             {
4655                 JPanel namePanel = new JPanel();
4656                 argumentNameField.setText(((ArgumentName)value).getString());
4657                 argumentNameField.setBorder(null);
4658                 argumentNameField.setBackground(rowBackground);
4659                 namePanel.setLayout(new BorderLayout());
4660                 namePanel.setBackground(rowBackground);
4661                 namePanel.add(BorderLayout.CENTER, argumentNameField);
4662 
4663                 Dimension size = argumentNameField.getPreferredSize();
4664                 size.height = 25;
4665                 argumentNameField.setPreferredSize(size);
4666 
4667                 JPanel panel = new JPanel();
4668                 panel.setLayout(new BorderLayout());
4669                 panel.setBackground(rowBackground);
4670                 panel.add(BorderLayout.NORTH, namePanel);
4671 
4672                 return panel;
4673             }
4674             else if (value instanceof ArgumentDescription)
4675             {
4676                 descriptionButton = new JButton("More...");
4677                 descriptionButton.setPreferredSize(new Dimension(75, 27));
4678 
4679                 JPanel descPanel = new JPanel();
4680                 argumentDescriptionField.setText(
4681                     ((ArgumentDescription)value).getFirstLine());
4682                 argumentDescriptionField.setBorder(null);
4683                 argumentDescriptionField.setBackground(rowBackground);
4684                 descPanel.setLayout(new BorderLayout());
4685                 descPanel.setBackground(rowBackground);
4686                 descPanel.add(BorderLayout.CENTER, argumentDescriptionField);
4687 
4688                 JPanel buttonPanel = new JPanel();
4689                 buttonPanel.setLayout(new BorderLayout());
4690                 buttonPanel.setBackground(rowBackground);
4691                 buttonPanel.add(BorderLayout.NORTH, descriptionButton);
4692                 descPanel.add(BorderLayout.EAST, buttonPanel);
4693 
4694                 Dimension size = argumentDescriptionField.getPreferredSize();
4695                 size.height = 25;
4696                 argumentDescriptionField.setPreferredSize(size);
4697 
4698                 JPanel panel = new JPanel();
4699                 panel.setLayout(new BorderLayout());
4700                 panel.setBackground(rowBackground);
4701                 panel.add(BorderLayout.NORTH, descPanel);
4702 
4703                 return panel;
4704             }
4705             else if (value instanceof ArgumentRequired)
4706             {
4707                 JPanel requiredPanel = new JPanel();
4708                 argumentRequiredField.setText(
4709                     ((ArgumentRequired)value).getString());
4710                 argumentRequiredField.setBorder(null);
4711                 argumentRequiredField.setBackground(rowBackground);
4712                 requiredPanel.setLayout(new BorderLayout());
4713                 requiredPanel.setBackground(rowBackground);
4714                 requiredPanel.add(BorderLayout.CENTER, argumentRequiredField);
4715 
4716                 Dimension size = argumentRequiredField.getPreferredSize();
4717                 size.height = 25;
4718                 argumentRequiredField.setPreferredSize(size);
4719 
4720                 JPanel panel = new JPanel();
4721                 panel.setLayout(new BorderLayout());
4722                 panel.setBackground(rowBackground);
4723                 panel.add(BorderLayout.NORTH, requiredPanel);
4724 
4725                 return panel;
4726             }
4727             else if (value instanceof ArgumentValue)
4728             {
4729                 editButton = new JButton("Edit...");
4730                 editButton.setPreferredSize(new Dimension(75, 27));
4731                 resetButton = new JButton("Default");
4732                 resetButton.setPreferredSize(new Dimension(75, 27));
4733 
4734                 JPanel valuePanel = new JPanel();
4735                 argumentValueField.setText(((ArgumentValue)value).getString());
4736                 argumentValueField.setBorder(null);
4737                 argumentValueField.setFont(
4738                     new Font("Monospaced", Font.PLAIN, 12));
4739                 argumentValueField.setBackground(rowBackground);
4740                 valuePanel.setLayout(new BorderLayout());
4741                 valuePanel.setBackground(rowBackground);
4742                 valuePanel.add(BorderLayout.CENTER, argumentValueField);
4743 
4744                 JPanel buttonPanel = new JPanel();
4745                 buttonPanel.setLayout(new BorderLayout());
4746                 buttonPanel.setBackground(rowBackground);
4747                 buttonPanel.add(BorderLayout.WEST, editButton); // was NORTH
4748 
4749                 ArgumentRequired argReq =
4750                     (ArgumentRequired)table.getModel().getValueAt(row, 2);
4751 
4752                 if (argReq.getString().equals("No"))
4753                 {
4754                     buttonPanel.add(BorderLayout.EAST, resetButton);
4755                 }
4756 
4757                 valuePanel.add(BorderLayout.EAST, buttonPanel);
4758 
4759                 Dimension size = argumentValueField.getPreferredSize();
4760                 size.height = 25;
4761                 argumentValueField.setPreferredSize(size);
4762 
4763                 JPanel panel = new JPanel();
4764                 panel.setLayout(new BorderLayout());
4765                 panel.setBackground(rowBackground);
4766                 panel.add(BorderLayout.NORTH, valuePanel);
4767 
4768                 return panel;
4769             }
4770             else
4771             {
4772                 headerLabel.setBorder(BorderFactory.createRaisedBevelBorder());
4773                 headerLabel.setText((String)value);
4774                 return headerLabel;
4775             }
4776         }
4777     }
4778 
4779     public class STAXWizardFunctionTableCellEditor
4780         extends DefaultCellEditor
4781     {
4782         JButton button;
4783         boolean isPushed;
4784         boolean resetPushed;
4785         String textEditValue = "";
4786         JDialog fEditValueDialog;
4787         JTextArea fEditValueTextArea;
4788         JButton fEditValueSaveButton;
4789         JButton fEditValueCancelButton;
4790         Object cellObj;
4791         int inputRow;
4792         JTextField textfield;
4793         JDialog fMoreDescriptionDialog;
4794         JEditorPane fMoreDescriptionEditorPane;
4795         JButton fMoreDescriptionCloseButton;
4796         JButton resetButton;
4797 
STAXWizardFunctionTableCellEditor(JCheckBox checkBox)4798         public STAXWizardFunctionTableCellEditor(JCheckBox checkBox)
4799         {
4800             super(checkBox);
4801 
4802             button = new JButton();
4803             button.setOpaque(true);
4804             button.addActionListener(new ActionListener()
4805             {
4806                 public void actionPerformed(ActionEvent e)
4807                 {
4808                     if (e.getSource() == button)
4809                     {
4810                         isPushed = true;
4811                         fireEditingStopped();
4812                     }
4813                 }
4814             });
4815 
4816             resetButton = new JButton();
4817             resetButton.setOpaque(true);
4818             resetButton.addActionListener(new ActionListener()
4819             {
4820                 public void actionPerformed(ActionEvent e)
4821                 {
4822                     if (e.getSource() == resetButton)
4823                     {
4824                         resetPushed = true;
4825                         fireEditingStopped();
4826                     }
4827                 }
4828             });
4829 
4830             fEditValueDialog = new JDialog(fWizardDialog,
4831                 "Edit Argument Value", true);
4832             fEditValueDialog.setDefaultCloseOperation(
4833                 WindowConstants.DO_NOTHING_ON_CLOSE);
4834             fEditValueDialog.setSize(new Dimension(400, 200));
4835             JPanel editValuePanel = new JPanel();
4836             editValuePanel.setLayout(new BorderLayout());
4837             fEditValueTextArea = new JTextArea(5, 15);
4838             fEditValueTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
4839             fEditValueTextArea.setBorder(new
4840                 TitledBorder("Edit argument value here"));
4841             editValuePanel.add(BorderLayout.CENTER,
4842                 new JScrollPane(fEditValueTextArea));
4843 
4844             fEditValueSaveButton = new JButton("Save");
4845             fEditValueCancelButton = new JButton("Cancel");
4846 
4847             JPanel editValueButtonPanel = new JPanel();
4848             editValueButtonPanel.setLayout(new
4849                 FlowLayout(FlowLayout.CENTER, 0, 0));
4850             editValueButtonPanel.add(fEditValueSaveButton);
4851             editValueButtonPanel.add(Box.createHorizontalStrut(20));
4852             editValueButtonPanel.add(fEditValueCancelButton);
4853 
4854             editValuePanel.add(BorderLayout.SOUTH, editValueButtonPanel);
4855 
4856             fEditValueDialog.getContentPane().add(editValuePanel);
4857 
4858             fMoreDescriptionDialog = new JDialog(fWizardDialog,
4859                 "Argument Description", true);
4860             fMoreDescriptionDialog.setDefaultCloseOperation(
4861                 WindowConstants.DO_NOTHING_ON_CLOSE);
4862             fMoreDescriptionDialog.setSize(new Dimension(400, 200));
4863             JPanel moreDescriptionPanel = new JPanel();
4864             moreDescriptionPanel.setLayout(new BorderLayout());
4865             fMoreDescriptionEditorPane = new JEditorPane();
4866             fMoreDescriptionEditorPane.setContentType("text/html");
4867             fMoreDescriptionEditorPane.setEditable(false);
4868             fMoreDescriptionEditorPane.setBorder(new
4869                 TitledBorder("Argument Description"));
4870 
4871             moreDescriptionPanel.add(BorderLayout.CENTER,
4872                 new JScrollPane(fMoreDescriptionEditorPane));
4873 
4874             fMoreDescriptionCloseButton = new JButton("Close");
4875 
4876             JPanel moreDescriptionButtonPanel = new JPanel();
4877             moreDescriptionButtonPanel.setLayout(new
4878                 FlowLayout(FlowLayout.CENTER, 0, 0));
4879             moreDescriptionButtonPanel.add(fMoreDescriptionCloseButton);
4880 
4881             moreDescriptionPanel.add(BorderLayout.SOUTH,
4882                 moreDescriptionButtonPanel);
4883 
4884             fMoreDescriptionDialog.getContentPane().add(
4885                 moreDescriptionPanel);
4886         }
4887 
getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)4888         public Component getTableCellEditorComponent(JTable table,
4889             Object value, boolean isSelected, int row, int column)
4890         {
4891             String stringValue = (value == null) ? "" : String.valueOf(value);
4892 
4893             // need this so getCellEditorValue can access it
4894             textEditValue = stringValue;
4895             inputRow = row + 1;
4896 
4897             textfield = new JTextField(((WizardArgumentInterface)value).
4898                                        getString());
4899 
4900             cellObj = value;
4901 
4902             if (value instanceof ArgumentValue)
4903             {
4904                 button.setText("Edit...");
4905                 button.setPreferredSize(new Dimension(75, 27));
4906 
4907                 JPanel textpanel = new JPanel();
4908                 textpanel.setLayout(new BorderLayout());
4909                 textfield.setBorder(null);
4910                 textfield.setOpaque(true);
4911                 textfield.setBackground(Color.white);
4912                 textfield.setForeground(Color.black);
4913                 textfield.setEditable(true);
4914                 textfield.setFont(new Font("Monospaced", Font.PLAIN, 12));
4915                 textpanel.add(BorderLayout.CENTER, textfield);
4916 
4917                 JPanel buttonPanel = new JPanel();
4918                 buttonPanel.setLayout(new BorderLayout());
4919                 buttonPanel.add(BorderLayout.WEST, button);
4920 
4921                 resetButton.setText("Default");
4922 
4923                 ArgumentRequired argReq =
4924                     (ArgumentRequired)table.getModel().getValueAt(row, 2);
4925 
4926                 if (argReq.getString().equals("No"))
4927                 {
4928                     buttonPanel.add(BorderLayout.EAST, resetButton);
4929                 }
4930 
4931                 textpanel.add(BorderLayout.EAST, buttonPanel);
4932 
4933                 JPanel panel = new JPanel();
4934                 panel.setLayout(new BorderLayout());
4935                 panel.setBackground(Color.white);
4936                 panel.add(BorderLayout.NORTH, textpanel);
4937 
4938                 return panel;
4939             }
4940             else if (value instanceof ArgumentDescription)
4941             {
4942                 Color rowBackground = lightGreen;
4943 
4944                 if (value instanceof WizardArgumentInterface)
4945                 {
4946                     ArgumentRequired argReq =
4947                         (ArgumentRequired)table.getModel().getValueAt(row, 2);
4948 
4949                     if (argReq.getString().equals("Yes"))
4950                     {
4951                         ArgumentValue argValue =
4952                             (ArgumentValue)table.getModel().getValueAt(row, 3);
4953 
4954                         if (argValue.getString().equals(""))
4955                         {
4956                             rowBackground = lightRed;
4957                         }
4958                     }
4959                     else if (argReq.getString().equals("Other"))
4960                     {
4961                         ArgumentValue argValue =
4962                             (ArgumentValue)table.getModel().getValueAt(row, 3);
4963 
4964                         if (argValue.getString().equals(""))
4965                         {
4966                             rowBackground = lightYellow;
4967                         }
4968                     }
4969 
4970                     ArgumentName argName =
4971                         (ArgumentName)table.getModel().getValueAt(row, 0);
4972 
4973                     if (argName.getString().equals("STAXArg"))
4974                     {
4975                         ArgumentValue argValue =
4976                             (ArgumentValue)table.getModel().getValueAt(row, 3);
4977 
4978                         if (argValue.getString().equals(""))
4979                         {
4980                             rowBackground = lightYellow;
4981                         }
4982                     }
4983                 }
4984 
4985                 button.setText("More...");
4986                 button.setPreferredSize(new Dimension(75, 27));
4987 
4988                 JPanel textpanel = new JPanel();
4989                 textpanel.setLayout(new BorderLayout());
4990                 textpanel.setBackground(rowBackground);
4991                 textfield.setBorder(null);
4992                 textfield.setOpaque(true);
4993                 textfield.setBackground(rowBackground);
4994                 textfield.setForeground(Color.black);
4995                 textfield.setEditable(false);
4996                 textpanel.add(BorderLayout.CENTER, textfield);
4997                 textpanel.add(BorderLayout.EAST, button);
4998 
4999                 JPanel panel = new JPanel();
5000                 panel.setLayout(new BorderLayout());
5001                 panel.setBackground(rowBackground);
5002                 panel.add(BorderLayout.NORTH, textpanel);
5003 
5004                 return panel;
5005             }
5006             else
5007             {
5008                 JPanel panel = new JPanel();
5009                 panel.setBackground(Color.lightGray);
5010                 return panel;
5011             }
5012         }
5013 
getCellEditorValue()5014         public Object getCellEditorValue()
5015         {
5016             String value = "";
5017 
5018             if (isPushed)
5019             {
5020                 if (cellObj instanceof ArgumentValue)
5021                 {
5022                     ((ArgumentValue)(cellObj)).setString(textEditValue);
5023                     fEditValueTextArea.setText(
5024                         ((WizardArgumentInterface)(cellObj)).getString());
5025                     fEditValueTextArea.requestFocus();
5026                     fEditValueDialog.setLocationRelativeTo(
5027                         button.getParent());
5028                     fEditValueDialog.setTitle("Edit Argument Value");
5029 
5030                     final String originalText = textEditValue;
5031 
5032                     fEditValueSaveButton.addActionListener(new
5033                         ActionListener()
5034                     {
5035                         public void actionPerformed(ActionEvent e)
5036                         {
5037                             ((WizardArgumentInterface)(cellObj)).setString(
5038                                 fEditValueTextArea.getText());
5039                             fEditValueDialog.setVisible(false);
5040                         }
5041                     });
5042 
5043                     fEditValueCancelButton.addActionListener(new
5044                         ActionListener()
5045                     {
5046                         public void actionPerformed(ActionEvent e)
5047                         {
5048                             fEditValueDialog.setVisible(false);
5049                         }
5050                     });
5051 
5052                     fEditValueDialog.setVisible(true);
5053                     isPushed = false;
5054                 }
5055                 else if (cellObj instanceof ArgumentDescription)
5056                 {
5057                     fMoreDescriptionEditorPane.setText(
5058                         ((WizardArgumentInterface)(cellObj)).getString());
5059                     fMoreDescriptionEditorPane.requestFocus();
5060                     fMoreDescriptionDialog.setLocationRelativeTo(
5061                         button.getParent());
5062                     fMoreDescriptionDialog.setTitle("Argument Description");
5063 
5064                     final String originalText = textEditValue;
5065 
5066                     fMoreDescriptionCloseButton.addActionListener(new
5067                         ActionListener()
5068                     {
5069                         public void actionPerformed(ActionEvent e)
5070                         {
5071                             fMoreDescriptionDialog.setVisible(false);
5072                         }
5073                     });
5074 
5075                     fMoreDescriptionDialog.setVisible(true);
5076                     isPushed = false;
5077                 }
5078             }
5079 
5080             if (resetPushed)
5081             {
5082                 String defaultValue = "";
5083 
5084                 String function = (String)
5085                     fWizardFunctionsList.getSelectedValue();
5086 
5087                 if (function.indexOf("(default)") > -1)
5088                 {
5089                     function = function.substring(0, function.indexOf(" "));
5090                 }
5091 
5092                 Vector argDefaults = (Vector)
5093                     fWizardFunctionArgDefaultsMap.get(function);
5094 
5095                 ((WizardArgumentInterface)(cellObj)).setString(
5096                     (String)argDefaults.get(inputRow - 1));
5097                 resetPushed = false;
5098             }
5099 
5100             return cellObj;
5101         }
5102 
shouldSelectCell(EventObject e)5103         public boolean shouldSelectCell(EventObject e)
5104         {
5105             return true;
5106         }
5107 
stopCellEditing()5108         public boolean stopCellEditing()
5109         {
5110             if (cellObj instanceof ArgumentValue)
5111             {
5112                 ((WizardArgumentInterface)cellObj).
5113                     setString(textfield.getText());
5114             }
5115 
5116             isPushed = false;
5117             resetPushed = false;
5118 
5119             return super.stopCellEditing();
5120         }
5121 
fireEditingStopped()5122         protected void fireEditingStopped()
5123         {
5124             super.fireEditingStopped();
5125         }
5126     }
5127 
valueChanged(ListSelectionEvent e)5128     public void valueChanged(ListSelectionEvent e)
5129     {
5130         if (e.getSource() == fWizardFunctionsList)
5131         {
5132             updateWizardFunctionTable();
5133         }
5134         else
5135         {
5136             if (fActiveJobsTable.getSelectedRow() > -1)
5137             {
5138                 fDisplaySelectedJobLog.setEnabled(true);
5139                 fDisplaySelectedJobUserLog.setEnabled(true);
5140             }
5141             else
5142             {
5143                 fDisplaySelectedJobLog.setEnabled(false);
5144                 fDisplaySelectedJobUserLog.setEnabled(false);
5145             }
5146         }
5147     }
5148 
itemStateChanged(ItemEvent e)5149     public void itemStateChanged(ItemEvent e)
5150     {
5151         Object source = e.getSource();
5152 
5153         if ((source == fMonitorYesRB) ||
5154             (source == fMonitorNoRB) ||
5155             (source == fDefaultFunctionRB) ||
5156             (source == fOtherFunctionRB) ||
5157             (source == fMachineLocalRB) ||
5158             (source == fMachineOtherRB))
5159         {
5160             fCurrentJobParmsNotSaved = true;
5161             fStartNewJobFileSave.setEnabled(true);
5162             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
5163                                         fCurrentJobParmsFile + " *");
5164         }
5165 
5166         if (source == fMachineLocalRB)
5167         {
5168             if (fMachineLocalRB.isSelected())
5169             {
5170                 fOtherXmlFileMachineField.setEnabled(false);
5171                 fOtherXmlFileNameField.setEnabled(false);
5172                 fOtherXmlFileMachineField.setEnabled(false);
5173                 fBrowseButton.setEnabled(true);
5174                 fLocalXmlFileNameField.setEnabled(true);
5175             }
5176         }
5177         else if (source == fMachineOtherRB)
5178         {
5179             if (fMachineOtherRB.isSelected())
5180             {
5181                 fOtherXmlFileMachineField.setEnabled(true);
5182                 fOtherXmlFileNameField.setEnabled(true);
5183                 fBrowseButton.setEnabled(false);
5184                 fLocalXmlFileNameField.setEnabled(false);
5185             }
5186         }
5187         else if (source == fDefaultFunctionRB)
5188         {
5189             if (fDefaultFunctionRB.isSelected())
5190             {
5191                 fFunctionField.setEnabled(false);
5192             }
5193         }
5194         else if (source == fOtherFunctionRB)
5195         {
5196             if (fOtherFunctionRB.isSelected())
5197             {
5198                 fFunctionField.setEnabled(true);
5199             }
5200         }
5201         if (source == fLocalScriptMachineRB)
5202         {
5203             if (fLocalScriptMachineRB.isSelected())
5204             {
5205                 fScriptFilesMachineTextField.setEnabled(false);
5206                 fAddScriptFilesBrowseButton.setEnabled(true);
5207             }
5208         }
5209         else if (source == fXMLJobFileScriptMachineRB)
5210         {
5211             if (fXMLJobFileScriptMachineRB.isSelected())
5212             {
5213                 fScriptFilesMachineTextField.setEnabled(false);
5214                 fAddScriptFilesBrowseButton.setEnabled(true);
5215             }
5216         }
5217         else if (source == fOtherScriptMachineRB)
5218         {
5219             if (fOtherScriptMachineRB.isSelected())
5220             {
5221                 fScriptFilesMachineTextField.setEnabled(true);
5222                 fAddScriptFilesBrowseButton.setEnabled(false);
5223             }
5224         }
5225         else if (source == fLimitMessages)
5226         {
5227             if (fLimitMessages.isSelected())
5228             {
5229                 fLimitMessagesField.setEnabled(true);
5230 
5231                 if ((fLimitMessagesFieldText == null) ||
5232                     (fLimitMessagesFieldText.equals("")))
5233                 {
5234                     fLimitMessagesField.setText(fDefaultLimitMessagesText);
5235                 }
5236                 else
5237                 {
5238                     fLimitMessagesField.setText(fLimitMessagesFieldText);
5239                 }
5240             }
5241             else
5242             {
5243                 fLimitMessagesField.setEnabled(false);
5244                 fLimitMessagesField.setText("");
5245             }
5246         }
5247     }
5248 
keyPressed(KeyEvent e)5249     public void keyPressed(KeyEvent e) {}
5250 
keyReleased(KeyEvent e)5251     public void keyReleased(KeyEvent e) {}
5252 
keyTyped(KeyEvent e)5253     public void keyTyped(KeyEvent e)
5254     {
5255         Object source = e.getSource();
5256 
5257         if ((source == fJobNameField) ||
5258             (source == fFunctionField) ||
5259             (source == fArgs) ||
5260             (source == fLocalXmlFileNameField) ||
5261             (source == fOtherXmlFileMachineField) ||
5262             (source == fArguments) ||
5263             (source == fOtherXmlFileNameField))
5264         {
5265             fCurrentJobParmsNotSaved = true;
5266             fStartNewJobFileSave.setEnabled(true);
5267             fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
5268                                         fCurrentJobParmsFile + " *");
5269         }
5270 
5271     }
5272 
mouseClicked(MouseEvent e)5273     public void mouseClicked(MouseEvent e)
5274     {
5275         if (e.getSource() == fScriptList)
5276         {
5277             if (e.getClickCount() == 2)
5278             {
5279                 int editIndex = fScriptList.getSelectedIndex();
5280 
5281                 if (editIndex > -1)
5282                 {
5283                     String currentValue = (String)
5284                         ((DefaultListModel)(fScriptList.getModel())).
5285                         getElementAt(editIndex);
5286                     fEditScriptTextArea.setText(currentValue);
5287                     fEditScriptTextArea.setFont(
5288                         new Font("Monospaced", Font.PLAIN, 12));
5289                     fEditScriptTextArea.requestFocus();
5290                     fEditScriptDialog.setLocationRelativeTo(fStartNewJobDialog);
5291                     fEditScriptDialog.setVisible(true);
5292                 }
5293             }
5294         }
5295         else if (e.getSource() == fScriptFilesList)
5296         {
5297             if (e.getClickCount() == 2)
5298             {
5299                 int editIndex = fScriptFilesList.getSelectedIndex();
5300 
5301                 if (editIndex > -1)
5302                 {
5303                     String currentValue = (String)
5304                         ((DefaultListModel)(fScriptFilesList.getModel())).
5305                         getElementAt(editIndex);
5306                     fEditScriptFilesTextField.setText(currentValue);
5307                     fEditScriptFilesTextField.requestFocus();
5308                     fEditScriptFilesDialog.setLocationRelativeTo(
5309                         fStartNewJobDialog);
5310                     fEditScriptFilesDialog.setVisible(true);
5311                 }
5312             }
5313         }
5314         else if (e.getSource() == fPluginJarsList)
5315         {
5316             if (e.getClickCount() == 2)
5317             {
5318                 int editIndex = fPluginJarsList.getSelectedIndex();
5319 
5320                 if (editIndex > -1)
5321                 {
5322                     String currentValue = (String)
5323                         ((DefaultListModel)(fPluginJarsList.getModel())).
5324                         getElementAt(editIndex);
5325                     fEditPluginJarsTextField.setText(currentValue);
5326                     fEditPluginJarsTextField.requestFocus();
5327                     fEditPluginJarsDialog.setLocationRelativeTo(
5328                         fPropertiesDialog);
5329                     fEditPluginJarsDialog.setVisible(true);
5330                 }
5331             }
5332         }
5333         else if (e.getSource() == fBreakpointTable)
5334         {
5335             if (e.getClickCount() == 2)
5336             {
5337                 int editRow = fBreakpointTable.getSelectedRow();
5338 
5339                 if (editRow > -1)
5340                 {
5341                     String currentFunction = (String)
5342                         fBreakpointsTableModel.getValueAt(editRow, 0);
5343                     String currentLineNumber = (String)
5344                         fBreakpointsTableModel.getValueAt(editRow, 1);
5345                     String currentLineFile = (String)
5346                         fBreakpointsTableModel.getValueAt(editRow, 2);
5347                     String currentLineMachine = (String)
5348                         fBreakpointsTableModel.getValueAt(editRow, 3);
5349 
5350                     if (currentFunction.equals(""))
5351                     {
5352                         fEditBreakpointLineNumberTextField.setText(
5353                             currentLineNumber);
5354                         fEditBreakpointLineNumberTextField.setFont(
5355                             new Font("Dialog", Font.PLAIN, 12));
5356 
5357                         fEditBreakpointLineFileTextField.setText(
5358                             currentLineFile);
5359                         fEditBreakpointLineFileTextField.setFont(
5360                             new Font("Dialog", Font.PLAIN, 12));
5361 
5362                         fEditBreakpointLineMachineTextField.setText(
5363                             currentLineMachine);
5364                         fEditBreakpointLineMachineTextField.setFont(
5365                             new Font("Dialog", Font.PLAIN, 12));
5366 
5367                         fEditBreakpointLineNumberTextField.requestFocus();
5368                         fEditBreakpointLineDialog.setLocationRelativeTo(
5369                             fStartNewJobDialog);
5370                         fEditBreakpointLineDialog.setVisible(true);
5371                     }
5372                     else
5373                     {
5374                         fEditBreakpointFunctionTextField.setText(
5375                             currentFunction);
5376                         fEditBreakpointFunctionTextField.setFont(
5377                             new Font("Dialog", Font.PLAIN, 12));
5378                         fEditBreakpointFunctionTextField.requestFocus();
5379                         fEditBreakpointFunctionDialog.setLocationRelativeTo(
5380                             fStartNewJobDialog);
5381                         fEditBreakpointFunctionDialog.setVisible(true);
5382                     }
5383                 }
5384             }
5385         }
5386     }
5387 
mouseEntered(MouseEvent e)5388     public void mouseEntered(MouseEvent e) {}
mouseExited(MouseEvent e)5389     public void mouseExited(MouseEvent e) {}
5390 
mousePressed(MouseEvent e)5391     public void mousePressed(MouseEvent e)
5392     {
5393         displayPopup(e);
5394     }
5395 
mouseReleased(MouseEvent e)5396     public void mouseReleased(MouseEvent e)
5397     {
5398         displayPopup(e);
5399     }
5400 
displayPopup(MouseEvent e)5401     public void displayPopup(MouseEvent e)
5402     {
5403         if (e.isPopupTrigger())
5404         {
5405             synchronized (fActiveJobsModelSorter)
5406             {
5407                 int tableIndex =
5408                     fActiveJobsTable.rowAtPoint(new Point(e.getX(), e.getY()));
5409 
5410                 if (tableIndex > -1)
5411                 {
5412                     fActiveJobsTable.setRowSelectionInterval(tableIndex,
5413                                                              tableIndex);
5414 
5415                     // Check what the status is for this job
5416 
5417                     String status = "";
5418 
5419                     try
5420                     {
5421                         status = (String)fActiveJobsTable.getValueAt(
5422                             tableIndex, 4);
5423                     }
5424                     catch (ClassCastException ex)
5425                     {
5426                         // XXX: This is for debugging how this could happen
5427                         System.out.println(
5428                             "Invalid status column in Active Jobs Table: " +
5429                             fActiveJobsTable.getValueAt(tableIndex, 4));
5430                         throw ex;
5431                     }
5432 
5433                     // Check if the job is already being monitored
5434 
5435                     Boolean isMonitored = new Boolean(false);
5436 
5437                     try
5438                     {
5439                         isMonitored = (Boolean)fActiveJobsTable.getValueAt(
5440                             tableIndex, 2);
5441                     }
5442                     catch (ClassCastException ex)
5443                     {
5444                         // XXX: This is for debugging how this could happen
5445                         System.out.println(
5446                             "Invalid isMonitored column in Active Jobs Table: " +
5447                             fActiveJobsTable.getValueAt(tableIndex, 2));
5448                         throw ex;
5449                     }
5450 
5451                     // Determine if the "Show Monitor Window" menu item for
5452                     // this job should be greyed out or not based on if the
5453                     // job is already being monitored or not.
5454                     // And determine if the "Start Monitoring" menu item for
5455                     // this job should be greyed out or not based on if the
5456                     // job is already be being monitored or not and if the
5457                     // job is in a Pending state.
5458 
5459                     if (isMonitored.booleanValue())
5460                     {
5461                         fJobShowMonitorMenuItem.setEnabled(true);
5462                         fJobStartMonitorMenuItem.setEnabled(false);
5463                     }
5464                     else
5465                     {
5466                         fJobShowMonitorMenuItem.setEnabled(false);
5467 
5468                         // Don't allow job to be monitored if it's in a
5469                         // "Pending" state
5470 
5471                         if (status.equals("Pending"))
5472                             fJobStartMonitorMenuItem.setEnabled(false);
5473                         else
5474                             fJobStartMonitorMenuItem.setEnabled(true);
5475                     }
5476 
5477                     // Determine if the "Terminate Job" menu item for this
5478                     // job should be greyed out or not based on the job's
5479                     // status.  Only allow a job to be terminated if it is
5480                     // in a "Running" state.
5481 
5482                     if (status.equals("Complete"))
5483                         fJobTerminateJobMenuItem.setEnabled(false);
5484                     else if (status.equals("Pending"))
5485                         fJobTerminateJobMenuItem.setEnabled(false);
5486                     else
5487                         fJobTerminateJobMenuItem.setEnabled(true);
5488 
5489                     fJobPopupMenu.show(e.getComponent(), e.getX(), e.getY());
5490                 }
5491             }
5492         }
5493     }
5494 
5495     /**
5496      * This method is called when a job is no longer being monitored.
5497      * @param jobNumber A string containing the ID for the job that is no
5498      * longer being monitored
5499      */
monitorExiting(String jobNumber)5500     public void monitorExiting(String jobNumber)
5501     {
5502         synchronized(fActiveJobsModelSorter)
5503         {
5504             synchronized (fMonitorTable)
5505             {
5506                 if (fMonitorTable.containsKey(jobNumber))
5507                     fMonitorTable.remove(jobNumber);
5508             }
5509 
5510             // Check if the job is found in the Active Jobs Table and if so,
5511             // set isComplete to true if the job is complete or false if it's
5512             // still running.
5513 
5514             Vector jobsVector = fActiveJobsTableModel.getDataVector();
5515 
5516             boolean isComplete = false;
5517             int rowIndex = -1;
5518 
5519             for (int j = 0; j < jobsVector.size(); j++)
5520             {
5521                 if (((Vector)(jobsVector.elementAt(j))).elementAt(0).equals(
5522                     new Integer(jobNumber)))
5523                 {
5524                     isComplete = ((String)((Vector)(jobsVector.elementAt(j))).
5525                                   elementAt(4)).equals("Complete");
5526                     rowIndex = j;
5527                     break;
5528                 }
5529             }
5530 
5531             if (rowIndex == -1)
5532                 return;  // Job ID not found in Active Jobs Table
5533 
5534             if (isComplete)
5535             {
5536                 // Remove the completed job from the Active Jobs Table since
5537                 // it is no longer being monitored.
5538 
5539                 fJobPopupMenu.setVisible(false);
5540 
5541                 fActiveJobsTableModel.removeRow(rowIndex);
5542                 ((STAXMonitorTableCellRenderer)fActiveJobsTable.
5543                  getColumnModel().getColumn(0).getCellRenderer()).
5544                     clearRowHeights();
5545 
5546                 repaint();
5547                 invalidate();
5548                 validate();
5549             }
5550             else
5551             {
5552                 // Indicate that the job is no longer being monitored
5553 
5554                 fActiveJobsTableModel.setValueAt(
5555                     new Boolean(false), rowIndex, 2);
5556             }
5557 
5558             synchronized (fActiveJobsTable)
5559             {
5560                 fActiveJobsTable.updateUI();
5561                 STAXMonitorUtil.updateRowHeights(fActiveJobsTable, 7);
5562                 STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
5563             }
5564         }
5565     }
5566 
main(String argv[])5567     public static void main(String argv[])
5568     {
5569         new STAXMonitor(argv);
5570     }
5571 
5572     /**
5573      * Converts the "pretty" value for "Python Output", as displayed by the
5574      * STAX Monitor in the combo box, to a valid value for the PYTHONOUTPUT
5575      * option
5576      * @param pythonOutput A string containing the "pretty" value for the
5577      * PYTHONOUTPUT option
5578      * @returns A string containing a valid value for the PYTHONOUTPUT option
5579      */
getPythonOutputFromPrettyString(String pythonOutput)5580     private static String getPythonOutputFromPrettyString(String pythonOutput)
5581     {
5582         if (pythonOutput.equals(JOBUSERLOG_PRETTY))
5583             return JOBUSERLOG_STRING;
5584         else if (pythonOutput.equals(MESSAGE_PRETTY))
5585             return MESSAGE_STRING;
5586         else if (pythonOutput.equals(JOBUSERLOGANDMSG_PRETTY))
5587             return JOBUSERLOGANDMSG_STRING;
5588         else if (pythonOutput.equals(JVMLOG_PRETTY))
5589             return JVMLOG_STRING;
5590         else
5591             return DEFAULT_STRING;
5592     }
5593 
5594     /**
5595      * Converts a valid value for the PYTHONOUTPUT option to the "pretty"
5596      * value for "Python Output", as displayed by the
5597      * STAX Monitor in the combo box
5598      * @param pythonOutput A string containing a valid value for the
5599      * PYTHONOUTPUT option
5600      * @returns A string containing the "pretty" value for "Python Output",
5601      * that can be displayed by the STAX Monitor in the "Python Output"
5602      * combo box
5603      */
getPrettyPythonOutput(String pythonOutput)5604     private static String getPrettyPythonOutput(String pythonOutput)
5605     {
5606         if (pythonOutput.equals(JOBUSERLOG_STRING))
5607             return JOBUSERLOG_PRETTY;
5608         else if (pythonOutput.equals(MESSAGE_STRING))
5609             return MESSAGE_PRETTY;
5610         else if (pythonOutput.equals(JOBUSERLOGANDMSG_STRING))
5611             return JOBUSERLOGANDMSG_PRETTY;
5612         else if (pythonOutput.equals(JVMLOG_STRING))
5613             return JVMLOG_PRETTY;
5614         else
5615             return DEFAULT_STRING;
5616     }
5617 
resolveVar(String optionValue, int handle)5618     private String resolveVar(String optionValue, int handle)
5619     {
5620         String value = optionValue;
5621         STAFResult resolvedResult = null;
5622 
5623         if (optionValue.indexOf("{") != -1)
5624         {
5625             resolvedResult = fHandle.submit2(
5626                 "local", "VAR", "RESOLVE ASHANDLE " + handle + " STRING " +
5627                 optionValue);
5628 
5629             if (resolvedResult.rc != 0)
5630             {
5631                 return optionValue;
5632             }
5633 
5634             value = resolvedResult.result;
5635         }
5636 
5637         return value;
5638     }
5639 
validateProperties()5640     public boolean validateProperties()
5641     {
5642         if (fStaxMachineNameField.getText().equals(""))
5643         {
5644             JOptionPane.showMessageDialog(fPropertiesDialog,
5645                 "You must enter the STAX Machine Name",
5646                 "Properties Error", JOptionPane.ERROR_MESSAGE);
5647             return false;
5648         }
5649 
5650         if (fStaxServiceNameField.getText().equals(""))
5651         {
5652             JOptionPane.showMessageDialog(fPropertiesDialog,
5653                 "You must enter the STAX Service Name",
5654                 "Properties Error", JOptionPane.ERROR_MESSAGE);
5655             return false;
5656         }
5657 
5658         // Get Event machine/service based on STAX machine/service
5659 
5660         EventServiceInfo eventServiceInfo = new EventServiceInfo(
5661             fStaxMachineNameField.getText(), fStaxServiceNameField.getText(),
5662             this, true);
5663 
5664         fEventMachineNameField.setText(eventServiceInfo.getMachine());
5665         fEventServiceNameField.setText(eventServiceInfo.getService());
5666 
5667         String processMonitorSeconds = fProcessMonitorSecondsField.getText();
5668         Integer seconds;
5669 
5670         try
5671         {
5672             seconds = new Integer(processMonitorSeconds);
5673         }
5674         catch (NumberFormatException e)
5675         {
5676             JOptionPane.showMessageDialog(fPropertiesDialog,
5677                 "Invalid number specified for Process Monitor Seconds",
5678                 "Properties Error", JOptionPane.ERROR_MESSAGE);
5679 
5680             return false;
5681         }
5682 
5683         if (seconds.intValue() < 0)
5684         {
5685             JOptionPane.showMessageDialog(fPropertiesDialog,
5686                 "Process Monitor Seconds must be 0 or greater",
5687                 "Properties Error", JOptionPane.ERROR_MESSAGE);
5688 
5689             return false;
5690         }
5691 
5692         String elapsedTimeSeconds = fElapsedTimeSecondsField.getText();
5693 
5694         try
5695         {
5696             seconds = new Integer(elapsedTimeSeconds);
5697         }
5698         catch (NumberFormatException e)
5699         {
5700             JOptionPane.showMessageDialog(fPropertiesDialog,
5701                 "Invalid number specified for Elapsed Time Seconds",
5702                 "Properties Error", JOptionPane.ERROR_MESSAGE);
5703 
5704             return false;
5705         }
5706 
5707         if (seconds.intValue() < 0)
5708         {
5709             JOptionPane.showMessageDialog(fPropertiesDialog,
5710                 "Elapsed Time Seconds must be 0 or greater",
5711                 "Properties Error", JOptionPane.ERROR_MESSAGE);
5712 
5713             return false;
5714         }
5715 
5716         return true;
5717     }
5718 
validateParms(String type)5719     public boolean validateParms(String type)
5720     {
5721         if (fMachineLocalRB.isSelected())
5722         {
5723             if (fLocalXmlFileNameField.getText().equals(""))
5724             {
5725                 JOptionPane.showMessageDialog(
5726                     fStartNewJobDialog,
5727                     "You must enter the local XML File name",
5728                     "Error " + type + "ing job",
5729                     JOptionPane.ERROR_MESSAGE);
5730                 return false;
5731             }
5732         }
5733         else
5734         {
5735             if (fOtherXmlFileNameField.getText().equals(""))
5736             {
5737                 JOptionPane.showMessageDialog(
5738                     fStartNewJobDialog,
5739                     "You must enter the other XML File name",
5740                     "Error " + type + "ing job",
5741                     JOptionPane.ERROR_MESSAGE);
5742                 return false;
5743             }
5744         }
5745 
5746         if (fMachineOtherRB.isSelected() &&
5747             fOtherXmlFileMachineField.getText().equals(""))
5748         {
5749             JOptionPane.showMessageDialog(
5750                 fStartNewJobDialog,
5751                 "You must enter the Machine name",
5752                 "Error " + type + "ing job",
5753                 JOptionPane.ERROR_MESSAGE);
5754             return false;
5755         }
5756 
5757         if (fOtherFunctionRB.isSelected() &&
5758             fFunctionField.getText().equals(""))
5759         {
5760             JOptionPane.showMessageDialog(
5761                 fStartNewJobDialog,
5762                 "You must enter the Function name",
5763                 "Error " + type + "ing job",
5764                 JOptionPane.ERROR_MESSAGE);
5765             return false;
5766         }
5767 
5768         if (fOtherScriptMachineRB.isSelected() &&
5769             fScriptFilesMachineTextField.getText().equals(""))
5770         {
5771             JOptionPane.showMessageDialog(
5772                 fStartNewJobDialog,
5773                 "You must enter the Other Script File machine name",
5774                 "Error " + type + "ing job",
5775                 JOptionPane.ERROR_MESSAGE);
5776             return false;
5777         }
5778 
5779         return true;
5780     }
5781 
submitNewJob()5782     public boolean submitNewJob()
5783     {
5784         if (fMonitorNoRB.isSelected())
5785         {
5786             StringBuffer request = new StringBuffer();
5787 
5788             if (fMachineLocalRB.isSelected())
5789             {
5790                 request.append("EXECUTE FILE ").append(
5791                     STAFUtil.wrapData(fLocalXmlFileName));
5792             }
5793             else
5794             {
5795                 request.append("EXECUTE FILE ").append(
5796                     STAFUtil.wrapData(fOtherXmlFileName));
5797                 request.append(" MACHINE ").append(
5798                            STAFUtil.wrapData(fOtherXmlFileMachineName));
5799             }
5800 
5801             if (fOtherFunctionRB.isSelected())
5802             {
5803                 request.append(" FUNCTION ").append(
5804                     STAFUtil.wrapData(fFunction));
5805             }
5806 
5807             if (fArgs != null && !(fArgs.equals("")))
5808             {
5809                 request.append(" ARGS ").append(STAFUtil.wrapData(fArgs));
5810             }
5811 
5812             if (fArgs != null && !fJobName.equals(""))
5813             {
5814                 request.append(" JOBNAME ").append(
5815                     STAFUtil.wrapData(fJobName));
5816             }
5817 
5818             fScriptVector = new Vector();
5819             Enumeration e = ((DefaultListModel)(fScriptList.getModel())).
5820                 elements();
5821 
5822             while (e.hasMoreElements())
5823             {
5824                 String nextScript = (String)e.nextElement();
5825                 fScriptVector.addElement(nextScript);
5826                 request.append(" SCRIPT ").append(
5827                     STAFUtil.wrapData(nextScript));
5828             }
5829 
5830             if (((DefaultListModel)(fScriptFilesList.getModel())).getSize() > 0)
5831             {
5832                 if (fXMLJobFileScriptMachineRB.isSelected())
5833                 {
5834                     // Don't add a SCRIPTFILEMACHINE option since it will
5835                     // default to the XML Job File machine if not specified
5836                 }
5837                 else if (fLocalScriptMachineRB.isSelected())
5838                 {
5839                     request.append(" SCRIPTFILEMACHINE ").append(
5840                         STAFUtil.wrapData(fSTAXMonitorEndpoint));
5841                 }
5842                 else if (fOtherScriptMachineRB.isSelected())
5843                 {
5844                     request.append(" SCRIPTFILEMACHINE ").append(
5845                         STAFUtil.wrapData(fScriptFilesMachineName));
5846                 }
5847             }
5848 
5849             fScriptFilesVector = new Vector();
5850             e = ((DefaultListModel)(fScriptFilesList.getModel())).elements();
5851 
5852             while (e.hasMoreElements())
5853             {
5854                 String nextScriptFile = (String)e.nextElement();
5855                 fScriptFilesVector.addElement(nextScriptFile);
5856                 request.append(" SCRIPTFILE ").append(
5857                     STAFUtil.wrapData(nextScriptFile));
5858             }
5859 
5860             if (fClearLogsYesRB.isSelected())
5861             {
5862                 request.append(" CLEARLOGS Enabled");
5863             }
5864             else if (fClearLogsNoRB.isSelected())
5865             {
5866                 request.append(" CLEARLOGS Disabled");
5867             }
5868 
5869             if (fLogTCElapsedTimeYesRB.isSelected())
5870             {
5871                 request.append(" LOGTCELAPSEDTIME Enabled");
5872             }
5873             else if (fLogTCElapsedTimeNoRB.isSelected())
5874             {
5875                 request.append(" LOGTCELAPSEDTIME Disabled");
5876             }
5877 
5878             if (fLogTCNumStartsYesRB.isSelected())
5879             {
5880                 request.append(" LOGTCNUMSTARTS Enabled");
5881             }
5882             else if (fLogTCNumStartsNoRB.isSelected())
5883             {
5884                 request.append(" LOGTCNUMSTARTS Disabled");
5885             }
5886 
5887             if (fLogTCStartStopYesRB.isSelected())
5888             {
5889                 request.append(" LOGTCSTARTSTOP Enabled");
5890             }
5891             else if (fLogTCStartStopNoRB.isSelected())
5892             {
5893                 request.append(" LOGTCSTARTSTOP Disabled");
5894             }
5895 
5896             String pythonOutput = getPythonOutputFromPrettyString(
5897                 (String)fPythonOutputCB.getSelectedItem());
5898 
5899             if (!pythonOutput.equals(DEFAULT_STRING))
5900             {
5901                 request.append(" PYTHONOUTPUT " + pythonOutput);
5902             }
5903 
5904             String pythonLogLevel = (String)fPythonLogLevelCB.getSelectedItem();
5905 
5906             if (!pythonLogLevel.equals(DEFAULT_STRING))
5907             {
5908                 request.append(" PYTHONLOGLEVEL " + pythonLogLevel);
5909             }
5910 
5911             for (int i = 0; i < fBreakpointTable.getRowCount(); i++)
5912             {
5913                 String function =
5914                     ((String)fBreakpointTable.getValueAt(i, 0)).trim();
5915                 String line =
5916                     ((String)fBreakpointTable.getValueAt(i, 1)).trim();
5917                 String xmlFile =
5918                     ((String)fBreakpointTable.getValueAt(i, 2)).trim();
5919                 String xmlMachine =
5920                     ((String)fBreakpointTable.getValueAt(i, 3)).trim();
5921 
5922                 if (function.equals(""))
5923                 {
5924                     if (xmlFile.equals(""))
5925                     {
5926                         if (fMachineLocalRB.isSelected())
5927                         {
5928                             xmlFile = fLocalXmlFileName;
5929                         }
5930                         else
5931                         {
5932                             xmlFile = fOtherXmlFileName;
5933                         }
5934                     }
5935 
5936                     if (!(xmlMachine.equals("")))
5937                     {
5938                         xmlMachine = " MACHINE " + STAFUtil.wrapData(xmlMachine);
5939                     }
5940 
5941                     if (!(xmlFile.equals("")))
5942                     {
5943                         request.append(" BREAKPOINT " +
5944                             STAFUtil.wrapData(line + "@@" +
5945                                               xmlFile + "@@" +
5946                                               xmlMachine));
5947                     }
5948                 }
5949                 else
5950                 {
5951                     request.append(" BREAKPOINT " +
5952                         STAFUtil.wrapData(function));
5953                 }
5954             }
5955 
5956             if (fBreakpointFirstFunctionCB.isSelected())
5957             {
5958                 request.append(" BREAKPOINTFIRSTFUNCTION");
5959             }
5960 
5961             if (fBreakpointSubjobFirstFunctionCB.isSelected())
5962             {
5963                 request.append(" BREAKPOINTSUBJOBFIRSTFUNCTION");
5964             }
5965 
5966             // Submit the STAX EXECUTE request and display a "Please Wait"
5967             // dialog while the request is preparing to run the job
5968 
5969             STAXMonitorExecuteResult executeResult = submitExecuteRequest(
5970                 request.toString());
5971 
5972             if (executeResult.getRC() != STAFResult.Ok)
5973             {
5974                 // Display a "STAX Error" popup with an error message
5975 
5976                 STAXMonitorUtil.showErrorDialog(
5977                     this,
5978                     executeResult.getResult().toString(),
5979                     new Font("Courier", Font.PLAIN, 12));
5980 
5981                 return false;
5982             }
5983         }
5984         else
5985         {
5986             try
5987             {
5988                 fScriptVector = new Vector();
5989                 Enumeration e = ((DefaultListModel)(fScriptList.getModel())).
5990                     elements();
5991 
5992                 while (e.hasMoreElements())
5993                 {
5994                     fScriptVector.addElement(e.nextElement());
5995                 }
5996 
5997                 fScriptFilesVector = new Vector();
5998                 e = ((DefaultListModel)
5999                     (fScriptFilesList.getModel())).elements();
6000 
6001                 while (e.hasMoreElements())
6002                 {
6003                     fScriptFilesVector.addElement(e.nextElement());
6004                 }
6005 
6006                 String file = "";
6007                 String xmlMachine = "";
6008                 String function = "";
6009 
6010                 if (fMachineLocalRB.isSelected())
6011                 {
6012                     file = fLocalXmlFileName;
6013                 }
6014                 else
6015                 {
6016                     file = fOtherXmlFileName;
6017                     xmlMachine = fOtherXmlFileMachineName;
6018                 }
6019 
6020                 if (fOtherFunctionRB.isSelected())
6021                 {
6022                     function = fFunction;
6023                 }
6024 
6025                 String limitMsgs = "";
6026 
6027                 if (fLimitMessagesField.getText().equals(""))
6028                 {
6029                     limitMsgs = "-1";
6030                 }
6031                 else
6032                 {
6033                     limitMsgs = fLimitMessagesField.getText();
6034                 }
6035 
6036                 String scriptFilesMachineName = fScriptFilesMachineName;
6037 
6038                 if (fLocalScriptMachineRB.isSelected())
6039                     scriptFilesMachineName = fSTAXMonitorEndpoint;
6040                 else if (fOtherScriptMachineRB.isSelected())
6041                     scriptFilesMachineName = fScriptFilesMachineName;
6042                 else
6043                     scriptFilesMachineName = "";
6044 
6045                 int autoMonitor = 0;
6046 
6047                 if (fAutoMonitorSubjobs)
6048                 {
6049                     autoMonitor = STAXMonitorFrame.AUTOMONITOR_ALWAYS;
6050                 }
6051                 else if (fAutoMonitorRecommendedSubjobs)
6052                 {
6053                     autoMonitor = STAXMonitorFrame.AUTOMONITOR_RECOMMENDED;
6054                 }
6055                 else if (fNeverAutoMonitorSubjobs)
6056                 {
6057                     autoMonitor = STAXMonitorFrame.AUTOMONITOR_NEVER;
6058                 }
6059 
6060                 int clearLogs = STAXMonitorFrame.DEFAULT;
6061 
6062                 if (fClearLogsYesRB.isSelected())
6063                     clearLogs = STAXMonitorFrame.ENABLED;
6064                 else if (fClearLogsNoRB.isSelected())
6065                     clearLogs = STAXMonitorFrame.DISABLED;
6066 
6067                 int logTCElapsedTime = STAXMonitorFrame.DEFAULT;
6068 
6069                 if (fLogTCElapsedTimeYesRB.isSelected())
6070                     logTCElapsedTime = STAXMonitorFrame.ENABLED;
6071                 else if (fLogTCElapsedTimeNoRB.isSelected())
6072                     logTCElapsedTime = STAXMonitorFrame.DISABLED;
6073 
6074                 int logTCNumStarts = STAXMonitorFrame.DEFAULT;
6075 
6076                 if (fLogTCNumStartsYesRB.isSelected())
6077                     logTCNumStarts = STAXMonitorFrame.ENABLED;
6078                 else if (fLogTCNumStartsNoRB.isSelected())
6079                     logTCNumStarts = STAXMonitorFrame.DISABLED;
6080 
6081                 int logTCStartStop = STAXMonitorFrame.DEFAULT;
6082 
6083                 if (fLogTCStartStopYesRB.isSelected())
6084                     logTCStartStop = STAXMonitorFrame.ENABLED;
6085                 else if (fLogTCStartStopNoRB.isSelected())
6086                     logTCStartStop = STAXMonitorFrame.DISABLED;
6087 
6088 
6089                 String pythonOutput = getPythonOutputFromPrettyString(
6090                     (String)fPythonOutputCB.getSelectedItem());
6091 
6092                 String pythonLogLevel =
6093                     (String)fPythonLogLevelCB.getSelectedItem();
6094 
6095                 Vector breakpointTriggerVector = new Vector();
6096 
6097                 for (int i = 0; i < fBreakpointTable.getRowCount(); i++)
6098                 {
6099                     String bpFunction =
6100                         ((String)fBreakpointTable.getValueAt(i, 0)).trim();
6101                     String bpLine =
6102                         ((String)fBreakpointTable.getValueAt(i, 1)).trim();
6103                     String bpXmlFile =
6104                         ((String)fBreakpointTable.getValueAt(i, 2)).trim();
6105                     String bpXmlMachine =
6106                         ((String)fBreakpointTable.getValueAt(i, 3)).trim();
6107 
6108                     if (bpFunction.equals(""))
6109                     {
6110                         if (bpXmlFile.equals(""))
6111                         {
6112                             if (fMachineLocalRB.isSelected())
6113                             {
6114                                 bpXmlFile = fLocalXmlFileName;
6115                             }
6116                             else
6117                             {
6118                                 bpXmlFile = fOtherXmlFileName;
6119                             }
6120                         }
6121 
6122                         if (!(bpXmlMachine.equals("")))
6123                         {
6124                             bpXmlMachine = " MACHINE " +
6125                                 STAFUtil.wrapData(bpXmlMachine);
6126                         }
6127 
6128                         if (!(bpXmlFile.equals("")))
6129                         {
6130                             breakpointTriggerVector.add(" BREAKPOINT " +
6131                                 STAFUtil.wrapData(bpLine + "@@" +
6132                                                   bpXmlFile + "@@" +
6133                                                   bpXmlMachine));
6134                         }
6135                     }
6136                     else
6137                     {
6138                         breakpointTriggerVector.add(" BREAKPOINT " +
6139                             STAFUtil.wrapData(bpFunction));
6140                     }
6141                 }
6142 
6143                 boolean breakpointFirstFunction =
6144                     fBreakpointFirstFunctionCB.isSelected();
6145 
6146                 boolean breakpointSubjobFirstFunction =
6147                     fBreakpointSubjobFirstFunctionCB.isSelected();
6148 
6149                 STAXMonitorFrame monitor = new STAXMonitorFrame(
6150                     this, fStaxMachineName, fStaxServiceName,
6151                     fStaxMachineNickname, "",
6152                     fEventMachineName, fEventServiceName,
6153                     file, xmlMachine, function, fArgs, fJobName,
6154                     fScriptVector, fShowNoSTAXMonitorInformation.isSelected(),
6155                     limitMsgs, fLocalExtJarFiles, fScriptFilesVector,
6156                     scriptFilesMachineName, clearLogs, logTCElapsedTime,
6157                     logTCNumStarts, logTCStartStop, autoMonitor,
6158                     pythonOutput, pythonLogLevel, breakpointTriggerVector,
6159                     breakpointFirstFunction, breakpointSubjobFirstFunction);
6160 
6161                 synchronized (fMonitorTable)
6162                 {
6163                     fMonitorTable.put(monitor.getJobNumber(), monitor);
6164 
6165                     if (fStartNewJobCloseOnEnd)
6166                     {
6167                         fCloseOnEndJobID = monitor.getJobNumber();
6168                     }
6169                 }
6170 
6171                 // Update the "Monitored" column for the job in the Active
6172                 // Jobs Table to show the job is being monitored
6173 
6174                 synchronized (fActiveJobsTable)
6175                 {
6176                     Vector jobsVector = fActiveJobsTableModel.getDataVector();
6177 
6178                     for (int j = 0; j < jobsVector.size(); j++)
6179                     {
6180                         if (((Vector)(jobsVector.elementAt(j))).elementAt(0).
6181                             equals(new Integer(monitor.getJobNumber())))
6182                         {
6183                             fActiveJobsModelSorter.setValueAt(
6184                                 new Boolean(true), j, 2);
6185                             fActiveJobsTable.updateUI();
6186                             STAXMonitorUtil.sizeColumnsToFitText(
6187                                 fActiveJobsTable);
6188                             STAXMonitorUtil.updateRowHeights(
6189                                 fActiveJobsTable, 7);
6190                             break;
6191                         }
6192                     }
6193                 }
6194             }
6195             catch (STAFException ex)
6196             {
6197                 // Display a "STAX Error" popup with an error message
6198 
6199                 STAXMonitorUtil.showErrorDialog(
6200                     this, ex.getMessage(),
6201                     new Font("Courier", Font.PLAIN, 12));
6202 
6203                 return false;
6204             }
6205         }
6206 
6207         return true;
6208     }
6209 
testJob()6210     public boolean testJob()
6211     {
6212         StringBuffer request = new StringBuffer();
6213 
6214         if (fMachineLocalRB.isSelected())
6215         {
6216             request.append("EXECUTE FILE ").append(
6217                        STAFUtil.wrapData(fLocalXmlFileName));
6218         }
6219         else
6220         {
6221             request.append("EXECUTE FILE ").append(
6222                       STAFUtil.wrapData(fOtherXmlFileName));
6223             request.append(" MACHINE ").append(
6224                        STAFUtil.wrapData(fOtherXmlFileMachineName));
6225         }
6226 
6227         if (fOtherFunctionRB.isSelected())
6228         {
6229             request.append(" FUNCTION ").append(STAFUtil.wrapData(fFunction));
6230         }
6231 
6232         if (!(fArgs.equals("")))
6233         {
6234             request.append(" ARGS ").append(STAFUtil.wrapData(fArgs));
6235         }
6236 
6237         if (!fJobName.equals(""))
6238         {
6239             request.append(" JOBNAME ").append(STAFUtil.wrapData(fJobName));
6240         }
6241 
6242         fScriptVector = new Vector();
6243         Enumeration e = ((DefaultListModel)(fScriptList.getModel())).
6244             elements();
6245 
6246         while (e.hasMoreElements())
6247         {
6248             String nextScript = (String)e.nextElement();
6249             fScriptVector.addElement(nextScript);
6250             request.append(" SCRIPT ").append(STAFUtil.wrapData(nextScript));
6251         }
6252 
6253         if (((DefaultListModel)(fScriptFilesList.getModel())).getSize() > 0)
6254         {
6255             if (fXMLJobFileScriptMachineRB.isSelected())
6256             {
6257                 // Don't add a SCRIPTFILEMACHINE option since it will
6258                 // default to the XML Job File machine if not specified
6259             }
6260             else if (fLocalScriptMachineRB.isSelected())
6261             {
6262                 request.append(" SCRIPTFILEMACHINE ").append(
6263                     STAFUtil.wrapData(fSTAXMonitorEndpoint));
6264             }
6265             else if (fOtherScriptMachineRB.isSelected())
6266             {
6267                 request.append(" SCRIPTFILEMACHINE ").append(
6268                     STAFUtil.wrapData(fScriptFilesMachineName));
6269             }
6270         }
6271 
6272         fScriptFilesVector = new Vector();
6273         e = ((DefaultListModel)(fScriptFilesList.getModel())).elements();
6274 
6275         while (e.hasMoreElements())
6276         {
6277             String nextScriptFile = (String)e.nextElement();
6278             fScriptFilesVector.addElement(nextScriptFile);
6279             request.append(" SCRIPTFILE ").append(
6280                 STAFUtil.wrapData(nextScriptFile));
6281         }
6282 
6283         request.append(" TEST");
6284 
6285         // Submit the STAX EXECUTE request and display a "Please Wait" dialog
6286         // while the request is running to validate the xml file
6287 
6288         STAXMonitorExecuteResult executeResult = submitExecuteRequest(
6289             request.toString());
6290 
6291         if (executeResult.getRC() != STAFResult.Ok)
6292         {
6293             // Display a "STAX Error" popup with an error message
6294 
6295             STAXMonitorUtil.showErrorDialog(
6296                 fStartNewJobDialog,
6297                 executeResult.getResult().toString(),
6298                 new Font("Courier", Font.PLAIN, 12));
6299 
6300             return false;
6301         }
6302 
6303         // Display a "Validation Successful" popup with the Job ID in the
6304         // message
6305 
6306         JOptionPane.showMessageDialog(
6307             fStartNewJobDialog,
6308             "Validation Successful\n\n" +
6309             "The job ID generated was: " + executeResult.getResult(),
6310             "Validation Successful",
6311             JOptionPane.INFORMATION_MESSAGE);
6312 
6313         return true;
6314     }
6315 
6316     /**
6317      * Submits the specified EXECUTE request to the STAX service and displays
6318      * a * "Please wait" message while the request is preparing to execute
6319      * the STAX job.
6320      * @param request The EXECUTE request to be submitted to the STAX service
6321      * @return STAXMonitorExecuteResult
6322      * If no error occurred submitting the request, its fRC field will be 0
6323      * and its fResult field will contain the result from the request.
6324      * Or, if an error occurred submitting the request, its fRC field will be
6325      * non-zero and its fResult field will contain an error message string.
6326      */
submitExecuteRequest(String request)6327     public STAXMonitorExecuteResult submitExecuteRequest(String request)
6328     {
6329         // Create a new handle to submit the STAX EXECUTE request
6330         // asynchronously so that it's queue will only contain the
6331         // STAF/RequestComplete message for this STAF service request
6332 
6333         STAFHandle fSubmitHandle = null;
6334 
6335         try
6336         {
6337             fSubmitHandle = STAXMonitorUtil.getNewSTAFHandle(
6338                 fStaxServiceName + "/JobMonitor/" + fStaxMachineName +
6339                 "/SubmitExecute");
6340         }
6341         catch (STAFException ex)
6342         {
6343             return new STAXMonitorExecuteResult(
6344                 ex.rc,
6345                 "Creating a new STAF handle to submit a STAX EXECUTE " +
6346                 "request failed.\n" + ex.toString());
6347         }
6348 
6349         // Submit the STAX EXECUTE request asynchronously because it
6350         // may take more than a few seconds to validate the xml file
6351         // (especially if it contains <function-import> elements)
6352 
6353         STAFResult result = fSubmitHandle.submit2(
6354             STAFHandle.ReqQueue,
6355             fStaxMachineName, fStaxServiceName, request.toString());
6356 
6357         int requestNumber = 0;
6358 
6359         if (result.rc == 0)
6360             requestNumber = Integer.parseInt(result.result);
6361 
6362         if ((result.rc != 0) || (requestNumber == 0))
6363         {
6364             // Submitting the STAX EXECUTE request failed
6365 
6366             return new STAXMonitorExecuteResult(
6367                 result.rc,
6368                 "RC: " + result.rc + "\n" + result.result +
6369                 "\n\nSTAF " + fStaxMachineName + " " + fStaxServiceName +
6370                 " " + request.toString() +
6371                 "\n\nSubmitting this request asynchronously failed.");
6372         }
6373 
6374         // Display a "Please Wait" pop-up while waiting for the
6375         // asynchronous submit of the STAX EXECUTE request to complete
6376 
6377         STAXMonitorWaitDialog waitDialog = new STAXMonitorWaitDialog(this);
6378 
6379         // Wait for the STAX EXECUTE request to complete
6380 
6381         String getRequest = "GET WAIT TYPE STAF/RequestComplete";
6382         result = fSubmitHandle.submit2("local", "QUEUE", getRequest);
6383 
6384         // Delete the fSubmitHandle since no longer needed
6385 
6386         STAXMonitorUtil.freeHandle(fSubmitHandle.getHandle());
6387 
6388         // No longer display the wait dialog
6389         waitDialog.hideDialog();
6390 
6391         // Display an error popup if the QUEUE GET WAIT request failed
6392 
6393         if (result.rc != STAFResult.Ok)
6394         {
6395             return new STAXMonitorExecuteResult(
6396                 result.rc,
6397                 "RC: " + result.rc + "\n" + result.result +
6398                 "\n\nSTAF local QUEUE " + getRequest);
6399         }
6400 
6401         // Get the STAX EXECUTE request's RC and result from the message
6402         // sent to the fSubmitHandle's queue
6403 
6404         Map queueMap = (Map)result.resultObj;
6405         Map messageMap = (Map)queueMap.get("message");
6406         int executeRC = Integer.parseInt((String)messageMap.get("rc"));
6407 
6408         if (executeRC != STAFResult.Ok)
6409         {
6410             // Note that the "result" field in the STAF/RequestComplete
6411             // message may contain a String or a STAFMarshallingContext object
6412 
6413             String command = "STAF " + fStaxMachineName + " " +
6414                 fStaxServiceName + " " + request.toString();
6415 
6416             return new STAXMonitorExecuteResult(
6417                 executeRC,
6418                 generateErrorMsg(
6419                     executeRC,
6420                     messageMap.get("result").toString() + "\n\n" + command));
6421         }
6422 
6423         return new STAXMonitorExecuteResult(
6424             STAFResult.Ok, messageMap.get("result"));
6425     }
6426 
monitorExistingJob(String jobNumber, int rowIndex)6427     public void monitorExistingJob(String jobNumber, int rowIndex)
6428     {
6429         if (fMonitorTable.containsKey(jobNumber))
6430         {
6431             STAXMonitorFrame monitorFrame =
6432                 (STAXMonitorFrame)fMonitorTable.get(jobNumber);
6433             monitorFrame.setState(Frame.NORMAL);
6434             monitorFrame.toFront();
6435             monitorFrame.requestFocus();
6436             return;
6437         }
6438 
6439         try
6440         {
6441             String limitMsgs = "";
6442 
6443             if (fLimitMessagesField.getText().equals(""))
6444             {
6445                 limitMsgs = "-1";
6446             }
6447             else
6448             {
6449                 limitMsgs = fLimitMessagesField.getText();
6450             }
6451 
6452             int autoMonitor = 0;
6453 
6454             if (fAutoMonitorSubjobs)
6455             {
6456                 autoMonitor = STAXMonitorFrame.AUTOMONITOR_ALWAYS;
6457             }
6458             else if (fAutoMonitorRecommendedSubjobs)
6459             {
6460                 autoMonitor = STAXMonitorFrame.AUTOMONITOR_RECOMMENDED;
6461             }
6462             else if (fNeverAutoMonitorSubjobs)
6463             {
6464                 autoMonitor = STAXMonitorFrame.AUTOMONITOR_NEVER;
6465             }
6466 
6467             // 817339
6468             // Query the job to get the information necessary to
6469             // restart the job.
6470 
6471             STAFResult queryResult = fHandle.submit2(
6472                 fStaxMachineName, fStaxServiceName, "QUERY JOB " + jobNumber);
6473 
6474             if (queryResult.rc != 0)
6475             {
6476                 return;
6477             }
6478 
6479             Map jobInfoMap = (HashMap)queryResult.resultObj;
6480 
6481             String jobName       = (String)jobInfoMap.get("jobName");
6482             String xmlfile       = (String)jobInfoMap.get("xmlFileName");
6483             String fileMachine   = (String)jobInfoMap.get("fileMachine");
6484             String function      = (String)jobInfoMap.get("function");
6485             String args          = (String)jobInfoMap.get("arguments");
6486             String scriptMachine = (String)jobInfoMap.get("scriptMachine");
6487             String state         = (String)jobInfoMap.get("state");
6488 
6489             // XXX: Is this right?
6490             if (state.equals("Pending"))
6491             {
6492                 STAXMonitorUtil.showErrorDialog(
6493                     this, "Cannot monitor a job in a Pending state.  " +
6494                     "Please wait until the job is in a Running state.");
6495                 return;
6496             }
6497 
6498             // Convert the list of scripts to a vector of scripts
6499 
6500             java.util.List scriptList =
6501                 (java.util.List)jobInfoMap.get("scriptList");
6502             Vector scripts = new Vector();
6503 
6504             Iterator iter = scriptList.iterator();
6505 
6506             while (iter.hasNext())
6507             {
6508                 scripts.add((String)iter.next());
6509             }
6510 
6511             // Convert the list of scriptfiles to a vector of scriptfiles
6512 
6513             java.util.List scriptFileList =
6514                 (java.util.List)jobInfoMap.get("scriptFileList");
6515             Vector scriptFiles = new Vector();
6516 
6517             iter = scriptFileList.iterator();
6518 
6519             while (iter.hasNext())
6520             {
6521                 scriptFiles.add((String)iter.next());
6522             }
6523 
6524             // Convert the enabled/disabled strings for clearLogs,
6525             // logTCElapsedTime, logTCNumStarts, and logTCStartStop to ints
6526 
6527             String clearLogsString = (String)jobInfoMap.get("clearLogs");
6528             int clearLogs = STAXMonitorFrame.DEFAULT;
6529 
6530             if (clearLogsString.equals("Enabled"))
6531                 clearLogs = STAXMonitorFrame.ENABLED;
6532             else if (clearLogsString.equals("Disabled"))
6533                 clearLogs = STAXMonitorFrame.DISABLED;
6534 
6535             String logTCElapsedTimeString =
6536                 (String)jobInfoMap.get("logTCElapsedTime");
6537             int logTCElapsedTime = STAXMonitorFrame.DEFAULT;
6538 
6539             if (logTCElapsedTimeString.equals("Enabled"))
6540                 logTCElapsedTime = STAXMonitorFrame.ENABLED;
6541             else if (logTCElapsedTimeString.equals("Disabled"))
6542                 logTCElapsedTime = STAXMonitorFrame.DISABLED;
6543 
6544             String logTCNumStartsString =
6545                 (String)jobInfoMap.get("logTCNumStarts");
6546             int logTCNumStarts = STAXMonitorFrame.DEFAULT;
6547 
6548             if (logTCNumStartsString.equals("Enabled"))
6549                 logTCNumStarts = STAXMonitorFrame.ENABLED;
6550             else if (logTCNumStartsString.equals("Disabled"))
6551                 logTCNumStarts = STAXMonitorFrame.DISABLED;
6552 
6553             String logTCStartStopString =
6554                 (String)jobInfoMap.get("logTCStartStop");
6555             int logTCStartStop = STAXMonitorFrame.DEFAULT;
6556 
6557             if (logTCStartStopString.equals("Enabled"))
6558                 logTCStartStop = STAXMonitorFrame.ENABLED;
6559             else if (logTCStartStopString.equals("Disabled"))
6560                 logTCStartStop = STAXMonitorFrame.DISABLED;
6561 
6562             STAXMonitorFrame monitor = new STAXMonitorFrame(
6563                 false, this, fStaxMachineName, fStaxServiceName,
6564                 fStaxMachineNickname, jobNumber,
6565                 fEventMachineName, fEventServiceName,
6566                 xmlfile, fileMachine, function, args, jobName, scripts,
6567                 fShowNoSTAXMonitorInformation.isSelected(), limitMsgs,
6568                 fLocalExtJarFiles, scriptFiles, scriptMachine, clearLogs,
6569                 logTCElapsedTime, logTCNumStarts, logTCStartStop,
6570                 autoMonitor);
6571 
6572             synchronized (fMonitorTable)
6573             {
6574                 fMonitorTable.put(jobNumber, monitor);
6575             }
6576 
6577             synchronized (fActiveJobsModelSorter)
6578             {
6579                 // If STAXMonitorFrame calls this method, it passes -1 for the
6580                 // rowIndex since it doesn't know the row number for the job.
6581                 // So, determine the row index for the job if rowIndex == -1.
6582 
6583                 if (rowIndex == -1)
6584                 {
6585                     Vector jobsVector = fActiveJobsTableModel.getDataVector();
6586 
6587                     for (int j = 0; j < jobsVector.size(); j++)
6588                     {
6589                         if (((Vector)(jobsVector.elementAt(j))).elementAt(0).equals(
6590                             new Integer(jobNumber)))
6591                         {
6592                             rowIndex = j;
6593                             break;
6594                         }
6595                     }
6596                 }
6597 
6598                 if (rowIndex == -1)
6599                     return;  // Job not found in Active Job Table.
6600 
6601                 // Job found in Active Job Table.  Set the "Monitored" column
6602                 // for the job to show it is being monitored
6603 
6604                 fActiveJobsModelSorter.setValueAt(
6605                     new Boolean(true), rowIndex, 2);
6606 
6607                 synchronized (fActiveJobsTable)
6608                 {
6609                     fActiveJobsTable.updateUI();
6610                     STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
6611                     STAXMonitorUtil.updateRowHeights(fActiveJobsTable, 7);
6612                 }
6613             }
6614         }
6615         catch (STAFException ex)
6616         {
6617             // Display a "STAX Error" popup with an error message
6618 
6619             STAXMonitorUtil.showErrorDialog(
6620                 this, ex.getMessage(), new Font("Courier", Font.PLAIN, 12));
6621         }
6622     }
6623 
addMonitoredJob(STAXMonitorFrame monitor)6624     public void addMonitoredJob(STAXMonitorFrame monitor)
6625     {
6626         synchronized (fMonitorTable)
6627         {
6628             fMonitorTable.put(monitor.getJobNumber(), monitor);
6629         }
6630     }
6631 
showBrowseFileDialog()6632     public void showBrowseFileDialog()
6633     {
6634         STAXMonitorFileFilter filter = new STAXMonitorFileFilter();
6635         filter.addExtension("xml");
6636         JFileChooser xmlFileChooser = new JFileChooser(fLastFileDirectory);
6637         xmlFileChooser.setFileFilter(filter);
6638         xmlFileChooser.setDialogTitle("Select an XML Job Definition File");
6639         int rc = xmlFileChooser.showDialog(this, "Select this XML File");
6640 
6641         if (rc == JFileChooser.APPROVE_OPTION)
6642         {
6643             try
6644             {
6645                 fLocalXmlFileNameField.setText(
6646                     xmlFileChooser.getSelectedFile().getCanonicalPath());
6647                 fLastFileDirectory = xmlFileChooser.getCurrentDirectory();
6648 
6649                 fCurrentJobParmsNotSaved = true;
6650                 fStartNewJobFileSave.setEnabled(true);
6651                 fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
6652                                             fCurrentJobParmsFile + " *");
6653             }
6654             catch (IOException ex)
6655             {
6656                 ex.printStackTrace();
6657             }
6658         }
6659     }
6660 
showOpenJobParmsFileDialog()6661     public void showOpenJobParmsFileDialog()
6662     {
6663         JFileChooser jobParmsFileChooser =
6664             new JFileChooser(fLastJobParmsFileDirectory);
6665         jobParmsFileChooser.setDialogTitle("Open Job Parameters file");
6666         int rc = jobParmsFileChooser.showOpenDialog(this);
6667 
6668         if (rc == JFileChooser.APPROVE_OPTION)
6669         {
6670             try
6671             {
6672                 String fileName =
6673                     jobParmsFileChooser.getSelectedFile().getCanonicalPath();
6674                 loadJobParms(fileName);
6675 
6676                 File jobParmsFileDirectory =
6677                     jobParmsFileChooser.getCurrentDirectory();
6678 
6679                 if (!(jobParmsFileDirectory.equals(fLastJobParmsFileDirectory)))
6680                 {
6681                     fLastJobParmsFileDirectory = jobParmsFileDirectory;
6682                     saveProperties();
6683                 }
6684 
6685                 fCurrentJobParmsNotSaved = false;
6686                 fCurrentJobParmsFile = fileName;
6687                 fStartNewJobFileSave.setEnabled(false);
6688                 fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
6689                                             fileName);
6690 
6691                 updateRecentFiles(fileName);
6692             }
6693             catch (IOException ex)
6694             {
6695                 ex.printStackTrace();
6696             }
6697         }
6698     }
6699 
showSaveJobParmsFileDialog()6700     public void showSaveJobParmsFileDialog()
6701     {
6702         JFileChooser jobParmsFileChooser =
6703             new JFileChooser(fLastJobParmsFileDirectory);
6704         jobParmsFileChooser.setDialogTitle("Save current Job Parameters as");
6705         int rc = jobParmsFileChooser.showSaveDialog(this);
6706 
6707         if (rc == JFileChooser.APPROVE_OPTION)
6708         {
6709             try
6710             {
6711                 String fileName =
6712                     jobParmsFileChooser.getSelectedFile().getCanonicalPath();
6713                 saveJobParms(fileName);
6714                 fLastJobParmsFileDirectory =
6715                     jobParmsFileChooser.getCurrentDirectory();
6716 
6717                 fCurrentJobParmsNotSaved = false;
6718                 fCurrentJobParmsFile = fileName;
6719                 fStartNewJobFileSave.setEnabled(false);
6720                 fStartNewJobDialog.setTitle(fStartNewJobTitle + "  " +
6721                                             fileName);
6722 
6723                 updateRecentFiles(fileName);
6724             }
6725             catch (IOException ex)
6726             {
6727                 ex.printStackTrace();
6728             }
6729         }
6730     }
6731 
showStartNewJobDialog()6732     public void showStartNewJobDialog()
6733     {
6734         if (fStartNewJobDialog != null)
6735         {
6736             fStartNewJobDialog.setVisible(true);
6737         }
6738     }
6739 
createStartNewJobDialog()6740     public void createStartNewJobDialog()
6741     {
6742         fStartNewJobDialog = new JDialog(this, fStartNewJobTitle, true);
6743 
6744         // this is required for the menu bar to correctly repaint
6745         fStartNewJobDialog.addWindowListener(new WindowAdapter()
6746             {
6747                 public void windowActivated(WindowEvent ev)
6748                 {
6749                     ev.getWindow().repaint();
6750                 }
6751             }
6752         );
6753 
6754         JTabbedPane startNewJobTabbedPane = new JTabbedPane();
6755 
6756         JMenuBar mainMenuBar = new JMenuBar();
6757         fStartNewJobDialog.setJMenuBar(mainMenuBar);
6758         fStartNewJobFileMenu = new JMenu("File");
6759         mainMenuBar.add(fStartNewJobFileMenu);
6760 
6761         fStartNewJobFileOpen = new JMenuItem("Open");
6762         fStartNewJobFileOpen.addActionListener(this);
6763         fStartNewJobFileMenu.add(fStartNewJobFileOpen);
6764 
6765         fStartNewJobFileSave = new JMenuItem("Save");
6766         fStartNewJobFileSave.addActionListener(this);
6767         fStartNewJobFileSave.setEnabled(false);
6768         fStartNewJobFileMenu.add(fStartNewJobFileSave);
6769 
6770         fStartNewJobFileSaveAs = new JMenuItem("Save As...");
6771         fStartNewJobFileSaveAs.addActionListener(this);
6772         fStartNewJobFileMenu.add(fStartNewJobFileSaveAs);
6773 
6774         fStartNewJobFileMenu.insertSeparator(3);
6775 
6776         fStartNewJobFileExit = new JMenuItem("Exit");
6777         fStartNewJobFileExit.addActionListener(this);
6778         fStartNewJobFileMenu.add(fStartNewJobFileExit);
6779 
6780         JPanel newJobPanel = new JPanel();
6781         newJobPanel.setLayout(new BorderLayout());
6782 
6783         JPanel jobInfoPanel = new JPanel();
6784         jobInfoPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6785         jobInfoPanel.setBorder(new TitledBorder("Job Information"));
6786         fJobNameField = new JTextField(15);
6787         fJobNameField.addKeyListener(this);
6788         fJobNameField.setText(fJobName);
6789 
6790         JPanel jobNameMonitorPanel = new JPanel();
6791         jobNameMonitorPanel.setLayout(new
6792             BoxLayout(jobNameMonitorPanel, BoxLayout.X_AXIS));
6793         jobNameMonitorPanel.setBorder(new TitledBorder("Job Options"));
6794 
6795         JPanel jobNamePanel = new JPanel();
6796         jobNamePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6797         jobNamePanel.add(new JLabel("Job Name: "));
6798         jobNamePanel.add(fJobNameField);
6799 
6800         JPanel monitorPanel = new JPanel();
6801         monitorPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6802         monitorPanel.add(new JLabel("Monitor:"));
6803         monitorPanel.add(Box.createHorizontalStrut(20));
6804         fMonitorYesRB = new JRadioButton("Yes", true);
6805         fMonitorNoRB = new JRadioButton("No", false);
6806         fMonitorYesRB.addItemListener(this);
6807         fMonitorNoRB.addItemListener(this);
6808         ButtonGroup monitorGroup = new ButtonGroup();
6809         monitorGroup.add(fMonitorYesRB);
6810         monitorGroup.add(fMonitorNoRB);
6811 
6812         monitorPanel.add(fMonitorYesRB);
6813         monitorPanel.add(Box.createHorizontalStrut(10));
6814         monitorPanel.add(fMonitorNoRB);
6815 
6816         monitorPanel.add(Box.createHorizontalStrut(20));
6817 
6818         jobNameMonitorPanel.add(jobNamePanel);
6819         jobNameMonitorPanel.add(Box.createHorizontalStrut(15));
6820         jobNameMonitorPanel.add(monitorPanel);
6821 
6822         jobInfoPanel.add(Box.createHorizontalStrut(10));
6823         jobInfoPanel.add(jobNameMonitorPanel);
6824         jobInfoPanel.add(Box.createHorizontalStrut(20));
6825 
6826         JPanel functionPanel = new JPanel();
6827         functionPanel.setLayout(new
6828             BoxLayout(functionPanel, BoxLayout.Y_AXIS));
6829         functionPanel.setBorder(new TitledBorder("Start Function"));
6830         fDefaultFunctionRB = new JRadioButton("default", true);
6831         fDefaultFunctionRB.addItemListener(this);
6832         fOtherFunctionRB = new JRadioButton("other", false);
6833         fOtherFunctionRB.addItemListener(this);
6834         ButtonGroup functionGroup = new ButtonGroup();
6835         functionGroup.add(fDefaultFunctionRB);
6836         functionGroup.add(fOtherFunctionRB);
6837         fFunctionField = new JTextField(15);
6838         fFunctionField.addKeyListener(this);
6839         fFunctionField.setText(fFunction);
6840         fFunctionField.setEnabled(false);
6841 
6842         JPanel defaultPanel = new JPanel();
6843         defaultPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6844         defaultPanel.add(Box.createHorizontalStrut(10));
6845         defaultPanel.add(fDefaultFunctionRB);
6846 
6847         JPanel otherFunctionPanel = new JPanel();
6848         otherFunctionPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6849         otherFunctionPanel.add(Box.createHorizontalStrut(10));
6850         otherFunctionPanel.add(fOtherFunctionRB);
6851         otherFunctionPanel.add(Box.createHorizontalStrut(10));
6852         otherFunctionPanel.add(fFunctionField);
6853 
6854         JPanel argsPanel = new JPanel();
6855         argsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6856         argsPanel.add(Box.createHorizontalStrut(10));
6857         JPanel argsLeftPanel = new JPanel();
6858         argsLeftPanel.setLayout(new BorderLayout());
6859         argsLeftPanel.add(BorderLayout.NORTH, new JLabel("Arguments:"));
6860         argsLeftPanel.add(BorderLayout.CENTER, fClearArguments);
6861         fClearArguments.addActionListener(this);
6862         argsPanel.add(argsLeftPanel);
6863         fArguments = new JTextArea(5, 70);
6864         fArguments.setLineWrap(true);
6865         fArguments.setFont(new Font("Monospaced", Font.PLAIN, 12));
6866         fArguments.addKeyListener(this);
6867         argsPanel.add(Box.createHorizontalStrut(10));
6868         argsPanel.add(fArguments);
6869 
6870         functionPanel.add(defaultPanel);
6871         functionPanel.add(otherFunctionPanel);
6872         functionPanel.add(Box.createVerticalStrut(10));
6873         functionPanel.add(argsPanel);
6874 
6875         jobInfoPanel.add(functionPanel);
6876 
6877         JPanel xmlJobPanel = new JPanel();
6878         xmlJobPanel.setLayout(new BoxLayout(xmlJobPanel, BoxLayout.Y_AXIS));
6879         xmlJobPanel.setBorder(new TitledBorder("XML Job File"));
6880         fMachineLocalRB = new JRadioButton("local machine", true);
6881         fMachineLocalRB.addItemListener(this);
6882         fMachineOtherRB = new JRadioButton("other machine", false);
6883         fMachineOtherRB.addItemListener(this);
6884         ButtonGroup machineGroup = new ButtonGroup();
6885         machineGroup.add(fMachineLocalRB);
6886         machineGroup.add(fMachineOtherRB);
6887 
6888         JPanel localPanel = new JPanel();
6889         localPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6890         localPanel.add(Box.createHorizontalStrut(10));
6891         localPanel.add(fMachineLocalRB);
6892         localPanel.add(Box.createHorizontalStrut(13));
6893         localPanel.add(new JLabel("Filename: "));
6894         fLocalXmlFileNameField = new JTextField(15);
6895         fLocalXmlFileNameField.addKeyListener(this);
6896         fLocalXmlFileNameField.setText(fLocalXmlFileName);
6897         localPanel.add(fLocalXmlFileNameField);
6898         localPanel.add(Box.createHorizontalStrut(10));
6899         fBrowseButton = new JButton("Browse...");
6900         fBrowseButton.addActionListener(this);
6901         localPanel.add(fBrowseButton);
6902 
6903         fOtherXmlFileMachineField = new JTextField(15);
6904         fOtherXmlFileMachineField.addKeyListener(this);
6905         fOtherXmlFileMachineField.setEnabled(false);
6906 
6907         JPanel otherPanel = new JPanel();
6908         otherPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6909         otherPanel.add(Box.createHorizontalStrut(10));
6910         otherPanel.add(fMachineOtherRB);
6911         otherPanel.add(Box.createHorizontalStrut(10));
6912         otherPanel.add(new JLabel("Name: "));
6913         otherPanel.add(fOtherXmlFileMachineField);
6914         otherPanel.add(Box.createHorizontalStrut(10));
6915         otherPanel.add(new JLabel("Filename: "));
6916         fOtherXmlFileNameField = new JTextField(15);
6917         fOtherXmlFileNameField.addKeyListener(this);
6918         fOtherXmlFileNameField.setText(fOtherXmlFileName);
6919         fOtherXmlFileNameField.setEnabled(false);
6920         otherPanel.add(fOtherXmlFileNameField);
6921         otherPanel.add(Box.createHorizontalStrut(30));
6922 
6923         xmlJobPanel.add(localPanel);
6924         xmlJobPanel.add(otherPanel);
6925 
6926         JPanel scriptPanel = new JPanel();
6927         scriptPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
6928         scriptPanel.setBorder(new TitledBorder("Scripts"));
6929         scriptPanel.add(Box.createHorizontalStrut(10));
6930 
6931         fScriptList = new JList(fScriptVector);
6932         fScriptList.setModel(new DefaultListModel());
6933         fScriptList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
6934         fScriptList.setCellRenderer(new STAXJobListCellRenderer(
6935             new Font("Monospaced", Font.PLAIN, 12)));
6936         fScriptList.addMouseListener(this);
6937 
6938         JPanel scriptButtonPanel = new JPanel();
6939         scriptButtonPanel.setLayout(new
6940             BoxLayout(scriptButtonPanel, BoxLayout.Y_AXIS));
6941         fScriptAddButton = new JButton("Add...");
6942         fScriptAddButton.addActionListener(this);
6943         fScriptDeleteButton = new JButton("Delete");
6944         fScriptDeleteButton.addActionListener(this);
6945         fScriptDeleteAllButton = new JButton("Delete All");
6946         fScriptDeleteAllButton.addActionListener(this);
6947         scriptButtonPanel.add(fScriptAddButton);
6948         scriptButtonPanel.add(Box.createVerticalStrut(5));
6949         scriptButtonPanel.add(fScriptDeleteButton);
6950         scriptButtonPanel.add(Box.createVerticalStrut(5));
6951         scriptButtonPanel.add(fScriptDeleteAllButton);
6952 
6953         JScrollPane fScriptScrollPane = new JScrollPane(fScriptList);
6954         fScriptScrollPane.setPreferredSize(new Dimension(400, 150));
6955 
6956         scriptPanel.add(fScriptScrollPane);
6957         scriptPanel.add(Box.createHorizontalStrut(10));
6958         scriptPanel.add(scriptButtonPanel);
6959 
6960         fAddScriptDialog = new JDialog(fStartNewJobDialog,
6961                                        "Add Script", true);
6962         fAddScriptDialog.setSize(new Dimension(400, 200));
6963         JPanel addScriptPanel = new JPanel();
6964         addScriptPanel.setLayout(new BorderLayout());
6965         fAddScriptTextArea = new JTextArea(5, 15);
6966         fAddScriptTextArea.setBorder(new TitledBorder("Enter script here"));
6967         addScriptPanel.add(BorderLayout.CENTER,
6968                            new JScrollPane(fAddScriptTextArea));
6969 
6970         fAddScriptAddButton = new JButton("Add");
6971         fAddScriptCancelButton = new JButton("Cancel");
6972 
6973         JPanel addScriptButtonPanel = new JPanel();
6974         addScriptButtonPanel.setLayout(new
6975             FlowLayout(FlowLayout.CENTER, 0, 0));
6976         addScriptButtonPanel.add(fAddScriptAddButton);
6977         addScriptButtonPanel.add(Box.createHorizontalStrut(20));
6978         addScriptButtonPanel.add(fAddScriptCancelButton);
6979 
6980         addScriptPanel.add(BorderLayout.SOUTH, addScriptButtonPanel);
6981 
6982         fAddScriptAddButton.addActionListener(this);
6983         fAddScriptCancelButton.addActionListener(this);
6984 
6985         fAddScriptDialog.getContentPane().add(addScriptPanel);
6986 
6987         fEditScriptDialog = new JDialog(fStartNewJobDialog,
6988                                        "Edit Script", true);
6989         fEditScriptDialog.setSize(new Dimension(400, 200));
6990         JPanel editScriptPanel = new JPanel();
6991         editScriptPanel.setLayout(new BorderLayout());
6992         fEditScriptTextArea = new JTextArea(5, 15);
6993         fEditScriptTextArea.setBorder(new TitledBorder("Update script here"));
6994         editScriptPanel.add(BorderLayout.CENTER,
6995                            new JScrollPane(fEditScriptTextArea));
6996 
6997         fEditScriptSaveButton = new JButton("Save");
6998         fEditScriptCancelButton = new JButton("Cancel");
6999 
7000         JPanel editScriptButtonPanel = new JPanel();
7001         editScriptButtonPanel.setLayout(new
7002             FlowLayout(FlowLayout.CENTER, 0, 0));
7003         editScriptButtonPanel.add(fEditScriptSaveButton);
7004         editScriptButtonPanel.add(Box.createHorizontalStrut(20));
7005         editScriptButtonPanel.add(fEditScriptCancelButton);
7006 
7007         editScriptPanel.add(BorderLayout.SOUTH, editScriptButtonPanel);
7008 
7009         fEditScriptSaveButton.addActionListener(this);
7010         fEditScriptCancelButton.addActionListener(this);
7011 
7012         fEditScriptDialog.getContentPane().add(editScriptPanel);
7013 
7014         fScriptFilesVector = new Vector();
7015         JPanel scriptFilesPanel = new JPanel();
7016         scriptFilesPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
7017         scriptFilesPanel.add(Box.createHorizontalStrut(10));
7018 
7019         fScriptFilesList = new JList(fScriptFilesVector);
7020         fScriptFilesList.setModel(new DefaultListModel());
7021         fScriptFilesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
7022         fScriptFilesList.setCellRenderer(new STAXJobListCellRenderer());
7023         fScriptFilesList.addMouseListener(this);
7024 
7025         JPanel scriptFilesButtonPanel = new JPanel();
7026         scriptFilesButtonPanel.setLayout(new
7027             BoxLayout(scriptFilesButtonPanel, BoxLayout.Y_AXIS));
7028         fScriptFilesAddButton = new JButton("Add...");
7029         fScriptFilesAddButton.addActionListener(this);
7030         fScriptFilesDeleteButton = new JButton("Delete");
7031         fScriptFilesDeleteButton.addActionListener(this);
7032         fScriptFilesDeleteAllButton = new JButton("Delete All");
7033         fScriptFilesDeleteAllButton.addActionListener(this);
7034         scriptFilesButtonPanel.add(fScriptFilesAddButton);
7035         scriptFilesButtonPanel.add(Box.createVerticalStrut(5));
7036         scriptFilesButtonPanel.add(fScriptFilesDeleteButton);
7037         scriptFilesButtonPanel.add(Box.createVerticalStrut(5));
7038         scriptFilesButtonPanel.add(fScriptFilesDeleteAllButton);
7039 
7040         JScrollPane fScriptFilesScrollPane = new JScrollPane(fScriptFilesList);
7041         fScriptFilesScrollPane.setPreferredSize(new Dimension(350,120));
7042 
7043         scriptFilesPanel.add(fScriptFilesScrollPane);
7044         scriptFilesPanel.add(Box.createHorizontalStrut(10));
7045         scriptFilesPanel.add(scriptFilesButtonPanel);
7046 
7047         JPanel scriptFilesMachinePanel = new JPanel();
7048         scriptFilesMachinePanel.setBorder(new TitledBorder("Script Files"));
7049         scriptFilesMachinePanel.setLayout(new
7050             BoxLayout(scriptFilesMachinePanel, BoxLayout.Y_AXIS));
7051 
7052         JPanel scriptMachinePanel = new JPanel();
7053         scriptMachinePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
7054 
7055         fLocalScriptMachineRB = new JRadioButton("Local machine", false);
7056         fXMLJobFileScriptMachineRB = new JRadioButton("XML Job File machine",
7057                                                       true);
7058         fOtherScriptMachineRB = new JRadioButton("Other machine", false);
7059         fLocalScriptMachineRB.addItemListener(this);
7060         fXMLJobFileScriptMachineRB.addItemListener(this);
7061         fOtherScriptMachineRB.addItemListener(this);
7062 
7063         ButtonGroup scriptMachineGroup = new ButtonGroup();
7064         scriptMachineGroup.add(fLocalScriptMachineRB);
7065         scriptMachineGroup.add(fXMLJobFileScriptMachineRB);
7066         scriptMachineGroup.add(fOtherScriptMachineRB);
7067 
7068         fScriptFilesMachineTextField = new JTextField(20);
7069         fScriptFilesMachineTextField.setEnabled(false);
7070         scriptMachinePanel.add(fLocalScriptMachineRB);
7071         scriptMachinePanel.add(fXMLJobFileScriptMachineRB);
7072         scriptMachinePanel.add(fOtherScriptMachineRB);
7073         scriptMachinePanel.add(fScriptFilesMachineTextField);
7074 
7075         scriptFilesMachinePanel.add(Box.createVerticalStrut(10));
7076         scriptFilesMachinePanel.add(scriptMachinePanel);
7077         scriptFilesMachinePanel.add(scriptFilesPanel);
7078 
7079         fAddScriptFilesDialog = new JDialog(this,
7080             "Add Script File", true);
7081         fAddScriptFilesDialog.setSize(new Dimension(400, 115));
7082         JPanel addScriptFilesPanel = new JPanel();
7083         addScriptFilesPanel.setLayout(new BorderLayout());
7084         fAddScriptFilesTextField = new JTextField(15);
7085         fAddScriptFilesTextField.setBorder(new TitledBorder(
7086             "Enter script file name here"));
7087         addScriptFilesPanel.add(BorderLayout.CENTER,
7088             new JScrollPane(fAddScriptFilesTextField));
7089 
7090         fAddScriptFilesBrowseButton = new JButton("Browse...");
7091         fAddScriptFilesAddButton = new JButton("Add");
7092         fAddScriptFilesCancelButton = new JButton("Cancel");
7093 
7094         JPanel addScriptFilesButtonPanel = new JPanel();
7095         addScriptFilesButtonPanel.setLayout(new
7096             FlowLayout(FlowLayout.CENTER, 0, 0));
7097         addScriptFilesButtonPanel.add(fAddScriptFilesBrowseButton);
7098         addScriptFilesButtonPanel.add(Box.createHorizontalStrut(20));
7099         addScriptFilesButtonPanel.add(fAddScriptFilesAddButton);
7100         addScriptFilesButtonPanel.add(Box.createHorizontalStrut(20));
7101         addScriptFilesButtonPanel.add(fAddScriptFilesCancelButton);
7102 
7103         addScriptFilesPanel.add(BorderLayout.SOUTH, addScriptFilesButtonPanel);
7104 
7105         fAddScriptFilesAddButton.addActionListener(this);
7106         fAddScriptFilesCancelButton.addActionListener(this);
7107         fAddScriptFilesBrowseButton.addActionListener(this);
7108 
7109         fAddScriptFilesDialog.getContentPane().add(addScriptFilesPanel);
7110 
7111         fEditScriptFilesDialog = new JDialog(this,
7112            "Edit Script File", true);
7113         fEditScriptFilesDialog.setSize(new Dimension(400, 115));
7114         JPanel editScriptFilesPanel = new JPanel();
7115         editScriptFilesPanel.setLayout(new BorderLayout());
7116         fEditScriptFilesTextField = new JTextField(15);
7117         fEditScriptFilesTextField.setBorder(new TitledBorder(
7118             "Update script file name here"));
7119         editScriptFilesPanel.add(BorderLayout.CENTER,
7120             new JScrollPane(fEditScriptFilesTextField));
7121 
7122         fEditScriptFilesSaveButton = new JButton("Save");
7123         fEditScriptFilesCancelButton = new JButton("Cancel");
7124 
7125         JPanel editScriptFilesButtonPanel = new JPanel();
7126         editScriptFilesButtonPanel.setLayout(new
7127             FlowLayout(FlowLayout.CENTER, 0, 0));
7128         editScriptFilesButtonPanel.add(fEditScriptFilesSaveButton);
7129         editScriptFilesButtonPanel.add(Box.createHorizontalStrut(20));
7130         editScriptFilesButtonPanel.add(fEditScriptFilesCancelButton);
7131 
7132         editScriptFilesPanel.add(BorderLayout.SOUTH,
7133             editScriptFilesButtonPanel);
7134 
7135         fEditScriptFilesSaveButton.addActionListener(this);
7136         fEditScriptFilesCancelButton.addActionListener(this);
7137 
7138         fEditScriptFilesDialog.getContentPane().add(editScriptFilesPanel);
7139 
7140         // Beginning of "Log Options" Tab Panel
7141 
7142         JPanel logOptionsPanel = new JPanel();
7143         logOptionsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
7144         logOptionsPanel.setBorder(new TitledBorder("Log Options"));
7145 
7146         JPanel logOptionsSubPanel = new JPanel();
7147         logOptionsSubPanel.setLayout(new
7148             BoxLayout(logOptionsSubPanel, BoxLayout.Y_AXIS));
7149 
7150         JPanel clearLogsPanel = new JPanel();
7151         clearLogsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
7152 
7153         clearLogsPanel.add(new JLabel("Clear Logs                   :"));
7154         clearLogsPanel.add(Box.createHorizontalStrut(20));
7155         fClearLogsYesRB = new JRadioButton("Enabled", false);
7156         fClearLogsYesRB.setBackground(Color.white);
7157         fClearLogsNoRB = new JRadioButton("Disabled", false);
7158         fClearLogsNoRB.setBackground(Color.white);
7159         fClearLogsDefaultRB = new JRadioButton("Default", true);
7160         fClearLogsDefaultRB.setBackground(Color.white);
7161         fClearLogsYesRB.addItemListener(this);
7162         fClearLogsNoRB.addItemListener(this);
7163         fClearLogsDefaultRB.addItemListener(this);
7164         ButtonGroup clearLogsGroup = new ButtonGroup();
7165         clearLogsGroup.add(fClearLogsYesRB);
7166         clearLogsGroup.add(fClearLogsNoRB);
7167         clearLogsGroup.add(fClearLogsDefaultRB);
7168         clearLogsPanel.add(fClearLogsYesRB);
7169         clearLogsPanel.add(Box.createHorizontalStrut(10));
7170         clearLogsPanel.add(fClearLogsNoRB);
7171         clearLogsPanel.add(Box.createHorizontalStrut(10));
7172         clearLogsPanel.add(fClearLogsDefaultRB);
7173 
7174         JPanel logTCElapsedTimePanel = new JPanel();
7175         logTCElapsedTimePanel.setLayout(new BoxLayout(logTCElapsedTimePanel,
7176                                                       BoxLayout.X_AXIS));
7177         logTCElapsedTimePanel.add(new JLabel("Log TC Elapsed Time:"));
7178         logTCElapsedTimePanel.add(Box.createHorizontalStrut(20));
7179         fLogTCElapsedTimeYesRB = new JRadioButton("Enabled", false);
7180         fLogTCElapsedTimeYesRB.setBackground(Color.white);
7181         fLogTCElapsedTimeNoRB = new JRadioButton("Disabled", false);
7182         fLogTCElapsedTimeNoRB.setBackground(Color.white);
7183         fLogTCElapsedTimeDefaultRB = new JRadioButton("Default", true);
7184         fLogTCElapsedTimeDefaultRB.setBackground(Color.white);
7185         fLogTCElapsedTimeYesRB.addItemListener(this);
7186         fLogTCElapsedTimeNoRB.addItemListener(this);
7187         fLogTCElapsedTimeDefaultRB.addItemListener(this);
7188         ButtonGroup logTCElapsedTimeGroup = new ButtonGroup();
7189         logTCElapsedTimeGroup.add(fLogTCElapsedTimeYesRB);
7190         logTCElapsedTimeGroup.add(fLogTCElapsedTimeNoRB);
7191         logTCElapsedTimeGroup.add(fLogTCElapsedTimeDefaultRB);
7192         logTCElapsedTimePanel.add(fLogTCElapsedTimeYesRB);
7193         logTCElapsedTimePanel.add(Box.createHorizontalStrut(10));
7194         logTCElapsedTimePanel.add(fLogTCElapsedTimeNoRB);
7195         logTCElapsedTimePanel.add(Box.createHorizontalStrut(10));
7196         logTCElapsedTimePanel.add(fLogTCElapsedTimeDefaultRB);
7197 
7198         JPanel logTCNumStartsPanel = new JPanel();
7199         logTCNumStartsPanel.setLayout(new BoxLayout(logTCNumStartsPanel,
7200                                                     BoxLayout.X_AXIS));
7201         logTCNumStartsPanel.add(new JLabel("Log TC Num Starts    :"));
7202         logTCNumStartsPanel.add(Box.createHorizontalStrut(20));
7203         fLogTCNumStartsYesRB = new JRadioButton("Enabled", false);
7204         fLogTCNumStartsYesRB.setBackground(Color.white);
7205         fLogTCNumStartsNoRB = new JRadioButton("Disabled", false);
7206         fLogTCNumStartsNoRB.setBackground(Color.white);
7207         fLogTCNumStartsDefaultRB = new JRadioButton("Default", true);
7208         fLogTCNumStartsDefaultRB.setBackground(Color.white);
7209         fLogTCNumStartsYesRB.addItemListener(this);
7210         fLogTCNumStartsNoRB.addItemListener(this);
7211         fLogTCNumStartsDefaultRB.addItemListener(this);
7212         ButtonGroup logTCNumStartsGroup = new ButtonGroup();
7213         logTCNumStartsGroup.add(fLogTCNumStartsYesRB);
7214         logTCNumStartsGroup.add(fLogTCNumStartsNoRB);
7215         logTCNumStartsGroup.add(fLogTCNumStartsDefaultRB);
7216         logTCNumStartsPanel.add(fLogTCNumStartsYesRB);
7217         logTCNumStartsPanel.add(Box.createHorizontalStrut(10));
7218         logTCNumStartsPanel.add(fLogTCNumStartsNoRB);
7219         logTCNumStartsPanel.add(Box.createHorizontalStrut(10));
7220         logTCNumStartsPanel.add(fLogTCNumStartsDefaultRB);
7221 
7222         JPanel logTCStartStopPanel = new JPanel();
7223         logTCStartStopPanel.setLayout(new BoxLayout(logTCStartStopPanel,
7224                                                     BoxLayout.X_AXIS));
7225         logTCStartStopPanel.add(new JLabel("Log TC Start/Stop      :"));
7226         logTCStartStopPanel.add(Box.createHorizontalStrut(20));
7227         fLogTCStartStopYesRB = new JRadioButton("Enabled", false);
7228         fLogTCStartStopYesRB.setBackground(Color.white);
7229         fLogTCStartStopNoRB = new JRadioButton("Disabled", false);
7230         fLogTCStartStopNoRB.setBackground(Color.white);
7231         fLogTCStartStopDefaultRB = new JRadioButton("Default", true);
7232         fLogTCStartStopDefaultRB.setBackground(Color.white);
7233         fLogTCStartStopYesRB.addItemListener(this);
7234         fLogTCStartStopNoRB.addItemListener(this);
7235         fLogTCStartStopDefaultRB.addItemListener(this);
7236         ButtonGroup logTCStartStopGroup = new ButtonGroup();
7237         logTCStartStopGroup.add(fLogTCStartStopYesRB);
7238         logTCStartStopGroup.add(fLogTCStartStopNoRB);
7239         logTCStartStopGroup.add(fLogTCStartStopDefaultRB);
7240         logTCStartStopPanel.add(fLogTCStartStopYesRB);
7241         logTCStartStopPanel.add(Box.createHorizontalStrut(10));
7242         logTCStartStopPanel.add(fLogTCStartStopNoRB);
7243         logTCStartStopPanel.add(Box.createHorizontalStrut(10));
7244         logTCStartStopPanel.add(fLogTCStartStopDefaultRB);
7245 
7246         fPythonOutputCB = new JComboBox();
7247 
7248         // Add "Default" as the first item in the Python Output combo box,
7249         // as the first item is the default selection if no selection is made
7250         fPythonOutputCB.addItem(DEFAULT_STRING);
7251 
7252         // Add all valid python outputs to the Python Output combobox
7253         for (int i = 0; i < PYTHON_OUTPUTS_PRETTY.length; i++)
7254         {
7255             fPythonOutputCB.addItem(PYTHON_OUTPUTS_PRETTY[i]);
7256         }
7257 
7258         JPanel pythonOutputPanel = new JPanel();
7259         pythonOutputPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
7260         pythonOutputPanel.add(new JLabel("Python Output            :"));
7261         pythonOutputPanel.add(Box.createHorizontalStrut(20));
7262         fPythonOutputCB.setBackground(Color.white);
7263         fPythonOutputCB.addActionListener(this);
7264         pythonOutputPanel.add(fPythonOutputCB);
7265 
7266         fPythonLogLevelCB = new JComboBox();
7267 
7268         // Add "Default" as the first item in the Python Log Level combo box,
7269         // as the first item is the default selection if no selection is made
7270         fPythonLogLevelCB.addItem(DEFAULT_STRING);
7271 
7272         // Add all valid log levels to the Python Log Level combo box
7273         for (int i = 0; i < LOGLEVELS.length; i++)
7274         {
7275             fPythonLogLevelCB.addItem(LOGLEVELS[i]);
7276         }
7277 
7278         JPanel pythonLogLevelPanel = new JPanel();
7279         pythonLogLevelPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
7280         pythonLogLevelPanel.add(new JLabel("Python Log Level       :"));
7281         pythonLogLevelPanel.add(Box.createHorizontalStrut(20));
7282         fPythonLogLevelCB.setBackground(Color.white);
7283         fPythonLogLevelCB.addActionListener(this);
7284         pythonLogLevelPanel.add(fPythonLogLevelCB);
7285 
7286         // Add the various panels to the logOptionsSubPanel
7287 
7288         logOptionsSubPanel.add(Box.createHorizontalStrut(15));
7289         logOptionsSubPanel.add(clearLogsPanel);
7290         logOptionsSubPanel.add(logTCElapsedTimePanel);
7291         logOptionsSubPanel.add(logTCNumStartsPanel);
7292         logOptionsSubPanel.add(logTCStartStopPanel);
7293         logOptionsSubPanel.add(Box.createVerticalStrut(20));
7294         logOptionsSubPanel.add(pythonOutputPanel);
7295         logOptionsSubPanel.add(pythonLogLevelPanel);
7296 
7297         logOptionsPanel.add(Box.createHorizontalStrut(10));
7298         logOptionsPanel.add(logOptionsSubPanel);
7299         logOptionsPanel.add(Box.createHorizontalStrut(20));
7300 
7301         // End of "Log Options" Tab Panel
7302 
7303         // Beginning of "Breakpoints" Tab Panel
7304 
7305         JPanel breakpointsPanel = new JPanel();
7306         breakpointsPanel.setLayout(new BorderLayout());
7307         breakpointsPanel.setBorder(new TitledBorder("Breakpoints"));
7308 
7309         fBreakpointFirstFunctionCB = new JCheckBox(
7310             "Set breakpoint on first function", false);
7311 
7312         fBreakpointSubjobFirstFunctionCB = new JCheckBox(
7313             "Set breakpoint on subjob first function", false);
7314 
7315         fBreakpointsTableModel =
7316             new STAXMonitorTableModel(fBreakpointTableColumnNames, 0);
7317         fBreakpointsModelSorter =
7318             new STAXMonitorTableSorter(fBreakpointsTableModel);
7319 
7320         fBreakpointTable = new JTable(fBreakpointsModelSorter);
7321         fBreakpointTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
7322         fBreakpointTable.setSelectionMode(
7323             ListSelectionModel.SINGLE_SELECTION);
7324         fBreakpointTable.setRowSelectionAllowed(true);
7325         fBreakpointTable.addMouseListener(this);
7326 
7327         for (int i = 0; i < fBreakpointTableColumnNames.size(); i++)
7328         {
7329             fBreakpointTable.getColumnModel().getColumn(i).
7330                 setCellRenderer(new STAXMonitorTableCellRenderer(
7331                 Color.black, false, new Font("Dialog", Font.PLAIN, 12)));
7332 
7333             fBreakpointTable.getColumnModel().getColumn(i).
7334                 setHeaderRenderer(new STAXMonitorTableCellRenderer(
7335                 Color.black, true, new Font("Dialog", Font.BOLD, 12)));
7336         }
7337 
7338         TableColumn column = null;
7339 
7340         for (int i = 0; i < 4; i++) {
7341             column = fBreakpointTable.getColumnModel().getColumn(i);
7342             if (i == 1) {
7343                 column.setPreferredWidth(15);
7344             } else {
7345                 column.setPreferredWidth(125);
7346             }
7347         }
7348 
7349         fBreakpointTable.updateUI();
7350         STAXMonitorUtil.updateRowHeights(fBreakpointTable, 0);
7351         STAXMonitorUtil.sizeColumnsToFitText(fBreakpointTable);
7352 
7353         JPanel breakpointLinesPanel = new JPanel();
7354         breakpointLinesPanel.setLayout(new
7355             FlowLayout(FlowLayout.LEFT, 0, 0));
7356         breakpointLinesPanel.add(Box.createHorizontalStrut(10));
7357 
7358         JPanel breakpointLinesButtonPanel = new JPanel();
7359         breakpointLinesButtonPanel.setLayout(new
7360             BoxLayout(breakpointLinesButtonPanel, BoxLayout.Y_AXIS));
7361         fBreakpointLineAddButton = new JButton("Add Breakpoint Line...");
7362         fBreakpointLineAddButton.addActionListener(this);
7363         fBreakpointFunctionAddButton = new JButton("Add Breakpoint Function...");
7364         fBreakpointFunctionAddButton.addActionListener(this);
7365         fBreakpointDeleteButton = new JButton("Delete");
7366         fBreakpointDeleteButton.addActionListener(this);
7367         fBreakpointDeleteAllButton = new JButton("Delete All");
7368         fBreakpointDeleteAllButton.addActionListener(this);
7369         breakpointLinesButtonPanel.add(fBreakpointLineAddButton);
7370         breakpointLinesButtonPanel.add(Box.createVerticalStrut(5));
7371         breakpointLinesButtonPanel.add(fBreakpointFunctionAddButton);
7372         breakpointLinesButtonPanel.add(Box.createVerticalStrut(5));
7373         breakpointLinesButtonPanel.add(fBreakpointDeleteButton);
7374         breakpointLinesButtonPanel.add(Box.createVerticalStrut(5));
7375         breakpointLinesButtonPanel.add(fBreakpointDeleteAllButton);
7376 
7377         JScrollPane fBreakpointLinesScrollPane =
7378             new JScrollPane(fBreakpointTable);
7379         fBreakpointLinesScrollPane.setPreferredSize(
7380             new Dimension(400, 130));
7381 
7382         breakpointLinesPanel.add(fBreakpointLinesScrollPane);
7383         breakpointLinesPanel.add(Box.createHorizontalStrut(10));
7384         breakpointLinesPanel.add(breakpointLinesButtonPanel);
7385 
7386         fAddBreakpointLineDialog = new JDialog(fStartNewJobDialog,
7387             "Add Line Breakpoint", true);
7388         fAddBreakpointLineDialog.setSize(new Dimension(400, 165));
7389 
7390         JPanel addBreakpointLinePanel = new JPanel();
7391         addBreakpointLinePanel.setLayout(new BorderLayout());
7392 
7393         JPanel breakpointLineOptionsPanel = new JPanel();
7394         breakpointLineOptionsPanel.setBorder(
7395             new TitledBorder("Breakpoint Line options"));
7396         breakpointLineOptionsPanel.setLayout(
7397             new BoxLayout(breakpointLineOptionsPanel, BoxLayout.Y_AXIS));
7398 
7399         JPanel addBreakpointLineNumberPanel = new JPanel();
7400         addBreakpointLineNumberPanel.setLayout(
7401             new FlowLayout(FlowLayout.LEFT, 0, 0));
7402         JLabel breakpointLineNumberName = new JLabel(" Line Number:    ");
7403         fAddBreakpointLineNumberTextField = new JTextField(15)
7404             {
7405                 public JToolTip createToolTip()
7406                 {
7407                     MultiLineToolTip tip = new MultiLineToolTip();
7408                     tip.setComponent(this);
7409                     return tip;
7410                 }
7411             };
7412 
7413         fAddBreakpointLineNumberTextField.setToolTipText(
7414             STAXMonitorUtil.wrapText(BREAKPOINT_LINE_NUMBER_TOOLTIP, 80));
7415 
7416         fAddBreakpointLineNumberTextField.setFont(
7417             new Font("Dialog", Font.PLAIN, 12));
7418         fAddBreakpointLineNumberTextField.setBackground(Color.white);
7419         fAddBreakpointLineNumberTextField.addActionListener(this);
7420         addBreakpointLineNumberPanel.add(breakpointLineNumberName);
7421         addBreakpointLineNumberPanel.add(fAddBreakpointLineNumberTextField);
7422 
7423         JPanel addBreakpointLineFilePanel = new JPanel();
7424         addBreakpointLineFilePanel.setLayout(
7425             new FlowLayout(FlowLayout.LEFT, 0, 0));
7426         JLabel breakpointLineFileName = new JLabel(" XML File:            ");
7427         fAddBreakpointLineFileTextField = new JTextField(25)
7428             {
7429                 public JToolTip createToolTip()
7430                 {
7431                     MultiLineToolTip tip = new MultiLineToolTip();
7432                     tip.setComponent(this);
7433                     return tip;
7434                 }
7435             };
7436 
7437         fAddBreakpointLineFileTextField.setToolTipText(
7438             STAXMonitorUtil.wrapText(BREAKPOINT_LINE_FILE_TOOLTIP, 80));
7439 
7440         fAddBreakpointLineFileTextField.setFont(
7441             new Font("Dialog", Font.PLAIN, 12));
7442         fAddBreakpointLineFileTextField.setBackground(Color.white);
7443         fAddBreakpointLineFileTextField.addActionListener(this);
7444         addBreakpointLineFilePanel.add(breakpointLineFileName);
7445         addBreakpointLineFilePanel.add(fAddBreakpointLineFileTextField);
7446 
7447         JPanel addBreakpointLineMachinePanel = new JPanel();
7448         addBreakpointLineMachinePanel.setLayout(
7449             new FlowLayout(FlowLayout.LEFT, 0, 0));
7450         JLabel breakpointLineMachineName = new JLabel(" Machine:            ");
7451         fAddBreakpointLineMachineTextField = new JTextField(25)
7452             {
7453                 public JToolTip createToolTip()
7454                 {
7455                     MultiLineToolTip tip = new MultiLineToolTip();
7456                     tip.setComponent(this);
7457                     return tip;
7458                 }
7459             };
7460 
7461         fAddBreakpointLineMachineTextField.setToolTipText(
7462             STAXMonitorUtil.wrapText(BREAKPOINT_LINE_MACHINE_TOOLTIP, 80));
7463 
7464         fAddBreakpointLineMachineTextField.setFont(
7465             new Font("Dialog", Font.PLAIN, 12));
7466         fAddBreakpointLineMachineTextField.setBackground(Color.white);
7467         fAddBreakpointLineMachineTextField.addActionListener(this);
7468         addBreakpointLineMachinePanel.add(breakpointLineMachineName);
7469         addBreakpointLineMachinePanel.add(fAddBreakpointLineMachineTextField);
7470 
7471         fAddBreakpointLineAddButton = new JButton("Add");
7472         fAddBreakpointLineCancelButton = new JButton("Cancel");
7473 
7474         JPanel addBreakpointLineButtonPanel = new JPanel();
7475         addBreakpointLineButtonPanel.setLayout(new
7476             FlowLayout(FlowLayout.CENTER, 0, 0));
7477         addBreakpointLineButtonPanel.add(fAddBreakpointLineAddButton);
7478         addBreakpointLineButtonPanel.add(Box.createHorizontalStrut(20));
7479         addBreakpointLineButtonPanel.add(
7480             fAddBreakpointLineCancelButton);
7481 
7482         breakpointLineOptionsPanel.add(addBreakpointLineNumberPanel);
7483         breakpointLineOptionsPanel.add(addBreakpointLineFilePanel);
7484         breakpointLineOptionsPanel.add(addBreakpointLineMachinePanel);
7485 
7486         addBreakpointLinePanel.add(BorderLayout.CENTER,
7487             breakpointLineOptionsPanel);
7488         addBreakpointLinePanel.add(BorderLayout.SOUTH,
7489             addBreakpointLineButtonPanel);
7490 
7491         fAddBreakpointLineAddButton.addActionListener(this);
7492         fAddBreakpointLineCancelButton.addActionListener(this);
7493 
7494         fAddBreakpointLineDialog.getContentPane().add(
7495             addBreakpointLinePanel);
7496 
7497         fEditBreakpointLineDialog = new JDialog(fStartNewJobDialog,
7498             "Edit Line Breakpoint", true);
7499         fEditBreakpointLineDialog.setSize(new Dimension(400, 165));
7500 
7501         JPanel editBreakpointLinePanel = new JPanel();
7502         editBreakpointLinePanel.setLayout(new BorderLayout());
7503 
7504         JPanel editBreakpointLineOptionsPanel = new JPanel();
7505         editBreakpointLineOptionsPanel.setBorder(
7506             new TitledBorder("Breakpoint Line options"));
7507         editBreakpointLineOptionsPanel.setLayout(
7508             new BoxLayout(editBreakpointLineOptionsPanel, BoxLayout.Y_AXIS));
7509 
7510         JPanel editBreakpointLineNumberPanel = new JPanel();
7511         editBreakpointLineNumberPanel.setLayout(
7512             new FlowLayout(FlowLayout.LEFT, 0, 0));
7513         JLabel editBreakpointLineNumberName = new JLabel(" Line Number:    ");
7514         fEditBreakpointLineNumberTextField = new JTextField(15)
7515             {
7516                 public JToolTip createToolTip()
7517                 {
7518                     MultiLineToolTip tip = new MultiLineToolTip();
7519                     tip.setComponent(this);
7520                     return tip;
7521                 }
7522             };
7523 
7524         fEditBreakpointLineNumberTextField.setToolTipText(
7525             STAXMonitorUtil.wrapText(BREAKPOINT_LINE_NUMBER_TOOLTIP, 80));
7526 
7527         fEditBreakpointLineNumberTextField.setFont(
7528             new Font("Dialog", Font.PLAIN, 12));
7529         fEditBreakpointLineNumberTextField.setBackground(Color.white);
7530         fEditBreakpointLineNumberTextField.addActionListener(this);
7531         editBreakpointLineNumberPanel.add(editBreakpointLineNumberName);
7532         editBreakpointLineNumberPanel.add(fEditBreakpointLineNumberTextField);
7533 
7534         JPanel editBreakpointLineFilePanel = new JPanel();
7535         editBreakpointLineFilePanel.setLayout(
7536             new FlowLayout(FlowLayout.LEFT, 0, 0));
7537         JLabel editBreakpointLineFileName =
7538             new JLabel(" XML File:            ");
7539         fEditBreakpointLineFileTextField = new JTextField(25)
7540             {
7541                 public JToolTip createToolTip()
7542                 {
7543                     MultiLineToolTip tip = new MultiLineToolTip();
7544                     tip.setComponent(this);
7545                     return tip;
7546                 }
7547             };
7548 
7549         fEditBreakpointLineFileTextField.setToolTipText(
7550             STAXMonitorUtil.wrapText(BREAKPOINT_LINE_FILE_TOOLTIP, 80));
7551 
7552         fEditBreakpointLineFileTextField.setFont(
7553             new Font("Dialog", Font.PLAIN, 12));
7554         fEditBreakpointLineFileTextField.setBackground(Color.white);
7555         fEditBreakpointLineFileTextField.addActionListener(this);
7556         editBreakpointLineFilePanel.add(editBreakpointLineFileName);
7557         editBreakpointLineFilePanel.add(fEditBreakpointLineFileTextField);
7558 
7559         JPanel editBreakpointLineMachinePanel = new JPanel();
7560         editBreakpointLineMachinePanel.setLayout(
7561             new FlowLayout(FlowLayout.LEFT, 0, 0));
7562         JLabel editBreakpointLineMachineName =
7563             new JLabel(" Machine:            ");
7564         fEditBreakpointLineMachineTextField = new JTextField(25)
7565             {
7566                 public JToolTip createToolTip()
7567                 {
7568                     MultiLineToolTip tip = new MultiLineToolTip();
7569                     tip.setComponent(this);
7570                     return tip;
7571                 }
7572             };
7573 
7574         fEditBreakpointLineMachineTextField.setToolTipText(
7575             STAXMonitorUtil.wrapText(BREAKPOINT_LINE_MACHINE_TOOLTIP, 80));
7576 
7577         fEditBreakpointLineMachineTextField.setFont(
7578             new Font("Dialog", Font.PLAIN, 12));
7579         fEditBreakpointLineMachineTextField.setBackground(Color.white);
7580         fEditBreakpointLineMachineTextField.addActionListener(this);
7581         editBreakpointLineMachinePanel.add(editBreakpointLineMachineName);
7582         editBreakpointLineMachinePanel.add(fEditBreakpointLineMachineTextField);
7583 
7584         fEditBreakpointLineSaveButton = new JButton("Save");
7585         fEditBreakpointLineCancelButton = new JButton("Cancel");
7586 
7587         JPanel editBreakpointLineButtonPanel = new JPanel();
7588         editBreakpointLineButtonPanel.setLayout(new
7589             FlowLayout(FlowLayout.CENTER, 0, 0));
7590         editBreakpointLineButtonPanel.add(fEditBreakpointLineSaveButton);
7591         editBreakpointLineButtonPanel.add(Box.createHorizontalStrut(20));
7592         editBreakpointLineButtonPanel.add(
7593             fEditBreakpointLineCancelButton);
7594 
7595         editBreakpointLineOptionsPanel.add(editBreakpointLineNumberPanel);
7596         editBreakpointLineOptionsPanel.add(editBreakpointLineFilePanel);
7597         editBreakpointLineOptionsPanel.add(editBreakpointLineMachinePanel);
7598 
7599         editBreakpointLinePanel.add(BorderLayout.CENTER,
7600             editBreakpointLineOptionsPanel);
7601         editBreakpointLinePanel.add(BorderLayout.SOUTH,
7602             editBreakpointLineButtonPanel);
7603 
7604         fEditBreakpointLineSaveButton.addActionListener(this);
7605         fEditBreakpointLineCancelButton.addActionListener(this);
7606 
7607         fEditBreakpointLineDialog.getContentPane().add(
7608             editBreakpointLinePanel);
7609 
7610         JPanel breakpointFunctionsPanel = new JPanel();
7611         breakpointFunctionsPanel.setLayout(new
7612             FlowLayout(FlowLayout.LEFT, 0, 0));
7613         breakpointFunctionsPanel.add(Box.createHorizontalStrut(10));
7614 
7615         JPanel breakpointFunctionsButtonPanel = new JPanel();
7616         breakpointFunctionsButtonPanel.setLayout(new
7617             BoxLayout(breakpointFunctionsButtonPanel, BoxLayout.Y_AXIS));
7618         fBreakpointFunctionDeleteButton = new JButton("Delete");
7619         fBreakpointFunctionDeleteButton.addActionListener(this);
7620         fBreakpointFunctionDeleteAllButton = new JButton("Delete All");
7621         fBreakpointFunctionDeleteAllButton.addActionListener(this);
7622         breakpointFunctionsButtonPanel.add(fBreakpointFunctionDeleteButton);
7623         breakpointFunctionsButtonPanel.add(Box.createVerticalStrut(5));
7624         breakpointFunctionsButtonPanel.add(fBreakpointFunctionDeleteAllButton);
7625 
7626         fAddBreakpointFunctionDialog = new JDialog(fStartNewJobDialog,
7627             "Add Function Breakpoint", true);
7628         fAddBreakpointFunctionDialog.setSize(new Dimension(400, 125));
7629         JPanel addBreakpointFunctionPanel = new JPanel();
7630         addBreakpointFunctionPanel.setLayout(new BorderLayout());
7631         fAddBreakpointFunctionTextField = new JTextField(15);
7632         fAddBreakpointFunctionTextField.setBorder(
7633             new TitledBorder("Enter function name here"));
7634         addBreakpointFunctionPanel.add(BorderLayout.CENTER,
7635                            new JScrollPane(fAddBreakpointFunctionTextField));
7636 
7637         fAddBreakpointFunctionAddButton = new JButton("Add");
7638         fAddBreakpointFunctionCancelButton = new JButton("Cancel");
7639 
7640         JPanel addBreakpointFunctionButtonPanel = new JPanel();
7641         addBreakpointFunctionButtonPanel.setLayout(new
7642             FlowLayout(FlowLayout.CENTER, 0, 0));
7643         addBreakpointFunctionButtonPanel.add(fAddBreakpointFunctionAddButton);
7644         addBreakpointFunctionButtonPanel.add(Box.createHorizontalStrut(20));
7645         addBreakpointFunctionButtonPanel.add(
7646             fAddBreakpointFunctionCancelButton);
7647 
7648         addBreakpointFunctionPanel.add(BorderLayout.SOUTH,
7649             addBreakpointFunctionButtonPanel);
7650 
7651         fAddBreakpointFunctionAddButton.addActionListener(this);
7652         fAddBreakpointFunctionCancelButton.addActionListener(this);
7653 
7654         fAddBreakpointFunctionDialog.getContentPane().add(
7655             addBreakpointFunctionPanel);
7656 
7657         fEditBreakpointFunctionDialog = new JDialog(fStartNewJobDialog,
7658             "Edit Function Name", true);
7659         fEditBreakpointFunctionDialog.setSize(new Dimension(400, 125));
7660         JPanel editBreakpointFunctionPanel = new JPanel();
7661         editBreakpointFunctionPanel.setLayout(new BorderLayout());
7662         fEditBreakpointFunctionTextField = new JTextField(15);
7663         fEditBreakpointFunctionTextField.setBorder(new
7664             TitledBorder("Update function name here"));
7665         editBreakpointFunctionPanel.add(BorderLayout.CENTER,
7666                            new JScrollPane(fEditBreakpointFunctionTextField));
7667 
7668         fEditBreakpointFunctionSaveButton = new JButton("Save");
7669         fEditBreakpointFunctionCancelButton = new JButton("Cancel");
7670 
7671         JPanel editBreakpointFunctionButtonPanel = new JPanel();
7672         editBreakpointFunctionButtonPanel.setLayout(new
7673             FlowLayout(FlowLayout.CENTER, 0, 0));
7674         editBreakpointFunctionButtonPanel.add(
7675             fEditBreakpointFunctionSaveButton);
7676         editBreakpointFunctionButtonPanel.add(Box.createHorizontalStrut(20));
7677         editBreakpointFunctionButtonPanel.add(
7678             fEditBreakpointFunctionCancelButton);
7679 
7680         editBreakpointFunctionPanel.add(BorderLayout.SOUTH,
7681             editBreakpointFunctionButtonPanel);
7682 
7683         fEditBreakpointFunctionSaveButton.addActionListener(this);
7684         fEditBreakpointFunctionCancelButton.addActionListener(this);
7685 
7686         fEditBreakpointFunctionDialog.getContentPane().add(
7687             editBreakpointFunctionPanel);
7688 
7689         //breakpointTabbedPane.addTab("Line Number",
7690         //                            breakpointLinesPanel);
7691         //breakpointTabbedPane.addTab("Function",
7692         //                            breakpointFunctionsPanel);
7693 
7694         JPanel breakpointFirstFunctionPanel = new JPanel();
7695         breakpointFirstFunctionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
7696         breakpointFirstFunctionPanel.add(fBreakpointFirstFunctionCB);
7697         breakpointFirstFunctionPanel.add(fBreakpointSubjobFirstFunctionCB);
7698 
7699         breakpointsPanel.add(breakpointFirstFunctionPanel, BorderLayout.NORTH);
7700         breakpointsPanel.add(new JScrollPane(breakpointLinesPanel),
7701                              BorderLayout.CENTER);
7702 
7703         // End of "Breakpoints" Tab Panel
7704 
7705         fStartNewJobSubmitButton = new JButton("Submit New Job");
7706         fStartNewJobTestButton = new JButton("Test");
7707         fStartNewJobWizardButton = new JButton("Job Wizard...");
7708         fStartNewJobCancelButton = new JButton("Close");
7709         fStartNewJobClearButton = new JButton("Clear all Parameters");
7710 
7711         JPanel startNewJobButtonPanel = new JPanel();
7712         startNewJobButtonPanel.setLayout(new
7713             FlowLayout(FlowLayout.CENTER, 0, 0));
7714         startNewJobButtonPanel.add(fStartNewJobSubmitButton);
7715         startNewJobButtonPanel.add(Box.createHorizontalStrut(20));
7716         startNewJobButtonPanel.add(fStartNewJobTestButton);
7717         startNewJobButtonPanel.add(Box.createHorizontalStrut(20));
7718         startNewJobButtonPanel.add(fStartNewJobWizardButton);
7719         startNewJobButtonPanel.add(Box.createHorizontalStrut(20));
7720         startNewJobButtonPanel.add(fStartNewJobCancelButton);
7721         startNewJobButtonPanel.add(Box.createHorizontalStrut(40));
7722         startNewJobButtonPanel.add(fStartNewJobClearButton);
7723 
7724         fStartNewJobSubmitButton.addActionListener(this);
7725         fStartNewJobTestButton.addActionListener(this);
7726         fStartNewJobWizardButton.addActionListener(this);
7727         fStartNewJobCancelButton.addActionListener(this);
7728         fStartNewJobClearButton.addActionListener(this);
7729 
7730         loadRecentFiles();
7731 
7732         JPanel jobInfoTab = new JPanel();
7733         jobInfoTab.setLayout(new BoxLayout(jobInfoTab, BoxLayout.Y_AXIS));
7734         jobInfoTab.add(xmlJobPanel);
7735         jobInfoTab.add(jobNameMonitorPanel);
7736 
7737         startNewJobTabbedPane.addTab("Job Info", new JScrollPane(jobInfoTab));
7738         startNewJobTabbedPane.addTab("Function", new JScrollPane(functionPanel));
7739         startNewJobTabbedPane.addTab("Scripts", new JScrollPane(scriptPanel));
7740         startNewJobTabbedPane.addTab("Script Files", new JScrollPane(scriptFilesMachinePanel));
7741         startNewJobTabbedPane.addTab("Log Options", new JScrollPane(logOptionsPanel));
7742         startNewJobTabbedPane.addTab("Breakpoints", new JScrollPane(breakpointsPanel));
7743 
7744         // Set tab colors
7745         for (int i = 0; i < startNewJobTabbedPane.getTabCount(); i++)
7746         {
7747             if (i == 0)
7748             {
7749                 startNewJobTabbedPane.setBackgroundAt(i, Color.lightGray);
7750             }
7751             else
7752             {
7753                 startNewJobTabbedPane.setBackgroundAt(i, Color.white);
7754                 startNewJobTabbedPane.setForegroundAt(i, Color.darkGray);
7755             }
7756         }
7757 
7758         newJobPanel.add(BorderLayout.CENTER,
7759             startNewJobTabbedPane);
7760         newJobPanel.add(BorderLayout.SOUTH, startNewJobButtonPanel);
7761 
7762         fStartNewJobDialog.setSize(new Dimension(650, 325));
7763         fStartNewJobDialog.getContentPane().
7764             add(newJobPanel);
7765         fStartNewJobDialog.setLocationRelativeTo(this);
7766 
7767         startNewJobTabbedPane.addChangeListener(this);
7768     }
7769 
stateChanged(ChangeEvent e)7770     public void stateChanged(ChangeEvent e)
7771     {
7772         JTabbedPane pane = (JTabbedPane)e.getSource();
7773 
7774         for (int i = 0; i < pane.getTabCount(); i++)
7775         {
7776             pane.setBackgroundAt(i, Color.white);
7777             pane.setForegroundAt(i, Color.darkGray);
7778         }
7779 
7780         int selected = ((JTabbedPane)e.getSource()).getSelectedIndex();
7781 
7782         if (selected != -1)
7783         {
7784             pane.setForegroundAt(selected, Color.black);
7785         }
7786     }
7787 
updateProperties(String newStaxMachineName, String newStaxServiceName, String newEventMachineName, String newEventServiceName, String newJobParmsDirectory, boolean displayMessage)7788     public void updateProperties(String newStaxMachineName,
7789                                  String newStaxServiceName,
7790                                  String newEventMachineName,
7791                                  String newEventServiceName,
7792                                  String newJobParmsDirectory,
7793                                  boolean displayMessage)
7794     {
7795         // Default values for properties if properties file doesn't exist
7796 
7797         String staxMachineName = "local";
7798         String staxServiceName = "STAX";
7799         String eventMachineName = "local";
7800         String eventServiceName = "Event";
7801         Boolean showNoSTAXMonitorInformation =
7802             fDefaultShowNoSTAXMonitorInformation;
7803         Boolean limitMessages = fDefaultLimitMessages;
7804         String limitMessagesField = fDefaultLimitMessagesText;
7805         Integer autoMonitorSubjobs = fDefaultAutoMonitorSubjobs;
7806         Vector localExtJarFiles = new Vector();
7807         String processMonitorSeconds = fDefaultProcessMonitorSeconds;
7808         String elapsedTimeSeconds = fDefaultElapsedTimeSeconds;
7809         String messageFontName = fDefaultMessageFontName;
7810         String logViewerFontName = fDefaultLogViewerFontName;
7811         String saveAsDirectory = null;
7812 
7813         // Get the properties from the properties file (if it exists)
7814 
7815         try
7816         {
7817             File propertiesFile = new File(fPropertiesFileName);
7818 
7819             if (propertiesFile.exists())
7820             {
7821                 ObjectInputStream ois =
7822                     new ObjectInputStream(new FileInputStream(propertiesFile));
7823 
7824                 Hashtable propertiesData = (Hashtable)(ois.readObject());
7825                 ois.close();
7826 
7827                 staxMachineName = (String)propertiesData.get(
7828                     "staxMachineName");
7829                 staxServiceName = (String)propertiesData.get(
7830                     "staxServiceName");
7831                 eventMachineName = (String)propertiesData.get(
7832                     "eventMachineName");
7833                 eventServiceName = (String)propertiesData.get(
7834                     "eventServiceName");
7835                 showNoSTAXMonitorInformation = (Boolean)propertiesData.get(
7836                     "showNoSTAXMonitorInformation");
7837                 limitMessages = (Boolean)propertiesData.get("limitMessages");
7838                 limitMessagesField = (String)propertiesData.get(
7839                     "limitMessagesField");
7840 
7841                 localExtJarFiles = (Vector)propertiesData.get("pluginJars");
7842 
7843                 // This key was changed from processMonitorSeconds to
7844                 // processMonitorSeconds-1 in STAX V3.1.2, in order to pick
7845                 // up the new default value of 60 seconds
7846                 processMonitorSeconds = (String)propertiesData.get(
7847                     "processMonitorSeconds-1");
7848                 elapsedTimeSeconds = (String)propertiesData.get(
7849                     "elapsedTimeSeconds");
7850 
7851                 try
7852                 {
7853                     autoMonitorSubjobs =
7854                         (Integer)propertiesData.get("autoMonitorSubjobs");
7855                 }
7856                 catch (ClassCastException ex)
7857                 {
7858                     // Do nothing since default is already set
7859                 }
7860 
7861                 if (propertiesData.get("messageFontName") != null)
7862                 {
7863                     messageFontName = (String)propertiesData.get(
7864                         "messageFontName");
7865                 }
7866 
7867                 if (propertiesData.get("logViewerFontName") != null)
7868                 {
7869                     logViewerFontName = (String)propertiesData.get(
7870                         "logViewerFontName");
7871                 }
7872 
7873                 // Log Viewer Save As Directory (Added in V3.3.5)
7874 
7875                 if (propertiesData.get("saveAsDirectory") != null)
7876                 {
7877                     saveAsDirectory = (String)propertiesData.get(
7878                         "saveAsDirectory");
7879                 }
7880             }
7881         }
7882         catch (IOException e)
7883         {
7884             e.printStackTrace();
7885             return;
7886         }
7887         catch (ClassNotFoundException e)
7888         {
7889             e.printStackTrace();
7890             return;
7891         }
7892 
7893         // If the STAX Machine/Service names change, update them
7894 
7895         if (!newStaxMachineName.equals(""))
7896             staxMachineName = newStaxMachineName;
7897 
7898         if (!newStaxServiceName.equals(""))
7899             staxServiceName = newStaxServiceName;
7900 
7901         // Get event machine and service names based by submitting a
7902         // LIST SETTINGS request to the STAX service machine
7903 
7904         EventServiceInfo eventServiceInfo = new EventServiceInfo(
7905             staxMachineName, staxServiceName, this, displayMessage);
7906 
7907         eventMachineName = eventServiceInfo.getMachine();
7908         eventServiceName = eventServiceInfo.getService();
7909 
7910         // Write the new properties to the properties file
7911 
7912         Hashtable propertiesData = new Hashtable();
7913         propertiesData.put("staxMachineName", staxMachineName);
7914         propertiesData.put("staxServiceName", staxServiceName);
7915         propertiesData.put("eventMachineName", eventMachineName);
7916         propertiesData.put("eventServiceName", eventServiceName);
7917         propertiesData.put("showNoSTAXMonitorInformation",
7918             showNoSTAXMonitorInformation);
7919         propertiesData.put("limitMessages", limitMessages);
7920         propertiesData.put("limitMessagesField", limitMessagesField);
7921         propertiesData.put("pluginJars", localExtJarFiles);
7922         // This key was changed from processMonitorSeconds to
7923         // processMonitorSeconds-1 in STAX V3.1.2, in order to pick
7924         // up the new default value of 60 seconds
7925         propertiesData.put("processMonitorSeconds-1", processMonitorSeconds);
7926         propertiesData.put("elapsedTimeSeconds", elapsedTimeSeconds);
7927         propertiesData.put("autoMonitorSubjobs", autoMonitorSubjobs);
7928 
7929         propertiesData.put("messageFontName", messageFontName);
7930         propertiesData.put("logViewerFontName", logViewerFontName);
7931         propertiesData.put("saveAsDirectory", saveAsDirectory);
7932 
7933         try
7934         {
7935             ObjectOutputStream oos = new ObjectOutputStream(new
7936                 FileOutputStream(fPropertiesFileName));
7937             oos.writeObject(((Object)(propertiesData)));
7938             oos.close();
7939 
7940             // Print the updated properties
7941 
7942             System.out.println("\nUpdated Properties:");
7943 
7944             if (!newStaxMachineName.equals(""))
7945             {
7946                 System.out.println("  STAX Machine = " + newStaxMachineName);
7947             }
7948 
7949             if (!newStaxServiceName.equals(""))
7950             {
7951                 System.out.println("  STAX Service Name = " +
7952                                    newStaxServiceName);
7953             }
7954 
7955             if (!newEventMachineName.equals(""))
7956             {
7957                 System.out.println("  Event Machine = " + newEventMachineName);
7958             }
7959 
7960             if (!newEventServiceName.equals(""))
7961             {
7962                 System.out.println("  Event Service Name = " +
7963                                    newEventServiceName);
7964             }
7965 
7966             if (!newJobParmsDirectory.equals(""))
7967             {
7968                 System.out.println("  jobParmsDirectory = " +
7969                                    newJobParmsDirectory);
7970             }
7971         }
7972         catch (IOException ex)
7973         {
7974             ex.printStackTrace();
7975         }
7976     }
7977 
saveProperties()7978     public void saveProperties()
7979     {
7980         // Get STAX service version
7981 
7982         String versionRequest = "VERSION";
7983 
7984         STAFResult versionResult = fHandle.submit2(
7985             fStaxMachineName, fStaxServiceName, versionRequest);
7986 
7987         if (versionResult.rc == 0)
7988         {
7989             String staxServiceVersion = versionResult.result;
7990             fSTAXServiceVersion = new STAFVersion(staxServiceVersion);
7991 
7992             // Check if STAX service is at the required version (or later)
7993 
7994             STAFVersion requiredVersion1 = new STAFVersion(
7995                 fServiceRequiredVersion);
7996 
7997             if (fSTAXServiceVersion.compareTo(requiredVersion1) < 0)
7998             {
7999                 JOptionPane.showMessageDialog(this,
8000                     "WARNING: STAX service machine is not at STAX version " +
8001                     requiredVersion1 + " or later.\n" +
8002                     "machine=" + fStaxMachineName + ", service=" +
8003                     fStaxServiceName + ", version=" + fSTAXServiceVersion,
8004                     "Incorrect STAX service version",
8005                     JOptionPane.ERROR_MESSAGE);
8006             }
8007         }
8008 
8009         try
8010         {
8011             Hashtable propertiesData = new Hashtable();
8012             propertiesData.put("staxMachineName", fStaxMachineName);
8013             propertiesData.put("staxServiceName", fStaxServiceName);
8014             propertiesData.put("eventMachineName", fEventMachineName);
8015             propertiesData.put("eventServiceName", fEventServiceName);
8016 
8017             fShowNoSTAXMonitorInformationBool =
8018                 fShowNoSTAXMonitorInformation.isSelected();
8019             propertiesData.put("showNoSTAXMonitorInformation",
8020                                new Boolean(fShowNoSTAXMonitorInformationBool));
8021 
8022             fLimitMessagesBool = fLimitMessages.isSelected();
8023 
8024             propertiesData.put("limitMessages",
8025                                new Boolean(fLimitMessagesBool));
8026 
8027             fLimitMessagesFieldText = fLimitMessagesField.getText();
8028 
8029             propertiesData.put("limitMessagesField", fLimitMessagesFieldText);
8030 
8031             propertiesData.put("pluginJars", fLocalExtJarFiles);
8032             // This key was changed from processMonitorSeconds to
8033             // processMonitorSeconds-1 in STAX V3.1.2, in order to pick
8034             // up the new default value of 60 seconds
8035             propertiesData.put("processMonitorSeconds-1",
8036                 fProcessMonitorSecondsFieldText);
8037             propertiesData.put("elapsedTimeSeconds",
8038                 fElapsedTimeSecondsFieldText);
8039 
8040             int autoMonitor = 0;
8041 
8042             if (fAutoMonitorSubjobs)
8043             {
8044                 autoMonitor = STAXMonitorFrame.AUTOMONITOR_ALWAYS;
8045             }
8046             else if (fAutoMonitorRecommendedSubjobs)
8047             {
8048                 autoMonitor = STAXMonitorFrame.AUTOMONITOR_RECOMMENDED;
8049             }
8050             else if (fNeverAutoMonitorSubjobs)
8051             {
8052                 autoMonitor = STAXMonitorFrame.AUTOMONITOR_NEVER;
8053             }
8054 
8055             propertiesData.put("autoMonitorSubjobs", new Integer(autoMonitor));
8056 
8057             propertiesData.put("messageFontName",
8058                                fMessageFontNameCB.getSelectedItem());
8059 
8060             propertiesData.put("logViewerFontName",
8061                                fLogViewerFontNameCB.getSelectedItem());
8062 
8063             propertiesData.put("saveAsDirectory", fSaveAsDirectory);
8064 
8065             if (fLastJobParmsFileDirectory != null)
8066             {
8067                 propertiesData.put("lastJobParmsFileDirectory",
8068                     fLastJobParmsFileDirectory.getAbsolutePath());
8069             }
8070 
8071             propertiesData.put("displayTestcaseNameColumn",
8072                 new Boolean(fTestcaseNameCB.isSelected()));
8073             propertiesData.put("displayTestcasePassColumn",
8074                 new Boolean(fTestcasePassCB.isSelected()));
8075             propertiesData.put("displayTestcaseFailColumn",
8076                 new Boolean(fTestcaseFailCB.isSelected()));
8077             propertiesData.put("displayTestcaseStartDateTimeColumn",
8078                 new Boolean(fTestcaseStartDateTimeCB.isSelected()));
8079             propertiesData.put("displayTestcaseStatusDateTimeColumn",
8080                 new Boolean(fTestcaseStatusDateTimeCB.isSelected()));
8081             propertiesData.put("displayTestcaseDurationColumn",
8082                 new Boolean(fTestcaseDurationCB.isSelected()));
8083             propertiesData.put("displayTestcaseStartsColumn",
8084                 new Boolean(fTestcaseStartsCB.isSelected()));
8085             propertiesData.put("displayTestcaseInformationColumn",
8086                 new Boolean(fTestcaseInformationCB.isSelected()));
8087             propertiesData.put("testcaseAutoResize",
8088                 new Boolean(fTestcaseAutoResizeCB.isSelected()));
8089 
8090             propertiesData.put("testcaseSortColumnName",
8091                                fTestcaseSortColumnCB.getSelectedItem());
8092             propertiesData.put("testcaseSortOrder",
8093                                fTestcaseSortOrderCB.getSelectedItem());
8094 
8095             ObjectOutputStream oos = new ObjectOutputStream(new
8096                 FileOutputStream(fPropertiesFileName));
8097             oos.writeObject(((Object)(propertiesData)));
8098             oos.close();
8099         }
8100         catch (IOException ex)
8101         {
8102             ex.printStackTrace();
8103         }
8104     }
8105 
loadProperties()8106     public void loadProperties()
8107     {
8108         try
8109         {
8110             File propertiesFile = new File(fPropertiesFileName);
8111 
8112             ObjectInputStream ois =
8113                 new ObjectInputStream(new FileInputStream(propertiesFile));
8114             Hashtable propertiesData = (Hashtable)(ois.readObject());
8115 
8116             ois.close();
8117 
8118             fStaxMachineName = (String)propertiesData.get("staxMachineName");
8119             fStaxMachineNameField.setText(fStaxMachineName);
8120             fStaxServiceName = (String)propertiesData.get("staxServiceName");
8121             fStaxServiceNameField.setText(fStaxServiceName);
8122 
8123             resolveMachineNames();
8124 
8125             Boolean showNoSTAXMonitorInformation =
8126                 (Boolean)propertiesData.get("showNoSTAXMonitorInformation");
8127             Boolean limitMessages =
8128                 (Boolean)propertiesData.get("limitMessages");
8129 
8130             Integer autoMonitorSubjobs;
8131 
8132             try
8133             {
8134                 autoMonitorSubjobs =
8135                     (Integer)propertiesData.get("autoMonitorSubjobs");
8136             }
8137             catch (ClassCastException ex)
8138             {
8139                 autoMonitorSubjobs = fDefaultAutoMonitorSubjobs;
8140             }
8141 
8142             fOldStaxMachineName = fStaxMachineName;
8143             fOldStaxServiceName = fStaxServiceName;
8144             fOldEventMachineName = fEventMachineName;
8145             fOldEventServiceName = fEventServiceName;
8146 
8147             if (autoMonitorSubjobs != null)
8148             {
8149                 if (autoMonitorSubjobs.intValue() ==
8150                     STAXMonitorFrame.AUTOMONITOR_ALWAYS)
8151                 {
8152                     fAutoMonitorSubjobsRB.setSelected(true);
8153                     fAutoMonitorSubjobs = true;
8154                     fAutoMonitorRecommendedSubjobsRB.setSelected(false);
8155                     fAutoMonitorRecommendedSubjobs = false;
8156                     fNeverAutoMonitorSubjobsRB.setSelected(false);
8157                     fNeverAutoMonitorSubjobs = false;
8158                 }
8159                 else if (autoMonitorSubjobs.intValue() ==
8160                     STAXMonitorFrame.AUTOMONITOR_RECOMMENDED)
8161                 {
8162                     fAutoMonitorSubjobsRB.setSelected(false);
8163                     fAutoMonitorSubjobs = false;
8164                     fAutoMonitorRecommendedSubjobsRB.setSelected(true);
8165                     fAutoMonitorRecommendedSubjobs = true;
8166                     fNeverAutoMonitorSubjobsRB.setSelected(false);
8167                     fNeverAutoMonitorSubjobs = false;
8168                 }
8169                 else
8170                 {
8171                     fAutoMonitorSubjobsRB.setSelected(false);
8172                     fAutoMonitorSubjobs = false;
8173                     fAutoMonitorRecommendedSubjobsRB.setSelected(false);
8174                     fAutoMonitorRecommendedSubjobs = false;
8175                     fNeverAutoMonitorSubjobsRB.setSelected(true);
8176                     fNeverAutoMonitorSubjobs = true;
8177                 }
8178             }
8179 
8180             fLocalExtJarFiles = (Vector)propertiesData.get("pluginJars");
8181 
8182             fUpdatedLocalExtJarFiles = new Vector();
8183 
8184             for (int i = 0; i < fLocalExtJarFiles.size(); i++)
8185             {
8186                 fUpdatedLocalExtJarFiles.addElement(
8187                     fLocalExtJarFiles.elementAt(i));
8188             }
8189 
8190             if (fLocalExtJarFiles == null)
8191             {
8192                 fLocalExtJarFiles = new Vector();
8193                 fUpdatedLocalExtJarFiles = new Vector();
8194             }
8195 
8196             fOldLocalExtJarFiles = new Vector(fLocalExtJarFiles);
8197 
8198             DefaultListModel pluginJarsModel =
8199                 (DefaultListModel)fPluginJarsList.getModel();
8200             pluginJarsModel.removeAllElements();
8201 
8202             if (fLocalExtJarFiles != null)
8203             {
8204                 for (int i = 0; i < fLocalExtJarFiles.size(); i++)
8205                 {
8206                     pluginJarsModel.addElement(
8207                         (String)fLocalExtJarFiles.elementAt(i));
8208                 }
8209             }
8210 
8211             if (showNoSTAXMonitorInformation != null)
8212             {
8213                 fShowNoSTAXMonitorInformation.setSelected(
8214                     showNoSTAXMonitorInformation.booleanValue());
8215             }
8216 
8217             fShowNoSTAXMonitorInformationBool =
8218                 fShowNoSTAXMonitorInformation.isSelected();
8219 
8220             if (limitMessages != null)
8221             {
8222                 fLimitMessages.setSelected(
8223                     limitMessages.booleanValue());
8224 
8225                 fLimitMessagesFieldText = (String)
8226                     propertiesData.get("limitMessagesField");
8227 
8228                 fLimitMessagesField.setText(fLimitMessagesFieldText);
8229             }
8230 
8231             fLimitMessagesBool = fLimitMessages.isSelected();
8232 
8233             // This key was changed from processMonitorSeconds to
8234             // processMonitorSeconds-1 in STAX V3.1.2, in order to pick
8235             // up the new default value of 60 seconds
8236             String processMonitorSeconds =
8237                 (String)propertiesData.get("processMonitorSeconds-1");
8238 
8239             if (processMonitorSeconds != null)
8240             {
8241                 fProcessMonitorSecondsFieldText = processMonitorSeconds;
8242                 fProcessMonitorSecondsField.setText(processMonitorSeconds);
8243             }
8244 
8245             String elapsedTimeSeconds =
8246                 (String)propertiesData.get("elapsedTimeSeconds");
8247 
8248             if (elapsedTimeSeconds != null)
8249             {
8250                 fElapsedTimeSecondsFieldText = elapsedTimeSeconds;
8251 
8252                 fElapsedTimeSecondsField.setText(elapsedTimeSeconds);
8253             }
8254 
8255             String messageFontName = (String)propertiesData.get(
8256                 "messageFontName");
8257 
8258             if (messageFontName != null)
8259             {
8260                 fMessageFontName = messageFontName;
8261                 fMessageFontNameCB.setSelectedItem(messageFontName);
8262             }
8263 
8264             String logViewerFontName = (String)propertiesData.get(
8265                 "logViewerFontName");
8266 
8267             if (logViewerFontName != null)
8268             {
8269                 fLogViewerFontName = logViewerFontName;
8270                 fLogViewerFontNameCB.setSelectedItem(logViewerFontName);
8271             }
8272 
8273             String saveAsDirectory = (String)propertiesData.get(
8274                 "saveAsDirectory");
8275 
8276             if (saveAsDirectory != null)
8277             {
8278                 fSaveAsDirectory = saveAsDirectory;
8279                 fSaveAsDirectoryField.setText(saveAsDirectory);
8280             }
8281 
8282             String lastJobParmsFileDirectory = (String)propertiesData.get(
8283                 "lastJobParmsFileDirectory");
8284 
8285             if (lastJobParmsFileDirectory != null)
8286             {
8287                 fLastJobParmsFileDirectory =
8288                     new File(lastJobParmsFileDirectory);
8289             }
8290 
8291             Boolean displayTestcaseNameColumn =
8292                 (Boolean)propertiesData.get("displayTestcaseNameColumn");
8293             Boolean displayTestcasePassColumn =
8294                 (Boolean)propertiesData.get("displayTestcasePassColumn");
8295             Boolean displayTestcaseFailColumn =
8296                 (Boolean)propertiesData.get("displayTestcaseFailColumn");
8297             Boolean displayTestcaseStartDateTimeColumn =
8298                 (Boolean)propertiesData.get(
8299                 "displayTestcaseStartDateTimeColumn");
8300             Boolean displayTestcaseStatusDateTimeColumn =
8301                 (Boolean)propertiesData.get(
8302                 "displayTestcaseStatusDateTimeColumn");
8303             Boolean displayTestcaseDurationColumn =
8304                 (Boolean)propertiesData.get("displayTestcaseDurationColumn");
8305             Boolean displayTestcaseStartsColumn =
8306                 (Boolean)propertiesData.get("displayTestcaseStartsColumn");
8307             Boolean displayTestcaseInformationColumn =
8308                 (Boolean)propertiesData.get("displayTestcaseInformationColumn");
8309             Boolean testcaseAutoResize =
8310                 (Boolean)propertiesData.get("testcaseAutoResize");
8311 
8312             if (displayTestcaseNameColumn != null)
8313             {
8314                 fTestcaseNameCB.setSelected(
8315                     displayTestcaseNameColumn.booleanValue());
8316                 fDisplayTestcaseName = displayTestcaseNameColumn.booleanValue();
8317             }
8318 
8319             if (displayTestcasePassColumn != null)
8320             {
8321                 fTestcasePassCB.setSelected(
8322                     displayTestcasePassColumn.booleanValue());
8323                 fDisplayTestcasePass = displayTestcasePassColumn.booleanValue();
8324             }
8325 
8326             if (displayTestcaseFailColumn != null)
8327             {
8328                 fTestcaseFailCB.setSelected(
8329                     displayTestcaseFailColumn.booleanValue());
8330                 fDisplayTestcaseFail = displayTestcaseFailColumn.booleanValue();
8331             }
8332 
8333             if (displayTestcaseStartDateTimeColumn != null)
8334             {
8335                 fTestcaseStartDateTimeCB.setSelected(
8336                     displayTestcaseStartDateTimeColumn.booleanValue());
8337                 fDisplayTestcaseStartDateTime =
8338                     displayTestcaseStartDateTimeColumn.booleanValue();
8339             }
8340 
8341             if (displayTestcaseStatusDateTimeColumn != null)
8342             {
8343                 fTestcaseStatusDateTimeCB.setSelected(
8344                     displayTestcaseStatusDateTimeColumn.booleanValue());
8345                 fDisplayTestcaseStatusDateTime =
8346                     displayTestcaseStatusDateTimeColumn.booleanValue();
8347             }
8348 
8349             if (displayTestcaseDurationColumn != null)
8350             {
8351                 fTestcaseDurationCB.setSelected(
8352                     displayTestcaseDurationColumn.booleanValue());
8353                 fDisplayTestcaseDuration =
8354                     displayTestcaseDurationColumn.booleanValue();
8355             }
8356 
8357             if (displayTestcaseStartsColumn != null)
8358             {
8359                 fTestcaseStartsCB.setSelected(
8360                     displayTestcaseStartsColumn.booleanValue());
8361                 fDisplayTestcaseStarts =
8362                     displayTestcaseStartsColumn.booleanValue();
8363             }
8364 
8365             if (displayTestcaseInformationColumn != null)
8366             {
8367                 fTestcaseInformationCB.setSelected(
8368                     displayTestcaseInformationColumn.booleanValue());
8369                 fDisplayTestcaseInformation =
8370                     displayTestcaseInformationColumn.booleanValue();
8371             }
8372 
8373             if (testcaseAutoResize != null)
8374             {
8375                 fTestcaseAutoResizeCB.setSelected(
8376                     testcaseAutoResize.booleanValue());
8377                 fTestcaseAutoResize = testcaseAutoResize.booleanValue();
8378             }
8379 
8380             String testcaseSortColumnName = (String)propertiesData.get(
8381                 "testcaseSortColumnName");
8382 
8383             if (testcaseSortColumnName != null)
8384             {
8385                 fTestcaseSortColumnCB.setSelectedItem(testcaseSortColumnName);
8386                 fTestcaseSortColumn = fTestcaseSortColumnCB.getSelectedIndex();
8387             }
8388 
8389             String testcaseSortOrder = (String)propertiesData.get(
8390                 "testcaseSortOrder");
8391 
8392             if (testcaseSortOrder != null)
8393             {
8394                 fTestcaseSortOrderCB.setSelectedItem(testcaseSortOrder);
8395                 fTestcaseSortOrder = fTestcaseSortOrderCB.getSelectedIndex();
8396             }
8397         }
8398         catch (IOException e)
8399         {e.printStackTrace();
8400             return;
8401         }
8402         catch (ClassNotFoundException e)
8403         {e.printStackTrace();
8404             return;
8405         }
8406     }
8407 
resolveMachineNames()8408     public void resolveMachineNames()
8409     {
8410         // Get STAX Machine full name
8411 
8412         STAFResult res = fHandle.submit2(
8413             fStaxMachineName,
8414             "VAR", "RESOLVE STRING {STAF/Config/Machine}");
8415 
8416         if (res.rc == 0)
8417         {
8418             fStaxConfigMachine = res.result;
8419         }
8420         else
8421         {
8422             System.out.println(
8423                 "Error resolving string {STAF/Config/Machine} " +
8424                 "on machine " + fStaxMachineName + ", RC: " + res.rc +
8425                 ", Result: " + res.result);
8426         }
8427 
8428         // Get STAX Machine nickname
8429 
8430         res = fHandle.submit2(
8431             fStaxMachineName,
8432            "VAR", "RESOLVE STRING {STAF/Config/MachineNickname}");
8433 
8434         if (res.rc == 0)
8435         {
8436             fStaxMachineNickname = res.result;
8437         }
8438         else
8439         {
8440             System.out.println(
8441                 "Error resolving string {STAF/Config/MachineNickname} " +
8442                 "on machine " + fStaxMachineName + ", RC: " + res.rc +
8443                 ", Result: " + res.result);
8444         }
8445 
8446         // Check if the STAX Monitor is running on the same machine as
8447         // the STAX service using the same STAF instance and get the
8448         // UUID for the STAF instance used by the STAX machine.
8449 
8450         String isLocalRequest = "No";
8451 
8452         STAFResult result = fHandle.submit2(
8453             fStaxMachineName, "MISC", "WhoAreYou");
8454 
8455         if (result.rc == 0)
8456         {
8457             Map resultsMap = (Map)result.resultObj;
8458 
8459             isLocalRequest = (String)resultsMap.get("isLocalRequest");
8460 
8461             if (isLocalRequest == null)
8462                 isLocalRequest = "No";
8463 
8464             fStaxInstanceUUID = (String)resultsMap.get("instanceUUID");
8465         }
8466         else
8467         {
8468             System.out.println(
8469                 "STAF " + fStaxMachineName + " MISC WHOAREYOU failed, " +
8470                 "RC: " + result.rc + ", Result: " + result.result);
8471         }
8472 
8473         if (isLocalRequest.equalsIgnoreCase("Yes"))
8474             fIsSTAXServiceLocal = true;
8475         else
8476             fIsSTAXServiceLocal = false;
8477 
8478         // Get Event machine/service based on STAX machine/service
8479         // (Note:  Used to get from properties file)
8480 
8481         EventServiceInfo eventServiceInfo = new EventServiceInfo(
8482             fStaxMachineName, fStaxServiceName, this, true);
8483 
8484         fEventMachineName = eventServiceInfo.getMachine();
8485         fEventServiceName = eventServiceInfo.getService();
8486 
8487         fEventMachineNameField.setText(fEventMachineName);
8488         fEventServiceNameField.setText(fEventServiceName);
8489     }
8490 
saveJobParms(String fileName)8491     public void saveJobParms(String fileName)
8492     {
8493         try
8494         {
8495             Hashtable jobParms = new Hashtable();
8496             jobParms.put("id", fJobParmsID);
8497             fJobName = fJobNameField.getText();
8498             jobParms.put("jobName", fJobName);
8499             fOtherXmlFileMachineName = fOtherXmlFileMachineField.getText();
8500             jobParms.put("otherXmlFileMachine", fOtherXmlFileMachineName);
8501             fLocalXmlFileName = fLocalXmlFileNameField.getText();
8502             jobParms.put("localXmlFileName", fLocalXmlFileName);
8503             fOtherXmlFileName = fOtherXmlFileNameField.getText();
8504             jobParms.put("otherXmlFileName", fOtherXmlFileName);
8505             fFunction = fFunctionField.getText();
8506             jobParms.put("argumentsEnabled", new Boolean(fArgumentsEnabled));
8507             jobParms.put("function", fFunction);
8508             fArgs = fArguments.getText();
8509             jobParms.put("args", fArgs);
8510 
8511             ListModel scriptModel = fScriptList.getModel();
8512             Vector scriptVector = new Vector(scriptModel.getSize());
8513 
8514             for (int i = 0; i < scriptModel.getSize(); i++)
8515             {
8516                 scriptVector.addElement(scriptModel.getElementAt(i));
8517             }
8518 
8519             jobParms.put("scriptVector", scriptVector);
8520 
8521             ListModel scriptFilesModel = fScriptFilesList.getModel();
8522             Vector scriptFilesVector = new Vector(scriptFilesModel.getSize());
8523 
8524             for (int i = 0; i < scriptFilesModel.getSize(); i++)
8525             {
8526                 scriptFilesVector.addElement(scriptFilesModel.getElementAt(i));
8527             }
8528 
8529             jobParms.put("scriptFilesVector", scriptFilesVector);
8530 
8531             jobParms.put("localMachine",
8532                          new Boolean(fMachineLocalRB.isSelected()));
8533             jobParms.put("otherFunction",
8534                          new Boolean(fOtherFunctionRB.isSelected()));
8535             jobParms.put("monitor",
8536                          new Boolean(fMonitorYesRB.isSelected()));
8537 
8538             // To maintain backwards compatibility with the meaning of the
8539             // "localScriptMachine" key with already existing job parm files:
8540             // - if fXMLJobFileScriptMachineRB is selected:
8541             //      Assign "localScriptMachine" = true
8542             // - else if fOtherScriptMachineRB is selected:
8543             //      Assign "localScriptMachine" = false
8544             // - else if fLocalScriptMachineRB is selected:
8545             //      Don't put a "localScriptMachine" key in the jobParms map
8546 
8547             if (fXMLJobFileScriptMachineRB.isSelected())
8548             {
8549                 jobParms.put("localScriptMachine", new Boolean(true));
8550             }
8551             else if (fOtherScriptMachineRB.isSelected())
8552             {
8553                 jobParms.put("localScriptMachine", new Boolean(false));
8554             }
8555             else if (fLocalScriptMachineRB.isSelected())
8556             {
8557                 // Don't put a "localScriptMachine" key in the map
8558             }
8559 
8560             fScriptFilesMachineName = fScriptFilesMachineTextField.getText();
8561             jobParms.put("otherScriptMachine", fScriptFilesMachineName);
8562 
8563             int clearLogs = STAXMonitorFrame.DEFAULT;
8564 
8565             if (fClearLogsYesRB.isSelected())
8566                 clearLogs = STAXMonitorFrame.ENABLED;
8567             else if (fClearLogsNoRB.isSelected())
8568                 clearLogs = STAXMonitorFrame.DISABLED;
8569 
8570             jobParms.put("clearLogs", new Integer(clearLogs));
8571 
8572             int logTCElapsedTime = STAXMonitorFrame.DEFAULT;
8573 
8574             if (fLogTCElapsedTimeYesRB.isSelected())
8575                 logTCElapsedTime = STAXMonitorFrame.ENABLED;
8576             else if (fLogTCElapsedTimeNoRB.isSelected())
8577                 logTCElapsedTime = STAXMonitorFrame.DISABLED;
8578 
8579             jobParms.put("logTCElapsedTime", new Integer(logTCElapsedTime));
8580 
8581             int logTCNumStarts = STAXMonitorFrame.DEFAULT;
8582 
8583             if (fLogTCNumStartsYesRB.isSelected())
8584                 logTCNumStarts = STAXMonitorFrame.ENABLED;
8585             else if (fLogTCNumStartsNoRB.isSelected())
8586                 logTCNumStarts = STAXMonitorFrame.DISABLED;
8587 
8588             jobParms.put("logTCNumStarts", new Integer(logTCNumStarts));
8589 
8590             int logTCStartStop = STAXMonitorFrame.DEFAULT;
8591 
8592             if (fLogTCStartStopYesRB.isSelected())
8593                 logTCStartStop = STAXMonitorFrame.ENABLED;
8594             else if (fLogTCStartStopNoRB.isSelected())
8595                 logTCStartStop = STAXMonitorFrame.DISABLED;
8596 
8597             jobParms.put("logTCStartStop", new Integer(logTCStartStop));
8598 
8599             jobParms.put("pythonOutput", getPythonOutputFromPrettyString(
8600                 (String)fPythonOutputCB.getSelectedItem()));
8601 
8602             jobParms.put("pythonLogLevel",
8603                          fPythonLogLevelCB.getSelectedItem());
8604 
8605             jobParms.put("wizardSavedFileMachineName",
8606                          fWizardSavedFileMachineName);
8607             jobParms.put("wizardSavedFileName", fWizardSavedFileName);
8608             jobParms.put("wizardSavedFunctionName", fWizardSavedFunctionName);
8609             jobParms.put("wizardSavedFunctionArgList",
8610                 fWizardSavedFunctionArgList);
8611 
8612             if (fLastFileDirectory != null)
8613             {
8614                 jobParms.put("lastFileDirectory",
8615                              fLastFileDirectory.getAbsolutePath());
8616             }
8617 
8618             jobParms.put("breakpointLinesVector",
8619                 fBreakpointsTableModel.getDataVector());
8620 
8621             jobParms.put("breakpointFirstFunction",
8622                 new Boolean(fBreakpointFirstFunctionCB.isSelected()));
8623 
8624             jobParms.put("breakpointSubjobFirstFunction",
8625                 new Boolean(fBreakpointSubjobFirstFunctionCB.isSelected()));
8626 
8627             ObjectOutputStream oos = new ObjectOutputStream(new
8628                 FileOutputStream(fileName));
8629             oos.writeObject(((Object)(jobParms)));
8630             oos.close();
8631         }
8632         catch (IOException ex)
8633         {
8634             ex.printStackTrace();
8635         }
8636     }
8637 
loadJobParms(String fileName)8638     public boolean loadJobParms(String fileName)
8639     {
8640         try
8641         {
8642             File jobParmsFile = new File(fileName);
8643 
8644             if (!jobParmsFile.exists())
8645             {
8646                 return false;
8647             }
8648 
8649             ObjectInputStream ois = null;
8650 
8651             try
8652             {
8653                 ois = new ObjectInputStream(new FileInputStream(jobParmsFile));
8654             }
8655             catch (StreamCorruptedException ex)
8656             {
8657                 if (ois != null)
8658                 {
8659                     ois.close();
8660                 }
8661 
8662                 STAXMonitorUtil.showErrorDialog(
8663                     this, "File " + jobParmsFile +
8664                     "\nis not a valid STAX Monitor Job Parameters file." +
8665                     "\nNot a serialized file.");
8666                 return false;
8667             }
8668 
8669             Object obj = ois.readObject();
8670             ois.close();
8671 
8672             if (!(obj instanceof Hashtable))
8673             {
8674                 STAXMonitorUtil.showErrorDialog(
8675                     this, "File " + jobParmsFile +
8676                     "\nis not a valid STAX Monitor Job Parameters file." +
8677                     "\nIncorrect File Type.");
8678                 return false;
8679             }
8680 
8681             Hashtable jobParms = (Hashtable)(obj);
8682 
8683             if (jobParms.get("id") == null)
8684             {
8685                 STAXMonitorUtil.showErrorDialog(
8686                     this, "File " + jobParmsFile +
8687                     "\nis not a valid STAX Monitor Job Parameters file." +
8688                     "\nID not found.");
8689                 return false;
8690             }
8691             else if (!((String)jobParms.get("id")).equals(fJobParmsID))
8692             {
8693                 STAXMonitorUtil.showErrorDialog(
8694                     this, "File " + jobParmsFile +
8695                     "\nis not a valid STAX Monitor Job Parameters file." +
8696                     "\nIncorrect ID.");
8697                 return false;
8698             }
8699 
8700             fJobName = (String)jobParms.get("jobName");
8701             fJobNameField.setText(fJobName);
8702             fOtherXmlFileMachineName =
8703                 (String)jobParms.get("otherXmlFileMachine");
8704             fOtherXmlFileMachineField.setText(fOtherXmlFileMachineName);
8705             fLocalXmlFileName = (String)jobParms.get("localXmlFileName");
8706             fLocalXmlFileNameField.setText(fLocalXmlFileName);
8707             fOtherXmlFileName = (String)jobParms.get("otherXmlFileName");
8708             fOtherXmlFileNameField.setText(fOtherXmlFileName);
8709             fFunction = (String)jobParms.get("function");
8710             fFunctionField.setText(fFunction);
8711             fArgs = (String)jobParms.get("args");
8712 
8713             Boolean argsEnabled =
8714                 ((Boolean)jobParms.get("argumentsEnabled"));
8715 
8716             if (argsEnabled == null)
8717             {
8718                 fArguments.setEnabled(true);
8719                 fArgumentsEnabled = true;
8720             }
8721             else
8722             {
8723                 fArguments.setEnabled(argsEnabled.booleanValue());
8724                 fArgumentsEnabled = argsEnabled.booleanValue();
8725             }
8726 
8727             fScriptFilesMachineName =
8728                 (String)jobParms.get("otherScriptMachine");
8729 
8730             if (fScriptFilesMachineName == null)
8731             {
8732                 fScriptFilesMachineName = "";
8733             }
8734 
8735             fScriptFilesMachineTextField.setText(fScriptFilesMachineName);
8736 
8737             if (fArgs == null)
8738             {
8739                 fArgs = "";
8740             }
8741 
8742             fArguments.setText(fArgs);
8743 
8744             Vector scriptVector = (Vector)jobParms.get("scriptVector");
8745 
8746             DefaultListModel scriptModel =
8747                 (DefaultListModel)fScriptList.getModel();
8748             scriptModel.removeAllElements();
8749 
8750             if (scriptVector != null)
8751             {
8752                 fScriptVector = scriptVector;
8753 
8754                 for (int i = 0; i < scriptVector.size(); i++)
8755                 {
8756                     scriptModel.addElement((String)scriptVector.elementAt(i));
8757                 }
8758             }
8759             else
8760             {
8761                 fScriptVector = new Vector();
8762             }
8763 
8764             Vector scriptFilesVector =
8765                 (Vector)jobParms.get("scriptFilesVector");
8766 
8767             DefaultListModel scriptFilesModel =
8768                 (DefaultListModel)fScriptFilesList.getModel();
8769             scriptFilesModel.removeAllElements();
8770 
8771             if (scriptFilesVector != null)
8772             {
8773                 fScriptFilesVector = scriptFilesVector;
8774 
8775                 for (int i = 0; i < scriptFilesVector.size(); i++)
8776                 {
8777                     scriptFilesModel.addElement(
8778                         (String)scriptFilesVector.elementAt(i));
8779                 }
8780             }
8781             else
8782             {
8783                 fScriptFilesVector = new Vector();
8784             }
8785 
8786             if (((Boolean)jobParms.get("localMachine")).booleanValue())
8787             {
8788                 fMachineLocalRB.setSelected(true);
8789             }
8790             else
8791             {
8792                 fMachineOtherRB.setSelected(true);
8793             }
8794 
8795             if (((Boolean)jobParms.get("otherFunction")).booleanValue())
8796             {
8797                 fOtherFunctionRB.setSelected(true);
8798             }
8799             else
8800             {
8801                 fDefaultFunctionRB.setSelected(true);
8802             }
8803 
8804             // To maintain backwards compatibility with the meaning of the
8805             // "localScriptMachine" key with already existing job parm files:
8806             // - if localScriptMachine=true
8807             //    indicates fXMLJobFileScriptMachineRB is selected
8808             // - else if localScriptMachine=false
8809             //    indicates fOtherScriptMachineRB is selected
8810             // - else if no localScriptMachine key
8811             //    indicates fLocalScriptMachineRB is selected
8812 
8813             Boolean localScriptMachine =
8814                 (Boolean)jobParms.get("localScriptMachine");
8815 
8816             if (localScriptMachine != null)
8817             {
8818                 if (localScriptMachine.booleanValue())
8819                 {
8820                     fXMLJobFileScriptMachineRB.setSelected(true);
8821                 }
8822                 else
8823                 {
8824                     fOtherScriptMachineRB.setSelected(true);
8825                 }
8826             }
8827             else
8828             {
8829                 fLocalScriptMachineRB.setSelected(true);
8830             }
8831 
8832             if (((Boolean)jobParms.get("monitor")).booleanValue())
8833             {
8834                 fMonitorYesRB.setSelected(true);
8835             }
8836             else
8837             {
8838                 fMonitorNoRB.setSelected(true);
8839             }
8840 
8841             // Handle boolean (true/false) values for clearLogs to support
8842             // saved JobParms for jobs run with STAX V1.4.1 and earlier.
8843             // After STAX V1.4.1, clearLogs is an Integer.
8844 
8845             Object clearLogsObj = jobParms.get("clearLogs");
8846 
8847             if (clearLogsObj instanceof Integer)
8848             {
8849                 Integer clearLogsInt = (Integer)jobParms.get("clearLogs");
8850 
8851                 if (clearLogsInt != null)
8852                 {
8853                     int clearLogs = clearLogsInt.intValue();
8854 
8855                     if (clearLogs == STAXMonitorFrame.ENABLED)
8856                         fClearLogsYesRB.setSelected(true);
8857                     else if (clearLogs == STAXMonitorFrame.DISABLED)
8858                         fClearLogsNoRB.setSelected(true);
8859                     else
8860                         fClearLogsDefaultRB.setSelected(true);
8861                 }
8862             }
8863             else if (clearLogsObj instanceof Boolean)
8864             {
8865                 Boolean clearLogsBool = (Boolean)clearLogsObj;
8866 
8867                 if (clearLogsBool != null)
8868                 {
8869                     if (clearLogsBool.booleanValue())
8870                         fClearLogsYesRB.setSelected(true);
8871                     else
8872                         fClearLogsNoRB.setSelected(true);
8873                 }
8874             }
8875 
8876             Integer logTCElapsedTimeInt =
8877                 (Integer)jobParms.get("logTCElapsedTime");
8878 
8879             if (logTCElapsedTimeInt != null)
8880             {
8881                 int logTCElapsedTime = logTCElapsedTimeInt.intValue();
8882 
8883                 if (logTCElapsedTime == STAXMonitorFrame.ENABLED)
8884                     fLogTCElapsedTimeYesRB.setSelected(true);
8885                 else if (logTCElapsedTime == STAXMonitorFrame.DISABLED)
8886                     fLogTCElapsedTimeNoRB.setSelected(true);
8887                 else
8888                     fLogTCElapsedTimeDefaultRB.setSelected(true);
8889             }
8890 
8891             Integer logTCNumStartsInt = (Integer)jobParms.get("logTCNumStarts");
8892 
8893             if (logTCNumStartsInt != null)
8894             {
8895                 int logTCNumStarts = logTCNumStartsInt.intValue();
8896 
8897                 if (logTCNumStarts == STAXMonitorFrame.ENABLED)
8898                     fLogTCNumStartsYesRB.setSelected(true);
8899                 else if (logTCNumStarts == STAXMonitorFrame.DISABLED)
8900                     fLogTCNumStartsNoRB.setSelected(true);
8901                 else
8902                     fLogTCNumStartsDefaultRB.setSelected(true);
8903             }
8904 
8905             Integer logTCStartStopInt = (Integer)jobParms.get("logTCStartStop");
8906 
8907             if (logTCStartStopInt != null)
8908             {
8909                 int logTCStartStop = logTCStartStopInt.intValue();
8910 
8911                 if (logTCStartStop == STAXMonitorFrame.ENABLED)
8912                     fLogTCStartStopYesRB.setSelected(true);
8913                 else if (logTCStartStop == STAXMonitorFrame.DISABLED)
8914                     fLogTCStartStopNoRB.setSelected(true);
8915                 else
8916                     fLogTCStartStopDefaultRB.setSelected(true);
8917             }
8918 
8919             String pythonOutput = (String)jobParms.get("pythonOutput");
8920 
8921             if (pythonOutput != null)
8922                 fPythonOutputCB.setSelectedItem(
8923                     getPrettyPythonOutput(pythonOutput));
8924 
8925             String pythonLogLevel = (String)jobParms.get("pythonLogLevel");
8926 
8927             if (pythonLogLevel != null)
8928                 fPythonLogLevelCB.setSelectedItem(pythonLogLevel);
8929 
8930             fWizardSavedFileMachineName =
8931                 (String)jobParms.get("wizardSavedFileMachineName");
8932 
8933             if (fWizardSavedFileMachineName == null)
8934                 fWizardSavedFileMachineName = "";
8935 
8936             fWizardSavedFileName = (String)jobParms.get("wizardSavedFileName");
8937 
8938             if (fWizardSavedFileName == null)
8939                 fWizardSavedFileName = "";
8940 
8941             fWizardSavedFunctionName =
8942                 (String)jobParms.get("wizardSavedFunctionName");
8943 
8944             if (fWizardSavedFunctionName == null)
8945                 fWizardSavedFunctionName = "";
8946 
8947             fWizardSavedFunctionArgList =
8948                 (Vector)jobParms.get("wizardSavedFunctionArgList");
8949 
8950             if (fWizardSavedFunctionArgList == null)
8951             {
8952                 fWizardSavedFunctionArgList = new Vector();
8953             }
8954 
8955             String lastFileDirectory = (String)jobParms.get(
8956                 "lastFileDirectory");
8957 
8958             if (lastFileDirectory != null)
8959             {
8960                 fLastFileDirectory = new File(lastFileDirectory);
8961             }
8962             else
8963             {
8964                 fLastFileDirectory = new File(System.getProperty("user.dir"));
8965             }
8966 
8967             Vector breakpointLinesVector =
8968                 (Vector)jobParms.get("breakpointLinesVector");
8969 
8970             if (breakpointLinesVector == null)
8971             {
8972                 breakpointLinesVector = new Vector();
8973             }
8974 
8975             for (int j = 0; j < breakpointLinesVector.size(); j++)
8976             {
8977                 fBreakpointsTableModel.addRow(
8978                     (Vector)(breakpointLinesVector.elementAt(j)));
8979             }
8980 
8981             for (int i = 0; i < fBreakpointTableColumnNames.size(); i++)
8982             {
8983                 fBreakpointTable.getColumnModel().getColumn(i).
8984                     setCellRenderer(new STAXExtensionsTableCellRenderer(
8985                         SwingConstants.LEFT));
8986 
8987                 fBreakpointTable.getColumnModel().getColumn(i).
8988                     setHeaderRenderer(new STAXExtensionsTableCellRenderer(
8989                         new Font("Dialog", Font.BOLD, 12), Color.lightGray));
8990             }
8991 
8992             fBreakpointTable.updateUI();
8993             STAXMonitorUtil.updateRowHeights(fBreakpointTable, 0);
8994             STAXMonitorUtil.sizeColumnsToFitText(fBreakpointTable);
8995 
8996             Boolean breakpointFirstFunction =
8997                 (Boolean)jobParms.get("breakpointFirstFunction");
8998 
8999             if (breakpointFirstFunction != null)
9000             {
9001                 if (breakpointFirstFunction.booleanValue())
9002                 {
9003                     fBreakpointFirstFunctionCB.setSelected(true);
9004                 }
9005             }
9006 
9007             Boolean breakpointSubjobFirstFunction =
9008                 (Boolean)jobParms.get("breakpointSubjobFirstFunction");
9009 
9010             if (breakpointSubjobFirstFunction != null)
9011             {
9012                 if (breakpointSubjobFirstFunction.booleanValue())
9013                 {
9014                     fBreakpointSubjobFirstFunctionCB.setSelected(true);
9015                 }
9016             }
9017         }
9018         catch (IOException e)
9019         {
9020             e.printStackTrace();
9021             return false;
9022         }
9023         catch (ClassNotFoundException e)
9024         {
9025             e.printStackTrace();
9026             return false;
9027         }
9028 
9029         return true;
9030     }
9031 
loadRecentFiles()9032     public void loadRecentFiles()
9033     {
9034         try
9035         {
9036             File recentFile = new File(fRecentFilesName);
9037             if (!recentFile.exists())
9038             {
9039                 fRecentFiles = new Vector();
9040                 return;
9041             }
9042             else
9043             {
9044                 ObjectInputStream ois =
9045                     new ObjectInputStream(new FileInputStream(recentFile));
9046                 fRecentFiles = (Vector)(ois.readObject());
9047                 ois.close();
9048             }
9049         }
9050         catch (IOException e)
9051         {
9052             fRecentFiles = new Vector();
9053             return;
9054         }
9055         catch (ClassNotFoundException e)
9056         {
9057             fRecentFiles = new Vector();
9058             return;
9059         }
9060 
9061         if (!fRecentFiles.isEmpty())
9062         {
9063             fStartNewJobFileMenu.insertSeparator(
9064                 fStartNewJobFileMenu.getItemCount()-1);
9065 
9066             for (int i=0; i < fRecentFiles.size(); i++)
9067             {
9068                 if (fRecentFiles.elementAt(i) == null)
9069                 {
9070                     return;
9071                 }
9072 
9073                 fRecentFileMenuItems[i] =
9074                     new JMenuItem((String)fRecentFiles.elementAt(i));
9075                 fStartNewJobFileMenu.insert(fRecentFileMenuItems[i],
9076                     fStartNewJobFileMenu.getItemCount()-2);
9077                 fRecentFileMenuItems[i].addActionListener(this);
9078             }
9079         }
9080     }
9081 
updateRecentFiles(String newFile)9082     public void updateRecentFiles(String newFile)
9083     {
9084         if (fRecentFiles.contains(newFile))
9085         {
9086             int priorIndex = fRecentFiles.indexOf(newFile);
9087 
9088             if (priorIndex == 0)
9089             {
9090                 return;
9091             }
9092             else
9093             {
9094                 for (int i=priorIndex; i > 0; i--)
9095                 {
9096                     fRecentFiles.setElementAt(fRecentFiles.elementAt(i-1), i);
9097                     fRecentFileMenuItems[i].setText(
9098                         fRecentFileMenuItems[i-1].getText());
9099                 }
9100 
9101                 fRecentFiles.setElementAt(newFile, 0);
9102 
9103                 fRecentFileMenuItems[0].setText(newFile);
9104             }
9105         }
9106         else
9107         {
9108             if (fRecentFiles.isEmpty())
9109             {
9110                 fStartNewJobFileMenu.insertSeparator(
9111                     fStartNewJobFileMenu.getItemCount()-1);
9112             }
9113 
9114             fRecentFiles.insertElementAt(newFile, 0);
9115 
9116             fRecentFiles.setSize(10);
9117 
9118             for (int i=0; i < fRecentFileMenuItems.length; i++)
9119             {
9120                 if (fRecentFileMenuItems[i] != null)
9121                 {
9122                     fStartNewJobFileMenu.remove(fRecentFileMenuItems[i]);
9123                 }
9124             }
9125 
9126             for (int i=0; i <10; i++)
9127             {
9128                 if (fRecentFiles.elementAt(i) == null)
9129                 {
9130                     break;
9131                 }
9132 
9133                 fRecentFileMenuItems[i] =
9134                     new JMenuItem((String)fRecentFiles.elementAt(i));
9135                 fStartNewJobFileMenu.insert(fRecentFileMenuItems[i],
9136                     fStartNewJobFileMenu.getItemCount()-2);
9137                 fRecentFileMenuItems[i].addActionListener(this);
9138             }
9139         }
9140     }
9141 
updateRecentLogs(String logQuery, String tooltip)9142     public void updateRecentLogs(String logQuery, String tooltip)
9143     {
9144         if (fRecentLogs.contains(logQuery))
9145         {
9146             int priorIndex = fRecentLogs.indexOf(logQuery);
9147 
9148             if (priorIndex == 0)
9149             {
9150                 return;
9151             }
9152             else
9153             {
9154                 for (int i=priorIndex; i > 0; i--)
9155                 {
9156                     fRecentLogs.setElementAt(fRecentLogs.elementAt(i-1), i);
9157                     fRecentLogsTooltips.setElementAt(
9158                         fRecentLogsTooltips.elementAt(i-1), i);
9159 
9160                     fRecentLogsMenuItems[i].setText(
9161                         fRecentLogsMenuItems[i-1].getText());
9162                     fRecentLogsMenuItems[i].setToolTipText(
9163                         fRecentLogsMenuItems[i-1].getToolTipText());
9164                 }
9165 
9166                 fRecentLogs.setElementAt(logQuery, 0);
9167                 fRecentLogsTooltips.setElementAt(tooltip, 0);
9168 
9169                 fRecentLogsMenuItems[0].setText(logQuery);
9170                 fRecentLogsMenuItems[0].setToolTipText(tooltip);
9171             }
9172         }
9173         else
9174         {
9175             fRecentLogs.insertElementAt(logQuery, 0);
9176             fRecentLogsTooltips.insertElementAt(tooltip, 0);
9177 
9178             fRecentLogs.setSize(20);
9179             fRecentLogsTooltips.setSize(20);
9180 
9181             for (int i=0; i < fRecentLogsMenuItems.length; i++)
9182             {
9183                 if (fRecentLogsMenuItems[i] != null)
9184                 {
9185                     fDisplayRecentLogs.remove(fRecentLogsMenuItems[i]);
9186                 }
9187             }
9188 
9189             for (int i=0; i < 20; i++)
9190             {
9191                 if (fRecentLogs.elementAt(i) == null)
9192                 {
9193                     break;
9194                 }
9195 
9196                 fRecentLogsMenuItems[i] =
9197                     new JMenuItem((String)fRecentLogs.elementAt(i))
9198                     {
9199                         public JToolTip createToolTip()
9200                         {
9201                             MultiLineToolTip tip = new MultiLineToolTip();
9202                             tip.setComponent(this);
9203                             return tip;
9204                         }
9205                     };
9206 
9207                 fRecentLogsMenuItems[i].setToolTipText(
9208                     (String)fRecentLogsTooltips.elementAt(i));
9209 
9210                 fDisplayRecentLogs.insert(fRecentLogsMenuItems[i], i);
9211 
9212                 fRecentLogsMenuItems[i].addActionListener(this);
9213             }
9214         }
9215     }
9216 
updateJobTableRenderers()9217     public void updateJobTableRenderers()
9218     {
9219 
9220         fActiveJobsTable.getColumnModel().getColumn(0).setCellRenderer(
9221             new STAXMonitorTableCellRenderer(
9222                 Color.black, false,
9223                 new Font("Dialog", Font.PLAIN, 12)));
9224 
9225         fActiveJobsTable.getColumnModel().getColumn(0).
9226             setHeaderRenderer(new STAXMonitorTableCellRenderer(
9227                 Color.black, true,
9228                 new Font("Dialog", Font.BOLD, 12)));
9229 
9230         fActiveJobsTable.getColumnModel().getColumn(1).setCellRenderer(
9231             new STAXMonitorTableCellRenderer(
9232                 Color.black, false,
9233                 new Font("Dialog", Font.PLAIN, 12)));
9234 
9235         fActiveJobsTable.getColumnModel().getColumn(1).
9236             setHeaderRenderer(new STAXMonitorTableCellRenderer(
9237                 Color.black, true,
9238                 new Font("Dialog", Font.BOLD, 12)));
9239 
9240         fActiveJobsTable.getColumnModel().getColumn(2).setCellRenderer(
9241             new STAXJobTableCellRenderer());
9242 
9243         fActiveJobsTable.getColumnModel().getColumn(2).
9244             setHeaderRenderer(new STAXMonitorTableCellRenderer(
9245                 Color.black, true,
9246                 new Font("Dialog", Font.BOLD, 12)));
9247 
9248         fActiveJobsTable.getColumnModel().getColumn(3).setCellRenderer(
9249             new STAXMonitorTableCellRenderer(
9250                 Color.black, false,
9251                 new Font("Dialog", Font.PLAIN, 12)));
9252 
9253         fActiveJobsTable.getColumnModel().getColumn(3).
9254             setHeaderRenderer(new STAXMonitorTableCellRenderer(
9255                 Color.black, true,
9256                 new Font("Dialog", Font.BOLD, 12)));
9257 
9258         fActiveJobsTable.getColumnModel().getColumn(4).setCellRenderer(
9259             new STAXMonitorTableCellRenderer(
9260                 Color.black, false,
9261                 new Font("Dialog", Font.PLAIN, 12)));
9262 
9263         fActiveJobsTable.getColumnModel().getColumn(4).
9264             setHeaderRenderer(new STAXMonitorTableCellRenderer(
9265                 Color.black, true,
9266                 new Font("Dialog", Font.BOLD, 12)));
9267 
9268         fActiveJobsTable.getColumnModel().getColumn(5).setCellRenderer(
9269             new STAXMonitorTableCellRenderer(
9270                 Color.black, false,
9271                 new Font("Dialog", Font.PLAIN, 12)));
9272 
9273         fActiveJobsTable.getColumnModel().getColumn(5).
9274             setHeaderRenderer(new STAXMonitorTableCellRenderer(
9275                 Color.black, true,
9276                 new Font("Dialog", Font.BOLD, 12)));
9277 
9278         fActiveJobsTable.getColumnModel().getColumn(6).setCellRenderer(
9279             new STAXMonitorTableCellRenderer(
9280                 Color.black, false,
9281                 new Font("Dialog", Font.PLAIN, 12)));
9282 
9283         fActiveJobsTable.getColumnModel().getColumn(6).
9284             setHeaderRenderer(new STAXMonitorTableCellRenderer(
9285                 Color.black, true,
9286                 new Font("Dialog", Font.BOLD, 12)));
9287 
9288         fActiveJobsTable.getColumnModel().getColumn(7).setCellRenderer(
9289             new STAXMonitorTableCellRenderer(
9290                 Color.black, false,
9291                 new Font("Dialog", Font.PLAIN, 12)));
9292 
9293         fActiveJobsTable.getColumnModel().getColumn(7).
9294             setHeaderRenderer(new STAXMonitorTableCellRenderer(
9295                 Color.black, true,
9296                 new Font("Dialog", Font.BOLD, 12)));
9297     }
9298 
updateExtensionsTableRenderers()9299     public void updateExtensionsTableRenderers()
9300     {
9301         for (int i = 0; i < fExtensionsColumns.size(); i++)
9302         {
9303             fExtensionsTable.getColumnModel().getColumn(i).
9304                 setCellRenderer(new STAXExtensionsTableCellRenderer(
9305                     SwingConstants.LEFT));
9306 
9307             fExtensionsTable.getColumnModel().getColumn(i).
9308                 setHeaderRenderer(new STAXExtensionsTableCellRenderer(
9309                     new Font("Dialog", Font.BOLD, 12), Color.lightGray));
9310         }
9311     }
9312 
registerForJobEvents()9313     public void registerForJobEvents()
9314     {
9315         STAFResult registerResult = fHandle.submit2(
9316             fEventMachineName,
9317             fEventServiceName, "REGISTER TYPE " +
9318             fStaxServiceName.toUpperCase() + "/" + fStaxConfigMachine +
9319             " SUBTYPE Job MAXATTEMPTS 1 ACKNOWLEDGETIMEOUT 1000 BYHANDLE");
9320 
9321         if (registerResult.rc != 0)
9322         {
9323             JOptionPane.showMessageDialog(
9324                 this,
9325                 "Could not register for Job events\n" +
9326                 "RC = " + registerResult.rc,
9327                 "Error registering Job Monitor",
9328                 JOptionPane.ERROR_MESSAGE);
9329         }
9330     }
9331 
unregisterForJobEvents()9332     public void unregisterForJobEvents()
9333     {
9334         STAFResult unRegisterResult = fHandle.submit2(
9335             fEventMachineName,
9336             fEventServiceName, "UNREGISTER TYPE " +
9337             fStaxServiceName.toUpperCase() + "/" + fStaxConfigMachine +
9338             " SUBTYPE Job SUBTYPE staxjobmessage " +
9339             "SUBTYPE staxjobtestcasestatus");
9340 
9341         if (unRegisterResult.rc != 0)
9342         {
9343             // do not display message
9344         }
9345     }
9346 
seedExistingJobs()9347     public void seedExistingJobs()
9348     {
9349         synchronized(fActiveJobsModelSorter)
9350         {
9351             String request = "LIST JOBS";
9352 
9353             STAFResult listJobsResult = fHandle.submit2(
9354                 fStaxMachineName, fStaxServiceName, request);
9355 
9356             if (listJobsResult.rc != 0)
9357             {
9358                 System.out.println("LIST JOBS request failed with RC: " +
9359                                    listJobsResult.rc + ", Result: " +
9360                                    listJobsResult.result);
9361                 return;
9362             }
9363 
9364             Vector jobsVector = fActiveJobsTableModel.getDataVector();
9365             Vector jobIDs = new Vector();
9366 
9367             for (int k = 0; k < jobsVector.size(); k++)
9368             {
9369                 jobIDs.addElement(
9370                     (((Vector)(jobsVector.elementAt(k))).elementAt(0)));
9371             }
9372 
9373             // Iterate thru the list of STAX jobs currently running
9374 
9375             java.util.List outputList =
9376                 (java.util.List)listJobsResult.resultObj;
9377 
9378             Iterator iter = outputList.iterator();
9379 
9380             while (iter.hasNext())
9381             {
9382                 Map jobInfoMap = (Map)iter.next();
9383 
9384                 String jobID = (String)jobInfoMap.get("jobID");
9385 
9386                 String jobName = (String)jobInfoMap.get("jobName");
9387                 if (jobName == null) jobName = sNONE;
9388 
9389                 String function = (String)jobInfoMap.get("function");
9390 
9391                 // startTimestamp format is YYYYMMDD-HH:MM:SS
9392                 String startTimestamp = (String)jobInfoMap.get(
9393                     "startTimestamp");
9394                 String startDate = startTimestamp.substring(0, 8);
9395                 String startTime = startTimestamp.substring(9);
9396 
9397                 String state = (String)jobInfoMap.get("state");
9398 
9399                 // Update jobs in the active jobs table
9400 
9401                 boolean found = false;
9402                 int rowIndex = 0;
9403 
9404                 for (int j = 0; j < jobsVector.size(); j++)
9405                 {
9406                     if (!found)
9407                     {
9408                         if (((Vector)(jobsVector.elementAt(j))).
9409                                         elementAt(0).equals(jobID))
9410                         {
9411                             found = true;
9412                             rowIndex = j;
9413                         }
9414                     }
9415                 }
9416 
9417                 if (!found)
9418                 {
9419                     Object rowData[] = new Object[8];
9420                     rowData[0] = new Integer(jobID);
9421                     rowData[1] = jobName;
9422 
9423                     if (fMonitorTable.containsKey(jobID))
9424                         rowData[2] = new Boolean(true);
9425                     else
9426                         rowData[2] = new Boolean(false);
9427 
9428                     final int waitTime = getElapsedTimeInterval();
9429                     String initialTime = "";
9430 
9431                     if (waitTime > 0) initialTime = "00:00:00";
9432 
9433                     rowData[3] = function;
9434                     rowData[4] = state;
9435                     rowData[5] = startTimestamp;
9436                     rowData[6] = initialTime;
9437                     rowData[7] = "";
9438 
9439                     fActiveJobsTableModel.addRow(rowData);
9440                 }
9441 
9442                 jobIDs.remove(jobID);
9443 
9444                 STAXMonitorUtil.updateRowHeights(fActiveJobsTable, 7);
9445                 STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
9446 
9447                 fJobStartTimes.put(jobID, getCalendar(startDate, startTime));
9448 
9449                 fJobStartDateTimes.put(jobID,
9450                     startDate + "@" + startTime);
9451             }
9452         }
9453     }
9454 
getCalendar(String startDate, String startTime)9455     Calendar getCalendar(String startDate, String startTime)
9456     {
9457         int year = (new Integer(startDate.substring(0, 4))).intValue();
9458         int month = (new Integer(startDate.substring(4, 6))).intValue();
9459         int date = (new Integer(startDate.substring(6, 8))).intValue();
9460 
9461         int hours = (new Integer(startTime.substring(0, 2))).intValue();
9462         int minutes = (new Integer(startTime.substring(3, 5))).intValue();
9463         int seconds = (new Integer(startTime.substring(6, 8))).intValue();
9464 
9465         Calendar startCalendar = Calendar.getInstance();
9466         startCalendar.set(year, month - 1, date, hours, minutes, seconds);
9467 
9468         return startCalendar;
9469     }
9470 
addRecentLog(String queryRequest, String tooltip)9471     public void addRecentLog(String queryRequest, String tooltip)
9472     {
9473         updateRecentLogs(queryRequest, tooltip);
9474     }
9475 
run()9476     public void run()
9477     {
9478         STAFResult getResult;
9479         boolean continueRunning = true;
9480         int numErrors = 0;
9481 
9482         // Maximum consecutive errors submitting a local QUEUE GET WAIT
9483         // request before we decide to exit the infinite loop
9484         int maxErrors = 5;
9485 
9486         while (continueRunning)
9487         {
9488             // Use the ALL option to improve performance by getting multiple
9489             // messages, if available, off the queue at once
9490 
9491             getResult = fHandle.submit2("local", "QUEUE", "GET ALL WAIT");
9492 
9493             if (getResult.rc == STAFResult.Ok)
9494             {
9495                 numErrors = 0;
9496             }
9497             else if (getResult.rc == STAFResult.HandleDoesNotExist ||
9498                      getResult.rc == STAFResult.RequestCancelled)
9499             {
9500                 // If the handle doesn't exist, or the request was cancelled
9501                 // (because the handle no longer exists), exit the thread
9502                 // since this handle cannot submit any more requests
9503                 // successfully,
9504 
9505                 continueRunning = false;
9506                 break;
9507             }
9508             else
9509             {
9510                 numErrors++;
9511 
9512                 System.out.println(
9513                     "STAF local QUEUE GET ALL WAIT request failed with RC: " +
9514                     getResult.rc + ", Result: " + getResult.result);
9515 
9516                 if (numErrors < maxErrors)
9517                 {
9518                     continue;
9519                 }
9520                 else
9521                 {
9522                     System.out.println(
9523                         "Exiting the queue monitor thread after the " +
9524                         "QUEUE GET request failed " + maxErrors +
9525                         " consecutive times");
9526 
9527                     continueRunning = false;
9528                     break; // Don't process any more messages on the queue
9529                 }
9530             }
9531 
9532             java.util.List queueList = (java.util.List)getResult.resultObj;
9533 
9534             // Iterate through the list of messages we got off our queue
9535 
9536             Iterator queueIter = queueList.iterator();
9537 
9538             while (queueIter.hasNext())
9539             {
9540                 Map queueMap = (Map)queueIter.next();
9541                 String queueType = (String)queueMap.get("type");
9542 
9543                 if (queueType == null)
9544                     continue; // Ignore message
9545 
9546                 if (queueType.equalsIgnoreCase("STAF/STAXMonitor/End"))
9547                 {
9548                     continueRunning = false;
9549                     break; // Don't process any more messages on the queue
9550                 }
9551                 else if (!queueType.equalsIgnoreCase("STAF/Service/Event"))
9552                 {
9553                     continue; // Ignore messages that don't have this type
9554                 }
9555 
9556                 // Process only STAF/Service/Event messages whose event type
9557                 // matches the STAX service name and machine for which the
9558                 // STAX Monitor is configured
9559 
9560                 Map messageMap = (Map)queueMap.get("message");
9561                 String type = (String)messageMap.get("type");
9562 
9563                 if (!type.equalsIgnoreCase(fStaxServiceName + "/" +
9564                                            fStaxConfigMachine))
9565                 {
9566                     continue;  // Ignore messages that don't have this type
9567                 }
9568 
9569                 // Process STAF/Service/Event messages with matching event type
9570 
9571                 String eventID = (String)messageMap.get("eventID");
9572 
9573                 STAFResult ackResult = fHandle.submit2(
9574                     STAFHandle.ReqFireAndForget, fEventMachineName,
9575                     fEventServiceName, "ACKNOWLEDGE EVENTID " + eventID);
9576 
9577                 String subtype = (String)messageMap.get("subtype");
9578 
9579                 if (!subtype.equals("Job"))
9580                 {
9581                     continue;  // Ignore messages that don't have subtype Job
9582                 }
9583 
9584                 // Process STAF/ServiceEvent messages with matching event type
9585                 // and have event subtype "Job"
9586 
9587                 Map propertyMap = (HashMap)messageMap.get("propertyMap");
9588                 String status = (String)propertyMap.get("status");
9589 
9590                 if (status == null)
9591                     continue; // Ignore message
9592 
9593                 if (status.equals("begin"))
9594                 {
9595                     final String jobID = (String)propertyMap.get("jobID");
9596                     final String jobName = (String)propertyMap.get("jobName");
9597                     final String startFunction = (String)propertyMap.get(
9598                         "startFunction");
9599                     String startTimestamp = (String)propertyMap.get(
9600                         "startTimestamp");
9601 
9602                     String startDate = "";
9603                     String startTime = "";
9604 
9605                     if ((startTimestamp != null) &&
9606                         (startTimestamp.length() > 9))
9607                     {
9608                         // startTimestamp format is YYYYMMDD-HH:MM:SS
9609                         startDate = startTimestamp.substring(0, 8);
9610                         startTime = startTimestamp.substring(9);
9611                     }
9612 
9613                     final String runnableStartDate = startDate;
9614                     final String runnableStartTime = startTime;
9615 
9616                     Runnable runnable = new Runnable()
9617                     {
9618                         public void run()
9619                         {
9620                             addJob(jobID, jobName, startFunction,
9621                                    runnableStartDate, runnableStartTime);
9622                         }
9623                     };
9624 
9625                     try
9626                     {
9627                         SwingUtilities.invokeAndWait(runnable);
9628                     }
9629                     catch (InterruptedException e) {}
9630                     catch (InvocationTargetException e) {}
9631                 }
9632                 else if (status.equals("run"))
9633                 {
9634                     // The job is now in a Running state so update its "State"
9635                     // and "Start Function" (and possibly the "Job Name" and
9636                     // "Start Timestamp" if the job run event is received
9637                     // before the job start event
9638 
9639                     final String jobID = (String)propertyMap.get("jobID");
9640                     final String startFunction =
9641                         (String)propertyMap.get("startFunction");
9642                     final String jobName = (String)propertyMap.get("jobName");
9643                     final String startTimestamp =
9644                         (String)propertyMap.get("startTimestamp");
9645 
9646                     Runnable runnable = new Runnable()
9647                     {
9648                         public void run()
9649                         {
9650                             updateJob(jobID, jobName, startFunction,
9651                                       startTimestamp);
9652                         }
9653                     };
9654 
9655                     try
9656                     {
9657                         SwingUtilities.invokeAndWait(runnable);
9658                     }
9659                     catch (InterruptedException e) {}
9660                     catch (InvocationTargetException e) {}
9661                 }
9662                 else if (status.equals("end"))
9663                 {
9664                     String jobID = (String)propertyMap.get("jobID");
9665                     String result = STAFMarshallingContext.formatObject(
9666                         propertyMap.get("result"));
9667 
9668                     final String runnableJobID = jobID;
9669                     final String runnableResult = result;
9670 
9671                     Runnable runnable = new Runnable()
9672                     {
9673                         public void run()
9674                         {
9675                             removeJob(runnableJobID, runnableResult);
9676                         }
9677                     };
9678 
9679                     try
9680                     {
9681                         SwingUtilities.invokeAndWait(runnable);
9682                     }
9683                     catch (InterruptedException e) {}
9684                     catch (InvocationTargetException e) {}
9685 
9686                     if (fCloseOnEndJobID.equals(jobID))
9687                     {
9688                         exit();
9689                         System.exit(0);
9690                     }
9691                 }
9692             } // end while iterating through the queue list
9693         } // end while continueRunning
9694 
9695         try
9696         {
9697             STAXMonitorUtil.unregisterMainHandle();
9698         }
9699         catch (STAFException e)
9700         {
9701             // Ignore any errors
9702         }
9703     }
9704 
9705     /**
9706      * This method is called when the STAX Monitor receives a job begin event
9707      * indicating that the job is being submitted for execution (has a
9708      * "Pending" state).  This method adds the job to the Active Jobs Table
9709      * if is doesn't already exist and if a STAX QUERY JOB request verifies
9710      * that the job is still running.
9711      */
addJob(String jobID, String jobName, String startFunction, String startDate, String startTime)9712     public void addJob(String jobID, String jobName, String startFunction,
9713                        String startDate, String startTime)
9714     {
9715         synchronized(fActiveJobsModelSorter)
9716         {
9717             // Determine if job already is in Active Jobs Table.  If so,
9718             // received job run event before job begin event so ignore.
9719 
9720             Vector jobsVector = fActiveJobsTableModel.getDataVector();
9721 
9722             for (int j = 0; j < jobsVector.size(); j++)
9723             {
9724                 if (((Vector)(jobsVector.elementAt(j))).elementAt(0).equals(
9725                     new Integer(jobID)))
9726                 {
9727                     return;  // Job is already in the Active Jobs Table
9728                 }
9729             }
9730 
9731             // Job is not in Active Jobs Table.  Submit a STAX QUERY JOB
9732             // request to make sure didn't receive a job end event before the
9733             // job begin event
9734 
9735             String request = "QUERY JOB " + jobID;
9736 
9737             STAFResult result = fHandle.submit2(
9738                 fStaxMachineName, fStaxServiceName, request);
9739 
9740             if (result.rc != STAFResult.Ok)
9741                 return;  // The job has already completed so don't add the job
9742 
9743             // Add the job to the Active Jobs Table using the query job info
9744 
9745             Object rowData[] = new Object[8];
9746             rowData[0] = new Integer(jobID);
9747 
9748             Map jobInfo = (Map)result.resultObj;
9749 
9750             if (jobName.equals(""))
9751                 jobName = NOT_APPLICABLE;
9752 
9753             rowData[1] = jobName;
9754 
9755             synchronized (fMonitorTable)
9756             {
9757                 if (fMonitorTable.containsKey(jobID))
9758                     rowData[2] = new Boolean(true);
9759                 else
9760                     rowData[2] = new Boolean(false);
9761             }
9762 
9763             final int waitTime = getElapsedTimeInterval();
9764             String initialTime = "";
9765 
9766             if (waitTime > 0)
9767                 initialTime = "00:00:00";
9768 
9769             rowData[3] = (String)jobInfo.get("startFunction");
9770             rowData[4] = (String)jobInfo.get("state");
9771             rowData[5] = startDate + "-" + startTime;
9772             rowData[6] = initialTime;
9773             rowData[7] = "";
9774 
9775             fActiveJobsTableModel.addRow(rowData);
9776             STAXMonitorUtil.updateRowHeights(fActiveJobsTable, 7);
9777             STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
9778         }
9779 
9780         fJobStartTimes.put(jobID, getCalendar(startDate, startTime));
9781         fJobStartDateTimes.put(jobID, startDate + "@" + startTime);
9782     }
9783 
9784     /**
9785      * This method is called when the STAX Monitor receives a job run event
9786      * indicating that the job is being executed (has a "Running" state).
9787      */
updateJob(String jobID, String jobName, String startFunction, String startTimestamp)9788     public void updateJob(String jobID, String jobName, String startFunction,
9789                           String startTimestamp)
9790     {
9791         synchronized (fActiveJobsModelSorter)
9792         {
9793             Vector jobsVector = fActiveJobsTableModel.getDataVector();
9794 
9795             // Check if the job already is in the Active Jobs Table.  If so,
9796             // update isMonitored and start function.  If the job's status in
9797             // the "Active Jobs Table" is not "Complete", set the job's status
9798             // to "Running".
9799 
9800             for (int j = 0; j < jobsVector.size(); j++)
9801             {
9802                 Vector jobVector = (Vector)jobsVector.elementAt(j);
9803 
9804                 if (jobVector.elementAt(0).equals(new Integer(jobID)))
9805                 {
9806                     synchronized (fMonitorTable)
9807                     {
9808                         if (fMonitorTable.containsKey(jobID))
9809                         {
9810                             fActiveJobsTableModel.setValueAt(
9811                                 new Boolean(true), j, 2);
9812                         }
9813                         else
9814                         {
9815                             fActiveJobsTableModel.setValueAt(
9816                                 new Boolean(false), j, 2);
9817                         }
9818                     }
9819 
9820                     fActiveJobsTableModel.setValueAt(startFunction, j, 3);
9821 
9822                     if (!jobVector.elementAt(4).equals("Complete"))
9823                     {
9824                         fActiveJobsTableModel.setValueAt("Running", j, 4);
9825                     }
9826 
9827                     synchronized (fActiveJobsTable)
9828                     {
9829                         fActiveJobsTable.updateUI();
9830                         STAXMonitorUtil.updateRowHeights(fActiveJobsTable, 7);
9831                         STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
9832                     }
9833 
9834                     return;
9835                 }
9836             }
9837 
9838             // The job is not in Active Jobs Table.
9839             // Submit a STAX QUERY JOB request to make sure the job is still
9840             // running (e.g. because could have received a job end event
9841             // before the job run event),
9842 
9843             String request = "QUERY JOB " + jobID;
9844 
9845             STAFResult result = fHandle.submit2(
9846                 fStaxMachineName, fStaxServiceName, request);
9847 
9848             if (result.rc != STAFResult.Ok)
9849                 return;  // The job has already completed so don't add the job
9850 
9851             // The job is still running, so add it to the Active Jobs Table
9852             // (this means that the job run event was received before the
9853             // job begin event),
9854 
9855             Object rowData[] = new Object[8];
9856             rowData[0] = new Integer(jobID);
9857 
9858             Map jobInfo = (Map)result.resultObj;
9859 
9860             if (jobName.equals(""))
9861                 rowData[1] = NOT_APPLICABLE;
9862             else
9863                 rowData[1] = jobName;
9864 
9865             synchronized (fMonitorTable)
9866             {
9867                 if (fMonitorTable.containsKey(jobID))
9868                     rowData[2] = new Boolean(true);
9869                 else
9870                     rowData[2] = new Boolean(false);
9871             }
9872 
9873             rowData[3] = (String)jobInfo.get("startFunction");
9874             rowData[4] = (String)jobInfo.get("state");
9875 
9876             String startDate = "";
9877             String startTime = "";
9878 
9879             if ((startTimestamp != null) && (startTimestamp.length() > 9))
9880             {
9881                 startDate = startTimestamp.substring(0, 8);
9882                 startTime = startTimestamp.substring(9);
9883                 rowData[5] = startDate + "-" + startTime;
9884                 fJobStartTimes.put(jobID, getCalendar(startDate, startTime));
9885                 fJobStartDateTimes.put(jobID, startDate + "@" + startTime);
9886             }
9887             else
9888             {
9889                 rowData[5] = "";
9890             }
9891 
9892             int waitTime = getElapsedTimeInterval();
9893             String initialTime = "";
9894 
9895             if (waitTime > 0)
9896                 initialTime = "00:00:00";
9897 
9898             rowData[6] = initialTime;
9899             rowData[7] = "";
9900 
9901             fActiveJobsTableModel.addRow(rowData);
9902             STAXMonitorUtil.updateRowHeights(fActiveJobsTable, 7);
9903             STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
9904         }
9905     }
9906 
9907     /**
9908      * This method is called when the STAX Monitor receives a job stop event
9909      * indicating that the job has completed
9910      */
removeJob(String jobID, String result)9911     public void removeJob(String jobID, String result)
9912     {
9913         synchronized(fActiveJobsModelSorter)
9914         {
9915             // Check if the job is in the Active Jobs Table
9916 
9917             Vector jobsVector = fActiveJobsTableModel.getDataVector();
9918             int rowIndex = -1;
9919 
9920             for (int j = 0; j < jobsVector.size(); j++)
9921             {
9922                 if (((Vector)(jobsVector.elementAt(j))).elementAt(0).equals(
9923                     new Integer(jobID)))
9924                 {
9925                     rowIndex = j;
9926                     break;
9927                 }
9928             }
9929 
9930             if (rowIndex == -1)
9931                 return;  // Job not found in Active Jobs Table
9932 
9933             if (!fMonitorTable.containsKey(jobID))
9934             {
9935                 // The job is not being monitored so remove the job from
9936                 // the Active Jobs Table
9937 
9938                 fJobPopupMenu.setVisible(false);
9939                 fActiveJobsTableModel.removeRow(rowIndex);
9940 
9941                 ((STAXMonitorTableCellRenderer)fActiveJobsTable.
9942                  getColumnModel().getColumn(0).getCellRenderer()).
9943                     clearRowHeights();
9944             }
9945             else
9946             {
9947                 // The job is being monitored so update its "Status" as
9948                 // complete and its "Result"
9949 
9950                 fActiveJobsTableModel.setValueAt("Complete", rowIndex, 4);
9951                 fActiveJobsTableModel.setValueAt(result, rowIndex, 7);
9952             }
9953 
9954             fJobStartTimes.remove(jobID);
9955             fJobStartDateTimes.remove(jobID);
9956 
9957             synchronized (fActiveJobsTable)
9958             {
9959                 fActiveJobsTable.updateUI();
9960                 STAXMonitorUtil.updateRowHeights(fActiveJobsTable, 7);
9961                 STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
9962             }
9963         }
9964     }
9965 
exit()9966     public void exit()
9967     {
9968         // Delete temporary extension jar files on local system copied from
9969         // STAX Service machine (if not the local system)
9970 
9971         Iterator iter = fTempLocalExtFiles.iterator();
9972 
9973         while (iter.hasNext())
9974         {
9975             // Delete the extension jar file in fExtensionDirectory
9976 
9977             String jarFileName = (String)(iter.next());
9978 
9979             String deleteRequest = "DELETE ENTRY " +
9980                 STAFUtil.wrapData(jarFileName) + " CONFIRM";
9981 
9982             STAFResult deleteResult = fHandle.submit2(
9983                 "local", "FS", deleteRequest);
9984         }
9985 
9986         if (fExtensionsDirectory != null)
9987         {
9988             // Delete the local fExtensionDirectory
9989 
9990             String deleteRequest = "DELETE ENTRY " +
9991                 STAFUtil.wrapData(fExtensionsDirectory) + " RECURSE CONFIRM";
9992 
9993             STAFResult deleteResult = fHandle.submit2(
9994                 "local", "FS", deleteRequest);
9995         }
9996 
9997         // Unregister for Job Events
9998 
9999         unregisterForJobEvents();
10000 
10001         try
10002         {
10003             ObjectOutputStream oos =
10004                 new ObjectOutputStream(new FileOutputStream(fRecentFilesName));
10005             oos.writeObject(((Object)(fRecentFiles)));
10006             oos.close();
10007         }
10008         catch (IOException ex)
10009         {
10010             ex.printStackTrace();
10011         }
10012 
10013         fHandle.submit2(
10014             "local", "QUEUE", "QUEUE TYPE STAF/STAXMonitor/End MESSAGE " +
10015             STAFUtil.wrapData(""));
10016 
10017         saveJobParms(fLastJobParmsFileName);
10018 
10019         fContinueElapsedTime = false;
10020 
10021         STAXMonitorUtil.cleanupHandles();
10022     }
10023 
getStaxConfigMachine()10024     public String getStaxConfigMachine()
10025     {
10026         return fStaxConfigMachine;
10027     }
10028 
getStaxInstanceUUID()10029     public String getStaxInstanceUUID()
10030     {
10031         return fStaxInstanceUUID;
10032     }
10033 
getVersion()10034     public String getVersion()
10035     {
10036         return fVersion;
10037     }
10038 
getPluginClasses()10039     public Vector getPluginClasses()
10040     {
10041         return fPluginClasses;
10042     }
10043 
getElapsedTimeInterval()10044     public int getElapsedTimeInterval()
10045     {
10046         return new Integer(fElapsedTimeSecondsFieldText).intValue() * 1000;
10047     }
10048 
getProcessMonitorInterval()10049     public int getProcessMonitorInterval()
10050     {
10051         return new Integer(fProcessMonitorSecondsFieldText).intValue() * 1000;
10052     }
10053 
getMessageFontName()10054     public String getMessageFontName()
10055     {
10056         return fMessageFontName;
10057     }
10058 
getLogViewerFontName()10059     public String getLogViewerFontName()
10060     {
10061         return fLogViewerFontName;
10062     }
10063 
getSaveAsDirectory()10064     public String getSaveAsDirectory()
10065     {
10066         return fSaveAsDirectory;
10067     }
10068 
getDefaultTestcaseSortColumn()10069     public int getDefaultTestcaseSortColumn()
10070     {
10071         return fTestcaseSortColumn;
10072     }
10073 
getDefaultTestcaseSortOrder()10074     public int getDefaultTestcaseSortOrder()
10075     {
10076         // 0 is Ascending, 1 is Descending
10077         return fTestcaseSortOrder;
10078     }
10079 
getDisplayTestcaseName()10080     public boolean getDisplayTestcaseName()
10081     {
10082         return fDisplayTestcaseName;
10083     }
10084 
getDisplayTestcasePass()10085     public boolean getDisplayTestcasePass()
10086     {
10087         return fDisplayTestcasePass;
10088     }
10089 
getDisplayTestcaseFail()10090     public boolean getDisplayTestcaseFail()
10091     {
10092         return fDisplayTestcaseFail;
10093     }
10094 
getDisplayTestcaseStartDateTime()10095     public boolean getDisplayTestcaseStartDateTime()
10096     {
10097         return fDisplayTestcaseStartDateTime;
10098     }
10099 
getDisplayTestcaseStatusDateTime()10100     public boolean getDisplayTestcaseStatusDateTime()
10101     {
10102         return fDisplayTestcaseStatusDateTime;
10103     }
10104 
getDisplayTestcaseDuration()10105     public boolean getDisplayTestcaseDuration()
10106     {
10107         return fDisplayTestcaseDuration;
10108     }
10109 
getDisplayTestcaseStarts()10110     public boolean getDisplayTestcaseStarts()
10111     {
10112         return fDisplayTestcaseStarts;
10113     }
10114 
getDisplayTestcaseInformation()10115     public boolean getDisplayTestcaseInformation()
10116     {
10117         return fDisplayTestcaseInformation;
10118     }
10119 
getTestcaseAutoResize()10120     public boolean getTestcaseAutoResize()
10121     {
10122         return fTestcaseAutoResize;
10123     }
10124 
generateErrorMsg(int rc, String result)10125     public String generateErrorMsg(int rc, String result)
10126     {
10127         String errorMsg = "RC: " + rc;
10128         String rcDescription = "";
10129 
10130         if ((rcDescription = getErrorDescription(rc)).length() > 0)
10131             errorMsg += " (" + rcDescription + ")";
10132 
10133         if (result.length() > 0)
10134             errorMsg += "\nAdditional info\n---------------\n" + result;
10135 
10136         return errorMsg;
10137     }
10138 
getErrorDescription(int rc)10139     public String getErrorDescription(int rc)
10140     {
10141         String errorDescription = "";
10142         String helpServiceMachine = "local";
10143 
10144         if (!fStaxMachineName.equals(""))
10145             helpServiceMachine = fStaxMachineName;
10146 
10147         if (rc < 4000)
10148         {
10149             // Submit a request to the HELP service to get the error
10150             // description for this error
10151 
10152             STAFResult result = fHandle.submit2(
10153                 helpServiceMachine, "HELP", "ERROR " + rc);
10154 
10155             if (result.rc == STAFResult.Ok)
10156             {
10157                 Map errorHelpMap = (Map)result.resultObj;
10158                 errorDescription = (String)errorHelpMap.get("description");
10159             }
10160         }
10161         else
10162         {
10163             // Submit a request to the HELP servicve to get the error
10164             // description for this STAX service error
10165 
10166             String staxServiceName = "STAX";
10167 
10168             if (!fStaxServiceName.equals(""))
10169                 staxServiceName = fStaxServiceName;
10170 
10171             STAFResult result = fHandle.submit2(
10172                 helpServiceMachine, "HELP", "ERROR " + rc + " SERVICE " +
10173                 staxServiceName);
10174 
10175             if (result.rc == STAFResult.Ok)
10176             {
10177                 Map errorHelpMap = (Map)result.resultObj;
10178                 errorDescription = (String)errorHelpMap.get("description");
10179             }
10180         }
10181 
10182         return errorDescription;
10183     }
10184 
10185     // Convert a list of messages to a single string with numbered messages
10186     // where each message is prepended with "\n\n" + messageNumber + ")  "
10187 
convertMsgs(java.util.List msgList)10188     private String convertMsgs(java.util.List msgList)
10189     {
10190         StringBuffer msg = new StringBuffer();
10191 
10192         Iterator iter = msgList.iterator();
10193         int i = 0;
10194 
10195         while (iter.hasNext())
10196         {
10197             msg.append("\n\n" + ++i + ")  " + (String)iter.next());
10198         }
10199 
10200         return msg.toString();
10201     }
10202 
10203     // Load monitor extensions from local extension jar files
10204 
loadLocalExtensions()10205     private STAFResult loadLocalExtensions()
10206     {
10207         // Return if no local extension jar files specified
10208 
10209         if (fLocalExtJarFiles.isEmpty())
10210         {
10211             return new STAFResult(STAFResult.Ok);
10212         }
10213 
10214         java.util.List msgList = new ArrayList();
10215 
10216         // Iterate through the local extension jar file list, loading valid
10217         // monitor extensions from each extension jar file.
10218 
10219         Iterator iter = fLocalExtJarFiles.iterator();
10220 
10221         while (iter.hasNext())
10222         {
10223             String jarFileName = (String)(iter.next());
10224             String localJarFileName = jarFileName;
10225 
10226             // Validate extensions in the jar file and load valid extensions
10227 
10228             validateExtension(localJarFileName, LOCAL_EXTENSION,
10229                               jarFileName, msgList);
10230         }
10231 
10232         if (msgList.size() == 0)
10233             return new STAFResult(STAFResult.Ok);
10234         else
10235             return new STAFResult(STAFResult.InvalidValue,
10236                                   convertMsgs(msgList));
10237     }
10238 
10239     // Load monitor extensions from extension jar files registered on the
10240     // STAX service machine.
10241 
loadSTAXServiceExtensions()10242     private STAFResult loadSTAXServiceExtensions()
10243     {
10244         java.util.List msgList = new ArrayList();
10245         java.util.List monitorExtList = new ArrayList();
10246 
10247         // Create a list of extension jar files registered on the STAX service
10248         // machine that contain one or more monitor extensions
10249 
10250         createExtensionJarFileList(monitorExtList, msgList);
10251 
10252         // Return if no monitor extensions are registered for the STAX service
10253 
10254         if (monitorExtList.isEmpty())
10255         {
10256             if (msgList.isEmpty())
10257                 return new STAFResult(STAFResult.Ok);
10258             else
10259                 return new STAFResult(STAFResult.InvalidValue,
10260                                       convertMsgs(msgList));
10261         }
10262 
10263         // For each monitor extension in the extension jar file, check if
10264         // it's valid and load an instance of the extension's class.
10265 
10266         Iterator iter = monitorExtList.iterator();
10267         boolean firstExtension = true;
10268 
10269         while (iter.hasNext())
10270         {
10271             String jarFileName = (String)(iter.next());
10272             String localJarFileName = jarFileName;
10273             File extJarFile = null;
10274 
10275             if (!fIsSTAXServiceLocal)
10276             {
10277                 // If 1st extension, create fExtensionsDirectory
10278 
10279                 if (firstExtension)
10280                 {
10281                     firstExtension = false;
10282 
10283                     // Assign name of directory to temporarily store extension
10284                     // jar files copied from the STAX Service machine
10285                     fExtensionsDirectory = fMonitorFileDirectory + fFileSep +
10286                         "extensions" + fFileSep + fStaxConfigMachine +
10287                         fFileSep + fStaxServiceName;
10288 
10289                     File extDir = new File(fExtensionsDirectory);
10290 
10291                     if (extDir.exists())
10292                     {
10293                         // Delete the local fExtensionDirectory
10294 
10295                         String deleteRequest = "DELETE ENTRY " +
10296                              STAFUtil.wrapData(fExtensionsDirectory) +
10297                              " RECURSE CONFIRM";
10298 
10299                         STAFResult deleteResult = fHandle.submit2(
10300                             "local", "FS", deleteRequest);
10301 
10302                         if (deleteResult.rc != 0 && deleteResult.rc != 50)
10303                         {
10304                             // Ignore RC 50 errors since it could indicate
10305                             // another instance of the STAX Monitor talking
10306                             // to the same STAX service machine is running.
10307 
10308                             msgList.add(
10309                                 "WARNING: Error deleting local temporary " +
10310                                 "directory used to store extension jar " +
10311                                 "files copied from STAX service machine.\n" +
10312                                 "Service: FS, Request: " + deleteRequest +
10313                                 ", RC: " + deleteResult.rc + ", Result: " +
10314                                 deleteResult.result);
10315                         }
10316                     }
10317 
10318                     if (!extDir.exists())
10319                     {
10320                         if (!(extDir.mkdirs()))
10321                         {
10322                             msgList.add(
10323                                 "Error creating directory " +
10324                                 fExtensionsDirectory + " to use for " +
10325                                 "temporarily storing extension jar files " +
10326                                 "copied from STAX service machine " +
10327                                 fStaxMachineName);
10328 
10329                             return new STAFResult(STAFResult.InvalidValue,
10330                                                   convertMsgs(msgList));
10331                         }
10332                     }
10333                 }
10334 
10335                 // Copy the extension jar files from the STAX service machine
10336                 // to the local STAX Monitor machine's fExtensionsDirectory.
10337 
10338                 extJarFile = new File(jarFileName);
10339                 String toFile = fExtensionsDirectory + fFileSep +
10340                                 extJarFile.getName();
10341 
10342                 String copyRequest = "COPY FILE " +
10343                     STAFUtil.wrapData(jarFileName) + " TOFILE " +
10344                     STAFUtil.wrapData(toFile);
10345 
10346                 STAFResult copyResult = fHandle.submit2(
10347                     fStaxMachineName, "FS", copyRequest);
10348 
10349                 if (copyResult.rc != 0)
10350                 {
10351                     msgList.add(
10352                         "Error copying extension jar file " + jarFileName +
10353                         " from STAX service machine.  machine=" +
10354                         fStaxMachineName + ", Service: FS, Request: " +
10355                         copyRequest + ", rc=" + copyResult.rc +
10356                         ", Result: " + copyResult.result);
10357 
10358                     continue;  // Skip this jar file
10359                 }
10360                 else
10361                 {
10362                     localJarFileName = toFile;
10363                     fTempLocalExtFiles.add(toFile);
10364                 }
10365             }
10366 
10367             // Validate extensions in the jar file and load valid extensions
10368 
10369             validateExtension(localJarFileName, STAX_SERVICE_EXTENSION,
10370                               jarFileName, msgList);
10371         }
10372 
10373         if (msgList.size() == 0)
10374             return new STAFResult(STAFResult.Ok);
10375         else
10376             return new STAFResult(STAFResult.InvalidValue,
10377                                   convertMsgs(msgList));
10378     }
10379 
10380     // Create a list of extension jar files registered on the STAX service
10381     // machine that contain at least one monitor extension.
10382 
createExtensionJarFileList(java.util.List monitorExtList, java.util.List msgList)10383     private void createExtensionJarFileList(java.util.List monitorExtList,
10384                                             java.util.List msgList)
10385     {
10386         // Get STAX service version
10387 
10388         String versionRequest = "VERSION";
10389 
10390         STAFResult versionResult = fHandle.submit2(
10391             fStaxMachineName, fStaxServiceName, versionRequest);
10392 
10393         if (versionResult.rc == 0)
10394         {
10395             String staxServiceVersion = versionResult.result;
10396             fSTAXServiceVersion = new STAFVersion(staxServiceVersion);
10397         }
10398 
10399         // Get extension jar file information from the STAX service machine
10400 
10401         String queryRequest = "QUERY EXTENSIONJARFILES";
10402 
10403         STAFResult queryResult = fHandle.submit2(
10404             fStaxMachineName, fStaxServiceName, queryRequest);
10405 
10406         if (queryResult.rc != 0)
10407         {
10408             if (queryResult.rc == STAFResult.InvalidRequestString)
10409             {
10410                 // Check if STAX service is at the required version or later
10411 
10412                 STAFVersion requiredVersion = new STAFVersion(
10413                     fServiceRequiredVersion);
10414 
10415                 if (fSTAXServiceVersion.compareTo(requiredVersion) < 0)
10416                 {
10417                     msgList.add(
10418                         "Cannot get monitor extensions from STAX " +
10419                         "service machine because it's not at STAX " +
10420                         "version " + requiredVersion + " or later.  " +
10421                         "machine=" + fStaxMachineName +
10422                         ", service=" + fStaxServiceName +
10423                         ", version=" + fSTAXServiceVersion );
10424 
10425                     return;
10426                 }
10427             }
10428 
10429             msgList.add(
10430                 "Error querying extension jar files on STAX service machine " +
10431                 fStaxMachineName + ", Service: " + fStaxServiceName +
10432                 ", Request: " + queryRequest + ", RC: " + queryResult.rc +
10433                 ", Result: " + queryResult.result);
10434 
10435             return;
10436         }
10437 
10438         // Read through the query output and add the extension jar file names
10439         // that contain at least one monitor extension to monitoExtList
10440 
10441         java.util.List extensionList = (java.util.List)queryResult.resultObj;
10442         Iterator iter = extensionList.iterator();
10443 
10444         while (iter.hasNext())
10445         {
10446             Map extensionMap = (Map)iter.next();
10447 
10448             String jarFileName = (String)extensionMap.get("extensionJarFile");
10449             Map monitorExtensionMap =
10450                 (Map)extensionMap.get("monitorExtensions");
10451 
10452             if (monitorExtensionMap != null)
10453                 monitorExtList.add(jarFileName);
10454         }
10455     }
10456 
10457     // Validate each monitor extension provided in the specified extension
10458     // jar file.  Load an instance of each valid monitor extension class.
10459     // Add valid monitor extension information to the fMonitorExtensionMap
10460     // and add valid extension instances to the fPluginMap.
10461     // Returns STAFResult (rc, result):
10462     // - If no validation errors, rc = 0, result = ""
10463     // - If any validation errors occur, a rc = non-zero value and
10464     //   result = validation error(s)/warning(s)
10465 
validateExtension(String localJarFileName, int source, String jarFileName, java.util.List msgList)10466     private void validateExtension(String localJarFileName, int source,
10467                                    String jarFileName, java.util.List msgList)
10468     {
10469         // Assign a string value for the source of the extension jar files
10470 
10471         String sourceStr = "STAX service";
10472 
10473         if (source == STAX_SERVICE_EXTENSION)
10474             sourceStr = "STAX service";
10475         else if (source == LOCAL_EXTENSION)
10476             sourceStr = "local";
10477 
10478         // Access the extension jar file
10479 
10480         int numMonExtensions = 0;  // Count of monitor extensions in jar file
10481         JarFile jarFile = null;
10482 
10483         try
10484         {
10485             jarFile = new JarFile(localJarFileName);
10486         }
10487         catch (IOException e)
10488         {
10489             msgList.add(
10490                 "Unable to access " + sourceStr + " extension jar file " +
10491                 jarFileName + "\n" + e.getMessage());
10492 
10493             return;
10494         }
10495 
10496         // Access the extension jar file's manifest
10497 
10498         Manifest manifest = null;
10499 
10500         try
10501         {
10502             manifest = jarFile.getManifest();
10503         }
10504         catch (IOException e)
10505         {
10506             msgList.add(
10507                 "Unable to access manifest in " + sourceStr +
10508                 " extension jar file " + jarFileName + "\n" + e.getMessage());
10509 
10510             return;
10511         }
10512 
10513         Map manifestEntryMap = manifest.getEntries();
10514 
10515         // Get information (e.g. version, description, prereq monitor
10516         // version), if provided, from the manifest
10517 
10518         String extVersion = NOT_APPLICABLE;
10519         String description = NOT_APPLICABLE;
10520         String monitorVersion = NOT_APPLICABLE;
10521 
10522         if (manifestEntryMap.containsKey(STAX_EXTENSION_INFO))
10523         {
10524             Attributes attrs = manifest.getAttributes(STAX_EXTENSION_INFO);
10525 
10526             if (attrs.getValue("Extension-Version") != null)
10527             {
10528                 extVersion = attrs.getValue("Extension-Version");
10529             }
10530 
10531             if (attrs.getValue("Extension-Description") != null)
10532             {
10533                 description = attrs.getValue("Extension-Description");
10534             }
10535 
10536             if (attrs.getValue("Required-Monitor-Version") != null)
10537             {
10538                 monitorVersion = attrs.getValue("Required-Monitor-Version");
10539 
10540                 // Make sure STAX Monitor is at this version or later.
10541 
10542                 STAFVersion requiredVersion;
10543 
10544                 try
10545                 {
10546                     requiredVersion = new STAFVersion(monitorVersion);
10547 
10548                     if (fMonitorVersion.compareTo(requiredVersion) < 0)
10549                     {
10550                         msgList.add(
10551                             "Monitor extensions in " + sourceStr +
10552                             " extension jar file " + jarFileName +
10553                             " require version " + requiredVersion +
10554                             " or later of the STAX Monitor." +
10555                             "  You are running version " + fMonitorVersion +
10556                             " so not loading these monitor extensions.");
10557 
10558                         // Not loading monitor extensions in this jar file
10559                         return;
10560                     }
10561                 }
10562                 catch (NumberFormatException e)
10563                 {
10564                     msgList.add(
10565                         "Monitor extensions in " + sourceStr +
10566                         " extension jar file " + jarFileName +
10567                         " require an invalid version (" + monitorVersion +
10568                         ") of the STAX Monitor.\n" + e.toString() +
10569                         "\nLoading these monitor extensions anyway.");
10570                 }
10571             }
10572         }
10573 
10574         // Create a class loader used to load STAX so it can be passed to
10575         // the STAXMonitorExtensionClassLoader to load STAX classes
10576 
10577         Class c = this.getClass();
10578         ClassLoader parentClassLoader = c.getClassLoader();
10579 
10580         // Make sure can load the extension class
10581 
10582         ClassLoader loader = new STAXMonitorExtensionClassLoader(
10583             jarFile, parentClassLoader);
10584 
10585         // Iterate through the staf/staxmonitor/extension entries in the
10586         // manifest, adding valid monitor extensions to fMonitorExtensionMap
10587 
10588         Iterator mfIter = manifestEntryMap.keySet().iterator();
10589 
10590         while (mfIter.hasNext())
10591         {
10592             String entry = (String)mfIter.next();
10593 
10594             if (!entry.startsWith(STAX_MONITOR_EXTENSION))
10595             {
10596                 continue; // Ignore these entries
10597             }
10598 
10599             String extName = entry.substring(STAX_MONITOR_EXTENSION.length());
10600 
10601             numMonExtensions++;
10602 
10603             Attributes attrs = manifest.getAttributes(STAX_MONITOR_EXTENSION +
10604                                                       extName);
10605 
10606             if (!attrs.containsKey(new Attributes.Name("Extension-Class")))
10607             {
10608                 msgList.add(
10609                     "Monitor extension '" + extName + "' is missing " +
10610                     "attribute Extension-Class in manifest for " +
10611                     sourceStr + " extension jar file " + jarFileName +
10612                     ".");
10613 
10614                 continue;  // Skip this extension
10615             }
10616 
10617             String pluginClassName = attrs.getValue("Extension-Class");
10618 
10619             if (fMonitorExtensionMap.containsKey(extName))
10620             {
10621                 ExtensionInfo extInfo =
10622                     (ExtensionInfo)fMonitorExtensionMap.get(extName);
10623 
10624                 if ((source == STAX_SERVICE_EXTENSION) &&
10625                     (extInfo.getSource() == LOCAL_EXTENSION))
10626                 {
10627                     // Local extension is overriding STAX Service extension
10628 
10629                     extInfo.putOverriddenJarFileName(jarFileName);
10630 
10631                     // Display warning message if the STAX Service
10632                     // extension's version is equal or later than the local
10633                     // extension's version.
10634 
10635                     STAFVersion serviceExtVersion;
10636                     STAFVersion localExtVersion;
10637 
10638                     try
10639                     {
10640                         serviceExtVersion = new STAFVersion(
10641                             extInfo.getVersion());
10642 
10643                         localExtVersion = new STAFVersion(extVersion);
10644 
10645                         int compareValue = serviceExtVersion.compareTo(
10646                             localExtVersion);
10647 
10648                         if (compareValue == 0)
10649                         {
10650                             msgList.add(
10651                                 "WARNING: Monitor extension '" + extName +
10652                                 "' version " + localExtVersion + " in " +
10653                                 sourceStr + " extension jar file " +
10654                                 jarFileName +
10655                                 " is overridden by the same version (" +
10656                                 serviceExtVersion + ") of the extension in " +
10657                                 extInfo.getSourceStr() +
10658                                 " extension jar file " +
10659                                 extInfo.getJarFileName() + ".");
10660                         }
10661                         else if (compareValue < 0)
10662                         {
10663                             msgList.add(
10664                                 "WARNING: Monitor extension '" + extName +
10665                                 "' version " + localExtVersion +
10666                                 " in " + sourceStr + " extension jar file " +
10667                                 jarFileName +
10668                                 " is overridden by an earlier version (" +
10669                                 serviceExtVersion + ") of the extension in " +
10670                                 extInfo.getSourceStr() +
10671                                 " extension jar file " +
10672                                 extInfo.getJarFileName() + ".");
10673                         }
10674                     }
10675                     catch (NumberFormatException e)
10676                     {
10677                         msgList.add(
10678                             "WARNING: Monitor extension '" + extName +
10679                             "' version " + extVersion + " in " + sourceStr +
10680                             " extension jar file " + jarFileName +
10681                             " is overridden by version (" +
10682                             extInfo.getVersion() + ") of the extension in " +
10683                             extInfo.getSourceStr() + " extension jar file " +
10684                             extInfo.getJarFileName() + ".\n" + e.toString());
10685                     }
10686                 }
10687                 else
10688                 {
10689                     msgList.add(
10690                         "Cannot register monitor extension '" + extName +
10691                         "' in " + sourceStr + " extension jar file " +
10692                         jarFileName + " because it was already " +
10693                         "registered from " + extInfo.getSourceStr() +
10694                         " extension jar file " + extInfo.getJarFileName() +
10695                         ".");
10696                 }
10697 
10698                 continue;  // Skip this extension
10699             }
10700 
10701             Class pluginClass = null;
10702             Object pluginObj = null;
10703 
10704             try
10705             {
10706                 pluginClass = loader.loadClass(pluginClassName);
10707 
10708                 // Try using a constructor that accepts a STAX object
10709 
10710                 Class [] parameterTypes = new Class[1];
10711                 parameterTypes[0] = this.getClass();
10712 
10713                 try
10714                 {
10715                     Constructor construct =
10716                         pluginClass.getConstructor(parameterTypes);
10717                     Object [] initArgs = new Object[1];
10718                     initArgs[0] = this;
10719                     pluginObj = construct.newInstance(initArgs);
10720 
10721                     // Add to extension info to fMonitorExtensionMap
10722                     fMonitorExtensionMap.put(
10723                         extName,
10724                         new ExtensionInfo(jarFileName, extVersion,
10725                                           description, monitorVersion,
10726                                           source));
10727 
10728                     // Add extension class to fPluginClasses
10729                     fPluginClasses.add(pluginClass);
10730                 }
10731                 catch (NoSuchMethodException e)
10732                 {
10733                     // Extension does not have a constructor that accepts
10734                     // a STAX object, so use constructor without parameters
10735                     pluginObj = pluginClass.newInstance();
10736 
10737                     // Add to extension info to fMonitorExtensionMap
10738                     fMonitorExtensionMap.put(
10739                         extName,
10740                         new ExtensionInfo(jarFileName, extVersion,
10741                                           description, monitorVersion,
10742                                           source));
10743 
10744                     // Add extension class to fPluginClasses
10745                     fPluginClasses.add(pluginClass);
10746                 }
10747                 catch (InvocationTargetException e)
10748                 {
10749                     msgList.add(
10750                         "Cannot load class for monitor extension '" +
10751                         extName + "' in " + sourceStr +
10752                         " extension jar file " + jarFileName +
10753                         ".  Class name: " + pluginClassName + "\n" +
10754                         e.getMessage());
10755 
10756                     e.printStackTrace();
10757                 }
10758                 catch (IllegalArgumentException e)
10759                 {
10760                     msgList.add(
10761                         "Cannot load class for monitor extension '" +
10762                         extName + "' in " + sourceStr +
10763                         " extension jar file " + jarFileName +
10764                         ".  Class name: " + pluginClassName + "\n" +
10765                         e.getMessage());
10766 
10767                     e.printStackTrace();
10768                 }
10769             }
10770             catch (ClassNotFoundException e)
10771             {
10772                 msgList.add(
10773                     "Cannot load class for monitor extension '" +
10774                     extName + "' in " + sourceStr +
10775                     " extension jar file " + jarFileName +
10776                     ".  Class name: " + pluginClassName + "\n" +
10777                     e.getMessage());
10778 
10779                 e.printStackTrace();
10780             }
10781             catch (InstantiationException e)
10782             {
10783                 msgList.add(
10784                     "Cannot load class for monitor extension '" +
10785                     extName + "' in " + sourceStr +
10786                     " extension jar file " + jarFileName +
10787                     ".  Class name: " + pluginClassName + "\n" +
10788                     e.getMessage());
10789 
10790                 e.printStackTrace();
10791             }
10792             catch (IllegalAccessException e)
10793             {
10794                 msgList.add(
10795                     "Cannot load class for monitor extension '" +
10796                     extName + "' in " + sourceStr +
10797                     " extension jar file " + jarFileName +
10798                     ".  Class name: " + pluginClassName +
10799                     "\n" + e.getMessage());
10800 
10801                 e.printStackTrace();
10802             }
10803         }
10804 
10805         if (numMonExtensions == 0)
10806         {
10807             msgList.add(
10808                 "No monitor extensions exist in " + sourceStr +
10809                 " extension jar file " + jarFileName +
10810                 ".  It's manifest file does not specify any " +
10811                 "entries beginning with " + STAX_MONITOR_EXTENSION + ".");
10812         }
10813 
10814         return;
10815     }
10816 
10817     public class SplashScreen extends JWindow implements Runnable,
10818                                                          MouseListener,
10819                                                          ActionListener
10820     {
SplashScreen(ImageIcon image, int timeout, String msg)10821         public SplashScreen(ImageIcon image, int timeout, String msg)
10822         {
10823             int w = image.getIconWidth() + 5;
10824             int h = image.getIconHeight() + 5;
10825             Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
10826             int x = (screen.width - w) / 2;
10827             int y = (screen.height - h) / 2;
10828             setBounds(x, y, w, h);
10829 
10830             JPanel splashPanel = new JPanel();
10831             splashPanel.setLayout(new BorderLayout());
10832             splashPanel.setBorder(new BevelBorder(BevelBorder.RAISED));
10833             JLabel picture = new JLabel(image);
10834             splashPanel.add("Center", picture);
10835             picture.addMouseListener(this);
10836 
10837             JLabel text = new JLabel(msg, SwingConstants.CENTER);
10838             text.setPreferredSize(new Dimension(w,25));
10839             text.setOpaque(true);
10840             text.setBackground(Color.black);
10841             text.setForeground(Color.white);
10842             text.addMouseListener(this);
10843 
10844             splashPanel.add("South", text);
10845             getContentPane().add(splashPanel);
10846 
10847             javax.swing.Timer timer = new javax.swing.Timer(0, this);
10848             timer.setRepeats(false);
10849             timer.setInitialDelay(timeout);
10850             timer.start();
10851         }
10852 
SplashScreen(ImageIcon image, String msg)10853         public SplashScreen(ImageIcon image, String msg)
10854         {
10855             // Displays the initializing splash screen without a timer and
10856             // does not close it you  mouse click on the splash screen
10857 
10858             int w = image.getIconWidth() + 5;
10859             int h = image.getIconHeight() + 5;
10860             Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
10861             int x = (screen.width - w) / 2;
10862             int y = (screen.height - h) / 2;
10863             setBounds(x, y, w, h);
10864 
10865             JPanel splashPanel = new JPanel();
10866             splashPanel.setLayout(new BorderLayout());
10867             splashPanel.setBorder(new BevelBorder(BevelBorder.RAISED));
10868             JLabel picture = new JLabel(image);
10869             splashPanel.add("Center", picture);
10870 
10871             JLabel text = new JLabel(msg, SwingConstants.CENTER);
10872             text.setPreferredSize(new Dimension(w,25));
10873             text.setOpaque(true);
10874             text.setBackground(Color.black);
10875             text.setForeground(Color.white);
10876 
10877             splashPanel.add("South", text);
10878             getContentPane().add(splashPanel);
10879         }
10880 
run()10881         public void run()
10882         {
10883             setVisible(true);
10884         }
10885 
mouseClicked(MouseEvent event)10886         public void mouseClicked(MouseEvent event)
10887         {
10888             setVisible(false);
10889             dispose();
10890         }
10891 
mouseEntered(MouseEvent event)10892         public void mouseEntered(MouseEvent event) {}
mouseExited(MouseEvent event)10893         public void mouseExited(MouseEvent event) {}
mousePressed(MouseEvent event)10894         public void mousePressed(MouseEvent event) {}
mouseReleased(MouseEvent event)10895         public void mouseReleased(MouseEvent event) {}
10896 
actionPerformed(ActionEvent event)10897         public void actionPerformed(ActionEvent event)
10898         {
10899             setVisible(false);
10900             dispose();
10901         }
10902 
close()10903         public void close()
10904         {
10905             setVisible(false);
10906             dispose();
10907         }
10908 
10909     }
10910 
10911     public class DirectoryFilter extends FileFilter
10912     {
accept(File file)10913         public boolean accept(File file)
10914         {
10915             if (file == null) return false;
10916 
10917             if (file.isDirectory())
10918                 return true;
10919             else
10920                 return false;
10921         }
10922 
getDescription()10923         public String getDescription()
10924         {
10925             return "All Directories";
10926         }
10927     }
10928 
10929     public class STAXJobTableCellRenderer
10930              extends JPanel implements TableCellRenderer
10931     {
10932         private JLabel label = new JLabel();
10933         public Hashtable rowHeights = new Hashtable();
10934         private boolean isHeader = true;
10935 
10936         private java.net.URL greenballURL =
10937             ClassLoader.getSystemClassLoader().
10938                 getSystemResource("images/grnball.gif");
10939 
10940         private ImageIcon monitoredIcon = new ImageIcon(greenballURL);
10941 
STAXJobTableCellRenderer()10942         public STAXJobTableCellRenderer()
10943         {
10944             this(new Font("Dialog", Font.PLAIN, 12), Color.white);
10945             isHeader = false;
10946         }
10947 
STAXJobTableCellRenderer(Font font, Color background)10948         public STAXJobTableCellRenderer(Font font, Color background)
10949         {
10950             label.setFont(font);
10951             label.setOpaque(true);
10952             label.setBackground(background);
10953             label.setForeground(Color.black);
10954             label.setHorizontalAlignment(SwingConstants.CENTER);
10955 
10956             setBorder(BorderFactory.createRaisedBevelBorder());
10957 
10958             JPanel innerPanel = new JPanel();
10959             innerPanel.setLayout(new BorderLayout());
10960             innerPanel.add(label, BorderLayout.NORTH);
10961 
10962             setLayout(new BorderLayout());
10963             add(innerPanel, BorderLayout.NORTH);
10964         }
10965 
clearRowHeights()10966         public void clearRowHeights()
10967         {
10968             rowHeights.clear();
10969         }
10970 
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)10971         public Component getTableCellRendererComponent(JTable table,
10972                                                        Object value,
10973                                                        boolean isSelected,
10974                                                        boolean hasFocus,
10975                                                        int row, int col)
10976         {
10977             if (isHeader)
10978             {
10979                 setBackground(Color.lightGray);
10980                 label.setBackground(Color.lightGray);
10981             }
10982             else if (isSelected)
10983             {
10984                 setBackground(UIManager.getColor("Table.selectionBackground"));
10985                 label.setBackground(
10986                     UIManager.getColor("Table.selectionBackground"));
10987             }
10988             else
10989             {
10990                 setBackground(Color.white);
10991                 label.setBackground(Color.white);
10992             }
10993 
10994             if (fActiveJobsTableModel.getColumnClass(col).equals(
10995                 Boolean.class) && !isHeader)
10996             {
10997                 label.setText("");
10998                 if (((Boolean)value).booleanValue())
10999                 {
11000                     label.setIcon(monitoredIcon);
11001                 }
11002                 else
11003                 {
11004                     label.setIcon(null);
11005                 }
11006                 return this;
11007             }
11008             else
11009             {
11010                 label.setText((value == null) ? "" : String.valueOf(value));
11011             }
11012 
11013             return this;
11014         }
11015     }
11016 
11017     public class STAXJobListCellRenderer
11018              extends JTextArea implements ListCellRenderer
11019     {
11020         public Hashtable rowHeights = new Hashtable();
11021 
STAXJobListCellRenderer()11022         public STAXJobListCellRenderer()
11023         {
11024             setBorder(BorderFactory.createRaisedBevelBorder());
11025         }
11026 
STAXJobListCellRenderer(Font font)11027         public STAXJobListCellRenderer(Font font)
11028         {
11029             setFont(font);
11030             setBorder(BorderFactory.createRaisedBevelBorder());
11031         }
11032 
getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)11033         public Component getListCellRendererComponent(JList list,
11034                                                       Object value,
11035                                                       int index,
11036                                                       boolean isSelected,
11037                                                       boolean cellHasFocus)
11038         {
11039             setText((value == null) ? "" : String.valueOf(value));
11040 
11041             if (isSelected)
11042             {
11043                 setBackground(fScriptList.getSelectionBackground());
11044             }
11045             else
11046             {
11047                 setBackground(Color.white);
11048             }
11049 
11050             return this;
11051         }
11052     }
11053 
11054     public class STAXExtensionsTableCellRenderer
11055              extends JLabel implements TableCellRenderer
11056     {
11057         public Hashtable rowHeights = new Hashtable();
11058         private boolean isHeader = true;
11059 
11060         private java.net.URL greenballURL =
11061             ClassLoader.getSystemClassLoader().
11062                 getSystemResource("images/grnball.gif");
11063 
11064         private ImageIcon monitoredIcon = new ImageIcon(greenballURL);
11065 
STAXExtensionsTableCellRenderer()11066         public STAXExtensionsTableCellRenderer()
11067         {
11068             this(new Font("Dialog", Font.PLAIN, 12), Color.white);
11069             isHeader = false;
11070         }
11071 
STAXExtensionsTableCellRenderer(int alignment)11072         public STAXExtensionsTableCellRenderer(int alignment)
11073         {
11074             this(new Font("Dialog", Font.PLAIN, 12), Color.white);
11075             isHeader = false;
11076             setHorizontalAlignment(alignment);
11077         }
11078 
STAXExtensionsTableCellRenderer(Font font, Color background)11079         public STAXExtensionsTableCellRenderer(Font font, Color background)
11080         {
11081             setFont(font);
11082             setOpaque(true);
11083             setBackground(background);
11084             setForeground(Color.black);
11085             setHorizontalAlignment(SwingConstants.CENTER);
11086 
11087             setBorder(BorderFactory.createRaisedBevelBorder());
11088         }
11089 
clearRowHeights()11090         public void clearRowHeights()
11091         {
11092             rowHeights.clear();
11093         }
11094 
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)11095         public Component getTableCellRendererComponent(JTable table,
11096                                                        Object value,
11097                                                        boolean isSelected,
11098                                                        boolean hasFocus,
11099                                                        int row, int col)
11100         {
11101             if (isHeader)
11102             {
11103                 setBackground(Color.lightGray);
11104             }
11105             else if (isSelected)
11106             {
11107                 setBackground(UIManager.getColor("Table.selectionBackground"));
11108             }
11109             else
11110             {
11111                 setBackground(Color.white);
11112             }
11113 
11114             setText((value == null) ? "" : String.valueOf(value));
11115 
11116             return this;
11117         }
11118     }
11119 
11120     class MonitorElapsedTime extends Thread
11121     {
run()11122         public void run()
11123         {
11124             final int waitTime = getElapsedTimeInterval();
11125 
11126             if (waitTime == 0)
11127                 return;
11128 
11129             while (fContinueElapsedTime)
11130             {
11131                 try
11132                 {
11133                     Thread.sleep(waitTime);
11134                 }
11135                 catch (InterruptedException ex)
11136                 {
11137                 }
11138 
11139                 final Enumeration jobElapsedTimeKeys = fJobStartTimes.keys();
11140 
11141                 Runnable runnable = new Runnable()
11142                 {
11143                     public void run()
11144                     {
11145                         while (fContinueElapsedTime &&
11146                                jobElapsedTimeKeys.hasMoreElements())
11147                         {
11148                             String jobID =
11149                                 (String)jobElapsedTimeKeys.nextElement();
11150 
11151                             Calendar jobStarted = (Calendar)
11152                                 fJobStartTimes.get(jobID);
11153 
11154                             updateElapsedTime(jobID,
11155                                 STAXMonitorUtil.getElapsedTime(jobStarted));
11156                         }
11157 
11158                         synchronized (fActiveJobsTable)
11159                         {
11160                             fActiveJobsTable.repaint();
11161                         }
11162                     }
11163                 };
11164 
11165                 try
11166                 {
11167                     SwingUtilities.invokeAndWait(runnable);
11168                 }
11169                 catch (InterruptedException ex)
11170                 {
11171                      ex.printStackTrace();
11172                 }
11173                 catch (InvocationTargetException ex)
11174                 {
11175                      ex.printStackTrace();
11176                 }
11177             }
11178         }
11179 
11180         /**
11181          * Find the row in the Active Jobs Table for the specified job ID
11182          * and update its elapsed time field
11183          */
updateElapsedTime(String jobID, String elapsedTime)11184         public void updateElapsedTime(String jobID, String elapsedTime)
11185         {
11186             Vector jobsVector = fActiveJobsTableModel.getDataVector();
11187 
11188             for (int j = 0; j < jobsVector.size(); j++)
11189             {
11190                 if (((Vector)(jobsVector.elementAt(j))).elementAt(0).equals(
11191                     new Integer(jobID)))
11192                 {
11193                     fActiveJobsTableModel.setValueAt(elapsedTime, j, 6);
11194 
11195                     /* XXX: Need?
11196                     synchronized (fActiveJobsTable)
11197                     {
11198                         fActiveJobsTable.updateUI();
11199                         STAXMonitorUtil.sizeColumnsToFitText(fActiveJobsTable);
11200                     }
11201                     */
11202                 }
11203             }
11204         }
11205     }
11206 
11207     // Helper class to contain information about each monitor extension
11208 
11209     public class ExtensionInfo
11210     {
11211         private String fJarFileName;
11212         private String fVersion;
11213         private String fDescription;
11214         private String fRequiredMonitorVersion;
11215         private int    fSource;  // STAX_SERVICE_EXTENSION or LOCAL_EXTENSION
11216         private String fOverriddenJarFileName = new String("");
11217 
ExtensionInfo(String jarFileName, String version, String description, String requiredMonitorVersion, int source)11218         public ExtensionInfo(String jarFileName, String version,
11219                       String description, String requiredMonitorVersion,
11220                       int source)
11221         {
11222             fJarFileName = jarFileName;
11223             fVersion = version;
11224             fDescription = description;
11225             fRequiredMonitorVersion = requiredMonitorVersion;
11226             fSource = source;
11227         }
11228 
getJarFileName()11229         public String getJarFileName() { return fJarFileName; }
getVersion()11230         public String getVersion()     { return fVersion; }
getDescription()11231         public String getDescription() { return fDescription; }
getRequiredMonitorVersion()11232         public String getRequiredMonitorVersion()
11233         { return fRequiredMonitorVersion; }
getSource()11234         public int    getSource()      { return fSource; }
11235 
getSourceStr()11236         public String getSourceStr()
11237         {
11238             if (fSource == STAX_SERVICE_EXTENSION)
11239                 return "STAX Service";
11240             else if (fSource == LOCAL_EXTENSION)
11241                 return "local";
11242             else
11243                 return "unknown";
11244         }
11245 
getOverriddenJarFileName()11246         public String getOverriddenJarFileName()
11247         { return fOverriddenJarFileName; }
11248 
putOverriddenJarFileName(String jarFileName)11249         public void putOverriddenJarFileName(String jarFileName)
11250         { fOverriddenJarFileName = jarFileName; }
11251     }
11252 
11253     private class Endpoint
11254     {
11255         private String fInterface = null;
11256         private String fMachineIdentifier = null;
11257         private String fPort = null;
11258 
Endpoint(String endpoint)11259         private Endpoint(String endpoint)
11260         {
11261             int beginIndex = 0;
11262             int endIndex = endpoint.length();
11263 
11264             // Remove the interface, if present, from the beginning of the
11265             // endpoint, indicated by <Interface>://
11266 
11267             int interfaceIndex = endpoint.indexOf(sInterfaceSeparator);
11268 
11269             if (interfaceIndex > -1)
11270             {
11271                 fInterface = endpoint.substring(0, interfaceIndex);
11272                 beginIndex = interfaceIndex + sInterfaceSeparator.length();
11273             }
11274 
11275             // Remove the port, if present, from the end of the endpoint,
11276             // indicated by @<Port>
11277 
11278             int portIndex = endpoint.lastIndexOf(sPortSeparator);
11279 
11280             if (portIndex > -1)
11281             {
11282                 endIndex = portIndex;
11283                 fPort = endpoint.substring(portIndex + sPortSeparator.length());
11284             }
11285 
11286             fMachineIdentifier = endpoint.substring(beginIndex, endIndex);
11287         }
11288 
getInterface()11289         String getInterface()
11290         {
11291             return fInterface;
11292         }
11293 
getMachineIdentifier()11294         String getMachineIdentifier()
11295         {
11296             return fMachineIdentifier;
11297         }
11298 
getPort()11299         String getPort()
11300         {
11301             return fPort;
11302         }
11303     }
11304 
11305 
11306     // Helper class to contain information about the Event Service associated
11307     // with the STAX Service used by the STAX Monitor
11308 
11309     private class EventServiceInfo
11310     {
11311         private String eventMachineName;
11312         private String eventServiceName;
11313 
EventServiceInfo(String staxMachineName, String staxServiceName, STAXMonitor staxMonitor, boolean displayMessage)11314         private EventServiceInfo(String staxMachineName,
11315                                  String staxServiceName,
11316                                  STAXMonitor staxMonitor,
11317                                  boolean displayMessage)
11318         {
11319             String errorTitle = "Error Listing STAX Service Settings";
11320             String errorText = "STAX Service Machine:  " +
11321                 staxMachineName + "\nSTAX Service Name:  " +
11322                 staxServiceName + "\n\n";
11323 
11324             // Set to default values
11325             this.eventMachineName = staxMachineName;
11326             this.eventServiceName = "Event";
11327 
11328             Endpoint staxEndpoint = new Endpoint(staxMachineName);
11329             fStaxMachineInterface = staxEndpoint.getInterface();
11330             fStaxMachineIdentifier = staxEndpoint.getMachineIdentifier();
11331             fStaxMachinePort = staxEndpoint.getPort();
11332 
11333             // Get event machine and service names based by submitting a
11334             // LIST SETTINGS request to the STAX service machine
11335 
11336             String listRequest = "LIST SETTINGS";
11337 
11338             STAFResult listResult = fHandle.submit2(
11339                 staxMachineName, staxServiceName, listRequest);
11340 
11341             if (listResult.rc != 0)
11342             {
11343                 // An error occurred trying to list the STAX service settings
11344 
11345                 if (listResult.rc == STAFResult.UnknownService)
11346                 {
11347                     errorTitle = "STAX Service Not Registered";
11348                     errorText += "WARNING: The STAX service is not " +
11349                         "registered on the specified machine." +
11350                         "\n\nVerify the STAX Monitor's properties.\n";
11351 
11352                 }
11353                 else if (listResult.rc == STAFResult.NoPathToMachine)
11354                 {
11355                     errorTitle = "No Path to STAX Service Machine";
11356                     errorText += "WARNING: No path to the STAX service " +
11357                         "machine\nThis indicates that the STAX Monitor is " +
11358                         "not able to submit a request to the specified " +
11359                         "STAX service machine.  This error usually " +
11360                         "indicates that STAF is not running or that " +
11361                         "this is not the correct STAX service machine.\n\n" +
11362                         "Verify the STAX Monitor's properties.\n";
11363                 }
11364                 else
11365                 {
11366                     errorText += "Error listing settings on STAX service " +
11367                         "machine\n\nRequest: " + listRequest +
11368                         "\nRC: " + listResult.rc +
11369                         "\nResult: " + listResult.result +
11370                         "\n\nVerify the STAX Monitor's properties.\n";
11371                 }
11372 
11373                 if (displayMessage)
11374                 {
11375                     STAXMonitorUtil.showErrorDialog(
11376                         staxMonitor, errorText, errorTitle);
11377                 }
11378 
11379                 return;
11380             }
11381             else if (!STAFMarshallingContext.isMarshalledData(
11382                      listResult.result))
11383             {
11384                 errorText += "Error listing settings on STAX service " +
11385                     "machine\n\nRequest: " + listRequest +
11386                     "\nRC: " + listResult.rc +
11387                     "\nResult: " + listResult.result +
11388                     "\n\nThe LIST SETTINGS result is not marshalled data.\n";
11389 
11390                 if (displayMessage)
11391                 {
11392                     STAXMonitorUtil.showErrorDialog(
11393                         staxMonitor, errorText, errorTitle);
11394                 }
11395 
11396                 return;
11397             }
11398 
11399             // Get the event machine name and the event service name
11400 
11401             Map settingsMap = (Map)listResult.resultObj;
11402 
11403             this.eventMachineName = (String)settingsMap.get("eventMachine");
11404             this.eventServiceName = (String)settingsMap.get("eventService");
11405 
11406             if (this.eventMachineName.equalsIgnoreCase("local") ||
11407                 this.eventMachineName.equalsIgnoreCase("local://local"))
11408             {
11409                 this.eventMachineName = staxMachineName;
11410             }
11411             else
11412             {
11413                 Endpoint eventEndpoint = new Endpoint(this.eventMachineName);
11414                 String eventMachineInterface = eventEndpoint.getInterface();
11415                 String eventMachineIdentifier = eventEndpoint.getMachineIdentifier();
11416                 String eventMachinePort = eventEndpoint.getPort();
11417 
11418                 // Determine port to use for Event machine if not specified
11419 
11420                 if (eventMachinePort == null)
11421                 {
11422                     String port = "";
11423 
11424                     if (eventMachineInterface == null)
11425                     {
11426                         STAFResult res = fHandle.submit2(
11427                             staxMachineName, "VAR",
11428                             "RESOLVE STRING {STAF/Config/DefaultInterface}");
11429 
11430                         if (res.rc != 0)
11431                         {
11432                             System.out.println(
11433                                 "Error resolving variable " +
11434                                 "STAF/Config/DefaultInterface on machine: " +
11435                                 staxMachineName + "\nRC: " + res.rc +
11436                                 ", Result: " + res.result);
11437                             return;
11438                         }
11439 
11440                         eventMachineInterface = res.result;
11441                     }
11442 
11443                     STAFResult res = fHandle.submit2(
11444                         staxMachineName, "MISC", "QUERY INTERFACE " +
11445                         eventMachineInterface);
11446 
11447                     if (res.rc != 0)
11448                     {
11449                         System.out.println(
11450                             "Error submitting MISC QUERY INTERFACE request " +
11451                             "to machine: " + staxMachineName + "\nRC: " +
11452                             res.rc + ", Result: " + res.result);
11453                         return;
11454                     }
11455 
11456                     Map interfaceMap = (Map)res.resultObj;
11457                     Map optionMap = (Map)interfaceMap.get("optionMap");
11458 
11459                     if (optionMap.containsKey("Port"))
11460                         port = (String)optionMap.get("Port");
11461 
11462                     eventMachinePort = port;
11463                 }
11464 
11465                 String eventMachine = "";
11466 
11467                 if (fStaxMachineInterface != null)
11468                     eventMachine += fStaxMachineInterface + sInterfaceSeparator;
11469 
11470                 eventMachine += eventMachineIdentifier + sPortSeparator +
11471                     eventMachinePort;
11472 
11473                 this.eventMachineName = eventMachine;
11474             }
11475 
11476             // Get the version of the event service
11477 
11478             STAFResult versionResult = fHandle.submit2(
11479                 this.eventMachineName, this.eventServiceName, "VERSION");
11480 
11481             if (versionResult.rc != 0)
11482             {
11483                 // An error occurred getting the version of the Event service
11484 
11485                 if (versionResult.rc == STAFResult.UnknownService)
11486                 {
11487                     errorTitle = "Event Service Not Registered";
11488                     errorText += "WARNING: Event service " +
11489                         this.eventServiceName +
11490                         " is not registered on machine " +
11491                         this.eventMachineName + ".\n";
11492                 }
11493                 else if (versionResult.rc == STAFResult.NoPathToMachine)
11494                 {
11495                     errorTitle = "No Path to Event Service Machine";
11496                     errorText += "WARNING: No path to the Event service " +
11497                         "machine " + this.eventMachineName +
11498                         "\nThis indicates that the STAX Monitor is " +
11499                         "not able to submit a request to the specified " +
11500                         "Event service machine.  This error usually " +
11501                         "indicates that STAF is not running on the machine " +
11502                         "or this is not the correct Event service machine.\n";
11503                 }
11504                 else
11505                 {
11506                     errorTitle = "Error Getting Event Service Version";
11507                     errorText += "Error getting the version of the Event " +
11508                         "service\nRC: " + versionResult.rc +
11509                         ", Result: " + versionResult.result + "\n";
11510                 }
11511 
11512                 if (displayMessage)
11513                 {
11514                     STAXMonitorUtil.showErrorDialog(
11515                         staxMonitor, errorText, errorTitle);
11516                 }
11517 
11518                 return;
11519             }
11520 
11521             // Verify that the version of the Event service is at the
11522             // required version or later
11523 
11524             STAFVersion eventServiceVersion = new STAFVersion(
11525                 versionResult.result);
11526             STAFVersion eventRequiredVersion = new STAFVersion(
11527                 fEventRequiredVersion);
11528 
11529             if (eventServiceVersion.compareTo(eventRequiredVersion) < 0)
11530             {
11531                 if (displayMessage)
11532                 {
11533                     STAXMonitorUtil.showErrorDialog(
11534                         staxMonitor, "The STAX Monitor requires version " +
11535                         eventRequiredVersion +
11536                         " or later of the event service.  The version of the " +
11537                         this.eventServiceName + " service on machine " +
11538                         this.eventMachineName + " is " + eventServiceVersion +
11539                         ".",  "Invalid Event Service Version");
11540 
11541                     return;
11542                 }
11543             }
11544         }
11545 
getMachine()11546         private String getMachine()
11547         {
11548             return eventMachineName;
11549         }
11550 
getService()11551         private String getService()
11552         {
11553             return eventServiceName;
11554         }
11555 
setMachine(String eventMachine)11556         private void setMachine(String eventMachine)
11557         {
11558             this.eventMachineName = eventMachine;
11559         }
11560 
setService(String eventService)11561         private void setService(String eventService)
11562         {
11563             this.eventServiceName = eventService;
11564         }
11565     }
11566 
11567     public class ArgumentTableCellRenderer
11568              extends DefaultTableCellRenderer
11569     {
11570         public Hashtable rowHeights = new Hashtable();
11571         private boolean isHeader = true;
11572         private Color background = Color.white;
11573 
ArgumentTableCellRenderer()11574         public ArgumentTableCellRenderer()
11575         {
11576             this(new Font("Courier", Font.PLAIN, 12), Color.white);
11577             isHeader = false;
11578         }
11579 
ArgumentTableCellRenderer(Font font, Color background)11580         public ArgumentTableCellRenderer(Font font, Color background)
11581         {
11582             //textfield.setFont(font);
11583             //textfield.setOpaque(true);
11584             //textfield.setBackground(background);
11585             //textfield.setForeground(Color.black);
11586             //textfield.setEditable(true);
11587         }
11588 
clearRowHeights()11589         public void clearRowHeights()
11590         {
11591             rowHeights.clear();
11592         }
11593 
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)11594         public Component getTableCellRendererComponent(JTable table,
11595                                                        Object value,
11596                                                        boolean isSelected,
11597                                                        boolean hasFocus,
11598                                                        int row, int col)
11599         {
11600             String cellContent = (value == null) ? "" :
11601                 String.valueOf(value);
11602 
11603             if (value instanceof ArgumentName)
11604             {
11605                 JPanel panel = new JPanel();
11606                 panel.setLayout(new BorderLayout());
11607                 panel.setBackground(Color.white);
11608                 //panel.add(BorderLayout.NORTH, combo);
11609 
11610                 return panel;
11611             }
11612             else
11613             {
11614                 JPanel panel = new JPanel();
11615                 panel.setBackground(Color.white);
11616                 return panel;
11617             }
11618         }
11619     }
11620 
11621     public interface WizardArgumentInterface
11622     {
setString(String string)11623         public void setString(String string);
getString()11624         public String getString();
getFirstLine()11625         public String getFirstLine();
11626     }
11627 
11628     public class ArgumentName implements WizardArgumentInterface
11629     {
11630         private String string;
11631 
ArgumentName(String string)11632         public ArgumentName(String string)
11633         {
11634             this.string = string;
11635         }
11636 
getString()11637         public String getString()
11638         {
11639             return string;
11640         }
11641 
setString(String string)11642         public void setString(String string)
11643         {
11644             this.string = string;
11645         }
11646 
getFirstLine()11647         public String getFirstLine()
11648         {
11649             return string;
11650         }
11651 
toString()11652         public String toString()
11653         {
11654             return string;
11655         }
11656     }
11657 
11658     public class ArgumentDescription implements WizardArgumentInterface
11659     {
11660         private String string;
11661         private String firstLine;
11662 
ArgumentDescription(String string)11663         public ArgumentDescription(String string)
11664         {
11665             this.string = string;
11666 
11667             StringTokenizer tok = new StringTokenizer(string, "\n");
11668             int count = tok.countTokens();
11669 
11670             if (count < 2)
11671             {
11672                 firstLine = string;
11673             }
11674             else
11675             {
11676                 firstLine = tok.nextToken() + "...";
11677             }
11678         }
11679 
getString()11680         public String getString()
11681         {
11682             return string;
11683         }
11684 
setString(String string)11685         public void setString(String string)
11686         {
11687             this.string = string;
11688         }
11689 
getFirstLine()11690         public String getFirstLine()
11691         {
11692             return firstLine;
11693         }
11694 
toString()11695         public String toString()
11696         {
11697             return string;
11698         }
11699     }
11700 
11701     public class ArgumentRequired implements WizardArgumentInterface
11702     {
11703         private String string;
11704 
ArgumentRequired(String string)11705         public ArgumentRequired(String string)
11706         {
11707             this.string = string;
11708         }
11709 
getString()11710         public String getString()
11711         {
11712             return string;
11713         }
11714 
setString(String string)11715         public void setString(String string)
11716         {
11717             this.string = string;
11718         }
11719 
getFirstLine()11720         public String getFirstLine()
11721         {
11722             return string;
11723         }
11724 
toString()11725         public String toString()
11726         {
11727             return string;
11728         }
11729     }
11730 
11731     public class ArgumentValue implements WizardArgumentInterface
11732     {
11733         private String string;
11734         private String firstLine;
11735 
ArgumentValue(String string)11736         public ArgumentValue(String string)
11737         {
11738             this.string = string;
11739         }
11740 
getString()11741         public String getString()
11742         {
11743             return string;
11744         }
11745 
setString(String string)11746         public void setString(String string)
11747         {
11748             this.string = string;
11749         }
11750 
getFirstLine()11751         public String getFirstLine()
11752         {
11753             return string;
11754         }
11755 
toString()11756         public String toString()
11757         {
11758             return string;
11759         }
11760     }
11761 
11762     class MultiLineToolTip extends JToolTip
11763     {
MultiLineToolTip()11764         public MultiLineToolTip()
11765         {
11766             setUI(new MultiLineToolTipUI());
11767         }
11768     }
11769 
11770     class MultiLineToolTipUI extends MetalToolTipUI
11771     {
11772         String[] lines;
11773         int maxWidth = 0;
11774 
paint(Graphics g, JComponent c)11775         public void paint(Graphics g, JComponent c)
11776         {
11777             FontMetrics metrics = c.getFontMetrics(g.getFont());
11778             Dimension size = c.getSize();
11779             g.setColor(c.getBackground());
11780             g.fillRect(0, 0, size.width, size.height);
11781             g.setColor(c.getForeground());
11782 
11783             if (lines != null)
11784             {
11785                 for (int i = 0; i < lines.length; i++)
11786                 {
11787                     g.drawString(lines[i], 3, (metrics.getHeight()) * (i + 1));
11788                 }
11789             }
11790         }
11791 
getPreferredSize(JComponent c)11792         public Dimension getPreferredSize(JComponent c)
11793         {
11794             FontMetrics metrics = c.getFontMetrics(c.getFont());
11795             String tipText = ((JToolTip)c).getTipText();
11796 
11797             if (tipText == null)
11798             {
11799                 tipText = "";
11800             }
11801 
11802             BufferedReader br = new BufferedReader(new StringReader(tipText));
11803             String line;
11804             int maxWidth = 0;
11805             Vector lineVector = new Vector();
11806 
11807             try
11808             {
11809                 while ((line = br.readLine()) != null)
11810                 {
11811                     int width =
11812                         SwingUtilities.computeStringWidth(metrics, line);
11813 
11814                     if (maxWidth < width)
11815                     {
11816                         maxWidth = width;
11817                     }
11818 
11819                     lineVector.addElement(line);
11820                 }
11821             }
11822             catch (IOException ex)
11823             {
11824                 ex.printStackTrace();
11825             }
11826 
11827             int numberOfLines = lineVector.size();
11828 
11829             if (numberOfLines < 1)
11830             {
11831                 lines = null;
11832                 numberOfLines = 1;
11833             }
11834             else
11835             {
11836                 lines = new String[numberOfLines];
11837                 int i = 0;
11838 
11839                 for (Enumeration e = lineVector.elements();
11840                      e.hasMoreElements();
11841                      i++)
11842                 {
11843                     lines[i] = (String)e.nextElement();
11844                 }
11845             }
11846 
11847             int height = metrics.getHeight() * numberOfLines;
11848             this.maxWidth = maxWidth;
11849 
11850             return new Dimension(maxWidth + 8, height + 8);
11851         }
11852     }
11853 }
11854 
11855