/[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 42089 - (show annotations)
Sat Mar 13 00:22:49 2004 UTC (15 years, 11 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 98108 byte(s)
Fixed `scroll_to_feature' to ensure that when `feat_as.ast' is Void nothing
is done like it was in version 5.1 or older. Reviewed code that calls
`scroll_to_feature' to preserve the original if statement as much as we could.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23