/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/windows/eb_development_window.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/windows/eb_development_window.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 55839 - (show annotations)
Tue Nov 22 17:55:30 2005 UTC (14 years, 3 months ago) by tedf
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 122223 byte(s)
Modified 'process' method to notify search tool 'No' is selected in saving dialog.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23