/[eiffelstudio]/branches/eth/eve/Src/Eiffel/interface/graphical/tools/autodebug/panels/es_adb_panel_settings.e
ViewVC logotype

Contents of /branches/eth/eve/Src/Eiffel/interface/graphical/tools/autodebug/panels/es_adb_panel_settings.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 95332 - (show annotations)
Fri Jun 27 12:57:49 2014 UTC (5 years, 3 months ago) by maxpei
File size: 20546 byte(s)
Fixed a few bugs in AutoFix and AutoDebug.
1
2 class
3 ES_ADB_PANEL_SETTINGS
4
5 inherit
6
7 ES_ADB_PANEL_SETTINGS_IMP
8 redefine
9 propogate_values_from_ui_to_config,
10 propogate_values_from_config_to_ui
11 end
12
13 ES_ADB_ACTIONS
14 undefine
15 copy,
16 default_create,
17 is_equal
18 end
19
20 create
21 make
22
23 feature{NONE} -- Initialization
24
25 make (a_tool: like tool_panel)
26 -- Initialization
27 require
28 a_tool /= Void
29 do
30 set_tool_panel (a_tool)
31 default_create
32
33 clear_information_display_widget
34 enable_information_display_widget (False)
35 enable_command_invocation_widget (False)
36
37 register_event_handlers
38
39 info_center.extend (Current)
40 end
41
42 feature{NONE} -- Update UI
43
44 clear_information_display_widget
45 -- Clear the contents of config widgets.
46 do
47 evtext_group_to_add.set_text ("")
48 evlist_groups_to_debug.wipe_out
49 evtext_working_directory.set_text ("")
50 evtext_testing_cutoff_time.set_text ("")
51 evtext_testing_seed.set_text ("")
52 evtext_fixing_cutoff_time.set_text ("")
53 evtext_fixing_number_of_fixes.set_text ("")
54 evtext_fixing_passing_tests.set_text ("")
55 evtext_fixing_failing_tests.set_text ("")
56 end
57
58 enable_information_display_widget (a_flag: BOOLEAN)
59 -- Enable/Disable config widgets.
60 do
61 if a_flag then
62 evtext_group_to_add.enable_sensitive
63 on_group_to_add_changed
64 evlist_groups_to_debug.remove_selection
65 evlist_groups_to_debug.enable_sensitive
66 on_list_content_changed
67 evtext_working_directory.enable_sensitive
68 evbutton_browse.enable_sensitive
69 evcombo_testing_session_type.enable_sensitive
70 evtext_testing_cutoff_time.enable_sensitive
71 evtext_testing_seed.enable_sensitive
72 evcheckbutton_testing_use_fixed_seed.enable_sensitive
73 evcombo_start_fixing_type.enable_sensitive
74 evtext_fixing_cutoff_time.enable_sensitive
75 evtext_fixing_number_of_fixes.enable_sensitive
76 evcheckbutton_fixing_contracts.enable_sensitive
77 evcheckbutton_fixing_implementation.enable_sensitive
78 evtext_fixing_passing_tests.enable_sensitive
79 evtext_fixing_failing_tests.enable_sensitive
80 else
81 evtext_group_to_add.disable_sensitive
82 evbutton_add.disable_sensitive
83 evlist_groups_to_debug.remove_selection
84 evlist_groups_to_debug.disable_sensitive
85 evlist_classes_in_group.hide
86 evbutton_remove.disable_sensitive
87 evbutton_remove_all.disable_sensitive
88 evtext_working_directory.disable_sensitive
89 evbutton_browse.disable_sensitive
90 evcombo_testing_session_type.disable_sensitive
91 evtext_testing_cutoff_time.disable_sensitive
92 evtext_testing_seed.disable_sensitive
93 evcheckbutton_testing_use_fixed_seed.disable_sensitive
94 evcombo_start_fixing_type.disable_sensitive
95 evtext_fixing_cutoff_time.disable_sensitive
96 evtext_fixing_number_of_fixes.disable_sensitive
97 evcheckbutton_fixing_contracts.disable_sensitive
98 evcheckbutton_fixing_implementation.disable_sensitive
99 evtext_fixing_passing_tests.disable_sensitive
100 evtext_fixing_failing_tests.disable_sensitive
101 end
102 end
103
104 enable_command_invocation_widget (a_flag: BOOLEAN)
105 -- Enable/Disable all command widgets on the panel.
106 do
107 if a_flag then
108 evbutton_load_config.enable_sensitive
109 evbutton_save_config.enable_sensitive
110 update_evbutton_start (workbench.eiffel_project /= Void and workbench.eiffel_project.successful)
111 else
112 evbutton_load_config.disable_sensitive
113 evbutton_save_config.disable_sensitive
114 evbutton_start.disable_sensitive
115 end
116 end
117
118 update_evbutton_start (a_flag: BOOLEAN)
119 -- Enable/Disable `evbutton_start'.
120 do
121 if a_flag then
122 evbutton_start.enable_sensitive
123 else
124 evbutton_start.disable_sensitive
125 end
126 end
127
128 feature -- ADB Action
129
130 on_project_loaded
131 -- <Precursor>
132 do
133 propogate_values_from_config_to_ui
134
135 enable_information_display_widget (True)
136 enable_command_invocation_widget (True)
137 end
138
139 on_project_unloaded
140 -- <Precursor>
141 do
142 propogate_values_from_ui_to_config
143 config.save
144 config.unload
145
146 enable_information_display_widget (False)
147 enable_command_invocation_widget (False)
148 clear_information_display_widget
149 end
150
151 on_compile_start
152 -- <Precursor>
153 do
154 end
155
156 on_compile_stop
157 -- <Precursor>
158 do
159 end
160
161 on_debugging_start
162 -- <Precursor>
163 do
164 tool_panel.set_external_process_running (True)
165 on_save_settings
166 enable_information_display_widget (False)
167 enable_command_invocation_widget (False)
168 evbutton_start.set_text (button_text_stop)
169 evbutton_start.enable_sensitive
170 end
171
172 on_debugging_stop
173 -- <Precursor>
174 do
175 evbutton_start.set_text (button_text_start)
176 enable_information_display_widget (True)
177 enable_command_invocation_widget (True)
178 tool_panel.set_external_process_running (False)
179 end
180
181 on_testing_start
182 -- <Precursor>
183 do
184 end
185
186 on_test_case_generated (a_test: ES_ADB_TEST)
187 -- <Precursor>
188 do
189 end
190
191 on_testing_stop
192 -- <Precursor>
193 do
194 end
195
196 on_fixing_start (a_fault: ES_ADB_FAULT)
197 -- <Precursor>
198 do
199
200 end
201
202 on_fixing_stop
203 -- <Precursor>
204 do
205 end
206
207 on_continuation_debugging_start
208 -- <Precursor>
209 do
210 on_save_settings
211 enable_information_display_widget (False)
212 enable_command_invocation_widget (False)
213 end
214
215 on_continuation_debugging_stop
216 -- <Precursor>
217 do
218 enable_information_display_widget (True)
219 enable_command_invocation_widget (True)
220 end
221
222 on_valid_fix_found (a_fix: ES_ADB_FIX)
223 -- <Precursor>
224 do
225 end
226
227 on_fix_applied (a_fix: ES_ADB_FIX)
228 -- <Precursor>
229 do
230 end
231
232 on_output (a_line: STRING)
233 -- <Precursor>
234 do
235 end
236
237 feature -- UI Actions
238
239 register_event_handlers
240 -- Register handlers to UI events.
241 local
242 do
243 evtext_group_to_add.change_actions.extend (agent on_group_to_add_changed)
244 evtext_group_to_add.key_press_actions.extend (agent on_group_to_add_enter)
245 evlist_groups_to_debug.select_actions.extend (agent on_select_group)
246 evlist_groups_to_debug.deselect_actions.extend (agent on_deselect_group)
247 evbutton_add.select_actions.extend (agent on_add)
248 evbutton_remove.select_actions.extend (agent on_remove)
249 evbutton_remove_all.select_actions.extend (agent on_remove_all)
250 evbutton_browse.select_actions.extend (agent on_browse)
251 evcheckbutton_testing_use_fixed_seed.select_actions.extend (agent on_use_fixed_seed_change)
252
253 evbutton_load_config.select_actions.extend (agent on_load_settings)
254 evbutton_save_config.select_actions.extend (agent on_save_settings)
255 evbutton_start.select_actions.extend (agent on_start)
256 end
257
258 on_group_to_add_changed
259 -- Action to perform when the text in `evtext_group_to_add' is changed.
260 local
261 l_text: STRING
262 do
263 l_text := evtext_group_to_add.text
264 if not l_text.is_empty then
265 evbutton_add.enable_sensitive
266 else
267 evbutton_add.disable_sensitive
268 end
269 end
270
271 on_group_to_add_enter (a_key: EV_KEY)
272 -- Action to perform when `a_key' is pressed in `evtext_group_to_add'.
273 do
274 if a_key.code = {EV_KEY_CONSTANTS}.key_enter then
275 on_add
276 end
277 end
278
279 on_list_content_changed
280 -- Action to perform when the content of `evlist_groups_to_debug' is changed.
281 do
282 if evlist_groups_to_debug.is_empty then
283 evbutton_remove_all.disable_sensitive
284 evbutton_start.disable_sensitive
285 else
286 evbutton_remove_all.enable_sensitive
287 evbutton_start.enable_sensitive
288 end
289 end
290
291 on_add
292 -- Action to perform when "Add" button is clicked.
293 local
294 l_text: STRING
295 l_group_item: EV_LIST_ITEM
296 do
297 l_text := evtext_group_to_add.text.twin
298 l_text.prune_all (' ')
299 l_text.prune_all ('%T')
300 if not l_text.is_empty then
301 if not config.class_groups.has (l_text) then
302 create l_group_item.make_with_text (l_text)
303 evlist_groups_to_debug.force (l_group_item)
304 config.add_class_group (l_text)
305
306 on_list_content_changed
307 end
308 end
309 evtext_group_to_add.set_text ("")
310 end
311
312 on_select_group
313 -- Action to perform when a group in `evlist_groups_to_debug' is selected.
314 do
315 if attached evlist_groups_to_debug.selected_item as lt_list_item then
316 evbutton_remove.enable_sensitive
317 display_group_detail (lt_list_item.text, True)
318 end
319 end
320
321 on_deselect_group
322 -- Action to perform when a group in `evlist_groups_to_debug' is deselected.
323 do
324 evbutton_remove.disable_sensitive
325 display_group_detail (Void, False)
326 end
327
328 on_remove
329 -- Action to perform when "Remove" button is clicked.
330 local
331 l_text: STRING
332 do
333 if attached evlist_groups_to_debug.selected_item as lt_selected_item then
334 l_text := lt_selected_item.text
335 evlist_groups_to_debug.go_i_th (evlist_groups_to_debug.index_of (lt_selected_item, 1))
336 evlist_groups_to_debug.remove
337 config.remove_class_group (l_text)
338
339 on_list_content_changed
340 end
341 end
342
343 on_remove_all
344 -- Action to perform when "Remove all" button is clicked.
345 do
346 evlist_groups_to_debug.wipe_out
347 config.remove_all_class_groups
348
349 on_list_content_changed
350 end
351
352 on_browse
353 -- Browse for a location.
354 local
355 l_str: STRING
356 l_dir: DIRECTORY
357 l_path: PATH
358 l_file: RAW_FILE
359 l_new_path_str: STRING
360 do
361 -- Get current working directory, or the default one when the current does not exist.
362 if evtext_working_directory /= Void then
363 l_str := evtext_working_directory.text
364 create l_dir.make (l_str)
365 if not l_dir.exists then
366 l_str := Void
367 end
368 end
369 if l_str = Void then
370 l_str := config.default_working_directory.out
371 end
372
373 -- Path string of the new working directory.
374 Browse_dialog.set_start_directory (l_str)
375 Browse_dialog.show_modal_to_window (tool_window)
376 if attached Browse_dialog.path as lt_path and then not lt_path.is_empty then
377 create l_dir.make_with_path (lt_path)
378 if l_dir.is_empty then
379 l_str := lt_path.out
380 else
381 if is_approved_by_user ({ES_ADB_INTERFACE_STRINGS}.Msg_delete_directory_content) then
382 l_dir.recursive_delete
383 l_dir.recursive_create_dir
384 l_str := lt_path.out
385 end
386 end
387 end
388
389 evtext_working_directory.set_text (l_str)
390 end
391
392 on_use_fixed_seed_change
393 -- Action to perform when `evcheckbutton_testing_use_fixed_seed' is selected/deselected.
394 do
395 if evcheckbutton_testing_use_fixed_seed.is_selected then
396 evtext_testing_seed.enable_sensitive
397 else
398 evtext_testing_seed.disable_sensitive
399 end
400 end
401
402 on_load_settings
403 -- Action to perform when `evbutton_load_settings' is clicked.
404 do
405 tool_panel.load_settings
406 end
407
408 on_save_settings
409 -- Action to perform when `evbutton_save_settings' is clicked.
410 do
411 tool_panel.save_settings
412 end
413
414 on_start
415 -- Action to perform when "Start/Stop" button is clicked.
416 local
417 l_text: STRING
418 l_confirmation_dialog: EV_CONFIRMATION_DIALOG
419 l_should_continue: BOOLEAN
420 l_debugging_task: ES_ADB_PROCESS_SEQUENCE_FOR_DEBUGGING
421 do
422 l_text := evbutton_start.text
423 if l_text ~ button_text_start then
424 if info_center.fault_repository.is_empty and then info_center.test_cases.is_empty then
425 l_should_continue := True
426 else
427 l_should_continue := is_approved_by_user ({ES_ADB_INTERFACE_STRINGS}.Msg_remove_existing_debugging_results)
428 end
429 if l_should_continue then
430 info_center.on_debugging_start
431
432 copy_project (workbench.eiffel_project, config.working_directory)
433 if is_project_copied_into_working_dir then
434 create l_debugging_task.make
435 create forwarding_task.make (l_debugging_task)
436 forwarding_task.on_terminate_actions.extend (agent info_center.on_debugging_stop)
437 forwarding_task.start
438 else
439 display_message ({ES_ADB_INTERFACE_STRINGS}.Msg_failed_to_copy_project)
440 info_center.on_debugging_stop
441 end
442 end
443
444 elseif l_text ~ button_text_stop then
445 forwarding_task.cancel
446 info_center.on_debugging_stop
447 end
448 end
449
450 feature{NONE} -- Access
451
452 forwarding_task: ES_ADB_OUTPUT_RETRIEVER
453 -- Task to forward the process output to `info_center'.
454
455 feature{NONE} -- Action implementation
456
457 last_selected_group: STRING
458 -- The group whose classes are displayed in `evlist_classes_in_group'.
459
460 display_group_detail (a_group: STRING; a_show: BOOLEAN)
461 -- Display the classes in `a_group' in `evlist_classes_in_group'.
462 local
463 l_classes: DS_HASH_SET [CLASS_C]
464 l_cursor: DS_HASH_SET_CURSOR [CLASS_C]
465 l_detail: STRING
466 l_detail_item: EV_LIST_ITEM
467 do
468 if a_show then
469
470 if last_selected_group = Void or else a_group /~ last_selected_group then
471 last_selected_group := a_group
472
473 evlist_classes_in_group.wipe_out
474 l_classes := config.groups_to_classes.item (a_group)
475 if l_classes.is_empty then
476 create l_detail_item.make_with_text ("< No class found in the group >")
477 evlist_classes_in_group.force (l_detail_item)
478 else
479 create l_detail.make (64)
480 from
481 l_cursor := l_classes.new_cursor
482 l_cursor.start
483 until
484 l_cursor.after
485 loop
486 if l_cursor.item /= Void then
487 create l_detail_item.make_with_text (l_cursor.item.name_in_upper)
488 evlist_classes_in_group.force (l_detail_item)
489 end
490 l_cursor.forth
491 end
492 end
493 end
494
495 evlist_classes_in_group.show
496 else
497 evlist_classes_in_group.hide
498 end
499 end
500
501 Browse_dialog: EV_DIRECTORY_DIALOG
502 -- Dialog to browse to a library
503 local
504 l_dir: DIRECTORY
505 l_str: STRING
506 once
507 create Result
508 if evtext_working_directory /= Void then
509 l_str := evtext_working_directory.text
510 create l_dir.make (l_str)
511 if not l_dir.exists then
512 l_str := Void
513 end
514 end
515 if l_str = Void then
516 l_str := config.default_working_directory.out
517 end
518 Result.set_start_directory (l_str)
519 ensure
520 result_not_void: Result /= Void
521 end
522
523 feature{NONE} -- UI/Config sync
524
525 propogate_values_from_config_to_ui
526 -- <Precursor>
527 local
528 l_config: like config
529 l_class_cursor: DS_ARRAYED_LIST_CURSOR [STRING]
530 l_list_item: EV_LIST_ITEM
531 do
532 l_config := config
533
534 evlist_groups_to_debug.wipe_out
535 from
536 l_class_cursor := l_config.class_groups.new_cursor
537 l_class_cursor.start
538 until
539 l_class_cursor.after
540 loop
541 create l_list_item.make_with_text (l_class_cursor.item)
542 evlist_groups_to_debug.force (l_list_item)
543 l_class_cursor.forth
544 end
545 on_list_content_changed
546
547 evtext_working_directory.set_text (l_config.working_directory.root_dir.out)
548
549 if l_config.is_each_session_testing_one_class then
550 evcombo_testing_session_type.set_text (combobox_text_test_session_type_one_class)
551 elseif l_config.is_each_session_testing_one_group then
552 evcombo_testing_session_type.set_text (combobox_text_test_session_type_one_group)
553 elseif l_config.is_each_session_testing_all_classes then
554 evcombo_testing_session_type.set_text (combobox_text_test_session_type_all_classes)
555 end
556
557 evtext_testing_cutoff_time.set_text (l_config.max_session_length_for_testing.out)
558 evtext_testing_seed.set_text (l_config.fixed_seed.out)
559 if l_config.should_use_fixed_seed_in_testing then
560 evcheckbutton_testing_use_fixed_seed.enable_select
561 evtext_testing_seed.enable_sensitive
562 else
563 evcheckbutton_testing_use_fixed_seed.disable_select
564 evtext_testing_seed.disable_sensitive
565 end
566
567 if l_config.is_starting_fixing_after_each_testing_session then
568 evcombo_start_fixing_type.set_text (combobox_text_start_fixing_type_after_each_testing_session)
569 elseif l_config.is_starting_fixing_after_all_testing_sessions then
570 evcombo_start_fixing_type.set_text (combobox_text_start_fixing_type_after_all_testing_sessions)
571 elseif l_config.is_starting_fixing_manually then
572 evcombo_start_fixing_type.set_text (combobox_text_start_fixing_type_manually)
573 end
574
575 evtext_fixing_cutoff_time.set_text (l_config.max_session_length_for_fixing.out)
576 evtext_fixing_number_of_fixes.set_text (l_config.max_nbr_fix_candidates.out)
577 if l_config.should_fix_implementation then
578 evcheckbutton_fixing_implementation.enable_select
579 else
580 evcheckbutton_fixing_implementation.disable_select
581 end
582 if l_config.should_fix_contracts then
583 evcheckbutton_fixing_contracts.enable_select
584 else
585 evcheckbutton_fixing_contracts.disable_select
586 end
587 evtext_fixing_passing_tests.set_text (l_config.max_nbr_passing_tests.out)
588 evtext_fixing_failing_tests.set_text (l_config.max_nbr_failing_tests.out)
589 end
590
591 propogate_values_from_ui_to_config
592 -- <Precursor>
593 local
594 l_config: like config
595 l_working_dir: ES_ADB_WORKING_DIRECTORY
596 l_testing_session_type_str: STRING
597 l_start_fixing_type_str: STRING
598 do
599 l_config := config
600
601 propogate_class_groups_from_ui_to_config
602 create l_working_dir.make (create {PATH}.make_from_string (evtext_working_directory.text))
603 l_config.set_working_directory (l_working_dir)
604 l_testing_session_type_str := evcombo_testing_session_type.text
605 if l_testing_session_type_str ~ combobox_text_test_session_type_one_class then
606 config.set_testing_session_type ({ES_ADB_CONFIG}.Testing_session_type_one_class)
607 elseif l_testing_session_type_str ~ combobox_text_test_session_type_one_group then
608 config.set_testing_session_type ({ES_ADB_CONFIG}.Testing_session_type_one_group)
609 elseif l_testing_session_type_str ~ combobox_text_test_session_type_all_classes then
610 config.set_testing_session_type ({ES_ADB_CONFIG}.Testing_session_type_all_classes)
611 end
612 l_config.set_max_session_length_for_testing (evtext_testing_cutoff_time.text.to_integer)
613 l_config.set_use_fixed_seed_in_testing (evcheckbutton_testing_use_fixed_seed.is_selected)
614 l_config.set_fixed_seed (evtext_testing_seed.text.to_integer)
615 l_start_fixing_type_str := evcombo_start_fixing_type.text
616 if l_start_fixing_type_str ~ combobox_text_start_fixing_type_after_each_testing_session then
617 config.set_start_fixing_type ({ES_ADB_CONFIG}.start_fixing_type_after_each_testing_session)
618 elseif l_start_fixing_type_str ~ combobox_text_start_fixing_type_after_all_testing_sessions then
619 config.set_start_fixing_type ({ES_ADB_CONFIG}.start_fixing_type_after_all_testing_sessions)
620 elseif l_start_fixing_type_str ~ combobox_text_start_fixing_type_manually then
621 config.set_start_fixing_type ({ES_ADB_CONFIG}.start_fixing_type_manually)
622 end
623 l_config.set_max_session_length_for_fixing (evtext_fixing_cutoff_time.text.to_integer)
624 l_config.set_max_nbr_fix_candidates (evtext_fixing_number_of_fixes.text.to_integer)
625 l_config.set_fix_implementation (evcheckbutton_fixing_implementation.is_selected)
626 l_config.set_fix_contracts (evcheckbutton_fixing_contracts.is_selected)
627 l_config.set_max_nbr_passing_tests (evtext_fixing_passing_tests.text.to_integer)
628 l_config.set_max_nbr_failing_tests (evtext_fixing_failing_tests.text.to_integer)
629 end
630
631 propogate_class_groups_from_ui_to_config
632 -- Update `config' using the class groups in the UI.
633 local
634 l_config: like config
635 l_list_item: EV_LIST_ITEM
636 l_classes: DS_ARRAYED_LIST [STRING]
637 l_cursor: DS_ARRAYED_LIST_CURSOR [STRING]
638 l_class: STRING
639 do
640 l_config := config
641 l_config.remove_all_class_groups
642
643 from
644 evlist_groups_to_debug.start
645 create l_classes.make_equal (evlist_groups_to_debug.count)
646 until
647 evlist_groups_to_debug.after
648 loop
649 l_list_item := evlist_groups_to_debug.item_for_iteration
650 l_config.add_class_group (l_list_item.text)
651 evlist_groups_to_debug.forth
652 end
653 end
654
655 note
656 copyright: "Copyright (c) 1984-2014, Eiffel Software"
657 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
658 licensing_options: "http://www.eiffel.com/licensing"
659 copying: "[
660 This file is part of Eiffel Software's Eiffel Development Environment.
661
662 Eiffel Software's Eiffel Development Environment is free
663 software; you can redistribute it and/or modify it under
664 the terms of the GNU General Public License as published
665 by the Free Software Foundation, version 2 of the License
666 (available at the URL listed under "license" above).
667
668 Eiffel Software's Eiffel Development Environment is
669 distributed in the hope that it will be useful, but
670 WITHOUT ANY WARRANTY; without even the implied warranty
671 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
672 See the GNU General Public License for more details.
673
674 You should have received a copy of the GNU General Public
675 License along with Eiffel Software's Eiffel Development
676 Environment; if not, write to the Free Software Foundation,
677 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
678 ]"
679 source: "[
680 Eiffel Software
681 5949 Hollister Ave., Goleta, CA 93117 USA
682 Telephone 805-685-1006, Fax 805-685-6869
683 Website http://www.eiffel.com
684 Customer support http://support.eiffel.com
685 ]"
686 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23