crashanalysercmd/UI/Plugins/CAPluginCrashAnalyserUi/Wizards/CAWizardCrashAnalysis.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 using System;
       
    19 using System.Collections.Generic;
       
    20 using System.ComponentModel;
       
    21 using System.Data;
       
    22 using System.Text;
       
    23 using System.Windows.Forms;
       
    24 using SymbianUtils;
       
    25 using CrashItemLib.Engine.Sources;
       
    26 using CAPCrashAnalysis.Plugin;
       
    27 
       
    28 namespace CAPluginCrashAnalysisUi.Wizards
       
    29 {
       
    30     internal partial class CAWizardCrashAnalysis : Form
       
    31     {
       
    32         #region Constructors
       
    33         public CAWizardCrashAnalysis( CAPluginCrashAnalysis aEngine )
       
    34         {
       
    35             iEngine = aEngine;
       
    36             //
       
    37             InitializeComponent();
       
    38         }
       
    39         #endregion
       
    40 
       
    41         #region Events
       
    42         private void CAWizardCrashFile_Load( object sender, EventArgs e )
       
    43         {
       
    44         }
       
    45 
       
    46         private void CAWizardCrashFile_FormClosing( object sender, FormClosingEventArgs e )
       
    47         {
       
    48         }
       
    49 
       
    50         private void iWizard_WizardClosedFromFinish( SymbianWizardLib.Engine.SymWizardClosureEvent aEventArgs )
       
    51         {
       
    52             DialogResult = DialogResult.OK;
       
    53         }
       
    54         #endregion
       
    55 
       
    56         #region Page - source files
       
    57         private void PG_SourceFiles_UpdateWizardButtonState()
       
    58         {
       
    59             iWizard.ButtonNext.Enabled = ( iPG_SourceFiles_FileList.FileCount > 0 );
       
    60         }
       
    61 
       
    62         private void iPG_SourceFiles_Load( object aSender, EventArgs aArgs )
       
    63         {
       
    64             // Seed file list dialog with file types.
       
    65             string types = iEngine.GetSupportedCrashFileTypes();
       
    66             iPG_SourceFiles_FileList.DialogFilter = types;
       
    67  
       
    68             iEngine.Settings.Load( "CrashFileWizard_SourceFiles", iPG_SourceFiles_FileList );
       
    69             PG_SourceFiles_UpdateWizardButtonState();
       
    70         }
       
    71 
       
    72         private void iPG_SourceFiles_FileList_SourceListChanged( CrashItemUiLib.Controls.CIEngineSourceManager aControl, CrashItemUiLib.Controls.CIEngineSourceManager.TEvent aEvent )
       
    73         {
       
    74             PG_SourceFiles_UpdateWizardButtonState();
       
    75         }
       
    76 
       
    77         private void iPG_SourceFiles_PageClosedFromButtonNext( SymbianWizardLib.Engine.SymWizardPageTransitionEvent aEventArgs )
       
    78         {
       
    79             if ( iPG_SourceFiles_FileList.FileCount == 0 )
       
    80             {
       
    81                 aEventArgs.SuggestedNewPage = aEventArgs.CurrentPage;
       
    82             }
       
    83             else
       
    84             {
       
    85                 List<string> files = iPG_SourceFiles_FileList.FileNames;
       
    86                 iEngine.PrimeSources( files.ToArray() );
       
    87 
       
    88                 // Save settings
       
    89                 iEngine.Settings.Save( "CrashFileWizard_SourceFiles", iPG_SourceFiles_FileList );
       
    90             }
       
    91         }
       
    92         #endregion
       
    93 
       
    94         #region Page - debug engine
       
    95         private void iPG_DebugEngine_Load( object aSender, EventArgs aArgs )
       
    96         {
       
    97             iPG_DebugEngine_Control.Engine = iEngine.DebugEngine;
       
    98         }
       
    99 
       
   100         private void iPG_DebugEngine_PageClosedFromButtonNext( SymbianWizardLib.Engine.SymWizardPageTransitionEvent aEventArgs )
       
   101         {
       
   102             string errorText = string.Empty;
       
   103             bool isReady = iPG_DebugEngine_Control.IsReadyToPrime( out errorText );
       
   104             if ( isReady )
       
   105             {
       
   106                 // Store the settings at this point as we are largely past the
       
   107                 // initial configuration
       
   108                 iEngine.Settings.Store();
       
   109 
       
   110                 // Also save debug engine configuration
       
   111                 iPG_DebugEngine_Control.XmlSettingsSave();
       
   112 
       
   113                 // Begin priming
       
   114                 iPG_DebugEngine_Control.Prime();
       
   115             }
       
   116             else
       
   117             {
       
   118                 MessageBox.Show( errorText, "Error" );
       
   119                 aEventArgs.SuggestedNewPage = aEventArgs.CurrentPage;
       
   120             }
       
   121         }
       
   122         #endregion
       
   123 
       
   124         #region Page - processing summary
       
   125         private void iPG_Processing_Load( object aSender, EventArgs aArgs )
       
   126         {
       
   127             // Observe crash item engine events
       
   128             iPG_Processing_CrashList.Engine = iEngine.CrashItemEngine;
       
   129             iEngine.CrashItemEngine.StateChanged += new CrashItemLib.Engine.CIEngine.CIEngineStateHandler( CrashItemEngine_StateHandler );
       
   130         }
       
   131 
       
   132         private void iPG_Processing_Unload( object sender, EventArgs e )
       
   133         {
       
   134             // Triggers event unsubscriptions
       
   135             iPG_Processing_SourceList.Sources = null;
       
   136             iPG_Processing_CrashList.Engine = null;
       
   137             iEngine.CrashItemEngine.StateChanged -= new CrashItemLib.Engine.CIEngine.CIEngineStateHandler( CrashItemEngine_StateHandler );
       
   138         }
       
   139 
       
   140         private void iPG_Processing_PageShownFromButtonNext( SymbianWizardLib.GUI.SymWizardPage aSender )
       
   141         {
       
   142             // Prevent navigation
       
   143             iWizard.ButtonNext.Enabled = false;
       
   144             iWizard.ButtonBack.Enabled = false;
       
   145 
       
   146             // Set up controls to interact with crash engine
       
   147             iPG_Processing_SourceList.Sources = iEngine.CrashItemEngine.Sources;
       
   148             iPG_Processing_CrashList.Engine = iEngine.CrashItemEngine;
       
   149 
       
   150             // Start reading the crash files asynchronously. We'll allow
       
   151             // the user to continue once the "processing complete" event
       
   152             // is signalled.
       
   153             iEngine.IdentifyCrashes( TSynchronicity.EAsynchronous );
       
   154         }
       
   155 
       
   156         private void CrashItemEngine_StateHandler( CrashItemLib.Engine.CIEngine.TState aState )
       
   157         {
       
   158             if ( InvokeRequired )
       
   159             {
       
   160                 CrashItemLib.Engine.CIEngine.CIEngineStateHandler observer = new CrashItemLib.Engine.CIEngine.CIEngineStateHandler( CrashItemEngine_StateHandler );
       
   161                 this.BeginInvoke( observer, new object[] { aState } );
       
   162             }
       
   163             else
       
   164             {
       
   165                 switch ( aState )
       
   166                 {
       
   167                 case CrashItemLib.Engine.CIEngine.TState.EStateProcessingStarted:
       
   168                     break;
       
   169                 case CrashItemLib.Engine.CIEngine.TState.EStateProcessingComplete:
       
   170                     iWizard.ButtonNext.Enabled = true;
       
   171                     iWizard.ButtonBack.Enabled = true;
       
   172                     break;
       
   173                 }
       
   174             }
       
   175         }
       
   176         #endregion
       
   177 
       
   178         #region Internal methods
       
   179         #endregion
       
   180 
       
   181         #region Data members
       
   182         private readonly CAPluginCrashAnalysis iEngine;
       
   183         #endregion
       
   184     }
       
   185 }