/[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 27144 - (show annotations)
Wed Aug 22 21:21:58 2001 UTC (18 years, 6 months ago) by etienne
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 78273 byte(s)
Updated so that, when calls to undo put an edited text back into its last saved state,
it is considered unchanged: the save icon becomes insensitive and the star in the title
bar disappears.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23