Changeset 2706


Ignore:
Timestamp:
5/25/2012 5:01:42 AM (2 years ago)
Author:
lowjoel
Message:

Use a global Singleton for the BlackBoxMainForm? class. This is because we may be reentrant during report uploads. As such, modify the form class to refresh the reports in the reports list view every time the form is loaded.
Also, don't block the user from checking reports after they have been submitted. This behaviour is needed to check for solutions when it is implemented later.

Location:
trunk/eraser/Eraser.BlackBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.BlackBox/BlackBoxClientTool.cs

    r2681 r2706  
    5656        private void OnToolClicked(object sender, EventArgs e) 
    5757        { 
    58             BlackBoxMainForm form = new BlackBoxMainForm(); 
     58            BlackBoxMainForm form = BlackBoxMainForm.Get(); 
    5959 
    6060            Form owner = null; 
  • trunk/eraser/Eraser.BlackBox/BlackBoxMainForm.Designer.cs

    r2683 r2706  
    5959            this.ReportsLvTimestampColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 
    6060            this.ReportsLvErrorColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 
     61            this.ReportsLvStatusColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 
    6162            this.ReportsMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 
    6263            this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    6364            this.DataCollectionPolicyLbl = new System.Windows.Forms.LinkLabel(); 
    64             this.ReportsLvStatusColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 
    6565            ((System.ComponentModel.ISupportInitialize)(this.BlackBoxPic)).BeginInit(); 
    6666            this.ReportsMenuStrip.SuspendLayout(); 
     
    119119            resources.ApplyResources(this.ReportsLvErrorColumn, "ReportsLvErrorColumn"); 
    120120            //  
     121            // ReportsLvStatusColumn 
     122            //  
     123            resources.ApplyResources(this.ReportsLvStatusColumn, "ReportsLvStatusColumn"); 
     124            //  
    121125            // ReportsMenuStrip 
    122126            //  
     
    140144            this.DataCollectionPolicyLbl.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.DataCollectionPolicyLbl_LinkClicked); 
    141145            //  
    142             // ReportsLvStatusColumn 
    143             //  
    144             resources.ApplyResources(this.ReportsLvStatusColumn, "ReportsLvStatusColumn"); 
    145             //  
    146146            // BlackBoxMainForm 
    147147            //  
     
    161161            this.Name = "BlackBoxMainForm"; 
    162162            this.ShowInTaskbar = false; 
     163            this.Load += new System.EventHandler(this.BlackBoxMainForm_Load); 
     164            this.Shown += new System.EventHandler(this.BlackBoxMainForm_Shown); 
    163165            ((System.ComponentModel.ISupportInitialize)(this.BlackBoxPic)).EndInit(); 
    164166            this.ReportsMenuStrip.ResumeLayout(false); 
  • trunk/eraser/Eraser.BlackBox/BlackBoxMainForm.cs

    r2704 r2706  
    3737    public partial class BlackBoxMainForm : Form 
    3838    { 
    39         public BlackBoxMainForm() 
     39        #region Singleton instance 
     40        public static BlackBoxMainForm Get() 
     41        { 
     42            if (Instance == null) 
     43                Instance = new BlackBoxMainForm(); 
     44            return Instance; 
     45        } 
     46 
     47        private static BlackBoxMainForm Instance; 
     48        #endregion 
     49 
     50        private BlackBoxMainForm() 
    4051        { 
    4152            InitializeComponent(); 
    4253            Theming.ApplyTheme(this); 
    43  
    44             ReportsLv.BeginUpdate(); 
    45             foreach (BlackBoxReport report in BlackBox.GetDumps()) 
    46             { 
    47                 ListViewItem item = ReportsLv.Items.Add(report.Timestamp.ToString( 
    48                     "g", CultureInfo.CurrentCulture)); 
    49                 if (report.StackTrace.Count != 0) 
    50                     item.SubItems.Add(report.StackTrace[0].ExceptionType); 
    51                 else 
    52                     item.SubItems.Add(string.Empty); 
    53                 item.SubItems.Add(report.Submitted ? 
    54                     S._("Submitted (Report ID {0})", report.ID) : 
    55                     S._("Not submitted")); 
    56                 item.Tag = report; 
    57                 item.Checked = !report.Submitted; 
    58             } 
    59             ReportsLv.EndUpdate(); 
    6054        } 
    6155 
    62         private void ReportsLv_ItemCheck(object sender, ItemCheckEventArgs e) 
     56        private void BlackBoxMainForm_Load(object sender, EventArgs e) 
    6357        { 
    64             BlackBoxReport report = ((BlackBoxReport)ReportsLv.Items[e.Index].Tag); 
    65             if (e.NewValue == CheckState.Checked && report.Submitted) 
    66                 e.NewValue = CheckState.Unchecked; 
     58            RefreshReports(); 
    6759        } 
    6860 
     
    129121        } 
    130122 
     123        private void RefreshReports() 
     124        { 
     125            ReportsLv.BeginUpdate(); 
     126            ReportsLv.Items.Clear(); 
     127            foreach (BlackBoxReport report in BlackBox.GetDumps()) 
     128            { 
     129                ListViewItem item = ReportsLv.Items.Add(report.Timestamp.ToString( 
     130                    "g", CultureInfo.CurrentCulture)); 
     131                if (report.StackTrace.Count != 0) 
     132                    item.SubItems.Add(report.StackTrace[0].ExceptionType); 
     133                else 
     134                    item.SubItems.Add(string.Empty); 
     135                item.SubItems.Add(report.Submitted ? 
     136                    S._("Submitted (Report ID {0})", report.ID) : 
     137                    S._("Not submitted")); 
     138                item.Tag = report; 
     139                item.Checked = true; 
     140            } 
     141            ReportsLv.EndUpdate(); 
     142        } 
     143 
    131144        /// <summary> 
    132145        /// The global BlackBox instance. 
  • trunk/eraser/Eraser.BlackBox/BlackBoxMainForm.resx

    r2683 r2706  
    18991899    <value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    19001900  </data> 
     1901  <data name="&gt;&gt;ReportsLvStatusColumn.Name" xml:space="preserve"> 
     1902    <value>ReportsLvStatusColumn</value> 
     1903  </data> 
     1904  <data name="&gt;&gt;ReportsLvStatusColumn.Type" xml:space="preserve"> 
     1905    <value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
     1906  </data> 
    19011907  <data name="&gt;&gt;deleteToolStripMenuItem.Name" xml:space="preserve"> 
    19021908    <value>deleteToolStripMenuItem</value> 
     
    19051911    <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    19061912  </data> 
    1907   <data name="&gt;&gt;ReportsLvStatusColumn.Name" xml:space="preserve"> 
    1908     <value>ReportsLvStatusColumn</value> 
    1909   </data> 
    1910   <data name="&gt;&gt;ReportsLvStatusColumn.Type" xml:space="preserve"> 
    1911     <value>System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    1912   </data> 
    19131913  <data name="&gt;&gt;$this.Name" xml:space="preserve"> 
    19141914    <value>BlackBoxMainForm</value> 
  • trunk/eraser/Eraser.BlackBox/BlackBoxNotifier.cs

    r2681 r2706  
    9797        private void OnClick(object sender, EventArgs e) 
    9898        { 
    99             BlackBoxMainForm form = new BlackBoxMainForm(); 
     99            BlackBoxMainForm form = BlackBoxMainForm.Get(); 
    100100            Form owner = null; 
    101101            if (Application.OpenForms.Count > 0) 
Note: See TracChangeset for help on using the changeset viewer.