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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33858 - (hide annotations)
Wed Aug 21 00:21:30 2002 UTC (17 years, 6 months ago) by neilc
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 93185 byte(s)
Added functionality to format feature tree for .NET classes.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23