crashanalysercmd/UI/Plugins/CAPluginCrashAnalyserUi/Tabs/CATabCrashContainerSummary.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.Drawing;
       
    22 using System.Data;
       
    23 using System.Text;
       
    24 using System.Windows.Forms;
       
    25 using CrashItemLib.Crash.Container;
       
    26 using CrashItemLib.Crash.Source;
       
    27 using CrashItemLib.Crash.Summarisable;
       
    28 using XPTable.Models;
       
    29 using CAPCrashAnalysis.Plugin;
       
    30 
       
    31 namespace CAPluginCrashAnalysisUi.Tabs
       
    32 {
       
    33     internal partial class CATabCrashContainerSummary : CATabCrashBase
       
    34     {
       
    35         #region Constructors
       
    36         public CATabCrashContainerSummary( CAPluginCrashAnalysis aSubEngine )
       
    37             : base( aSubEngine )
       
    38         {
       
    39             InitializeComponent();
       
    40         }
       
    41         #endregion
       
    42 
       
    43         #region Event handlers
       
    44         private void CASubControlCrashSummary_Load( object sender, EventArgs e )
       
    45         {
       
    46             UpdateTable();
       
    47             UpdateButtons();
       
    48         }
       
    49 
       
    50         private void iBT_Open_Click( object sender, EventArgs e )
       
    51         {
       
    52             if ( iTable.SelectedIndicies.Length > 0 )
       
    53             {
       
    54                 int index = iTable.SelectedIndicies[ 0 ];
       
    55                 CIContainer container = (CIContainer) iTableModel.Rows[ index ].Tag;
       
    56                 //
       
    57                 CATabCrashContainerExplorer control = new CATabCrashContainerExplorer( SubEngine, container );
       
    58                 base.UIManager.UIManagerContentAdd( control );
       
    59             }
       
    60         }
       
    61 
       
    62         private void iBT_Open_All_Click( object sender, EventArgs e )
       
    63         {
       
    64             foreach ( CIContainer container in base.CrashItemEngine )
       
    65             {
       
    66                 CATabCrashContainerExplorer control = new CATabCrashContainerExplorer( SubEngine, container );
       
    67                 base.UIManager.UIManagerContentAdd( control );
       
    68             }
       
    69         }
       
    70 
       
    71         private void iBT_Close_Click( object sender, EventArgs e )
       
    72         {
       
    73             base.UIManager.UIManagerContentClose( this );
       
    74         }
       
    75 
       
    76         private void iTable_SelectionChanged( object sender, XPTable.Events.SelectionEventArgs e )
       
    77         {
       
    78             UpdateButtons();
       
    79         }
       
    80         #endregion
       
    81 
       
    82         #region Internal methods
       
    83         private void UpdateTable()
       
    84         {
       
    85             iTable.BeginUpdate();
       
    86             iTableModel.Rows.Clear();
       
    87 
       
    88             foreach ( CIContainer item in base.CrashItemEngine )
       
    89             {
       
    90                 CISourceElement source = item.Source;
       
    91 
       
    92                 // Main row
       
    93                 Row row = new Row();
       
    94                 row.Tag = item;
       
    95 
       
    96                 // Cell: crash source file name
       
    97                 Cell cFile = new Cell( source.MasterFileName );
       
    98                 cFile.ForeColor = Color.Blue;
       
    99                 cFile.ColSpan = iColModel.Columns.Count;
       
   100                 cFile.Font = new Font( iTable.Font, FontStyle.Bold );
       
   101                 row.Cells.Add( cFile );
       
   102                 iTableModel.Rows.Add( row );
       
   103 
       
   104                 // Sub-row
       
   105                 int index = 1;
       
   106                 int numberOfNonCrashingThreads = 0;
       
   107                 CISummarisableEntityList list = item.Summaries;
       
   108                 foreach ( CISummarisableEntity entity in list )
       
   109                 {
       
   110                     if ( entity.IsAbnormalTermination )
       
   111                     {
       
   112                         Row subRow = new Row();
       
   113                         subRow.Tag = item; 
       
   114 
       
   115                         // Spacer
       
   116                         subRow.Cells.Add( new Cell() );
       
   117 
       
   118                         // Sub-cell: line number of crash item within source file
       
   119                         Cell scLineNumber = new Cell( index.ToString() );
       
   120                         if ( source.IsLineNumberAvailable )
       
   121                         {
       
   122                             scLineNumber.Text = source.LineNumber.ToString();
       
   123                         }
       
   124                         subRow.Cells.Add( scLineNumber );
       
   125                         ++index;
       
   126 
       
   127                         // Sub-cell: summary name (thread/stack name)
       
   128                         Cell scThreadName = new Cell( entity.Name );
       
   129                         subRow.Cells.Add( scThreadName );
       
   130 
       
   131                         // Sub-cell: summary exit info (for threads)
       
   132                         if ( entity.IsAvailable( CISummarisableEntity.TElement.EElementThread ) )
       
   133                         {
       
   134                             Cell scThreadExitInfo = new Cell( entity.Thread.ExitInfo.ToString() );
       
   135                             subRow.Cells.Add( scThreadExitInfo );
       
   136                         }
       
   137 
       
   138                         // Save subrow as a child of main row. *MUST* do this 
       
   139                         // after adding row to table model.
       
   140                         row.SubRows.Add( subRow );
       
   141                     }
       
   142                     else
       
   143                     {
       
   144                         ++numberOfNonCrashingThreads;
       
   145                     }
       
   146                 }
       
   147 
       
   148                 // If we saw other (non-crashed) threads, also include a count
       
   149                 if ( numberOfNonCrashingThreads > 0 )
       
   150                 {
       
   151                     Row subRow = new Row();
       
   152                     subRow.Tag = item; 
       
   153 
       
   154                     // Spacer
       
   155                     subRow.Cells.Add( new Cell() );
       
   156 
       
   157                     // Our text
       
   158                     string numberOfNonCrashingThreadsText = string.Format( "...plus {0} more running thread{1}", numberOfNonCrashingThreads, numberOfNonCrashingThreads != 1 ? "s" : string.Empty );
       
   159                     Cell cell = new Cell( numberOfNonCrashingThreadsText );
       
   160                     subRow.Cells.Add( cell );
       
   161 
       
   162                     // Spacer
       
   163                     subRow.Cells.Add( new Cell() );
       
   164 
       
   165                     // Spacer
       
   166                     subRow.Cells.Add( new Cell() );
       
   167                 }
       
   168             }
       
   169 
       
   170             iTable.EndUpdate();
       
   171         }
       
   172 
       
   173         private void UpdateButtons()
       
   174         {
       
   175             iBT_Open.Enabled = ( iTable.TableModel.Selections.SelectedIndicies.Length > 0 );
       
   176             iBT_Open_All.Enabled = ( iTable.TableModel.Rows.Count > 0 );
       
   177         }
       
   178         #endregion
       
   179 
       
   180         #region Data members
       
   181         #endregion
       
   182     }
       
   183 }