/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/metric_tool/metric_interface/eb_metric_archive_panel.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/metric_tool/metric_interface/eb_metric_archive_panel.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61871 - (show annotations)
Sun Jul 30 05:44:25 2006 UTC (13 years, 6 months ago) by manus
File size: 29975 byte(s)
EiffelStudio docking branch. It only contains modified classes needed to get the docking version of EiffelStudio.
1 indexing
2 description: "Objects that represent an EV_TITLED_WINDOW.%
3 %The original version of this class was generated by EiffelBuild."
4 legal: "See notice at end of class."
5 status: "See notice at end of class."
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EB_METRIC_ARCHIVE_PANEL
11
12 inherit
13 EB_METRIC_ARCHIVE_PANEL_IMP
14
15 EB_METRIC_PANEL
16 undefine
17 copy,
18 is_equal,
19 default_create
20 end
21
22 EB_CONSTANTS
23 undefine
24 copy,
25 is_equal,
26 default_create
27 end
28
29 EB_SHARED_PREFERENCES
30 undefine
31 copy,
32 is_equal,
33 default_create
34 end
35
36 EB_METRIC_INTERFACE_PROVIDER
37 undefine
38 copy,
39 is_equal,
40 default_create
41 end
42
43 EXCEPTIONS
44 undefine
45 copy,
46 is_equal,
47 default_create
48 end
49
50 TRANSFER_MANAGER_BUILDER
51 undefine
52 copy,
53 is_equal,
54 default_create
55 end
56
57 create
58 make
59
60 feature {NONE} -- Initialization
61
62 make (a_tool: like metric_tool) is
63 -- Initialize `metric_tool' with `a_tool'.
64 require
65 a_tool_attached: a_tool /= Void
66 do
67 metric_tool := a_tool
68 default_create
69
70 -- Setup `open_file_dialog'.
71 create open_file_dialog.make_with_preference (preferences.dialog_data.last_opened_metric_browse_archive_directory_preference)
72 open_file_dialog.set_title (metric_names.t_select_archive)
73 open_file_dialog.filters.extend (["*.xml", "XML files"])
74
75 -- Setup timers.
76 create internal_timer.make_with_interval (0)
77 create current_archive_timer.make_with_interval (0)
78 create reference_archive_timer.make_with_interval (0)
79 end
80
81 user_initialization is
82 -- Called by `initialize'.
83 -- Any custom user initialization that
84 -- could not be performed in `initialize',
85 -- (due to regeneration of implementation class)
86 -- can be added here.
87 do
88 -- Setup domain selector.
89 create domain_selector.make (False)
90 domain_selector.set_minimum_width (100)
91 -- Setup metric selector.
92 create metric_selector.make (True)
93 metric_selector.set_minimum_width (160)
94 metric_selector.double_click_actions.extend (agent on_pointer_double_click_on_metric_item)
95
96 -- Setup toolbar.
97 run_btn.set_pixmap (pixmaps.icon_pixmaps.debug_run_icon)
98 run_btn.select_actions.extend (agent on_run_archive)
99 stop_btn.set_pixmap (pixmaps.icon_pixmaps.debug_stop_icon)
100
101 domain_selection_area.extend (domain_selector)
102 metric_selection_area.extend (metric_selector)
103
104 new_archive_browse_btn.select_actions.extend (agent on_open_new_archive (agent on_new_archive_file_name_selected))
105 new_archive_file_name_text.change_actions.extend (agent on_new_archive_file_name_changes)
106
107 stop_btn.disable_sensitive
108 stop_btn.select_actions.extend (agent on_stop_metric_evaluation_button_pressed)
109 clean_btn.disable_select
110 clean_btn.disable_sensitive
111
112 compare_btn.set_pixmap (pixmaps.icon_pixmaps.debug_run_icon)
113 browse_reference_archive_btn.select_actions.extend (agent on_open_new_archive (agent on_comparison_archive_selected (reference_metric_archive_text)))
114 browse_current_archive_btn.select_actions.extend (agent on_open_new_archive (agent on_comparison_archive_selected (current_metric_archive_text)))
115 compare_btn.select_actions.extend (agent on_compare_archives)
116 run_btn.set_tooltip (metric_names.f_start_archive)
117 stop_btn.set_tooltip (metric_names.f_stop_archive)
118 new_archive_browse_btn.set_tooltip (metric_names.f_select_exist_archive_file)
119 clean_btn.set_tooltip (metric_names.f_clean_archive)
120 compare_btn.set_tooltip (metric_names.f_compare_archive)
121 compare_btn.set_text (metric_names.t_compare)
122 browse_current_archive_btn.set_tooltip (metric_names.f_select_current_archive)
123 browse_reference_archive_btn.set_tooltip (metric_names.f_select_reference_archive)
124 run_btn.disable_sensitive
125 domain_selector.domain_change_actions.extend (agent (a_domain: EB_METRIC_DOMAIN) do synchronize_archive_evaluation_area end)
126 new_archive_file_lbl.set_text (metric_names.t_location)
127 clean_btn.set_text (metric_names.t_clean)
128 archive_definition_frame.set_text (metric_names.t_archive_management)
129 archive_comparison_area.set_text (metric_names.t_archive_comparison)
130 source_domain_lbl.set_text (metric_names.t_select_source_domain)
131 metric_lbl.set_text (metric_names.t_select_metric)
132 reference_archive_lbl.set_text (metric_names.t_select_reference_archive)
133 current_archive_lbl.set_text (metric_names.t_select_current_archive)
134 end
135
136 feature -- Access
137
138 domain_selector: EB_METRIC_DOMAIN_SELECTOR
139 -- Domain selector
140
141 metric_selector: EB_METRIC_SELECTOR
142 -- Metric selector
143
144 last_reference_archive: LIST [EB_METRIC_ARCHIVE_NODE]
145 -- Last reference archive
146
147 last_current_archive: LIST [EB_METRIC_ARCHIVE_NODE]
148 -- Last current archive
149
150 feature -- Status report
151
152 is_cancel_evaluation_requested: BOOLEAN
153 -- Is cancel metric evaluation requested?
154
155 is_current_metric_archive_ok: BOOLEAN
156 -- Is file specified in `current_metric_archive_text' valid?
157
158 is_reference_metric_archive_ok: BOOLEAN
159 -- Is file specified in `reference_metric_archive_text' valid?
160
161 is_archive_running: BOOLEAN
162 -- Is metric archive evaluation running?
163
164 is_compiling: BOOLEAN is
165 -- Is Eiffel compilation under-going?
166 do
167 Result := metric_tool.is_compiling
168 end
169
170 is_new_archive_file_selected: BOOLEAN
171 -- Is new archive file selected?
172
173 is_new_archive_file_exists: BOOLEAN
174 -- Does selected new archive file exist?
175
176 is_last_load_successful: BOOLEAN
177 -- Is last `load_archive' successful?
178
179 feature -- Basic operations
180
181 synchronize_when_compile_start is
182 -- Synchronize when Eiffel compilation starts.
183 do
184 archive_definition_frame.disable_sensitive
185 archive_comparison_area.disable_sensitive
186 end
187
188 synchronize_when_compile_stop is
189 -- Synchronize when Eiffel compilation stops.
190 do
191 archive_definition_frame.enable_sensitive
192 archive_comparison_area.enable_sensitive
193 end
194
195 feature -- Actions
196
197 on_select is
198 -- Action to be performed when current panel is selected
199 do
200 end
201
202 on_open_new_archive (a_selection_agent: PROCEDURE [ANY, TUPLE]) is
203 -- Action to be performed to open a dialog to select a file name when create/update a metric archive
204 -- When user press "OK" in `open_file_dialog', `a_selection_agent' will be invoked.
205 require
206 a_selection_agent_attached: a_selection_agent /= Void
207 do
208 open_file_dialog.open_actions.wipe_out
209 open_file_dialog.open_actions.extend (a_selection_agent)
210 open_file_dialog.show_modal_to_window (metric_tool.development_window.window)
211 end
212
213 on_new_archive_file_name_selected is
214 -- Action to be performed when user selected a file name for metric archive create/update
215 do
216 new_archive_file_name_text.set_text (open_file_dialog.file_name)
217 end
218
219 on_new_archive_file_name_changes is
220 -- Action to be performed when text in `new_archive_file_name_text' changes
221 do
222 internal_timer.actions.wipe_out
223 internal_timer.actions.extend_kamikaze (agent check_archive_validity (new_archive_file_name_text, agent on_new_archive_checked, internal_timer))
224 internal_timer.set_interval (500)
225 end
226
227 on_new_archive_checked (a_file_exist: BOOLEAN; a_valid: BOOLEAN; a_archive: LIST [EB_METRIC_ARCHIVE_NODE]) is
228 -- Action to be performed when archive file specified in `new_archive_file_name_text' is checked
229 -- If `a_valid' is True, `a_archive' is the archive, otherwise, `a_archive' is Void.
230 do
231 is_new_archive_file_exists := False
232 if a_file_exist then
233 if a_valid then
234 clean_btn.enable_sensitive
235 clean_btn.disable_select
236 new_archive_file_name_text.set_foreground_color (default_foreground_color)
237 new_archive_file_name_text.set_tooltip (tooltip_from_archive (a_archive))
238 is_new_archive_file_exists := True
239 else
240 clean_btn.disable_sensitive
241 clean_btn.enable_select
242 new_archive_file_name_text.set_foreground_color (red_color)
243 new_archive_file_name_text.set_tooltip (metric_names.t_selected_archive_not_valid)
244 end
245 is_new_archive_file_selected := True
246 else
247 clean_btn.disable_select
248 clean_btn.disable_sensitive
249 new_archive_file_name_text.set_foreground_color (default_foreground_color)
250 new_archive_file_name_text.remove_tooltip
251 is_new_archive_file_selected := not new_archive_file_name_text.text.is_empty
252 end
253 synchronize_archive_evaluation_area
254 end
255
256 synchronize_archive_evaluation_area is
257 -- Synchronize archive evaluation area.
258 do
259 if is_new_archive_file_selected and then domain_selector.domain.is_valid then
260 run_btn.enable_sensitive
261 else
262 run_btn.disable_sensitive
263 end
264 end
265
266 on_run_archive is
267 -- Action to be performed to start metric calcuation for generating archive information
268 local
269 l_selected_metrics: LIST [STRING]
270 l_msg: STRING
271 l_error_dialog: EV_ERROR_DIALOG
272 l_retried: BOOLEAN
273 l_file_name: STRING
274 l_archive: LIST [EB_METRIC_ARCHIVE_NODE]
275 l_source_domain: EB_METRIC_DOMAIN
276 l_metric: EB_METRIC
277 l_value: DOUBLE
278 l_archive_node: EB_METRIC_ARCHIVE_NODE
279 l_domain_generator: QL_TARGET_DOMAIN_GENERATOR
280 l_archive_tbl: HASH_TABLE [EB_METRIC_ARCHIVE_NODE, STRING]
281 do
282 create l_domain_generator
283 if not l_retried then
284 l_selected_metrics := metric_selector.selected_metrics
285 l_msg := check_selected_metrics (l_selected_metrics)
286 if l_msg /= Void then
287 create l_error_dialog.make_with_text (l_msg)
288 l_error_dialog.set_buttons (<<metric_names.t_ok>>)
289 l_error_dialog.show_modal_to_window (metric_tool.development_window.window)
290 else
291 l_file_name := new_archive_file_name_text.text
292 create {ARRAYED_LIST [EB_METRIC_ARCHIVE_NODE]} l_archive.make (l_selected_metrics.count)
293 l_source_domain := domain_selector.domain
294 setup_metric_evaluation_callback (l_domain_generator)
295 is_archive_running := True
296 from
297 l_selected_metrics.start
298 until
299 l_selected_metrics.after
300 loop
301 l_metric := metric_manager.metric_with_name (l_selected_metrics.item)
302 l_metric.disable_fill_domain
303 l_value := l_metric.value (l_source_domain).first.value
304 create l_archive_node.make (l_metric.name, metric_type_id (l_metric), create{DATE_TIME}.make_now, l_value, l_source_domain)
305 l_archive.extend (l_archive_node)
306 l_selected_metrics.forth
307 end
308 is_archive_running := False
309 synchronize_after_metric_evaluation (l_domain_generator)
310 if not clean_btn.is_selected then
311 l_archive_tbl := metric_archive_from_file (l_file_name)
312 if l_archive_tbl /= Void then
313 l_archive := merge_archive_from_archive_table (l_archive_tbl, l_archive)
314 end
315 end
316 metric_manager.store_metric_archive (l_file_name, l_archive)
317 display_status_message ("")
318 end
319 end
320 rescue
321 l_retried := True
322 synchronize_after_metric_evaluation (l_domain_generator)
323 if not is_cancel_evaluation_requested then
324 display_error_message
325 else
326 if l_domain_generator.error_handler.has_error then
327 display_status_message (l_domain_generator.error_handler.error_list.last.out)
328 else
329 display_status_message (tag_name)
330 end
331 end
332 retry
333 end
334
335 on_stop_metric_evaluation (a_item: QL_ITEM) is
336 -- Action to be performed when metric evaluation is stopped
337 local
338 l_domain_generator: QL_CLASS_DOMAIN_GENERATOR
339 do
340 if is_cancel_evaluation_requested then
341 create l_domain_generator
342 if is_compiling then
343 l_domain_generator.error_handler.insert_interrupt_error (metric_names.e_interrupted_by_compile)
344 else
345 l_domain_generator.error_handler.insert_interrupt_error (metric_names.e_interrupted_by_user)
346 end
347 end
348 end
349
350 on_stop_metric_evaluation_button_pressed is
351 -- Action to be performed when stop button is pressed.
352 do
353 is_cancel_evaluation_requested := True
354 end
355
356 on_comparison_archive_selected (a_text_field: EV_TEXT_FIELD) is
357 -- Action to be performed when reference metric archive or current metric archive is selected
358 do
359 a_text_field.set_text (open_file_dialog.file_name)
360 end
361
362 on_reference_archive_checked (a_file_exist: BOOLEAN; a_valid: BOOLEAN; a_archive: LIST [EB_METRIC_ARCHIVE_NODE]) is
363 -- Action to be performed when archive file specified in `reference_metric_archive_text' is checked
364 -- If `a_valid' is True, `a_archive' is the archive, otherwise, `a_archive' is Void.
365 do
366 is_reference_metric_archive_ok := a_valid
367 if a_valid then
368 reference_metric_archive_text.set_foreground_color (default_foreground_color)
369 reference_metric_archive_text.set_tooltip (tooltip_from_archive (a_archive))
370 else
371 reference_metric_archive_text.set_foreground_color (red_color)
372 if a_file_exist then
373 reference_metric_archive_text.set_tooltip (metric_names.t_selected_archive_not_valid)
374 else
375 reference_metric_archive_text.set_tooltip (metric_names.t_selected_file_not_exists)
376 end
377 end
378 last_reference_archive := a_archive
379 synchronize_compare_metric_button
380 end
381
382 on_current_archive_checked (a_file_exist: BOOLEAN; a_valid: BOOLEAN; a_archive: LIST [EB_METRIC_ARCHIVE_NODE]) is
383 -- Action to be performed when archive file specified in `current_metric_archive_text' is checked
384 -- If `a_valid' is True, `a_archive' is the archive, otherwise, `a_archive' is Void.
385 do
386 is_current_metric_archive_ok := a_valid
387 if a_valid then
388 current_metric_archive_text.set_foreground_color (default_foreground_color)
389 current_metric_archive_text.set_tooltip (tooltip_from_archive (a_archive))
390 else
391 current_metric_archive_text.set_foreground_color (red_color)
392 if a_file_exist then
393 current_metric_archive_text.set_tooltip (metric_names.t_selected_archive_not_valid)
394 else
395 current_metric_archive_text.set_tooltip (metric_names.t_selected_file_not_exists)
396 end
397 end
398 last_current_archive := a_archive
399 synchronize_compare_metric_button
400 end
401
402 on_compare_archives is
403 -- Action to be performed when user wants to compare selected archives
404 local
405 l_cur_archive: STRING
406 l_ref_archive: STRING
407 l_ref_arc: LIST [EB_METRIC_ARCHIVE_NODE]
408 l_cur_arc: LIST [EB_METRIC_ARCHIVE_NODE]
409 l_is_ref_ok: BOOLEAN
410 l_is_cur_ok: BOOLEAN
411 l_error: BOOLEAN
412 do
413 prepare_file_name (reference_metric_archive_text)
414 l_ref_archive ?= reference_metric_archive_text.data
415 if l_ref_archive /= Void then
416 l_ref_archive.left_adjust
417 l_ref_archive.right_adjust
418 if not l_ref_archive.is_empty then
419 l_ref_arc := load_archive (l_ref_archive)
420 l_error := not is_last_load_successful
421 l_is_ref_ok := is_last_load_successful
422 end
423 else
424 l_error := True
425 end
426 if not l_error then
427 prepare_file_name (current_metric_archive_text)
428 l_cur_archive ?= current_metric_archive_text.data
429 if l_cur_archive /= Void then
430 l_cur_archive.left_adjust
431 l_cur_archive.right_adjust
432 if not l_cur_archive.is_empty then
433 l_cur_arc := load_archive (l_cur_archive)
434 l_error := not is_last_load_successful
435 l_is_cur_ok := is_last_load_successful
436 end
437 else
438 l_error := True
439 end
440 end
441 if not l_error then
442 if l_is_ref_ok or l_is_cur_ok then
443 metric_tool.register_archive_result_for_display (l_ref_arc, l_cur_arc)
444 metric_tool.go_to_result
445 else
446 display_message (metric_names.t_no_archive_selected)
447 end
448 end
449 end
450
451 on_pointer_double_click_on_metric_item (a_name: STRING) is
452 -- Action to be performed when pointer double clicks on a metric named `a_name' in `metric_selector'.
453 require
454 a_name_attached: a_name /= Void
455 do
456 if metric_manager.has_metric (a_name) then
457 metric_tool.go_to_definition (metric_manager.metric_with_name (a_name), False)
458 end
459 end
460
461 feature -- Notification
462
463 update (a_observable: QL_OBSERVABLE; a_data: ANY) is
464 -- Notification from `a_observable' indicating that `a_data' changed.
465 local
466 l_data: BOOLEAN_REF
467 do
468 metric_selector.load_metrics (True)
469 metric_selector.try_to_selected_last_metric
470 if metric_selector.last_selected_metric = Void then
471 metric_selector.select_first_metric
472 end
473 if a_data /= Void then
474 l_data ?= a_data
475 if l_data /= Void then
476 if l_data.item then
477 -- This is an update when Eiffel compilation starts.
478 if is_archive_running then
479 on_stop_metric_evaluation_button_pressed
480 end
481 synchronize_when_compile_start
482 else
483 -- This is an update when Eiffel compilation stops.
484 synchronize_when_compile_stop
485 end
486 end
487 end
488 end
489
490 feature {NONE} -- Implementation
491
492 open_file_dialog: EB_FILE_OPEN_DIALOG
493 -- Dialog to select a file
494
495 last_domain_generator_tick_interval: NATURAL_64
496 -- Last stored tick domain generator interval
497
498 internal_timer: EV_TIMEOUT
499 -- Internal timer
500
501 reference_archive_timer: EV_TIMEOUT
502 -- Timer used in `reference_metric_archive_text'
503
504 current_archive_timer: EV_TIMEOUT
505 -- Timer used in `current_metric_archive_text'
506
507 check_archive_validity (a_text_field: EV_TEXT_FIELD; a_action: PROCEDURE [ANY, TUPLE [a_file_exist: BOOLEAN; a_archive_valid: BOOLEAN; a_archive: LIST [EB_METRIC_ARCHIVE_NODE]]]; a_timer: EV_TIMEOUT) is
508 -- Check vadility of archive defined in `a_text_field' and invoke `a_action' after checking.
509 -- If the specified archive file doesn't exist, the first boolean argument (a_file_exist) of `a_action' will be False, otherwise True.
510 -- If the archive file exists, the second will be set to True if the archive is valid, otherwise False.
511 -- If `a_archive_valid' is True, `a_archive' is the archive, otherwise, `a_archive' is Void.
512 require
513 a_text_field_attached: a_text_field /= Void
514 a_action_attached: a_action /= Void
515 a_timer_attached: a_timer /= Void
516 local
517 l_file: RAW_FILE
518 l_file_name: STRING
519 l_archive: LIST [EB_METRIC_ARCHIVE_NODE]
520 do
521 l_file_name := a_text_field.text
522 create l_file.make (l_file_name)
523 if l_file.exists and then not l_file.is_directory then
524 l_archive := metric_manager.load_metric_archive (l_file_name)
525 a_action.call ([True, not metric_manager.has_error, l_archive])
526 metric_manager.clear_last_error
527 else
528 a_action.call ([False, False, Void])
529 end
530 a_timer.set_interval (0)
531 end
532
533 check_selected_metrics (a_list: LIST [STRING]): STRING is
534 -- Check vadility of metrics whose names are in `a_list'.
535 -- Return message if error occurs, otherwise, return Void.
536 require
537 a_list_attached: a_list /= Void
538 do
539 if a_list.is_empty then
540 Result := metric_names.e_no_metric_is_selected
541 else
542 from
543 a_list.start
544 until
545 a_list.after or Result /= Void
546 loop
547 if not metric_manager.is_metric_valid (a_list.item) then
548 Result := metric_names.t_metric + " %"" + a_list.item + "%" " + metric_names.t_metric_is_not_valid
549 else
550 a_list.forth
551 end
552 end
553 end
554 end
555
556 metric_archive_from_file (a_file_name: STRING): HASH_TABLE [EB_METRIC_ARCHIVE_NODE, STRING] is
557 -- Metric archive from file `a_file_name'.
558 -- Key is metric name, value is the metric archive for that metric.
559 -- Void if error occurs.
560 local
561 l_archive: LIST [EB_METRIC_ARCHIVE_NODE]
562 l_metric_manager: like metric_manager
563 do
564 l_metric_manager := metric_manager
565 l_metric_manager.clear_last_error
566 l_archive := l_metric_manager.load_metric_archive (a_file_name)
567 if not l_metric_manager.has_error then
568 create Result.make (l_archive.count)
569 from
570 l_archive.start
571 until
572 l_archive.after
573 loop
574 Result.force (l_archive.item, l_archive.item.metric_name.as_lower)
575 l_archive.forth
576 end
577 end
578 end
579
580 merge_archive_from_archive_table (a_tbl: HASH_TABLE [EB_METRIC_ARCHIVE_NODE, STRING]; a_list: LIST [EB_METRIC_ARCHIVE_NODE]): LIST [EB_METRIC_ARCHIVE_NODE] is
581 -- Merge new metric archive information into `a_tbl'.
582 require
583 a_tbl_attached: a_tbl /= Void
584 a_list_attached: a_list /= Void
585 do
586 from
587 a_list.start
588 until
589 a_list.after
590 loop
591 a_tbl.force (a_list.item, a_list.item.metric_name.as_lower)
592 a_list.forth
593 end
594 create {LINKED_LIST [EB_METRIC_ARCHIVE_NODE]} Result.make
595 from
596 a_tbl.start
597 until
598 a_tbl.after
599 loop
600 Result.extend (a_tbl.item_for_iteration)
601 a_tbl.forth
602 end
603 ensure
604 result_attached: Result /= Void
605 end
606
607 setup_metric_evaluation_callback (a_domain_generator: QL_DOMAIN_GENERATOR) is
608 -- Setup metric evaluation callback, because when metric is running, we want to keep GUI alive.
609 require
610 a_domain_generator_attached: a_domain_generator /= Void
611 do
612 last_domain_generator_tick_interval := a_domain_generator.interval
613 a_domain_generator.set_interval (20)
614 a_domain_generator.tick_actions.wipe_out
615 a_domain_generator.tick_actions.extend (agent on_stop_metric_evaluation)
616 a_domain_generator.tick_actions.extend (agent on_process_gui)
617 is_cancel_evaluation_requested := False
618 stop_btn.enable_sensitive
619 run_btn.disable_sensitive
620 new_archive_file_name_text.disable_sensitive
621 new_archive_browse_btn.disable_sensitive
622 clean_btn.disable_sensitive
623 end
624
625 synchronize_after_metric_evaluation (a_domain_generator: QL_DOMAIN_GENERATOR) is
626 -- Synchronize domain generator after metric evaluation.
627 require
628 a_domain_generator_attached: a_domain_generator /= Void
629 do
630 a_domain_generator.tick_actions.wipe_out
631 a_domain_generator.set_interval (last_domain_generator_tick_interval)
632 stop_btn.disable_sensitive
633 run_btn.enable_sensitive
634 new_archive_file_name_text.enable_sensitive
635 new_archive_browse_btn.enable_sensitive
636 if is_new_archive_file_selected and then is_new_archive_file_exists then
637 clean_btn.enable_sensitive
638 end
639 end
640
641 synchronize_compare_metric_button is
642 -- Synchronize `compare_btn'.
643 do
644 if is_reference_metric_archive_ok or is_current_metric_archive_ok then
645 compare_btn.enable_sensitive
646 else
647 compare_btn.disable_sensitive
648 end
649 end
650
651 red_color: EV_COLOR is
652 -- Red color
653 do
654 Result := (create {EV_STOCK_COLORS}).red
655 ensure
656 result_attached: Result /= Void
657 end
658
659 default_foreground_color: EV_COLOR is
660 -- Default foreground_color is
661 do
662 Result := (create {EV_STOCK_COLORS}).default_foreground_color
663 ensure
664 result_attached: Result /= Void
665 end
666
667 tooltip_from_archive (a_archive: LIST [EB_METRIC_ARCHIVE_NODE]): STRING is
668 -- Tooltip from `a_archive' describing how many metric are archived in `a_archive' and what are they.
669 require
670 a_archive_attached: a_archive /= Void
671 local
672 l_temp_str: STRING
673 l_cnt: INTEGER
674 do
675 create Result.make (512)
676 l_cnt := a_archive.count
677 if l_cnt > 1 then
678 Result.append ("There are ")
679 l_temp_str := " metrics in archive:%N"
680 else
681 Result.append ("There is ")
682 if l_cnt = 0 then
683 l_temp_str := " metric in archive."
684 else
685 l_temp_str := " metric in archive:%N"
686 end
687 end
688 Result.append (l_cnt.out)
689 Result.append (l_temp_str)
690 if l_cnt > 0 then
691 from
692 a_archive.start
693 until
694 a_archive.after
695 loop
696 Result.append ("%T")
697 Result.append (a_archive.item.metric_name)
698 Result.append (": ")
699 Result.append (a_archive.item.value.out)
700 Result.append ("%N")
701 a_archive.forth
702 end
703 end
704 end
705
706 prepare_file_name (a_text_field: EV_TEXT_FIELD) is
707 -- Prepare file name specified in `a_text_field'.
708 require
709 a_text_field_attached: a_text_field /= Void
710 local
711 url_address, http, ftp, file: STRING
712 l_is_file: BOOLEAN
713 do
714 url_address := a_text_field.text.twin
715 a_text_field.set_data (Void)
716 if url_address /= Void and then not url_address.is_empty then
717 http := url_address.substring (1, 7).as_lower
718 ftp := url_address.substring (1, 6).as_lower
719 file := url_address.substring (1, 7).as_lower
720 if equal (file, "file://") then
721 l_is_file := True
722 url_address := url_address.substring (8, url_address.count)
723 elseif equal (ftp, "ftp://") or equal (http, "http://") then
724 else
725 l_is_file := True
726 end
727 else
728 l_is_file := True
729 end
730 if l_is_file then
731 -- It is a local file.
732 a_text_field.set_data (url_address)
733 else
734 -- It is a network address.
735 if a_text_field = current_metric_archive_text then
736 a_text_field.set_data (save_file_from_url (url_address, "transferred_current_archive.xml"))
737 elseif a_text_field = reference_metric_archive_text then
738 a_text_field.set_data (save_file_from_url (url_address, "transferred_reference_archive.xml"))
739 end
740 end
741 end
742
743 save_file_from_url (a_url_address: STRING; a_target_file_name: STRING): STRING is
744 -- Save file from url address `a_url_address' and return the saved file name in local machine.
745 require
746 a_url_address_attached: a_url_address /= Void
747 a_target_file_name_attached: a_target_file_name /= Void
748 local
749 file_name: FILE_NAME
750 target_file: STRING
751 directory: DIRECTORY
752 file: PLAIN_TEXT_FILE
753 error_dialog: EB_INFORMATION_DIALOG
754 do
755 create directory.make (metric_manager.userdefined_metrics_path)
756 if not directory.exists then
757 directory.create_dir
758 end
759 create file_name.make_from_string (metric_manager.userdefined_metrics_path + operating_environment.directory_separator.out + a_target_file_name)
760 create file.make (file_name)
761
762 if file.exists then
763 create confirm_dialog.make_with_text_and_actions ("Remote file will be loaded in:%N" + file_name +
764 "%NThis file already exists. Overwrite?", actions_array)
765 confirm_dialog.show_modal_to_window (metric_tool.development_window.window)
766 end
767 if not file.exists or overwrite then
768 target_file := "file://" + file_name
769 transfer_manager_builder.set_timeout (10)
770 transfer_manager_builder.wipe_out
771 transfer_manager_builder.add_transaction (a_url_address, target_file)
772 if not transfer_manager_builder.last_added_source_correct then
773 create error_dialog.make_with_text ("Unable to read remote file.%NPlease check URL:%N" + a_url_address)
774 error_dialog.show_modal_to_window (metric_tool.development_window.window)
775 elseif not transfer_manager_builder.last_added_target_correct then
776 create error_dialog.make_with_text ("Unable to load remote file in:%N" + file_name +
777 "Please make sure file does not exist or is writable.")
778 error_dialog.show_modal_to_window (metric_tool.development_window.window)
779 else
780 transfer_manager_builder.build_manager
781 metric_tool.development_window.window.set_pointer_style (metric_tool.development_window.Wait_cursor)
782 transfer_manager_builder.transfer
783 metric_tool.development_window.window.set_pointer_style (metric_tool.development_window.Standard_cursor)
784 if transfer_manager_builder.transfer_succeeded then
785 Result := file_name
786 else
787 create error_dialog.make_with_text ("Unable to transfer remote file.%NReason: "
788 + transfer_manager_builder.error_reason)
789 error_dialog.show_modal_to_window (metric_tool.development_window.window)
790 end
791 end
792 end
793 end
794
795 feature -- Overwritting
796
797 overwrite: BOOLEAN
798 -- Overwrite file?
799
800 confirm_dialog: EV_CONFIRMATION_DIALOG
801 -- Dialog to confirm file overwritting.
802
803 actions_array: ARRAY [PROCEDURE [ANY, TUPLE]] is
804 -- Actions to be performed for `confirm_dialog'.
805 do
806 create Result.make (1, 2)
807 Result.put (agent overwrite_action, 1)
808 Result.put (agent abort_overwrite_action, 2)
809 ensure
810 filled_array: Result @ 1 /= Void and Result @ 2 /= Void
811 end
812
813 overwrite_action is
814 -- Action to be performed on clicking on `yes_button' in `confirm_dialog'.
815 do
816 overwrite := True
817 end
818
819 abort_overwrite_action is
820 -- Action to be performed on clicking on `no_button' in `confirm_dialog'.
821 do
822 overwrite := False
823 end
824
825 display_message (a_msg: STRING) is
826 -- Display error message `a_msg'.
827 require
828 a_msg_attached: a_msg /= Void
829 local
830 l_dlg: EV_ERROR_DIALOG
831 do
832 create l_dlg.make_with_text (a_msg)
833 l_dlg.set_buttons_and_actions (<<metric_names.t_ok>>, <<agent do_nothing>>)
834 l_dlg.show_relative_to_window (metric_tool.development_window.window)
835 end
836
837 load_archive (a_file_name: STRING): LIST [EB_METRIC_ARCHIVE_NODE] is
838 -- Load archive from file `a_file_name'.
839 require
840 a_file_name_attached: a_file_name /= Void
841 do
842 metric_manager.clear_last_error
843 Result := metric_manager.load_metric_archive (a_file_name)
844 is_last_load_successful := not metric_manager.has_error
845 if not is_last_load_successful then
846 display_error_message
847 end
848 end
849
850 invariant
851 open_file_dialog_attached: open_file_dialog /= Void
852 internal_timer_attached: internal_timer /= Void
853 reference_archive_timer_attached: reference_archive_timer /= Void
854 current_archive_timer_attched: current_archive_timer /= Void
855 domain_selector_attached: domain_selector /= Void
856 metric_selector_attached: metric_selector /= Void
857
858 indexing
859 copyright: "Copyright (c) 1984-2006, Eiffel Software"
860 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
861 licensing_options: "http://www.eiffel.com/licensing"
862 copying: "[
863 This file is part of Eiffel Software's Eiffel Development Environment.
864
865 Eiffel Software's Eiffel Development Environment is free
866 software; you can redistribute it and/or modify it under
867 the terms of the GNU General Public License as published
868 by the Free Software Foundation, version 2 of the License
869 (available at the URL listed under "license" above).
870
871 Eiffel Software's Eiffel Development Environment is
872 distributed in the hope that it will be useful, but
873 WITHOUT ANY WARRANTY; without even the implied warranty
874 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
875 See the GNU General Public License for more details.
876
877 You should have received a copy of the GNU General Public
878 License along with Eiffel Software's Eiffel Development
879 Environment; if not, write to the Free Software Foundation,
880 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
881 ]"
882 source: "[
883 Eiffel Software
884 356 Storke Road, Goleta, CA 93117 USA
885 Telephone 805-685-1006, Fax 805-685-6869
886 Website http://www.eiffel.com
887 Customer support http://support.eiffel.com
888 ]"
889
890 end -- class EB_METRIC_ARCHIVE_PANEL
891

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23