Package: ValidationTable

ValidationTable

nameinstructionbranchcomplexitylinemethod
ValidationTable(Composite)
M: 134 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
parseValidationFile(Reader)
M: 306 C: 0
0%
M: 62 C: 0
0%
M: 32 C: 0
0%
M: 87 C: 0
0%
M: 1 C: 0
0%
setCallback(IViewCallback)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
unlink(IViewCallback)
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * RT Trace Viewer Plugin
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.plugins.rttraceviewer.view;
23:
24: import java.io.IOException;
25: import java.io.Reader;
26: import java.io.StreamTokenizer;
27:
28: import org.eclipse.swt.SWT;
29: import org.eclipse.swt.events.SelectionAdapter;
30: import org.eclipse.swt.events.SelectionEvent;
31: import org.eclipse.swt.widgets.Composite;
32: import org.eclipse.swt.widgets.Table;
33: import org.eclipse.swt.widgets.TableColumn;
34: import org.eclipse.swt.widgets.TableItem;
35: import org.overture.ide.plugins.rttraceviewer.TracefileViewerPlugin;
36:
37: public class ValidationTable
38: {
39:         private Table theTable;
40:         private IViewCallback theViewer;
41:         
42:         final String STATUS_FAILED = "F";
43:         final String STATUS_PASSED = "P";
44:         
45:         final int COLUMN_INTERNAL_STATUS = 7;
46:
47:         public ValidationTable(Composite theComposite)
48:         {
49:                 theTable = null;
50:                 theViewer = null;
51:
52:                 theTable = new Table(theComposite, 0x10804);
53:                 theTable.setHeaderVisible(true);
54:                 theTable.setLinesVisible(true);
55:                 theTable.addSelectionListener(new SelectionAdapter()
56:                 {
57:
58:                         @Override
59:                         public void widgetSelected(SelectionEvent event)
60:                         {
61:                                 int current = theTable.getSelectionIndex();
62:                                 if (current != -1)
63:                                 {
64:                                         if (current != prev)
65:                                                 prev = -1;
66:                                         TableItem selection = theTable.getItem(current);
67:                                         if (selection.getText(COLUMN_INTERNAL_STATUS).equals(STATUS_FAILED))
68:                                         {
69:                                                 String time;
70:                                                 String thrid;
71:                                                 if (prev == -1)
72:                                                 {
73:                                                         time = selection.getText(3);
74:                                                         thrid = selection.getText(4);
75:                                                         prev = current;
76:                                                 } else
77:                                                 {
78:                                                         time = selection.getText(5);
79:                                                         thrid = selection.getText(6);
80:                                                         prev = -1;
81:                                                 }
82:                                                 theViewer.panToTime(Long.parseLong(time), Long.parseLong(thrid));
83:                                         } else
84:                                         {
85:                                                 prev = -1;
86:                                         }
87:                                 }
88:                         }
89:
90:                         private int prev;
91:                         // final ValidationTable this$0;
92:                         //
93:                         //
94:                         // {
95:                         // this$0 = ValidationTable.this;
96:                         // super();
97:                         // prev = -1;
98:                         // }
99:                 });
100:                 TableColumn col1 = new TableColumn(theTable, 0);
101:                 col1.setText("status");
102:                 col1.pack();
103:                 TableColumn col2 = new TableColumn(theTable, 0);
104:                 col2.setText("name");
105:                 col2.pack();
106:                 TableColumn col3 = new TableColumn(theTable, 0);
107:                 col3.setText("expression");
108:                 col3.pack();
109:                 TableColumn col4 = new TableColumn(theTable, 0);
110:                 col4.setText("src time");
111:                 col4.pack();
112:                 TableColumn col5 = new TableColumn(theTable, 0);
113:                 col5.setText("src thread");
114:                 col5.pack();
115:                 TableColumn col6 = new TableColumn(theTable, 0);
116:                 col6.setText("dest time");
117:                 col6.pack();
118:                 TableColumn col7 = new TableColumn(theTable, 0);
119:                 col7.setText("dest thread");
120:                 col7.pack();
121:                 TableColumn col8 = new TableColumn(theTable, SWT.Hide);
122:                 col8.setText("Internal status");
123: //                col8.
124:                 return;
125:         }
126:         
127:         public void setCallback(IViewCallback callback)
128:         {
129:                 this.theViewer = callback;
130:         }
131:
132:         public void parseValidationFile(Reader reader)
133:         {
134:                 boolean abort = false;
135:                 char qchar = '"';
136:                 String vrname = "";
137:                 Long sthrid = null;
138:                 Long stime = null;
139:                 Long dthrid = null;
140:                 Long dtime = null;
141:                 theTable.removeAll();
142:                 TableItem theItem = null;
143:                 int cnt = 1;
144:•                if (reader != null)
145:                 {
146:                         try
147:                         {
148:                                 StreamTokenizer tokens = new StreamTokenizer(reader);
149:                                 tokens.eolIsSignificant(true);
150:                                 tokens.quoteChar(qchar);
151:                                 tokens.parseNumbers();
152:•                                while (tokens.nextToken() != StreamTokenizer.TT_EOF && !abort)
153:                                 {
154:•                                        if (cnt != 1 || tokens.ttype != StreamTokenizer.TT_EOL)
155:                                         {
156:•                                                if (cnt == 1 && tokens.ttype == qchar)
157:                                                 {
158:                                                         vrname = new String(tokens.sval);
159:                                                         theItem = new TableItem(theTable, 0);
160:                                                         theItem.setText(cnt, tokens.sval);
161:                                                         cnt++;
162:•                                                } else if (cnt == 2 && tokens.ttype == qchar)
163:                                                 {
164:                                                         new String(tokens.sval);
165:                                                         theItem.setText(cnt, tokens.sval);
166:                                                         cnt++;
167:•                                                } else if (cnt == 3
168:•                                                                && tokens.ttype == StreamTokenizer.TT_NUMBER)
169:                                                 {
170:                                                         stime = new Long(Math.round(tokens.nval));
171:                                                         theItem.setText(cnt, stime.toString());
172: //                                                        theItem.setBackground(0, ColorConstants.red);
173: //                                                        theItem.setForeground(0, ColorConstants.white);
174:                                                         theItem.setText(COLUMN_INTERNAL_STATUS,STATUS_FAILED);
175:                                                         theItem.setImage(TracefileViewerPlugin.getImageDescriptor("icons/faild_obj.png").createImage());
176:                                                         cnt++;
177:•                                                } else if (cnt == 3
178:•                                                                && tokens.ttype == StreamTokenizer.TT_WORD)
179:                                                 {
180:                                                         stime = null;
181:                                                         theItem.setText(COLUMN_INTERNAL_STATUS, STATUS_PASSED);
182: //                                                        theItem.setBackground(0, ColorConstants.green);
183:                                                         theItem.setImage(TracefileViewerPlugin.getImageDescriptor("icons/succes_obj.png").createImage());
184:                                                         cnt++;
185:•                                                } else if (cnt == 4
186:•                                                                && tokens.ttype == StreamTokenizer.TT_EOL)
187:                                                         cnt = 1;
188:•                                                else if (cnt == 4
189:•                                                                && tokens.ttype == StreamTokenizer.TT_NUMBER)
190:                                                 {
191:                                                         sthrid = new Long(Math.round(tokens.nval));
192:                                                         theItem.setText(cnt, sthrid.toString());
193:                                                         theViewer.addLowerError(stime, sthrid, vrname);
194:                                                         cnt++;
195:•                                                } else if (cnt == 4
196:•                                                                && tokens.ttype == StreamTokenizer.TT_WORD)
197:                                                 {
198:                                                         stime = null;
199:                                                         cnt++;
200:•                                                } else if (cnt == 5
201:•                                                                && tokens.ttype == StreamTokenizer.TT_NUMBER)
202:                                                 {
203:                                                         dtime = new Long(Math.round(tokens.nval));
204:                                                         theItem.setText(cnt, dtime.toString());
205:                                                         cnt++;
206:•                                                } else if (cnt == 5
207:•                                                                && tokens.ttype == StreamTokenizer.TT_WORD)
208:                                                 {
209:                                                         dtime = null;
210:                                                         cnt++;
211:•                                                } else if (cnt == 6
212:•                                                                && tokens.ttype == StreamTokenizer.TT_NUMBER)
213:                                                 {
214:                                                         dthrid = new Long(Math.round(tokens.nval));
215:                                                         theItem.setText(cnt, dthrid.toString());
216:                                                         theViewer.addUpperError(dtime, dthrid, vrname);
217:                                                         cnt++;
218:•                                                } else if (cnt == 6
219:•                                                                && tokens.ttype == StreamTokenizer.TT_WORD)
220:                                                 {
221:                                                         dthrid = null;
222:                                                         cnt++;
223:•                                                } else if (cnt == 7
224:•                                                                && tokens.ttype == StreamTokenizer.TT_EOL)
225:                                                 {
226:                                                         stime = null;
227:                                                         sthrid = null;
228:                                                         dtime = null;
229:                                                         dthrid = null;
230:                                                         cnt = 1;
231:                                                 } else
232:                                                 {
233:                                                         abort = true;
234:                                                 }
235:                                         }
236:                                 }
237:•                                if (abort)
238:                                 {
239:                                         theViewer.showMessage("syntax error in validation conjecture file");
240:                                 }
241:                         } catch (IOException ioe)
242:                         {
243:                                 ioe.printStackTrace();
244:                         }
245:                 }
246:•                for (cnt = 0; cnt < 6; cnt++)
247:                 {
248:                         theTable.getColumn(cnt).pack();
249:                 }
250:
251:                 // MVQ; This is called from
252:                 // theViewer.updateOverviewPage();
253:         }
254:
255:         public void unlink(IViewCallback theCallback)
256:         {
257:•                if(theViewer==theCallback)
258:                 {
259:                 theTable.clearAll();
260:                 theViewer = null;
261:         }}
262:
263: }