/[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 48565 - (show annotations)
Fri Feb 18 22:11:49 2005 UTC (15 years ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 100249 byte(s)
Added ability to search for special kind of callers: usage, assign, creation.

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 feature {DEPEND_UNIT}.is_in_assignment_flag))
401 managed_feature_formatters.extend (create {EB_CALLERS_FORMATTER}.make (Current,
402 feature {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 local
2269 txt: STRING
2270 do
2271 txt := current_editor.clipboard.text
2272 if
2273 not current_editor.is_empty and then
2274 current_editor.is_editable and then
2275 txt /= Void and then
2276 not txt.is_empty
2277 then
2278 editor_paste_cmd.enable_sensitive
2279 else
2280 editor_paste_cmd.disable_sensitive
2281 end
2282 end
2283
2284 feature {NONE} -- Multiple editor management
2285
2286 editors: ARRAYED_LIST [EB_EDITOR]
2287 -- editor contained in `Current'
2288
2289 current_editor_index: INTEGER
2290 -- Index in `editors' of the editor that has the focus.
2291
2292 feature {EB_FEATURES_TOOL, EB_FEATURES_TREE, DOTNET_CLASS_AS, DOTNET_CLASS_CONTEXT} -- Feature Clauses
2293
2294 set_feature_clauses (a_features: ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]]; a_type: STRING) is
2295 -- Set 'features' to 'a_features' and store in hash table with key 'a_type' denoting name of consumed
2296 -- type pertinent to 'a_features'.
2297 require
2298 a_features_not_void: a_features /= Void
2299 do
2300 if feature_clauses = Void then
2301 create feature_clauses.make (5)
2302 end
2303 feature_clauses.put (a_features, a_type)
2304 end
2305
2306 get_feature_clauses (a_type: STRING): ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]] is
2307 -- Get list of feature clauses relevant to .NET type with name 'a_type'.
2308 require
2309 a_type_not_void: a_type /= Void
2310 has_type_clauses: feature_clauses.has (a_type)
2311 do
2312 Result := feature_clauses.item (a_type)
2313 ensure
2314 result_not_void: Result /= Void
2315 end
2316
2317 feature_clauses: HASH_TABLE [ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]], STRING]
2318 -- List of features clauses for Current window hashed by the .NET name of the consumed_type.
2319
2320 feature_positions: HASH_TABLE [INTEGER, E_FEATURE]
2321 -- Features indexed by line position in class text (for .NET features).
2322
2323 feature {EB_WINDOW_MANAGER} -- Window management / Implementation
2324
2325 destroy_imp is
2326 -- Destroy window.
2327 do
2328 -- To avoid reentrance
2329 if not is_destroying then
2330 is_destroying := True
2331 -- If a launched application is still running, kill it.
2332 if Application.is_running and then debugger_manager.debugging_window = Current then
2333 Application.kill
2334 else
2335 save_left_panel_layout (left_panel.save_to_resource)
2336 save_right_panel_layout (right_panel.save_to_resource)
2337 end
2338 save_left_panel_width (panel.split_position)
2339 -- Save width & height.
2340 save_size (window.width, window.height, window.is_maximized)
2341 left_panel.wipe_out
2342 right_panel.wipe_out
2343 save_search_tool_options (search_tool)
2344 hide
2345
2346 -- Commit saves
2347 save_resources
2348
2349 toolbars_area.wipe_out
2350 address_manager.recycle
2351 project_customizable_toolbar.recycle
2352 Precursor {EB_TOOL_MANAGER}
2353
2354 managed_class_formatters.wipe_out
2355 managed_feature_formatters.wipe_out
2356 managed_main_formatters.wipe_out
2357 toolbarable_commands.wipe_out
2358 editors.wipe_out
2359 stone := Void
2360 end
2361 end
2362
2363 feature {NONE} -- Implementation
2364
2365 set_stone_after_check (a_stone: STONE) is
2366 local
2367 old_stone: STONE
2368 new_class_stone: CLASSI_STONE
2369 old_class_stone: CLASSI_STONE
2370 conv_classc: CLASSC_STONE
2371 conv_brkstone: BREAKABLE_STONE
2372 cluster_st: CLUSTER_STONE
2373 feature_stone: FEATURE_STONE
2374 conv_ferrst: FEATURE_ERROR_STONE
2375 l_format_context: FORMAT_CONTEXT
2376 l_indexes: EIFFEL_LIST [INDEX_AS]
2377 conv_errst: ERROR_STONE
2378 class_file: RAW_FILE
2379 class_text_exists: BOOLEAN
2380 same_class: BOOLEAN
2381 test_stone: CLASSI_STONE
2382 conv_ace: ACE_SYNTAX_STONE
2383 externali: EXTERNAL_CLASS_I
2384 l_reader: EIFFEL_XML_DESERIALIZER
2385 external_cons: CONSUMED_TYPE
2386 str: STRING
2387 dotnet_class: BOOLEAN
2388 l_short_formatter: EB_SHORT_FORMATTER
2389 l_flat_formatter: EB_FLAT_SHORT_FORMATTER
2390 do
2391 -- the text does not change if the text was saved with syntax errors
2392 cur_wid := window
2393 if cur_wid = Void then
2394 --| Do nothing.
2395 else
2396 if old_cur = Void then
2397 old_cur := cur_wid.pointer_style
2398 end
2399 -- cur_wid.enable_capture
2400 cur_wid.set_pointer_style (Wait_cursor)
2401 end
2402
2403 conv_brkstone ?= a_stone
2404 conv_errst ?= a_stone
2405 conv_ace ?= a_stone
2406 if conv_brkstone /= Void then
2407 if Application.is_breakpoint_enabled (conv_brkstone.routine, conv_brkstone.index) then
2408 Application.remove_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2409 else
2410 Application.set_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2411 end
2412 output_manager.display_stop_points
2413 window_manager.quick_refresh_all
2414 elseif conv_errst /= Void then
2415 display_error_help_cmd.execute_with_stone (conv_errst)
2416 elseif conv_ace /= Void then
2417 --| FIXME XR: What should we do?!
2418 else
2419
2420 -- Remember previous stone.
2421 old_stone := stone
2422 old_class_stone ?= stone
2423
2424 -- New stone properties
2425 new_class_stone ?= a_stone
2426
2427 -- Set the stone.
2428 old_set_stone (a_stone)
2429 cluster_st ?= a_stone
2430
2431 new_feature_cmd.disable_sensitive
2432 toggle_feature_signature_cmd.disable_sensitive
2433
2434 -- We update the state of the `Add to Favorites' command.
2435 if new_class_stone /= Void then
2436 favorites_menu.first.enable_sensitive
2437 else
2438 favorites_menu.first.disable_sensitive
2439 end
2440
2441 -- Update the history.
2442 if
2443 new_class_stone /= Void
2444 then
2445 history_manager.extend (new_class_stone)
2446 elseif
2447 cluster_st /= Void
2448 then
2449 history_manager.extend (cluster_st)
2450 end
2451 -- Update the address manager if needed.
2452 address_manager.refresh
2453 if new_class_stone /= Void then
2454 -- class stone was dropped
2455 create class_file.make (new_class_stone.class_i.file_name)
2456 class_text_exists := class_file.exists
2457 feature_stone ?= a_stone
2458 --| We have to create a classi_stone to check whether the stones are really similar.
2459 --| Otherwise a redefinition of same_as may be called.
2460 create test_stone.make (new_class_stone.class_i)
2461 if test_stone.same_as (old_class_stone) then
2462 same_class := True
2463 end
2464 if not feature_stone_already_processed then
2465 if
2466 same_class and then text_saved
2467 then
2468 -- nothing changed in the editor
2469 -- we only have to update click_list
2470 if editor_tool.text_area.is_editable then
2471 editor_tool.text_area.update_click_list (False)
2472 end
2473 else
2474 if changed then
2475 -- user has already chosen not to save the file
2476 -- do not ask again
2477 Feature_positions.wipe_out
2478 editor_tool.text_area.no_save_before_next_load
2479 end
2480 end
2481 end
2482
2483 conv_classc ?= new_class_stone
2484 if conv_classc = Void or else
2485 conv_classc.e_class.is_external or else
2486 feature_stone /= Void and not
2487 feature_stone_already_processed and not
2488 (same_class and context_tool.sending_stone) then
2489 -- If a classi_stone or a feature_stone or a external call
2490 -- has been dropped, check to see if a .NET class.
2491 if class_text_exists then
2492 if new_class_stone.class_i.is_external_class then
2493 create l_reader
2494 externali ?= new_class_stone.class_i
2495 external_cons ?= l_reader.new_object_from_file (externali.file_name)
2496 if external_cons /= Void then
2497 -- A .NET class.
2498 dotnet_class := True
2499 l_short_formatter ?= managed_main_formatters.i_th (4)
2500 l_flat_formatter ?= managed_main_formatters.i_th (5)
2501 if l_short_formatter /= Void then
2502 l_short_formatter.set_dotnet_mode (True)
2503 end
2504 if l_flat_formatter /= Void then
2505 l_flat_formatter.set_dotnet_mode (True)
2506 end
2507 end
2508 else
2509 managed_main_formatters.first.set_stone (new_class_stone)
2510 managed_main_formatters.first.execute
2511 end
2512 else
2513 editor_tool.text_area.clear_window
2514 editor_tool.text_area.display_message (
2515 Warning_messages.w_file_not_exist (
2516 new_class_stone.class_i.file_name))
2517 end
2518 end
2519 if conv_classc = Void then
2520 --| The dropped class is not compiled.
2521 --| Display only the textual formatter.
2522 if dotnet_class then
2523 managed_main_formatters.i_th (4).set_stone (new_class_stone)
2524 managed_main_formatters.i_th (5).set_stone (new_class_stone)
2525 managed_main_formatters.i_th (4).execute
2526 end
2527 address_manager.disable_formatters
2528 else
2529 --| We have a compiled class.
2530 if
2531 class_text_exists and then
2532 Eiffel_project.Workbench.last_reached_degree <= 2
2533 then
2534 new_feature_cmd.enable_sensitive
2535 toggle_feature_signature_cmd.enable_sensitive
2536 end
2537
2538 --address_manager.enable_formatters
2539 update_formatters
2540 if not class_text_exists then
2541 --| Disable the textual formatter.
2542 managed_main_formatters.first.disable_sensitive
2543 from
2544 managed_main_formatters.start
2545 until
2546 managed_main_formatters.after
2547 loop
2548 managed_main_formatters.item.set_stone (new_class_stone)
2549 managed_main_formatters.forth
2550 end
2551 managed_main_formatters.i_th (2).execute
2552 else
2553 if not changed or not same_class then
2554 --| Enable all formatters.
2555 if
2556 not feature_stone_already_processed or
2557 not managed_main_formatters.first.selected
2558 then
2559 from
2560 managed_main_formatters.start
2561 until
2562 managed_main_formatters.after
2563 loop
2564 managed_main_formatters.item.set_stone (new_class_stone)
2565 managed_main_formatters.forth
2566 end
2567 end
2568 else
2569 address_manager.disable_formatters
2570 from
2571 managed_main_formatters.start
2572 until
2573 managed_main_formatters.after
2574 loop
2575 managed_main_formatters.item.set_stone (new_class_stone)
2576 managed_main_formatters.forth
2577 end
2578 end
2579 end
2580 end
2581 else
2582 -- not a class text : cannot be edited
2583 editor_tool.text_area.disable_editable
2584 address_manager.disable_formatters
2585
2586 --| Disable all formatters.
2587 from
2588 managed_main_formatters.start
2589 until
2590 managed_main_formatters.after
2591 loop
2592 managed_main_formatters.item.set_stone (Void)
2593 managed_main_formatters.forth
2594 end
2595 if cluster_st /= Void then
2596 --| FIXME XR: Really manage cluster display in the main editor
2597 create l_format_context.make_for_case
2598 l_format_context.put_text_item (ti_indexing_keyword)
2599 l_format_context.put_new_line
2600 l_format_context.indent
2601 l_format_context.put_text_item (create {INDEXING_TAG_TEXT}.make ("cluster"))
2602 l_format_context.put_text_item_without_tabs (ti_colon)
2603 l_format_context.put_space
2604 l_format_context.put_string ("%"" + cluster_st.cluster_i.cluster_name + "%"")
2605 l_format_context.put_new_line
2606 l_format_context.put_text_item (create {INDEXING_TAG_TEXT}.make ("cluster_path"))
2607 l_format_context.put_text_item_without_tabs (ti_colon)
2608 l_format_context.put_space
2609 l_format_context.put_string ("%"" + cluster_st.cluster_i.path + "%"")
2610 l_format_context.put_new_line
2611 l_indexes := cluster_st.cluster_i.indexes
2612 if l_indexes /= Void then
2613 l_format_context.set_new_line_between_tokens
2614 l_format_context.format_ast (l_indexes)
2615 l_format_context.exdent
2616 end
2617 l_format_context.put_new_line
2618 editor_tool.text_area.process_text (l_format_context.text)
2619 --| END FIXME
2620 end
2621 end
2622 if feature_stone /= Void and class_text_exists and not feature_stone_already_processed and not (same_class and context_tool.sending_stone) then
2623 conv_ferrst ?= feature_stone
2624 if conv_ferrst /= Void then
2625 -- Scroll to the line of the error.
2626 editor_tool.text_area.display_line_when_ready (conv_ferrst.line_number, True)
2627 else
2628 -- if a feature_stone has been dropped
2629 -- scroll to the corresponding feature in the basic text format
2630 if not during_synchronization then
2631 scroll_to_feature (feature_stone.e_feature, new_class_stone.class_i)
2632 end
2633 end
2634 end
2635 -- Update the title of the window
2636 if a_stone /= Void then
2637 if changed then
2638 str := a_stone.header.twin
2639 str.prepend ("* ")
2640 set_title (str)
2641 else
2642 set_title (a_stone.header)
2643 end
2644 else
2645 set_title (Interface_names.t_Empty_development_window)
2646 end
2647
2648 -- Refresh the tools.
2649 features_tool.set_stone (a_stone)
2650 cluster_tool.set_stone (a_stone)
2651 -- Update the context tool.
2652 if unified_stone then
2653 context_tool.set_stone (a_stone)
2654 end
2655
2656 end
2657 if
2658 stone /= Void and then
2659 not unified_stone
2660 then
2661 send_stone_to_context_cmd.enable_sensitive
2662 else
2663 send_stone_to_context_cmd.disable_sensitive
2664 end
2665 if cur_wid = Void then
2666 --| Do nothing.
2667 else
2668 cur_wid.set_pointer_style (old_cur)
2669 old_cur := Void
2670 -- cur_wid.disable_capture
2671 cur_wid := Void
2672 end
2673 end
2674
2675 scroll_to_feature (feat_as: E_FEATURE; displayed_class: CLASS_I) is
2676 -- highlight the feature correspnding to `feat_as' in the class represented by `displayed_class'
2677 require
2678 class_is_not_void: displayed_class /= Void
2679 feat_as_is_not_void: feat_as /= Void
2680 local
2681 begin_index, offset: INTEGER
2682 tmp_text: STRING
2683 do
2684 if not feat_as.is_il_external then
2685 if feat_as.ast /= Void then
2686 begin_index := feat_as.ast.start_position
2687 if platform_constants.is_windows then
2688 tmp_text := displayed_class.text.substring (1, begin_index)
2689 offset := tmp_text.occurrences('%R')
2690 end
2691 editor_tool.text_area.scroll_to_when_ready (begin_index.item - offset)
2692 end
2693 else
2694 -- FIXME NC: Doesn't work properly for .NET features
2695 -- .NET formatted feature.
2696 begin_index := feature_positions.item (feat_as)
2697 if platform_constants.is_windows then
2698 tmp_text := displayed_class.text.substring (1, begin_index)
2699 offset := tmp_text.occurrences('%N')
2700 end
2701 editor_tool.text_area.scroll_to_when_ready (begin_index // 2) -- - offset)
2702 end
2703 end
2704
2705 check_passed: BOOLEAN
2706
2707 save_canceled: BOOLEAN
2708 -- did user cancel save ?
2709
2710 save_only: BOOLEAN
2711 -- skip parse and update after save ?
2712
2713 text_saved: BOOLEAN
2714 -- has the user chosen to save the file
2715
2716 is_destroying: BOOLEAN
2717 -- Is `current' being currently destroyed?
2718
2719 feature_stone_already_processed: BOOLEAN
2720 -- Is the processed stone a feature stone and has it
2721 -- been already processed by the editor ?
2722
2723 feature {NONE} -- Implementation
2724
2725 update_save_symbol is
2726 do
2727 Precursor {EB_FILEABLE}
2728 if changed then
2729 save_cmd.enable_sensitive
2730 address_manager.disable_formatters
2731 else
2732 save_cmd.disable_sensitive
2733 update_formatters
2734 end
2735 if is_empty then
2736 print_cmd.disable_sensitive
2737 save_as_cmd.disable_sensitive
2738 else
2739 print_cmd.enable_sensitive
2740 save_as_cmd.enable_sensitive
2741 end
2742 end
2743
2744 is_stone_external: BOOLEAN
2745 -- Does 'stone' contain a .NET consumed type?
2746
2747 update_formatters is
2748 -- Give a correct sensitivity to formatters.
2749 local
2750 cist: CLASSI_STONE
2751 cst: CLASSC_STONE
2752 type_changed: BOOLEAN
2753 do
2754 cst ?= stone
2755 cist ?= stone
2756 -- Check to if formatting context has changed.
2757 if cst /= Void then
2758 type_changed := (cst.e_class.is_true_external and not is_stone_external) or
2759 (not cst.e_class.is_true_external and is_stone_external)
2760 elseif cist /= Void then
2761 type_changed := (cist.class_i.is_external_class and not is_stone_external) or
2762 (not cist.class_i.is_external_class and is_stone_external)
2763 end
2764
2765 if type_changed then
2766 -- Toggle stone flag.
2767 is_stone_external := not is_stone_external
2768 end
2769
2770 if cst /= Void then
2771 address_manager.enable_formatters
2772 if is_stone_external then
2773 -- Change formatters to .NET sensitivity (from normal).
2774 enable_dotnet_formatters
2775 if type_changed then
2776 managed_main_formatters.i_th (4).enable_select
2777 end
2778 else
2779 if changed then
2780 address_manager.disable_formatters
2781 else
2782 --managed_main_formatters.first.disable_sensitive
2783 end
2784 end
2785 elseif cist /= Void and is_stone_external then
2786 -- Change formatters to .NET sensitivity (from normal).
2787 enable_dotnet_formatters
2788 if type_changed then
2789 managed_main_formatters.i_th (4).enable_select
2790 end
2791 else
2792 address_manager.disable_formatters
2793 if cist /= stone then
2794 managed_main_formatters.first.execute
2795 end
2796 end
2797 end
2798
2799 enable_dotnet_formatters is
2800 -- Enable only the .NET class text formatters.
2801 do
2802 from
2803 managed_main_formatters.start
2804 until
2805 managed_main_formatters.after
2806 loop
2807 if managed_main_formatters.item.is_dotnet_formatter then
2808 managed_main_formatters.item.enable_sensitive
2809 else
2810 managed_main_formatters.item.disable_sensitive
2811 end
2812 managed_main_formatters.forth
2813 end
2814 end
2815
2816
2817 on_text_reset is
2818 -- The main editor has just been wiped out
2819 -- before loading a new file.
2820 local
2821 str: STRING
2822 do
2823 str := title.twin
2824 if str @ 1 = '*' then
2825 str.keep_tail (str.count - 2)
2826 set_title (str)
2827 end
2828 address_manager.disable_formatters
2829 status_bar.display_message ("")
2830 status_bar.remove_cursor_position
2831 text_edited := False
2832 end
2833
2834 on_cursor_moved is
2835 -- The cursor has moved, reflect the change in the status bar.
2836 do
2837 refresh_cursor_position
2838 end
2839
2840 on_text_fully_loaded is
2841 -- The main editor has just been reloaded.
2842 do
2843 update_paste_cmd
2844 update_formatters
2845 if editor_tool.text_area.syntax_is_correct then
2846 status_bar.display_message ("")
2847 else
2848 status_bar.display_message (Interface_names.L_syntax_error)
2849 end
2850 refresh_cursor_position
2851 text_edited := False
2852 end
2853
2854 on_text_back_to_its_last_saved_state is
2855 local
2856 str: STRING
2857 do
2858 str := title.twin
2859 if str @ 1 = '*' then
2860 str.keep_tail (str.count - 2)
2861 set_title (str)
2862 end
2863 update_formatters
2864 text_edited := False
2865 end
2866
2867 text_edited: BOOLEAN
2868 -- Do we know that the text was edited?
2869 -- If so, no need to update the display each time it is edited.
2870
2871 on_text_edited (unused: BOOLEAN) is
2872 -- The text in the editor is modified, add the '*' in the title.
2873 -- Gray out the formatters.
2874 local
2875 str: STRING
2876 cst: CLASSI_STONE
2877 do
2878 if not text_edited then
2879 str := title.twin
2880 if str @ 1 /= '*' then
2881 str.prepend ("* ")
2882 set_title (str)
2883 end
2884 address_manager.disable_formatters
2885 cst ?= stone
2886 if cst /= Void then
2887 Eiffel_project.Manager.class_is_edited (cst.class_i)
2888 end
2889 text_edited := True
2890 end
2891 status_bar.display_message ("")
2892 end
2893
2894 on_back is
2895 -- User pressed Alt+left.
2896 -- Go back in the history (or the context history).
2897 do
2898 if context_tool_has_focus then
2899 if context_tool.history_manager.is_back_possible then
2900 context_tool.history_manager.back_command.execute
2901 end
2902 elseif history_manager.is_back_possible then
2903 history_manager.back_command.execute
2904 end
2905 end
2906
2907 on_forth is
2908 -- User pressed Alt+right.
2909 -- Go forth in the history (or the context history).
2910 do
2911 if context_tool_has_focus then
2912 if context_tool.history_manager.is_forth_possible then
2913 context_tool.history_manager.forth_command.execute
2914 end
2915 elseif history_manager.is_forth_possible then
2916 history_manager.forth_command.execute
2917 end
2918 end
2919
2920 context_tool_has_focus: BOOLEAN is
2921 -- Does the context tool or one of its children has the focus?
2922 local
2923 fw: EV_WIDGET
2924 cont: EV_CONTAINER
2925 wid: EV_WIDGET
2926 do
2927 fw := (create {EV_ENVIRONMENT}).application.focused_widget
2928 wid := context_tool.explorer_bar_item.widget
2929 if wid = fw then
2930 Result := True
2931 elseif fw = Void then
2932 Result := False
2933 else
2934 from
2935 cont := fw.parent
2936 until
2937 cont = wid or cont = Void
2938 loop
2939 cont := cont.parent
2940 end
2941 if cont = wid then
2942 Result := True
2943 end
2944 end
2945 end
2946
2947 saved_cursor: CURSOR
2948 -- Saved cursor position for displaying the stack.
2949
2950 can_drop (st: ANY): BOOLEAN is
2951 -- Can the user drop the stone `st'?
2952 local
2953 conv_ace: ACE_SYNTAX_STONE
2954 do
2955 conv_ace ?= st
2956 Result := conv_ace = Void
2957 end
2958
2959 quick_refresh_on_class_drop (unused: CLASSI_STONE) is
2960 -- Quick refresh all windows.
2961 do
2962 window_manager.quick_refresh_all
2963 end
2964
2965 quick_refresh_on_brk_drop (unused: BREAKABLE_STONE) is
2966 -- Quick refresh all windows.
2967 do
2968 window_manager.quick_refresh_all
2969 end
2970
2971 send_stone_to_context is
2972 -- Send current stone to the context tool.
2973 -- Used by `send_stone_to_context_cmd'.
2974 do
2975 if stone /= Void then
2976 context_tool.set_stone (stone)
2977 end
2978 end
2979
2980 destroy is
2981 -- check if current text has been saved and destroy
2982 local
2983 dialog_w: EB_WARNING_DIALOG
2984 do
2985 if editor_tool /= Void and then editor_tool.text_area /= Void and then changed and then not confirmed then
2986 if Window_manager.development_windows_count > 1 then
2987 create dialog_w.make_with_text (Warning_messages.w_Save_before_closing)
2988 dialog_w.set_buttons_and_actions (<<"Yes", "No", "Cancel">>, <<agent save_and_destroy, agent force_destroy, agent do_nothing>>)
2989 dialog_w.set_default_push_button (dialog_w.button("Yes"))
2990 dialog_w.set_default_cancel_button (dialog_w.button("Cancel"))
2991 dialog_w.show_modal_to_window (window)
2992 else
2993 -- We let the window manager handle the saving, along with other windows
2994 -- (not development windows)
2995 force_destroy
2996 end
2997 else
2998 Precursor {EB_TOOL_MANAGER}
2999 end
3000 end
3001
3002 save_and_destroy is
3003 do
3004 save_text
3005 destroy
3006 end
3007
3008 force_destroy is
3009 -- Destroy without asking.
3010 do
3011 confirmed := True
3012 destroy
3013 confirmed := False
3014 end
3015
3016 confirmed: BOOLEAN
3017 -- Did the user say he wanted to exit?
3018
3019 show_dynamic_library_dialog is
3020 -- Create a new dynamic library window and display it.
3021 do
3022 Window_manager.create_dynamic_lib_window
3023 end
3024
3025 recycle is
3026 -- Call the precursors.
3027 do
3028 Precursor {EB_TOOL_MANAGER}
3029 command_controller.recycle
3030 end
3031
3032 feature {NONE} -- Implementation: Editor commands
3033
3034 refresh_cursor_position is
3035 -- Display the current cursor position in the status bar.
3036 require
3037 text_loaded: not is_empty
3038 local
3039 l, c: INTEGER
3040 do
3041 l := editor_tool.text_area.cursor_y_position
3042 c := editor_tool.text_area.cursor_x_position
3043 status_bar.set_cursor_position (l, c)
3044 end
3045
3046 select_all is
3047 -- Select the whole text in the focused editor.
3048 do
3049 current_editor.select_all
3050 end
3051
3052 search is
3053 -- Search some text in the focused editor.
3054 local
3055 cv_ced: EB_CLICKABLE_EDITOR
3056 do
3057 cv_ced ?= current_editor
3058 if cv_ced /= Void then
3059 cv_ced.search
3060 end
3061 end
3062
3063 find_next is
3064 -- Find the next occurrence of the search text.
3065 local
3066 cv_ced: EB_CLICKABLE_EDITOR
3067 do
3068 if search_tool.currently_searched /= Void then
3069 cv_ced ?= current_editor
3070 if cv_ced /= Void then
3071 cv_ced.find_next
3072 end
3073 else
3074 search_tool.show_and_set_focus
3075 end
3076 end
3077
3078 find_previous is
3079 -- Find the previous occurrence of the search text.
3080 local
3081 cv_ced: EB_CLICKABLE_EDITOR
3082 do
3083 if search_tool.currently_searched /= Void then
3084 cv_ced ?= current_editor
3085 if cv_ced /= Void then
3086 cv_ced.find_previous
3087 end
3088 else
3089 search_tool.show_and_set_focus
3090 end
3091 end
3092
3093 find_selection is
3094 -- Find the next occurrence of the selection.
3095 local
3096 cv_ced: EB_CLICKABLE_EDITOR
3097 do
3098 cv_ced ?= current_editor
3099 if cv_ced /= Void then
3100 cv_ced.find_selection
3101 end
3102 end
3103
3104 cut_selection is
3105 -- Cut the selection in the current editor.
3106 do
3107 current_editor.cut_selection
3108 end
3109
3110 copy_selection is
3111 -- Cut the selection in the current editor.
3112 do
3113 current_editor.copy_selection
3114 end
3115
3116 toggle_formatting_marks is
3117 -- Show/Hide formatting marks in the editor and update related menu item.
3118 do
3119 current_editor.toggle_view_invisible_symbols
3120 if current_editor.view_invisible_symbols then
3121 formatting_marks_command_menu_item.set_text (Interface_names.m_Hide_formatting_marks)
3122 else
3123 formatting_marks_command_menu_item.set_text(Interface_names.m_Show_formatting_marks)
3124 end
3125 end
3126
3127 feature {NONE} -- Implementation / Menus
3128
3129 number_of_displayed_external_commands: INTEGER
3130 -- Number of external commands in the tools menu.
3131
3132 old_cur: EV_CURSOR
3133 -- Cursor saved while displaying the hourglass cursor.
3134
3135 cur_wid: EV_WIDGET
3136 -- Widget on which the hourglass cursor was set.
3137
3138 project_menu: EV_MENU
3139 -- Menu for entries relative to the Project.
3140
3141 recent_projects_menu: EB_RECENT_PROJECTS_MANAGER_MENU
3142 -- SubMenu for recent projects.
3143
3144 during_synchronization: BOOLEAN
3145 -- Are we during a resynchronization?
3146
3147 formatting_marks_command_menu_item: EB_COMMAND_MENU_ITEM
3148 -- Menu item used to shw/hide formatting marks.
3149
3150 undo_accelerator: EV_ACCELERATOR
3151 -- Accelerator for Ctrl+Z
3152
3153 redo_accelerator: EV_ACCELERATOR
3154 -- Accelerator for Ctrl+Y
3155
3156 feature {EB_TOOL} -- Implementation / Commands
3157
3158 shell_cmd: EB_OPEN_SHELL_COMMAND
3159 -- Command to use an external editor.
3160
3161 undo_cmd: EB_UNDO_COMMAND
3162 -- Command to undo in the editor.
3163
3164 redo_cmd: EB_REDO_COMMAND
3165 -- Command to redo in the editor.
3166
3167 editor_cut_cmd: EB_ON_SELECTION_COMMAND
3168 -- Command to cut text in the editor.
3169
3170 editor_copy_cmd: EB_ON_SELECTION_COMMAND
3171 -- Command to copy text in the editor.
3172
3173 editor_paste_cmd: EB_EDITOR_PASTE_COMMAND
3174 -- Command to paste text in the editor.
3175
3176 melt_cmd: EB_MELT_PROJECT_COMMAND
3177 -- Command to start compilation.
3178
3179 freeze_cmd: EB_FREEZE_PROJECT_COMMAND
3180 -- Command to Freeze the project.
3181
3182 finalize_cmd: EB_FINALIZE_PROJECT_COMMAND
3183 -- Command to Finalize the project.
3184
3185 c_workbench_compilation_cmd: EB_C_COMPILATION_COMMAND
3186 -- Command to compile the workbench C code.
3187
3188 c_finalized_compilation_cmd: EB_C_COMPILATION_COMMAND
3189 -- Command to compile the finalized C code.
3190
3191 new_cluster_cmd: EB_NEW_CLUSTER_COMMAND
3192 -- Command to create a new cluster.
3193
3194 new_class_cmd: EB_NEW_CLASS_COMMAND
3195 -- Command to create a new class.
3196
3197 new_feature_cmd: EB_NEW_FEATURE_COMMAND
3198 -- Command to execute the feature wizard.
3199
3200 toggle_feature_signature_cmd: EB_TOGGLE_FEATURE_SIGNATURE_COMMAND
3201 -- Show/Hide signature of feature node in eb_feature_tool
3202
3203 toggle_stone_cmd: EB_UNIFY_STONE_CMD
3204 -- Command to toggle between the stone management modes.
3205
3206 delete_class_cluster_cmd: EB_DELETE_CLASS_CLUSTER_COMMAND
3207 -- Command to remove a class or a cluster from the system
3208 -- (permanent deletion).
3209
3210 show_profiler: EB_SHOW_PROFILE_TOOL
3211 -- What allows us to display the profiler window.
3212
3213 toolbarable_commands: ARRAYED_LIST [EB_TOOLBARABLE_COMMAND]
3214 -- All commands that can be put in a toolbar.
3215
3216 command_controller: EB_EDITOR_COMMAND_CONTROLLER
3217 -- Object that takes care of updating the sensitivity of all editor commands.
3218
3219 save_as_cmd: EB_SAVE_FILE_AS_COMMAND
3220 -- Command to save a class with a different file name.
3221
3222 Edit_external_commands_cmd: EB_EXTERNAL_COMMANDS_EDITOR is
3223 -- Command that lets the user add new external commands to the tools menu.
3224 once
3225 create Result.make
3226 Result.enable_sensitive
3227 end
3228
3229 system_info_cmd: EB_STANDARD_CMD is
3230 -- Command to display information about the system (root class,...)
3231 do
3232 Result := debugger_manager.system_info_cmd
3233 end
3234
3235 display_error_help_cmd: EB_ERROR_INFORMATION_CMD is
3236 -- Command to pop up a dialog giving help on compilation errors.
3237 do
3238 Result := debugger_manager.display_error_help_cmd
3239 end
3240
3241 send_stone_to_context_cmd: EB_STANDARD_CMD
3242 -- Command to send the current stone to the context tool.
3243
3244 print_cmd: EB_PRINT_COMMAND
3245 -- Command to print the content of editor with focus
3246
3247 eac_browser_cmd: EB_OPEN_EAC_BROWSER_CMD is
3248 -- Command to display the eac browser
3249 do
3250 Result := Debugger_manager.eac_browser_cmd
3251 end
3252
3253 show_favorites_menu_item: EV_MENU_ITEM
3254 -- Show/Hide favorites menu item.
3255
3256 update_show_favorites_menu_item is
3257 -- Update `show_favorites_menu_item' menu label.
3258 do
3259 if favorites_tool.shown then
3260 show_favorites_menu_item.set_text (Interface_names.m_Hide_favorites)
3261 else
3262 show_favorites_menu_item.set_text (Interface_names.m_Show_favorites)
3263 end
3264 end
3265
3266 execute_show_favorites is
3267 -- Show `favorites_tool' if it is closed, close
3268 -- it in the opposite case.
3269 do
3270 update_show_favorites_menu_item
3271 if favorites_tool.shown then
3272 favorites_tool.close
3273 else
3274 favorites_tool.show
3275 end
3276 end
3277
3278 feature {EB_TOOL_WINDOW, EB_EXPLORER_BAR, EB_DEBUGGER_MANAGER} -- Floating tool handling
3279
3280 all_tool_windows: ARRAYED_LIST [EB_TOOL_WINDOW]
3281 -- All tool windows under the control of `Current'.
3282
3283 add_tool_window (a_tool_window: EB_TOOL_WINDOW) is
3284 -- Add `a_tool_window' to `all_tool_windows', ensuring it is
3285 -- then under the control of `Current'.
3286 require
3287 a_tool_window_not_void: a_tool_window /= Void
3288 do
3289 if all_tool_windows = Void then
3290 create all_tool_windows.make (2)
3291 end
3292 all_tool_windows.extend (a_tool_window)
3293 ensure
3294 extended: all_tool_windows.has (a_tool_window)
3295 end
3296
3297 remove_tool_window (a_widget: EV_WIDGET) is
3298 -- Remove tool window associate with `a_widget'.
3299 require
3300 a_widget_not_void: a_widget /= Void
3301 do
3302 if all_tool_windows /= Void then
3303 from
3304 all_tool_windows.start
3305 until
3306 all_tool_windows.off
3307 loop
3308 if all_tool_windows.item.tool = a_widget then
3309 all_tool_windows.remove
3310 all_tool_windows.finish
3311 end
3312 all_tool_windows.forth
3313 end
3314 end
3315 end
3316
3317 remove_all_tool_windows is
3318 -- Ensure `all_tool_windows' is empty if non Void.
3319 do
3320 if all_tool_windows /= Void then
3321 all_tool_windows.wipe_out
3322 end
3323 ensure
3324 tool_windows_empty: all_tool_windows /= Void implies all_tool_windows.is_empty
3325 end
3326
3327
3328 window_moved (x_pos, y_pos: INTEGER) is
3329 -- `Current' has been moved, so move all associated tool windows within `all_tool_windows'.
3330 local
3331 tool_window: EB_TOOL_WINDOW
3332 do
3333 if all_tool_windows /= Void then
3334 from
3335 all_tool_windows.start
3336 until
3337 all_tool_windows.off
3338 loop
3339 tool_window := all_tool_windows.item
3340 check
3341 not_destroyed: not tool_window.window.is_destroyed
3342 end
3343 if boolean_resource_value ("dock_tracking", True) then
3344 tool_window.window.move_actions.block
3345 tool_window.window.set_x_position (x_pos + tool_window.x_position)
3346 tool_window.window.set_y_position (y_pos + tool_window.y_position)
3347 tool_window.window.move_actions.resume
3348 else
3349 -- If we are not performing dock tracking, we must update the relative position
3350 -- of the tool window, so that if dock tracking is enabled, the relative
3351 -- positions are correct.
3352 tool_window.set_x_position ( tool_window.window.screen_x - x_pos)
3353 tool_window.set_y_position ( tool_window.window.screen_y - y_pos)
3354 end
3355 all_tool_windows.forth
3356 end
3357 end
3358 end
3359
3360 feature {NONE} -- external edition handling
3361
3362 on_focus is
3363 -- check if the text has not been modified by an external editor
3364 local
3365 dialog: EV_INFORMATION_DIALOG
3366 button_labels: ARRAY [STRING]
3367 actions: ARRAY [PROCEDURE [ANY, TUPLE]]
3368 do
3369 debug ("DEBUGGER_INTERFACE")
3370 io.put_string ("Took focus!%N")
3371 end
3372 if not editor_tool.edited_file_is_up_to_date then
3373 if not editor_tool.file_date_already_checked then
3374 if not editor_tool.changed and Editor_preferences.automatic_update
3375 then
3376 editor_tool.reload
3377 else
3378 create dialog.make_with_text (warning_messages.w_file_modified_by_another_editor)
3379 create button_labels.make (1, 2)
3380 create actions.make (1, 2)
3381 button_labels.put (interface_names.b_Reload, 1)
3382 actions.put (agent editor_tool.reload, 1)
3383 button_labels.put (interface_names.b_Continue_anyway, 2)
3384 actions.put (agent editor_tool.set_changed (True), 2)
3385 dialog.set_buttons_and_actions (button_labels,actions)
3386 dialog.set_default_push_button (dialog.button (button_labels @ 1))
3387 dialog.set_default_cancel_button (dialog.button (button_labels @ 2))
3388 dialog.set_title (interface_names.t_External_edition)
3389 dialog.show_modal_to_window (window)
3390 end
3391 end
3392 end
3393 end
3394
3395 feature {NONE} -- Execution
3396
3397 Kcst: EV_KEY_CONSTANTS is
3398 -- A way to access key constants.
3399 once
3400 create Result
3401 end
3402
3403 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
3404 -- Action called when the user right-click in the toolbar.
3405 -- Display a popup menu to show/hide toolbars and customize the general toolbar.
3406 local
3407 popup_menu: EV_MENU
3408 do
3409 if a_button = 3 then
3410 popup_menu := build_toolbar_menu
3411 popup_menu.show
3412 end
3413 end
3414
3415 enable_commands_on_project_created is
3416 -- Enable commands when a new project has been created (not yet compiled)
3417 do
3418 system_info_cmd.enable_sensitive
3419 if
3420 stone /= Void and then
3421 not unified_stone
3422 then
3423 send_stone_to_context_cmd.enable_sensitive
3424 end
3425 end
3426
3427 enable_commands_on_project_loaded is
3428 -- Enable commands when a new project has been created and compiled
3429 do
3430 if has_profiler then
3431 show_profiler.enable_sensitive
3432 end
3433 if has_dll_generation then
3434 show_dynamic_lib_tool.enable_sensitive
3435 end
3436 open_cmd.enable_sensitive
3437 new_class_cmd.enable_sensitive
3438 new_cluster_cmd.enable_sensitive
3439 system_info_cmd.enable_sensitive
3440 if unified_stone then
3441 send_stone_to_context_cmd.disable_sensitive
3442 elseif stone /= Void then
3443 send_stone_to_context_cmd.enable_sensitive
3444 end
3445 new_class_cmd.enable_sensitive
3446 new_cluster_cmd.enable_sensitive
3447 delete_class_cluster_cmd.enable_sensitive
3448 c_workbench_compilation_cmd.enable_sensitive
3449 c_finalized_compilation_cmd.enable_sensitive
3450 end
3451
3452 disable_commands_on_project_unloaded is
3453 -- Enable commands when a project has been closed.
3454 do
3455 if has_dll_generation then
3456 show_dynamic_lib_tool.disable_sensitive
3457 end
3458 if has_profiler then
3459 show_profiler.disable_sensitive
3460 end
3461 open_cmd.disable_sensitive
3462 new_class_cmd.disable_sensitive
3463 new_cluster_cmd.disable_sensitive
3464 if not project_manager.is_created then
3465 system_info_cmd.disable_sensitive
3466 send_stone_to_context_cmd.disable_sensitive
3467 end
3468 delete_class_cluster_cmd.disable_sensitive
3469 c_workbench_compilation_cmd.disable_sensitive
3470 c_finalized_compilation_cmd.disable_sensitive
3471 end
3472
3473 end -- class EB_DEVELOPMENT_WINDOW
3474

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23