/[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 26913 - (show annotations)
Sun Aug 12 23:50:20 2001 UTC (18 years, 6 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 77916 byte(s)
Merged branch `dev46_manu' to the trunc.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23