/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/tools/debugging/es_watch_tool.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/tools/debugging/es_watch_tool.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61949 - (show annotations)
Sun Jul 30 06:01:22 2006 UTC (13 years, 4 months ago) by manus
File size: 35660 byte(s)
EiffelStudio docking branch. It only contains modified classes needed to get the docking version of EiffelStudio.
1 indexing
2 description: "Tool that evaluates expressions in the debugger"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: "$Author$"
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 ES_WATCH_TOOL
11
12 inherit
13 REFACTORING_HELPER
14
15 ES_OBJECTS_GRID_MANAGER
16
17 ES_NOTEBOOK_ATTACHABLE
18
19 EB_TOOL
20 redefine
21 menu_name,
22 pixmap,
23 close
24 end
25
26 EB_CONSTANTS
27 export
28 {NONE} all
29 end
30
31 EB_RECYCLABLE
32 export
33 {NONE} all
34 end
35
36 SHARED_DEBUG
37 export
38 {NONE} all
39 end
40
41 EB_SHARED_DEBUG_TOOLS
42 export
43 {NONE} all
44 end
45
46 EB_SHARED_PIXMAPS
47 export
48 {NONE} all
49 end
50
51 DEBUGGING_UPDATE_ON_IDLE
52 redefine
53 real_update, update
54 end
55
56 EB_SHARED_PREFERENCES
57 export
58 {NONE} all
59 end
60
61 create
62 make_with_title
63
64 feature {NONE} -- Initialization
65
66 make_with_title (a_manager: like manager; a_title: like title) is
67 do
68 if a_title = Void or else a_title.is_empty then
69 set_title (interface_names.t_Watch_tool)
70 else
71 set_title (a_title)
72 end
73 make (a_manager)
74 end
75
76 build_interface is
77 -- Build all the tool's widgets.
78 local
79 esgrid: ES_OBJECTS_GRID
80 do
81 create watched_items.make (10)
82
83 create esgrid.make_with_name ("Watches", "watches")
84 esgrid.enable_multiple_row_selection
85 esgrid.set_column_count_to (5)
86 esgrid.set_columns_layout_from_string_preference (
87 preferences.debug_tool_data.grid_column_layout_preference_for (esgrid.id),
88 <<
89 [1, True, False, 150, "Expression"],
90 [2, True, False, 150, "Value"],
91 [3, True, False, 100, "Type"],
92 [4, True, False, 80, "Address"],
93 [5, True, False, 200, "Context"]
94 >>
95 )
96
97 -- Set scrolling preferences.
98 esgrid.set_mouse_wheel_scroll_size (preferences.editor_data.mouse_wheel_scroll_size)
99 esgrid.set_mouse_wheel_scroll_full_page (preferences.editor_data.mouse_wheel_scroll_full_page)
100 esgrid.set_scrolling_common_line_count (preferences.editor_data.scrolling_common_line_count)
101 preferences.editor_data.mouse_wheel_scroll_size_preference.typed_change_actions.extend (
102 agent esgrid.set_mouse_wheel_scroll_size)
103 preferences.editor_data.mouse_wheel_scroll_full_page_preference.typed_change_actions.extend (
104 agent esgrid.set_mouse_wheel_scroll_full_page)
105 preferences.editor_data.scrolling_common_line_count_preference.typed_change_actions.extend (
106 agent esgrid.set_scrolling_common_line_count)
107
108 esgrid.row_select_actions.extend (agent on_row_selected)
109 esgrid.row_deselect_actions.extend (agent on_row_deselected)
110 esgrid.drop_actions.extend (agent on_element_drop)
111 esgrid.key_press_actions.extend (agent key_pressed)
112 esgrid.key_press_string_actions.extend (agent string_key_pressed)
113
114 watches_grid := esgrid
115 initialize_watches_grid_layout (preferences.debug_tool_data.is_watches_grids_layout_managed_preference)
116
117 create_update_on_idle_agent
118 end
119
120 build_mini_toolbar is
121 -- Build associated tool bar
122 local
123 tbb: EV_TOOL_BAR_BUTTON
124 scmd: EB_STANDARD_CMD
125 do
126 create mini_toolbar
127
128 create scmd.make
129 scmd.set_mini_pixmap (pixmaps.mini_pixmaps.toolbar_dropdown_icon)
130 scmd.set_tooltip ("Open Watch tool menu")
131 scmd.add_agent (agent open_watch_menu (mini_toolbar, 0, 0))
132 scmd.enable_sensitive
133 mini_toolbar.extend (scmd.new_mini_toolbar_item)
134
135 create create_expression_cmd.make
136 create_expression_cmd.set_mini_pixmap (pixmaps.mini_pixmaps.new_expression_icon)
137 create_expression_cmd.set_tooltip (interface_names.e_new_expression)
138 create_expression_cmd.add_agent (agent define_new_expression)
139 create_expression_cmd.enable_sensitive
140 mini_toolbar.extend (create_expression_cmd.new_mini_toolbar_item)
141
142 create edit_expression_cmd.make
143 edit_expression_cmd.set_mini_pixmap (pixmaps.mini_pixmaps.general_edit_icon)
144 edit_expression_cmd.set_tooltip (interface_names.e_edit_expression)
145 edit_expression_cmd.add_agent (agent edit_expression)
146 tbb := edit_expression_cmd.new_mini_toolbar_item
147 mini_toolbar.extend (tbb)
148
149 create toggle_state_of_expression_cmd.make
150 toggle_state_of_expression_cmd.set_mini_pixmap (pixmaps.mini_pixmaps.general_toogle_icon)
151 toggle_state_of_expression_cmd.set_tooltip (interface_names.e_toggle_state_of_expressions)
152 toggle_state_of_expression_cmd.add_agent (agent toggle_state_of_selected)
153 tbb := toggle_state_of_expression_cmd.new_mini_toolbar_item
154 mini_toolbar.extend (tbb)
155
156 create slices_cmd.make (Current)
157 slices_cmd.enable_sensitive
158 mini_toolbar.extend (slices_cmd.new_mini_toolbar_item)
159
160 create hex_format_cmd.make (agent set_hexadecimal_mode (?))
161 hex_format_cmd.enable_sensitive
162 mini_toolbar.extend (hex_format_cmd.new_mini_toolbar_item)
163
164 create pretty_print_cmd.make
165 pretty_print_cmd.enable_sensitive
166 mini_toolbar.extend (pretty_print_cmd.new_mini_toolbar_item)
167
168 create delete_expression_cmd.make
169 delete_expression_cmd.set_mini_pixmap (pixmaps.mini_pixmaps.general_delete_icon)
170 delete_expression_cmd.set_tooltip (interface_names.e_remove_expressions)
171 delete_expression_cmd.add_agent (agent remove_selected)
172 tbb := delete_expression_cmd.new_mini_toolbar_item
173 tbb.drop_actions.extend (agent remove_object_line)
174 tbb.drop_actions.set_veto_pebble_function (agent is_removable )
175 mini_toolbar.extend (tbb)
176
177 create move_up_cmd.make
178 move_up_cmd.set_mini_pixmap (pixmaps.mini_pixmaps.general_up_icon)
179 move_up_cmd.set_tooltip ("Move item up")
180 move_up_cmd.add_agent (agent move_selected (watches_grid, -1))
181 tbb := move_up_cmd.new_mini_toolbar_item
182 mini_toolbar.extend (tbb)
183
184 create move_down_cmd.make
185 move_down_cmd.set_mini_pixmap (pixmaps.mini_pixmaps.general_down_icon)
186 move_down_cmd.set_tooltip ("Move item down")
187 move_down_cmd.add_agent (agent move_selected (watches_grid, +1))
188 tbb := move_down_cmd.new_mini_toolbar_item
189 mini_toolbar.extend (tbb)
190
191 --| Attach the slices_cmd to the objects grid
192 watches_grid.set_slices_cmd (slices_cmd)
193 ensure
194 mini_toolbar_exists: mini_toolbar /= Void
195 end
196
197 build_explorer_bar_item (explorer_bar: EB_EXPLORER_BAR) is
198 -- Build the associated explorer bar item and
199 -- Add it to `explorer_bar'
200 do
201 if mini_toolbar = Void then
202 build_mini_toolbar
203 end
204 create explorer_bar_item.make_with_mini_toolbar (explorer_bar, widget, title, False, mini_toolbar)
205 explorer_bar_item.set_menu_name (menu_name)
206 if pixmap /= Void then
207 explorer_bar_item.set_pixmap (pixmap)
208 end
209 explorer_bar.add (explorer_bar_item)
210 end
211
212 build_notebook_item (nb: ES_NOTEBOOK) is
213 do
214 if mini_toolbar = Void then
215 build_mini_toolbar
216 end
217 create notebook_item.make_with_mini_toolbar (nb, widget, title, mini_toolbar)
218 notebook_item.drop_actions.extend (agent on_element_drop)
219 notebook_item.pointer_button_pressed_actions.extend (agent on_notebook_item_pointer_button_pressed)
220 nb.extend (notebook_item)
221 end
222
223 feature {EB_DEBUGGER_MANAGER} -- Closing
224
225 close is
226 do
227 Precursor
228 if notebook_item /= Void then
229 unattach_from_notebook
230 end
231 end
232
233 feature -- Access
234
235 mini_toolbar: EV_TOOL_BAR
236 -- Associated mini toolbar.
237
238 widget: EV_WIDGET is
239 -- Widget representing Current.
240 do
241 Result := watches_grid
242 end
243
244 title: STRING
245 -- Title of the tool.
246
247 menu_name: STRING is
248 -- Name as it may appear in a menu.
249 do
250 Result := interface_names.m_Watch_tool
251 end
252
253 pixmap: EV_PIXMAP is
254 -- Pixmap as it may appear in toolbars and menus.
255 do
256 end
257
258 can_refresh: BOOLEAN
259 -- Should we display data when a stone is set?
260
261 feature -- Change
262
263 set_title (a_title: like title) is
264 require
265 title_valid: a_title /= Void and then not a_title.is_empty
266 do
267 title := a_title
268 ensure
269 title_set: title.is_equal (a_title)
270 end
271
272 feature -- Properties setting
273
274 set_hexadecimal_mode (v: BOOLEAN) is
275 do
276 watches_grid.set_hexadecimal_mode (v)
277 end
278
279 feature {ES_OBJECTS_GRID_SLICES_CMD} -- Query
280
281 objects_grid_item (addr: STRING): ES_OBJECTS_GRID_LINE is
282 local
283 r: INTEGER
284 lrow: EV_GRID_ROW
285 litem: ES_OBJECTS_GRID_LINE
286 ladd: STRING
287 do
288 from
289 r := 1
290 until
291 r > watches_grid.row_count or Result /= Void
292 loop
293 lrow := watches_grid.row (r)
294 if lrow.parent_row = Void then
295 litem ?= grid_data_from_widget (lrow)
296 if litem /= Void then
297 ladd := litem.object_address
298 if ladd /= Void and then ladd.is_equal (addr) then
299 Result := litem
300 end
301 end
302 end
303 r := r + 1
304 end
305 end
306
307 feature -- Status setting
308
309 set_stone (a_stone: STONE) is
310 -- Assign `a_stone' as new stone.
311 local
312 cst: CALL_STACK_STONE
313 do
314 if can_refresh then
315 cst ?= a_stone
316 if cst /= Void and then application.is_stopped then
317 fixme ("Check if we should not call `update' to benefit real_update optimisation")
318 if
319 not Application.is_dotnet
320 or else not Application.imp_dotnet.callback_notification_processing
321 then
322 refresh_context_expressions
323 end
324 end
325 end
326 end
327
328 enable_refresh is
329 -- Set `can_refresh' to `True'.
330 do
331 can_refresh := True
332 end
333
334 disable_refresh is
335 -- Set `can_refresh' to `False'.
336 do
337 can_refresh := False
338 end
339
340 refresh is
341 -- Class has changed in `development_window'.
342 do
343 end
344
345 prepare_for_debug is
346 -- Remove obsolete expressions from `Current'.
347 local
348 l_expr: EB_EXPRESSION
349 witem: like watched_item_from
350 do
351 clean_watched_grid
352 from
353 watched_items.start
354 until
355 watched_items.after
356 loop
357 witem := watched_items.item
358
359 l_expr := witem.expression
360 if not l_expr.is_still_valid then
361 watched_items.remove
362 else
363 l_expr.set_unevaluated
364 add_watched_item_to_grid (witem, watches_grid)
365 watched_items.forth
366 end
367 end
368
369 update
370 end
371
372 change_manager_and_explorer_bar (a_manager: EB_TOOL_MANAGER; an_explorer_bar: EB_EXPLORER_BAR) is
373 -- Change the window and explorer bar `Current' is in.
374 require
375 a_manager_exists: a_manager /= Void
376 an_explorer_bar_exists: an_explorer_bar /= Void
377 do
378 if explorer_bar_item.is_visible then
379 explorer_bar_item.close
380 end
381 explorer_bar_item.recycle
382 manager := a_manager
383 set_explorer_bar (an_explorer_bar)
384 end
385
386 feature -- Memory management
387
388 recycle is
389 -- Recycle `Current', but leave `Current' in an unstable state,
390 -- so that we know whether we're still referenced or not.
391 do
392 reset_update_on_idle
393 pretty_print_cmd.end_debug
394 if explorer_bar_item /= Void then
395 explorer_bar_item.recycle
396 end
397 recycle_expressions
398 watches_grid.reset_layout_manager
399 clean_watched_grid
400 end
401
402 recycle_expressions is
403 -- Recycle
404 local
405 witem: ES_OBJECTS_GRID_EXPRESSION_LINE
406 do
407 from
408 watched_items.start
409 until
410 watched_items.after
411 loop
412 witem := watched_items.item
413 witem.recycle
414 check witem.expression /= Void end
415 if not witem.expression.is_still_valid then
416 watched_items.remove
417 else
418 watched_items.forth
419 end
420 end
421 end
422
423 feature {NONE} -- add new expression from the grid
424
425 new_expression_row: EV_GRID_ROW
426 -- Grid row which should always be at the end of the grid
427 -- this is used to enter new expression easily
428
429 ensure_last_row_is_new_expression_row is
430 -- ensure
431 local
432 glab: ES_OBJECTS_GRID_EMPTY_EXPRESSION_CELL
433 do
434 if
435 new_expression_row = Void
436 or else new_expression_row.is_destroyed
437 or else new_expression_row.parent = Void
438 then
439 new_expression_row := watches_grid.extended_new_row
440 create glab.make_with_text ("...")
441 grid_cell_set_tooltip (glab, "Click here to add a new expression")
442
443 new_expression_row.set_item (1, glab)
444 glab.pointer_double_press_actions.force_extend (agent glab.activate)
445 glab.apply_actions.extend (agent add_new_expression_for_context)
446 set_up_complete_possibilities_provider (glab)
447 elseif new_expression_row.index < watches_grid.row_count then
448 grid_move_to_end_of_grid (new_expression_row)
449 end
450 watches_grid_empty := False
451 ensure
452 new_expression_row.index = watches_grid.row_count
453 end
454
455 add_new_expression_for_context (s: STRING_32) is
456 local
457 expr: EB_EXPRESSION
458 do
459 if valid_expression_text (s) then
460 create expr.make_for_context (s)
461 add_expression (expr)
462 end
463 end
464
465 valid_expression_text (s: STRING_32): BOOLEAN is
466 do
467 Result := s /= Void and then not s.has ('%R') and not s.has ('%N')
468 end
469
470 feature {NONE} -- Event handling
471
472 open_watch_menu (w: EV_WIDGET; ax, ay: INTEGER) is
473 local
474 m: EV_MENU
475 mi: EV_MENU_ITEM
476 do
477 if notebook_item /= Void then
478 create m
479 create mi.make_with_text_and_action ("Create new watch", agent open_new_created_watch_tool)
480 m.extend (mi)
481 if Eb_debugger_manager.watch_tool_list.count > 1 then
482 create mi.make_with_text_and_action ("Close " + title, agent Eb_debugger_manager.close_watch_tool (Current))
483 m.extend (mi)
484 end
485
486 m.show_at (w, ax, ay)
487 end
488 end
489
490 open_new_created_watch_tool is
491 local
492 wt: like Current
493 do
494 if notebook_item /= Void then
495 Eb_debugger_manager.create_new_watch_tool_inside_notebook (manager, notebook_item.parent)
496 wt := Eb_debugger_manager.watch_tool_list.last
497 if wt /= Void then
498 if
499 wt.notebook_item /= Void
500 and then wt.notebook_item.tab /= Void
501 then
502 wt.notebook_item.tab.enable_select
503 end
504 end
505 wt.update
506 end
507 end
508
509 define_new_expression is
510 -- Create a new expression.
511 local
512 dlg: EB_EXPRESSION_DEFINITION_DIALOG
513 ce: EB_EDITOR
514 l_text: STRING
515 do
516 ce := Eb_debugger_manager.debugging_window.current_editor
517 if ce /= Void and then ce.has_selection then
518 l_text := ce.string_selection
519 if l_text.has ('%N') then
520 l_text := Void
521 end
522 end
523 if l_text /= Void and then not l_text.is_empty then
524 create dlg.make_with_expression_text (l_text)
525 else
526 create dlg.make_new_expression
527 end
528 dlg.set_callback (agent add_expression_with_dialog (dlg))
529 dlg.show_modal_to_window (Eb_debugger_manager.debugging_window.window)
530 end
531
532 edit_expression is
533 -- Edit a selected expression.
534 local
535 rows: ARRAYED_LIST [EV_GRID_ROW]
536 sel: EV_GRID_ROW
537 expr: EB_EXPRESSION
538 dlg: EB_EXPRESSION_DEFINITION_DIALOG
539 l_item: like watched_item_from
540 do
541 rows := grid_selected_top_rows (watches_grid)
542 if not rows.is_empty then
543 from
544 rows.start
545 until
546 rows.after
547 loop
548 sel := rows.item
549 l_item := watched_item_from (sel)
550 if l_item /= Void then
551 expr := l_item.expression
552 check expr /= Void end
553 create dlg.make_with_expression (expr)
554 dlg.set_callback (agent refresh_expression (expr))
555 dlg.show_modal_to_window (Eb_debugger_manager.debugging_window.window)
556 end
557 rows.forth
558 end
559 end
560 end
561
562 toggle_state_of_selected is
563 -- Toggle state of the selected expressions from the list.
564 local
565 rows: LIST [EV_GRID_ROW]
566 l_expr: EB_EXPRESSION
567 sel_index: INTEGER
568 l_item: like watched_item_from
569 do
570 rows := grid_selected_top_rows (watches_grid)
571 if not rows.is_empty then
572 sel_index := rows.first.index
573 end
574 from
575 rows.start
576 until
577 rows.after
578 loop
579 if rows.item.parent /= Void and then rows.item.parent_row = Void then
580 l_item := watched_item_from (rows.item)
581 if l_item = Void then
582 check False end
583 else
584 l_expr := l_item.expression
585 if l_expr /= Void and then l_expr.evaluation_disabled then
586 l_expr.enable_evaluation
587 else
588 l_expr.disable_evaluation
589 end
590 refresh_watched_item (l_item)
591 end
592 end
593 rows.forth
594 end
595 if not rows.is_empty then
596 if watches_grid.row_count >= sel_index then
597 watches_grid.row (sel_index).enable_select
598 else
599 on_row_deselected (Void)
600 end
601 end
602 end
603
604 move_processing: BOOLEAN
605
606 move_selected (grid: ES_OBJECTS_GRID; offset: INTEGER) is
607 local
608 sel_rows: LIST [EV_GRID_ROW]
609 sel: EV_GRID_ROW
610 sel_index: INTEGER
611 new_index, to_index: INTEGER
612 line: ES_OBJECTS_GRID_EXPRESSION_LINE
613 do
614 if not move_processing then
615 move_processing := True --| To avoid concurrent move
616 sel_rows := grid_selected_top_rows (watches_grid)
617 if not sel_rows.is_empty then
618 sel := sel_rows.first
619 if sel.parent_row = Void then
620 sel_index := sel.index
621 line ?= sel.data
622 if line /= Void then
623 watched_items.start
624 watched_items.search (line)
625 if not watched_items.exhausted then
626 check watched_items.item = line end
627 new_index := watched_items.index + offset
628 if new_index < 1 then
629 new_index := 1
630 elseif new_index > watched_items.count then
631 new_index := watched_items.count
632 end
633 watched_items.swap (new_index)
634 end
635 end
636 to_index := grid.grid_move_top_row_node_by (grid, sel_index, offset)
637 grid.remove_selection
638 sel.enable_select
639 end
640 end
641 move_processing := False
642 ensure_last_row_is_new_expression_row
643 end
644 end
645
646 is_removable (a: ANY): BOOLEAN is
647 do
648 Result := True
649 end
650
651 remove_object_line (a: ANY) is
652 do
653 remove_selected
654 end
655
656 remove_selected is
657 -- Remove the selected expressions from the list.
658 local
659 rows: LIST [EV_GRID_ROW]
660 sel_index: INTEGER
661 do
662 rows := grid_selected_top_rows (watches_grid)
663 if not rows.is_empty then
664 sel_index := rows.first.index
665 end
666 from
667 rows.start
668 until
669 rows.after
670 loop
671 if rows.item.parent_row = Void then
672 remove_expression_row (rows.item)
673 end
674 rows.forth
675 end
676 ensure_last_row_is_new_expression_row
677 if not rows.is_empty then
678 if watches_grid.row_count >= sel_index then
679 if sel_index > 1 and sel_index = new_expression_row.index then
680 sel_index := sel_index - 1
681 end
682 watches_grid.row (sel_index).enable_select
683 else
684 on_row_deselected (Void)
685 end
686 end
687 end
688
689 remove_expression_row (row: EV_GRID_ROW) is
690 local
691 l_item: like watched_item_from
692 do
693 l_item ?= watched_item_from (row)
694 watched_items.prune_all (l_item)
695 watches_grid.row (row.index).clear
696 watches_grid.remove_row (row.index)
697 end
698
699 on_element_drop (s: CLASSC_STONE) is
700 -- Something was dropped in `ev_list'.
701 local
702 fst: FEATURE_STONE
703 cst: CLASSC_STONE
704 ost: OBJECT_STONE
705 fost: FEATURED_OBJECT_STONE
706 dlg: EB_EXPRESSION_DEFINITION_DIALOG
707 oname: STRING
708 do
709 fost ?= s
710 if fost /= Void then
711 oname := fost.feature_name
712 if ev_application.ctrl_pressed then
713 else
714 create dlg.make_with_expression_on_object (fost.object_address, fost.feature_name)
715 end
716 else
717 fst ?= s
718 if fst /= Void then
719 oname := fst.feature_name
720 create dlg.make_with_expression_text (fst.feature_name)
721 if fst.e_class /= Void then
722 dlg.set_class_text (fst.e_class)
723 end
724 else
725 ost ?= s
726 if ost /= Void then
727 oname := ost.name + ": " + ost.object_address
728 if ev_application.ctrl_pressed then
729 add_object (ost, oname)
730 else
731 create dlg.make_with_named_object (ost.object_address, oname)
732 end
733 else
734 cst ?= s
735 if cst /= Void then
736 create dlg.make_with_class (cst.e_class)
737 end
738 end
739 end
740 end
741 if dlg /= Void then
742 dlg.set_callback (agent add_expression_with_dialog (dlg))
743 dlg.show_modal_to_window (Eb_debugger_manager.debugging_window.window)
744 end
745 end
746
747 on_row_selected (row: EV_GRID_ROW) is
748 -- An item in the list of expression was selected.
749 do
750 if row.parent_row = Void then
751 delete_expression_cmd.enable_sensitive
752 edit_expression_cmd.enable_sensitive
753 toggle_state_of_expression_cmd.enable_sensitive
754 move_up_cmd.enable_sensitive
755 move_down_cmd.enable_sensitive
756 else
757 delete_expression_cmd.disable_sensitive
758 edit_expression_cmd.disable_sensitive
759 toggle_state_of_expression_cmd.disable_sensitive
760 move_up_cmd.disable_sensitive
761 move_down_cmd.disable_sensitive
762 end
763 if row = new_expression_row then
764 delete_expression_cmd.disable_sensitive
765 edit_expression_cmd.disable_sensitive
766 toggle_state_of_expression_cmd.disable_sensitive
767 move_up_cmd.disable_sensitive
768 move_down_cmd.disable_sensitive
769 end
770 end
771
772 on_row_deselected (row: EV_GRID_ROW) is
773 -- An item in the list of expression was selected.
774 do
775 if row /= Void and then row.parent_row = Void then
776 delete_expression_cmd.enable_sensitive
777 edit_expression_cmd.enable_sensitive
778 toggle_state_of_expression_cmd.enable_sensitive
779 move_up_cmd.enable_sensitive
780 move_down_cmd.enable_sensitive
781 else
782 delete_expression_cmd.disable_sensitive
783 edit_expression_cmd.disable_sensitive
784 toggle_state_of_expression_cmd.disable_sensitive
785 move_up_cmd.disable_sensitive
786 move_down_cmd.disable_sensitive
787 end
788 end
789
790 key_pressed (k: EV_KEY) is
791 -- A key was pressed in `ev_list'.
792 local
793 ost: OBJECT_STONE
794 do
795 if k /= Void then
796 inspect k.code
797 when {EV_KEY_CONSTANTS}.key_delete then
798 remove_selected
799 when {EV_KEY_CONSTANTS}.key_f2 then
800 edit_expression
801 when {EV_KEY_CONSTANTS}.key_c , {EV_KEY_CONSTANTS}.key_insert then
802 if
803 ev_application.ctrl_pressed
804 and not ev_application.alt_pressed
805 and not ev_application.shift_pressed
806 then
807 update_clipboard_string_with_selection (watches_grid)
808 end
809 when {EV_KEY_CONSTANTS}.key_v then
810 if
811 ev_application.ctrl_pressed
812 and not ev_application.alt_pressed
813 and not ev_application.shift_pressed
814 then
815 set_expression_from_clipboard (watches_grid)
816 end
817 when {EV_KEY_CONSTANTS}.key_e then
818 if
819 ev_application.ctrl_pressed
820 and not ev_application.alt_pressed
821 and not ev_application.shift_pressed
822 then
823 if watches_grid.selected_rows.count > 0 then
824 ost ?= watches_grid.grid_pebble_from_row (watches_grid.selected_rows.first)
825 pretty_print_cmd.set_stone (ost)
826 end
827 end
828 when {EV_KEY_CONSTANTS}.key_page_up then
829 if
830 ev_application.ctrl_pressed
831 and not ev_application.alt_pressed
832 and not ev_application.shift_pressed
833 then
834 move_selected (watches_grid, -1)
835 end
836 when {EV_KEY_CONSTANTS}.key_page_down then
837 if
838 ev_application.ctrl_pressed
839 and not ev_application.alt_pressed
840 and not ev_application.shift_pressed
841 then
842 move_selected (watches_grid, +1)
843 end
844 when {EV_KEY_CONSTANTS}.key_right then
845 expand_selected_rows (watches_grid)
846 when {EV_KEY_CONSTANTS}.key_left then
847 collapse_selected_rows (watches_grid)
848 when {EV_KEY_CONSTANTS}.key_enter then
849 if
850 not ev_application.ctrl_pressed
851 and not ev_application.alt_pressed
852 and not ev_application.shift_pressed
853 then
854 enter_key_pressed (watches_grid)
855 end
856 else
857 end
858 end
859 end
860
861 string_key_pressed (s: STRING_32) is
862 -- A key was pressed in `watches_grid'.
863 local
864 row: EV_GRID_ROW
865 rows: ARRAYED_LIST [EV_GRID_ROW]
866 empty_expression_cell: ES_OBJECTS_GRID_EMPTY_EXPRESSION_CELL
867 do
868 if
869 not ev_application.ctrl_pressed
870 and not ev_application.alt_pressed
871 then
872 rows := grid_selected_top_rows (watches_grid)
873 if not rows.is_empty then
874 row := rows.first
875 if
876 watches_grid.col_name_index <= row.count
877 then
878 empty_expression_cell ?= row.item (watches_grid.col_name_index)
879 if empty_expression_cell /= Void then
880 if s.is_equal ("%N") then
881 empty_expression_cell.activate
882 else
883 empty_expression_cell.activate_with_string (s)
884 end
885 end
886 end
887 end
888 end
889 end
890
891 enter_key_pressed (a_grid: ES_OBJECTS_GRID) is
892 -- A [enter] key was pressed in `watches_grid'.
893 local
894 row: EV_GRID_ROW
895 rows: ARRAYED_LIST [EV_GRID_ROW]
896 expression_cell: ES_OBJECTS_GRID_EXPRESSION_CELL
897 do
898 if
899 not ev_application.ctrl_pressed
900 and not ev_application.alt_pressed
901 and not ev_application.shift_pressed
902 then
903 rows := grid_selected_top_rows (watches_grid)
904 if not rows.is_empty then
905 row := rows.first
906 if
907 watches_grid.col_name_index <= row.count
908 then
909 expression_cell ?= row.item (watches_grid.col_name_index)
910 if expression_cell /= Void then
911 expression_cell.activate
912 end
913 end
914 end
915 end
916 end
917
918 add_expression_with_dialog (dlg: EB_EXPRESSION_DEFINITION_DIALOG) is
919 -- Add a new expression defined by `dlg'.
920 local
921 l_expr: EB_EXPRESSION
922 do
923 l_expr := dlg.new_expression
924 add_expression (l_expr)
925 end
926
927 add_object (ost: OBJECT_STONE; oname: STRING) is
928 require
929 ost_ot_void: ost /= Void
930 oname /= Void
931 application_is_running: Application.is_running
932 local
933 expr: EB_EXPRESSION
934 do
935 Application.status.keep_object (ost.object_address)
936 create expr.make_as_object (ost.dynamic_class , ost.object_address)
937 expr.set_name (oname)
938 add_expression (expr)
939 end
940
941 add_expression (expr: EB_EXPRESSION) is
942 local
943 expr_item: like watched_item_from
944 do
945 if expr.evaluation_disabled then
946 -- Nothing special
947 else
948 if application.is_running and application.is_stopped then
949 expr.evaluate
950 else
951 expr.set_unevaluated
952 end
953 end
954 expr_item := new_watched_item_from_expression (expr, watches_grid)
955 watched_items.extend (expr_item)
956
957 if expr_item /= Void and then expr_item.row /= Void then
958 if
959 not expr_item.compute_grid_display_done
960 and then (expr /= Void and then (expr.evaluation_disabled or not expr.is_evaluated))
961 then
962 expr_item.compute_grid_display
963 end
964 watches_grid.remove_selection
965 expr_item.row.ensure_visible
966 expr_item.row.enable_select
967 end
968 end
969
970 feature {NONE} -- Event handling on notebook item
971
972 on_notebook_item_pointer_button_pressed (ax, ay, ab: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
973 require
974 notebook_item /= Void
975 do
976 if
977 ab = 3
978 and then not Ev_application.ctrl_pressed
979 and then not Ev_application.shift_pressed
980 and then not Ev_application.alt_pressed
981 then
982 open_watch_menu (notebook_item.parent.widget, ax, ay)
983 end
984 end
985
986 feature {NONE} -- Implementation: internal data
987
988 delete_expression_cmd: EB_STANDARD_CMD
989 -- Command that deletes one or more rows from the list of expressions.
990
991 create_expression_cmd: EB_STANDARD_CMD
992 -- Command that creates a new expression.
993
994 edit_expression_cmd: EB_STANDARD_CMD
995 -- Command that creates a new expression.
996
997 toggle_state_of_expression_cmd: EB_STANDARD_CMD
998 -- Command that enable/disable a new expression
999
1000 move_up_cmd, move_down_cmd: EB_STANDARD_CMD
1001 -- Move selected item up or down.
1002
1003
1004 watches_grid: ES_OBJECTS_GRID
1005 -- Graphical representation of the list of expressions to evaluate.
1006
1007 update_agent: PROCEDURE [ANY, TUPLE]
1008 -- Agent that is put in the idle_actions to update the call stack after a while.
1009
1010 watched_items: ARRAYED_LIST [like watched_item_from]
1011 -- List of items that are displayed
1012 -- ie: mostly ES_OBJECTS_GRID_EXPRESSION_LINE
1013
1014 feature -- Grid management
1015
1016 watches_grid_empty: BOOLEAN
1017
1018 clean_watched_grid is
1019 do
1020 if not watches_grid_empty then
1021 -- if record_layout_on_next_clean then
1022 -- watches_grid.record_layout
1023 -- record_layout_on_next_clean := False
1024 -- end
1025 watches_grid.remove_and_clear_all_rows
1026 watches_grid_empty := True
1027 end
1028 end
1029
1030 record_grid_layout is
1031 do
1032 if process_record_layout_on_next_recording_request then
1033 watches_grid.record_layout
1034 process_record_layout_on_next_recording_request := False
1035 end
1036 end
1037
1038 feature {NONE} -- grid Layout Implementation
1039
1040 keep_object_reference_fixed (addr: STRING) is
1041 do
1042 if debugger_manager.application_is_executing then
1043 application.status.keep_object_for_gui (addr)
1044 end
1045 end
1046
1047 initialize_watches_grid_layout (pv: BOOLEAN_PREFERENCE) is
1048 require
1049 not is_grid_layout_initialized
1050 watches_grid.layout_manager = Void
1051 local
1052 l_grid: ES_OBJECTS_GRID
1053 do
1054 l_grid := watches_grid
1055 l_grid.initialize_layout_management (pv)
1056 check
1057 l_grid.layout_manager /= Void
1058 end
1059
1060 -- l_grid.layout_manager.set_row_is_ready_for_identification_agent (agent l_grid.row_is_ready_for_grid_objects_identification)
1061 -- l_grid.layout_manager.set_identification_agent (agent l_grid.grid_objects_id_name_from_row)
1062 -- l_grid.layout_manager.set_value_agent (agent l_grid.grid_objects_id_value_from_row)
1063 -- l_grid.layout_manager.set_on_difference_callback (agent l_grid.grid_objects_on_difference_cb)
1064 is_grid_layout_initialized := True
1065 end
1066
1067 is_grid_layout_initialized: BOOLEAN
1068
1069 process_record_layout_on_next_recording_request: BOOLEAN
1070
1071 feature -- Access
1072
1073 refresh_watched_item (a_item: like watched_item_from) is
1074 -- Refresh expression grid row item
1075 require
1076 a_item_not_void: a_item /= Void
1077 a_item_has_expression: a_item.expression /= Void
1078 a_item_attached: a_item.row /= Void
1079 local
1080 l_row: EV_GRID_ROW
1081 l_expr: EB_EXPRESSION
1082 do
1083 l_row := a_item.row
1084 l_expr := a_item.expression
1085 if l_expr.evaluation_disabled then
1086 -- nothing special
1087 else
1088 if Application.is_running and Application.is_stopped then
1089 l_expr.evaluate
1090 else
1091 l_expr.set_unevaluated
1092 end
1093 end
1094 a_item.refresh
1095 end
1096
1097 feature -- Update
1098
1099 update is
1100 -- Display current execution status.
1101 local
1102 l_status: APPLICATION_STATUS
1103 do
1104 cancel_process_real_update_on_idle
1105 l_status := Application.status
1106 if l_status /= Void then
1107 process_real_update_on_idle (l_status.is_stopped)
1108 else
1109 watches_grid.reset_layout_recorded_values
1110 end
1111 end
1112
1113 feature {NONE} -- Auto-completion
1114
1115 set_up_complete_possibilities_provider (a_item: ES_OBJECTS_GRID_EMPTY_EXPRESSION_CELL) is
1116 -- Set up code completion possibilities.
1117 local
1118 l_provider: EB_NORMAL_COMPLETION_POSSIBILITIES_PROVIDER
1119 do
1120 create l_provider.make (Void, Void, false)
1121 a_item.set_completion_possibilities_provider (l_provider)
1122 end
1123
1124 feature {NONE} -- Implementation
1125
1126 real_update (dbg_was_stopped: BOOLEAN) is
1127 -- Display current execution status.
1128 -- dbg_was_stopped is ignore if Application/Debugger is not running
1129 local
1130 eval: BOOLEAN
1131 l_expr: EB_EXPRESSION
1132 l_item: like watched_item_from
1133 do
1134 Precursor {DEBUGGING_UPDATE_ON_IDLE} (dbg_was_stopped)
1135 if application.is_running and application.is_stopped and dbg_was_stopped then
1136 eval := True
1137 end
1138 watches_grid.remove_selection
1139 if
1140 watches_grid.row_count > 0
1141 and not eval
1142 and process_record_layout_on_next_recording_request
1143 then
1144 process_record_layout_on_next_recording_request := False
1145 watches_grid.record_layout
1146 end
1147
1148 from
1149 watched_items.start
1150 until
1151 watched_items.after
1152 loop
1153 l_item := watched_items.item
1154 l_item.request_evaluation (False)
1155 check l_item.row /= Void end
1156 l_expr := l_item.expression
1157 if l_expr.evaluation_disabled then
1158 -- Nothing special
1159 else
1160 if eval then
1161 l_item.request_evaluation (True)
1162 else
1163 l_expr.set_unevaluated
1164 end
1165 end
1166 if l_item.row = Void then
1167 check
1168 should_not_occurred: False
1169 end
1170 l_item.attach_to_row (watches_grid.extended_new_row)
1171 end
1172 l_item.request_refresh
1173 watched_items.forth
1174 end
1175 ensure_last_row_is_new_expression_row
1176 on_row_deselected (Void) -- Reset toolbar buttons
1177 if eval then
1178 watches_grid.restore_layout
1179 end
1180 process_record_layout_on_next_recording_request := eval
1181 end
1182
1183 standard_grid_label (s: STRING): EV_GRID_LABEL_ITEM is
1184 do
1185 create Result
1186 Result.set_text (s)
1187 end
1188
1189 Cst_expression_col: INTEGER is 1
1190
1191 Cst_type_col: INTEGER is 2
1192
1193 Cst_value_col: INTEGER is 3
1194
1195 Cst_context_col: INTEGER is 4
1196
1197 Cst_nota_col: INTEGER is 5
1198
1199 new_watched_item_from_expression (expr: EB_EXPRESSION; a_grid: ES_OBJECTS_GRID): like watched_item_from is
1200 require
1201 expr /= Void
1202 a_grid /= Void
1203 do
1204 create Result.make_with_expression (expr, a_grid)
1205 add_watched_item_to_grid (Result, a_grid)
1206 end
1207
1208 add_watched_item_to_grid (witem: like watched_item_from; a_grid: ES_OBJECTS_GRID) is
1209 require
1210 witem /= Void
1211 a_grid /= Void
1212 do
1213 if witem.is_attached_to_row then
1214 witem.unattach
1215 end
1216 witem.attach_to_row (a_grid.extended_new_row)
1217 ensure_last_row_is_new_expression_row
1218 end
1219
1220 show_text_in_popup (txt: STRING; x, y, button: INTEGER; gi: EV_GRID_ITEM) is
1221 --
1222 -- (export status {NONE})
1223 local
1224 w_dlg: EB_INFORMATION_DIALOG
1225 do
1226 create w_dlg.make_with_text (txt)
1227 w_dlg.show_modal_to_window (Eb_debugger_manager.debugging_window.window)
1228 end
1229
1230 watched_item_from (row: EV_GRID_ROW): ES_OBJECTS_GRID_EXPRESSION_LINE is
1231 local
1232 ctlr: ES_GRID_ROW_CONTROLLER
1233 do
1234 Result ?= row.data
1235 if Result = Void then
1236 ctlr ?= row.data
1237 if ctlr /= Void then
1238 Result ?= ctlr.data
1239 end
1240 end
1241 end
1242
1243 watched_item_for_expression (expr: EB_EXPRESSION): like watched_item_from is
1244 require
1245 valid_expr: expr /= Void
1246 local
1247 do
1248 from
1249 watched_items.start
1250 until
1251 watched_items.after or Result /= Void
1252 loop
1253 Result := watched_items.item
1254 if Result.expression /= expr then
1255 Result := Void
1256 end
1257 watched_items.forth
1258 end
1259 end
1260
1261 refresh_expression (expr: EB_EXPRESSION) is
1262 require
1263 valid_expr: expr /= Void
1264 local
1265 l_item: like watched_item_from
1266 do
1267 l_item := watched_item_for_expression (expr)
1268 check l_item /= Void end
1269 refresh_watched_item (l_item)
1270 end
1271
1272 refresh_context_expressions is
1273 -- Refresh the value and display of context-related expressions.
1274 require
1275 application_stopped: application.is_running and application.is_stopped
1276 local
1277 r: INTEGER
1278 row: EV_GRID_ROW
1279 expr: EB_EXPRESSION
1280 l_item: like watched_item_from
1281 do
1282 if watches_grid.row_count > 0 then
1283 from
1284 r := 1
1285 until
1286 r > watches_grid.row_count
1287 loop
1288 row := watches_grid.row (r)
1289 if row.parent_row = Void then
1290 l_item := watched_item_from (row)
1291 if l_item /= Void then
1292 expr ?= l_item.expression
1293 if expr.on_context then
1294 if expr.evaluation_disabled then
1295 expr.set_unevaluated
1296 else
1297 expr.evaluate
1298 end
1299 refresh_watched_item (l_item)
1300 end
1301 end
1302 end
1303 r := r + 1
1304 end
1305 end
1306 end
1307
1308 Unevaluated: STRING is ""
1309 -- String that is displayed in the "expression" column when an expression was not evaluated.
1310 -- expressions.count = watches_grid.row_count
1311
1312 invariant
1313
1314 not_void_delete_expression_cmd: delete_expression_cmd /= Void
1315
1316 indexing
1317 copyright: "Copyright (c) 1984-2006, Eiffel Software"
1318 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
1319 licensing_options: "http://www.eiffel.com/licensing"
1320 copying: "[
1321 This file is part of Eiffel Software's Eiffel Development Environment.
1322
1323 Eiffel Software's Eiffel Development Environment is free
1324 software; you can redistribute it and/or modify it under
1325 the terms of the GNU General Public License as published
1326 by the Free Software Foundation, version 2 of the License
1327 (available at the URL listed under "license" above).
1328
1329 Eiffel Software's Eiffel Development Environment is
1330 distributed in the hope that it will be useful, but
1331 WITHOUT ANY WARRANTY; without even the implied warranty
1332 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1333 See the GNU General Public License for more details.
1334
1335 You should have received a copy of the GNU General Public
1336 License along with Eiffel Software's Eiffel Development
1337 Environment; if not, write to the Free Software Foundation,
1338 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1339 ]"
1340 source: "[
1341 Eiffel Software
1342 356 Storke Road, Goleta, CA 93117 USA
1343 Telephone 805-685-1006, Fax 805-685-6869
1344 Website http://www.eiffel.com
1345 Customer support http://support.eiffel.com
1346 ]"
1347
1348 end -- class ES_WATCH_TOOL

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23