/[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 49446 - (show annotations)
Thu Mar 24 07:11:22 2005 UTC (14 years, 11 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 100162 byte(s)
Use new syntax for static calls.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23