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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62017 - (show annotations)
Sun Jul 30 06:14:45 2006 UTC (13 years, 5 months ago) by manus
File size: 29036 byte(s)
EiffelStudio docking branch. It only contains modified classes needed to get the docking version of EiffelStudio.
1 indexing
2 description: "Objects that ..."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: ""
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EB_METRIC_ARCHIVE_COMPARISON_CMD
11
12 inherit
13 EB_METRIC_COMMAND
14
15 SHARED_XML_ROUTINES
16 export
17 {NONE} all
18 end
19
20 EV_KEY_CONSTANTS
21 export
22 {NONE} all
23 end
24
25 TRANSFER_MANAGER_BUILDER
26
27 PROJECT_CONTEXT
28 export
29 {NONE} all
30 end
31
32 EB_CONSTANTS
33 export
34 {NONE} all
35 end
36
37 EB_FILE_DIALOG_CONSTANTS
38 export
39 {NONE} all
40 end
41
42 EB_SHARED_PREFERENCES
43 export
44 {NONE} all
45 end
46
47 create
48 make
49
50 feature -- Initialization
51
52 pixmap: EV_PIXMAP is
53 -- Pixmap representing the command.
54 do
55 Result := Pixmaps.Icon_sorter
56 end
57
58 tooltip: STRING is
59 -- Tooltip for the toolbar button.
60 do
61 Result := "Compare measures to archive."
62 end
63
64 description: STRING is
65 -- Description for this command.
66 do
67 Result := "Archive comparison"
68 end
69
70 name: STRING is "Comparison"
71 -- Name of the command. Used to store the command in the
72 -- preferences.
73
74 feature -- Initialization
75
76 build_archive_dialog is
77 -- Build `archive_dialog' to create, update or compare to an archive.
78 local
79 hb: EV_HORIZONTAL_BOX
80 vb1, vb2: EV_VERTICAL_BOX
81 frame: EV_FRAME
82 label: EV_LABEL
83 ok_button, button: EV_BUTTON
84 do
85 create archive_dialog
86 archive_dialog.set_title ("Archive setting")
87 archive_dialog.set_icon_pixmap (pixmaps.icon_pixmaps.general_dialog_icon)
88
89 create vb1
90 vb1.set_padding (5)
91 vb1.set_border_width (5)
92 create frame.make_with_text ("Set reference archive")
93 create vb2
94 vb2.set_border_width (5)
95 vb2.set_padding (5)
96
97 create hb
98
99 create label.make_with_text ("Compare current archive to:")
100 label.align_text_left
101 hb.extend (label)
102 hb.disable_item_expand (label)
103
104 hb.extend (create {EV_CELL})
105
106 create button.make_with_text_and_action ("Browse...", agent browse_archive)
107 layout_constants.set_default_size_for_button (button)
108 hb.extend (button)
109 hb.disable_item_expand (button)
110
111 vb2.extend (hb)
112 vb2.disable_item_expand (hb)
113
114 create hb
115 hb.set_padding (5)
116 create label.make_with_text ("File or URL:")
117 label.align_text_left
118 hb.extend (label)
119 hb.disable_item_expand (label)
120
121 create browse_archive_field
122 hb.extend (browse_archive_field)
123 vb2.extend (hb)
124 vb2.disable_item_expand (hb)
125
126 create label.make_with_text ("Display comparison in terms of:")
127 label.align_text_left
128 vb2.extend (label)
129 vb2.disable_item_expand (label)
130
131 create hb
132 hb.set_padding (5)
133 create label.make_with_text ("Ratio of current measure to archive")
134 hb.extend (label)
135 hb.disable_item_expand (label)
136
137 hb.extend (create {EV_CELL})
138
139 create button.make_with_text_and_action ("Set", agent validate_url ("default"))
140 layout_constants.set_default_size_for_button (button)
141 hb.extend (button)
142 hb.disable_item_expand (button)
143 vb2.extend (hb)
144 vb2.disable_item_expand (hb)
145
146
147 create hb
148 hb.set_padding (5)
149 create label.make_with_text ("Difference of current measure to archive")
150 hb.extend (label)
151 hb.disable_item_expand (label)
152
153 hb.extend (create {EV_CELL})
154
155 create button.make_with_text_and_action ("Set", agent validate_url ("difference"))
156 layout_constants.set_default_size_for_button (button)
157 hb.extend (button)
158 hb.disable_item_expand (button)
159 vb2.extend (hb)
160 vb2.disable_item_expand (hb)
161
162 create hb
163 hb.set_padding (5)
164 create label.make_with_text ("Archive value")
165 hb.extend (label)
166 hb.disable_item_expand (label)
167
168 hb.extend (create {EV_CELL})
169
170 create button.make_with_text_and_action ("Set", agent validate_url ("value"))
171 layout_constants.set_default_size_for_button (button)
172 hb.extend (button)
173 hb.disable_item_expand (button)
174 vb2.extend (hb)
175 vb2.disable_item_expand (hb)
176 frame.extend (vb2)
177 vb1.extend (frame)
178 vb1.disable_item_expand (frame)
179
180 create frame.make_with_text ("Create/replace archive")
181 create vb2
182 vb2.set_border_width (5)
183 vb2.set_padding (5)
184
185 create hb
186 hb.set_padding (5)
187
188 create label.make_with_text ("Create new archive for current system:")
189 label.align_text_left
190 hb.extend (label)
191 hb.disable_item_expand (label)
192
193 hb.extend (create {EV_CELL})
194
195 create button.make_with_text_and_action ("Browse...", agent new_archive)
196 button.set_minimum_size (50, 22)
197 layout_constants.set_default_size_for_button (button)
198 hb.extend (button)
199 hb.disable_item_expand (button)
200
201 vb2.extend (hb)
202 vb2.disable_item_expand (hb)
203
204 create hb
205 hb.set_padding (5)
206 create label.make_with_text ("Current archive:")
207 label.align_text_left
208 hb.extend (label)
209 hb.disable_item_expand (label)
210
211 create new_archive_field
212 new_archive_field.disable_edit
213 hb.extend (new_archive_field)
214 vb2.extend (hb)
215 vb2.disable_item_expand (hb)
216 frame.extend (vb2)
217 vb1.extend (frame)
218 vb1.disable_item_expand (frame)
219
220 create frame.make_with_text ("Update archive")
221 create vb2
222 vb2.set_border_width (5)
223 vb2.set_padding (5)
224
225 create hb
226
227 create label.make_with_text ("Update current system archive:")
228 label.align_text_left
229 hb.extend (label)
230 hb.disable_item_expand (label)
231
232 hb.extend (create {EV_CELL})
233
234 create button.make_with_text_and_action ("Browse...", agent update_archive)
235 button.set_minimum_size (50, 22)
236 layout_constants.set_default_size_for_button (button)
237 hb.extend (button)
238 hb.disable_item_expand (button)
239
240 vb2.extend (hb)
241 vb2.disable_item_expand (hb)
242
243 create hb
244 hb.set_padding (5)
245 create label.make_with_text ("Current archive:")
246 label.align_text_left
247 hb.extend (label)
248 hb.disable_item_expand (label)
249
250 create update_archive_field
251 update_archive_field.disable_edit
252 hb.extend (update_archive_field)
253 vb2.extend (hb)
254 vb2.disable_item_expand (hb)
255 frame.extend (vb2)
256 vb1.extend (frame)
257 vb1.disable_item_expand (frame)
258
259 create hb
260 create ok_button.make_with_text_and_action ("Close", agent ok_action)
261 ok_button.set_minimum_width (60)
262 layout_constants.set_default_size_for_button (ok_button)
263 hb.extend (create {EV_CELL})
264 hb.extend (ok_button)
265 hb.disable_item_expand (ok_button)
266 hb.extend (create {EV_CELL})
267
268 vb1.extend (hb)
269 vb1.disable_item_expand (hb)
270
271 archive_dialog.extend (vb1)
272 archive_dialog.set_default_push_button (ok_button)
273 archive_dialog.set_default_cancel_button (ok_button)
274 end
275
276 feature -- Access
277
278 archive_dialog: EV_DIALOG
279 -- Dialog to create, update or compare to an archive.
280
281 default_ratio: EV_RADIO_BUTTON
282 -- Display comparison as ratio of system value to archived one.
283
284 difference_ratio: EV_RADIO_BUTTON
285 -- Display comparison as ratio of difference between system and archives values to archived value.
286
287 archive_value: EV_RADIO_BUTTON
288 -- Display archived value.
289
290 new_archive_field: EV_TEXT_FIELD
291 -- Field to display path of the created archive.
292
293 update_archive_field: EV_TEXT_FIELD
294 -- Field to display path of the updated archive.
295
296 browse_archive_field: EV_TEXT_FIELD
297 -- Field to display path of the selected archive for comparison .
298
299 open_dialog: EB_FILE_OPEN_DIALOG
300 -- Dialog to load archive.
301
302 save_dialog: EB_FILE_SAVE_DIALOG
303 -- Dialog to save new archive.
304
305 archived_root_element: XM_ELEMENT
306 -- XML element written in archive file.
307
308 archived_file: PLAIN_TEXT_FILE
309 -- Loaded archive file for comparison.
310
311 feature -- Action
312
313 new_archive is
314 -- Open dialog to create new archive file.
315 do
316 create save_dialog.make_with_preference (preferences.dialog_data.last_saved_metric_new_archive_directory_preference)
317 set_dialog_filters_and_add_all (save_dialog, <<xml_files_filter>>)
318 save_dialog.save_actions.extend (agent confirm_new_archive)
319 save_dialog.show_modal_to_window (archive_dialog)
320 end
321
322 confirm_new_archive is
323 -- Confirm creation of new archive
324 local
325 array: ARRAY [PROCEDURE [ANY, TUPLE]]
326 do
327 create array.make (1, 1)
328 array.put (agent on_new_archive, 1)
329 create confirm_dialog.make_with_text_and_actions (
330 "Archive creation can take some time.%NContinue?", array)
331 confirm_dialog.show_modal_to_window (archive_dialog)
332 end
333
334 on_new_archive is
335 -- Launch metric calculation for all non scope ratio metrics over
336 -- `System_scope'. Save measures in the created file.
337 local
338 file: PLAIN_TEXT_FILE
339 file_name: STRING
340 retried: BOOLEAN
341 error_dialog: EB_INFORMATION_DIALOG
342 x_pos, y_pos: INTEGER
343 do
344 overwrite := False
345 x_pos := archive_dialog.x_position + 50
346 y_pos := archive_dialog.y_position + 50
347 file_name := save_dialog.file_name
348 if not retried then
349 if file_name /= Void and then not file_name.is_empty then
350 new_archive_field.set_text (file_name)
351 create file.make (file_name)
352 if file.exists then
353 create confirm_dialog.make_with_text_and_actions ("Selected file already exists.%NOverwrite?", actions_array)
354 confirm_dialog.show_modal_to_window (archive_dialog)
355 end
356 if not file.exists or overwrite then
357 create file.make_open_write (file_name)
358 fill_archive (file)
359 file.close
360 end
361 end
362 end
363 rescue
364 retried := True
365 create error_dialog.make_with_text ("Unable to create file:"
366 + file_name)
367 error_dialog.set_position (x_pos, y_pos)
368 error_dialog.show_modal_to_window (archive_dialog)
369 retry
370 end
371
372 update_archive is
373 -- Open dialog to update archive file.
374 do
375 create open_dialog.make_with_preference (preferences.dialog_data.last_opened_metric_update_archive_directory_preference)
376 set_dialog_filters_and_add_all (open_dialog, <<xml_files_filter>>)
377 open_dialog.open_actions.extend (agent confirm_update_archive)
378 open_dialog.show_modal_to_window (archive_dialog)
379 end
380
381 confirm_update_archive is
382 -- Confirm creation of new archive
383 local
384 array: ARRAY [PROCEDURE [ANY, TUPLE]]
385 do
386 create array.make (1, 1)
387 array.put (agent on_update_archive, 1)
388 create confirm_dialog.make_with_text_and_actions (
389 "Archive creation can take some time.%NContinue?", array)
390 confirm_dialog.show_modal_to_window (archive_dialog)
391 end
392
393 on_update_archive is
394 -- Launch metric calculation for all non scope ratio metrics over
395 -- `System_scope'. Overwrite updated file.
396 local
397 file: PLAIN_TEXT_FILE
398 file_name: STRING
399 root_name, system_name: STRING
400 right_file, retried: BOOLEAN
401 l_deserialized_document: XM_DOCUMENT
402 error_dialog: EB_INFORMATION_DIALOG
403 x_pos, y_pos: INTEGER
404 do
405 overwrite := False
406 x_pos := archive_dialog.x_position + 50
407 y_pos := archive_dialog.y_position + 50
408 file_name := open_dialog.file_name
409 if not retried then
410 if file_name /= Void and then not file_name.is_empty then
411 l_deserialized_document := Xml_routines.deserialize_document (file_name)
412 if l_deserialized_document /= Void then
413 if l_deserialized_document.root_element.has_attribute_by_name ("System") then
414 system_name := l_deserialized_document.root_element.attribute_by_name ("System").value
415 end
416
417 right_file := (root_name /= Void and then equal (root_name, "ARCHIVE")) and
418 (system_name /= Void and then equal (system_name, tool.System.name))
419 if right_file then
420 create confirm_dialog.make_with_text_and_actions (
421 "System name in selected file%N%
422 %is the same as current system name.%N%
423 %However, it could be just a homonym.%N%
424 %continue overwritting?", actions_array)
425 else
426 create confirm_dialog.make_with_text_and_actions (
427 "Selected file is not the%N%
428 %current system's archive.%N%
429 %Overwrite?", actions_array)
430 end
431 confirm_dialog.show_modal_to_window (archive_dialog)
432 if overwrite then
433 update_archive_field.set_text (file_name)
434 create file.make (file_name)
435 file.open_write
436 fill_archive (file)
437 file.close
438 end
439 else
440 create error_dialog.make_with_text ("File does not exist.%N%
441 %Please check location.")
442 error_dialog.set_position (x_pos, y_pos)
443 error_dialog.show_modal_to_window (archive_dialog)
444 end
445 end
446 end
447 rescue
448 retried := True
449 create error_dialog.make_with_text ("Unable to read file:"
450 + file_name)
451 error_dialog.set_position (x_pos, y_pos)
452 error_dialog.show_modal_to_window (archive_dialog)
453 retry
454 end
455
456 browse_archive is
457 -- Open dialog to select archive file forcomparison with surrent system.
458 do
459 create open_dialog.make_with_preference (preferences.dialog_data.last_opened_metric_browse_archive_directory_preference)
460 set_dialog_filters_and_add_all (open_dialog, <<xml_files_filter>>)
461 open_dialog.open_actions.extend (agent on_browse_archive)
462 open_dialog.show_modal_to_window (archive_dialog)
463 end
464
465 on_browse_archive is
466 -- Display archive path and compare.
467 do
468 browse_archive_field.set_text (open_dialog.file_name)
469 end
470
471 archive_syntax (root_element: XM_ELEMENT): BOOLEAN is
472 -- Is `root_element' the XML representation of an archive file?
473 require
474 element_not_void: root_element /= Void
475 do
476 Result := (root_element.name /= Void and then equal (root_element.name, "ARCHIVE")) and
477 root_element.has (Xml_routines.element_by_name (root_element, "METRIC_DEFINITIONS")) and
478 root_element.has (Xml_routines.element_by_name (root_element, "RECORDED_MEASURES")) and
479 (root_element.has_attribute_by_name ("System") and then root_element.attribute_by_name ("System").value /= Void)
480 end
481
482 handle_archive (file_name: STRING) is
483 -- Glance through archive `file_name' and compare saved resiults of
484 -- current system to the archived ones. Comparison is displayed in
485 -- `tool.multi_column_list' regarding selected radio button.
486 require
487 existing_file_name: file_name /= Void and then not file_name.is_empty
488 local
489 root_name, system_name, archived_result: STRING
490 right_syntax, retried: BOOLEAN
491 l_deserialized_document: XM_DOCUMENT
492 error_dialog: EB_INFORMATION_DIALOG
493 root_element, current_measure_xml, metric_definitions: XM_ELEMENT
494 row: EV_MULTI_COLUMN_LIST_ROW
495 a_metric: EB_METRIC
496 current_measure: DOUBLE
497 x_pos, y_pos, i: INTEGER
498 do
499 x_pos := archive_dialog.x_position + 50
500 y_pos := archive_dialog.y_position + 50
501 if not retried then
502 if file_name /= Void and then not file_name.is_empty then
503 l_deserialized_document := Xml_routines.deserialize_document (file_name)
504 if l_deserialized_document /= Void then
505 root_element := l_deserialized_document.root_element
506 root_name := root_element.name
507 if root_element.has_attribute_by_name ("System") then
508 system_name := root_element.attribute_by_name ("System").value
509 end
510 -- right_syntax := (root_name /= Void and then equal (root_name, "ARCHIVE")) and
511 -- root_element.has (Xml_routines.element_by_name (root_element, "METRIC_DEFINITIONS")) and
512 -- root_element.has (Xml_routines.element_by_name (root_element, "RECORDED_MEASURES")) and
513 -- system_name /= Void
514 right_syntax := archive_syntax (root_element)
515
516 if right_syntax then
517 import := False
518 tool.set_default_archive (False)
519 create archived_file.make (file_name)
520 archived_root_element := root_element
521 metric_definitions := Xml_routines.element_by_name (archived_root_element, "METRIC_DEFINITIONS")
522 if not metric_definitions.is_empty then
523 create confirm_dialog.make_with_text_and_actions ("Import saved metrics of archive:%N"
524 + file_name + "?", import_actions_array)
525 confirm_dialog.show_modal_to_window (archive_dialog)
526 if import then
527 import_metrics (file_name)
528 end
529 end
530 from
531 tool.multi_column_list.start
532 i := 1
533 until
534 tool.multi_column_list.after
535 loop
536 row := tool.multi_column_list.item
537 a_metric := tool.metric (row.i_th (4))
538 current_measure_xml ?= tool.file_manager.measure_header.item (i)
539 check current_measure_xml /= Void end
540 current_measure := Xml_routines.xml_double (current_measure_xml, "RESULT")
541 archived_result := retrieve_archived_result (a_metric, archived_file, root_element, archive_mode, current_measure)
542 row.put_i_th (archived_result, 6)
543 tool.multi_column_list.forth
544 i := i + 1
545 end
546 tool.multi_column_list.set_column_title ("Comparison to: " + system_name, 6)
547 end
548 end
549 end
550 end
551 rescue
552 retried := True
553 create error_dialog.make_with_text ("Unable to read file:" + file_name)
554 error_dialog.set_position (x_pos, y_pos)
555 error_dialog.show_modal_to_window (archive_dialog)
556 retry
557 end
558
559
560 validate_url (str: STRING) is
561 -- Try to load remote file when connexion succeeded. Make comparison regarding
562 -- `archive_mode'.
563 require
564 existing_mode: equal (str, "default") or equal (str, "difference") or equal (str, "value")
565 local
566 url_address, http, ftp, file: STRING
567 f: PLAIN_TEXT_FILE
568 x_pos, y_pos: INTEGER
569 do
570 archive_mode := str
571 tool.set_archive_mode (archive_mode)
572 overwrite := False
573 x_pos := archive_dialog.x_position + 50
574 y_pos := archive_dialog.y_position + 50
575 url_address := browse_archive_field.text
576 if url_address /= Void and then not url_address.is_empty then
577 http := url_address.substring (1, 7)
578 ftp := url_address.substring (1, 6)
579 file := url_address.substring (1, 7)
580 if equal (file, "file://") then
581 handle_archive (url_address.substring (8, url_address.count))
582 elseif equal (ftp, "ftp://") or equal (http, "http://") then
583 transfer_and_compare (url_address)
584 else
585 create f.make (url_address)
586 if f.exists then
587 handle_archive (url_address)
588 else
589 transfer_and_compare (url_address)
590 end
591 end
592 end
593 end
594
595 transfer_and_compare (url_address: STRING) is
596 -- Transfer remote file to a concrete one on disk. Make comparison regarding
597 -- `archive_mode'.
598 require
599 url_not_empty: url_address /= Void and then not url_address.is_empty
600 local
601 file_name: FILE_NAME
602 target_file: STRING
603 directory: DIRECTORY
604 file: PLAIN_TEXT_FILE
605 error_dialog: EB_INFORMATION_DIALOG
606 do
607 create file_name.make_from_string (project_location.location)
608 create directory.make ("Metrics")
609 if not directory.exists then
610 directory.create_dir
611 end
612 file_name.set_subdirectory ("Metrics")
613 file_name.extend (tool.System.name + "_transfered_archive")
614 file_name.add_extension ("xml")
615
616 create file.make (file_name)
617 if file.exists then
618 create confirm_dialog.make_with_text_and_actions ("Remote file will be loaded in:%N" + file_name +
619 "%NThis file already exists. Overwrite?", actions_array)
620 confirm_dialog.show_modal_to_window (archive_dialog)
621 end
622 if not file.exists or overwrite then
623 target_file := "file://" + file_name
624 transfer_manager_builder.set_timeout (10)
625 transfer_manager_builder.wipe_out
626 transfer_manager_builder.add_transaction (url_address, target_file)
627 if not transfer_manager_builder.last_added_source_correct then
628 create error_dialog.make_with_text ("Unable to read remote file.%NPlease check URL:%N" + url_address)
629 error_dialog.show_modal_to_window (archive_dialog)
630 elseif not transfer_manager_builder.last_added_target_correct then
631 create error_dialog.make_with_text ("Unable to load remote file in:%N" + file_name +
632 "Please make sure file does not exist or is writable.")
633 error_dialog.show_modal_to_window (archive_dialog)
634 else
635 transfer_manager_builder.build_manager
636 tool.development_window.window.set_pointer_style (tool.development_window.Wait_cursor)
637 transfer_manager_builder.transfer
638 tool.development_window.window.set_pointer_style (tool.development_window.Standard_cursor)
639 if transfer_manager_builder.transfer_succeeded then
640 handle_archive (file_name)
641 else
642 create error_dialog.make_with_text ("Unable to transfer remote file.%NReason: "
643 + transfer_manager_builder.error_reason)
644 error_dialog.show_modal_to_window (archive_dialog)
645 end
646 end
647 end
648 end
649
650 ok_action is
651 -- Action to be performed when clicking on `ok_button'.
652 do
653 archive_dialog.hide
654 end
655
656 archive_mode: STRING
657 -- Way to display arhive comparison.
658
659 fill_archive (f: PLAIN_TEXT_FILE) is
660 -- Launch metric calculation for all non scope ratio metrics over
661 -- `System_scope'. Save measures in `f'.
662 require
663 concrete_file: f /= Void
664 local
665 archive_header: XM_DOCUMENT
666 node, metric_header, measure_header, xml_element: XM_ELEMENT
667 metric_list: ARRAYED_LIST [EB_METRIC]
668 metric_result: DOUBLE
669 scope: EB_METRIC_SCOPE
670 a_metric: EB_METRIC_COMPOSITE
671 retried: BOOLEAN
672 l_namespace: XM_NAMESPACE
673 do
674 if not retried then
675 create l_namespace.make_default
676 create archive_header.make_with_root_named ("ARCHIVE", l_namespace)
677 node := archive_header.root_element
678 node.add_attribute ("System", l_namespace, tool.System.name)
679 metric_header := tool.file_manager.metric_header
680 node.put_last (metric_header)
681 create measure_header.make (node, "RECORDED_MEASURES", l_namespace)
682 scope := tool.scope (interface_names.metric_this_system)
683 scope.set_system_i (tool.System)
684 metric_list := tool.metrics
685 from
686 metric_list.start
687 until
688 metric_list.after
689 loop
690 a_metric ?= metric_list.item
691 if a_metric = Void or else not a_metric.is_scope_ratio then
692 create xml_element.make (node, "MEASURE", l_namespace)
693 xml_element.add_attribute ("Metric", l_namespace, metric_list.item.name)
694 metric_result := tool.calculate.calculate_metric (metric_list.item, scope)
695 xml_element.add_attribute ("Result", l_namespace, metric_result.out)
696 measure_header.put_last (xml_element)
697 end
698 metric_list.forth
699 end
700 node.put_last (measure_header)
701 Xml_routines.save_xml_document (f.name, archive_header)
702 tool.progress_dialog.hide
703 end
704 rescue
705 retried := True
706 tool.progress_dialog.hide
707 tool.progress_dialog.enable_cancel
708 tool.development_window.window.set_pointer_style (tool.development_window.Standard_cursor)
709 retry
710 end
711
712 feature -- Comparison
713
714 retrieve_archived_result (a_metric: EB_METRIC; f: PLAIN_TEXT_FILE; root_element: XM_ELEMENT; mode: STRING; current_measure: DOUBLE): STRING is
715 -- Return saved measure for `a_metric' in file `f'
716 require
717 metric_not_void: a_metric /= Void
718 concrete_file: f /= Void
719 root_not_void: root_element /= Void
720 existing_mode: equal (mode, "default") or
721 equal (mode, "difference") or
722 equal (mode, "value")
723 local
724 basic_metric: EB_METRIC_BASIC
725 measure_header, measure_element: XM_ELEMENT
726 archived_result, displayed_result: DOUBLE
727 retried: BOOLEAN
728 metric_value: STRING
729 do
730 if not retried then
731 basic_metric ?= a_metric
732 if basic_metric /= Void or else
733 tool.calculate.has_metric (a_metric, f) then
734 measure_header := Xml_routines.element_by_name (root_element, "RECORDED_MEASURES")
735 from
736 measure_header.start
737 until
738 measure_header.after or Result /= Void
739 loop
740 measure_element ?= measure_header.item_for_iteration
741 metric_value := measure_element.attribute_by_name ("Metric").value
742 archived_result := measure_element.attribute_by_name ("Result").value.to_double
743 if
744 measure_element /= Void and then
745 equal (metric_value, a_metric.name)
746 then
747 if equal (mode, "default") then
748 displayed_result := current_measure / archived_result
749 Result := tool.fix_decimals_and_percentage (displayed_result, True)
750 elseif equal (mode, "difference") then
751 displayed_result := (current_measure - archived_result) / current_measure
752 Result := tool.fix_decimals_and_percentage (displayed_result, True)
753 elseif equal (mode, "value") then
754 displayed_result := archived_result
755 Result := tool.fix_decimals_and_percentage (displayed_result, False)
756 end
757 end
758 measure_header.forth
759 end
760 end
761 tool.progress_dialog.hide
762 if Result = Void or else Result.is_empty then
763 Result := "-"
764 end
765 end
766 rescue
767 retried := True
768 tool.progress_dialog.hide
769 tool.progress_dialog.enable_cancel
770 tool.development_window.window.set_pointer_style (tool.development_window.Standard_cursor)
771 retry
772 end
773
774 feature -- Overwritting
775
776 overwrite: BOOLEAN
777 -- Overwrite file?
778
779 confirm_dialog: EV_CONFIRMATION_DIALOG
780 -- Dialog to confirm file overwritting.
781
782 actions_array: ARRAY [PROCEDURE [ANY, TUPLE]] is
783 -- Actions to be performed for `confirm_dialog'.
784 do
785 create Result.make (1, 2)
786 Result.put (agent overwrite_action, 1)
787 Result.put (agent abort_overwrite_action, 2)
788 ensure
789 filled_array: Result @ 1 /= Void and Result @ 2 /= Void
790 end
791
792 overwrite_action is
793 -- Action to be performed on clicking on `yes_button' in `confirm_dialog'.
794 do
795 overwrite := True
796 end
797
798 abort_overwrite_action is
799 -- Action to be performed on clicking on `no_button' in `confirm_dialog'.
800 do
801 overwrite := False
802 end
803
804 key_enter_pressed (a_key: EV_KEY; a_button: EV_BUTTON) is
805 -- On CR, call `a_button' associated action.
806 do
807 if a_key.code = Key_enter then
808 a_button.select_actions.call (Void)
809 end
810 end
811
812 feature -- Metric importation
813
814 import: BOOLEAN
815 -- When comparing, import saved metrics of selected archive?
816
817 import_action is
818 -- Action to be performed on clicking on `yes_button' in `confirm_dialog'
819 -- when asking for archive comparison.
820 do
821 import := True
822 end
823
824 abort_import_action is
825 -- Action to be performed on clicking on `no_button' in `confirm_dialog'
826 -- when asking for archive comparison.
827 do
828 import := False
829 end
830
831 import_actions_array: ARRAY [PROCEDURE [ANY, TUPLE]] is
832 -- Actions to be performed for `confirm_dialog'.
833 do
834 create Result.make (1, 2)
835 Result.put (agent import_action, 1)
836 Result.put (agent abort_import_action, 2)
837 ensure
838 filled_array: Result @ 1 /= Void and Result @ 2 /= Void
839 end
840
841 import_metrics (file_name: STRING) is
842 -- Import metrics of archive `file'.
843 do
844 tool.manage.ev_list.wipe_out
845 tool.manage.fill_ev_list (tool.manage.ev_list)
846 if tool.manage.import.importable_metric_list /= Void and tool.manage.import.current_metric_list /= Void then
847 tool.manage.import.importable_metric_list.wipe_out
848 tool.manage.import.current_metric_list.wipe_out
849 end
850 tool.manage.import.on_import (file_name, archive_dialog)
851 tool.manage.save_action
852 end
853
854
855 feature -- Action
856
857 execute is
858 -- Display archive_dialog and reset needed fields.
859 local
860 x_pos, y_pos: INTEGER
861 do
862 x_pos := tool.development_window.window.x_position + 200
863 y_pos := tool.development_window.window.y_position + 40
864 if archive_dialog = Void then
865 build_archive_dialog
866 end
867 archive_dialog.set_position (x_pos, y_pos)
868 new_archive_field.remove_text
869 update_archive_field.remove_text
870 browse_archive_field.remove_text
871 archive_dialog.show_modal_to_window (tool.development_window.window)
872 tool.multi_column_list.do_nothing
873 tool.resize_column_list_to_content (tool.multi_column_list)
874 end
875
876 indexing
877 copyright: "Copyright (c) 1984-2006, Eiffel Software"
878 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
879 licensing_options: "http://www.eiffel.com/licensing"
880 copying: "[
881 This file is part of Eiffel Software's Eiffel Development Environment.
882
883 Eiffel Software's Eiffel Development Environment is free
884 software; you can redistribute it and/or modify it under
885 the terms of the GNU General Public License as published
886 by the Free Software Foundation, version 2 of the License
887 (available at the URL listed under "license" above).
888
889 Eiffel Software's Eiffel Development Environment is
890 distributed in the hope that it will be useful, but
891 WITHOUT ANY WARRANTY; without even the implied warranty
892 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
893 See the GNU General Public License for more details.
894
895 You should have received a copy of the GNU General Public
896 License along with Eiffel Software's Eiffel Development
897 Environment; if not, write to the Free Software Foundation,
898 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
899 ]"
900 source: "[
901 Eiffel Software
902 356 Storke Road, Goleta, CA 93117 USA
903 Telephone 805-685-1006, Fax 805-685-6869
904 Website http://www.eiffel.com
905 Customer support http://support.eiffel.com
906 ]"
907
908 end -- class EB_METRIC_ARCHIVE_COMPARISON_CMD

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23