/[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 38124 - (hide annotations)
Mon Jul 21 19:16:52 2003 UTC (16 years, 7 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 94000 byte(s)
Fixed bug which was causing the message `File ... Does not exist' not to
be kept on screen and to be switch right away. This was because we were
computing the formatter even if the current stone was identical to the last
one (see last change of this file).
Cosmetics changes (relaced spaces by tabs)

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23