/[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 33294 - (hide annotations)
Sat Jul 27 02:22:45 2002 UTC (17 years, 7 months ago) by neilc
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 93025 byte(s)
Made changes to account for .NET class formatting.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23