0:   //  OpenTaskView.cs
1:   //  Copyright (C) 2000 Mike Krueger
2:   //
3:   //  This program is free software; you can redistribute it and/or modify
4:   //  it under the terms of the GNU General Public License as published by
5:   //  the Free Software Foundation; either version 2 of the License, or
6:   //  (at your option) any later version.
7:   //
8:   //  This program is distributed in the hope that it will be useful,
9:   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10:   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11:   //  GNU General Public License for more details.
12:   //
13:   //  You should have received a copy of the GNU General Public License
14:   //  along with this program; if not, write to the Free Software
15:   //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16:  
17:   using System;
18:   using System.Windows.Forms;
19:   using System.Drawing;
20:   using System.CodeDom.Compiler;
21:   using System.Collections;
22:   using System.IO;
23:   using System.Diagnostics;
24:  
25:   using SharpDevelop.Tool.Data;
26:   using SharpDevelop.Tool.Function;
27:  
28:  
29:   namespace SharpDevelop.Gui.Navigation {
30:       
31:       /// <summary>
32:       /// This class displays the errors and warnings which the compiler outputs and
33:       /// allows the user to jump to the source of the warnig / error
34:       /// </summary>
35:       public class CompilerResultListItem : ListViewItem
36:       {
37:           Point pos;
38:           string filename;
39:           
40:           public CompilerResultListItem(Point posString filenamestring[] rowItemsbase(rowItems)
41:           {
42:               this.pos      pos;
43:               this.filename filename;
44:           }
45:           public string FileName {
46:               get {
47:                   return filename;
48:               }
49:           }
50:           public Point Pos {
51:               get {
52:                   return pos;
53:               }
54:           }
55:       }
56:       
57:       public class OpenTaskView : ListView
58:       {
59:           ColumnHeader type        new ColumnHeader();
60:           ColumnHeader line        new ColumnHeader();
61:           ColumnHeader description new ColumnHeader();
62:           ColumnHeader file        new ColumnHeader();
63:           int errors   0;
64:           int warnings 0;
65:           
66:           /// <summary>
67:           /// returns the number of errors in the last compilation
68:           /// </summary>
69:           public int Errors {
70:               get {
71:                   return errors;
72:               }
73:           }
74:           
75:           /// <summary>
76:           /// returns the number of warnings in the last compilation
77:           /// </summary>
78:           public int Warnings {
79:               get {
80:                   return warnings;
81:               }
82:           }
83:           
84:           ArrayList tc new ArrayList();
85:           
86:           class TagClass {
87:               public string FileName;
88:               public string Comment;
89:               public int    Line;
90:               public string ProjectRoot;
91:               public string Tagname;
92:               
93:               public TagClass(string filestring tagnamestring commentstring projectRootint line)
94:               {
95:                   Tagname tagname;
96:                   FileName file;
97:                   Comment comment;
98:                   Line line;
99:                   ProjectRoot projectRoot;
100:               }
101:           }
102:           
103:           public void ClearTags()
104:           {
105:               tc.Clear();
106:           }
107:           
108:           public void AddTag(string filestring tagnamestring commentstring projectRootint line)
109:           {
110:               tc.Add(new TagClass(filetagnamecommentprojectRootline));
111:           }
112:           
113:           public OpenTaskView()
114:           {
115:               type.Text "!";
116:               
117:               line.Text        Resource.GetString("CompilerResultView.LineText");
118:               description.Text Resource.GetString("CompilerResultView.DescriptionText");
119:               file.Text        Resource.GetString("CompilerResultView.FileText");
120:               
121:               Columns.Add(type);
122:               Columns.Add(line);
123:               Columns.Add(description);
124:               Columns.Add(file);
125:               
126:               FullRowSelect true;
127:               AutoArrange true;
128:               Alignment   ListViewAlignment.Left;
129:               View View.Details;
130:               Dock DockStyle.Fill;
131:               GridLines  true;
132:               Activation ItemActivation.OneClick;
133:               OnResize(null);
134:           }
135:           
136:           protected override void OnResize(EventArgs e)
137:           {
138:               type.Width 20;
139:               line.Width 50;
140:               int Width type.Width line.Width;
141:               file.Width 20 100;
142:               description.Width file.Width 5;
143:               base.OnResize(e);
144:           }
145:           
146:           public CompilerResults CompilerResults null;
147:           
148:           public void ShowResults(CompilerResults resstring projectroot)
149:           {
150:               Debug.Assert(res != null,         "SharpDevelop.Gui.Navigation.CompilerResultView : ShowResults : parameter CompilerResults res == null");
151:               Debug.Assert(projectroot != null"SharpDevelop.Gui.Navigation.CompilerResultView : ShowResults : parameter CompilerResults projectroot == null");
152:               this.CompilerResults res;
153:               errors   0;
154:               warnings 0;
155:               BeginUpdate();
156:               Items.Clear();
157:               foreach (CompilerError err in res.Errors) {
158:                   if (err.IsWarning)
159:                       ++warnings;
160:                   else
161:                       ++errors;
162:                   string tmpPath =FileUtility.AbsoluteToRelativePath(projectrooterr.FileName);
163:                   if (tmpPath.Length >= 2) {
164:                       tmpPath tmpPath.Substring(2);
165:                   }
166:                   ListViewItem item new CompilerResultListItem(
167:                       new Point(err.Column 1err.Line 1),
168:                       err.FileName
169:                       new string [] {
170:                           err.IsWarning "W" "E",
171:                           err.Line.ToString(),
172:                           err.ErrorText "(" err.ErrorNumber ")",
173:                           tmpPath
174:                       }
175:                   );
176:                   Items.Add(item);
177:               }
178:                           
179:               EndUpdate();
180:               ShowTags();
181:           }
182:           
183:           public void ShowTags()
184:           {
185:               BeginUpdate();
186:               foreach (TagClass tag in tc) {
187:                   
188:                   string tmpPath FileUtility.AbsoluteToRelativePath(tag.ProjectRoottag.FileName);
189:                   if (tmpPath.Length >= 2) {
190:                       tmpPath tmpPath.Substring(2);
191:                   }
192:                   ListViewItem item new CompilerResultListItem(
193:                       new Point(0tag.Line),
194:                       tag.FileName
195:                       new string [] {
196:                           "C",
197:                           tag.Line.ToString(),
198:                           tag.Tagname " : " tag.Comment,
199:                           tmpPath
200:                       }
201:                   );
202:                   Items.Add(item);
203:               }
204:               EndUpdate();
205:           }
206:       }
207:   }

This page was automatically generated by SharpDevelop.