/[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 27498 - (show annotations)
Mon Sep 10 19:26:16 2001 UTC (18 years, 5 months ago) by xavier
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 80479 byte(s)
Implemented the back/forth shortcuts (separately on the context and the rest).
It does work with the explorer mouse, Arnaud was right.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23