/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/windows/eb_development_window.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/windows/eb_development_window.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44503 - (show annotations)
Thu Jul 29 22:59:15 2004 UTC (15 years, 6 months ago) by rogers
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 99033 byte(s)
Added protection for `all_tool_wwindows' to be `Void' within
`remove_all_tool_windows'.

1 indexing
2 description : "Window holding a project tool"
3 date : "$Date$"
4 revision : "$Revision$"
5 author : "Arnaud PICHERY [ aranud@mail.dotcom.fr ]"
6
7 class
8 EB_DEVELOPMENT_WINDOW
9
10 inherit
11 EB_TOOL_MANAGER
12 redefine
13 make,
14 init_size_and_position,
15 window_displayed,
16 init_commands,
17 build_menu_bar,
18 build_menus,
19 build_file_menu,
20 build_edit_menu,
21 build_view_menu,
22 build_tools_menu,
23 build_favorites_menu,
24 refresh,
25 recycle,
26 destroy_imp,
27 destroy
28 end
29
30 EB_FILEABLE
31 redefine
32 set_stone,
33 reset,
34 stone,
35 on_text_saved,
36 perform_check_before_save,
37 check_passed,
38 update_save_symbol
39 select
40 set_stone
41 end
42
43 EB_FILEABLE
44 rename
45 set_stone as old_set_stone
46 export {NONE}
47 old_set_stone
48 redefine
49 reset,
50 stone,
51 on_text_saved,
52 perform_check_before_save,
53 check_passed,
54 update_save_symbol
55 end
56
57
58 -- Shared tools & contexts
59 SHARED_APPLICATION_EXECUTION
60
61 SHARED_EIFFEL_PROJECT
62
63 PROJECT_CONTEXT
64
65 EB_SHARED_MANAGERS
66
67 EB_SHARED_GRAPHICAL_COMMANDS
68
69 -- Resources
70 EB_PROJECT_TOOL_DATA
71 rename
72 initialized as resources_initialized
73 export
74 {NONE} all
75 undefine
76 context_unified_stone
77 end
78
79 EB_GENERAL_DATA
80 rename
81 initialized as resources_initialized
82 export
83 {NONE} all
84 end
85
86 EV_STOCK_PIXMAPS
87
88 EB_CONFIRM_SAVE_CALLBACK
89
90 -- Errors
91 EB_GRAPHICAL_ERROR_MANAGER
92
93 TEXT_OBSERVER
94 redefine
95 on_text_reset, on_text_edited,
96 on_text_back_to_its_last_saved_state,
97 on_text_fully_loaded, on_cursor_moved
98 end
99
100 EB_FORMATTER_DATA
101 rename
102 initialized as resources_initialized
103 export
104 {NONE} all
105 end
106
107 EB_SHARED_EDITOR_DATA
108
109 EV_KEY_CONSTANTS
110 export
111 {NONE} All
112 end
113
114 create {EB_WINDOW_MANAGER}
115 make,
116 make_as_context_tool,
117 make_as_editor
118
119 feature {NONE} -- Initialization
120
121 make_as_context_tool is
122 -- Create a new development window and expand the context tool.
123 do
124 make
125 -- Perform window setting from `show_actions', as the
126 -- resizing executed as a result only works correctly
127 -- while the window is displayed.
128 window.show_actions.extend (agent set_context_mode)
129 end
130
131 set_context_mode is
132 -- Set `current' into context mode, that is the context tool
133 -- maximized, and the non editor panel is hidden.
134 do
135 if not context_tool.shown then
136 context_tool.show
137 end
138 if not unified_stone then
139 toggle_stone_cmd.execute
140 end
141 context_tool.explorer_bar_item.maximize
142 close_all_bars_except (right_panel)
143 end
144
145 make_as_editor is
146 -- Create a new development window and expand the editor tool.
147 do
148 make
149 -- Perform window setting from `show_actions', as the resizing executed
150 -- must be performed after `current' is displayed.
151 window.show_actions.extend (agent (editor_tool.explorer_bar_item).maximize)
152 window.show_actions.extend (agent close_all_bars_except (right_panel))
153 end
154
155 make is
156 -- Create a new development window.
157 do
158 unified_stone := context_unified_stone
159 -- Build the history manager, the address manager, ...
160 create history_manager.make (Current)
161 create address_manager.make (Current, False)
162 build_formatters
163 address_manager.set_formatters (managed_main_formatters)
164
165 -- Init commands, build interface, build menus, ...
166 Precursor
167
168 initialized := False -- Reset the flag since initialization is not yet complete.
169 set_up_accelerators
170
171 -- Create the toolbars.
172 build_toolbars_area
173 container.put_front (toolbars_area)
174 container.disable_item_expand (toolbars_area)
175
176 -- Update widgets visibilities
177 window.show_actions.extend (agent update)
178 status_bar.remove_cursor_position
179 address_manager.set_output_line (status_bar.label)
180
181 -- Finish initializing the main editor formatters
182 end_build_formatters
183
184 address_manager.disable_formatters
185 if Eiffel_project.manager.is_project_loaded then
186 on_project_created
187 on_project_loaded
188 elseif Eiffel_project.manager.is_created then
189 on_project_unloaded
190 on_project_created
191 else
192 on_project_unloaded
193 end
194
195 -- Create feature position table
196 create feature_positions.make (1)
197 feature_positions.compare_objects
198
199 window.move_actions.force_extend (agent window_moved)
200
201 initialized := True
202 is_destroying := False
203 end
204
205 init_size_and_position is
206 -- Initialize window size.
207 local
208 default_width, default_height: INTEGER
209 screen: EV_SCREEN
210 do
211 create screen
212 default_width := width.min (screen.width)
213 default_height := height.min (screen.height)
214 window.set_size (default_width, default_height)
215 end
216
217 window_displayed is
218 -- `Current' has been displayed on screen.
219 do
220 -- Maximize window if needed.
221 if is_maximized then
222 window.maximize
223 end
224 end
225
226 init_commands is
227 -- Initialize commands.
228 local
229 accel: EV_ACCELERATOR
230 do
231 Precursor
232 create toolbarable_commands.make (15)
233
234 -- Open, save, ...
235 toolbarable_commands.extend (new_editor_cmd)
236
237 toolbarable_commands.extend (new_context_tool_cmd)
238
239 create open_cmd.make (Current)
240 toolbarable_commands.extend (open_cmd)
241
242 create save_cmd.make (Current)
243 toolbarable_commands.extend (save_cmd)
244
245 create save_as_cmd.make (Current)
246 if editor_tool = Void or else editor_tool.text_area.is_empty then
247 save_as_cmd.disable_sensitive
248 else
249 save_as_cmd.enable_sensitive
250 end
251
252 create shell_cmd.make (Current)
253 toolbarable_commands.extend (shell_cmd)
254
255 create print_cmd.make (Current)
256 if is_empty then
257 print_cmd.disable_sensitive
258 else
259 print_cmd.enable_sensitive
260 end
261 toolbarable_commands.extend (print_cmd)
262
263 -- Compilation
264 create c_workbench_compilation_cmd.make_workbench (Current)
265 create c_finalized_compilation_cmd.make_finalized (Current)
266 if has_dll_generation then
267 create show_dynamic_lib_tool.make
268 show_dynamic_lib_tool.set_menu_name (Interface_names.m_New_dynamic_lib)
269 show_dynamic_lib_tool.add_agent (agent show_dynamic_library_dialog)
270 end
271 if has_profiler then
272 create show_profiler
273 end
274
275 -- Undo/redo, cut, copy, paste.
276 create undo_cmd.make (Current)
277 toolbarable_commands.extend (undo_cmd)
278
279 create redo_cmd.make (Current)
280 toolbarable_commands.extend (redo_cmd)
281
282 create editor_paste_cmd.make (Current)
283 toolbarable_commands.extend (editor_paste_cmd)
284
285 create new_cluster_cmd.make (Current)
286 toolbarable_commands.extend (new_cluster_cmd)
287
288 create new_class_cmd.make (Current)
289 toolbarable_commands.extend (new_class_cmd)
290
291 create delete_class_cluster_cmd.make (Current)
292 toolbarable_commands.extend (delete_class_cluster_cmd)
293
294 create new_feature_cmd.make (Current)
295 toolbarable_commands.extend (new_feature_cmd)
296
297 create toggle_feature_signature_cmd.make (Current)
298 toolbarable_commands.extend (toggle_feature_signature_cmd)
299
300 create toggle_stone_cmd.make (Current)
301 toolbarable_commands.extend (toggle_stone_cmd)
302
303 create send_stone_to_context_cmd.make
304 send_stone_to_context_cmd.set_pixmaps (Pixmaps.Icon_send_stone_down)
305 send_stone_to_context_cmd.set_tooltip (Interface_names.e_Send_stone_to_context)
306 send_stone_to_context_cmd.set_menu_name (Interface_names.m_Send_stone_to_context)
307 send_stone_to_context_cmd.set_name ("Send_to_context")
308 send_stone_to_context_cmd.add_agent (agent send_stone_to_context)
309 create accel.make_with_key_combination (
310 create {EV_KEY}.make_with_code (Kcst.Key_down), False, True, False
311 )
312 accel.actions.extend (agent send_stone_to_context)
313 send_stone_to_context_cmd.set_accelerator (accel)
314 send_stone_to_context_cmd.disable_sensitive
315 toolbarable_commands.extend (send_stone_to_context_cmd)
316
317 toolbarable_commands.extend (window_manager.minimize_all_cmd)
318 window_manager.minimize_all_cmd.enable_sensitive
319 toolbarable_commands.extend (window_manager.raise_all_cmd)
320 window_manager.raise_all_cmd.enable_sensitive
321
322 toolbarable_commands.extend (New_development_window_cmd)
323 -- Show tool/toolbar commands (will be filled when tools will
324 -- be created)
325 create show_tool_commands.make (7)
326 create show_toolbar_commands.make (3)
327
328 window.focus_in_actions.extend(agent on_focus)
329
330 new_feature_cmd.disable_sensitive
331 toggle_feature_signature_cmd.disable_sensitive
332
333 create editors.make (5)
334 end
335
336 set_up_accelerators is
337 -- Fill the accelerator of `window' with the accelerators of the `toolbarable_commands'.
338 do
339 from
340 toolbarable_commands.start
341 until
342 toolbarable_commands.after
343 loop
344 if toolbarable_commands.item.accelerator /= Void then
345 window.accelerators.extend (toolbarable_commands.item.accelerator)
346 end
347 toolbarable_commands.forth
348 end
349
350 from
351 debugger_manager.toolbarable_commands.start
352 until
353 debugger_manager.toolbarable_commands.after
354 loop
355 if
356 debugger_manager.toolbarable_commands.item.accelerator /= Void
357 then
358 window.accelerators.extend (debugger_manager.toolbarable_commands.item.accelerator)
359 end
360 debugger_manager.toolbarable_commands.forth
361 end
362 end
363
364 build_formatters is
365 -- Build all formatters used.
366 local
367 form: EB_CLASS_TEXT_FORMATTER
368 accel: EV_ACCELERATOR
369 do
370 create managed_class_formatters.make (17)
371 managed_class_formatters.extend (create {EB_CLICKABLE_FORMATTER}.make (Current))
372 managed_class_formatters.extend (create {EB_FLAT_FORMATTER}.make (Current))
373 managed_class_formatters.extend (create {EB_SHORT_FORMATTER}.make (Current))
374 managed_class_formatters.extend (create {EB_FLAT_SHORT_FORMATTER}.make (Current))
375 managed_class_formatters.extend (Void)
376 managed_class_formatters.extend (create {EB_ANCESTORS_FORMATTER}.make (Current))
377 managed_class_formatters.extend (create {EB_DESCENDANTS_FORMATTER}.make (Current))
378 managed_class_formatters.extend (create {EB_CLIENTS_FORMATTER}.make (Current))
379 managed_class_formatters.extend (create {EB_SUPPLIERS_FORMATTER}.make (Current))
380 managed_class_formatters.extend (Void)
381 managed_class_formatters.extend (create {EB_ATTRIBUTES_FORMATTER}.make (Current))
382 managed_class_formatters.extend (create {EB_ROUTINES_FORMATTER}.make (Current))
383 managed_class_formatters.extend (create {EB_DEFERREDS_FORMATTER}.make (Current))
384 managed_class_formatters.extend (create {EB_ONCES_FORMATTER}.make (Current))
385 managed_class_formatters.extend (create {EB_EXTERNALS_FORMATTER}.make (Current))
386 managed_class_formatters.extend (create {EB_EXPORTED_FORMATTER}.make (Current))
387
388 create managed_feature_formatters.make (9)
389 managed_feature_formatters.extend (create {EB_BASIC_FEATURE_FORMATTER}.make (Current))
390 managed_feature_formatters.extend (create {EB_ROUTINE_FLAT_FORMATTER}.make (Current))
391 managed_feature_formatters.extend (Void)
392 managed_feature_formatters.extend (create {EB_CALLERS_FORMATTER}.make (Current))
393 managed_feature_formatters.extend (create {EB_IMPLEMENTERS_FORMATTER}.make (Current))
394 managed_feature_formatters.extend (create {EB_ROUTINE_ANCESTORS_FORMATTER}.make (Current))
395 managed_feature_formatters.extend (create {EB_ROUTINE_DESCENDANTS_FORMATTER}.make (Current))
396 managed_feature_formatters.extend (create {EB_HOMONYMS_FORMATTER}.make (Current))
397
398
399 create managed_main_formatters.make (6)
400
401
402 create {EB_BASIC_TEXT_FORMATTER} form.make (Current)
403 create accel.make_with_key_combination (
404 create {EV_KEY}.make_with_code (Kcst.Key_t),
405 True, False, True)
406 accel.actions.extend (agent form.execute)
407 form.set_accelerator (accel)
408 managed_main_formatters.extend (form)
409
410 create {EB_CLICKABLE_FORMATTER} form.make (Current)
411 create accel.make_with_key_combination (
412 create {EV_KEY}.make_with_code (Kcst.Key_c),
413 True, False, True)
414 accel.actions.extend (agent form.execute)
415 form.set_accelerator (accel)
416 managed_main_formatters.extend (form)
417
418 create {EB_FLAT_FORMATTER} form.make (Current)
419 create accel.make_with_key_combination (
420 create {EV_KEY}.make_with_code (Kcst.Key_f),
421 True, False, True)
422 accel.actions.extend (agent form.execute)
423 form.set_accelerator (accel)
424 managed_main_formatters.extend (form)
425
426 create {EB_SHORT_FORMATTER} form.make (Current)
427 create accel.make_with_key_combination (
428 create {EV_KEY}.make_with_code (Kcst.Key_o),
429 True, False, True)
430 accel.actions.extend (agent form.execute)
431 form.set_accelerator (accel)
432 managed_main_formatters.extend (form)
433
434 create {EB_FLAT_SHORT_FORMATTER} form.make (Current)
435 create accel.make_with_key_combination (
436 create {EV_KEY}.make_with_code (Kcst.Key_i),
437 True, False, True)
438 accel.actions.extend (agent form.execute)
439 form.set_accelerator (accel)
440 managed_main_formatters.extend (form)
441
442 from
443 managed_class_formatters.start
444 until
445 managed_class_formatters.after
446 loop
447 if managed_class_formatters.item /= Void then
448 managed_class_formatters.item.enable_breakpoints
449 end
450 managed_class_formatters.forth
451 end
452 from
453 managed_main_formatters.start
454 until
455 managed_main_formatters.after
456 loop
457 managed_main_formatters.item.enable_breakpoints
458 managed_main_formatters.forth
459 end
460 end
461
462 end_build_formatters is
463 -- Finish initialization of formatters (associate them with editor
464 -- and select a formatter).
465 local
466 f_ind: INTEGER
467 do
468 from
469 managed_class_formatters.start
470 until
471 managed_class_formatters.after
472 loop
473 if managed_class_formatters.item /= Void then
474 managed_class_formatters.item.set_manager (context_tool)
475 end
476 managed_class_formatters.forth
477 end
478 from
479 managed_feature_formatters.start
480 until
481 managed_feature_formatters.after
482 loop
483 if managed_feature_formatters.item /= Void then
484 managed_feature_formatters.item.set_manager (context_tool)
485 end
486 managed_feature_formatters.forth
487 end
488 from
489 managed_main_formatters.start
490 until
491 managed_main_formatters.after
492 loop
493 managed_main_formatters.item.set_editor (editor_tool.text_area)
494 managed_main_formatters.item.on_shown
495 if managed_main_formatters.item.accelerator /= Void then
496 window.accelerators.extend (managed_main_formatters.item.accelerator)
497 end
498 managed_main_formatters.forth
499 end
500
501 (managed_main_formatters @ 1).enable_select;
502
503 -- We now select the correct class formatter.
504 f_ind := default_class_formatter_index
505 --| This takes the formatter separators in consideration.
506 if f_ind > 4 then
507 f_ind := f_ind + 1
508 end
509 if f_ind > 8 then
510 f_ind := f_ind + 1
511 end
512 if f_ind < 1 or f_ind > managed_class_formatters.count then
513 f_ind := 6
514 end
515 (managed_class_formatters @ f_ind).enable_select;
516 -- We now select the correct feature formatter.
517 f_ind := default_feature_formatter_index
518 if f_ind > 2 then
519 f_ind := f_ind + 1
520 end
521 if f_ind < 1 or f_ind > managed_feature_formatters.count then
522 f_ind := 2
523 end
524 managed_class_formatters.i_th (f_ind).enable_select
525 end
526
527 build_tools is
528 -- Build all tools that can take place in this window and put them
529 -- in `left_tools' or `bottom_tools'.
530 local
531 show_cmd: EB_SHOW_TOOL_COMMAND
532 do
533 lock_update
534 -- Build the features tool
535 create features_tool.make (Current, left_panel)
536 left_tools.extend (features_tool.explorer_bar_item)
537 create show_cmd.make (Current, features_tool.explorer_bar_item)
538 show_tool_commands.extend (show_cmd)
539 toolbarable_commands.extend (show_cmd)
540 add_recyclable (features_tool)
541
542 -- Build the cluster tool
543 create cluster_tool.make (Current, left_panel, Current)
544 left_tools.extend (cluster_tool.explorer_bar_item)
545 create show_cmd.make (Current, cluster_tool.explorer_bar_item)
546 show_tool_commands.extend (show_cmd)
547 toolbarable_commands.extend (show_cmd)
548 add_recyclable (cluster_tool)
549
550 -- Build the favorites tool
551 create favorites_tool.make (Current, left_panel, favorites_manager)
552 left_tools.extend (favorites_tool.explorer_bar_item)
553 create show_cmd.make (Current, favorites_tool.explorer_bar_item)
554 show_tool_commands.extend (show_cmd)
555 toolbarable_commands.extend (show_cmd)
556 add_recyclable (favorites_tool)
557
558 -- Build the windows tool (formerly known as Selector tool)
559 create windows_tool.make (Current, left_panel)
560 left_tools.extend (windows_tool.explorer_bar_item)
561 create show_cmd.make (Current, windows_tool.explorer_bar_item)
562 show_tool_commands.extend (show_cmd)
563 toolbarable_commands.extend (show_cmd)
564 add_recyclable (windows_tool)
565
566 -- Build the search tool
567 create search_tool.make (Current, left_panel)
568 left_tools.extend (search_tool.explorer_bar_item)
569 create show_cmd.make (Current, search_tool.explorer_bar_item)
570 show_tool_commands.extend (show_cmd)
571 toolbarable_commands.extend (show_cmd)
572 add_recyclable (search_tool)
573
574 -- Build the editor tool
575 create editor_tool.make (Current, right_panel)
576 bottom_tools.extend (editor_tool.explorer_bar_item)
577 editor_tool.text_area.add_edition_observer(save_cmd)
578 editor_tool.text_area.add_edition_observer(save_as_cmd)
579 editor_tool.text_area.add_edition_observer(print_cmd)
580 editor_tool.text_area.add_edition_observer(Current)
581 editor_tool.text_area.drop_actions.set_veto_pebble_function (agent can_drop)
582 editor_tool.text_area.add_cursor_observer (Current)
583
584 -- The minimim height masks a bug on windows to do with the sizing of the editors
585 -- scroll bars, which were affecting the resizing although they should not have done so.
586 -- Having a default minimum height on the editor is perfectly reasonable.
587 editor_tool.widget.set_minimum_height (20)
588 add_recyclable (editor_tool)
589
590 -- Build the context tool
591 create context_tool.make (Current, right_panel)
592 bottom_tools.extend (context_tool.explorer_bar_item)
593 create show_cmd.make (Current, context_tool.explorer_bar_item)
594 show_tool_commands.extend (show_cmd)
595 toolbarable_commands.extend (show_cmd)
596 add_recyclable (context_tool)
597
598 -- Set the flag "Tools initialized"
599 tools_initialized := True
600
601 -- Initialize undo / redo accelerators
602 create undo_accelerator.make_with_key_combination (create {EV_KEY}.make_with_code (Key_z), True, False, False)
603 if has_case then
604 undo_accelerator.actions.extend (agent (context_tool.editor.undo_cmd).on_ctrl_z)
605 end
606 undo_accelerator.actions.extend (agent undo_cmd.accelerator_execute)
607 create redo_accelerator.make_with_key_combination (create {EV_KEY}.make_with_code (Key_y), True, False, False)
608 if has_case then
609 redo_accelerator.actions.extend (agent (context_tool.editor.redo_cmd).on_ctrl_y)
610 end
611 redo_accelerator.actions.extend (agent redo_cmd.accelerator_execute)
612 window.accelerators.extend (undo_accelerator)
613 window.accelerators.extend (redo_accelerator)
614 unlock_update
615 end
616
617 feature -- Access
618
619 cluster: CLUSTER_I is
620 -- Cluster for current class. Void if none.
621 local
622 classi_stone: CLASSI_STONE
623 cluster_stone: CLUSTER_STONE
624 do
625 classi_stone ?= stone
626 if classi_stone /= Void then
627 Result := classi_stone.cluster
628 end
629 cluster_stone ?= stone
630 if cluster_stone /= Void then
631 Result := cluster_stone.cluster_i
632 end
633 end
634
635 class_name: STRING is
636 -- Name of the current class, Void if none.
637 local
638 class_stone: CLASSI_STONE
639 do
640 class_stone ?= stone
641 if class_stone /= Void then
642 Result := class_stone.class_name
643 end
644 end
645
646 feature_name: STRING is
647 -- Name of the current feature, Void if none.
648 local
649 feature_stone: FEATURE_STONE
650 do
651 feature_stone ?= stone
652 if feature_stone /= Void then
653 Result := feature_stone.feature_name
654 end
655 end
656
657 feature -- Status setting
658
659 disable_sensitive is
660 -- Disable sensitivity of all widgets.
661 do
662 window.disable_sensitive
663 end
664
665 enable_sensitive is
666 -- Enable sensitivity of all widgets.
667 do
668 window.enable_sensitive
669 end
670
671 feature -- Window Settings
672
673 set_initialized is
674 -- Set `initialized' to True.
675 do
676 initialized := True
677 end
678
679 set_text (a_text: STRING) is
680 -- Assign `a_text' to `text'.
681 require
682 a_text_not_void: a_text /= Void
683 do
684 editor_tool.text_area.set_text (a_text)
685 ensure
686 --| FIXME This needs to work: text_assigned: text.is_equal (a_text)
687 --| FIXME changed_flag_set: changed
688 end
689
690 feature -- Window Properties
691
692 changed: BOOLEAN is
693 -- Has something been changed and not yet been saved?
694 do
695 Result := editor_tool.changed
696 end
697
698 is_empty: BOOLEAN is
699 -- Does `Current's text is empty?
700 do
701 Result := editor_tool = Void or else editor_tool.text_area.is_empty
702 end
703
704 text: STRING is
705 -- Text representing Current
706 do
707 Result := editor_tool.text_area.text
708 end
709
710 pixmap: EV_PIXMAP is
711 -- Pixmap representing Current window.
712 do
713 Result := Pixmaps.Icon_development_window
714 end
715
716 preference_tool_is_hidden: BOOLEAN
717 -- Is the preference tool hidden?
718
719 profile_tool_is_hidden: BOOLEAN
720 -- Is the profile tool hidden?
721
722 has_argument_dialog: BOOLEAN is
723 -- Does Current have an associted arguments dialog?
724 do
725 Result := arguments_dialog /= Void
726 end
727
728 feature -- Pulldown Menus
729
730 metric_menu: EV_MENU
731 -- Menu for entries of metric tool.
732
733 format_menu: EV_MENU
734 -- ID Menu for formats.
735 -- Only used during debugging
736
737 compile_menu: EV_MENU
738 -- Compile ID menu.
739
740 debug_menu: EV_MENU
741 -- Debug ID menu.
742
743 active_menus (erase: BOOLEAN) is
744 -- Enable all the menus and if `erase' clean
745 -- the content of the Project tool.
746 do
747 compile_menu.enable_sensitive
748 if erase then
749 output_manager.clear
750 end
751 end
752
753 disable_menus is
754 -- Disable all the menus.
755 do
756 compile_menu.disable_sensitive
757 end
758
759 feature -- Modifiable menus
760
761 melt_menu_item: EV_MENU_ITEM
762 -- Melt menu entry
763
764 freeze_menu_item: EV_MENU_ITEM
765 -- Freeze menu entry
766
767 finalize_menu_item: EV_MENU_ITEM
768 -- Finalize menu entry
769
770 feature -- Update
771
772 synchronize is
773 -- Synchronize stones.
774 local
775 st: STONE
776 do
777 during_synchronization := True
778 favorites_manager.refresh
779 context_tool.synchronize
780 cluster_tool.synchronize
781 history_manager.synchronize
782 features_tool.synchronize
783 if stone /= Void then
784 st := stone.synchronized_stone
785 end
786 editor_tool.text_area.update_click_list (False)
787 set_stone (st)
788 update_save_symbol
789 address_manager.refresh
790 during_synchronization := False
791 end
792
793 synchronize_routine_tool_to_default is
794 -- Synchronize the editor tool to the debug format.
795 do
796 --| FIXME ARNAUD: To be implemented
797 end
798
799 clear_object_tool is
800 -- Clear the contents of the object tool if shown.
801 do
802 --| FIXME ARNAUD: To be implemented
803 end
804
805 build_menus is
806 -- Build all menus displayed in the development window.
807 do
808 -- Build each menu
809 build_file_menu
810 build_edit_menu
811 build_view_menu
812 build_favorites_menu
813 build_project_menu
814 build_debug_menu
815 build_tools_menu
816 build_window_menu
817 build_help_menu
818 -- Build the menu bar.
819 build_menu_bar
820 end
821
822 build_debug_menu is
823 -- Build the `Debug' menu through the debugger_manager.
824 local
825 conv_mit: EB_COMMAND_MENU_ITEM
826 do
827 debug_menu := debugger_manager.new_debug_menu
828 from
829 debug_menu.start
830 until
831 debug_menu.after
832 loop
833 conv_mit ?= debug_menu.item
834 if conv_mit /= Void then
835 add_recyclable (conv_mit)
836 end
837 debug_menu.forth
838 end
839 end
840
841 build_menu_bar is
842 -- Build the menu bar
843 local
844 mb: EV_MENU_BAR
845 do
846 check
847 window.menu_bar /= Void implies not window.menu_bar.is_empty
848 -- If a menu bar was already present, it shouldn't be empty.
849 end
850 if window.menu_bar /= Void then
851 mb := window.menu_bar
852 from
853 mb.start
854 mb.forth
855 until
856 mb.after
857 loop
858 mb.remove
859 end
860 else
861 create mb
862 window.set_menu_bar (mb)
863 mb.extend (file_menu)
864 end
865
866 if Eiffel_project.manager.is_created then
867 mb.extend (edit_menu)
868 mb.extend (view_menu)
869 mb.extend (favorites_menu)
870 mb.extend (project_menu)
871 mb.extend (debug_menu)
872 else
873 mb.extend (view_menu)
874 end
875 mb.extend (tools_menu)
876 mb.extend (window_menu)
877 mb.extend (help_menu)
878 end
879
880 feature -- Graphical Interface
881
882 build_general_toolbar is
883 -- Set up the general toolbar (New, Save, Search, Shell, Undo, Redo, ...)
884 local
885 cell: EV_CELL
886 hsep: EV_HORIZONTAL_SEPARATOR
887 hbox: EV_HORIZONTAL_BOX
888 do
889 -- Create the toolbar.
890 create general_toolbar
891 general_customizable_toolbar := retrieve_general_toolbar (toolbarable_commands)
892 if show_text_in_general_toolbar then
893 general_customizable_toolbar.enable_text_displayed
894 end
895 create hbox
896 hbox.extend (general_customizable_toolbar.widget)
897 hbox.disable_item_expand (general_customizable_toolbar.widget)
898
899 -- Generate the toolbar.
900 general_customizable_toolbar.update_toolbar
901
902 -- Cell to fill in empty space and receive the right click menu holder.
903 create cell
904 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
905 hbox.extend (cell)
906
907 -- Create the vertical layout (separator + toolbar)
908 create hsep
909 general_toolbar.set_padding (2)
910 general_toolbar.extend (hsep)
911 general_toolbar.disable_item_expand (hsep)
912 general_toolbar.extend (hbox)
913 general_toolbar.pointer_button_release_actions.extend (agent toolbar_right_click_action)
914
915 -- Create the command to show/hide this toolbar.
916 create show_general_toolbar_command.make (general_toolbar, Interface_names.m_General_toolbar)
917 show_toolbar_commands.extend (show_general_toolbar_command)
918 if show_general_toolbar then
919 show_general_toolbar_command.enable_visible
920 else
921 show_general_toolbar_command.disable_visible
922 end
923
924 end
925
926 build_address_toolbar is
927 -- Set up the address toolbar (Back, Forward, Current, Class name, feature name, ...)
928 local
929 tb: EV_TOOL_BAR
930 -- address_bar: EV_HORIZONTAL_BOX -- Contains "Class" + Combobox + "Feature" + Combobox + "Format" + Combobox
931 hsep: EV_HORIZONTAL_SEPARATOR
932 hbox: EV_HORIZONTAL_BOX -- Contains HistoryToolbar (back, forth, current) + `address_bar'
933 cell: EV_CELL
934 accel: EV_ACCELERATOR
935 do
936 -- Create the toolbar
937 create address_toolbar
938 create hsep
939 create hbox
940 -- create address_bar
941 create tb
942 address_toolbar.set_padding (2)
943 address_toolbar.extend (hsep)
944 address_toolbar.disable_item_expand (hsep)
945 address_toolbar.extend (hbox)
946
947 hbox.extend (tb)
948 hbox.disable_item_expand (tb)
949 -- hbox.extend (address_bar)
950 -- hbox.disable_item_expand (address_bar)
951
952 -- Back icon
953 tb.extend (history_manager.back_command.new_toolbar_item (False, False))
954
955 -- Forward icon
956 tb.extend (history_manager.forth_command.new_toolbar_item (False, False))
957
958 -- Set up the accelerators.
959 create accel.make_with_key_combination (
960 create {EV_KEY}.make_with_code (Kcst.Key_right), False, True, False
961 )
962 accel.actions.extend (agent on_forth)
963 window.accelerators.extend (accel)
964
965 create accel.make_with_key_combination (
966 create {EV_KEY}.make_with_code (Kcst.Key_left), False, True, False
967 )
968 accel.actions.extend (agent on_back)
969 window.accelerators.extend (accel)
970
971 ------------------------------------------
972 -- Address bar (Class name & feature name)
973 ------------------------------------------
974 hbox.extend (address_manager.widget)
975
976 -- Create the command to show/hide this toolbar.
977 create show_address_toolbar_command.make (address_toolbar, Interface_names.m_Address_toolbar)
978 show_toolbar_commands.extend (show_address_toolbar_command)
979
980 if show_address_toolbar then
981 show_address_toolbar_command.enable_visible
982 else
983 show_address_toolbar_command.disable_visible
984 end
985
986 -- Cell to fill in empty space and receive the right click menu holder.
987 create cell
988 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
989 hbox.extend (cell)
990 end
991
992 build_project_toolbar is
993 -- Build toolbar corresponding to the project options bar
994 local
995 cell: EV_CELL
996 hsep: EV_HORIZONTAL_SEPARATOR
997 hbox: EV_HORIZONTAL_BOX
998 do
999 create project_toolbar
1000 create hsep
1001 project_toolbar.extend (hsep)
1002 project_toolbar.disable_item_expand (hsep)
1003
1004 -- Generate the toolbar.
1005 create hbox
1006 project_customizable_toolbar := debugger_manager.new_toolbar
1007 hbox.extend (project_customizable_toolbar.widget)
1008 hbox.disable_item_expand (project_customizable_toolbar.widget)
1009
1010 project_customizable_toolbar.update_toolbar
1011
1012 -- Create the command to show/hide this toolbar.
1013 create show_project_toolbar_command.make (project_toolbar, Interface_names.m_Project_toolbar)
1014 show_toolbar_commands.extend (show_project_toolbar_command)
1015 if show_project_toolbar then
1016 show_project_toolbar_command.enable_visible
1017 else
1018 show_project_toolbar_command.disable_visible
1019 end
1020
1021 -- Cell to fill in empty space and receive the right click menu holder.
1022 create cell
1023 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
1024 hbox.extend (cell)
1025 project_toolbar.extend (hbox)
1026 end
1027
1028 feature -- Menu Building
1029
1030 build_file_menu is
1031 -- Build the file menu.
1032 local
1033 new_project_cmd: EB_NEW_PROJECT_COMMAND
1034 open_project_cmd: EB_OPEN_PROJECT_COMMAND
1035 send_to_menu: EV_MENU
1036 menu_item: EV_MENU_ITEM
1037 command_menu_item: EB_COMMAND_MENU_ITEM
1038 do
1039 create file_menu.make_with_text (Interface_names.m_File)
1040
1041 -- New
1042 command_menu_item := New_development_window_cmd.new_menu_item
1043 add_recyclable (command_menu_item)
1044 file_menu.extend (command_menu_item)
1045
1046 -- New editor
1047 command_menu_item := New_editor_cmd.new_menu_item
1048 add_recyclable (command_menu_item)
1049 file_menu.extend (command_menu_item)
1050
1051 -- New context tool
1052 command_menu_item := New_context_tool_cmd.new_menu_item
1053 add_recyclable (command_menu_item)
1054 file_menu.extend (command_menu_item)
1055
1056 -- Open
1057 command_menu_item := open_cmd.new_menu_item
1058 add_recyclable (command_menu_item)
1059 file_menu.extend (command_menu_item)
1060
1061 -- Close
1062 create menu_item.make_with_text (Interface_names.m_Close)
1063 menu_item.select_actions.extend (agent destroy)
1064 file_menu.extend (menu_item)
1065
1066 -- Separator --------------------------------------
1067 file_menu.extend (create {EV_MENU_SEPARATOR})
1068
1069 -- Save
1070 command_menu_item := save_cmd.new_menu_item
1071 add_recyclable (command_menu_item)
1072 file_menu.extend (command_menu_item)
1073
1074 -- Save as
1075 command_menu_item := save_as_cmd.new_menu_item
1076 add_recyclable (command_menu_item)
1077 file_menu.extend (command_menu_item)
1078
1079 -- Sent to
1080 create send_to_menu.make_with_text (Interface_names.m_Send_to)
1081 -- External editor
1082 command_menu_item := shell_cmd.new_menu_item
1083 add_recyclable (command_menu_item)
1084 send_to_menu.extend (command_menu_item)
1085 file_menu.extend (send_to_menu)
1086
1087 -- Separator --------------------------------------
1088 file_menu.extend (create {EV_MENU_SEPARATOR})
1089 command_menu_item := print_cmd.new_menu_item
1090 add_recyclable (command_menu_item)
1091 file_menu.extend (command_menu_item)
1092
1093 -- Separator --------------------------------------
1094 file_menu.extend (create {EV_MENU_SEPARATOR})
1095
1096 -- New Project
1097 create new_project_cmd.make_with_parent (window)
1098 create menu_item.make_with_text (Interface_names.m_New_project)
1099 menu_item.select_actions.extend (agent new_project_cmd.execute)
1100 file_menu.extend (menu_item)
1101
1102 -- Open Project
1103 create open_project_cmd.make_with_parent (window)
1104 create menu_item.make_with_text (Interface_names.m_Open_project)
1105 menu_item.select_actions.extend (agent open_project_cmd.execute)
1106 file_menu.extend (menu_item)
1107
1108 -- Recent Projects
1109 recent_projects_menu := recent_projects_manager.new_menu
1110 add_recyclable (recent_projects_menu)
1111 file_menu.extend (recent_projects_menu)
1112
1113 -- Separator --------------------------------------
1114 file_menu.extend (create {EV_MENU_SEPARATOR})
1115
1116 -- Exit
1117 command_menu_item := Exit_application_cmd.new_menu_item
1118 add_recyclable (Command_menu_item)
1119 file_menu.extend (command_menu_item)
1120 end
1121
1122 build_class_info_menu: EV_MENU is
1123 -- Build the class format sub-menu.
1124 local
1125 form: EB_CLASS_INFO_FORMATTER
1126 empty_menu: EV_MENU_ITEM
1127 i: INTEGER
1128 do
1129 create Result.make_with_text (Interface_names.m_Class_info)
1130 i := 1
1131
1132 create empty_menu.make_with_text (Interface_names.m_Formatter_separators @ i)
1133 i := i + 1
1134 empty_menu.disable_sensitive
1135 Result.extend (empty_menu)
1136 from
1137 managed_class_formatters.start
1138 until
1139 managed_class_formatters.after
1140 loop
1141 form := managed_class_formatters.item
1142 if form /= Void then
1143 Result.extend (form.new_menu_item)
1144 else
1145 create empty_menu.make_with_text (Interface_names.m_Formatter_separators @ i)
1146 i := i + 1
1147 empty_menu.disable_sensitive
1148 Result.extend (empty_menu)
1149 end
1150 managed_class_formatters.forth
1151 end
1152 end
1153
1154 build_feature_info_menu: EV_MENU is
1155 -- Build the feature format sub-menu.
1156 local
1157 form: EB_FEATURE_INFO_FORMATTER
1158 do
1159 create Result.make_with_text (Interface_names.m_Feature_info)
1160 from
1161 managed_feature_formatters.start
1162 until
1163 managed_feature_formatters.after
1164 loop
1165 form := managed_feature_formatters.item
1166 if form /= Void then
1167 Result.extend (form.new_menu_item)
1168 end
1169 managed_feature_formatters.forth
1170 end
1171 end
1172
1173 build_edit_menu is
1174 -- Create and build `edit_menu'
1175 local
1176 command_menu_item: EB_COMMAND_MENU_ITEM
1177 sub_menu: EV_MENU
1178 cmd: EB_EDITOR_COMMAND
1179 os_cmd: EB_ON_SELECTION_COMMAND
1180 editor: EB_SMART_EDITOR
1181 do
1182 editor := editor_tool.text_area
1183 create command_controller.make
1184
1185 create edit_menu.make_with_text (Interface_names.m_Edit)
1186
1187 -- Undo
1188 command_menu_item := undo_cmd.new_menu_item
1189 add_recyclable (command_menu_item)
1190 edit_menu.extend (command_menu_item)
1191
1192 -- Redo
1193 command_menu_item := redo_cmd.new_menu_item
1194 add_recyclable (command_menu_item)
1195 edit_menu.extend (command_menu_item)
1196
1197 -- Separator --------------------------------------
1198 edit_menu.extend (create {EV_MENU_SEPARATOR})
1199
1200 -- Cut
1201 create os_cmd.make (Current)
1202 os_cmd.set_menu_name (Interface_names.M_cut)
1203 os_cmd.set_pixmaps (pixmaps.icon_cut)
1204 os_cmd.set_name ("Editor_cut")
1205 os_cmd.set_tooltip (interface_names.f_cut)
1206 os_cmd.add_agent (agent cut_selection)
1207 toolbarable_commands.extend (os_cmd)
1208 os_cmd.set_needs_editable (True)
1209 command_controller.add_selection_command (os_cmd)
1210 command_menu_item := os_cmd.new_menu_item
1211 add_recyclable (command_menu_item)
1212 edit_menu.extend (command_menu_item)
1213
1214 -- Copy
1215 create os_cmd.make (Current)
1216 os_cmd.set_menu_name (Interface_names.M_copy)
1217 os_cmd.set_pixmaps (pixmaps.icon_copy)
1218 os_cmd.set_name ("Editor_copy")
1219 os_cmd.set_tooltip (interface_names.f_copy)
1220 os_cmd.add_agent (agent copy_selection)
1221 toolbarable_commands.extend (os_cmd)
1222 os_cmd.set_needs_editable (False)
1223 command_controller.add_selection_command (os_cmd)
1224 command_menu_item := os_cmd.new_menu_item
1225 add_recyclable (command_menu_item)
1226 edit_menu.extend (command_menu_item)
1227
1228 -- Paste
1229 command_menu_item := editor_paste_cmd.new_menu_item
1230 add_recyclable (command_menu_item)
1231 edit_menu.extend (command_menu_item)
1232
1233 -- Separator --------------------------------------
1234 edit_menu.extend (create {EV_MENU_SEPARATOR})
1235
1236 -- Select all
1237 create cmd.make
1238 cmd.set_menu_name (Interface_names.m_select_all)
1239 cmd.add_agent (agent select_all)
1240 command_menu_item := cmd.new_menu_item
1241 command_controller.add_edition_command (cmd)
1242 add_recyclable (command_menu_item)
1243 edit_menu.extend (command_menu_item)
1244
1245 -- Separator --------------------------------------
1246 edit_menu.extend (create {EV_MENU_SEPARATOR})
1247
1248 -- Search
1249 create cmd.make
1250 cmd.set_menu_name (Interface_names.m_Search + "%T" + Editor_preferences.shorcut_name_for_action (3))
1251 cmd.add_agent (agent search)
1252 command_menu_item := cmd.new_menu_item
1253 command_controller.add_edition_command (cmd)
1254 add_recyclable (command_menu_item)
1255 edit_menu.extend (command_menu_item)
1256
1257 -- Replace
1258 create cmd.make
1259 cmd.set_menu_name (Interface_names.m_Replace + "%T" + Editor_preferences.shorcut_name_for_action (4))
1260 cmd.add_agent (agent editor.replace)
1261 cmd.set_needs_editable (True)
1262 command_menu_item := cmd.new_menu_item
1263 command_controller.add_edition_command (cmd)
1264 add_recyclable (command_menu_item)
1265 edit_menu.extend (command_menu_item)
1266
1267 -- Find sub menu
1268
1269 create sub_menu.make_with_text (Interface_names.m_Find)
1270
1271 -- Find next
1272 create cmd.make
1273 cmd.set_menu_name (Interface_names.m_Find_next + "%T" + Editor_preferences.shorcut_name_for_action (6))
1274 cmd.add_agent (agent find_next)
1275 command_menu_item := cmd.new_menu_item
1276 command_controller.add_edition_command (cmd)
1277 add_recyclable (command_menu_item)
1278 sub_menu.extend (command_menu_item)
1279
1280 -- Find previous
1281 create cmd.make
1282 cmd.set_menu_name (Interface_names.m_Find_previous + "%T" + Editor_preferences.shorcut_name_for_action (7))
1283 cmd.add_agent (agent find_previous)
1284 command_menu_item := cmd.new_menu_item
1285 command_controller.add_edition_command (cmd)
1286 add_recyclable (command_menu_item)
1287 sub_menu.extend (command_menu_item)
1288
1289 -- Find selection
1290 create os_cmd.make (Current)
1291 os_cmd.set_menu_name (Interface_names.m_Find_selection + "%T" + Editor_preferences.shorcut_name_for_action (5))
1292 os_cmd.add_agent (agent find_selection)
1293 command_menu_item := os_cmd.new_menu_item
1294 command_controller.add_selection_command (os_cmd)
1295 add_recyclable (command_menu_item)
1296 sub_menu.extend (command_menu_item)
1297
1298 edit_menu.extend (sub_menu)
1299
1300
1301 -- Separator --------------------------------------
1302 edit_menu.extend (create {EV_MENU_SEPARATOR})
1303
1304 create sub_menu.make_with_text (Interface_names.m_Advanced)
1305
1306 create os_cmd.make (Current)
1307 os_cmd.set_needs_editable (True)
1308 command_controller.add_selection_command (os_cmd)
1309 os_cmd.set_menu_name (Interface_names.m_Indent)
1310 os_cmd.add_agent (agent editor.indent_selection)
1311 command_menu_item := os_cmd.new_menu_item
1312 add_recyclable (command_menu_item)
1313 sub_menu.extend (command_menu_item)
1314
1315 create os_cmd.make (Current)
1316 os_cmd.set_needs_editable (True)
1317 command_controller.add_selection_command (os_cmd)
1318 os_cmd.set_menu_name (Interface_names.m_Unindent)
1319 os_cmd.add_agent (agent editor.unindent_selection)
1320 command_menu_item := os_cmd.new_menu_item
1321 add_recyclable (command_menu_item)
1322 sub_menu.extend (command_menu_item)
1323
1324 create os_cmd.make (Current)
1325 os_cmd.set_needs_editable (True)
1326 command_controller.add_selection_command (os_cmd)
1327 os_cmd.set_menu_name (Interface_names.m_To_lower)
1328 os_cmd.add_agent (agent editor.set_selection_case (True))
1329 command_menu_item := os_cmd.new_menu_item
1330 add_recyclable (command_menu_item)
1331 sub_menu.extend (command_menu_item)
1332
1333 create os_cmd.make (Current)
1334 os_cmd.set_needs_editable (True)
1335 command_controller.add_selection_command (os_cmd)
1336 os_cmd.set_menu_name (Interface_names.m_To_upper)
1337 os_cmd.add_agent (agent editor.set_selection_case (False))
1338 command_menu_item := os_cmd.new_menu_item
1339 add_recyclable (command_menu_item)
1340 sub_menu.extend (command_menu_item)
1341
1342 create cmd.make
1343 cmd.set_needs_editable (True)
1344 cmd.set_menu_name (Interface_names.m_Comment)
1345 cmd.add_agent (agent editor.comment_selection)
1346 command_menu_item := cmd.new_menu_item
1347 command_controller.add_edition_command (cmd)
1348 add_recyclable (command_menu_item)
1349 sub_menu.extend (command_menu_item)
1350
1351 create cmd.make
1352 cmd.set_needs_editable (True)
1353 cmd.set_menu_name (Interface_names.m_Uncomment)
1354 cmd.add_agent (agent editor.uncomment_selection)
1355 command_menu_item := cmd.new_menu_item
1356 command_controller.add_edition_command (cmd)
1357 add_recyclable (command_menu_item)
1358 sub_menu.extend (command_menu_item)
1359
1360 -- Separator --------------------------------------
1361 sub_menu.extend (create {EV_MENU_SEPARATOR})
1362
1363 -- Insert if block
1364 create cmd.make
1365 cmd.set_needs_editable (True)
1366 cmd.set_menu_name (Interface_names.m_If_block)
1367 cmd.add_agent (agent editor.embed_in_block("if then", 3))
1368 command_menu_item := cmd.new_menu_item
1369 command_controller.add_edition_command (cmd)
1370 add_recyclable (command_menu_item)
1371 sub_menu.extend (command_menu_item)
1372
1373 -- Insert debug block
1374 create cmd.make
1375 cmd.set_needs_editable (True)
1376 cmd.set_menu_name (Interface_names.m_debug_block)
1377 cmd.add_agent (agent editor.embed_in_block("debug", 5))
1378 command_menu_item := cmd.new_menu_item
1379 command_controller.add_edition_command (cmd)
1380 add_recyclable (command_menu_item)
1381 sub_menu.extend (command_menu_item)
1382
1383
1384 -- Separator --------------------------------------
1385 sub_menu.extend (create {EV_MENU_SEPARATOR})
1386
1387 -- Complete word
1388 create cmd.make
1389 cmd.set_needs_editable (True)
1390 cmd.set_menu_name (Interface_names.m_Complete_word + "%T" + Editor_preferences.shorcut_name_for_action (1))
1391 command_menu_item := cmd.new_menu_item
1392 command_controller.add_edition_command (cmd)
1393 cmd.add_agent (agent editor.complete_feature_name)
1394
1395 add_recyclable (command_menu_item)
1396 sub_menu.extend (command_menu_item)
1397
1398 -- Complete class name
1399 create cmd.make
1400 cmd.set_needs_editable (True)
1401 cmd.set_menu_name (Interface_names.m_Complete_class_name + "%T" + Editor_preferences.shorcut_name_for_action (2))
1402 command_menu_item := cmd.new_menu_item
1403 command_controller.add_edition_command (cmd)
1404 cmd.add_agent (agent editor.complete_class_name)
1405
1406 add_recyclable (command_menu_item)
1407 sub_menu.extend (command_menu_item)
1408
1409 sub_menu.extend (create {EV_MENU_SEPARATOR})
1410
1411 -- show/hide formatting marks.
1412 create cmd.make
1413 if editor_tool.text_area.view_invisible_symbols then
1414 cmd.set_menu_name (Interface_names.m_Hide_formatting_marks)
1415 else
1416 cmd.set_menu_name (Interface_names.m_Show_formatting_marks)
1417 end
1418 formatting_marks_command_menu_item := cmd.new_menu_item
1419 command_controller.add_edition_command (cmd)
1420 cmd.add_agent (agent toggle_formatting_marks)
1421
1422 add_recyclable (formatting_marks_command_menu_item)
1423 sub_menu.extend (formatting_marks_command_menu_item)
1424
1425 edit_menu.extend (sub_menu)
1426 end
1427
1428 build_view_menu is
1429 -- Build the view menu.
1430 local
1431 form: EB_CLASS_INFO_FORMATTER
1432 new_menu_item: EB_COMMAND_MENU_ITEM
1433 new_basic_item: EV_MENU_ITEM
1434 do
1435 Precursor
1436
1437 new_menu_item := toggle_stone_cmd.new_menu_item
1438 view_menu.extend (new_menu_item)
1439 add_recyclable (new_menu_item)
1440
1441 new_menu_item := send_stone_to_context_cmd.new_menu_item
1442 view_menu.extend (new_menu_item)
1443 add_recyclable (new_menu_item)
1444 -- Go to menu
1445 new_basic_item := history_manager.new_menu
1446 view_menu.extend (new_basic_item)
1447
1448 -- Separator --------------------------------------
1449 view_menu.extend (create {EV_MENU_SEPARATOR})
1450 view_menu.extend (build_class_info_menu)
1451 view_menu.extend (build_feature_info_menu)
1452
1453 -- Separator --------------------------------------
1454 view_menu.extend (create {EV_MENU_SEPARATOR})
1455
1456 from
1457 managed_main_formatters.start
1458 until
1459 managed_main_formatters.after
1460 loop
1461 form := managed_main_formatters.item
1462 new_basic_item := form.new_menu_item
1463 new_basic_item.select_actions.put_front (agent form.invalidate)
1464 view_menu.extend (new_basic_item)
1465 --add_recyclable (new_basic_item)
1466 managed_main_formatters.forth
1467 end
1468 end
1469
1470 build_favorites_menu is
1471 -- Build the favorites menu
1472 do
1473 Precursor {EB_TOOL_MANAGER}
1474
1475 create show_favorites_menu_item
1476 update_show_favorites_menu_item
1477 show_favorites_menu_item.select_actions.extend (agent execute_show_favorites)
1478
1479 favorites_menu.start
1480 favorites_menu.put_right (show_favorites_menu_item)
1481 favorites_menu.select_actions.extend (agent update_show_favorites_menu_item)
1482 end
1483
1484 build_project_menu is
1485 -- Build the project menu.
1486 local
1487 command_menu_item: EB_COMMAND_MENU_ITEM
1488 do
1489 create project_menu.make_with_text (Interface_names.m_Project)
1490
1491 -- Melt
1492 command_menu_item := Melt_project_cmd.new_menu_item
1493 add_recyclable (command_menu_item)
1494 project_menu.extend (command_menu_item)
1495
1496 -- Quick melt
1497 command_menu_item := Quick_melt_project_cmd.new_menu_item
1498 add_recyclable (command_menu_item)
1499 project_menu.extend (command_menu_item)
1500
1501 -- Freeze
1502 command_menu_item := Freeze_project_cmd.new_menu_item
1503 add_recyclable (command_menu_item)
1504 project_menu.extend (command_menu_item)
1505
1506 -- Finalize
1507 command_menu_item := Finalize_project_cmd.new_menu_item
1508 add_recyclable (command_menu_item)
1509 project_menu.extend (command_menu_item)
1510
1511 -- Precompile
1512 command_menu_item := precompilation_cmd.new_menu_item
1513 add_recyclable (command_menu_item)
1514 project_menu.extend (command_menu_item)
1515
1516 -- Separator -------------------------------------------------
1517 project_menu.extend (create {EV_MENU_SEPARATOR})
1518
1519 -- Compile Workbench C code
1520 command_menu_item := c_workbench_compilation_cmd.new_menu_item
1521 add_recyclable (command_menu_item)
1522 project_menu.extend (command_menu_item)
1523
1524 -- Compile Finalized C code
1525 command_menu_item := c_finalized_compilation_cmd.new_menu_item
1526 add_recyclable (command_menu_item)
1527 project_menu.extend (command_menu_item)
1528
1529 -- Execute Finalized code
1530 command_menu_item := run_finalized_cmd.new_menu_item
1531 add_recyclable (command_menu_item)
1532 project_menu.extend (command_menu_item)
1533
1534 -- Separator -------------------------------------------------
1535 project_menu.extend (create {EV_MENU_SEPARATOR})
1536
1537 -- System Tool window
1538 command_menu_item := system_cmd.new_menu_item
1539 add_recyclable (command_menu_item)
1540 project_menu.extend (command_menu_item)
1541
1542 -- System information
1543 command_menu_item := system_info_cmd.new_menu_item
1544 add_recyclable (command_menu_item)
1545 project_menu.extend (command_menu_item)
1546
1547 -- Error information
1548 command_menu_item := display_error_help_cmd.new_menu_item
1549 add_recyclable (command_menu_item)
1550 project_menu.extend (command_menu_item)
1551
1552 if has_documentation_generation or has_xmi_generation then
1553 -- Separator -------------------------------------------------
1554 project_menu.extend (create {EV_MENU_SEPARATOR})
1555 end
1556
1557 if has_documentation_generation then
1558 -- Generate Documentation
1559 command_menu_item := document_cmd.new_menu_item
1560 add_recyclable (command_menu_item)
1561 project_menu.extend (command_menu_item)
1562 end
1563
1564 if has_xmi_generation then
1565 -- Export XMI
1566 command_menu_item := export_cmd.new_menu_item
1567 add_recyclable (command_menu_item)
1568 project_menu.extend (command_menu_item)
1569 end
1570 end
1571
1572 build_tools_menu is
1573 -- Create and build `tools_menu'
1574 local
1575 command_menu_item: EB_COMMAND_MENU_ITEM
1576 menu_item: EV_MENU_ITEM
1577 do
1578 create tools_menu.make_with_text (Interface_names.m_Tools)
1579
1580 -- New Cluster command.
1581 command_menu_item := new_cluster_cmd.new_menu_item
1582 add_recyclable (command_menu_item)
1583 tools_menu.extend (command_menu_item)
1584
1585 -- New Class command.
1586 command_menu_item := new_class_cmd.new_menu_item
1587 add_recyclable (command_menu_item)
1588 tools_menu.extend (command_menu_item)
1589
1590 -- New Feature command.
1591 command_menu_item := new_feature_cmd.new_menu_item
1592 add_recyclable (command_menu_item)
1593 tools_menu.extend (command_menu_item)
1594
1595 -- Toggle feature signature command.
1596 command_menu_item := toggle_feature_signature_cmd.new_menu_item
1597 add_recyclable (command_menu_item)
1598 tools_menu.extend (command_menu_item)
1599
1600 -- Delete class/cluster command.
1601 command_menu_item := delete_class_cluster_cmd.new_menu_item
1602 add_recyclable (command_menu_item)
1603 tools_menu.extend (command_menu_item)
1604
1605 -- Separator --------------------------------------
1606 tools_menu.extend (create {EV_MENU_SEPARATOR})
1607
1608
1609 if has_metrics then
1610 -- Metric tool
1611 create metric_menu.make_with_text (interface_names.metric_metrics)
1612 create menu_item.make_with_text (interface_names.metric_calculate)
1613 metric_menu.extend (menu_item)
1614 create menu_item.make_with_text (interface_names.metric_add)
1615 metric_menu.extend (menu_item)
1616 create menu_item.make_with_text (interface_names.metric_delete)
1617 metric_menu.extend (menu_item)
1618 create menu_item.make_with_text (interface_names.metric_details)
1619 metric_menu.extend (menu_item)
1620 create menu_item.make_with_text (interface_names.metric_new_metrics)
1621 metric_menu.extend (menu_item)
1622 create menu_item.make_with_text (interface_names.metric_management)
1623 metric_menu.extend (menu_item)
1624 create menu_item.make_with_text (interface_names.metric_archive)
1625 metric_menu.extend (menu_item)
1626 metric_menu.disable_sensitive
1627 tools_menu.extend (metric_menu)
1628 end
1629
1630 if has_profiler then
1631 -- Profiler Window
1632 command_menu_item := show_profiler.new_menu_item
1633 add_recyclable (command_menu_item)
1634 tools_menu.extend (command_menu_item)
1635 end
1636
1637 -- Precompile Wizard
1638 command_menu_item := wizard_precompile_cmd.new_menu_item
1639 add_recyclable (command_menu_item)
1640 tools_menu.extend (command_menu_item)
1641
1642 if has_dll_generation then
1643 -- Dynamic Library Window
1644 command_menu_item := show_dynamic_lib_tool.new_menu_item
1645 add_recyclable (command_menu_item)
1646 tools_menu.extend (command_menu_item)
1647 end
1648
1649 if debugger_manager.display_dotnet_cmd then
1650 -- Import .Net Assembly
1651 command_menu_item := eac_browser_cmd.new_menu_item
1652 add_recyclable (command_menu_item)
1653 tools_menu.extend (command_menu_item)
1654 end
1655
1656 -- Separator -------------------------------------------------
1657 tools_menu.extend (create {EV_MENU_SEPARATOR})
1658
1659 -- Preferences
1660 command_menu_item := Show_preferences_cmd.new_menu_item
1661 add_recyclable (command_menu_item)
1662 tools_menu.extend (command_menu_item)
1663
1664 -- External commands editor
1665 command_menu_item := Edit_external_commands_cmd.new_menu_item
1666 add_recyclable (command_menu_item)
1667 tools_menu.extend (command_menu_item)
1668
1669 -- Separator -------------------------------------------------
1670 tools_menu.extend (create {EV_MENU_SEPARATOR})
1671
1672 rebuild_tools_menu
1673 end
1674
1675 feature -- Stone process
1676
1677 stone: STONE
1678 -- Current stone
1679
1680 toggle_unified_stone is
1681 -- Change the stone management mode.
1682 do
1683 unified_stone := not unified_stone
1684 if unified_stone then
1685 send_stone_to_context
1686 send_stone_to_context_cmd.disable_sensitive
1687 context_tool.link_to_development_window
1688 else
1689 if stone /= Void then
1690 send_stone_to_context_cmd.enable_sensitive
1691 end
1692 context_tool.cut_from_development_window
1693 end
1694 end
1695
1696 set_stone (a_stone: STONE) is
1697 -- Change the currently focused stone.
1698 local
1699 cd: STANDARD_DISCARDABLE_CONFIRMATION_DIALOG
1700 cv_cst: CLASSI_STONE
1701 l: LIST [EB_DEVELOPMENT_WINDOW]
1702 do
1703 cv_cst ?= a_stone
1704 if cv_cst /= Void then
1705 l := Window_manager.development_windows_with_class (cv_cst.class_i.name)
1706 if l.is_empty or else l.has (Current) then
1707 -- We're not editing the class in another window.
1708 set_stone_after_first_check (a_stone)
1709 else
1710 create cd.make_initialized (2, "already_editing_class", warning_messages.w_Class_already_edited, Interface_names.L_do_not_show_again)
1711 cd.set_ok_action (agent set_stone_after_first_check (a_stone))
1712 cd.show_modal_to_window (window)
1713 end
1714 else
1715 set_stone_after_first_check (a_stone)
1716 end
1717 end
1718
1719 set_stone_after_first_check (a_stone: STONE) is
1720 -- Display text associated with `a_stone', if any and if possible
1721 local
1722 feature_stone: FEATURE_STONE
1723 old_class_stone: CLASSI_STONE
1724 test_stone: CLASSI_STONE
1725 same_class: BOOLEAN
1726 conv_ferrst: FEATURE_ERROR_STONE
1727 do
1728 old_class_stone ?= stone
1729 feature_stone ?= a_stone
1730 if old_class_stone /= Void then
1731 create test_stone.make (old_class_stone.class_i)
1732 same_class := test_stone.same_as (a_stone)
1733 -- We need to compare classes. If `old_class_stone' is a FEATURE_STONE
1734 -- `same_as' will compare features. Therefore, we need `test_stone' to be sure
1735 -- we have a CLASSI_STONE.
1736 if same_class and then feature_stone /= Void then
1737 same_class := False
1738 -- if the stone corresponding to a feature of currently opened class is dropped
1739 -- we attempt to scroll to the feature without asking to save the file
1740 -- except if it is during a resynchronization, in which case we do not scroll at all.
1741 if editor_tool.text_area.text_is_fully_loaded then
1742 if not during_synchronization then
1743 editor_tool.text_area.find_feature_named (feature_stone.feature_name)
1744 feature_stone_already_processed := editor_tool.text_area.found_feature
1745 else
1746 feature_stone_already_processed := True
1747 end
1748 conv_ferrst ?= feature_stone
1749 if feature_stone_already_processed and conv_ferrst /= Void then
1750 -- Scroll to the line of the error.
1751 if not during_synchronization then
1752 editor_tool.text_area.display_line_when_ready (conv_ferrst.line_number, True)
1753 end
1754 end
1755 end
1756 end
1757 end
1758 -- first, let's check if there is already something in this window
1759 -- if there's nothing, there's no need to save anything...
1760 if stone = Void or else not changed or else feature_stone_already_processed or else same_class then
1761 set_stone_after_check (a_stone)
1762 feature_stone_already_processed := False
1763 else
1764 -- there is something to be saved
1765 -- if user chooses to save, current file will be parsed
1766 -- if there is a syntax_error, new file is not loaded
1767 save_and (agent set_stone_after_check (a_stone))
1768 if text_saved and then not syntax_is_correct then
1769 text_saved := False
1770 during_synchronization := True
1771 set_stone_after_check (stone)
1772 during_synchronization := False
1773 address_manager.refresh
1774 end
1775 end
1776 end
1777
1778 force_stone (s: STONE) is
1779 -- make `s' the new value of `stone', and
1780 -- change the display accordingly. Try to
1781 -- extract a class from `s' whenever possible.
1782 do
1783 if s.is_storable then
1784 set_stone (s)
1785 if not unified_stone then
1786 context_tool.advanced_set_stone (s)
1787 end
1788 end
1789 end
1790
1791 process_class (s: CLASSI_STONE) is
1792 -- Process class stone
1793 do
1794 set_stone (s)
1795 end
1796
1797 process_feature_error (s: FEATURE_ERROR_STONE) is
1798 -- Process feature error stone.
1799 local
1800 cl_stone: CLASSC_STONE
1801 e_class: CLASS_C
1802 txt: STRING
1803 pos, end_pos: INTEGER
1804 do
1805 set_default_format
1806 e_class := s.e_feature.written_class
1807 create cl_stone.make (e_class)
1808 set_stone (cl_stone)
1809 editor_tool.text_area.deselect_all
1810 pos := s.error_position
1811 txt := text
1812 if txt.count > pos then
1813 if txt.item (pos) = '%N' then
1814 end_pos := txt.index_of ('%N', pos + 1)
1815 else
1816 end_pos := txt.index_of ('%N', pos)
1817 end
1818 if pos /= 0 then
1819 editor_tool.text_area.highlight_selected (pos, end_pos)
1820 end
1821 end
1822 end
1823
1824
1825 process_class_syntax (s: CL_SYNTAX_STONE) is
1826 -- Process class syntax.
1827 local
1828 cl_stone: CLASSC_STONE
1829 do
1830 -- call set_stone to ensure the proper class is displayed
1831 create cl_stone.make (s.e_class)
1832 set_stone (cl_stone)
1833 editor_tool.text_area.deselect_all
1834 editor_tool.text_area.highlight_when_ready (s.start_position + 1, s.end_position + 1)
1835 end
1836
1837 refresh is
1838 -- Synchronize clickable elements with text, if possible.
1839 do
1840 --| FIXME ARNAUD
1841 -- synchronise_stone
1842 --| END FIXME
1843 --| FIXME XR: Refresh current display in the editor.
1844 editor_tool.text_area.update_click_list (False)
1845 update_save_symbol
1846 address_manager.refresh
1847 -- The cluster manager should already be refreshed by the window manager.
1848 -- cluster_manager.refresh
1849 -- context_tool.refresh
1850 end
1851
1852 quick_refresh is
1853 -- Redraw the main editor's drawing area.
1854 do
1855 editor_tool.text_area.refresh
1856 context_tool.quick_refresh
1857 end
1858
1859 set_default_format is
1860 -- Default format of windows.
1861 --| FIXME ARNAUD: To be implemented.
1862 -- local
1863 -- f: EB_FORMATTER
1864 do
1865 -- if stone /= Void then
1866 -- if stone.class_i.hide_implementation then
1867 -- f := format_list.precompiled_default_format
1868 -- else
1869 -- f := format_list.default_format
1870 -- end
1871 -- else
1872 -- f := format_list.default_format
1873 -- end
1874 -- set_last_format (f)
1875 --| END FIXME
1876 end
1877
1878 feature -- Resource Update
1879
1880 update is
1881 -- Update Current with the registered resources.
1882 do
1883 lock_update
1884 -- Show/hide general toolbar
1885 if show_general_toolbar then
1886 show_general_toolbar_command.enable_visible
1887 else
1888 show_general_toolbar_command.disable_visible
1889 end
1890
1891 -- Show/hide address toolbar
1892 if show_address_toolbar then
1893 show_address_toolbar_command.enable_visible
1894 else
1895 show_address_toolbar_command.disable_visible
1896 end
1897
1898 -- Show/hide project toolbar
1899 if show_project_toolbar then
1900 show_project_toolbar_command.enable_visible
1901 else
1902 show_project_toolbar_command.disable_visible
1903 end
1904
1905 left_panel.load_from_resource (left_panel_layout)
1906 right_panel.load_from_resource (right_panel_layout)
1907 splitter_position := left_panel_width
1908 update_splitters
1909 unlock_update
1910 end
1911
1912 update_splitters is
1913 -- Refresh the position of the splitter on screen according to
1914 -- our internal values.
1915 do
1916 -- Set the interior layout
1917 if panel.full then
1918 panel.set_split_position (splitter_position.max (panel.minimum_split_position))
1919 end
1920 end
1921
1922 register is
1923 -- Register to preferences we want notification of.
1924 do
1925 end
1926
1927 unregister is
1928 -- unregister to preferences we want notification of.
1929 do
1930 end
1931
1932 reset is
1933 -- Reset the window contents
1934 do
1935 Precursor
1936 address_manager.reset
1937
1938 --| FIXME ARNAUD, multiformat not yet implemented.
1939 -- format_list.enable_imp_formats_sensitive
1940 --| END FIXME
1941 end
1942
1943 rebuild_tools_menu is
1944 -- Refresh the list of external commands.
1945 local
1946 ms: LIST [EB_COMMAND_MENU_ITEM]
1947 do
1948 -- Remove all the external commands, which are at the end of the menu.
1949 from
1950 tools_menu.go_i_th (tools_menu.count + 1 - number_of_displayed_external_commands)
1951 until
1952 tools_menu.after
1953 loop
1954 tools_menu.remove
1955 end
1956 ms := Edit_external_commands_cmd.menus
1957 number_of_displayed_external_commands := ms.count
1958 from
1959 ms.start
1960 until
1961 ms.after
1962 loop
1963 tools_menu.extend (ms.item)
1964 add_recyclable (ms.item)
1965 ms.forth
1966 end
1967 end
1968
1969 syntax_is_correct: BOOLEAN is
1970 -- file was successfully parsed.
1971 do
1972 Result := editor_tool.text_area.syntax_is_correct
1973 end
1974
1975 on_project_created is
1976 -- Inform tools that the current project has been loaded or re-loaded.
1977 do
1978 build_menu_bar
1979 enable_commands_on_project_created
1980 context_tool.on_project_created
1981 address_manager.on_project_created
1982 if has_dll_generation then
1983 show_dynamic_lib_tool.enable_sensitive
1984 end
1985 if has_profiler then
1986 show_profiler.enable_sensitive
1987 end
1988 end
1989
1990 on_project_loaded is
1991 -- Inform tools that the current project has been loaded or re-loaded.
1992 do
1993 -- cluster_manager.on_project_loaded
1994 enable_commands_on_project_loaded
1995 cluster_tool.on_project_loaded
1996 context_tool.on_project_loaded
1997 end
1998
1999 on_project_unloaded is
2000 -- Inform tools that the current project will soon been unloaded.
2001 do
2002 -- cluster_manager.on_project_unloaded
2003 disable_commands_on_project_unloaded
2004 cluster_tool.on_project_unloaded
2005 context_tool.on_project_unloaded
2006 address_manager.on_project_unloaded
2007 build_menu_bar
2008 if has_dll_generation then
2009 show_dynamic_lib_tool.disable_sensitive
2010 end
2011 if has_profiler then
2012 show_profiler.disable_sensitive
2013 end
2014 end
2015
2016 save_before_compiling is
2017 -- save the text but do not update clickable positions
2018 do
2019 save_only := True
2020 save_text
2021 end
2022
2023 perform_check_before_save is
2024 local
2025 dial: EV_CONFIRMATION_DIALOG
2026 do
2027 debug ("EDITOR")
2028 if editor_tool.text_area.current_text /= Void and then changed then
2029 io.error.put_string ("%N Warning: Attempting to save a non editable format%N")
2030 end
2031 end
2032 if editor_tool.text_area.open_backup then
2033 create dial.make_with_text(Warning_messages.w_Save_backup)
2034 dial.set_buttons_and_actions(<<"Continue", "Cancel">>, <<agent continue_save, agent cancel_save>>)
2035 dial.set_default_push_button(dial.button("Continue"))
2036 dial.set_default_cancel_button(dial.button("Cancel"))
2037 dial.set_title ("Save Backup")
2038 dial.show_modal_to_window (window)
2039 else
2040 check_passed := True
2041 end
2042 end
2043
2044 continue_save is
2045 -- continue saving
2046 do
2047 check_passed := True
2048 end
2049
2050 cancel_save is
2051 -- cancel saving
2052 do
2053 check_passed := False
2054 end
2055
2056 process is
2057 -- process the user entry in the address bar
2058 do
2059 save_canceled := False
2060 end
2061
2062 on_text_saved is
2063 -- Notify the editor that the text has been saved
2064 local
2065 str: STRING
2066 do
2067 Precursor
2068 editor_tool.on_text_saved
2069 text_saved := True
2070 if not save_only then
2071 editor_tool.text_area.update_click_list (True)
2072 end
2073 save_only := False
2074 str := title.twin
2075 if str @ 1 = '*' then
2076 str.keep_tail (str.count - 2)
2077 set_title (str)
2078 end
2079 update_formatters
2080 if editor_tool.text_area.syntax_is_correct then
2081 status_bar.display_message ("")
2082 else
2083 status_bar.display_message (Interface_names.L_syntax_error)
2084 end
2085 text_edited := False
2086 end
2087
2088 save_and (an_action: PROCEDURE [ANY, TUPLE]) is
2089 local
2090 save_dialog: EB_CONFIRM_SAVE_DIALOG
2091 do
2092 save_canceled := True
2093 text_saved := False
2094 create save_dialog.make_and_launch (Current,Current)
2095 if not save_canceled and then syntax_is_correct then
2096 an_action.call(Void)
2097 end
2098 end
2099
2100 feature -- Window management
2101
2102 show_window is
2103 -- Show the window
2104 do
2105 show
2106 end
2107
2108 raise_window is
2109 -- Show the window and set the focus to it.
2110 do
2111 show
2112 --| FIXME, set the focus.
2113 end
2114
2115 hide_window is
2116 -- Hide the window
2117 do
2118 hide
2119 end
2120
2121 destroy_window is
2122 -- Destroy the window.
2123 do
2124 destroy
2125 end
2126
2127 give_focus is
2128 -- Give the focus to the address manager.
2129 do
2130 address_manager.set_focus
2131 end
2132
2133 save_layout is
2134 -- Store layout of `current'.
2135 do
2136 -- Now save the windows's layout, but only if the
2137 -- debugger is not displayed in `Current'. By saving the layout,
2138 -- we ensure that future windows may use exactly the same layout.
2139 -- If the debugger is displayed, the previopus layout is already saved,
2140 -- and this is the one that must be used, as only one debugger is ever displayed.
2141 if (Application.is_running and debugger_manager.debugging_window /= Current) or not application.is_running then
2142 save_left_panel_layout (left_panel.save_to_resource)
2143 save_right_panel_layout (right_panel.save_to_resource)
2144 save_left_panel_width (panel.split_position)
2145 -- Save width & height.
2146 save_size (window.width, window.height, window.is_maximized)
2147 end
2148 save_search_tool_options (search_tool)
2149 -- Commit saves
2150 save_resources
2151 end
2152
2153 feature -- Tools & Controls
2154
2155 editor_tool: EB_EDITOR_TOOL
2156
2157 favorites_tool: EB_FAVORITES_TOOL
2158
2159 cluster_tool: EB_CLUSTER_TOOL
2160
2161 search_tool: EB_SEARCH_TOOL
2162
2163 features_tool: EB_FEATURES_TOOL
2164
2165 windows_tool: EB_WINDOWS_TOOL
2166
2167 context_tool: EB_CONTEXT_TOOL
2168 -- Context explorer for current class and system.
2169
2170 address_manager: EB_ADDRESS_MANAGER
2171 -- Text field in the toolbar
2172 -- Allow user to enter the name
2173 -- of the class he wants to edit.
2174
2175 project_manager: EB_PROJECT_MANAGER is
2176 -- Project manager associated to the project the user is working on.
2177 do
2178 Result := Eiffel_project.manager
2179 end
2180
2181 managed_class_formatters: ARRAYED_LIST [EB_CLASS_INFO_FORMATTER]
2182 -- All formatters that operate on a class.
2183
2184 managed_feature_formatters: ARRAYED_LIST [EB_FEATURE_INFO_FORMATTER]
2185 -- All formatters that operate on a class.
2186
2187 managed_main_formatters: ARRAYED_LIST [EB_CLASS_TEXT_FORMATTER]
2188 -- All formatters that can be displayed in the main editor frame.
2189
2190 unified_stone: BOOLEAN
2191 -- Is the stone common with the context tool or not?
2192
2193 arguments_dialog: EB_ARGUMENT_DIALOG
2194 -- The arguments dialog for current, if any
2195
2196 feature -- Multiple editor management
2197
2198 add_editor_to_list (an_editor: EB_EDITOR) is
2199 -- adds `an_editor' to `editors'
2200 do
2201 editors.extend (an_editor)
2202 end
2203
2204 current_editor: EB_EDITOR is
2205 -- current editor, if none, main editor
2206 do
2207 if current_editor_index /= 0 then
2208 Result := editors @ current_editor_index
2209 else
2210 Result := editors.first
2211 end
2212 end
2213
2214 set_current_editor (an_editor: EB_EDITOR) is
2215 -- set `an_editor' as main editor
2216 local
2217 old_index: INTEGER
2218 new_index: INTEGER
2219 do
2220 old_index := current_editor_index
2221 new_index := editors.index_of (an_editor, 1)
2222 if
2223 editors.valid_index (new_index) and
2224 old_index /= new_index
2225 then
2226 current_editor_index := new_index
2227 from
2228 editors.start
2229 until
2230 editors.after
2231 loop
2232 if editors.index /= current_editor_index and then editors.item.has_selection then
2233 editors.item.disable_selection
2234 end
2235 editors.forth
2236 end
2237 update_paste_cmd
2238 -- Last thing, update the menu entry for the formatting marks.
2239 if current_editor.view_invisible_symbols then
2240 formatting_marks_command_menu_item.set_text (Interface_names.m_Hide_formatting_marks)
2241 else
2242 formatting_marks_command_menu_item.set_text(Interface_names.m_Show_formatting_marks)
2243 end
2244 command_controller.set_current_editor (an_editor)
2245 end
2246 end
2247
2248 update_paste_cmd is
2249 -- Update `editor_paste_cmd'. To be performed when an editor grabs the focus.
2250 local
2251 txt: STRING
2252 do
2253 txt := current_editor.clipboard.text
2254 if
2255 not current_editor.is_empty and then
2256 current_editor.is_editable and then
2257 txt /= Void and then
2258 not txt.is_empty
2259 then
2260 editor_paste_cmd.enable_sensitive
2261 else
2262 editor_paste_cmd.disable_sensitive
2263 end
2264 end
2265
2266 feature {NONE} -- Multiple editor management
2267
2268 editors: ARRAYED_LIST [EB_EDITOR]
2269 -- editor contained in `Current'
2270
2271 current_editor_index: INTEGER
2272 -- Index in `editors' of the editor that has the focus.
2273
2274 feature {EB_FEATURES_TOOL, EB_FEATURES_TREE, DOTNET_CLASS_AS, DOTNET_CLASS_CONTEXT} -- Feature Clauses
2275
2276 set_feature_clauses (a_features: ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]]; a_type: STRING) is
2277 -- Set 'features' to 'a_features' and store in hash table with key 'a_type' denoting name of consumed
2278 -- type pertinent to 'a_features'.
2279 require
2280 a_features_not_void: a_features /= Void
2281 do
2282 if feature_clauses = Void then
2283 create feature_clauses.make (5)
2284 end
2285 feature_clauses.put (a_features, a_type)
2286 end
2287
2288 get_feature_clauses (a_type: STRING): ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]] is
2289 -- Get list of feature clauses relevant to .NET type with name 'a_type'.
2290 require
2291 a_type_not_void: a_type /= Void
2292 has_type_clauses: feature_clauses.has (a_type)
2293 do
2294 Result := feature_clauses.item (a_type)
2295 ensure
2296 result_not_void: Result /= Void
2297 end
2298
2299 feature_clauses: HASH_TABLE [ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]], STRING]
2300 -- List of features clauses for Current window hashed by the .NET name of the consumed_type.
2301
2302 feature_positions: HASH_TABLE [INTEGER, E_FEATURE]
2303 -- Features indexed by line position in class text (for .NET features).
2304
2305 feature {EB_WINDOW_MANAGER} -- Window management / Implementation
2306
2307 destroy_imp is
2308 -- Destroy window.
2309 do
2310 -- To avoid reentrance
2311 if not is_destroying then
2312 is_destroying := True
2313 if Application.is_running and then debugger_manager.debugging_window = Current
2314 then
2315 set_array_resource ("left_debug_layout_new", left_panel.save_to_resource)
2316 set_array_resource ("right_debug_layout_new", right_panel.save_to_resource)
2317 debugger_manager.save_original_layout
2318 else
2319 save_left_panel_layout (left_panel.save_to_resource)
2320 save_right_panel_layout (right_panel.save_to_resource)
2321 end
2322 save_left_panel_width (panel.split_position)
2323 -- Save width & height.
2324 save_size (window.width, window.height, window.is_maximized)
2325 left_panel.wipe_out
2326 right_panel.wipe_out
2327 save_search_tool_options (search_tool)
2328 hide
2329
2330 -- Commit saves
2331 save_resources
2332
2333 -- If a launched application is still running, kill it.
2334 if
2335 Application.is_running and then
2336 debugger_manager.debugging_window = Current
2337 then
2338 Application.kill
2339 end
2340 toolbars_area.wipe_out
2341 address_manager.recycle
2342 project_customizable_toolbar.recycle
2343 Precursor {EB_TOOL_MANAGER}
2344
2345 managed_class_formatters.wipe_out
2346 managed_feature_formatters.wipe_out
2347 managed_main_formatters.wipe_out
2348 toolbarable_commands.wipe_out
2349 editors.wipe_out
2350 stone := Void
2351 end
2352 end
2353
2354 feature {NONE} -- Implementation
2355
2356 set_stone_after_check (a_stone: STONE) is
2357 local
2358 old_stone: STONE
2359 new_class_stone: CLASSI_STONE
2360 old_class_stone: CLASSI_STONE
2361 conv_classc: CLASSC_STONE
2362 conv_brkstone: BREAKABLE_STONE
2363 cluster_st: CLUSTER_STONE
2364 feature_stone: FEATURE_STONE
2365 conv_ferrst: FEATURE_ERROR_STONE
2366 tmp_structured_text: STRUCTURED_TEXT
2367 conv_errst: ERROR_STONE
2368 class_file: RAW_FILE
2369 class_text_exists: BOOLEAN
2370 same_class: BOOLEAN
2371 test_stone: CLASSI_STONE
2372 conv_ace: ACE_SYNTAX_STONE
2373 externali: EXTERNAL_CLASS_I
2374 l_reader: EIFFEL_XML_DESERIALIZER
2375 external_cons: CONSUMED_TYPE
2376 str: STRING
2377 dotnet_class: BOOLEAN
2378 l_short_formatter: EB_SHORT_FORMATTER
2379 l_flat_formatter: EB_FLAT_SHORT_FORMATTER
2380 do
2381 -- the text does not change if the text was saved with syntax errors
2382 cur_wid := window
2383 if cur_wid = Void then
2384 --| Do nothing.
2385 else
2386 if old_cur = Void then
2387 old_cur := cur_wid.pointer_style
2388 end
2389 -- cur_wid.enable_capture
2390 cur_wid.set_pointer_style (Wait_cursor)
2391 end
2392
2393 conv_brkstone ?= a_stone
2394 conv_errst ?= a_stone
2395 conv_ace ?= a_stone
2396 if conv_brkstone /= Void then
2397 if Application.is_breakpoint_enabled (conv_brkstone.routine, conv_brkstone.index) then
2398 Application.remove_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2399 else
2400 Application.set_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2401 end
2402 output_manager.display_stop_points
2403 window_manager.quick_refresh_all
2404 elseif conv_errst /= Void then
2405 display_error_help_cmd.execute_with_stone (conv_errst)
2406 elseif conv_ace /= Void then
2407 --| FIXME XR: What should we do?!
2408 else
2409
2410 -- Remember previous stone.
2411 old_stone := stone
2412 old_class_stone ?= stone
2413
2414 -- New stone properties
2415 new_class_stone ?= a_stone
2416
2417 -- Set the stone.
2418 old_set_stone (a_stone)
2419 cluster_st ?= a_stone
2420
2421 new_feature_cmd.disable_sensitive
2422 toggle_feature_signature_cmd.disable_sensitive
2423
2424 -- We update the state of the `Add to Favorites' command.
2425 if new_class_stone /= Void then
2426 favorites_menu.first.enable_sensitive
2427 else
2428 favorites_menu.first.disable_sensitive
2429 end
2430
2431 -- Update the history.
2432 if
2433 new_class_stone /= Void
2434 then
2435 history_manager.extend (new_class_stone)
2436 elseif
2437 cluster_st /= Void
2438 then
2439 history_manager.extend (cluster_st)
2440 end
2441 -- Update the address manager if needed.
2442 address_manager.refresh
2443 if new_class_stone /= Void then
2444 -- class stone was dropped
2445 create class_file.make (new_class_stone.class_i.file_name)
2446 class_text_exists := class_file.exists
2447 feature_stone ?= a_stone
2448 --| We have to create a classi_stone to check whether the stones are really similar.
2449 --| Otherwise a redefinition of same_as may be called.
2450 create test_stone.make (new_class_stone.class_i)
2451 if test_stone.same_as (old_class_stone) then
2452 same_class := True
2453 end
2454 if not feature_stone_already_processed then
2455 if
2456 same_class and then text_saved
2457 then
2458 -- nothing changed in the editor
2459 -- we only have to update click_list
2460 if editor_tool.text_area.is_editable then
2461 editor_tool.text_area.update_click_list (False)
2462 end
2463 else
2464 if changed then
2465 -- user has already chosen not to save the file
2466 -- do not ask again
2467 Feature_positions.wipe_out
2468 editor_tool.text_area.no_save_before_next_load
2469 end
2470 end
2471 end
2472
2473 conv_classc ?= new_class_stone
2474 if conv_classc = Void or else
2475 conv_classc.e_class.is_external or else
2476 feature_stone /= Void and not
2477 feature_stone_already_processed and not
2478 (same_class and context_tool.sending_stone) then
2479 -- If a classi_stone or a feature_stone or a external call
2480 -- has been dropped, check to see if a .NET class.
2481 if class_text_exists then
2482 if new_class_stone.class_i.is_external_class then
2483 create l_reader
2484 externali ?= new_class_stone.class_i
2485 external_cons ?= l_reader.new_object_from_file (externali.file_name)
2486 if external_cons /= Void then
2487 -- A .NET class.
2488 dotnet_class := True
2489 l_short_formatter ?= managed_main_formatters.i_th (4)
2490 l_flat_formatter ?= managed_main_formatters.i_th (5)
2491 if l_short_formatter /= Void then
2492 l_short_formatter.set_dotnet_mode (True)
2493 end
2494 if l_flat_formatter /= Void then
2495 l_flat_formatter.set_dotnet_mode (True)
2496 end
2497 end
2498 else
2499 managed_main_formatters.first.set_stone (new_class_stone)
2500 managed_main_formatters.first.execute
2501 end
2502 else
2503 editor_tool.text_area.clear_window
2504 editor_tool.text_area.display_message (
2505 Warning_messages.w_file_not_exist (
2506 new_class_stone.class_i.file_name))
2507 end
2508 end
2509 if conv_classc = Void then
2510 --| The dropped class is not compiled.
2511 --| Display only the textual formatter.
2512 if dotnet_class then
2513 managed_main_formatters.i_th (4).set_stone (new_class_stone)
2514 managed_main_formatters.i_th (5).set_stone (new_class_stone)
2515 managed_main_formatters.i_th (4).execute
2516 end
2517 address_manager.disable_formatters
2518 else
2519 --| We have a compiled class.
2520 if
2521 class_text_exists and then
2522 Eiffel_project.Workbench.last_reached_degree <= 2
2523 then
2524 new_feature_cmd.enable_sensitive
2525 toggle_feature_signature_cmd.enable_sensitive
2526 end
2527
2528 --address_manager.enable_formatters
2529 update_formatters
2530 if not class_text_exists then
2531 --| Disable the textual formatter.
2532 managed_main_formatters.first.disable_sensitive
2533 from
2534 managed_main_formatters.start
2535 until
2536 managed_main_formatters.after
2537 loop
2538 managed_main_formatters.item.set_stone (new_class_stone)
2539 managed_main_formatters.forth
2540 end
2541 managed_main_formatters.i_th (2).execute
2542 else
2543 if not changed or not same_class then
2544 --| Enable all formatters.
2545 if
2546 not feature_stone_already_processed or
2547 not managed_main_formatters.first.selected
2548 then
2549 from
2550 managed_main_formatters.start
2551 until
2552 managed_main_formatters.after
2553 loop
2554 managed_main_formatters.item.set_stone (new_class_stone)
2555 managed_main_formatters.forth
2556 end
2557 end
2558 else
2559 address_manager.disable_formatters
2560 from
2561 managed_main_formatters.start
2562 until
2563 managed_main_formatters.after
2564 loop
2565 managed_main_formatters.item.set_stone (new_class_stone)
2566 managed_main_formatters.forth
2567 end
2568 end
2569 end
2570 end
2571 else
2572 -- not a class text : cannot be edited
2573 editor_tool.text_area.disable_editable
2574 address_manager.disable_formatters
2575
2576 --| Disable all formatters.
2577 from
2578 managed_main_formatters.start
2579 until
2580 managed_main_formatters.after
2581 loop
2582 managed_main_formatters.item.set_stone (Void)
2583 managed_main_formatters.forth
2584 end
2585 if cluster_st /= Void then
2586 --| FIXME XR: Really manage cluster display in the main editor
2587 create tmp_structured_text.make
2588 tmp_structured_text.add_string ("Cluster: " + cluster_st.cluster_i.cluster_name)
2589 tmp_structured_text.add_new_line
2590 tmp_structured_text.add_string ("Cluster path: " + cluster_st.cluster_i.path)
2591 editor_tool.text_area.process_text (tmp_structured_text)
2592 --| END FIXME
2593 end
2594 end
2595 if feature_stone /= Void and class_text_exists and not feature_stone_already_processed and not (same_class and context_tool.sending_stone) then
2596 conv_ferrst ?= feature_stone
2597 if conv_ferrst /= Void then
2598 -- Scroll to the line of the error.
2599 editor_tool.text_area.display_line_when_ready (conv_ferrst.line_number, True)
2600 else
2601 -- if a feature_stone has been dropped
2602 -- scroll to the corresponding feature in the basic text format
2603 if not during_synchronization then
2604 scroll_to_feature (feature_stone.e_feature, new_class_stone.class_i)
2605 end
2606 end
2607 end
2608 -- Update the title of the window
2609 if a_stone /= Void then
2610 if changed then
2611 str := a_stone.header.twin
2612 str.prepend ("* ")
2613 set_title (str)
2614 else
2615 set_title (a_stone.header)
2616 end
2617 else
2618 set_title (Interface_names.t_Empty_development_window)
2619 end
2620
2621 -- Refresh the tools.
2622 features_tool.set_stone (a_stone)
2623 cluster_tool.set_stone (a_stone)
2624 -- Update the context tool.
2625 if unified_stone then
2626 context_tool.set_stone (a_stone)
2627 end
2628
2629 end
2630 if
2631 stone /= Void and then
2632 not unified_stone
2633 then
2634 send_stone_to_context_cmd.enable_sensitive
2635 else
2636 send_stone_to_context_cmd.disable_sensitive
2637 end
2638 if cur_wid = Void then
2639 --| Do nothing.
2640 else
2641 cur_wid.set_pointer_style (old_cur)
2642 old_cur := Void
2643 -- cur_wid.disable_capture
2644 cur_wid := Void
2645 end
2646 end
2647
2648 scroll_to_feature (feat_as: E_FEATURE; displayed_class: CLASS_I) is
2649 -- highlight the feature correspnding to `feat_as' in the class represented by `displayed_class'
2650 require
2651 class_is_not_void: displayed_class /= Void
2652 feat_as_is_not_void: feat_as /= Void
2653 local
2654 begin_index, offset: INTEGER
2655 tmp_text: STRING
2656 do
2657 if not feat_as.is_il_external then
2658 if feat_as.ast /= Void then
2659 begin_index := feat_as.ast.start_position
2660 if platform_constants.is_windows then
2661 tmp_text := displayed_class.text.substring (1, begin_index)
2662 offset := tmp_text.occurrences('%R')
2663 end
2664 editor_tool.text_area.scroll_to_when_ready (begin_index.item - offset)
2665 end
2666 else
2667 -- FIXME NC: Doesn't work properly for .NET features
2668 -- .NET formatted feature.
2669 begin_index := feature_positions.item (feat_as)
2670 if platform_constants.is_windows then
2671 tmp_text := displayed_class.text.substring (1, begin_index)
2672 offset := tmp_text.occurrences('%N')
2673 end
2674 editor_tool.text_area.scroll_to_when_ready (begin_index // 2) -- - offset)
2675 end
2676 end
2677
2678 check_passed: BOOLEAN
2679
2680 save_canceled: BOOLEAN
2681 -- did user cancel save ?
2682
2683 save_only: BOOLEAN
2684 -- skip parse and update after save ?
2685
2686 text_saved: BOOLEAN
2687 -- has the user chosen to save the file
2688
2689 is_destroying: BOOLEAN
2690 -- Is `current' being currently destroyed?
2691
2692 feature_stone_already_processed: BOOLEAN
2693 -- Is the processed stone a feature stone and has it
2694 -- been already processed by the editor ?
2695
2696 feature {NONE} -- Implementation
2697
2698 update_save_symbol is
2699 do
2700 Precursor {EB_FILEABLE}
2701 if changed then
2702 save_cmd.enable_sensitive
2703 address_manager.disable_formatters
2704 else
2705 save_cmd.disable_sensitive
2706 update_formatters
2707 end
2708 if is_empty then
2709 print_cmd.disable_sensitive
2710 save_as_cmd.disable_sensitive
2711 else
2712 print_cmd.enable_sensitive
2713 save_as_cmd.enable_sensitive
2714 end
2715 end
2716
2717 is_stone_external: BOOLEAN
2718 -- Does 'stone' contain a .NET consumed type?
2719
2720 update_formatters is
2721 -- Give a correct sensitivity to formatters.
2722 local
2723 cist: CLASSI_STONE
2724 cst: CLASSC_STONE
2725 type_changed: BOOLEAN
2726 do
2727 cst ?= stone
2728 cist ?= stone
2729 -- Check to if formatting context has changed.
2730 if cst /= Void then
2731 type_changed := (cst.e_class.is_true_external and not is_stone_external) or
2732 (not cst.e_class.is_true_external and is_stone_external)
2733 elseif cist /= Void then
2734 type_changed := (cist.class_i.is_external_class and not is_stone_external) or
2735 (not cist.class_i.is_external_class and is_stone_external)
2736 end
2737
2738 if type_changed then
2739 -- Toggle stone flag.
2740 is_stone_external := not is_stone_external
2741 end
2742
2743 if cst /= Void then
2744 address_manager.enable_formatters
2745 if is_stone_external then
2746 -- Change formatters to .NET sensitivity (from normal).
2747 enable_dotnet_formatters
2748 if type_changed then
2749 managed_main_formatters.i_th (4).enable_select
2750 end
2751 else
2752 if changed then
2753 address_manager.disable_formatters
2754 else
2755 --managed_main_formatters.first.disable_sensitive
2756 end
2757 end
2758 elseif cist /= Void and is_stone_external then
2759 -- Change formatters to .NET sensitivity (from normal).
2760 enable_dotnet_formatters
2761 if type_changed then
2762 managed_main_formatters.i_th (4).enable_select
2763 end
2764 else
2765 address_manager.disable_formatters
2766 if cist /= stone then
2767 managed_main_formatters.first.execute
2768 end
2769 end
2770 end
2771
2772 enable_dotnet_formatters is
2773 -- Enable only the .NET class text formatters.
2774 do
2775 from
2776 managed_main_formatters.start
2777 until
2778 managed_main_formatters.after
2779 loop
2780 if managed_main_formatters.item.is_dotnet_formatter then
2781 managed_main_formatters.item.enable_sensitive
2782 else
2783 managed_main_formatters.item.disable_sensitive
2784 end
2785 managed_main_formatters.forth
2786 end
2787 end
2788
2789
2790 on_text_reset is
2791 -- The main editor has just been wiped out
2792 -- before loading a new file.
2793 local
2794 str: STRING
2795 do
2796 str := title.twin
2797 if str @ 1 = '*' then
2798 str.keep_tail (str.count - 2)
2799 set_title (str)
2800 end
2801 address_manager.disable_formatters
2802 status_bar.display_message ("")
2803 status_bar.remove_cursor_position
2804 text_edited := False
2805 end
2806
2807 on_cursor_moved is
2808 -- The cursor has moved, reflect the change in the status bar.
2809 do
2810 refresh_cursor_position
2811 end
2812
2813 on_text_fully_loaded is
2814 -- The main editor has just been reloaded.
2815 do
2816 update_paste_cmd
2817 update_formatters
2818 if editor_tool.text_area.syntax_is_correct then
2819 status_bar.display_message ("")
2820 else
2821 status_bar.display_message (Interface_names.L_syntax_error)
2822 end
2823 refresh_cursor_position
2824 text_edited := False
2825 end
2826
2827 on_text_back_to_its_last_saved_state is
2828 local
2829 str: STRING
2830 do
2831 str := title.twin
2832 if str @ 1 = '*' then
2833 str.keep_tail (str.count - 2)
2834 set_title (str)
2835 end
2836 update_formatters
2837 text_edited := False
2838 end
2839
2840 text_edited: BOOLEAN
2841 -- Do we know that the text was edited?
2842 -- If so, no need to update the display each time it is edited.
2843
2844 on_text_edited (unused: BOOLEAN) is
2845 -- The text in the editor is modified, add the '*' in the title.
2846 -- Gray out the formatters.
2847 local
2848 str: STRING
2849 cst: CLASSI_STONE
2850 do
2851 if not text_edited then
2852 str := title.twin
2853 if str @ 1 /= '*' then
2854 str.prepend ("* ")
2855 set_title (str)
2856 end
2857 address_manager.disable_formatters
2858 cst ?= stone
2859 if cst /= Void then
2860 Eiffel_project.Manager.class_is_edited (cst.class_i)
2861 end
2862 text_edited := True
2863 end
2864 status_bar.display_message ("")
2865 end
2866
2867 on_back is
2868 -- User pressed Alt+left.
2869 -- Go back in the history (or the context history).
2870 do
2871 if context_tool_has_focus then
2872 if context_tool.history_manager.is_back_possible then
2873 context_tool.history_manager.back_command.execute
2874 end
2875 elseif history_manager.is_back_possible then
2876 history_manager.back_command.execute
2877 end
2878 end
2879
2880 on_forth is
2881 -- User pressed Alt+right.
2882 -- Go forth in the history (or the context history).
2883 do
2884 if context_tool_has_focus then
2885 if context_tool.history_manager.is_forth_possible then
2886 context_tool.history_manager.forth_command.execute
2887 end
2888 elseif history_manager.is_forth_possible then
2889 history_manager.forth_command.execute
2890 end
2891 end
2892
2893 context_tool_has_focus: BOOLEAN is
2894 -- Does the context tool or one of its children has the focus?
2895 local
2896 fw: EV_WIDGET
2897 cont: EV_CONTAINER
2898 wid: EV_WIDGET
2899 do
2900 fw := (create {EV_ENVIRONMENT}).application.focused_widget
2901 wid := context_tool.explorer_bar_item.widget
2902 if wid = fw then
2903 Result := True
2904 elseif fw = Void then
2905 Result := False
2906 else
2907 from
2908 cont := fw.parent
2909 until
2910 cont = wid or cont = Void
2911 loop
2912 cont := cont.parent
2913 end
2914 if cont = wid then
2915 Result := True
2916 end
2917 end
2918 end
2919
2920 saved_cursor: CURSOR
2921 -- Saved cursor position for displaying the stack.
2922
2923 can_drop (st: ANY): BOOLEAN is
2924 -- Can the user drop the stone `st'?
2925 local
2926 conv_ace: ACE_SYNTAX_STONE
2927 do
2928 conv_ace ?= st
2929 Result := conv_ace = Void
2930 end
2931
2932 quick_refresh_on_class_drop (unused: CLASSI_STONE) is
2933 -- Quick refresh all windows.
2934 do
2935 window_manager.quick_refresh_all
2936 end
2937
2938 quick_refresh_on_brk_drop (unused: BREAKABLE_STONE) is
2939 -- Quick refresh all windows.
2940 do
2941 window_manager.quick_refresh_all
2942 end
2943
2944 send_stone_to_context is
2945 -- Send current stone to the context tool.
2946 -- Used by `send_stone_to_context_cmd'.
2947 do
2948 if stone /= Void then
2949 context_tool.set_stone (stone)
2950 end
2951 end
2952
2953 destroy is
2954 -- check if current text has been saved and destroy
2955 local
2956 dialog_w: EB_WARNING_DIALOG
2957 do
2958 if editor_tool /= Void and then editor_tool.text_area /= Void and then changed and then not confirmed then
2959 if Window_manager.development_windows_count > 1 then
2960 create dialog_w.make_with_text (Warning_messages.w_Save_before_closing)
2961 dialog_w.set_buttons_and_actions (<<"Yes", "No", "Cancel">>, <<agent save_and_destroy, agent force_destroy, agent do_nothing>>)
2962 dialog_w.set_default_push_button (dialog_w.button("Yes"))
2963 dialog_w.set_default_cancel_button (dialog_w.button("Cancel"))
2964 dialog_w.show_modal_to_window (window)
2965 else
2966 -- We let the window manager handle the saving, along with other windows
2967 -- (not development windows)
2968 force_destroy
2969 end
2970 else
2971 Precursor {EB_TOOL_MANAGER}
2972 end
2973 end
2974
2975 save_and_destroy is
2976 do
2977 save_text
2978 destroy
2979 end
2980
2981 force_destroy is
2982 -- Destroy without asking.
2983 do
2984 confirmed := True
2985 destroy
2986 confirmed := False
2987 end
2988
2989 confirmed: BOOLEAN
2990 -- Did the user say he wanted to exit?
2991
2992 show_dynamic_library_dialog is
2993 -- Create a new dynamic library window and display it.
2994 do
2995 Window_manager.create_dynamic_lib_window
2996 end
2997
2998 recycle is
2999 -- Call the precursors.
3000 do
3001 Precursor {EB_TOOL_MANAGER}
3002 command_controller.recycle
3003 end
3004
3005 feature {NONE} -- Implementation: Editor commands
3006
3007 refresh_cursor_position is
3008 -- Display the current cursor position in the status bar.
3009 require
3010 text_loaded: not is_empty
3011 local
3012 l, c: INTEGER
3013 do
3014 l := editor_tool.text_area.cursor_y_position
3015 c := editor_tool.text_area.cursor_x_position
3016 status_bar.set_cursor_position (l, c)
3017 end
3018
3019 select_all is
3020 -- Select the whole text in the focused editor.
3021 do
3022 current_editor.select_all
3023 end
3024
3025 search is
3026 -- Search some text in the focused editor.
3027 local
3028 cv_ced: EB_CLICKABLE_EDITOR
3029 do
3030 cv_ced ?= current_editor
3031 if cv_ced /= Void then
3032 cv_ced.search
3033 end
3034 end
3035
3036 find_next is
3037 -- Find the next occurrence of the search text.
3038 local
3039 cv_ced: EB_CLICKABLE_EDITOR
3040 do
3041 if search_tool.currently_searched /= Void then
3042 cv_ced ?= current_editor
3043 if cv_ced /= Void then
3044 cv_ced.find_next
3045 end
3046 else
3047 search_tool.show_and_set_focus
3048 end
3049 end
3050
3051 find_previous is
3052 -- Find the previous occurrence of the search text.
3053 local
3054 cv_ced: EB_CLICKABLE_EDITOR
3055 do
3056 if search_tool.currently_searched /= Void then
3057 cv_ced ?= current_editor
3058 if cv_ced /= Void then
3059 cv_ced.find_previous
3060 end
3061 else
3062 search_tool.show_and_set_focus
3063 end
3064 end
3065
3066 find_selection is
3067 -- Find the next occurrence of the selection.
3068 local
3069 cv_ced: EB_CLICKABLE_EDITOR
3070 do
3071 cv_ced ?= current_editor
3072 if cv_ced /= Void then
3073 cv_ced.find_selection
3074 end
3075 end
3076
3077 cut_selection is
3078 -- Cut the selection in the current editor.
3079 do
3080 current_editor.cut_selection
3081 end
3082
3083 copy_selection is
3084 -- Cut the selection in the current editor.
3085 do
3086 current_editor.copy_selection
3087 end
3088
3089 toggle_formatting_marks is
3090 -- Show/Hide formatting marks in the editor and update related menu item.
3091 do
3092 current_editor.toggle_view_invisible_symbols
3093 if current_editor.view_invisible_symbols then
3094 formatting_marks_command_menu_item.set_text (Interface_names.m_Hide_formatting_marks)
3095 else
3096 formatting_marks_command_menu_item.set_text(Interface_names.m_Show_formatting_marks)
3097 end
3098 end
3099
3100 feature {NONE} -- Implementation / Menus
3101
3102 number_of_displayed_external_commands: INTEGER
3103 -- Number of external commands in the tools menu.
3104
3105 old_cur: EV_CURSOR
3106 -- Cursor saved while displaying the hourglass cursor.
3107
3108 cur_wid: EV_WIDGET
3109 -- Widget on which the hourglass cursor was set.
3110
3111 project_menu: EV_MENU
3112 -- Menu for entries relative to the Project.
3113
3114 recent_projects_menu: EB_RECENT_PROJECTS_MANAGER_MENU
3115 -- SubMenu for recent projects.
3116
3117 during_synchronization: BOOLEAN
3118 -- Are we during a resynchronization?
3119
3120 formatting_marks_command_menu_item: EB_COMMAND_MENU_ITEM
3121 -- Menu item used to shw/hide formatting marks.
3122
3123 undo_accelerator: EV_ACCELERATOR
3124 -- Accelerator for Ctrl+Z
3125
3126 redo_accelerator: EV_ACCELERATOR
3127 -- Accelerator for Ctrl+Y
3128
3129 feature {EB_TOOL} -- Implementation / Commands
3130
3131 shell_cmd: EB_OPEN_SHELL_COMMAND
3132 -- Command to use an external editor.
3133
3134 undo_cmd: EB_UNDO_COMMAND
3135 -- Command to undo in the editor.
3136
3137 redo_cmd: EB_REDO_COMMAND
3138 -- Command to redo in the editor.
3139
3140 editor_cut_cmd: EB_ON_SELECTION_COMMAND
3141 -- Command to cut text in the editor.
3142
3143 editor_copy_cmd: EB_ON_SELECTION_COMMAND
3144 -- Command to copy text in the editor.
3145
3146 editor_paste_cmd: EB_EDITOR_PASTE_COMMAND
3147 -- Command to paste text in the editor.
3148
3149 melt_cmd: EB_MELT_PROJECT_COMMAND
3150 -- Command to start compilation.
3151
3152 freeze_cmd: EB_FREEZE_PROJECT_COMMAND
3153 -- Command to Freeze the project.
3154
3155 finalize_cmd: EB_FINALIZE_PROJECT_COMMAND
3156 -- Command to Finalize the project.
3157
3158 c_workbench_compilation_cmd: EB_C_COMPILATION_COMMAND
3159 -- Command to compile the workbench C code.
3160
3161 c_finalized_compilation_cmd: EB_C_COMPILATION_COMMAND
3162 -- Command to compile the finalized C code.
3163
3164 new_cluster_cmd: EB_NEW_CLUSTER_COMMAND
3165 -- Command to create a new cluster.
3166
3167 new_class_cmd: EB_NEW_CLASS_COMMAND
3168 -- Command to create a new class.
3169
3170 new_feature_cmd: EB_NEW_FEATURE_COMMAND
3171 -- Command to execute the feature wizard.
3172
3173 toggle_feature_signature_cmd: EB_TOGGLE_FEATURE_SIGNATURE_COMMAND
3174 -- Show/Hide signature of feature node in eb_feature_tool
3175
3176 toggle_stone_cmd: EB_UNIFY_STONE_CMD
3177 -- Command to toggle between the stone management modes.
3178
3179 delete_class_cluster_cmd: EB_DELETE_CLASS_CLUSTER_COMMAND
3180 -- Command to remove a class or a cluster from the system
3181 -- (permanent deletion).
3182
3183 show_profiler: EB_SHOW_PROFILE_TOOL
3184 -- What allows us to display the profiler window.
3185
3186 toolbarable_commands: ARRAYED_LIST [EB_TOOLBARABLE_COMMAND]
3187 -- All commands that can be put in a toolbar.
3188
3189 command_controller: EB_EDITOR_COMMAND_CONTROLLER
3190 -- Object that takes care of updating the sensitivity of all editor commands.
3191
3192 save_as_cmd: EB_SAVE_FILE_AS_COMMAND
3193 -- Command to save a class with a different file name.
3194
3195 Edit_external_commands_cmd: EB_EXTERNAL_COMMANDS_EDITOR is
3196 -- Command that lets the user add new external commands to the tools menu.
3197 once
3198 create Result.make
3199 Result.enable_sensitive
3200 end
3201
3202 system_info_cmd: EB_STANDARD_CMD is
3203 -- Command to display information about the system (root class,...)
3204 do
3205 Result := debugger_manager.system_info_cmd
3206 end
3207
3208 display_error_help_cmd: EB_ERROR_INFORMATION_CMD is
3209 -- Command to pop up a dialog giving help on compilation errors.
3210 do
3211 Result := debugger_manager.display_error_help_cmd
3212 end
3213
3214 send_stone_to_context_cmd: EB_STANDARD_CMD
3215 -- Command to send the current stone to the context tool.
3216
3217 print_cmd: EB_PRINT_COMMAND
3218 -- Command to print the content of editor with focus
3219
3220 eac_browser_cmd: EB_OPEN_EAC_BROWSER_CMD is
3221 -- Command to display the eac browser
3222 do
3223 Result := Debugger_manager.eac_browser_cmd
3224 end
3225
3226 show_favorites_menu_item: EV_MENU_ITEM
3227 -- Show/Hide favorites menu item.
3228
3229 update_show_favorites_menu_item is
3230 -- Update `show_favorites_menu_item' menu label.
3231 do
3232 if favorites_tool.shown then
3233 show_favorites_menu_item.set_text (Interface_names.m_Hide_favorites)
3234 else
3235 show_favorites_menu_item.set_text (Interface_names.m_Show_favorites)
3236 end
3237 end
3238
3239 execute_show_favorites is
3240 -- Show `favorites_tool' if it is closed, close
3241 -- it in the opposite case.
3242 do
3243 update_show_favorites_menu_item
3244 if favorites_tool.shown then
3245 favorites_tool.close
3246 else
3247 favorites_tool.show
3248 end
3249 end
3250
3251 feature {EB_TOOL_WINDOW, EB_EXPLORER_BAR, EB_DEBUGGER_MANAGER} -- Floating tool handling
3252
3253 all_tool_windows: ARRAYED_LIST [EB_TOOL_WINDOW]
3254 -- All tool windows under the control of `Current'.
3255
3256 add_tool_window (a_tool_window: EB_TOOL_WINDOW) is
3257 -- Add `a_tool_window' to `all_tool_windows', ensuring it is
3258 -- then under the control of `Current'.
3259 require
3260 a_tool_window_not_void: a_tool_window /= Void
3261 do
3262 if all_tool_windows = Void then
3263 create all_tool_windows.make (2)
3264 end
3265 all_tool_windows.extend (a_tool_window)
3266 ensure
3267 extended: all_tool_windows.has (a_tool_window)
3268 end
3269
3270 remove_tool_window (a_widget: EV_WIDGET) is
3271 -- Remove tool window associate with `a_widget'.
3272 require
3273 a_widget_not_void: a_widget /= Void
3274 do
3275 if all_tool_windows /= Void then
3276 from
3277 all_tool_windows.start
3278 until
3279 all_tool_windows.off
3280 loop
3281 if all_tool_windows.item.tool = a_widget then
3282 all_tool_windows.remove
3283 all_tool_windows.finish
3284 end
3285 all_tool_windows.forth
3286 end
3287 end
3288 end
3289
3290 remove_all_tool_windows is
3291 -- Ensure `all_tool_windows' is empty if non Void.
3292 do
3293 if all_tool_windows /= Void then
3294 all_tool_windows.wipe_out
3295 end
3296 ensure
3297 tool_windows_empty: all_tool_windows.is_empty
3298 end
3299
3300
3301 window_moved (x_pos, y_pos: INTEGER) is
3302 -- `Current' has been moved, so move all associated tool windows within `all_tool_windows'.
3303 local
3304 tool_window: EB_TOOL_WINDOW
3305 do
3306 if all_tool_windows /= Void then
3307 from
3308 all_tool_windows.start
3309 until
3310 all_tool_windows.off
3311 loop
3312 tool_window := all_tool_windows.item
3313 check
3314 not_destroyed: not tool_window.window.is_destroyed
3315 end
3316 if boolean_resource_value ("dock_tracking", True) then
3317 tool_window.window.move_actions.block
3318 tool_window.window.set_x_position (x_pos + tool_window.x_position)
3319 tool_window.window.set_y_position (y_pos + tool_window.y_position)
3320 tool_window.window.move_actions.resume
3321 else
3322 -- If we are not performing dock tracking, we must update the relative position
3323 -- of the tool window, so that if dock tracking is enabled, the relative
3324 -- positions are correct.
3325 tool_window.set_x_position ( tool_window.window.screen_x - x_pos)
3326 tool_window.set_y_position ( tool_window.window.screen_y - y_pos)
3327 end
3328 all_tool_windows.forth
3329 end
3330 end
3331 end
3332
3333 feature {NONE} -- external edition handling
3334
3335 on_focus is
3336 -- check if the text has not been modified by an external editor
3337 local
3338 dialog: EV_INFORMATION_DIALOG
3339 button_labels: ARRAY [STRING]
3340 actions: ARRAY [PROCEDURE [ANY, TUPLE]]
3341 do
3342 debug ("DEBUGGER_INTERFACE")
3343 io.put_string ("Took focus!%N")
3344 end
3345 if not editor_tool.edited_file_is_up_to_date then
3346 if not editor_tool.file_date_already_checked then
3347 if not editor_tool.changed and Editor_preferences.automatic_update
3348 then
3349 editor_tool.reload
3350 else
3351 create dialog.make_with_text (warning_messages.w_file_modified_by_another_editor)
3352 create button_labels.make (1, 2)
3353 create actions.make (1, 2)
3354 button_labels.put (interface_names.b_Reload, 1)
3355 actions.put (agent editor_tool.reload, 1)
3356 button_labels.put (interface_names.b_Continue_anyway, 2)
3357 actions.put (agent editor_tool.set_changed (True), 2)
3358 dialog.set_buttons_and_actions (button_labels,actions)
3359 dialog.set_default_push_button (dialog.button (button_labels @ 1))
3360 dialog.set_default_cancel_button (dialog.button (button_labels @ 2))
3361 dialog.set_title (interface_names.t_External_edition)
3362 dialog.show_modal_to_window (window)
3363 end
3364 end
3365 end
3366 end
3367
3368 feature {NONE} -- Execution
3369
3370 Kcst: EV_KEY_CONSTANTS is
3371 -- A way to access key constants.
3372 once
3373 create Result
3374 end
3375
3376 toolbar_right_click_action (a_x, a_y, a_button: INTEGER; a_x_tilt, a_y_tilt, a_pressure: DOUBLE; a_screen_x, a_screen_y: INTEGER) is
3377 -- Action called when the user right-click in the toolbar.
3378 -- Display a popup menu to show/hide toolbars and customize the general toolbar.
3379 local
3380 popup_menu: EV_MENU
3381 do
3382 if a_button = 3 then
3383 popup_menu := build_toolbar_menu
3384 popup_menu.show
3385 end
3386 end
3387
3388 enable_commands_on_project_created is
3389 -- Enable commands when a new project has been created (not yet compiled)
3390 do
3391 system_info_cmd.enable_sensitive
3392 if
3393 stone /= Void and then
3394 not unified_stone
3395 then
3396 send_stone_to_context_cmd.enable_sensitive
3397 end
3398 end
3399
3400 enable_commands_on_project_loaded is
3401 -- Enable commands when a new project has been created and compiled
3402 do
3403 if has_profiler then
3404 show_profiler.enable_sensitive
3405 end
3406 if has_dll_generation then
3407 show_dynamic_lib_tool.enable_sensitive
3408 end
3409 open_cmd.enable_sensitive
3410 new_class_cmd.enable_sensitive
3411 new_cluster_cmd.enable_sensitive
3412 system_info_cmd.enable_sensitive
3413 if unified_stone then
3414 send_stone_to_context_cmd.disable_sensitive
3415 elseif stone /= Void then
3416 send_stone_to_context_cmd.enable_sensitive
3417 end
3418 new_class_cmd.enable_sensitive
3419 new_cluster_cmd.enable_sensitive
3420 delete_class_cluster_cmd.enable_sensitive
3421 c_workbench_compilation_cmd.enable_sensitive
3422 c_finalized_compilation_cmd.enable_sensitive
3423 end
3424
3425 disable_commands_on_project_unloaded is
3426 -- Enable commands when a project has been closed.
3427 do
3428 if has_dll_generation then
3429 show_dynamic_lib_tool.disable_sensitive
3430 end
3431 if has_profiler then
3432 show_profiler.disable_sensitive
3433 end
3434 open_cmd.disable_sensitive
3435 new_class_cmd.disable_sensitive
3436 new_cluster_cmd.disable_sensitive
3437 if not project_manager.is_created then
3438 system_info_cmd.disable_sensitive
3439 send_stone_to_context_cmd.disable_sensitive
3440 end
3441 delete_class_cluster_cmd.disable_sensitive
3442 c_workbench_compilation_cmd.disable_sensitive
3443 c_finalized_compilation_cmd.disable_sensitive
3444 end
3445
3446 end -- class EB_DEVELOPMENT_WINDOW
3447

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23