/[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 27214 - (show annotations)
Fri Aug 24 23:21:56 2001 UTC (18 years, 6 months ago) by xavier
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 78665 byte(s)
Fixed a typo

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 (3))
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 (4))
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 (6))
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 (7))
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 (5))
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_feature_name)
1263
1264 add_recyclable (command_menu_item)
1265 sub_menu.extend (command_menu_item)
1266
1267 -- Complete class name
1268 create cmd.make
1269 cmd.set_menu_name (Interface_names.m_Complete_class_name + "%T" + Editor_preferences.shorcut_name_for_action (2))
1270 command_menu_item := cmd.new_menu_item
1271 editor_tool.text_area.add_edition_observer(cmd)
1272 cmd.add_agent (editor~complete_feature_name)
1273
1274 add_recyclable (command_menu_item)
1275 sub_menu.extend (command_menu_item)
1276
1277 sub_menu.extend (create {EV_MENU_SEPARATOR})
1278
1279 -- show/hide formatting marks.
1280 create cmd.make
1281 if editor_tool.text_area.view_invisible_symbols then
1282 cmd.set_menu_name (Interface_names.m_Hide_formatting_marks)
1283 else
1284 cmd.set_menu_name (Interface_names.m_Show_formatting_marks)
1285 end
1286 formatting_marks_command_menu_item := cmd.new_menu_item
1287 editor_tool.text_area.add_edition_observer(cmd)
1288 cmd.add_agent (~toggle_formatting_marks)
1289
1290 add_recyclable (formatting_marks_command_menu_item)
1291 sub_menu.extend (formatting_marks_command_menu_item)
1292
1293 edit_menu.extend (sub_menu)
1294 end
1295
1296 build_view_menu is
1297 -- Build the view menu.
1298 local
1299 form: EB_CLASS_INFO_FORMATTER
1300 new_menu_item: EB_COMMAND_MENU_ITEM
1301 new_basic_item: EV_MENU_ITEM
1302 do
1303 Precursor
1304
1305 new_menu_item := toggle_stone_cmd.new_menu_item
1306 view_menu.extend (new_menu_item)
1307 add_recyclable (new_menu_item)
1308
1309 new_menu_item := send_stone_to_context_cmd.new_menu_item
1310 view_menu.extend (new_menu_item)
1311 add_recyclable (new_menu_item)
1312 -- Go to menu
1313 new_basic_item := history_manager.new_menu
1314 view_menu.extend (new_basic_item)
1315
1316 -- Separator --------------------------------------
1317 view_menu.extend (create {EV_MENU_SEPARATOR})
1318 view_menu.extend (build_class_info_menu)
1319 view_menu.extend (build_feature_info_menu)
1320
1321 -- Separator --------------------------------------
1322 view_menu.extend (create {EV_MENU_SEPARATOR})
1323
1324 from
1325 managed_main_formatters.start
1326 until
1327 managed_main_formatters.after
1328 loop
1329 form := managed_main_formatters.item
1330 new_basic_item := form.new_menu_item
1331 new_basic_item.select_actions.put_front (form~invalidate)
1332 view_menu.extend (new_basic_item)
1333 --add_recyclable (new_basic_item)
1334 managed_main_formatters.forth
1335 end
1336 end
1337
1338 build_favorites_menu is
1339 -- Build the favorites menu
1340 do
1341 Precursor {EB_TOOL_MANAGER}
1342
1343 create show_favorites_menu_item
1344 update_show_favorites_menu_item
1345 show_favorites_menu_item.select_actions.extend (~execute_show_favorites)
1346
1347 favorites_menu.start
1348 favorites_menu.put_right (show_favorites_menu_item)
1349 favorites_menu.select_actions.extend (~update_show_favorites_menu_item)
1350 end
1351
1352 build_project_menu is
1353 -- Build the project menu.
1354 local
1355 command_menu_item: EB_COMMAND_MENU_ITEM
1356 do
1357 create project_menu.make_with_text (Interface_names.m_Project)
1358
1359 -- Melt
1360 command_menu_item := Melt_project_cmd.new_menu_item
1361 add_recyclable (command_menu_item)
1362 project_menu.extend (command_menu_item)
1363
1364 -- Freeze
1365 command_menu_item := Freeze_project_cmd.new_menu_item
1366 add_recyclable (command_menu_item)
1367 project_menu.extend (command_menu_item)
1368
1369 -- Finalize
1370 command_menu_item := Finalize_project_cmd.new_menu_item
1371 add_recyclable (command_menu_item)
1372 project_menu.extend (command_menu_item)
1373
1374 -- Precompile
1375 command_menu_item := precompilation_cmd.new_menu_item
1376 add_recyclable (command_menu_item)
1377 project_menu.extend (command_menu_item)
1378
1379 -- Separator -------------------------------------------------
1380 project_menu.extend (create {EV_MENU_SEPARATOR})
1381
1382 -- Compile Workbench C code
1383 command_menu_item := c_workbench_compilation_cmd.new_menu_item
1384 add_recyclable (command_menu_item)
1385 project_menu.extend (command_menu_item)
1386
1387 -- Compile Finalized C code
1388 command_menu_item := c_finalized_compilation_cmd.new_menu_item
1389 add_recyclable (command_menu_item)
1390 project_menu.extend (command_menu_item)
1391
1392 -- Execute Finalized code
1393 command_menu_item := run_finalized_cmd.new_menu_item
1394 add_recyclable (command_menu_item)
1395 project_menu.extend (command_menu_item)
1396
1397 -- Separator -------------------------------------------------
1398 project_menu.extend (create {EV_MENU_SEPARATOR})
1399
1400 -- System Tool window
1401 command_menu_item := system_cmd.new_menu_item
1402 add_recyclable (command_menu_item)
1403 project_menu.extend (command_menu_item)
1404
1405 -- System information
1406 command_menu_item := system_info_cmd.new_menu_item
1407 add_recyclable (command_menu_item)
1408 project_menu.extend (command_menu_item)
1409
1410 -- Error information
1411 command_menu_item := display_error_help_cmd.new_menu_item
1412 add_recyclable (command_menu_item)
1413 project_menu.extend (command_menu_item)
1414
1415 -- Separator -------------------------------------------------
1416 project_menu.extend (create {EV_MENU_SEPARATOR})
1417
1418 -- Generate Documentation
1419 command_menu_item := document_cmd.new_menu_item
1420 add_recyclable (command_menu_item)
1421 project_menu.extend (command_menu_item)
1422
1423 -- Export XMI
1424 command_menu_item := export_cmd.new_menu_item
1425 add_recyclable (command_menu_item)
1426 project_menu.extend (command_menu_item)
1427 end
1428
1429 build_tools_menu is
1430 -- Create and build `tools_menu'
1431 local
1432 command_menu_item: EB_COMMAND_MENU_ITEM
1433 menu_item: EV_MENU_ITEM
1434 do
1435 create tools_menu.make_with_text (Interface_names.m_Tools)
1436
1437
1438 -- Metric tool
1439 create metric_menu.make_with_text (interface_names.l_Tab_metrics)
1440 create menu_item.make_with_text (interface_names.metric_calculate)
1441 metric_menu.extend (menu_item)
1442 create menu_item.make_with_text (interface_names.metric_add)
1443 metric_menu.extend (menu_item)
1444 create menu_item.make_with_text (interface_names.metric_delete)
1445 metric_menu.extend (menu_item)
1446 create menu_item.make_with_text (interface_names.metric_details)
1447 metric_menu.extend (menu_item)
1448 create menu_item.make_with_text (interface_names.metric_new_metrics)
1449 metric_menu.extend (menu_item)
1450 create menu_item.make_with_text (interface_names.metric_management)
1451 metric_menu.extend (menu_item)
1452 create menu_item.make_with_text (interface_names.metric_archive)
1453 metric_menu.extend (menu_item)
1454 metric_menu.disable_sensitive
1455 tools_menu.extend (metric_menu)
1456
1457 -- Profiler Window
1458 command_menu_item := show_profiler.new_menu_item
1459 add_recyclable (command_menu_item)
1460 tools_menu.extend (command_menu_item)
1461
1462 -- Precompile Wizard
1463 command_menu_item := wizard_precompile_cmd.new_menu_item
1464 add_recyclable (command_menu_item)
1465 tools_menu.extend (command_menu_item)
1466
1467 -- Dynamic Library Window
1468 command_menu_item := show_dynamic_lib_tool.new_menu_item
1469 add_recyclable (command_menu_item)
1470 tools_menu.extend (command_menu_item)
1471
1472 if debugger_manager.display_dotnet_cmd then
1473 -- Import .Net Assembly
1474 command_menu_item := dotnet_import_cmd.new_menu_item
1475 add_recyclable (command_menu_item)
1476 tools_menu.extend (command_menu_item)
1477 end
1478
1479 -- Separator -------------------------------------------------
1480 tools_menu.extend (create {EV_MENU_SEPARATOR})
1481
1482 -- New Cluster command.
1483 command_menu_item := new_cluster_cmd.new_menu_item
1484 add_recyclable (command_menu_item)
1485 tools_menu.extend (command_menu_item)
1486
1487 -- New Class command.
1488 command_menu_item := new_class_cmd.new_menu_item
1489 add_recyclable (command_menu_item)
1490 tools_menu.extend (command_menu_item)
1491
1492 -- New Feature command.
1493 command_menu_item := new_feature_cmd.new_menu_item
1494 add_recyclable (command_menu_item)
1495 tools_menu.extend (command_menu_item)
1496
1497 -- Delete class/cluster command.
1498 command_menu_item := delete_class_cluster_cmd.new_menu_item
1499 add_recyclable (command_menu_item)
1500 tools_menu.extend (command_menu_item)
1501
1502 -- Separator --------------------------------------
1503 tools_menu.extend (create {EV_MENU_SEPARATOR})
1504
1505 -- Preferences
1506 command_menu_item := Show_preferences_cmd.new_menu_item
1507 add_recyclable (command_menu_item)
1508 tools_menu.extend (command_menu_item)
1509 end
1510
1511 feature -- Stone process
1512
1513 stone: STONE
1514 -- Current stone
1515
1516 toggle_unified_stone is
1517 -- Change the stone management mode.
1518 do
1519 unified_stone := not unified_stone
1520 if unified_stone then
1521 send_stone_to_context
1522 send_stone_to_context_cmd.disable_sensitive
1523 context_tool.link_to_development_window
1524 else
1525 if stone /= Void then
1526 send_stone_to_context_cmd.enable_sensitive
1527 end
1528 context_tool.cut_from_development_window
1529 end
1530 end
1531
1532 set_stone (a_stone: STONE) is
1533 -- Display text associated with `a_stone', if any and if possible
1534 local
1535 feature_stone: FEATURE_STONE
1536 old_class_stone: CLASSI_STONE
1537 test_stone: CLASSI_STONE
1538 same_class: BOOLEAN
1539 conv_ferrst: FEATURE_ERROR_STONE
1540 do
1541 old_class_stone ?= stone
1542 feature_stone ?= a_stone
1543 if old_class_stone /= Void then
1544 create test_stone.make (old_class_stone.class_i)
1545 same_class := test_stone.same_as (a_stone)
1546 -- We need to compare classes. If `old_class_stone' is a FEATURE_STONE
1547 -- `same_as' will compare features. Therefore, we need `test_stone' to be sure
1548 -- we have a CLASSI_STONE.
1549 if same_class and then feature_stone /= Void then
1550 same_class := False
1551 -- if the stone corresponding to a feature of currently opened class is dropped
1552 -- we attempt to scroll to the feature without asking to save the file
1553 -- except if it is during a resynchronization, in which case we do not scroll at all.
1554 if editor_tool.text_area.text_is_fully_loaded then
1555 if not during_synchronization then
1556 editor_tool.text_area.find_feature_named (feature_stone.feature_name)
1557 feature_stone_already_processed := editor_tool.text_area.found_feature
1558 else
1559 feature_stone_already_processed := True
1560 end
1561 conv_ferrst ?= feature_stone
1562 if feature_stone_already_processed and conv_ferrst /= Void then
1563 -- Scroll to the line of the error.
1564 if not during_synchronization then
1565 editor_tool.text_area.display_line_when_ready (conv_ferrst.line_number, True)
1566 end
1567 end
1568 end
1569 end
1570 end
1571 -- first, let's check if there is already something in this window
1572 -- if there's nothing, there's no need to save anything...
1573 if stone = Void or else not changed or else feature_stone_already_processed or else same_class then
1574 set_stone_after_check (a_stone)
1575 feature_stone_already_processed := False
1576 else
1577 -- there is something to be saved
1578 -- if user chooses to save, current file will be parsed
1579 -- if there is a syntax_error, new file is not loaded
1580 save_and (~set_stone_after_check (a_stone))
1581 if text_saved and then not syntax_is_correct then
1582 text_saved := False
1583 during_synchronization := True
1584 set_stone_after_check (stone)
1585 during_synchronization := False
1586 address_manager.refresh
1587 end
1588 end
1589 end
1590
1591 force_stone (s: STONE) is
1592 -- make `s' the new value of `stone', and
1593 -- change the display accordingly. Try to
1594 -- extract a class from `s' whenever possible.
1595 do
1596 if s.is_storable then
1597 set_stone (s)
1598 if not unified_stone then
1599 context_tool.advanced_set_stone (s)
1600 end
1601 end
1602 end
1603
1604 process_class (s: CLASSI_STONE) is
1605 -- Process class stone
1606 do
1607 set_stone (s)
1608 end
1609
1610 process_feature_error (s: FEATURE_ERROR_STONE) is
1611 -- Process feature error stone.
1612 local
1613 cl_stone: CLASSC_STONE
1614 e_class: CLASS_C
1615 txt: STRING
1616 pos, end_pos: INTEGER
1617 do
1618 set_default_format
1619 e_class := s.e_feature.written_class
1620 if e_class.lace_class.hide_implementation then
1621 set_stone (s)
1622 else
1623 create cl_stone.make (e_class)
1624 set_stone (cl_stone)
1625 editor_tool.text_area.deselect_all
1626 pos := s.error_position
1627 txt := text
1628 if txt.count > pos then
1629 if txt.item (pos) = '%N' then
1630 end_pos := txt.index_of ('%N', pos + 1)
1631 else
1632 end_pos := txt.index_of ('%N', pos)
1633 end
1634 if pos /= 0 then
1635 editor_tool.text_area.highlight_selected (pos, end_pos)
1636 end
1637 end
1638 end
1639 end
1640
1641
1642 process_class_syntax (s: CL_SYNTAX_STONE) is
1643 -- Process class syntax.
1644 local
1645 cl_stone: CLASSC_STONE
1646 do
1647 -- call set_stone to ensure the proper class is displayed
1648 create cl_stone.make (s.e_class)
1649 set_stone (cl_stone)
1650 editor_tool.text_area.deselect_all
1651 editor_tool.text_area.highlight_when_ready (s.start_position + 1, s.end_position + 1)
1652 end
1653
1654 refresh is
1655 -- Synchronize clickable elements with text, if possible.
1656 do
1657 --| FIXME ARNAUD
1658 -- synchronise_stone
1659 --| END FIXME
1660 --| FIXME XR: Refresh current display in the editor.
1661 editor_tool.text_area.update_click_list (False)
1662 update_save_symbol
1663 address_manager.refresh
1664 -- The cluster manager should already be refreshed by the window manager.
1665 -- cluster_manager.refresh
1666 -- context_tool.refresh
1667 end
1668
1669 quick_refresh is
1670 -- Redraw the main editor's drawing area.
1671 do
1672 editor_tool.text_area.refresh
1673 context_tool.quick_refresh
1674 end
1675
1676 set_default_format is
1677 -- Default format of windows.
1678 --| FIXME ARNAUD: To be implemented.
1679 -- local
1680 -- f: EB_FORMATTER
1681 do
1682 -- if stone /= Void then
1683 -- if stone.class_i.hide_implementation then
1684 -- f := format_list.precompiled_default_format
1685 -- else
1686 -- f := format_list.default_format
1687 -- end
1688 -- else
1689 -- f := format_list.default_format
1690 -- end
1691 -- set_last_format (f)
1692 --| END FIXME
1693 end
1694
1695 feature -- Resource Update
1696
1697 update is
1698 -- Update Current with the registered resources.
1699 do
1700 -- Show/hide general toolbar
1701 if window_preferences.show_general_toolbar then
1702 show_general_toolbar_command.enable_visible
1703 else
1704 show_general_toolbar_command.disable_visible
1705 end
1706
1707 -- Show/hide address toolbar
1708 if window_preferences.show_address_toolbar then
1709 show_address_toolbar_command.enable_visible
1710 else
1711 show_address_toolbar_command.disable_visible
1712 end
1713
1714 -- Show/hide project toolbar
1715 if window_preferences.show_project_toolbar then
1716 show_project_toolbar_command.enable_visible
1717 else
1718 show_project_toolbar_command.disable_visible
1719 end
1720
1721 left_panel.load_from_resource (window_preferences.left_panel_layout)
1722 right_panel.load_from_resource (window_preferences.right_panel_layout)
1723 end
1724
1725 update_splitters is
1726 -- Refresh the position of the splitter on screen according to
1727 -- our internal values.
1728 do
1729 -- Set the interior layout
1730 if panel.full then
1731 panel.set_split_position (splitter_position.max (panel.minimum_split_position).min (panel.maximum_split_position))
1732 end
1733 left_panel.refresh_splitter
1734 right_panel.refresh_splitter
1735 end
1736
1737 register is
1738 -- Register to preferences we want notification of.
1739 do
1740 end
1741
1742 unregister is
1743 -- unregister to preferences we want notification of.
1744 do
1745 end
1746
1747 reset is
1748 -- Reset the window contents
1749 do
1750 Precursor
1751 address_manager.reset
1752
1753 --| FIXME ARNAUD, multiformat not yet implemented.
1754 -- format_list.enable_imp_formats_sensitive
1755 --| END FIXME
1756 end
1757
1758 syntax_is_correct: BOOLEAN is
1759 -- file was successfully parsed.
1760 do
1761 Result := editor_tool.text_area.syntax_is_correct
1762 end
1763
1764 on_project_created is
1765 -- Inform tools that the current project has been loaded or re-loaded.
1766 do
1767 build_menu_bar
1768 enable_commands_on_project_created
1769 address_manager.on_project_created
1770 context_tool.on_project_created
1771 end
1772
1773 on_project_loaded is
1774 -- Inform tools that the current project has been loaded or re-loaded.
1775 do
1776 -- cluster_manager.on_project_loaded
1777 enable_commands_on_project_loaded
1778 cluster_tool.on_project_loaded
1779 context_tool.on_project_loaded
1780 end
1781
1782 on_project_unloaded is
1783 -- Inform tools that the current project will soon been unloaded.
1784 do
1785 -- cluster_manager.on_project_unloaded
1786 disable_commands_on_project_unloaded
1787 cluster_tool.on_project_unloaded
1788 context_tool.on_project_unloaded
1789 address_manager.on_project_unloaded
1790 build_menu_bar
1791 end
1792
1793 save_before_compiling is
1794 -- save the text but do not update clickable positions
1795 do
1796 save_only := True
1797 save_text
1798 end
1799
1800 perform_check_before_save is
1801 local
1802 dial: EV_CONFIRMATION_DIALOG
1803 do
1804 debug ("EDITOR")
1805 if editor_tool.text_area.current_text /= Void and then changed then
1806 io.error.putstring ("%N Warning: Attempting to save a non editable format%N")
1807 end
1808 end
1809 if editor_tool.text_area.open_backup then
1810 create dial.make_with_text(Warning_messages.w_Save_backup)
1811 dial.set_buttons_and_actions(<<"Continue", "Cancel">>, <<~continue_save, ~cancel_save>>)
1812 dial.set_default_push_button(dial.button("Continue"))
1813 dial.set_default_cancel_button(dial.button("Cancel"))
1814 dial.set_title ("Save Backup")
1815 dial.show_modal_to_window (window)
1816 else
1817 check_passed := True
1818 end
1819 end
1820
1821 continue_save is
1822 -- continue saving
1823 do
1824 check_passed := True
1825 end
1826
1827 cancel_save is
1828 -- cancel saving
1829 do
1830 check_passed := False
1831 end
1832
1833 process is
1834 -- process the user entry in the address bar
1835 do
1836 save_canceled := False
1837 end
1838
1839 on_text_saved is
1840 -- Notify the editor that the text has been saved
1841 local
1842 str: STRING
1843 do
1844 Precursor
1845 editor_tool.on_text_saved
1846 text_saved := True
1847 if not save_only then
1848 editor_tool.text_area.update_click_list (True)
1849 end
1850 save_only := False
1851 str := clone (title)
1852 if str @ 1 = '*' then
1853 str.tail (str.count - 2)
1854 set_title (str)
1855 end
1856 address_manager.enable_formatters
1857 end
1858
1859 save_and (an_action: PROCEDURE [ANY, TUPLE []]) is
1860 local
1861 save_dialog: EB_CONFIRM_SAVE_DIALOG
1862 do
1863 save_canceled := True
1864 text_saved := False
1865 create save_dialog.make_and_launch (Current,Current)
1866 if not save_canceled and then syntax_is_correct then
1867 an_action.call([])
1868 end
1869 end
1870
1871 feature -- Window management
1872
1873 show_window is
1874 -- Show the window
1875 do
1876 show
1877 end
1878
1879 raise_window is
1880 -- Show the window and set the focus to it.
1881 do
1882 show
1883 --| FIXME, set the focus.
1884 end
1885
1886 hide_window is
1887 -- Hide the window
1888 do
1889 hide
1890 end
1891
1892 destroy_window is
1893 -- Destroy the window.
1894 do
1895 destroy
1896 end
1897
1898 give_focus is
1899 -- Give the focus to the address manager.
1900 do
1901 address_manager.set_focus
1902 end
1903
1904 feature -- Tools & Controls
1905
1906 editor_tool: EB_EDITOR_TOOL
1907
1908 favorites_tool: EB_FAVORITES_TOOL
1909
1910 cluster_tool: EB_CLUSTER_TOOL
1911
1912 search_tool: EB_SEARCH_TOOL
1913
1914 features_tool: EB_FEATURES_TOOL
1915
1916 windows_tool: EB_WINDOWS_TOOL
1917
1918 context_tool: EB_CONTEXT_TOOL
1919 -- Context explorer for current class and system.
1920
1921 address_manager: EB_ADDRESS_MANAGER
1922 -- Text field in the toolbar
1923 -- Allow user to enter the name
1924 -- of the class he wants to edit.
1925
1926 project_manager: EB_PROJECT_MANAGER is
1927 -- Project manager associated to the project the user is working on.
1928 do
1929 Result := Eiffel_project.manager
1930 end
1931
1932 managed_class_formatters: ARRAYED_LIST [EB_CLASS_INFO_FORMATTER]
1933 -- All formatters that operate on a class.
1934
1935 managed_feature_formatters: ARRAYED_LIST [EB_FEATURE_INFO_FORMATTER]
1936 -- All formatters that operate on a class.
1937
1938 managed_main_formatters: ARRAYED_LIST [EB_CLASS_TEXT_FORMATTER]
1939 -- All formatters that can be displayed in the main editor frame.
1940
1941 unified_stone: BOOLEAN
1942 -- Is the stone common with the context tool or not?
1943
1944 feature -- Multiple editor management
1945
1946 add_editor_to_list (an_editor: EB_EDITOR) is
1947 -- adds `an_editor' to `editors'
1948 do
1949 editors.extend (an_editor)
1950 end
1951
1952 current_editor: EB_EDITOR is
1953 -- current editor, if none, main editor
1954 do
1955 if current_editor_index /= 0 then
1956 Result := editors @ current_editor_index
1957 else
1958 Result := editors.first
1959 end
1960 end
1961
1962 set_current_editor (an_editor: EB_EDITOR) is
1963 -- set `an_editor' as main editor
1964 local
1965 old_index: INTEGER
1966 do
1967 old_index := current_editor_index
1968 current_editor_index := editors.index_of (an_editor, 1)
1969 if old_index /= current_editor_index then
1970 from
1971 editors.start
1972 until
1973 editors.after
1974 loop
1975 if editors.index /= current_editor_index and then editors.item.has_selection then
1976 editors.item.disable_selection
1977 end
1978 editors.forth
1979 end
1980 end
1981 update_paste_cmd
1982 end
1983
1984 on_selection_begun is
1985 -- Update `editor_copy_cmd' and `editor_cut_command'
1986 -- (to be performed when selection starts in one fo the editors)
1987 do
1988 editor_copy_cmd.enable_sensitive
1989 if current_editor.is_editable then
1990 editor_cut_cmd.enable_sensitive
1991 end
1992 end
1993
1994 on_selection_finished is
1995 -- Update `editor_copy_cmd' and `editor_cut_command'
1996 -- (to be performed when selection stops in one fo the editors)
1997 do
1998 if not current_editor.has_selection then
1999 editor_copy_cmd.disable_sensitive
2000 editor_cut_cmd.disable_sensitive
2001 end
2002 end
2003
2004 update_paste_cmd is
2005 -- Update `editor_paste_cmd'. To be performed when an editor grabs the focus.
2006 local
2007 txt: STRING
2008 do
2009 txt := current_editor.clipboard.text
2010 if current_editor.is_editable and then txt /= Void and then not txt.is_empty then
2011 editor_paste_cmd.enable_sensitive
2012 else
2013 editor_paste_cmd.disable_sensitive
2014 end
2015 end
2016
2017
2018 feature {NONE} -- Multiple editor management
2019
2020 editors: ARRAYED_LIST [EB_EDITOR]
2021 -- editor contained in `Current'
2022
2023 current_editor_index: INTEGER
2024
2025
2026 feature {EB_WINDOW_MANAGER} -- Window management / Implementation
2027
2028 destroy_imp is
2029 -- Destroy window.
2030 do
2031 -- To avoid reentrance
2032 if not is_destroying then
2033 is_destroying := True
2034 window_preferences.save_left_panel_layout (left_panel.save_to_resource)
2035 window_preferences.save_right_panel_layout (right_panel.save_to_resource)
2036 window_preferences.save_search_tool_options (search_tool)
2037 hide
2038
2039 -- Commit saves
2040 window_preferences.save_resources
2041
2042 -- If a launched application is still running, kill it.
2043 if
2044 Application.is_running and then
2045 debugger_manager.debugging_window = Current
2046 then
2047 Application.kill
2048 end
2049 toolbars_area.wipe_out
2050 address_manager.recycle
2051 project_customizable_toolbar.recycle
2052 Precursor {EB_TOOL_MANAGER}
2053
2054 -- These components are automatically recycled through `add_recyclable'.
2055 -- cluster_tool.recycle
2056 -- context_tool.recycle
2057 -- editor_tool.recycle
2058 -- favorites_tool.recycle
2059 -- features_tool.recycle
2060 -- search_tool.recycle
2061 -- windows_tool.recycle
2062
2063 -- The compile menu is never created !!!
2064 -- compile_menu.destroy
2065 -- debug_menu.destroy
2066 -- project_menu.destroy
2067
2068 managed_class_formatters.wipe_out
2069 managed_feature_formatters.wipe_out
2070 managed_main_formatters.wipe_out
2071 toolbarable_commands.wipe_out
2072 editors.wipe_out
2073 stone := Void
2074 end
2075 end
2076
2077 feature {NONE} -- Implementation
2078
2079 set_stone_after_check (a_stone: STONE) is
2080 local
2081 old_stone: STONE
2082 new_class_stone: CLASSI_STONE
2083 old_class_stone: CLASSI_STONE
2084 conv_classc: CLASSC_STONE
2085 conv_brkstone: BREAKABLE_STONE
2086 cluster_st: CLUSTER_STONE
2087 feature_stone: FEATURE_STONE
2088 conv_ferrst: FEATURE_ERROR_STONE
2089 tmp_structured_text: STRUCTURED_TEXT
2090 conv_errst: ERROR_STONE
2091 class_file: RAW_FILE
2092 class_text_exists: BOOLEAN
2093 same_class: BOOLEAN
2094 test_stone: CLASSI_STONE
2095 str: STRING
2096 do
2097 -- the text does not change if the text was saved with syntax errors
2098 cur_wid := window
2099 if cur_wid = Void then
2100 --| Do nothing.
2101 else
2102 if old_cur = Void then
2103 old_cur := cur_wid.pointer_style
2104 end
2105 -- cur_wid.enable_capture
2106 cur_wid.set_pointer_style (Wait_cursor)
2107 end
2108
2109 conv_brkstone ?= a_stone
2110 conv_errst ?= a_stone
2111 if conv_brkstone /= Void then
2112 if Application.is_breakpoint_enabled (conv_brkstone.routine, conv_brkstone.index) then
2113 Application.remove_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2114 else
2115 Application.set_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2116 end
2117 output_manager.display_stop_points
2118 window_manager.quick_refresh_all
2119 elseif conv_errst /= Void then
2120 display_error_help_cmd.execute_with_stone (conv_errst)
2121 else
2122
2123 -- Remember previous stone.
2124 old_stone := stone
2125 old_class_stone ?= stone
2126
2127 -- New stone properties
2128 new_class_stone ?= a_stone
2129
2130 -- Set the stone.
2131 old_set_stone (a_stone)
2132 cluster_st ?= a_stone
2133
2134 new_feature_cmd.disable_sensitive
2135 -- We update the state of the `Add to Favorites' command.
2136 if new_class_stone /= Void then
2137 favorites_menu.first.enable_sensitive
2138 else
2139 favorites_menu.first.disable_sensitive
2140 end
2141
2142 -- Update the history.
2143 if
2144 new_class_stone /= Void
2145 then
2146 history_manager.extend (new_class_stone)
2147 elseif
2148 cluster_st /= Void
2149 then
2150 history_manager.extend (cluster_st)
2151 end
2152 -- Update the address manager if needed.
2153 address_manager.refresh
2154 if
2155 new_class_stone /= Void
2156 then
2157 -- class stone was dropped
2158 create class_file.make (new_class_stone.class_i.file_name)
2159 class_text_exists := class_file.exists
2160 feature_stone ?= a_stone
2161 --| We have to create a classi_stone to check whether the stones are really similar.
2162 --| Otherwise a redefinition of same_as may be called.
2163 create test_stone.make (new_class_stone.class_i)
2164 if test_stone.same_as (old_class_stone) then
2165 same_class := True
2166 end
2167 if not feature_stone_already_processed then
2168 if
2169 same_class and then text_saved
2170 then
2171 -- nothing changed in the editor
2172 -- we only have to update click_list
2173 if editor_tool.text_area.is_editable then
2174 editor_tool.text_area.update_click_list (False)
2175 end
2176 else
2177 if changed then
2178 -- user has already chosen not to save the file
2179 -- do not ask again
2180 editor_tool.text_area.no_save_before_next_load
2181 end
2182 end
2183 end
2184
2185 conv_classc ?= new_class_stone
2186 if conv_classc = Void or else feature_stone /= Void and not feature_stone_already_processed then
2187 -- If a classi_stone or a feature_stone has been dropped,
2188 -- display the basic text formatter.
2189 if class_text_exists then
2190 managed_main_formatters.first.set_stone (new_class_stone)
2191 managed_main_formatters.first.execute
2192 else
2193 editor_tool.text_area.clear_window
2194 editor_tool.text_area.display_message (Warning_messages.w_file_not_exist (new_class_stone.class_i.file_name))
2195 end
2196 end
2197 if conv_classc = Void then
2198 --| The dropped class is not compiled.
2199 --| Display only the textual formatter.
2200 address_manager.disable_formatters
2201 else
2202 --| We have a compiled class.
2203 if
2204 class_text_exists and then
2205 Eiffel_project.Workbench.last_reached_degree <= 2
2206 then
2207 new_feature_cmd.enable_sensitive
2208 end
2209
2210 address_manager.enable_formatters
2211 if not class_text_exists then
2212 --| Disable the textual formatter.
2213 managed_main_formatters.first.disable_sensitive
2214 from
2215 managed_main_formatters.start
2216 managed_main_formatters.forth
2217 until
2218 managed_main_formatters.after
2219 loop
2220 managed_main_formatters.item.set_stone (new_class_stone)
2221 managed_main_formatters.forth
2222 end
2223 managed_main_formatters.i_th (2).execute
2224 else
2225 if not changed then
2226 --| Enable all formatters.
2227 if not feature_stone_already_processed then
2228 from
2229 managed_main_formatters.start
2230 until
2231 managed_main_formatters.after
2232 loop
2233 managed_main_formatters.item.set_stone (new_class_stone)
2234 managed_main_formatters.forth
2235 end
2236 end
2237 else
2238 address_manager.disable_formatters
2239 managed_main_formatters.first.set_stone (new_class_stone)
2240 end
2241 end
2242 end
2243 else
2244 -- not a class text : cannot be edited
2245 editor_tool.text_area.disable_editable
2246 address_manager.disable_formatters
2247
2248 --| Disable all formatters.
2249 from
2250 managed_main_formatters.start
2251 until
2252 managed_main_formatters.after
2253 loop
2254 managed_main_formatters.item.set_stone (Void)
2255 managed_main_formatters.forth
2256 end
2257 if cluster_st /= Void then
2258 --| FIXME XR: Really manage cluster display in the main editor
2259 create tmp_structured_text.make
2260 tmp_structured_text.add_string ("Cluster: " + cluster_st.cluster_i.cluster_name)
2261 tmp_structured_text.add_new_line
2262 tmp_structured_text.add_string ("Cluster path: " + cluster_st.cluster_i.path)
2263 editor_tool.text_area.process_text (tmp_structured_text)
2264 --| END FIXME
2265 end
2266 end
2267 if feature_stone /= Void and class_text_exists and not feature_stone_already_processed then
2268 conv_ferrst ?= feature_stone
2269 if conv_ferrst /= Void then
2270 -- Scroll to the line of the error.
2271 editor_tool.text_area.display_line_when_ready (conv_ferrst.line_number, True)
2272 else
2273 -- if a feature_stone has been dropped
2274 -- scroll to the corresponding feature in the basic text format
2275 if feature_stone.e_feature.ast /= Void and not during_synchronization then
2276 scroll_to_feature (feature_stone.e_feature.ast, new_class_stone.class_i)
2277 end
2278 end
2279 end
2280 -- Update the title of the window
2281 if a_stone /= Void then
2282 if changed then
2283 str := clone (a_stone.header)
2284 str.prepend ("* ")
2285 set_title (str)
2286 else
2287 set_title (a_stone.header)
2288 end
2289 else
2290 set_title (Interface_names.t_Empty_development_window)
2291 end
2292
2293 -- Refresh the tools.
2294 features_tool.set_stone (a_stone)
2295 cluster_tool.set_stone (a_stone)
2296 -- Update the context tool.
2297 if unified_stone then
2298 context_tool.set_stone (a_stone)
2299 end
2300
2301 end
2302 if
2303 stone /= Void and then
2304 not unified_stone
2305 then
2306 send_stone_to_context_cmd.enable_sensitive
2307 else
2308 send_stone_to_context_cmd.disable_sensitive
2309 end
2310 if cur_wid = Void then
2311 --| Do nothing.
2312 else
2313 cur_wid.set_pointer_style (old_cur)
2314 old_cur := Void
2315 -- cur_wid.disable_capture
2316 cur_wid := Void
2317 end
2318 end
2319
2320 scroll_to_feature (feat_as: FEATURE_AS; displayed_class: CLASS_I) is
2321 -- highlight the feature correspnding to `feat_as' in the class represented by `displayed_class'
2322 require
2323 class_is_not_void: displayed_class /= Void
2324 feat_as_is_not_void: feat_as /= Void
2325 local
2326 begin_index, offset: INTEGER
2327 tmp_text: STRING
2328 do
2329 begin_index := feat_as.start_position
2330 if platform_constants.is_windows then
2331 tmp_text := displayed_class.text.substring (1, begin_index)
2332 offset := tmp_text.occurrences('%R')
2333 end
2334 editor_tool.text_area.scroll_to_when_ready (begin_index - offset)
2335 end
2336
2337
2338 check_passed: BOOLEAN
2339
2340 save_canceled: BOOLEAN
2341 -- did user cancel save ?
2342
2343 save_only: BOOLEAN
2344 -- skip parse and update after save ?
2345
2346 text_saved: BOOLEAN
2347 -- has the user chosen to save the file
2348
2349 is_destroying: BOOLEAN
2350 -- Is `current' being currently destroyed?
2351
2352 feature_stone_already_processed: BOOLEAN
2353 -- Is the processed stone a feature stone and has it
2354 -- been already processed by the editor ?
2355
2356 feature {NONE} -- Implementation
2357
2358 update_save_symbol is
2359 do
2360 {EB_FILEABLE} Precursor
2361 if changed then
2362 save_cmd.enable_sensitive
2363 address_manager.disable_formatters
2364 else
2365 save_cmd.disable_sensitive
2366 address_manager.enable_formatters
2367 end
2368 if is_empty then
2369 print_cmd.disable_sensitive
2370 save_as_cmd.disable_sensitive
2371 else
2372 print_cmd.enable_sensitive
2373 save_as_cmd.enable_sensitive
2374 end
2375 end
2376
2377 on_text_reset is
2378 -- The main editor has just been wiped out
2379 -- before loading a new file.
2380 local
2381 str: STRING
2382 do
2383 str := clone (title)
2384 if str @ 1 = '*' then
2385 str.tail (str.count - 2)
2386 set_title (str)
2387 end
2388 address_manager.enable_formatters
2389 end
2390
2391 on_text_back_to_its_last_saved_state is
2392 local
2393 str: STRING
2394 do
2395 str := clone (title)
2396 if str @ 1 = '*' then
2397 str.tail (str.count - 2)
2398 set_title (str)
2399 end
2400 end
2401
2402
2403 on_text_edited (unused: BOOLEAN) is
2404 -- The text in the editor is modified, add the '*' in the title.
2405 -- Gray out the formatters.
2406 local
2407 str: STRING
2408 do
2409 str := clone (title)
2410 if str @ 1 /= '*' then
2411 str.prepend ("* ")
2412 set_title (str)
2413 end
2414 address_manager.disable_formatters
2415 end
2416
2417 saved_cursor: CURSOR
2418 -- Saved cursor position for displaying the stack.
2419
2420 quick_refresh_on_class_drop (unused: CLASSI_STONE) is
2421 -- Quick refresh all windows.
2422 do
2423 window_manager.quick_refresh_all
2424 end
2425
2426 quick_refresh_on_brk_drop (unused: BREAKABLE_STONE) is
2427 -- Quick refresh all windows.
2428 do
2429 window_manager.quick_refresh_all
2430 end
2431
2432 send_stone_to_context is
2433 -- Send current stone to the context tool.
2434 -- Used by `send_stone_to_context_cmd'.
2435 do
2436 if stone /= Void then
2437 context_tool.set_stone (stone)
2438 end
2439 end
2440
2441 destroy is
2442 -- check if current text has been saved and destroy
2443 local
2444 dialog_w: EB_WARNING_DIALOG
2445 do
2446 if editor_tool /= Void and then editor_tool.text_area /= Void and then changed and then not confirmed then
2447 Exit_application_cmd.set_already_save_confirmed (True)
2448 create dialog_w.make_with_text (Interface_names.l_Close_warning)
2449 dialog_w.set_buttons_and_actions (<<"Yes", "No", "Cancel">>, <<~save_and_destroy, ~force_destroy, Exit_application_cmd~set_already_save_confirmed (False)>>)
2450 dialog_w.set_default_push_button (dialog_w.button("Yes"))
2451 dialog_w.set_default_cancel_button (dialog_w.button("Cancel"))
2452 dialog_w.show_modal_to_window (window)
2453 else
2454 Precursor {EB_TOOL_MANAGER}
2455 Exit_application_cmd.set_already_save_confirmed (False)
2456 end
2457 end
2458
2459 save_and_destroy is
2460 do
2461 save_text
2462 destroy
2463 end
2464
2465 force_destroy is
2466 -- Destroy without asking.
2467 do
2468 confirmed := True
2469 destroy
2470 confirmed := False
2471 end
2472
2473 confirmed: BOOLEAN
2474 -- Did the user say he wanted to exit?
2475
2476 show_dynamic_library_dialog is
2477 -- Create a new dynamic library window and display it.
2478 do
2479 Window_manager.create_dynamic_lib_window
2480 end
2481
2482 toggle_formatting_marks is
2483 -- Show/Hide formatting marks in the editor and update related menu item.
2484 do
2485 editor_tool.text_area.toggle_view_invisible_symbols
2486 if editor_tool.text_area.view_invisible_symbols then
2487 formatting_marks_command_menu_item.set_text (Interface_names.m_Hide_formatting_marks)
2488 else
2489 formatting_marks_command_menu_item.set_text(Interface_names.m_Show_formatting_marks)
2490 end
2491 end
2492
2493 feature {NONE} -- Implementation / Menus
2494
2495 old_cur: EV_CURSOR
2496 -- Cursor saved while displaying the hourglass cursor.
2497
2498 cur_wid: EV_WIDGET
2499 -- Widget on which the hourglass cursor was set.
2500
2501 project_menu: EV_MENU
2502 -- Menu for entries relative to the Project.
2503
2504 recent_projects_menu: EB_RECENT_PROJECTS_MANAGER_MENU
2505 -- SubMenu for recent projects.
2506
2507 during_synchronization: BOOLEAN
2508 -- Are we during a resynchronization?
2509
2510 formatting_marks_command_menu_item: EB_COMMAND_MENU_ITEM
2511 -- Menu item used to shw/hide formatting marks.
2512
2513 undo_accelerator: EV_ACCELERATOR
2514 -- Accelerator for Ctrl+Z
2515
2516 redo_accelerator: EV_ACCELERATOR
2517 -- Accelerator for Ctrl+Y
2518
2519 feature {EB_TOOL} -- Implementation / Commands
2520
2521 history_forth_cmd: EB_HISTORY_FORTH_COMMAND
2522 -- Command to go forward in the history
2523
2524 history_back_cmd: EB_HISTORY_BACK_COMMAND
2525 -- Command to go back in the history
2526
2527 shell_cmd: EB_OPEN_SHELL_COMMAND
2528 -- Command to use an external editor.
2529
2530 undo_cmd: EB_UNDO_COMMAND
2531 -- Command to undo in the editor.
2532
2533 redo_cmd: EB_REDO_COMMAND
2534 -- Command to redo in the editor.
2535
2536 editor_cut_cmd: EB_EDITOR_CUT_COMMAND
2537 -- Command to cut text in the editor.
2538
2539 editor_copy_cmd: EB_EDITOR_COPY_COMMAND
2540 -- Command to copy text in the editor.
2541
2542 editor_paste_cmd: EB_EDITOR_PASTE_COMMAND
2543 -- Command to paste text in the editor.
2544
2545 melt_cmd: EB_MELT_PROJECT_COMMAND
2546 -- Command to start compilation.
2547
2548 freeze_cmd: EB_FREEZE_PROJECT_COMMAND
2549 -- Command to Freeze the project.
2550
2551 finalize_cmd: EB_FINALIZE_PROJECT_COMMAND
2552 -- Command to Finalize the project.
2553
2554 c_workbench_compilation_cmd: EB_C_COMPILATION_COMMAND
2555 -- Command to compile the workbench C code.
2556
2557 c_finalized_compilation_cmd: EB_C_COMPILATION_COMMAND
2558 -- Command to compile the finalized C code.
2559
2560 new_cluster_cmd: EB_NEW_CLUSTER_COMMAND
2561 -- Command to create a new cluster.
2562
2563 new_class_cmd: EB_NEW_CLASS_COMMAND
2564 -- Command to create a new class.
2565
2566 new_feature_cmd: EB_NEW_FEATURE_COMMAND
2567 -- Command to execute the feature wizard.
2568
2569 toggle_stone_cmd: EB_UNIFY_STONE_CMD
2570 -- Command to toggle between the stone management modes.
2571
2572 delete_class_cluster_cmd: EB_DELETE_CLASS_CLUSTER_COMMAND
2573 -- Command to remove a class or a cluster from the system
2574 -- (permanent deletion).
2575
2576 show_profiler: EB_SHOW_PROFILE_TOOL
2577 -- What allows us to display the profiler window.
2578
2579 toolbarable_commands: ARRAYED_LIST [EB_TOOLBARABLE_COMMAND]
2580 -- All commands that can be put in a toolbar.
2581
2582 save_as_cmd: EB_SAVE_FILE_AS_COMMAND
2583 -- Command to save a class with a different file name.
2584
2585 system_info_cmd: EB_STANDARD_CMD is
2586 -- Command to display information about the system (root class,...)
2587 do
2588 Result := debugger_manager.system_info_cmd
2589 end
2590
2591 display_error_help_cmd: EB_ERROR_INFORMATION_CMD is
2592 -- Command to pop up a dialog giving help on compilation errors.
2593 do
2594 Result := debugger_manager.display_error_help_cmd
2595 end
2596
2597 send_stone_to_context_cmd: EB_STANDARD_CMD
2598 -- Command to send the current stone to the context tool.
2599
2600 print_cmd: EB_PRINT_COMMAND
2601 -- Command to print the content of editor with focus
2602
2603 dotnet_import_cmd: EB_DOTNET_IMPORT_CMD is
2604 -- Manage .Net assemblies.
2605 do
2606 Result := debugger_manager.dotnet_import_cmd
2607 end
2608
2609 show_favorites_menu_item: EV_MENU_ITEM
2610 -- Show/Hide favorites menu item.
2611
2612 update_show_favorites_menu_item is
2613 -- Update `show_favorites_menu_item' menu label.
2614 do
2615 if favorites_tool.shown then
2616 show_favorites_menu_item.set_text (Interface_names.m_Hide_favorites)
2617 else
2618 show_favorites_menu_item.set_text (Interface_names.m_Show_favorites)
2619 end
2620 end
2621
2622 execute_show_favorites is
2623 -- Show `favorites_tool' if it is closed, close
2624 -- it in the opposite case.
2625 do
2626 update_show_favorites_menu_item
2627 if favorites_tool.shown then
2628 favorites_tool.close
2629 else
2630 favorites_tool.show
2631 end
2632 end
2633
2634 feature {NONE} -- external edition handling
2635
2636 on_focus is
2637 -- check if the text has not been modified by an external editor
2638 local
2639 dialog: EV_INFORMATION_DIALOG
2640 button_labels: ARRAY [STRING]
2641 actions: ARRAY [PROCEDURE [ANY, TUPLE]]
2642 do
2643 debug ("DEBUGGER_INTERFACE")
2644 io.putstring ("Took focus!%N")
2645 end
2646 if not editor_tool.edited_file_is_up_to_date then
2647 if not editor_tool.file_date_already_checked then
2648 if not editor_tool.changed and Editor_preferences.automatic_update
2649 then
2650 editor_tool.reload
2651 else
2652 create dialog.make_with_text (warning_messages.w_file_modified_by_another_editor)
2653 create button_labels.make (1, 2)
2654 create actions.make (1, 2)
2655 button_labels.put (interface_names.b_Reload, 1)
2656 actions.put (editor_tool~reload, 1)
2657 button_labels.put (interface_names.b_Continue_anyway, 2)
2658 actions.put (editor_tool~set_changed (True), 2)
2659 dialog.set_buttons_and_actions (button_labels,actions)
2660 dialog.set_default_push_button (dialog.button (button_labels @ 1))
2661 dialog.set_default_cancel_button (dialog.button (button_labels @ 2))
2662 dialog.set_title (interface_names.t_External_edition)
2663 dialog.show_modal_to_window (window)
2664 end
2665 end
2666 end
2667 end
2668
2669 feature {NONE} -- Execution
2670
2671 Kcst: EV_KEY_CONSTANTS is
2672 -- A way to access key constants.
2673 once
2674 create Result
2675 end
2676
2677 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
2678 -- Action called when the user right-click in the toolbar.
2679 -- Display a popup menu to show/hide toolbars and customize the general toolbar.
2680 local
2681 popup_menu: EV_MENU
2682 do
2683 if a_button = 3 then
2684 popup_menu := build_toolbar_menu
2685 popup_menu.show
2686 end
2687 end
2688
2689 enable_commands_on_project_created is
2690 -- Enable commands when a new project has been created (not yet compiled)
2691 do
2692 system_info_cmd.enable_sensitive
2693 if
2694 stone /= Void and then
2695 not unified_stone
2696 then
2697 send_stone_to_context_cmd.enable_sensitive
2698 end
2699 end
2700
2701 enable_commands_on_project_loaded is
2702 -- Enable commands when a new project has been created and compiled
2703 do
2704 show_profiler.enable_sensitive
2705 show_dynamic_lib_tool.enable_sensitive
2706 open_cmd.enable_sensitive
2707 new_class_cmd.enable_sensitive
2708 new_cluster_cmd.enable_sensitive
2709 system_info_cmd.enable_sensitive
2710 if unified_stone then
2711 send_stone_to_context_cmd.disable_sensitive
2712 elseif stone /= Void then
2713 send_stone_to_context_cmd.enable_sensitive
2714 end
2715 new_class_cmd.enable_sensitive
2716 new_cluster_cmd.enable_sensitive
2717 delete_class_cluster_cmd.enable_sensitive
2718 c_workbench_compilation_cmd.enable_sensitive
2719 c_finalized_compilation_cmd.enable_sensitive
2720 end
2721
2722 disable_commands_on_project_unloaded is
2723 -- Enable commands when a project has been closed.
2724 do
2725 show_dynamic_lib_tool.disable_sensitive
2726 show_profiler.disable_sensitive
2727 open_cmd.disable_sensitive
2728 new_class_cmd.disable_sensitive
2729 new_cluster_cmd.disable_sensitive
2730 if not project_manager.is_created then
2731 system_info_cmd.disable_sensitive
2732 send_stone_to_context_cmd.disable_sensitive
2733 end
2734 delete_class_cluster_cmd.disable_sensitive
2735 c_workbench_compilation_cmd.disable_sensitive
2736 c_finalized_compilation_cmd.disable_sensitive
2737 end
2738
2739 end -- class EB_DEVELOPMENT_WINDOW
2740

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23