/[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 33365 - (hide annotations)
Fri Aug 2 02:32:46 2002 UTC (17 years, 6 months ago) by neilc
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 92365 byte(s)
Changes to improve .NET class text formatting.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23