/[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 54847 - (hide annotations)
Mon Oct 3 21:50:19 2005 UTC (14 years, 4 months ago) by tedf
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 109730 byte(s)
Change search tool to regular expression based one, but new search tool has dock-in problem.

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