/[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 33315 - (hide annotations)
Mon Jul 29 16:13:05 2002 UTC (17 years, 6 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 93091 byte(s)
Fixed potential problem when switching from version previous 5.2.928 to 5.2.928.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23