/[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 27108 - (hide annotations)
Tue Aug 21 18:37:02 2001 UTC (18 years, 6 months ago) by etienne
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 77966 byte(s)
Fixed pick n drop update problem on basic text after compilation.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23