/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_metric_details_cmd.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_metric_details_cmd.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62171 - (show annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 4 months ago) by larryl
File size: 17941 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Command to display detailed metric calculation%N%
3 %for subclusters of current."
4 legal: "See notice at end of class."
5 status: "See notice at end of class."
6 author: "Tanit Talbi"
7 date: "$Date$"
8 revision: "$Revision$"
9
10 class
11 EB_METRIC_DETAILS_CMD
12
13 inherit
14 EB_METRIC_COMMAND
15 redefine
16 new_toolbar_item
17 end
18
19 EB_CONSTANTS
20
21 SHARED_WORKBENCH
22
23 EB_METRIC_SCOPE_INFO
24
25 create
26 make
27
28 feature -- Initialization
29
30 new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is
31 -- Create a new toolbar button for this command.
32 do
33 Result := Precursor (display_text)
34 current_button := Result
35 end
36
37 execute is
38 -- Show details for sub element of selected scope for last calculated measure.
39 do
40 on_details_click
41 end
42
43 pixmap: EV_PIXMAP is
44 -- Pixmaps representing the command.
45 do
46 Result := Pixmaps.Icon_view_measure_plus
47 end
48
49 pixel_buffer: EV_PIXEL_BUFFER is
50 -- Pixel buffer representing the command.
51 do
52 -- Currently there is no pixel buffer for this command.
53 end
54
55 tooltip: STRING is
56 -- Tooltip for the toolbar button.
57 do
58 if tool.details_hidden then
59 Result := "Show details for requested metric"
60 else
61 Result := "Hide details for requested metric"
62 end
63 end
64
65 description: STRING is
66 -- Description for this command.
67 do
68 Result := "Details metrics"
69 end
70
71 name: STRING is "details"
72 -- Name of the command. Used to store the command in the
73 -- preferences.
74
75 feature -- Level in hierarchy
76
77 depth_of_cluster (a_cluster: CLUSTER_I): INTEGER is
78 -- Number of cluster levels in `a_cluster' hierarchy.
79 require
80 existing_clster: a_cluster /= Void
81 local
82 depth: INTEGER
83 do
84 if a_cluster.sub_clusters.is_empty then
85 Result := 0
86 else
87 from
88 a_cluster.sub_clusters.start
89 until
90 a_cluster.sub_clusters.after
91 loop
92 depth := 1 + depth_of_cluster (a_cluster.sub_clusters.item)
93 if depth > Result then
94 Result := depth
95 end
96 a_cluster.sub_clusters.forth
97 end
98 end
99 end
100
101 depth_of_system: INTEGER is
102 -- Number of cluster levels in system hierarchy.
103 require
104 system_set: universe /= Void
105 local
106 -- depth: INTEGER
107 do
108 conf_todo
109 -- from
110 -- universe.clusters.start
111 -- until
112 -- universe.clusters.after
113 -- loop
114 -- depth := depth_of_cluster (universe.clusters.item)
115 -- if depth > Result then
116 -- Result := depth
117 -- end
118 -- universe.clusters.forth
119 -- end
120 end
121
122 feature -- Detailed column list
123
124 multi_column_list_for_details: EV_MULTI_COLUMN_LIST
125 -- Column list to display details of a metric result.
126
127 title_array_for_details (cluster_depth: INTEGER): ARRAY [STRING] is
128 -- `multi_column_list_for_details' titles.
129 require
130 existing_tool: tool /= Void
131 effective_metric: metric /= Void
132 local
133 array_depth, i: INTEGER
134 do
135 if metric.min_scope >= Cluster_scope then
136 array_depth := cluster_depth + 2
137 else
138 array_depth := cluster_depth + 4
139 end
140 create Result.make (1, array_depth)
141 Result.put ("Name", 1)
142 from
143 i := 2
144 until
145 i = cluster_depth + 3
146 loop
147 Result.put ("Subcluster", i)
148 i := i + 1
149 end
150 if equal (metric.name, interface_names.metric_classes) then
151 Result.put ("Compiled classes", array_depth)
152 elseif equal (metric.name, interface_names.metric_clusters) then
153 Result.put ("Clusters", array_depth)
154 else
155 Result.put ("Class name", array_depth - 2)
156 Result.put ("Metric", array_depth - 1)
157 Result.put ("Result", array_depth)
158 end
159 ensure
160 min_titles: Result.count >= 2
161 end
162
163 show_details_of_cluster (a_cluster: CLUSTER_I; depth, starting_index, index_column_insert: INTEGER) is
164 -- Build a column list to display details of a metric for a picked and dropped cluster.
165 -- `depth' is `a_cluster' depth in terms of sub-clusters.
166 -- `starting_index' is the line we start to insert details of `a_cluster'. Indeed, there
167 -- are possibly other clusters that have been detailed before `a_cluster' and we should not overwrite them.
168 -- `index_column_insert' is the index of column we start detailing.
169 require
170 calculation: tool.is_calculation_done
171 effective_cluster: a_cluster /= Void
172 positive_indexes: depth >= 0 and starting_index >= 0 and index_column_insert >= 0
173 correct_column_insert: index_column_insert >= 1 and index_column_insert < multi_column_list_for_details.column_count
174 local
175 insert_index, current_depth, column_insert: INTEGER
176 sub_clusters: ARRAYED_LIST [CLUSTER_I]
177 a_class_scope: EB_METRIC_SCOPE
178 a_percentage: BOOLEAN
179 do
180 -- `scope' is either system or cluster.
181 -- For each cluster, details are given per class, which means that
182 -- local scope is class.
183 a_class_scope := tool.scope (interface_names.metric_this_class)
184 -- Insert rows starting from `insert_index'.
185 insert_index := starting_index
186 -- Insert subclusters starting from column `column_insert'.
187 column_insert := index_column_insert
188
189 -- Adjust size of the detailed multi_column_list.
190 if metric.min_scope >= Cluster_scope then
191 current_depth := depth + 2
192 else
193 current_depth := depth + 4
194 end
195
196 a_percentage := metric.percentage
197 detailed_line_of_cluster (a_cluster, current_depth, column_insert, a_percentage)
198
199 -- Build rows for sub clusters of `a_cluster'.
200 insert_index := insert_index + 1
201 if not a_cluster.sub_clusters.is_empty then
202 sub_clusters := a_cluster.sub_clusters
203 column_insert := column_insert + 1
204 from
205 sub_clusters.start
206 until
207 sub_clusters.after
208 loop
209 show_details_of_cluster (sub_clusters.item, depth, insert_index, column_insert)
210 sub_clusters.forth
211 end
212 end
213 insert_index := detailed_lines_of_classes_in_cluster (a_cluster, depth, current_depth, insert_index, a_class_scope, a_percentage)
214 ensure
215 details_displayed: multi_column_list_for_details.count > 0
216 end
217
218 detailed_line_of_cluster (a_cluster: CLUSTER_I; current_depth, column_insert: INTEGER; a_percentage: BOOLEAN) is
219 -- Build detailed row for `a_cluster'
220 require
221 effective_cluster: a_cluster /= Void
222 positive_indexes: current_depth >= 0 and column_insert >= 0
223 correct_column_insert: column_insert >= 1 and column_insert < multi_column_list_for_details.column_count
224 local
225 mean: DOUBLE
226 row_array: ARRAY [STRING_32]
227 row: EV_MULTI_COLUMN_LIST_ROW
228 a_cluster_scope: EB_METRIC_SCOPE
229 i: INTEGER
230 do
231 -- Build row for current cluster with its name and mean over classes.
232 mean := calculate_mean (a_cluster)
233 create row_array.make (1, current_depth)
234 from
235 i := 1
236 until
237 i = column_insert
238 loop
239 row_array.put (" ", i)
240 i := i + 1
241 end
242 row_array.put (a_cluster.cluster_name, column_insert)
243 from
244 i := column_insert + 1
245 until
246 i = current_depth
247 loop
248 row_array.put ("--------------------", i)
249 i := i + 1
250 end
251
252 if metric.min_scope >= Cluster_scope then
253 a_cluster_scope := tool.scope (interface_names.metric_this_cluster)
254 a_cluster_scope.set_cluster_i (a_cluster)
255 row_array.put (tool.fix_decimals_and_percentage (metric.value (a_cluster_scope), a_percentage), current_depth)
256 else
257 if mean >= 0 then
258 row_array.put ("Average: " + tool.fix_decimals_and_percentage (mean, a_percentage), current_depth)
259 else
260 -- Not in system.
261 row_array.put (" ", current_depth)
262 end
263 end
264 create row
265 row.fill (row_array)
266 multi_column_list_for_details.extend (row)
267 ensure
268 add_line: multi_column_list_for_details.count = old multi_column_list_for_details. count + 1
269 end
270
271 detailed_lines_of_classes_in_cluster (a_cluster: CLUSTER_I; depth, current_depth, insert_index: INTEGER; a_class_scope: EB_METRIC_SCOPE; a_percentage: BOOLEAN): INTEGER is
272 -- Build detailed row for classes included in `a_cluster'
273 require
274 effective_cluster: a_cluster /= Void
275 positive_indexes: depth >= 0 and current_depth >= 0 and insert_index >= 0
276 effective_class_scope: a_class_scope /= Void and then a_class_scope.index = Class_scope
277 -- and then a_class_scope.class_c /= Void
278 local
279 classes_in_cluster: HASH_TABLE [CLASS_I, STRING]
280 x_pos, y_pos, i, progress_value: INTEGER
281 row_array: ARRAY [STRING_32]
282 row: EV_MULTI_COLUMN_LIST_ROW
283 a_cursor: CURSOR
284 displayed_result: DOUBLE
285 do
286 -- Build rows for classes of `a_cluster' if needed.
287 if not a_cluster.classes.is_empty
288 and (metric.min_scope < Cluster_scope
289 or equal (tool.selected_metric, interface_names.metric_classes)) then
290
291 classes_in_cluster := a_cluster.classes
292
293 x_pos := tool.development_window.window.x_position + 100
294 y_pos := tool.development_window.window.y_position + 100
295 tool.progress_dialog.set_message ("Retrieving details of cluster: " + a_cluster.cluster_name)
296 tool.progress_dialog.set_entity (interface_names.d_Compilation_class)
297 tool.progress_dialog.set_position (x_pos, y_pos)
298 tool.progress_dialog.start (classes_in_cluster.count)
299 tool.progress_dialog.set_value (0)
300
301 from
302 classes_in_cluster.start
303 until
304 classes_in_cluster.after
305 loop
306 if classes_in_cluster.item_for_iteration.compiled_class /= Void then
307 tool.progress_dialog.set_current_entity (classes_in_cluster.item_for_iteration.name_in_upper)
308 create row_array.make (1, current_depth)
309 from
310 i := 1
311 until
312 i = depth + 3
313 loop
314 row_array.put (" ", i)
315 i := i + 1
316 end
317 row_array.put (classes_in_cluster.item_for_iteration.compiled_class.name_in_upper, depth + 2)
318 if not equal (tool.selected_metric, interface_names.metric_classes) then
319 row_array.put (tool.selected_metric, current_depth - 1)
320 a_cursor := classes_in_cluster.cursor
321 -- When metric is composite, we have to update `scope' since
322 -- used in `value' in EB_METRIC_MEASURE
323 a_class_scope.set_class_c (classes_in_cluster.item_for_iteration.compiled_class)
324 displayed_result := metric.value (a_class_scope)
325 row_array.put (tool.fix_decimals_and_percentage (displayed_result, a_percentage), current_depth)
326 classes_in_cluster.go_to (a_cursor)
327 end
328 create row
329 row.fill (row_array)
330 multi_column_list_for_details.extend (row)
331 progress_value := progress_value + 1
332 tool.progress_dialog.set_value (progress_value)
333 end
334 classes_in_cluster.forth
335 Result := insert_index + classes_in_cluster.count
336 end
337 end
338 end
339
340 calculate_mean (a_cluster: CLUSTER_I): DOUBLE is
341 -- Calculate mean of `metric' (evaluated for `a_cluster') over number of classes
342 -- in `a_cluster'.
343 require
344 effective_tool: tool /= Void
345 effective_cluster: a_cluster /= Void
346 local
347 number_classes: INTEGER
348 a_cluster_scope: EB_METRIC_SCOPE
349 functionality: EB_METRIC_BASIC_FUNCTIONALITIES
350 do
351 create functionality
352 a_cluster_scope := tool.scope (interface_names.metric_this_cluster)
353 a_cluster_scope.set_cluster_i (a_cluster)
354 number_classes := functionality.number_of_classes_in_cluster (a_cluster_scope).truncated_to_integer
355 if number_classes > 0 then
356 -- Update cluster_i since changes in `number_of_classes_in_cluster'.
357 a_cluster_scope.set_cluster_i (a_cluster)
358 Result := metric.value (a_cluster_scope) / number_classes
359 else
360 Result := -1
361 end
362 end
363
364 show_details_of_system (depth: INTEGER) is
365 -- Build a column list to display details of a metric for this system.
366 require
367 positive_depth: depth >= 0
368 local
369 -- index: INTEGER
370 do
371 conf_todo
372 -- from
373 -- universe.clusters.start
374 -- until
375 -- universe.clusters.after
376 -- loop
377 -- if universe.clusters.item.parent_cluster = Void then
378 -- show_details_of_cluster (universe.clusters.item, depth, index, 1)
379 -- index := multi_column_list_for_details.count
380 -- end
381 -- universe.clusters.forth
382 -- end
383 end
384
385 metric: EB_METRIC
386 -- metric details apply to.
387
388 on_details_click is
389 -- Show details for calculated metric.
390 require
391 exixting_tool: tool /= Void
392 local
393 depth: INTEGER
394 selected_cluster: CLUSTER_I
395 retried: BOOLEAN
396 do
397 if not retried then
398 if tool.details_hidden then
399 -- Change details_button's pixmap.
400 current_button.set_pixmap (Pixmaps.Icon_view_measure_minus)
401 -- Disable all buttons.
402 disable_all_components
403 -- Hide unuseful ojects.
404 tool.text_area.hide
405 tool.sep.hide
406 tool.multi_column_list.hide
407 -- Create a multi_column_list for displaying details.
408 create multi_column_list_for_details
409 -- Display a progress dialog while waiting for details calculation.
410 tool.progress_dialog.set_value (1)
411
412 -- Retrieve metric object.
413 metric := tool.metric (tool.selected_metric)
414 check metric /= Void end
415
416 if equal (tool.selected_scope, interface_names.metric_this_cluster) then
417 selected_cluster := tool.selected_cluster
418 depth := depth_of_cluster (selected_cluster)
419 elseif equal (tool.selected_scope, interface_names.metric_this_system) then
420 depth := depth_of_system
421 end
422 multi_column_list_for_details.set_column_titles (title_array_for_details (depth))
423 tool.widget.extend (multi_column_list_for_details)
424 tool.development_window.window.set_pointer_style (tool.development_window.Wait_cursor)
425 if equal (tool.selected_scope, interface_names.metric_this_cluster) then
426 show_details_of_cluster (selected_cluster, depth, 0, 1)
427 elseif equal (tool.selected_scope, interface_names.metric_this_system) then
428 show_details_of_system (depth)
429 end
430 multi_column_list_for_details.align_text_right (multi_column_list_for_details.column_count)
431 tool.development_window.window.set_pointer_style (tool.development_window.Standard_cursor)
432 tool.resize_column_list_to_content (multi_column_list_for_details)
433 tool.set_details_hidden (False)
434 tool.progress_dialog.set_message ("Calculating requested metric(s)...")
435 tool.progress_dialog.set_entity (interface_names.d_Compilation_class)
436 tool.progress_dialog.hide
437 tool.details.enable_sensitive
438 tool.details_cmd_in_menu.enable_sensitive
439 else
440 current_button.set_pixmap (Pixmaps.Icon_view_measure_plus)
441 tool.widget.prune (multi_column_list_for_details)
442 tool.text_area.show
443 tool.sep.show
444 tool.multi_column_list.show
445 enable_all_components
446 tool.set_details_hidden (True)
447 end
448 current_button.set_tooltip (tooltip)
449 end
450 rescue
451 retried := True
452 tool.progress_dialog.set_message ("Calculating requested metric(s)...")
453 tool.progress_dialog.set_entity (interface_names.d_Compilation_class)
454 tool.progress_dialog.hide
455 tool.progress_dialog.enable_cancel
456 tool.details.enable_sensitive
457 tool.details_cmd_in_menu.enable_sensitive
458 tool.set_details_hidden (False)
459 tool.development_window.window.set_pointer_style (tool.development_window.Standard_cursor)
460 retry
461 end
462
463 disable_all_components is
464 -- Disable buttons and menu items during details calculation.
465 do
466 tool.details.disable_sensitive
467 tool.new_metric.disable_sensitive
468 tool.calculate.disable_sensitive
469 tool.add.disable_sensitive
470 tool.delete.disable_sensitive
471 tool.manage.disable_sensitive
472 tool.archive.disable_sensitive
473
474 tool.details_cmd_in_menu.disable_sensitive
475 tool.new_metric_cmd_in_menu.disable_sensitive
476 tool.calculate_cmd_in_menu.disable_sensitive
477 tool.add_cmd_in_menu.disable_sensitive
478 tool.delete_cmd_in_menu.disable_sensitive
479 tool.manage_cmd_in_menu.disable_sensitive
480 tool.archive_cmd_in_menu.disable_sensitive
481
482 tool.name.disable_sensitive
483 tool.scope_combobox.disable_sensitive
484 tool.metric_field.disable_sensitive
485 tool.metric_button.disable_sensitive
486 tool.unit_field.disable_sensitive
487 end
488
489 enable_all_components is
490 -- Enable buttons and menu items after details calculation.
491 do
492 if not tool.add.added then
493 tool.add.enable_sensitive
494 tool.add_cmd_in_menu.enable_sensitive
495 end
496
497 tool.new_metric.enable_sensitive
498 tool.calculate.enable_sensitive
499 tool.delete.enable_sensitive
500 tool.manage.enable_sensitive
501 tool.archive.enable_sensitive
502
503 tool.new_metric_cmd_in_menu.enable_sensitive
504 tool.calculate_cmd_in_menu.enable_sensitive
505 tool.delete_cmd_in_menu.enable_sensitive
506 tool.manage_cmd_in_menu.enable_sensitive
507 tool.archive_cmd_in_menu.enable_sensitive
508
509 tool.name.enable_sensitive
510 tool.scope_combobox.enable_sensitive
511 tool.metric_field.enable_sensitive
512 tool.metric_button.enable_sensitive
513 tool.unit_field.enable_sensitive
514 end
515
516 current_button: EB_COMMAND_TOOL_BAR_BUTTON;
517
518 indexing
519 copyright: "Copyright (c) 1984-2006, Eiffel Software"
520 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
521 licensing_options: "http://www.eiffel.com/licensing"
522 copying: "[
523 This file is part of Eiffel Software's Eiffel Development Environment.
524
525 Eiffel Software's Eiffel Development Environment is free
526 software; you can redistribute it and/or modify it under
527 the terms of the GNU General Public License as published
528 by the Free Software Foundation, version 2 of the License
529 (available at the URL listed under "license" above).
530
531 Eiffel Software's Eiffel Development Environment is
532 distributed in the hope that it will be useful, but
533 WITHOUT ANY WARRANTY; without even the implied warranty
534 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
535 See the GNU General Public License for more details.
536
537 You should have received a copy of the GNU General Public
538 License along with Eiffel Software's Eiffel Development
539 Environment; if not, write to the Free Software Foundation,
540 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
541 ]"
542 source: "[
543 Eiffel Software
544 356 Storke Road, Goleta, CA 93117 USA
545 Telephone 805-685-1006, Fax 805-685-6869
546 Website http://www.eiffel.com
547 Customer support http://support.eiffel.com
548 ]"
549
550 end -- class EB_METRIC_DETAILS_CMD

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23