/[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 46348 - (show annotations)
Fri Nov 5 18:37:26 2004 UTC (15 years, 3 months ago) by king
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 98951 byte(s)
Setting tooltext for Synchronize, Cut and Copy items

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23