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

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