/[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 42965 - (show annotations)
Wed May 12 15:48:36 2004 UTC (15 years, 9 months ago) by jfiat
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 98778 byte(s)
finished to add "signature" toggle for feature_tool

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23