/[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 45157 - (show annotations)
Thu Aug 26 01:32:15 2004 UTC (15 years, 5 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 98624 byte(s)
When destroying a development window while debugging taking that more than one
  development windows are open, there was a crash because we were trying to
  save the debugger layout twice. Once in `destroy_imp' and the second one indirectly
  by calling `Application.kill'. Now we simply use `Application.kill'.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23