/[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 51136 - (show annotations)
Wed May 18 15:20:09 2005 UTC (14 years, 9 months ago) by alexk
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 101528 byte(s)
Added a toggle for alias names.

1 indexing
2 description : "Window holding a project tool"
3 date : "$Date$"
4 revision : "$Revision$"
5 author : "Arnaud PICHERY [ aranud@mail.dotcom.fr ]"
6
7 class
8 EB_DEVELOPMENT_WINDOW
9
10 inherit
11 EB_TOOL_MANAGER
12 redefine
13 make,
14 init_size_and_position,
15 window_displayed,
16 init_commands,
17 build_menu_bar,
18 build_menus,
19 build_file_menu,
20 build_edit_menu,
21 build_view_menu,
22 build_tools_menu,
23 build_favorites_menu,
24 refresh,
25 recycle,
26 destroy_imp,
27 destroy
28 end
29
30 EB_FILEABLE
31 redefine
32 set_stone,
33 reset,
34 stone,
35 on_text_saved,
36 perform_check_before_save,
37 check_passed,
38 update_save_symbol
39 select
40 set_stone
41 end
42
43 EB_FILEABLE
44 rename
45 set_stone as old_set_stone
46 export {NONE}
47 old_set_stone
48 redefine
49 reset,
50 stone,
51 on_text_saved,
52 perform_check_before_save,
53 check_passed,
54 update_save_symbol
55 end
56
57
58 -- Shared tools & contexts
59 SHARED_APPLICATION_EXECUTION
60
61 SHARED_EIFFEL_PROJECT
62
63 PROJECT_CONTEXT
64
65 EB_SHARED_MANAGERS
66
67 EB_SHARED_GRAPHICAL_COMMANDS
68
69 EB_SHARED_PREFERENCES
70 export
71 {NONE} all
72 end
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_text_back_to_its_last_saved_state,
85 on_text_fully_loaded, on_cursor_moved
86 end
87
88 EV_KEY_CONSTANTS
89 export
90 {NONE} All
91 end
92
93 EIFFEL_ENV
94 export
95 {NONE} All
96 end
97
98 SHARED_TEXT_ITEMS
99 export
100 {NONE} All
101 end
102
103 create {EB_WINDOW_MANAGER}
104 make,
105 make_as_context_tool,
106 make_as_editor
107
108 feature {NONE} -- Initialization
109
110 make_as_context_tool is
111 -- Create a new development window and expand the context tool.
112 do
113 make
114 -- Perform window setting from `show_actions', as the
115 -- resizing executed as a result only works correctly
116 -- while the window is displayed.
117 window.show_actions.extend (agent set_context_mode)
118 end
119
120 set_context_mode is
121 -- Set `current' into context mode, that is the context tool
122 -- maximized, and the non editor panel is hidden.
123 do
124 if not context_tool.shown then
125 context_tool.show
126 end
127 if not unified_stone then
128 toggle_stone_cmd.execute
129 end
130 context_tool.explorer_bar_item.maximize
131 close_all_bars_except (right_panel)
132 end
133
134 make_as_editor is
135 -- Create a new development window and expand the editor tool.
136 do
137 make
138 -- Perform window setting from `show_actions', as the resizing executed
139 -- must be performed after `current' is displayed.
140 window.show_actions.extend (agent (editor_tool.explorer_bar_item).maximize)
141 window.show_actions.extend (agent close_all_bars_except (right_panel))
142 end
143
144 make is
145 -- Create a new development window.
146 do
147 unified_stone := preferences.development_window_data.context_unified_stone
148 -- Build the history manager, the address manager, ...
149 create history_manager.make (Current)
150 create address_manager.make (Current, False)
151 build_formatters
152 address_manager.set_formatters (managed_main_formatters)
153
154 -- Init commands, build interface, build menus, ...
155 Precursor
156
157 initialized := False -- Reset the flag since initialization is not yet complete.
158 set_up_accelerators
159
160 -- Create the toolbars.
161 build_toolbars_area
162 container.put_front (toolbars_area)
163 container.disable_item_expand (toolbars_area)
164
165 -- Update widgets visibilities
166 window.show_actions.extend (agent update)
167 status_bar.remove_cursor_position
168 address_manager.set_output_line (status_bar.label)
169
170 -- Finish initializing the main editor formatters
171 end_build_formatters
172
173 address_manager.disable_formatters
174 if Eiffel_project.manager.is_project_loaded then
175 on_project_created
176 on_project_loaded
177 elseif Eiffel_project.manager.is_created then
178 on_project_unloaded
179 on_project_created
180 else
181 on_project_unloaded
182 end
183
184 -- Create feature position table
185 create feature_positions.make (1)
186 feature_positions.compare_objects
187
188 window.move_actions.force_extend (agent window_moved)
189
190 initialized := True
191 is_destroying := False
192 end
193
194 init_size_and_position is
195 -- Initialize window size.
196 local
197 default_width, default_height: INTEGER
198 screen: EV_SCREEN
199 do
200 create screen
201 default_width := preferences.development_window_data.width.min (screen.width)
202 default_height := preferences.development_window_data.height.min (screen.height)
203 window.set_size (default_width, default_height)
204 end
205
206 window_displayed is
207 -- `Current' has been displayed on screen.
208 do
209 -- Maximize window if needed.
210 if preferences.development_window_data.is_maximized then
211 window.maximize
212 end
213 end
214
215 init_commands is
216 -- Initialize commands.
217 local
218 accel: EV_ACCELERATOR
219 do
220 Precursor
221 create toolbarable_commands.make (15)
222
223 -- Open, save, ...
224 toolbarable_commands.extend (new_editor_cmd)
225
226 toolbarable_commands.extend (new_context_tool_cmd)
227
228 create open_cmd.make (Current)
229 toolbarable_commands.extend (open_cmd)
230
231 create save_cmd.make (Current)
232 toolbarable_commands.extend (save_cmd)
233
234 create save_as_cmd.make (Current)
235 if editor_tool = Void or else editor_tool.text_area.is_empty then
236 save_as_cmd.disable_sensitive
237 else
238 save_as_cmd.enable_sensitive
239 end
240
241 create shell_cmd.make (Current)
242 toolbarable_commands.extend (shell_cmd)
243
244 create print_cmd.make (Current)
245 if is_empty then
246 print_cmd.disable_sensitive
247 else
248 print_cmd.enable_sensitive
249 end
250 toolbarable_commands.extend (print_cmd)
251
252 -- Compilation
253 create c_workbench_compilation_cmd.make_workbench (Current)
254 create c_finalized_compilation_cmd.make_finalized (Current)
255 if has_dll_generation then
256 create show_dynamic_lib_tool.make
257 show_dynamic_lib_tool.set_menu_name (Interface_names.m_new_dynamic_lib)
258 show_dynamic_lib_tool.add_agent (agent show_dynamic_library_dialog)
259 end
260 if has_profiler then
261 create show_profiler
262 end
263
264 -- Undo/redo, cut, copy, paste.
265 create undo_cmd.make (Current)
266 toolbarable_commands.extend (undo_cmd)
267
268 create redo_cmd.make (Current)
269 toolbarable_commands.extend (redo_cmd)
270
271 create editor_paste_cmd.make (Current)
272 toolbarable_commands.extend (editor_paste_cmd)
273
274 create new_cluster_cmd.make (Current)
275 toolbarable_commands.extend (new_cluster_cmd)
276
277 create new_class_cmd.make (Current)
278 toolbarable_commands.extend (new_class_cmd)
279
280 create delete_class_cluster_cmd.make (Current)
281 toolbarable_commands.extend (delete_class_cluster_cmd)
282
283 create new_feature_cmd.make (Current)
284 toolbarable_commands.extend (new_feature_cmd)
285
286 create toggle_feature_alias_cmd.make (Current)
287 toolbarable_commands.extend (toggle_feature_alias_cmd)
288
289 create toggle_feature_signature_cmd.make (Current)
290 toolbarable_commands.extend (toggle_feature_signature_cmd)
291
292 create toggle_stone_cmd.make (Current)
293 toolbarable_commands.extend (toggle_stone_cmd)
294
295 create send_stone_to_context_cmd.make
296 send_stone_to_context_cmd.set_pixmaps (Pixmaps.Icon_send_stone_down)
297 send_stone_to_context_cmd.set_tooltip (Interface_names.e_send_stone_to_context)
298 send_stone_to_context_cmd.set_menu_name (Interface_names.m_send_stone_to_context)
299 send_stone_to_context_cmd.set_name ("Send_to_context")
300 send_stone_to_context_cmd.set_tooltext (Interface_names.b_send_stone_to_context)
301 send_stone_to_context_cmd.add_agent (agent send_stone_to_context)
302 create accel.make_with_key_combination (
303 create {EV_KEY}.make_with_code (Kcst.Key_down), False, True, False
304 )
305 accel.actions.extend (agent send_stone_to_context)
306 send_stone_to_context_cmd.set_accelerator (accel)
307 send_stone_to_context_cmd.disable_sensitive
308 toolbarable_commands.extend (send_stone_to_context_cmd)
309
310 toolbarable_commands.extend (window_manager.minimize_all_cmd)
311 window_manager.minimize_all_cmd.enable_sensitive
312 toolbarable_commands.extend (window_manager.raise_all_cmd)
313 window_manager.raise_all_cmd.enable_sensitive
314
315 toolbarable_commands.extend (New_development_window_cmd)
316 -- Show tool/toolbar commands (will be filled when tools will
317 -- be created)
318 create show_tool_commands.make (7)
319 create show_toolbar_commands.make (3)
320
321 new_feature_cmd.disable_sensitive
322 toggle_feature_alias_cmd.disable_sensitive
323 toggle_feature_signature_cmd.disable_sensitive
324
325 create editors.make (5)
326 end
327
328 set_up_accelerators is
329 -- Fill the accelerator of `window' with the accelerators of the `toolbarable_commands'.
330 do
331 from
332 toolbarable_commands.start
333 until
334 toolbarable_commands.after
335 loop
336 if toolbarable_commands.item.accelerator /= Void then
337 window.accelerators.extend (toolbarable_commands.item.accelerator)
338 end
339 toolbarable_commands.forth
340 end
341
342 from
343 debugger_manager.toolbarable_commands.start
344 until
345 debugger_manager.toolbarable_commands.after
346 loop
347 if
348 debugger_manager.toolbarable_commands.item.accelerator /= Void
349 then
350 window.accelerators.extend (debugger_manager.toolbarable_commands.item.accelerator)
351 end
352 debugger_manager.toolbarable_commands.forth
353 end
354 end
355
356 build_formatters is
357 -- Build all formatters used.
358 local
359 form: EB_CLASS_TEXT_FORMATTER
360 accel: EV_ACCELERATOR
361 do
362 create managed_class_formatters.make (17)
363 managed_class_formatters.extend (create {EB_CLICKABLE_FORMATTER}.make (Current))
364 managed_class_formatters.extend (create {EB_FLAT_FORMATTER}.make (Current))
365 managed_class_formatters.extend (create {EB_SHORT_FORMATTER}.make (Current))
366 managed_class_formatters.extend (create {EB_FLAT_SHORT_FORMATTER}.make (Current))
367 managed_class_formatters.extend (Void)
368 managed_class_formatters.extend (create {EB_ANCESTORS_FORMATTER}.make (Current))
369 managed_class_formatters.extend (create {EB_DESCENDANTS_FORMATTER}.make (Current))
370 managed_class_formatters.extend (create {EB_CLIENTS_FORMATTER}.make (Current))
371 managed_class_formatters.extend (create {EB_SUPPLIERS_FORMATTER}.make (Current))
372 managed_class_formatters.extend (Void)
373 managed_class_formatters.extend (create {EB_ATTRIBUTES_FORMATTER}.make (Current))
374 managed_class_formatters.extend (create {EB_ROUTINES_FORMATTER}.make (Current))
375 managed_class_formatters.extend (create {EB_DEFERREDS_FORMATTER}.make (Current))
376 managed_class_formatters.extend (create {EB_ONCES_FORMATTER}.make (Current))
377 managed_class_formatters.extend (create {EB_EXTERNALS_FORMATTER}.make (Current))
378 managed_class_formatters.extend (create {EB_EXPORTED_FORMATTER}.make (Current))
379
380 create managed_feature_formatters.make (12)
381 managed_feature_formatters.extend (create {EB_BASIC_FEATURE_FORMATTER}.make (Current))
382 managed_feature_formatters.extend (create {EB_ROUTINE_FLAT_FORMATTER}.make (Current))
383 managed_feature_formatters.extend (Void)
384 managed_feature_formatters.extend (create {EB_CALLERS_FORMATTER}.make (Current, 0))
385 managed_feature_formatters.extend (create {EB_CALLERS_FORMATTER}.make (Current,
386 {DEPEND_UNIT}.is_in_assignment_flag))
387 managed_feature_formatters.extend (create {EB_CALLERS_FORMATTER}.make (Current,
388 {DEPEND_UNIT}.is_in_creation_flag))
389 managed_feature_formatters.extend (Void)
390 managed_feature_formatters.extend (create {EB_IMPLEMENTERS_FORMATTER}.make (Current))
391 managed_feature_formatters.extend (create {EB_ROUTINE_ANCESTORS_FORMATTER}.make (Current))
392 managed_feature_formatters.extend (create {EB_ROUTINE_DESCENDANTS_FORMATTER}.make (Current))
393 managed_feature_formatters.extend (Void)
394 managed_feature_formatters.extend (create {EB_HOMONYMS_FORMATTER}.make (Current))
395
396
397 create managed_main_formatters.make (6)
398
399 create {EB_BASIC_TEXT_FORMATTER} form.make (Current)
400 create accel.make_with_key_combination (
401 create {EV_KEY}.make_with_code (Kcst.Key_t),
402 True, False, True)
403 accel.actions.extend (agent form.execute)
404 form.set_accelerator (accel)
405 managed_main_formatters.extend (form)
406
407 create {EB_CLICKABLE_FORMATTER} form.make (Current)
408 create accel.make_with_key_combination (
409 create {EV_KEY}.make_with_code (Kcst.Key_c),
410 True, False, True)
411 accel.actions.extend (agent form.execute)
412 form.set_accelerator (accel)
413 managed_main_formatters.extend (form)
414
415 create {EB_FLAT_FORMATTER} form.make (Current)
416 create accel.make_with_key_combination (
417 create {EV_KEY}.make_with_code (Kcst.Key_f),
418 True, False, True)
419 accel.actions.extend (agent form.execute)
420 form.set_accelerator (accel)
421 managed_main_formatters.extend (form)
422
423 create {EB_SHORT_FORMATTER} form.make (Current)
424 create accel.make_with_key_combination (
425 create {EV_KEY}.make_with_code (Kcst.Key_o),
426 True, False, True)
427 accel.actions.extend (agent form.execute)
428 form.set_accelerator (accel)
429 managed_main_formatters.extend (form)
430
431 create {EB_FLAT_SHORT_FORMATTER} form.make (Current)
432 create accel.make_with_key_combination (
433 create {EV_KEY}.make_with_code (Kcst.Key_i),
434 True, False, True)
435 accel.actions.extend (agent form.execute)
436 form.set_accelerator (accel)
437 managed_main_formatters.extend (form)
438 end
439
440 end_build_formatters is
441 -- Finish initialization of formatters (associate them with editor
442 -- and select a formatter).
443 local
444 f_ind: INTEGER
445 do
446 from
447 managed_class_formatters.start
448 until
449 managed_class_formatters.after
450 loop
451 if managed_class_formatters.item /= Void then
452 managed_class_formatters.item.set_manager (context_tool)
453 end
454 managed_class_formatters.forth
455 end
456 from
457 managed_feature_formatters.start
458 until
459 managed_feature_formatters.after
460 loop
461 if managed_feature_formatters.item /= Void then
462 managed_feature_formatters.item.set_manager (context_tool)
463 end
464 managed_feature_formatters.forth
465 end
466 from
467 managed_main_formatters.start
468 until
469 managed_main_formatters.after
470 loop
471 managed_main_formatters.item.set_editor (editor_tool.text_area)
472 managed_main_formatters.item.on_shown
473 if managed_main_formatters.item.accelerator /= Void then
474 window.accelerators.extend (managed_main_formatters.item.accelerator)
475 end
476 managed_main_formatters.forth
477 end
478
479 (managed_main_formatters @ 1).enable_select;
480
481 -- We now select the correct class formatter.
482 f_ind := preferences.formatter_data.default_class_formatter_index
483 --| This takes the formatter separators in consideration.
484 if f_ind > 4 then
485 f_ind := f_ind + 1
486 end
487 if f_ind > 8 then
488 f_ind := f_ind + 1
489 end
490 if f_ind < 1 or f_ind > managed_class_formatters.count then
491 f_ind := 6
492 end
493 (managed_class_formatters @ f_ind).enable_select;
494 -- We now select the correct feature formatter.
495 f_ind := preferences.formatter_data.default_feature_formatter_index
496 if f_ind > 2 then
497 f_ind := f_ind + 1
498 end
499 if f_ind < 1 or f_ind > managed_feature_formatters.count then
500 f_ind := 2
501 end
502 managed_class_formatters.i_th (f_ind).enable_select
503 end
504
505 build_tools is
506 -- Build all tools that can take place in this window and put them
507 -- in `left_tools' or `bottom_tools'.
508 local
509 show_cmd: EB_SHOW_TOOL_COMMAND
510 do
511 lock_update
512 -- Build the features tool
513 create features_tool.make (Current)
514 features_tool.attach_to_explorer_bar (left_panel)
515 left_tools.extend (features_tool.explorer_bar_item)
516 create show_cmd.make (Current, features_tool.explorer_bar_item)
517 show_tool_commands.extend (show_cmd)
518 toolbarable_commands.extend (show_cmd)
519 add_recyclable (features_tool)
520
521 -- Build the cluster tool
522 create cluster_tool.make (Current, Current)
523 cluster_tool.attach_to_explorer_bar (left_panel)
524 left_tools.extend (cluster_tool.explorer_bar_item)
525 create show_cmd.make (Current, cluster_tool.explorer_bar_item)
526 show_tool_commands.extend (show_cmd)
527 toolbarable_commands.extend (show_cmd)
528 add_recyclable (cluster_tool)
529
530 -- Build the favorites tool
531 create favorites_tool.make (Current, favorites_manager)
532 favorites_tool.attach_to_explorer_bar (left_panel)
533 left_tools.extend (favorites_tool.explorer_bar_item)
534 create show_cmd.make (Current, favorites_tool.explorer_bar_item)
535 show_tool_commands.extend (show_cmd)
536 toolbarable_commands.extend (show_cmd)
537 add_recyclable (favorites_tool)
538
539 -- Build the windows tool (formerly known as Selector tool)
540 create windows_tool.make (Current)
541 windows_tool.attach_to_explorer_bar (left_panel)
542 left_tools.extend (windows_tool.explorer_bar_item)
543 create show_cmd.make (Current, windows_tool.explorer_bar_item)
544 show_tool_commands.extend (show_cmd)
545 toolbarable_commands.extend (show_cmd)
546 add_recyclable (windows_tool)
547
548 -- Build the search tool
549 create search_tool.make (Current)
550 search_tool.attach_to_explorer_bar (left_panel)
551 left_tools.extend (search_tool.explorer_bar_item)
552 create show_cmd.make (Current, search_tool.explorer_bar_item)
553 show_tool_commands.extend (show_cmd)
554 toolbarable_commands.extend (show_cmd)
555 add_recyclable (search_tool)
556
557 -- Build the editor tool
558 create editor_tool.make (Current)
559 editor_tool.attach_to_explorer_bar (right_panel)
560 bottom_tools.extend (editor_tool.explorer_bar_item)
561 editor_tool.text_area.add_edition_observer(save_cmd)
562 editor_tool.text_area.add_edition_observer(save_as_cmd)
563 editor_tool.text_area.add_edition_observer(print_cmd)
564 editor_tool.text_area.add_edition_observer(Current)
565 editor_tool.text_area.drop_actions.set_veto_pebble_function (agent can_drop)
566 editor_tool.text_area.add_cursor_observer (Current)
567
568 -- The minimim height masks a bug on windows to do with the sizing of the editors
569 -- scroll bars, which were affecting the resizing although they should not have done so.
570 -- Having a default minimum height on the editor is perfectly reasonable.
571 editor_tool.widget.set_minimum_height (20)
572 add_recyclable (editor_tool)
573
574 -- Build the context tool
575 create context_tool.make (Current)
576 context_tool.attach_to_explorer_bar (right_panel)
577 bottom_tools.extend (context_tool.explorer_bar_item)
578 create show_cmd.make (Current, context_tool.explorer_bar_item)
579 show_tool_commands.extend (show_cmd)
580 toolbarable_commands.extend (show_cmd)
581 add_recyclable (context_tool)
582
583 -- Set the flag "Tools initialized"
584 tools_initialized := True
585
586 -- Initialize undo / redo accelerators
587 create undo_accelerator.make_with_key_combination (
588 create {EV_KEY}.make_with_code (Key_z), True, False, False)
589 if has_case then
590 undo_accelerator.actions.extend (agent (context_tool.editor.undo_cmd).on_ctrl_z)
591 end
592 undo_accelerator.actions.extend (agent undo_cmd.accelerator_execute)
593 create redo_accelerator.make_with_key_combination (
594 create {EV_KEY}.make_with_code (Key_y), True, False, False)
595 if has_case then
596 redo_accelerator.actions.extend (agent (context_tool.editor.redo_cmd).on_ctrl_y)
597 end
598 redo_accelerator.actions.extend (agent redo_cmd.accelerator_execute)
599 window.accelerators.extend (undo_accelerator)
600 window.accelerators.extend (redo_accelerator)
601 unlock_update
602 end
603
604 feature -- Access
605
606 cluster: CLUSTER_I is
607 -- Cluster for current class. Void if none.
608 local
609 classi_stone: CLASSI_STONE
610 cluster_stone: CLUSTER_STONE
611 do
612 classi_stone ?= stone
613 if classi_stone /= Void then
614 Result := classi_stone.cluster
615 end
616 cluster_stone ?= stone
617 if cluster_stone /= Void then
618 Result := cluster_stone.cluster_i
619 end
620 end
621
622 class_name: STRING is
623 -- Name of the current class, Void if none.
624 local
625 class_stone: CLASSI_STONE
626 do
627 class_stone ?= stone
628 if class_stone /= Void then
629 Result := class_stone.class_name
630 end
631 end
632
633 feature_name: STRING is
634 -- Name of the current feature, Void if none.
635 local
636 feature_stone: FEATURE_STONE
637 do
638 feature_stone ?= stone
639 if feature_stone /= Void then
640 Result := feature_stone.feature_name
641 end
642 end
643
644 feature -- Status setting
645
646 disable_sensitive is
647 -- Disable sensitivity of all widgets.
648 do
649 window.disable_sensitive
650 end
651
652 enable_sensitive is
653 -- Enable sensitivity of all widgets.
654 do
655 window.enable_sensitive
656 end
657
658 feature -- Window Settings
659
660 set_initialized is
661 -- Set `initialized' to True.
662 do
663 initialized := True
664 end
665
666 set_text (a_text: STRING) is
667 -- Assign `a_text' to `text'.
668 require
669 a_text_not_void: a_text /= Void
670 do
671 editor_tool.text_area.set_editor_text (a_text)
672 ensure
673 --| FIXME This needs to work: text_assigned: text.is_equal (a_text)
674 --| FIXME changed_flag_set: changed
675 end
676
677 feature -- Window Properties
678
679 changed: BOOLEAN is
680 -- Has something been changed and not yet been saved?
681 do
682 Result := editor_tool.changed
683 end
684
685 is_empty: BOOLEAN is
686 -- Does `Current's text is empty?
687 do
688 Result := editor_tool = Void or else editor_tool.text_area.is_empty
689 end
690
691 text: STRING is
692 -- Text representing Current
693 do
694 Result := editor_tool.text_area.text
695 end
696
697 pixmap: EV_PIXMAP is
698 -- Pixmap representing Current window.
699 do
700 Result := Pixmaps.Icon_development_window
701 end
702
703 preference_tool_is_hidden: BOOLEAN
704 -- Is the preference tool hidden?
705
706 profile_tool_is_hidden: BOOLEAN
707 -- Is the profile tool hidden?
708
709 has_argument_dialog: BOOLEAN is
710 -- Does Current have an associted arguments dialog?
711 do
712 Result := arguments_dialog /= Void
713 end
714
715 feature -- Pulldown Menus
716
717 metric_menu: EV_MENU
718 -- Menu for entries of metric tool.
719
720 format_menu: EV_MENU
721 -- ID Menu for formats.
722 -- Only used during debugging
723
724 compile_menu: EV_MENU
725 -- Compile ID menu.
726
727 debug_menu: EV_MENU
728 -- Debug ID menu.
729
730 active_menus (erase: BOOLEAN) is
731 -- Enable all the menus and if `erase' clean
732 -- the content of the Project tool.
733 do
734 compile_menu.enable_sensitive
735 if erase then
736 output_manager.clear
737 end
738 end
739
740 disable_menus is
741 -- Disable all the menus.
742 do
743 compile_menu.disable_sensitive
744 end
745
746 feature -- Modifiable menus
747
748 melt_menu_item: EV_MENU_ITEM
749 -- Melt menu entry
750
751 freeze_menu_item: EV_MENU_ITEM
752 -- Freeze menu entry
753
754 finalize_menu_item: EV_MENU_ITEM
755 -- Finalize menu entry
756
757 feature -- Update
758
759 synchronize is
760 -- Synchronize stones.
761 local
762 st: STONE
763 do
764 during_synchronization := True
765 favorites_manager.refresh
766 context_tool.synchronize
767 cluster_tool.synchronize
768 history_manager.synchronize
769 features_tool.synchronize
770 if stone /= Void then
771 st := stone.synchronized_stone
772 end
773 editor_tool.text_area.update_click_list (False)
774 set_stone (st)
775 update_save_symbol
776 address_manager.refresh
777 during_synchronization := False
778 end
779
780 synchronize_routine_tool_to_default is
781 -- Synchronize the editor tool to the debug format.
782 do
783 --| FIXME ARNAUD: To be implemented
784 end
785
786 clear_object_tool is
787 -- Clear the contents of the object tool if shown.
788 do
789 --| FIXME ARNAUD: To be implemented
790 end
791
792 build_menus is
793 -- Build all menus displayed in the development window.
794 do
795 -- Build each menu
796 build_file_menu
797 build_edit_menu
798 build_view_menu
799 build_favorites_menu
800 build_project_menu
801 build_debug_menu
802 build_tools_menu
803 build_window_menu
804 build_help_menu
805 -- Build the menu bar.
806 build_menu_bar
807 end
808
809 build_debug_menu is
810 -- Build the `Debug' menu through the debugger_manager.
811 local
812 conv_mit: EB_COMMAND_MENU_ITEM
813 do
814 debug_menu := debugger_manager.new_debug_menu
815 from
816 debug_menu.start
817 until
818 debug_menu.after
819 loop
820 conv_mit ?= debug_menu.item
821 if conv_mit /= Void then
822 add_recyclable (conv_mit)
823 end
824 debug_menu.forth
825 end
826 end
827
828 build_menu_bar is
829 -- Build the menu bar
830 local
831 mb: EV_MENU_BAR
832 do
833 check
834 window.menu_bar /= Void implies not window.menu_bar.is_empty
835 -- If a menu bar was already present, it shouldn't be empty.
836 end
837 if window.menu_bar /= Void then
838 mb := window.menu_bar
839 from
840 mb.start
841 mb.forth
842 until
843 mb.after
844 loop
845 mb.remove
846 end
847 else
848 create mb
849 window.set_menu_bar (mb)
850 mb.extend (file_menu)
851 end
852
853 if Eiffel_project.manager.is_created then
854 mb.extend (edit_menu)
855 mb.extend (view_menu)
856 mb.extend (favorites_menu)
857 mb.extend (project_menu)
858 mb.extend (debug_menu)
859 else
860 mb.extend (view_menu)
861 end
862 mb.extend (tools_menu)
863 mb.extend (window_menu)
864 mb.extend (help_menu)
865 end
866
867 feature -- Graphical Interface
868
869 build_general_toolbar is
870 -- Set up the general toolbar (New, Save, Search, Shell, Undo, Redo, ...)
871 local
872 cell: EV_CELL
873 hsep: EV_HORIZONTAL_SEPARATOR
874 hbox: EV_HORIZONTAL_BOX
875 do
876 -- Create the toolbar.
877 create general_toolbar
878 general_customizable_toolbar := preferences.development_window_data.retrieve_general_toolbar (toolbarable_commands)
879 if preferences.development_window_data.show_text_in_general_toolbar then
880 general_customizable_toolbar.enable_important_text
881 elseif preferences.development_window_data.show_all_text_in_general_toolbar then
882 general_customizable_toolbar.enable_text_displayed
883 end
884
885 create hbox
886 hbox.extend (general_customizable_toolbar.widget)
887 hbox.disable_item_expand (general_customizable_toolbar.widget)
888
889 -- Generate the toolbar.
890 general_customizable_toolbar.update_toolbar
891
892 -- Cell to fill in empty space and receive the right click menu holder.
893 create cell
894 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
895 hbox.extend (cell)
896
897 -- Create the vertical layout (separator + toolbar)
898 create hsep
899 general_toolbar.set_padding (2)
900 general_toolbar.extend (hsep)
901 general_toolbar.disable_item_expand (hsep)
902 general_toolbar.extend (hbox)
903
904 -- Create the command to show/hide this toolbar.
905 create show_general_toolbar_command.make (general_toolbar, Interface_names.m_general_toolbar)
906 show_toolbar_commands.extend (show_general_toolbar_command)
907 if preferences.development_window_data.show_general_toolbar then
908 show_general_toolbar_command.enable_visible
909 else
910 show_general_toolbar_command.disable_visible
911 end
912
913 end
914
915 build_address_toolbar is
916 -- Set up the address toolbar (Back, Forward, Current, Class name, feature name, ...)
917 local
918 tb: EV_TOOL_BAR
919 -- address_bar: EV_HORIZONTAL_BOX -- Contains "Class" + Combobox + "Feature" + Combobox + "Format" + Combobox
920 hsep: EV_HORIZONTAL_SEPARATOR
921 hbox: EV_HORIZONTAL_BOX -- Contains HistoryToolbar (back, forth, current) + `address_bar'
922 cell: EV_CELL
923 accel: EV_ACCELERATOR
924 do
925 -- Create the toolbar
926 create address_toolbar
927 create hsep
928 create hbox
929 -- create address_bar
930 create tb
931 address_toolbar.set_padding (2)
932 address_toolbar.extend (hsep)
933 address_toolbar.disable_item_expand (hsep)
934 address_toolbar.extend (hbox)
935
936 hbox.extend (tb)
937 hbox.disable_item_expand (tb)
938 -- hbox.extend (address_bar)
939 -- hbox.disable_item_expand (address_bar)
940
941 -- Back icon
942 tb.extend (history_manager.back_command.new_toolbar_item (False, False))
943
944 -- Forward icon
945 tb.extend (history_manager.forth_command.new_toolbar_item (False, False))
946
947 -- Set up the accelerators.
948 create accel.make_with_key_combination (
949 create {EV_KEY}.make_with_code (Kcst.Key_right), False, True, False
950 )
951 accel.actions.extend (agent on_forth)
952 window.accelerators.extend (accel)
953
954 create accel.make_with_key_combination (
955 create {EV_KEY}.make_with_code (Kcst.Key_left), False, True, False
956 )
957 accel.actions.extend (agent on_back)
958 window.accelerators.extend (accel)
959
960 ------------------------------------------
961 -- Address bar (Class name & feature name)
962 ------------------------------------------
963 hbox.extend (address_manager.widget)
964 -- editor_tool.text_area.add_cursor_observer (address_manager)
965
966 -- Create the command to show/hide this toolbar.
967 create show_address_toolbar_command.make (address_toolbar, Interface_names.m_address_toolbar)
968 show_toolbar_commands.extend (show_address_toolbar_command)
969
970 if preferences.development_window_data.show_address_toolbar then
971 show_address_toolbar_command.enable_visible
972 else
973 show_address_toolbar_command.disable_visible
974 end
975
976 -- Cell to fill in empty space and receive the right click menu holder.
977 create cell
978 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
979 hbox.extend (cell)
980 end
981
982 build_project_toolbar is
983 -- Build toolbar corresponding to the project options bar
984 local
985 cell: EV_CELL
986 hsep: EV_HORIZONTAL_SEPARATOR
987 hbox: EV_HORIZONTAL_BOX
988 do
989 create project_toolbar
990 create hsep
991 project_toolbar.extend (hsep)
992 project_toolbar.disable_item_expand (hsep)
993
994 -- Generate the toolbar.
995 create hbox
996 project_customizable_toolbar := debugger_manager.new_toolbar
997 hbox.extend (project_customizable_toolbar.widget)
998 hbox.disable_item_expand (project_customizable_toolbar.widget)
999
1000 project_customizable_toolbar.update_toolbar
1001
1002 -- Create the command to show/hide this toolbar.
1003 create show_project_toolbar_command.make (project_toolbar, Interface_names.m_project_toolbar)
1004 show_toolbar_commands.extend (show_project_toolbar_command)
1005 if preferences.development_window_data.show_project_toolbar then
1006 show_project_toolbar_command.enable_visible
1007 else
1008 show_project_toolbar_command.disable_visible
1009 end
1010
1011 -- Cell to fill in empty space and receive the right click menu holder.
1012 create cell
1013 cell.pointer_button_release_actions.extend (agent toolbar_right_click_action)
1014 hbox.extend (cell)
1015 project_toolbar.extend (hbox)
1016 end
1017
1018 feature {NONE} -- Menu Building
1019
1020 build_file_menu is
1021 -- Build the file menu.
1022 local
1023 new_project_cmd: EB_NEW_PROJECT_COMMAND
1024 open_project_cmd: EB_OPEN_PROJECT_COMMAND
1025 send_to_menu: EV_MENU
1026 menu_item: EV_MENU_ITEM
1027 command_menu_item: EB_COMMAND_MENU_ITEM
1028 do
1029 create file_menu.make_with_text (Interface_names.m_file)
1030
1031 -- New
1032 command_menu_item := New_development_window_cmd.new_menu_item
1033 add_recyclable (command_menu_item)
1034 file_menu.extend (command_menu_item)
1035
1036 -- New editor
1037 command_menu_item := New_editor_cmd.new_menu_item
1038 add_recyclable (command_menu_item)
1039 file_menu.extend (command_menu_item)
1040
1041 -- New context tool
1042 command_menu_item := New_context_tool_cmd.new_menu_item
1043 add_recyclable (command_menu_item)
1044 file_menu.extend (command_menu_item)
1045
1046 -- Open
1047 command_menu_item := open_cmd.new_menu_item
1048 add_recyclable (command_menu_item)
1049 file_menu.extend (command_menu_item)
1050
1051 -- Close
1052 create menu_item.make_with_text (Interface_names.m_close)
1053 menu_item.select_actions.extend (agent destroy)
1054 file_menu.extend (menu_item)
1055
1056 -- Separator --------------------------------------
1057 file_menu.extend (create {EV_MENU_SEPARATOR})
1058
1059 -- Save
1060 command_menu_item := save_cmd.new_menu_item
1061 add_recyclable (command_menu_item)
1062 file_menu.extend (command_menu_item)
1063
1064 -- Save as
1065 command_menu_item := save_as_cmd.new_menu_item
1066 add_recyclable (command_menu_item)
1067 file_menu.extend (command_menu_item)
1068
1069 -- Sent to
1070 create send_to_menu.make_with_text (Interface_names.m_send_to)
1071 -- External editor
1072 command_menu_item := shell_cmd.new_menu_item
1073 add_recyclable (command_menu_item)
1074 send_to_menu.extend (command_menu_item)
1075 file_menu.extend (send_to_menu)
1076
1077 -- Separator --------------------------------------
1078 file_menu.extend (create {EV_MENU_SEPARATOR})
1079 command_menu_item := print_cmd.new_menu_item
1080 add_recyclable (command_menu_item)
1081 file_menu.extend (command_menu_item)
1082
1083 -- Separator --------------------------------------
1084 file_menu.extend (create {EV_MENU_SEPARATOR})
1085
1086 -- New Project
1087 create new_project_cmd.make_with_parent (window)
1088 create menu_item.make_with_text (Interface_names.m_new_project)
1089 menu_item.select_actions.extend (agent new_project_cmd.execute)
1090 file_menu.extend (menu_item)
1091
1092 -- Open Project
1093 create open_project_cmd.make_with_parent (window)
1094 create menu_item.make_with_text (Interface_names.m_open_project)
1095 menu_item.select_actions.extend (agent open_project_cmd.execute)
1096 file_menu.extend (menu_item)
1097
1098 -- Recent Projects
1099 recent_projects_menu := recent_projects_manager.new_menu
1100 add_recyclable (recent_projects_menu)
1101 file_menu.extend (recent_projects_menu)
1102
1103 -- Separator --------------------------------------
1104 file_menu.extend (create {EV_MENU_SEPARATOR})
1105
1106 -- Exit
1107 command_menu_item := Exit_application_cmd.new_menu_item
1108 add_recyclable (Command_menu_item)
1109 file_menu.extend (command_menu_item)
1110 end
1111
1112 build_class_info_menu: EV_MENU is
1113 -- Build the class format sub-menu.
1114 local
1115 form: EB_CLASS_INFO_FORMATTER
1116 empty_menu: EV_MENU_ITEM
1117 i: INTEGER
1118 do
1119 create Result.make_with_text (Interface_names.m_class_info)
1120 i := 1
1121
1122 create empty_menu.make_with_text (Interface_names.m_formatter_separators @ i)
1123 i := i + 1
1124 empty_menu.disable_sensitive
1125 Result.extend (empty_menu)
1126 from
1127 managed_class_formatters.start
1128 until
1129 managed_class_formatters.after
1130 loop
1131 form := managed_class_formatters.item
1132 if form /= Void then
1133 Result.extend (form.new_menu_item)
1134 else
1135 create empty_menu.make_with_text (Interface_names.m_formatter_separators @ i)
1136 i := i + 1
1137 empty_menu.disable_sensitive
1138 Result.extend (empty_menu)
1139 end
1140 managed_class_formatters.forth
1141 end
1142 end
1143
1144 build_feature_info_menu: EV_MENU is
1145 -- Build the feature format sub-menu.
1146 local
1147 form: EB_FEATURE_INFO_FORMATTER
1148 do
1149 create Result.make_with_text (Interface_names.m_feature_info)
1150 from
1151 managed_feature_formatters.start
1152 until
1153 managed_feature_formatters.after
1154 loop
1155 form := managed_feature_formatters.item
1156 if form /= Void then
1157 Result.extend (form.new_menu_item)
1158 end
1159 managed_feature_formatters.forth
1160 end
1161 end
1162
1163 build_edit_menu is
1164 -- Create and build `edit_menu'
1165 local
1166 command_menu_item: EB_COMMAND_MENU_ITEM
1167 sub_menu: EV_MENU
1168 cmd: EB_EDITOR_COMMAND
1169 os_cmd: EB_ON_SELECTION_COMMAND
1170 editor: EB_SMART_EDITOR
1171 do
1172 editor := editor_tool.text_area
1173 create command_controller.make
1174
1175 create edit_menu.make_with_text (Interface_names.m_edit)
1176
1177 -- Undo
1178 command_menu_item := undo_cmd.new_menu_item
1179 add_recyclable (command_menu_item)
1180 edit_menu.extend (command_menu_item)
1181
1182 -- Redo
1183 command_menu_item := redo_cmd.new_menu_item
1184 add_recyclable (command_menu_item)
1185 edit_menu.extend (command_menu_item)
1186
1187 -- Separator --------------------------------------
1188 edit_menu.extend (create {EV_MENU_SEPARATOR})
1189
1190 -- Cut
1191 create os_cmd.make (Current)
1192 os_cmd.set_menu_name (Interface_names.M_cut)
1193 os_cmd.set_pixmaps (pixmaps.icon_cut)
1194 os_cmd.set_name ("Editor_cut")
1195 os_cmd.set_tooltip (interface_names.f_cut)
1196 os_cmd.add_agent (agent cut_selection)
1197 os_cmd.set_tooltext (Interface_names.b_cut)
1198 toolbarable_commands.extend (os_cmd)
1199 os_cmd.set_needs_editable (True)
1200 command_controller.add_selection_command (os_cmd)
1201 command_menu_item := os_cmd.new_menu_item
1202 add_recyclable (command_menu_item)
1203 edit_menu.extend (command_menu_item)
1204
1205 -- Copy
1206 create os_cmd.make (Current)
1207 os_cmd.set_menu_name (Interface_names.M_copy)
1208 os_cmd.set_pixmaps (pixmaps.icon_copy)
1209 os_cmd.set_name ("Editor_copy")
1210 os_cmd.set_tooltip (interface_names.f_copy)
1211 os_cmd.set_tooltext (Interface_names.b_copy)
1212 os_cmd.add_agent (agent copy_selection)
1213 toolbarable_commands.extend (os_cmd)
1214 os_cmd.set_needs_editable (False)
1215 command_controller.add_selection_command (os_cmd)
1216 command_menu_item := os_cmd.new_menu_item
1217 add_recyclable (command_menu_item)
1218 edit_menu.extend (command_menu_item)
1219
1220 -- Paste
1221 command_menu_item := editor_paste_cmd.new_menu_item
1222 add_recyclable (command_menu_item)
1223 edit_menu.extend (command_menu_item)
1224
1225 -- Separator --------------------------------------
1226 edit_menu.extend (create {EV_MENU_SEPARATOR})
1227
1228 -- Select all
1229 create cmd.make
1230 cmd.set_menu_name (Interface_names.m_select_all)
1231 cmd.add_agent (agent select_all)
1232 command_menu_item := cmd.new_menu_item
1233 command_controller.add_edition_command (cmd)
1234 add_recyclable (command_menu_item)
1235 edit_menu.extend (command_menu_item)
1236
1237 -- Separator --------------------------------------
1238 edit_menu.extend (create {EV_MENU_SEPARATOR})
1239
1240 -- Line numbers
1241 create cmd.make
1242 cmd.set_menu_name (Interface_names.m_line_numbers)
1243 cmd.add_agent (agent toggle_line_number_display)
1244 cmd.set_needs_editable (True)
1245 command_menu_item := cmd.new_menu_item
1246 command_controller.add_edition_command (cmd)
1247 add_recyclable (command_menu_item)
1248 edit_menu.extend (command_menu_item)
1249
1250 -- Separator --------------------------------------
1251 edit_menu.extend (create {EV_MENU_SEPARATOR})
1252
1253 -- Search
1254 create cmd.make
1255 cmd.set_menu_name (Interface_names.m_search + "%T" + preferences.editor_data.shortcut_name_for_action (3))
1256 cmd.add_agent (agent search)
1257 command_menu_item := cmd.new_menu_item
1258 command_controller.add_edition_command (cmd)
1259 add_recyclable (command_menu_item)
1260 edit_menu.extend (command_menu_item)
1261
1262 -- Go to
1263 create cmd.make
1264 cmd.set_menu_name (Interface_names.m_go_to)
1265 cmd.add_agent (agent goto)
1266 cmd.set_needs_editable (True)
1267 command_menu_item := cmd.new_menu_item
1268 command_controller.add_edition_command (cmd)
1269 add_recyclable (command_menu_item)
1270 edit_menu.extend (command_menu_item)
1271
1272 -- Replace
1273 create cmd.make
1274 cmd.set_menu_name (Interface_names.m_replace + "%T" + preferences.editor_data.shortcut_name_for_action (4))
1275 cmd.add_agent (agent editor.replace)
1276 cmd.set_needs_editable (True)
1277 command_menu_item := cmd.new_menu_item
1278 command_controller.add_edition_command (cmd)
1279 add_recyclable (command_menu_item)
1280 edit_menu.extend (command_menu_item)
1281
1282 -- Find sub menu
1283
1284 create sub_menu.make_with_text (Interface_names.m_find)
1285
1286 -- Find next
1287 create cmd.make
1288 cmd.set_menu_name (Interface_names.m_find_next + "%T" + preferences.editor_data.shortcut_name_for_action (6))
1289 cmd.add_agent (agent find_next)
1290 command_menu_item := cmd.new_menu_item
1291 command_controller.add_edition_command (cmd)
1292 add_recyclable (command_menu_item)
1293 sub_menu.extend (command_menu_item)
1294
1295 -- Find previous
1296 create cmd.make
1297 cmd.set_menu_name (Interface_names.m_find_previous + "%T" + preferences.editor_data.shortcut_name_for_action (7))
1298 cmd.add_agent (agent find_previous)
1299 command_menu_item := cmd.new_menu_item
1300 command_controller.add_edition_command (cmd)
1301 add_recyclable (command_menu_item)
1302 sub_menu.extend (command_menu_item)
1303
1304 -- Find selection
1305 create os_cmd.make (Current)
1306 os_cmd.set_menu_name (Interface_names.m_find_selection + "%T" + preferences.editor_data.shortcut_name_for_action (5))
1307 os_cmd.add_agent (agent find_selection)
1308 command_menu_item := os_cmd.new_menu_item
1309 command_controller.add_selection_command (os_cmd)
1310 add_recyclable (command_menu_item)
1311 sub_menu.extend (command_menu_item)
1312
1313 edit_menu.extend (sub_menu)
1314
1315
1316 -- Separator --------------------------------------
1317 edit_menu.extend (create {EV_MENU_SEPARATOR})
1318
1319 create sub_menu.make_with_text (Interface_names.m_advanced)
1320
1321 create os_cmd.make (Current)
1322 os_cmd.set_needs_editable (True)
1323 command_controller.add_selection_command (os_cmd)
1324 os_cmd.set_menu_name (Interface_names.m_indent)
1325 os_cmd.add_agent (agent editor.indent_selection)
1326 command_menu_item := os_cmd.new_menu_item
1327 add_recyclable (command_menu_item)
1328 sub_menu.extend (command_menu_item)
1329
1330 create os_cmd.make (Current)
1331 os_cmd.set_needs_editable (True)
1332 command_controller.add_selection_command (os_cmd)
1333 os_cmd.set_menu_name (Interface_names.m_unindent)
1334 os_cmd.add_agent (agent editor.unindent_selection)
1335 command_menu_item := os_cmd.new_menu_item
1336 add_recyclable (command_menu_item)
1337 sub_menu.extend (command_menu_item)
1338
1339 create os_cmd.make (Current)
1340 os_cmd.set_needs_editable (True)
1341 command_controller.add_selection_command (os_cmd)
1342 os_cmd.set_menu_name (Interface_names.m_to_lower)
1343 os_cmd.add_agent (agent editor.set_selection_case (True))
1344 command_menu_item := os_cmd.new_menu_item
1345 add_recyclable (command_menu_item)
1346 sub_menu.extend (command_menu_item)
1347
1348 create os_cmd.make (Current)
1349 os_cmd.set_needs_editable (True)
1350 command_controller.add_selection_command (os_cmd)
1351 os_cmd.set_menu_name (Interface_names.m_to_upper)
1352 os_cmd.add_agent (agent editor.set_selection_case (False))
1353 command_menu_item := os_cmd.new_menu_item
1354 add_recyclable (command_menu_item)
1355 sub_menu.extend (command_menu_item)
1356
1357 create cmd.make
1358 cmd.set_needs_editable (True)
1359 cmd.set_menu_name (Interface_names.m_comment)
1360 cmd.add_agent (agent editor.comment_selection)
1361 command_menu_item := cmd.new_menu_item
1362 command_controller.add_edition_command (cmd)
1363 add_recyclable (command_menu_item)
1364 sub_menu.extend (command_menu_item)
1365
1366 create cmd.make
1367 cmd.set_needs_editable (True)
1368 cmd.set_menu_name (Interface_names.m_uncomment)
1369 cmd.add_agent (agent editor.uncomment_selection)
1370 command_menu_item := cmd.new_menu_item
1371 command_controller.add_edition_command (cmd)
1372 add_recyclable (command_menu_item)
1373 sub_menu.extend (command_menu_item)
1374
1375 -- Separator --------------------------------------
1376 sub_menu.extend (create {EV_MENU_SEPARATOR})
1377
1378 -- Insert if block
1379 create cmd.make
1380 cmd.set_needs_editable (True)
1381 cmd.set_menu_name (Interface_names.m_if_block)
1382 cmd.add_agent (agent editor.embed_in_block("if then", 3))
1383 command_menu_item := cmd.new_menu_item
1384 command_controller.add_edition_command (cmd)
1385 add_recyclable (command_menu_item)
1386 sub_menu.extend (command_menu_item)
1387
1388 -- Insert debug block
1389 create cmd.make
1390 cmd.set_needs_editable (True)
1391 cmd.set_menu_name (Interface_names.m_debug_block)
1392 cmd.add_agent (agent editor.embed_in_block("debug", 5))
1393 command_menu_item := cmd.new_menu_item
1394 command_controller.add_edition_command (cmd)
1395 add_recyclable (command_menu_item)
1396 sub_menu.extend (command_menu_item)
1397
1398
1399 -- Separator --------------------------------------
1400 sub_menu.extend (create {EV_MENU_SEPARATOR})
1401
1402 -- Complete word
1403 create cmd.make
1404 cmd.set_needs_editable (True)
1405 cmd.set_menu_name (Interface_names.m_complete_word + "%T" + preferences.editor_data.shortcut_name_for_action (1))
1406 command_menu_item := cmd.new_menu_item
1407 command_controller.add_edition_command (cmd)
1408 cmd.add_agent (agent editor.complete_feature_name)
1409
1410 add_recyclable (command_menu_item)
1411 sub_menu.extend (command_menu_item)
1412
1413 -- Complete class name
1414 create cmd.make
1415 cmd.set_needs_editable (True)
1416 cmd.set_menu_name (Interface_names.m_complete_class_name + "%T" + preferences.editor_data.shortcut_name_for_action (2))
1417 command_menu_item := cmd.new_menu_item
1418 command_controller.add_edition_command (cmd)
1419 cmd.add_agent (agent editor.complete_class_name)
1420
1421 add_recyclable (command_menu_item)
1422 sub_menu.extend (command_menu_item)
1423
1424 sub_menu.extend (create {EV_MENU_SEPARATOR})
1425
1426 -- show/hide formatting marks.
1427 create cmd.make
1428 if editor_tool.text_area.view_invisible_symbols then
1429 cmd.set_menu_name (Interface_names.m_hide_formatting_marks)
1430 else
1431 cmd.set_menu_name (Interface_names.m_show_formatting_marks)
1432 end
1433 formatting_marks_command_menu_item := cmd.new_menu_item
1434 command_controller.add_edition_command (cmd)
1435 cmd.add_agent (agent toggle_formatting_marks)
1436
1437 add_recyclable (formatting_marks_command_menu_item)
1438 sub_menu.extend (formatting_marks_command_menu_item)
1439
1440 edit_menu.extend (sub_menu)
1441 end
1442
1443 build_view_menu is
1444 -- Build the view menu.
1445 local
1446 form: EB_CLASS_INFO_FORMATTER
1447 new_menu_item: EB_COMMAND_MENU_ITEM
1448 new_basic_item: EV_MENU_ITEM
1449 do
1450 Precursor
1451
1452 new_menu_item := toggle_stone_cmd.new_menu_item
1453 view_menu.extend (new_menu_item)
1454 add_recyclable (new_menu_item)
1455
1456 new_menu_item := send_stone_to_context_cmd.new_menu_item
1457 view_menu.extend (new_menu_item)
1458 add_recyclable (new_menu_item)
1459 -- Go to menu
1460 new_basic_item := history_manager.new_menu
1461 view_menu.extend (new_basic_item)
1462
1463 -- Separator --------------------------------------
1464 view_menu.extend (create {EV_MENU_SEPARATOR})
1465 view_menu.extend (build_class_info_menu)
1466 view_menu.extend (build_feature_info_menu)
1467
1468 -- Separator --------------------------------------
1469 view_menu.extend (create {EV_MENU_SEPARATOR})
1470
1471 from
1472 managed_main_formatters.start
1473 until
1474 managed_main_formatters.after
1475 loop
1476 form := managed_main_formatters.item
1477 new_basic_item := form.new_menu_item
1478 new_basic_item.select_actions.put_front (agent form.invalidate)
1479 view_menu.extend (new_basic_item)
1480 --add_recyclable (new_basic_item)
1481 managed_main_formatters.forth
1482 end
1483 end
1484
1485 build_favorites_menu is
1486 -- Build the favorites menu
1487 do
1488 Precursor {EB_TOOL_MANAGER}
1489
1490 create show_favorites_menu_item
1491 update_show_favorites_menu_item
1492 show_favorites_menu_item.select_actions.extend (agent execute_show_favorites)
1493
1494 favorites_menu.start
1495 favorites_menu.put_right (show_favorites_menu_item)
1496 favorites_menu.select_actions.extend (agent update_show_favorites_menu_item)
1497 end
1498
1499 build_project_menu is
1500 -- Build the project menu.
1501 local
1502 command_menu_item: EB_COMMAND_MENU_ITEM
1503 do
1504 create project_menu.make_with_text (Interface_names.m_project)
1505
1506 -- Melt
1507 command_menu_item := Melt_project_cmd.new_menu_item
1508 add_recyclable (command_menu_item)
1509 project_menu.extend (command_menu_item)
1510
1511 -- Quick melt
1512 command_menu_item := Quick_melt_project_cmd.new_menu_item
1513 add_recyclable (command_menu_item)
1514 project_menu.extend (command_menu_item)
1515
1516 -- Freeze
1517 command_menu_item := Freeze_project_cmd.new_menu_item
1518 add_recyclable (command_menu_item)
1519 project_menu.extend (command_menu_item)
1520
1521 -- Finalize
1522 command_menu_item := Finalize_project_cmd.new_menu_item
1523 add_recyclable (command_menu_item)
1524 project_menu.extend (command_menu_item)
1525
1526 -- Precompile
1527 command_menu_item := precompilation_cmd.new_menu_item
1528 add_recyclable (command_menu_item)
1529 project_menu.extend (command_menu_item)
1530
1531 -- Separator -------------------------------------------------
1532 project_menu.extend (create {EV_MENU_SEPARATOR})
1533
1534 -- Compile Workbench C code
1535 command_menu_item := c_workbench_compilation_cmd.new_menu_item
1536 add_recyclable (command_menu_item)
1537 project_menu.extend (command_menu_item)
1538
1539 -- Compile Finalized C code
1540 command_menu_item := c_finalized_compilation_cmd.new_menu_item
1541 add_recyclable (command_menu_item)
1542 project_menu.extend (command_menu_item)
1543
1544 -- Execute Finalized code
1545 command_menu_item := run_finalized_cmd.new_menu_item
1546 add_recyclable (command_menu_item)
1547 project_menu.extend (command_menu_item)
1548
1549 -- Separator -------------------------------------------------
1550 project_menu.extend (create {EV_MENU_SEPARATOR})
1551
1552 -- System Tool window
1553 command_menu_item := system_cmd.new_menu_item
1554 add_recyclable (command_menu_item)
1555 project_menu.extend (command_menu_item)
1556
1557 -- System information
1558 command_menu_item := system_info_cmd.new_menu_item
1559 add_recyclable (command_menu_item)
1560 project_menu.extend (command_menu_item)
1561
1562 -- Error information
1563 command_menu_item := display_error_help_cmd.new_menu_item
1564 add_recyclable (command_menu_item)
1565 project_menu.extend (command_menu_item)
1566
1567 if has_documentation_generation or has_xmi_generation then
1568 -- Separator -------------------------------------------------
1569 project_menu.extend (create {EV_MENU_SEPARATOR})
1570 end
1571
1572 if has_documentation_generation then
1573 -- Generate Documentation
1574 command_menu_item := document_cmd.new_menu_item
1575 add_recyclable (command_menu_item)
1576 project_menu.extend (command_menu_item)
1577 end
1578
1579 if has_xmi_generation then
1580 -- Export XMI
1581 command_menu_item := export_cmd.new_menu_item
1582 add_recyclable (command_menu_item)
1583 project_menu.extend (command_menu_item)
1584 end
1585 end
1586
1587 build_tools_menu is
1588 -- Create and build `tools_menu'
1589 local
1590 command_menu_item: EB_COMMAND_MENU_ITEM
1591 menu_item: EV_MENU_ITEM
1592 do
1593 create tools_menu.make_with_text (Interface_names.m_tools)
1594
1595 -- New Cluster command.
1596 command_menu_item := new_cluster_cmd.new_menu_item
1597 add_recyclable (command_menu_item)
1598 tools_menu.extend (command_menu_item)
1599
1600 -- New Class command.
1601 command_menu_item := new_class_cmd.new_menu_item
1602 add_recyclable (command_menu_item)
1603 tools_menu.extend (command_menu_item)
1604
1605 -- New Feature command.
1606 command_menu_item := new_feature_cmd.new_menu_item
1607 add_recyclable (command_menu_item)
1608 tools_menu.extend (command_menu_item)
1609
1610 -- Delete class/cluster command.
1611 command_menu_item := delete_class_cluster_cmd.new_menu_item
1612 add_recyclable (command_menu_item)
1613 tools_menu.extend (command_menu_item)
1614
1615 -- Separator --------------------------------------
1616 tools_menu.extend (create {EV_MENU_SEPARATOR})
1617
1618
1619 if has_metrics then
1620 -- Metric tool
1621 create metric_menu.make_with_text (interface_names.metric_metrics)
1622 create menu_item.make_with_text (interface_names.metric_calculate)
1623 metric_menu.extend (menu_item)
1624 create menu_item.make_with_text (interface_names.metric_add)
1625 metric_menu.extend (menu_item)
1626 create menu_item.make_with_text (interface_names.metric_delete)
1627 metric_menu.extend (menu_item)
1628 create menu_item.make_with_text (interface_names.metric_details)
1629 metric_menu.extend (menu_item)
1630 create menu_item.make_with_text (interface_names.metric_new_metrics)
1631 metric_menu.extend (menu_item)
1632 create menu_item.make_with_text (interface_names.metric_management)
1633 metric_menu.extend (menu_item)
1634 create menu_item.make_with_text (interface_names.metric_archive)
1635 metric_menu.extend (menu_item)
1636 metric_menu.disable_sensitive
1637 tools_menu.extend (metric_menu)
1638 end
1639
1640 if has_profiler then
1641 -- Profiler Window
1642 command_menu_item := show_profiler.new_menu_item
1643 add_recyclable (command_menu_item)
1644 tools_menu.extend (command_menu_item)
1645 end
1646
1647 -- Precompile Wizard
1648 command_menu_item := wizard_precompile_cmd.new_menu_item
1649 add_recyclable (command_menu_item)
1650 tools_menu.extend (command_menu_item)
1651
1652 if has_dll_generation then
1653 -- Dynamic Library Window
1654 command_menu_item := show_dynamic_lib_tool.new_menu_item
1655 add_recyclable (command_menu_item)
1656 tools_menu.extend (command_menu_item)
1657 end
1658
1659 -- Separator -------------------------------------------------
1660 tools_menu.extend (create {EV_MENU_SEPARATOR})
1661
1662 -- Preferences
1663 command_menu_item := Show_preferences_cmd.new_menu_item
1664 add_recyclable (command_menu_item)
1665 tools_menu.extend (command_menu_item)
1666
1667 -- External commands editor
1668 command_menu_item := Edit_external_commands_cmd.new_menu_item
1669 add_recyclable (command_menu_item)
1670 tools_menu.extend (command_menu_item)
1671
1672 -- Separator -------------------------------------------------
1673 tools_menu.extend (create {EV_MENU_SEPARATOR})
1674
1675 rebuild_tools_menu
1676 end
1677
1678 feature -- Stone process
1679
1680 stone: STONE
1681 -- Current stone
1682
1683 toggle_unified_stone is
1684 -- Change the stone management mode.
1685 do
1686 unified_stone := not unified_stone
1687 if unified_stone then
1688 send_stone_to_context
1689 send_stone_to_context_cmd.disable_sensitive
1690 context_tool.link_to_development_window
1691 else
1692 if stone /= Void then
1693 send_stone_to_context_cmd.enable_sensitive
1694 end
1695 context_tool.cut_from_development_window
1696 end
1697 end
1698
1699 set_stone (a_stone: STONE) is
1700 -- Change the currently focused stone.
1701 local
1702 cd: STANDARD_DISCARDABLE_CONFIRMATION_DIALOG
1703 cv_cst: CLASSI_STONE
1704 ef_stone: EXTERNAL_FILE_STONE
1705 l: LIST [EB_DEVELOPMENT_WINDOW]
1706 l_filename: STRING
1707 do
1708 cv_cst ?= a_stone
1709 if cv_cst /= Void then
1710 l_filename := cv_cst.class_i.name
1711 else
1712 ef_stone ?= a_stone
1713 if ef_stone /= Void then
1714 l_filename := ef_stone.file_name.string
1715 end
1716 end
1717
1718 if cv_cst /= Void or ef_stone /= Void then
1719 l := Window_manager.development_windows_with_class (l_filename)
1720 if l.is_empty or else l.has (Current) then
1721 -- We're not editing the class in another window.
1722 set_stone_after_first_check (a_stone)
1723 else
1724 create cd.make_initialized (2,
1725 preferences.dialog_data.already_editing_class_string,
1726 warning_messages.w_class_already_edited,
1727 Interface_names.l_do_not_show_again,
1728 preferences.preferences)
1729 cd.set_ok_action (agent set_stone_after_first_check (a_stone))
1730 cd.show_modal_to_window (window)
1731 end
1732 else
1733 set_stone_after_first_check (a_stone)
1734 end
1735 end
1736
1737 set_stone_after_first_check (a_stone: STONE) is
1738 -- Display text associated with `a_stone', if any and if possible
1739 local
1740 feature_stone: FEATURE_STONE
1741 old_class_stone: CLASSI_STONE
1742 test_stone: CLASSI_STONE
1743 same_class: BOOLEAN
1744 conv_ferrst: FEATURE_ERROR_STONE
1745 ef_stone: EXTERNAL_FILE_STONE
1746 do
1747 old_class_stone ?= stone
1748 feature_stone ?= a_stone
1749 ef_stone ?= a_stone
1750 if old_class_stone /= Void then
1751 create test_stone.make (old_class_stone.class_i)
1752 same_class := test_stone.same_as (a_stone)
1753 -- We need to compare classes. If `old_class_stone' is a FEATURE_STONE
1754 -- `same_as' will compare features. Therefore, we need `test_stone' to be sure
1755 -- we have a CLASSI_STONE.
1756 if same_class and then feature_stone /= Void then
1757 same_class := False
1758 -- if the stone corresponding to a feature of currently opened class is dropped
1759 -- we attempt to scroll to the feature without asking to save the file
1760 -- except if it is during a resynchronization, in which case we do not scroll at all.
1761 if editor_tool.text_area.text_is_fully_loaded then
1762 if not during_synchronization then
1763 editor_tool.text_area.find_feature_named (feature_stone.feature_name)
1764 feature_stone_already_processed := editor_tool.text_area.found_feature
1765 else
1766 feature_stone_already_processed := True
1767 end
1768 conv_ferrst ?= feature_stone
1769 if feature_stone_already_processed and conv_ferrst /= Void then
1770 -- Scroll to the line of the error.
1771 if not during_synchronization then
1772 editor_tool.text_area.display_line_when_ready (conv_ferrst.line_number, True)
1773 end
1774 end
1775 end
1776 end
1777 elseif ef_stone /= Void then
1778 end
1779
1780 -- first, let's check if there is already something in this window
1781 -- if there's nothing, there's no need to save anything...
1782 if stone = Void or else not changed or else feature_stone_already_processed or else same_class then
1783 set_stone_after_check (a_stone)
1784 feature_stone_already_processed := False
1785 else
1786 -- there is something to be saved
1787 -- if user chooses to save, current file will be parsed
1788 -- if there is a syntax_error, new file is not loaded
1789 save_and (agent set_stone_after_check (a_stone))
1790 if text_saved and then not syntax_is_correct then
1791 text_saved := False
1792 during_synchronization := True
1793 set_stone_after_check (stone)
1794 during_synchronization := False
1795 address_manager.refresh
1796 end
1797 end
1798 end
1799
1800 force_stone (s: STONE) is
1801 -- make `s' the new value of `stone', and
1802 -- change the display accordingly. Try to
1803 -- extract a class from `s' whenever possible.
1804 do
1805 if s.is_storable then
1806 set_stone (s)
1807 if not unified_stone then
1808 context_tool.advanced_set_stone (s)
1809 end
1810 end
1811 end
1812
1813 process_class (s: CLASSI_STONE) is
1814 -- Process class stone
1815 do
1816 set_stone (s)
1817 end
1818
1819 process_feature_error (s: FEATURE_ERROR_STONE) is
1820 -- Process feature error stone.
1821 local
1822 cl_stone: CLASSC_STONE
1823 e_class: CLASS_C
1824 do
1825 set_default_format
1826 e_class := s.e_feature.written_class
1827 create cl_stone.make (e_class)
1828 set_stone (cl_stone)
1829 editor_tool.text_area.deselect_all
1830 if s.line_number > 0 then
1831 editor_tool.text_area.highlight_selected (s.line_number, s.line_number)
1832 end
1833 end
1834
1835
1836 process_class_syntax (s: CL_SYNTAX_STONE) is
1837 -- Process class syntax.
1838 local
1839 cl_stone: CLASSC_STONE
1840 do
1841 -- call set_stone to ensure the proper class is displayed
1842 create cl_stone.make (s.e_class)
1843 set_stone (cl_stone)
1844 editor_tool.text_area.deselect_all
1845 editor_tool.text_area.highlight_when_ready (s.line, s.line)
1846 end
1847
1848 refresh is
1849 -- Synchronize clickable elements with text, if possible.
1850 do
1851 --| FIXME ARNAUD
1852 -- synchronise_stone
1853 --| END FIXME
1854 --| FIXME XR: Refresh current display in the editor.
1855 editor_tool.text_area.update_click_list (False)
1856 update_save_symbol
1857 address_manager.refresh
1858 -- The cluster manager should already be refreshed by the window manager.
1859 -- cluster_manager.refresh
1860 -- context_tool.refresh
1861 end
1862
1863 quick_refresh is
1864 -- Redraw the main editor's drawing area.
1865 do
1866 editor_tool.text_area.refresh
1867 context_tool.quick_refresh
1868 end
1869
1870 set_default_format is
1871 -- Default format of windows.
1872 --| FIXME ARNAUD: To be implemented.
1873 -- local
1874 -- f: EB_FORMATTER
1875 do
1876 -- if stone /= Void then
1877 -- if stone.class_i.hide_implementation then
1878 -- f := format_list.precompiled_default_format
1879 -- else
1880 -- f := format_list.default_format
1881 -- end
1882 -- else
1883 -- f := format_list.default_format
1884 -- end
1885 -- set_last_format (f)
1886 --| END FIXME
1887 end
1888
1889 feature -- Resource Update
1890
1891 update is
1892 -- Update Current with the registered resources.
1893 do
1894 lock_update
1895 -- Show/hide general toolbar
1896 if preferences.development_window_data.show_general_toolbar then
1897 show_general_toolbar_command.enable_visible
1898 else
1899 show_general_toolbar_command.disable_visible
1900 end
1901
1902 -- Show/hide address toolbar
1903 if preferences.development_window_data.show_address_toolbar then
1904 show_address_toolbar_command.enable_visible
1905 else
1906 show_address_toolbar_command.disable_visible
1907 end
1908
1909 -- Show/hide project toolbar
1910 if preferences.development_window_data.show_project_toolbar then
1911 show_project_toolbar_command.enable_visible
1912 else
1913 show_project_toolbar_command.disable_visible
1914 end
1915
1916 left_panel.load_from_resource (preferences.development_window_data.left_panel_layout)
1917 right_panel.load_from_resource (preferences.development_window_data.right_panel_layout)
1918 splitter_position := preferences.development_window_data.left_panel_width
1919 update_splitters
1920 unlock_update
1921 end
1922
1923 update_splitters is
1924 -- Refresh the position of the splitter on screen according to
1925 -- our internal values.
1926 do
1927 -- Set the interior layout
1928 if panel.full then
1929 panel.set_split_position (splitter_position.max (panel.minimum_split_position))
1930 end
1931 end
1932
1933 register is
1934 -- Register to preferences we want notification of.
1935 do
1936 end
1937
1938 unregister is
1939 -- unregister to preferences we want notification of.
1940 do
1941 end
1942
1943 reset is
1944 -- Reset the window contents
1945 do
1946 Precursor
1947 address_manager.reset
1948
1949 --| FIXME ARNAUD, multiformat not yet implemented.
1950 -- format_list.enable_imp_formats_sensitive
1951 --| END FIXME
1952 end
1953
1954 rebuild_tools_menu is
1955 -- Refresh the list of external commands.
1956 local
1957 ms: LIST [EB_COMMAND_MENU_ITEM]
1958 do
1959 -- Remove all the external commands, which are at the end of the menu.
1960 from
1961 tools_menu.go_i_th (tools_menu.count + 1 - number_of_displayed_external_commands)
1962 until
1963 tools_menu.after
1964 loop
1965 tools_menu.remove
1966 end
1967 ms := Edit_external_commands_cmd.menus
1968 number_of_displayed_external_commands := ms.count
1969 from
1970 ms.start
1971 until
1972 ms.after
1973 loop
1974 tools_menu.extend (ms.item)
1975 add_recyclable (ms.item)
1976 ms.forth
1977 end
1978 end
1979
1980 syntax_is_correct: BOOLEAN is
1981 -- file was successfully parsed.
1982 do
1983 Result := editor_tool.text_area.syntax_is_correct
1984 end
1985
1986 on_project_created is
1987 -- Inform tools that the current project has been loaded or re-loaded.
1988 do
1989 build_menu_bar
1990 enable_commands_on_project_created
1991 context_tool.on_project_created
1992 address_manager.on_project_created
1993 if has_dll_generation then
1994 show_dynamic_lib_tool.enable_sensitive
1995 end
1996 if has_profiler then
1997 show_profiler.enable_sensitive
1998 end
1999 end
2000
2001 on_project_loaded is
2002 -- Inform tools that the current project has been loaded or re-loaded.
2003 do
2004 -- cluster_manager.on_project_loaded
2005 enable_commands_on_project_loaded
2006 cluster_tool.on_project_loaded
2007 context_tool.on_project_loaded
2008 end
2009
2010 on_project_unloaded is
2011 -- Inform tools that the current project will soon been unloaded.
2012 do
2013 -- cluster_manager.on_project_unloaded
2014 disable_commands_on_project_unloaded
2015 cluster_tool.on_project_unloaded
2016 context_tool.on_project_unloaded
2017 address_manager.on_project_unloaded
2018 build_menu_bar
2019 if has_dll_generation then
2020 show_dynamic_lib_tool.disable_sensitive
2021 end
2022 if has_profiler then
2023 show_profiler.disable_sensitive
2024 end
2025 end
2026
2027 save_before_compiling is
2028 -- save the text but do not update clickable positions
2029 do
2030 save_only := True
2031 save_text
2032 end
2033
2034 perform_check_before_save is
2035 -- Perform any pre-save operations/checks
2036 local
2037 dial: EV_CONFIRMATION_DIALOG
2038 do
2039 debug ("EDITOR")
2040 if editor_tool.text_area.current_text /= Void and then changed then
2041 io.error.put_string ("%N Warning: Attempting to save a non editable format%N")
2042 end
2043 end
2044 if changed then
2045 editor_tool.text_area.strip_unwanted_indentation
2046 end
2047 if editor_tool.text_area.open_backup then
2048 create dial.make_with_text(Warning_messages.w_save_backup)
2049 dial.set_buttons_and_actions(<<"Continue", "Cancel">>, <<agent continue_save, agent cancel_save>>)
2050 dial.set_default_push_button(dial.button("Continue"))
2051 dial.set_default_cancel_button(dial.button("Cancel"))
2052 dial.set_title ("Save Backup")
2053 dial.show_modal_to_window (window)
2054 else
2055 check_passed := True
2056 end
2057 end
2058
2059 continue_save is
2060 -- continue saving
2061 do
2062 check_passed := True
2063 end
2064
2065 cancel_save is
2066 -- cancel saving
2067 do
2068 check_passed := False
2069 end
2070
2071 process is
2072 -- process the user entry in the address bar
2073 do
2074 save_canceled := False
2075 end
2076
2077 on_text_saved is
2078 -- Notify the editor that the text has been saved
2079 local
2080 str: STRING
2081 do
2082 Precursor
2083 editor_tool.on_text_saved
2084 text_saved := True
2085 if not save_only then
2086 editor_tool.text_area.update_click_list (True)
2087 end
2088 save_only := False
2089 str := title.twin
2090 if str @ 1 = '*' then
2091 str.keep_tail (str.count - 2)
2092 set_title (str)
2093 end
2094 update_formatters
2095 if editor_tool.text_area.syntax_is_correct then
2096 status_bar.display_message ("")
2097 else
2098 status_bar.display_message (Interface_names.L_syntax_error)
2099 end
2100 text_edited := False
2101 end
2102
2103 save_and (an_action: PROCEDURE [ANY, TUPLE]) is
2104 local
2105 save_dialog: EB_CONFIRM_SAVE_DIALOG
2106 do
2107 save_canceled := True
2108 text_saved := False
2109 create save_dialog.make_and_launch (Current,Current)
2110 if not save_canceled and then syntax_is_correct then
2111 an_action.call(Void)
2112 end
2113 end
2114
2115 feature -- Window management
2116
2117 show_window is
2118 -- Show the window
2119 do
2120 show
2121 end
2122
2123 raise_window is
2124 -- Show the window and set the focus to it.
2125 do
2126 show
2127 --| FIXME, set the focus.
2128 end
2129
2130 hide_window is
2131 -- Hide the window
2132 do
2133 hide
2134 end
2135
2136 destroy_window is
2137 -- Destroy the window.
2138 do
2139 destroy
2140 end
2141
2142 give_focus is
2143 -- Give the focus to the address manager.
2144 do
2145 address_manager.set_focus
2146 end
2147
2148 save_layout is
2149 -- Store layout of `current'.
2150 do
2151 -- Now save the windows's layout, but only if the
2152 -- debugger is not displayed in `Current'. By saving the layout,
2153 -- we ensure that future windows may use exactly the same layout.
2154 -- If the debugger is displayed, the previopus layout is already saved,
2155 -- and this is the one that must be used, as only one debugger is ever displayed.
2156 if (Application.is_running and debugger_manager.debugging_window /= Current) or not application.is_running then
2157 preferences.development_window_data.save_left_panel_layout (left_panel.save_to_resource)
2158 preferences.development_window_data.save_right_panel_layout (right_panel.save_to_resource)
2159 preferences.development_window_data.save_left_panel_width (panel.split_position)
2160 -- Save width & height.
2161 preferences.development_window_data.save_size (window.width, window.height, window.is_maximized)
2162 end
2163 preferences.development_window_data.save_search_tool_options (search_tool)
2164 -- Commit saves
2165 -- save_resources
2166 end
2167
2168 feature -- Tools & Controls
2169
2170 editor_tool: EB_EDITOR_TOOL
2171
2172 favorites_tool: EB_FAVORITES_TOOL
2173
2174 cluster_tool: EB_CLUSTER_TOOL
2175
2176 search_tool: EB_SEARCH_TOOL
2177
2178 features_tool: EB_FEATURES_TOOL
2179
2180 windows_tool: EB_WINDOWS_TOOL
2181
2182 context_tool: EB_CONTEXT_TOOL
2183 -- Context explorer for current class and system.
2184
2185 address_manager: EB_ADDRESS_MANAGER
2186 -- Text field in the toolbar
2187 -- Allow user to enter the name
2188 -- of the class he wants to edit.
2189
2190 project_manager: EB_PROJECT_MANAGER is
2191 -- Project manager associated to the project the user is working on.
2192 do
2193 Result := Eiffel_project.manager
2194 end
2195
2196 managed_class_formatters: ARRAYED_LIST [EB_CLASS_INFO_FORMATTER]
2197 -- All formatters that operate on a class.
2198
2199 managed_feature_formatters: ARRAYED_LIST [EB_FEATURE_INFO_FORMATTER]
2200 -- All formatters that operate on a class.
2201
2202 managed_main_formatters: ARRAYED_LIST [EB_CLASS_TEXT_FORMATTER]
2203 -- All formatters that can be displayed in the main editor frame.
2204
2205 unified_stone: BOOLEAN
2206 -- Is the stone common with the context tool or not?
2207
2208 arguments_dialog: EB_ARGUMENT_DIALOG
2209 -- The arguments dialog for current, if any
2210
2211 goto_dialog: EB_GOTO_DIALOG
2212 -- The goto dialog for line number access
2213
2214 feature -- Multiple editor management
2215
2216 add_editor_to_list (an_editor: EB_EDITOR) is
2217 -- adds `an_editor' to `editors'
2218 do
2219 editors.extend (an_editor)
2220 end
2221
2222 current_editor: EB_EDITOR is
2223 -- current editor, if none, main editor
2224 do
2225 if current_editor_index /= 0 then
2226 Result := editors @ current_editor_index
2227 else
2228 Result := editors.first
2229 end
2230 end
2231
2232 set_current_editor (an_editor: EB_EDITOR) is
2233 -- set `an_editor' as main editor
2234 local
2235 old_index: INTEGER
2236 new_index: INTEGER
2237 do
2238 old_index := current_editor_index
2239 new_index := editors.index_of (an_editor, 1)
2240 if
2241 editors.valid_index (new_index) and
2242 old_index /= new_index
2243 then
2244 current_editor_index := new_index
2245 from
2246 editors.start
2247 until
2248 editors.after
2249 loop
2250 if editors.index /= current_editor_index and then editors.item.has_selection then
2251 editors.item.disable_selection
2252 end
2253 editors.forth
2254 end
2255 update_paste_cmd
2256 -- Last thing, update the menu entry for the formatting marks.
2257 if current_editor.view_invisible_symbols then
2258 formatting_marks_command_menu_item.set_text (Interface_names.m_hide_formatting_marks)
2259 else
2260 formatting_marks_command_menu_item.set_text(Interface_names.m_show_formatting_marks)
2261 end
2262 command_controller.set_current_editor (an_editor)
2263 end
2264 end
2265
2266 update_paste_cmd is
2267 -- Update `editor_paste_cmd'. To be performed when an editor grabs the focus.
2268 do
2269 if
2270 not current_editor.is_empty and then
2271 current_editor.is_editable and then
2272 current_editor.clipboard.has_text
2273 then
2274 editor_paste_cmd.enable_sensitive
2275 else
2276 editor_paste_cmd.disable_sensitive
2277 end
2278 end
2279
2280 feature {NONE} -- Multiple editor management
2281
2282 editors: ARRAYED_LIST [EB_EDITOR]
2283 -- editor contained in `Current'
2284
2285 current_editor_index: INTEGER
2286 -- Index in `editors' of the editor that has the focus.
2287
2288 feature {EB_FEATURES_TOOL, EB_FEATURES_TREE, DOTNET_CLASS_AS, DOTNET_CLASS_CONTEXT} -- Feature Clauses
2289
2290 set_feature_clauses (a_features: ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]]; a_type: STRING) is
2291 -- Set 'features' to 'a_features' and store in hash table with key 'a_type' denoting name of consumed
2292 -- type pertinent to 'a_features'.
2293 require
2294 a_features_not_void: a_features /= Void
2295 do
2296 if feature_clauses = Void then
2297 create feature_clauses.make (5)
2298 end
2299 feature_clauses.put (a_features, a_type)
2300 end
2301
2302 get_feature_clauses (a_type: STRING): ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]] is
2303 -- Get list of feature clauses relevant to .NET type with name 'a_type'.
2304 require
2305 a_type_not_void: a_type /= Void
2306 has_type_clauses: feature_clauses.has (a_type)
2307 do
2308 Result := feature_clauses.item (a_type)
2309 ensure
2310 result_not_void: Result /= Void
2311 end
2312
2313 feature_clauses: HASH_TABLE [ARRAYED_LIST [DOTNET_FEATURE_CLAUSE_AS [CONSUMED_ENTITY]], STRING]
2314 -- List of features clauses for Current window hashed by the .NET name of the consumed_type.
2315
2316 feature_positions: HASH_TABLE [INTEGER, E_FEATURE]
2317 -- Features indexed by line position in class text (for .NET features).
2318
2319 feature {EB_WINDOW_MANAGER} -- Window management / Implementation
2320
2321 destroy_imp is
2322 -- Destroy window.
2323 do
2324 -- To avoid reentrance
2325 if not is_destroying then
2326 is_destroying := True
2327 -- If a launched application is still running, kill it.
2328 if Application.is_running and then debugger_manager.debugging_window = Current then
2329 Application.kill
2330 else
2331 preferences.development_window_data.save_left_panel_layout (left_panel.save_to_resource)
2332 preferences.development_window_data.save_right_panel_layout (right_panel.save_to_resource)
2333 end
2334 preferences.development_window_data.save_left_panel_width (panel.split_position)
2335 -- Save width & height.
2336 preferences.development_window_data.save_size (window.width, window.height, window.is_maximized)
2337 left_panel.wipe_out
2338 right_panel.wipe_out
2339 preferences.development_window_data.save_search_tool_options (search_tool)
2340 hide
2341
2342 -- Commit saves
2343 -- save_resources
2344
2345 toolbars_area.wipe_out
2346 address_manager.recycle
2347 project_customizable_toolbar.recycle
2348 Precursor {EB_TOOL_MANAGER}
2349
2350 managed_class_formatters.wipe_out
2351 managed_feature_formatters.wipe_out
2352 managed_main_formatters.wipe_out
2353 toolbarable_commands.wipe_out
2354 editors.wipe_out
2355 stone := Void
2356 end
2357 end
2358
2359 feature {NONE} -- Implementation
2360
2361 set_stone_after_check (a_stone: STONE) is
2362 local
2363 old_stone: STONE
2364 new_class_stone: CLASSI_STONE
2365 old_class_stone: CLASSI_STONE
2366 conv_classc: CLASSC_STONE
2367 conv_brkstone: BREAKABLE_STONE
2368 cluster_st: CLUSTER_STONE
2369 feature_stone: FEATURE_STONE
2370 conv_ferrst: FEATURE_ERROR_STONE
2371
2372 ef_stone: EXTERNAL_FILE_STONE
2373 f: FILE
2374
2375 l_format_context: FORMAT_CONTEXT
2376 l_indexes: EIFFEL_LIST [INDEX_AS]
2377 conv_errst: ERROR_STONE
2378 cl_syntax_stone: CL_SYNTAX_STONE
2379 error_line: INTEGER
2380 class_file: RAW_FILE
2381 class_text_exists: BOOLEAN
2382 same_class: BOOLEAN
2383 test_stone: CLASSI_STONE
2384 conv_ace: ACE_SYNTAX_STONE
2385 externali: EXTERNAL_CLASS_I
2386 l_reader: EIFFEL_XML_DESERIALIZER
2387 external_cons: CONSUMED_TYPE
2388 str: STRING
2389 dotnet_class: BOOLEAN
2390 l_short_formatter: EB_SHORT_FORMATTER
2391 l_flat_formatter: EB_FLAT_SHORT_FORMATTER
2392 do
2393 -- the text does not change if the text was saved with syntax errors
2394 cur_wid := window
2395 if cur_wid = Void then
2396 --| Do nothing.
2397 else
2398 if old_cur = Void then
2399 old_cur := cur_wid.pointer_style
2400 end
2401 -- cur_wid.enable_capture
2402 cur_wid.set_pointer_style (Wait_cursor)
2403 end
2404
2405 conv_brkstone ?= a_stone
2406 conv_errst ?= a_stone
2407 conv_ace ?= a_stone
2408 ef_stone ?= a_stone
2409 if conv_brkstone /= Void then
2410 if Application.is_breakpoint_enabled (conv_brkstone.routine, conv_brkstone.index) then
2411 Application.remove_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2412 else
2413 Application.set_breakpoint (conv_brkstone.routine, conv_brkstone.index)
2414 end
2415 output_manager.display_stop_points
2416 window_manager.quick_refresh_all
2417 elseif conv_errst /= Void then
2418 display_error_help_cmd.execute_with_stone (conv_errst)
2419 elseif conv_ace /= Void then
2420 --| FIXME XR: What should we do?!
2421 elseif ef_stone /= Void then
2422 f := ef_stone.file
2423 f.make_open_read (f.name)
2424 f.read_stream (f.count)
2425 f.close
2426 editor_tool.text_area.load_text (f.last_string)
2427 else
2428 -- Remember previous stone.
2429 old_stone := stone
2430 old_class_stone ?= stone
2431
2432 -- New stone properties
2433 new_class_stone ?= a_stone
2434
2435 -- Set the stone.
2436 old_set_stone (a_stone)
2437 cluster_st ?= a_stone
2438
2439 new_feature_cmd.disable_sensitive
2440 toggle_feature_alias_cmd.disable_sensitive
2441 toggle_feature_signature_cmd.disable_sensitive
2442
2443 -- We update the state of the `Add to Favorites' command.
2444 if new_class_stone /= Void then
2445 favorites_menu.first.enable_sensitive
2446 else
2447 favorites_menu.first.disable_sensitive
2448 end
2449
2450 -- Update the history.
2451 if
2452 new_class_stone /= Void
2453 then
2454 history_manager.extend (new_class_stone)
2455 elseif
2456 cluster_st /= Void
2457 then
2458 history_manager.extend (cluster_st)
2459 end
2460 -- Update the address manager if needed.
2461 address_manager.refresh
2462 if new_class_stone /= Void then
2463 -- class stone was dropped
2464 create class_file.make (new_class_stone.class_i.file_name)
2465 class_text_exists := class_file.exists
2466 feature_stone ?= a_stone
2467 --| We have to create a classi_stone to check whether the stones are really similar.
2468 --| Otherwise a redefinition of same_as may be called.
2469 create test_stone.make (new_class_stone.class_i)
2470 if test_stone.same_as (old_class_stone) then
2471 same_class := True
2472 end
2473 if not feature_stone_already_processed then
2474 if same_class and then text_saved then
2475 -- nothing changed in the editor
2476 -- we only have to update click_list
2477 if editor_tool.text_area.is_editable then
2478 editor_tool.text_area.update_click_list (False)
2479 end
2480 else
2481 if changed then
2482 -- user has already chosen not to save the file
2483 -- do not ask again
2484 Feature_positions.wipe_out
2485 editor_tool.text_area.no_save_before_next_load
2486 end
2487 end
2488 end
2489
2490 conv_classc ?= new_class_stone
2491 if conv_classc = Void or else
2492 conv_classc.e_class.is_external or else
2493 feature_stone /= Void and not
2494 feature_stone_already_processed and not
2495 (same_class and context_tool.sending_stone) then
2496 -- If a classi_stone or a feature_stone or a external call
2497 -- has been dropped, check to see if a .NET class.
2498 if class_text_exists then
2499 if new_class_stone.class_i.is_external_class then
2500 create l_reader
2501 externali ?= new_class_stone.class_i
2502 external_cons ?= l_reader.new_object_from_file (externali.file_name)
2503 if external_cons /= Void then
2504 -- A .NET class.
2505 dotnet_class := True
2506 l_short_formatter ?= managed_main_formatters.i_th (4)
2507 l_flat_formatter ?= managed_main_formatters.i_th (5)
2508 if l_short_formatter /= Void then
2509 l_short_formatter.set_dotnet_mode (True)
2510 end
2511 if l_flat_formatter /= Void then
2512 l_flat_formatter.set_dotnet_mode (True)
2513 end
2514 end
2515 else
2516 managed_main_formatters.first.set_stone (new_class_stone)
2517 managed_main_formatters.first.execute
2518 end
2519 else
2520 editor_tool.text_area.clear_window
2521 editor_tool.text_area.display_message (
2522 Warning_messages.w_file_not_exist (
2523 new_class_stone.class_i.file_name))
2524 end
2525 end
2526 if conv_classc = Void then
2527 --| The dropped class is not compiled.
2528 --| Display only the textual formatter.
2529 if dotnet_class then
2530 managed_main_formatters.i_th (4).set_stone (new_class_stone)
2531 managed_main_formatters.i_th (5).set_stone (new_class_stone)
2532 managed_main_formatters.i_th (4).execute
2533 end
2534 address_manager.disable_formatters
2535 else
2536 --| We have a compiled class.
2537 if
2538 class_text_exists and then
2539 Eiffel_project.Workbench.last_reached_degree <= 2
2540 then
2541 new_feature_cmd.enable_sensitive
2542 toggle_feature_alias_cmd.enable_sensitive
2543 toggle_feature_signature_cmd.enable_sensitive
2544 end
2545
2546 --address_manager.enable_formatters
2547 update_formatters
2548 if not class_text_exists then
2549 --| Disable the textual formatter.
2550 managed_main_formatters.first.disable_sensitive
2551 from
2552 managed_main_formatters.start
2553 until
2554 managed_main_formatters.after
2555 loop
2556 managed_main_formatters.item.set_stone (new_class_stone)
2557 managed_main_formatters.forth
2558 end
2559 managed_main_formatters.i_th (2).execute
2560 else
2561 if not changed or not same_class then
2562 --| Enable all formatters.
2563 if
2564 not feature_stone_already_processed or
2565 not managed_main_formatters.first.selected
2566 then
2567 from
2568 managed_main_formatters.start
2569 until
2570 managed_main_formatters.after
2571 loop
2572 managed_main_formatters.item.set_stone (new_class_stone)
2573 managed_main_formatters.forth
2574 end
2575 end
2576 else
2577 address_manager.disable_formatters
2578 from
2579 managed_main_formatters.start
2580 until
2581 managed_main_formatters.after
2582 loop
2583 managed_main_formatters.item.set_stone (new_class_stone)
2584 managed_main_formatters.forth
2585 end
2586 end
2587 end
2588 end
2589 else
2590 -- not a class text : cannot be edited
2591 editor_tool.text_area.disable_editable
2592 address_manager.disable_formatters
2593
2594 --| Disable all formatters.
2595 from
2596 managed_main_formatters.start
2597 until
2598 managed_main_formatters.after
2599 loop
2600 managed_main_formatters.item.set_stone (Void)
2601 managed_main_formatters.forth
2602 end
2603 if cluster_st /= Void then
2604 --| FIXME XR: Really manage cluster display in the main editor
2605 create l_format_context.make_for_case
2606 l_format_context.put_text_item (ti_indexing_keyword)
2607 l_format_context.put_new_line
2608 l_format_context.indent
2609 l_format_context.put_text_item (create {INDEXING_TAG_TEXT}.make ("cluster"))
2610 l_format_context.put_text_item_without_tabs (ti_colon)
2611 l_format_context.put_space
2612 l_format_context.put_string ("%"" + cluster_st.cluster_i.cluster_name + "%"")
2613 l_format_context.put_new_line
2614 l_format_context.put_text_item (create {INDEXING_TAG_TEXT}.make ("cluster_path"))
2615 l_format_context.put_text_item_without_tabs (ti_colon)
2616 l_format_context.put_space
2617 l_format_context.put_string ("%"" + cluster_st.cluster_i.path + "%"")
2618 l_format_context.put_new_line
2619 l_indexes := cluster_st.cluster_i.indexes
2620 if l_indexes /= Void then
2621 l_format_context.set_new_line_between_tokens
2622 l_format_context.format_ast (l_indexes)
2623 l_format_context.exdent
2624 end
2625 l_format_context.put_new_line
2626 editor_tool.text_area.process_text (l_format_context.text)
2627 --| END FIXME
2628 end
2629 end
2630 if class_text_exists then
2631 if feature_stone /= Void and not feature_stone_already_processed and not (same_class and context_tool.sending_stone) then
2632 conv_ferrst ?= feature_stone
2633 if conv_ferrst /= Void then
2634 error_line := conv_ferrst.line_number
2635 else
2636 -- if a feature_stone has been dropped
2637 -- scroll to the corresponding feature in the basic text format
2638 if not during_synchronization then
2639 scroll_to_feature (feature_stone.e_feature, new_class_stone.class_i)
2640 end
2641 end
2642 else
2643 cl_syntax_stone ?= a_stone
2644 if cl_syntax_stone /= Void then
2645 error_line := cl_syntax_stone.line
2646 end
2647 end
2648 if error_line > 0 then
2649 -- Scroll to the line of the error.
2650 editor_tool.text_area.display_line_when_ready (error_line, True)
2651 end
2652 end
2653 -- Update the title of the window
2654 if a_stone /= Void then
2655 if changed then
2656 str := a_stone.header.twin
2657 str.prepend ("* ")
2658 set_title (str)
2659 else
2660 set_title (a_stone.header)
2661 end
2662 else
2663 set_title (Interface_names.t_empty_development_window)
2664 end
2665
2666 -- Refresh the tools.
2667 features_tool.set_stone (a_stone)
2668 cluster_tool.set_stone (a_stone)
2669 -- Update the context tool.
2670 if unified_stone then
2671 context_tool.set_stone (a_stone)
2672 end
2673
2674 end
2675 if
2676 stone /= Void and then
2677 not unified_stone
2678 then
2679 send_stone_to_context_cmd.enable_sensitive
2680 else
2681 send_stone_to_context_cmd.disable_sensitive
2682 end
2683 if cur_wid = Void then
2684 --| Do nothing.
2685 else
2686 cur_wid.set_pointer_style (old_cur)
2687 old_cur := Void
2688 -- cur_wid.disable_capture
2689 cur_wid := Void
2690 end
2691 end
2692
2693 scroll_to_feature (feat_as: E_FEATURE; displayed_class: CLASS_I) is
2694 -- highlight the feature correspnding to `feat_as' in the class represented by `displayed_class'
2695 require
2696 class_is_not_void: displayed_class /= Void
2697 feat_as_is_not_void: feat_as /= Void
2698 local
2699 begin_index, offset: INTEGER
2700 tmp_text: STRING
2701 do
2702 if not feat_as.is_il_external then
2703 if feat_as.ast /= Void then
2704 begin_index := feat_as.ast.start_position
2705 if platform_constants.is_windows then
2706 tmp_text := displayed_class.text.substring (1, begin_index)
2707 offset := tmp_text.occurrences('%R')
2708 end
2709 editor_tool.text_area.scroll_to_when_ready (begin_index.item - offset)
2710 end
2711 else
2712 -- FIXME NC: Doesn't work properly for .NET features
2713 -- .NET formatted feature.
2714 begin_index := feature_positions.item (feat_as)
2715 if platform_constants.is_windows then
2716 tmp_text := displayed_class.text.substring (1, begin_index)
2717 offset := tmp_text.occurrences('%N')
2718 end
2719 editor_tool.text_area.scroll_to_when_ready (begin_index // 2) -- - offset)
2720 end
2721 end
2722
2723 check_passed: BOOLEAN
2724
2725 save_canceled: BOOLEAN
2726 -- did user cancel save ?
2727
2728 save_only: BOOLEAN
2729 -- skip parse and update after save ?
2730
2731 text_saved: BOOLEAN
2732 -- has the user chosen to save the file
2733
2734 is_destroying: BOOLEAN
2735 -- Is `current' being currently destroyed?
2736
2737 feature_stone_already_processed: BOOLEAN
2738 -- Is the processed stone a feature stone and has it
2739 -- been already processed by the editor ?
2740
2741 feature {NONE} -- Implementation
2742
2743 update_save_symbol is
2744 do
2745 Precursor {EB_FILEABLE}
2746 if changed then
2747 save_cmd.enable_sensitive
2748 address_manager.disable_formatters
2749 else
2750 save_cmd.disable_sensitive
2751 update_formatters
2752 end
2753 if is_empty then
2754 print_cmd.disable_sensitive
2755 save_as_cmd.disable_sensitive
2756 else
2757 print_cmd.enable_sensitive
2758 save_as_cmd.enable_sensitive
2759 end
2760 end
2761
2762 is_stone_external: BOOLEAN
2763 -- Does 'stone' contain a .NET consumed type?
2764
2765 update_formatters is
2766 -- Give a correct sensitivity to formatters.
2767 local
2768 cist: CLASSI_STONE
2769 cst: CLASSC_STONE
2770 type_changed: BOOLEAN
2771 do
2772 cst ?= stone
2773 cist ?= stone
2774 -- Check to if formatting context has changed.
2775 if cst /= Void then
2776 type_changed := (cst.e_class.is_true_external and not is_stone_external) or
2777 (not cst.e_class.is_true_external and is_stone_external)
2778 elseif cist /= Void then
2779 type_changed := (cist.class_i.is_external_class and not is_stone_external) or
2780 (not cist.class_i.is_external_class and is_stone_external)
2781 end
2782
2783 if type_changed then
2784 -- Toggle stone flag.
2785 is_stone_external := not is_stone_external
2786 end
2787
2788 if cst /= Void then
2789 address_manager.enable_formatters
2790 if is_stone_external then
2791 -- Change formatters to .NET sensitivity (from normal).
2792 enable_dotnet_formatters
2793 if type_changed then
2794 managed_main_formatters.i_th (4).enable_select
2795 end
2796 else
2797 if changed then
2798 address_manager.disable_formatters
2799 else
2800 --managed_main_formatters.first.disable_sensitive
2801 end
2802 end
2803 elseif cist /= Void and is_stone_external then
2804 -- Change formatters to .NET sensitivity (from normal).
2805 enable_dotnet_formatters
2806 if type_changed then
2807 managed_main_formatters.i_th (4).enable_select
2808 end
2809 else
2810 address_manager.disable_formatters
2811 if cist /= stone then
2812 managed_main_formatters.first.execute
2813 end
2814 end
2815 end
2816
2817 enable_dotnet_formatters is
2818 -- Enable only the .NET class text formatters.
2819 do
2820 from
2821 managed_main_formatters.start
2822 until
2823 managed_main_formatters.after
2824 loop
2825 if managed_main_formatters.item.is_dotnet_formatter then
2826 managed_main_formatters.item.enable_sensitive
2827 else
2828 managed_main_formatters.item.disable_sensitive
2829 end
2830 managed_main_formatters.forth
2831 end
2832 end
2833
2834
2835 on_text_reset is
2836 -- The main editor has just been wiped out
2837 -- before loading a new file.
2838 local
2839 str: STRING
2840 do
2841 str := title.twin
2842 if str @ 1 = '*' then
2843 str.keep_tail (str.count - 2)
2844 set_title (str)
2845 end
2846 address_manager.disable_formatters
2847 status_bar.display_message ("")
2848 status_bar.remove_cursor_position
2849 text_edited := False
2850 end
2851
2852 on_cursor_moved is
2853 -- The cursor has moved, reflect the change in the status bar.
2854 do
2855 refresh_cursor_position
2856 end
2857
2858 on_text_fully_loaded is
2859 -- The main editor has just been reloaded.
2860 do
2861 update_paste_cmd
2862 update_formatters
2863 if editor_tool.text_area.syntax_is_correct then
2864 status_bar.display_message ("")
2865 else
2866 status_bar.display_message (Interface_names.L_syntax_error)
2867 end
2868 refresh_cursor_position
2869 text_edited := False
2870 end
2871
2872 on_text_back_to_its_last_saved_state is
2873 local
2874 str: STRING
2875 do
2876 str := title.twin
2877 if str @ 1 = '*' then
2878 str.keep_tail (str.count - 2)
2879 set_title (str)
2880 end
2881 update_formatters
2882 text_edited := False
2883 end
2884
2885 text_edited: BOOLEAN
2886 -- Do we know that the text was edited?
2887 -- If so, no need to update the display each time it is edited.
2888
2889 on_text_edited (unused: BOOLEAN) is
2890 -- The text in the editor is modified, add the '*' in the title.
2891 -- Gray out the formatters.
2892 local
2893 str: STRING
2894 cst: CLASSI_STONE
2895 do
2896 if not text_edited then
2897 str := title.twin
2898 if str @ 1 /= '*' then
2899 str.prepend ("* ")
2900 set_title (str)
2901 end
2902 address_manager.disable_formatters
2903 cst ?= stone
2904 if cst /= Void then
2905 Eiffel_project.Manager.class_is_edited (cst.class_i)
2906 end
2907 text_edited := True
2908 end
2909 status_bar.display_message ("")
2910 end
2911
2912 on_back is
2913 -- User pressed Alt+left.
2914 -- Go back in the history (or the context history).
2915 do
2916 if context_tool_has_focus then
2917 if context_tool.history_manager.is_back_possible then
2918 context_tool.history_manager.back_command.execute
2919 end
2920 elseif history_manager.is_back_possible then
2921 history_manager.back_command.execute
2922 end
2923 end
2924
2925 on_forth is
2926 -- User pressed Alt+right.
2927 -- Go forth in the history (or the context history).
2928 do
2929 if context_tool_has_focus then
2930 if context_tool.history_manager.is_forth_possible then
2931 context_tool.history_manager.forth_command.execute
2932 editor_tool.text_area.editor_viewport.enable_sensitive
2933 editor_tool.text_area.set_focus
2934 end
2935 elseif history_manager.is_forth_possible then
2936 history_manager.forth_command.execute
2937 editor_tool.text_area.editor_viewport.enable_sensitive
2938 editor_tool.text_area.set_focus
2939 end
2940 end
2941
2942 context_tool_has_focus: BOOLEAN is
2943 -- Does the context tool or one of its children has the focus?
2944 local
2945 fw: EV_WIDGET
2946 cont: EV_CONTAINER
2947 wid: EV_WIDGET
2948 do
2949 fw := (create {EV_ENVIRONMENT}).application.focused_widget
2950 wid := context_tool.explorer_bar_item.widget
2951 if wid = fw then
2952 Result := True
2953 elseif fw = Void then
2954 Result := False
2955 else
2956 from
2957 cont := fw.parent
2958 until
2959 cont = wid or cont = Void
2960 loop
2961 cont := cont.parent
2962 end
2963 if cont = wid then
2964 Result := True
2965 end
2966 end
2967 end
2968
2969 saved_cursor: CURSOR
2970 -- Saved cursor position for displaying the stack.
2971
2972 can_drop (st: ANY): BOOLEAN is
2973 -- Can the user drop the stone `st'?
2974 local
2975 conv_ace: ACE_SYNTAX_STONE
2976 do
2977 conv_ace ?= st
2978 Result := conv_ace = Void
2979 end
2980
2981 quick_refresh_on_class_drop (unused: CLASSI_STONE) is
2982 -- Quick refresh all windows.
2983 do
2984 window_manager.quick_refresh_all
2985 end
2986
2987 quick_refresh_on_brk_drop (unused: BREAKABLE_STONE) is
2988 -- Quick refresh all windows.
2989 do
2990 window_manager.quick_refresh_all
2991 end
2992
2993 send_stone_to_context is
2994 -- Send current stone to the context tool.
2995 -- Used by `send_stone_to_context_cmd'.
2996 do
2997 if stone /= Void then
2998 context_tool.set_stone (stone)
2999 end
3000 end
3001
3002 destroy is
3003 -- check if current text has been saved and destroy
3004 local
3005 dialog_w: EB_WARNING_DIALOG
3006 do
3007 if editor_tool /= Void and then editor_tool.text_area /= Void and then changed and then not confirmed then
3008 if Window_manager.development_windows_count > 1 then
3009 create dialog_w.make_with_text (Warning_messages.w_save_before_closing)
3010 dialog_w.set_buttons_and_actions (<<"Yes", "No", "Cancel">>, <<agent save_and_destroy, agent force_destroy, agent do_nothing>>)
3011 dialog_w.set_default_push_button (dialog_w.button("Yes"))
3012 dialog_w.set_default_cancel_button (dialog_w.button("Cancel"))
3013 dialog_w.show_modal_to_window (window)
3014 else
3015 -- We let the window manager handle the saving, along with other windows
3016 -- (not development windows)
3017 force_destroy
3018 end
3019 else
3020 Precursor {EB_TOOL_MANAGER}
3021 end
3022 end
3023
3024 save_and_destroy is
3025 do
3026 save_text
3027 destroy
3028 end
3029
3030 force_destroy is
3031 -- Destroy without asking.
3032 do
3033 confirmed := True
3034 destroy
3035 confirmed := False
3036 end
3037
3038 confirmed: BOOLEAN
3039 -- Did the user say he wanted to exit?
3040
3041 show_dynamic_library_dialog is
3042 -- Create a new dynamic library window and display it.
3043 do
3044 Window_manager.create_dynamic_lib_window
3045 end
3046
3047 recycle is
3048 -- Call the precursors.
3049 do
3050 Precursor {EB_TOOL_MANAGER}
3051 command_controller.recycle
3052 end
3053
3054 feature {NONE} -- Implementation: Editor commands
3055
3056 refresh_cursor_position is
3057 -- Display the current cursor position in the status bar.
3058 require
3059 text_loaded: not is_empty
3060 local
3061 l, c: INTEGER
3062 do
3063 l := editor_tool.text_area.cursor_y_position
3064 c := editor_tool.text_area.cursor_x_position
3065 status_bar.set_cursor_position (l, c)
3066 end
3067
3068 select_all is
3069 -- Select the whole text in the focused editor.
3070 do
3071 current_editor.select_all
3072 end
3073
3074 search is
3075 -- Search some text in the focused editor.
3076 local
3077 cv_ced: EB_CLICKABLE_EDITOR
3078 do
3079 cv_ced ?= current_editor
3080 if cv_ced /= Void then
3081 cv_ced.search
3082 end
3083 end
3084
3085 goto is
3086 -- Display a dialog to select a line to go to in the editor.
3087 local
3088 ed: EB_EDITOR
3089 do
3090 ed ?= current_editor
3091 if ed /= Void then
3092 create goto_dialog.make (ed)
3093 goto_dialog.show_modal_to_window (Current.window)
3094 end
3095 end
3096
3097 toggle_line_number_display is
3098 -- Toggle line number display on/off in editor
3099 local
3100 ed: EB_EDITOR
3101 do
3102 ed ?= current_editor
3103 if ed /= Void then
3104 ed.toggle_line_number_display
3105 end
3106 end
3107
3108 find_next is
3109 -- Find the next occurrence of the search text.
3110 local
3111 cv_ced: EB_CLICKABLE_EDITOR
3112 do
3113 if search_tool.currently_searched /= Void then
3114 cv_ced ?= current_editor
3115 if cv_ced /= Void then
3116 cv_ced.find_next
3117 end
3118 else
3119 search_tool.show_and_set_focus
3120 end
3121 end
3122
3123 find_previous is
3124 -- Find the previous occurrence of the search text.
3125 local
3126 cv_ced: EB_CLICKABLE_EDITOR
3127 do
3128 if search_tool.currently_searched /= Void then
3129 cv_ced ?= current_editor
3130 if cv_ced /= Void then
3131 cv_ced.find_previous
3132 end
3133 else
3134 search_tool.show_and_set_focus
3135 end
3136 end
3137
3138 find_selection is
3139 -- Find the next occurrence of the selection.
3140 local
3141 cv_ced: EB_CLICKABLE_EDITOR
3142 do
3143 cv_ced ?= current_editor
3144 if cv_ced /= Void then
3145 cv_ced.find_selection
3146 end
3147 end
3148
3149 cut_selection is
3150 -- Cut the selection in the current editor.
3151 do
3152 current_editor.cut_selection
3153 end
3154
3155 copy_selection is
3156 -- Cut the selection in the current editor.
3157 do
3158 current_editor.copy_selection
3159 end
3160
3161 toggle_formatting_marks is
3162 -- Show/Hide formatting marks in the editor and update related menu item.
3163 do
3164 current_editor.toggle_view_invisible_symbols
3165 if current_editor.view_invisible_symbols then
3166 formatting_marks_command_menu_item.set_text (Interface_names.m_hide_formatting_marks)
3167 else
3168 formatting_marks_command_menu_item.set_text(Interface_names.m_show_formatting_marks)
3169 end
3170 end
3171
3172 feature {NONE} -- Implementation / Menus
3173
3174 number_of_displayed_external_commands: INTEGER
3175 -- Number of external commands in the tools menu.
3176
3177 old_cur: EV_CURSOR
3178 -- Cursor saved while displaying the hourglass cursor.
3179
3180 cur_wid: EV_WIDGET
3181 -- Widget on which the hourglass cursor was set.
3182
3183 project_menu: EV_MENU
3184 -- Menu for entries relative to the Project.
3185
3186 recent_projects_menu: EB_RECENT_PROJECTS_MANAGER_MENU
3187 -- SubMenu for recent projects.
3188
3189 during_synchronization: BOOLEAN
3190 -- Are we during a resynchronization?
3191
3192 formatting_marks_command_menu_item: EB_COMMAND_MENU_ITEM
3193 -- Menu item used to shw/hide formatting marks.
3194
3195 undo_accelerator: EV_ACCELERATOR
3196 -- Accelerator for Ctrl+Z
3197
3198 redo_accelerator: EV_ACCELERATOR
3199 -- Accelerator for Ctrl+Y
3200
3201 feature {EB_TOOL} -- Implementation / Commands
3202
3203 shell_cmd: EB_OPEN_SHELL_COMMAND
3204 -- Command to use an external editor.
3205
3206 undo_cmd: EB_UNDO_COMMAND
3207 -- Command to undo in the editor.
3208
3209 redo_cmd: EB_REDO_COMMAND
3210 -- Command to redo in the editor.
3211
3212 editor_cut_cmd: EB_ON_SELECTION_COMMAND
3213 -- Command to cut text in the editor.
3214
3215 editor_copy_cmd: EB_ON_SELECTION_COMMAND
3216 -- Command to copy text in the editor.
3217
3218 editor_paste_cmd: EB_EDITOR_PASTE_COMMAND
3219 -- Command to paste text in the editor.
3220
3221 melt_cmd: EB_MELT_PROJECT_COMMAND
3222 -- Command to start compilation.
3223
3224 freeze_cmd: EB_FREEZE_PROJECT_COMMAND
3225 -- Command to Freeze the project.
3226
3227 finalize_cmd: EB_FINALIZE_PROJECT_COMMAND
3228 -- Command to Finalize the project.
3229
3230 c_workbench_compilation_cmd: EB_C_COMPILATION_COMMAND
3231 -- Command to compile the workbench C code.
3232
3233 c_finalized_compilation_cmd: EB_C_COMPILATION_COMMAND
3234 -- Command to compile the finalized C code.
3235
3236 new_cluster_cmd: EB_NEW_CLUSTER_COMMAND
3237 -- Command to create a new cluster.
3238
3239 new_class_cmd: EB_NEW_CLASS_COMMAND
3240 -- Command to create a new class.
3241
3242 new_feature_cmd: EB_NEW_FEATURE_COMMAND
3243 -- Command to execute the feature wizard.
3244
3245 toggle_feature_alias_cmd: EB_TOGGLE_FEATURE_ALIAS_COMMAND
3246 -- Show/Hide alias name of feature node in eb_feature_tool
3247
3248 toggle_feature_signature_cmd: EB_TOGGLE_FEATURE_SIGNATURE_COMMAND
3249 -- Show/Hide signature of feature node in eb_feature_tool
3250
3251 toggle_stone_cmd: EB_UNIFY_STONE_CMD
3252 -- Command to toggle between the stone management modes.
3253
3254 delete_class_cluster_cmd: EB_DELETE_CLASS_CLUSTER_COMMAND
3255 -- Command to remove a class or a cluster from the system
3256 -- (permanent deletion).
3257
3258 show_profiler: EB_SHOW_PROFILE_TOOL
3259 -- What allows us to display the profiler window.
3260
3261 toolbarable_commands: ARRAYED_LIST [EB_TOOLBARABLE_COMMAND]
3262 -- All commands that can be put in a toolbar.
3263
3264 command_controller: EB_EDITOR_COMMAND_CONTROLLER
3265 -- Object that takes care of updating the sensitivity of all editor commands.
3266
3267 save_as_cmd: EB_SAVE_FILE_AS_COMMAND
3268 -- Command to save a class with a different file name.
3269
3270 Edit_external_commands_cmd: EB_EXTERNAL_COMMANDS_EDITOR is
3271 -- Command that lets the user add new external commands to the tools menu.
3272 once
3273 create Result.make
3274 Result.enable_sensitive
3275 end
3276
3277 system_info_cmd: EB_STANDARD_CMD is
3278 -- Command to display information about the system (root class,...)
3279 do
3280 Result := debugger_manager.system_info_cmd
3281 end
3282
3283 display_error_help_cmd: EB_ERROR_INFORMATION_CMD is
3284 -- Command to pop up a dialog giving help on compilation errors.
3285 do
3286 Result := debugger_manager.display_error_help_cmd
3287 end
3288
3289 send_stone_to_context_cmd: EB_STANDARD_CMD
3290 -- Command to send the current stone to the context tool.
3291
3292 print_cmd: EB_PRINT_COMMAND
3293 -- Command to print the content of editor with focus
3294
3295 eac_browser_cmd: EB_OPEN_EAC_BROWSER_CMD is
3296 -- Command to display the eac browser
3297 do
3298 Result := Debugger_manager.eac_browser_cmd
3299 end
3300
3301 show_favorites_menu_item: EV_MENU_ITEM
3302 -- Show/Hide favorites menu item.
3303
3304 update_show_favorites_menu_item is
3305 -- Update `show_favorites_menu_item' menu label.
3306 do
3307 if favorites_tool.shown then
3308 show_favorites_menu_item.set_text (Interface_names.m_hide_favorites)
3309 else
3310 show_favorites_menu_item.set_text (Interface_names.m_show_favorites)
3311 end
3312 end
3313
3314 execute_show_favorites is
3315 -- Show `favorites_tool' if it is closed, close
3316 -- it in the opposite case.
3317 do
3318 update_show_favorites_menu_item
3319 if favorites_tool.shown then
3320 favorites_tool.close
3321 else
3322 favorites_tool.show
3323 end
3324 end
3325
3326 feature {EB_TOOL_WINDOW, EB_EXPLORER_BAR, EB_DEBUGGER_MANAGER} -- Floating tool handling
3327
3328 all_tool_windows: ARRAYED_LIST [EB_TOOL_WINDOW]
3329 -- All tool windows under the control of `Current'.
3330
3331 add_tool_window (a_tool_window: EB_TOOL_WINDOW) is
3332 -- Add `a_tool_window' to `all_tool_windows', ensuring it is
3333 -- then under the control of `Current'.
3334 require
3335 a_tool_window_not_void: a_tool_window /= Void
3336 do
3337 if all_tool_windows = Void then
3338 create all_tool_windows.make (2)
3339 end
3340 all_tool_windows.extend (a_tool_window)
3341 ensure
3342 extended: all_tool_windows.has (a_tool_window)
3343 end
3344
3345 remove_tool_window (a_widget: EV_WIDGET) is
3346 -- Remove tool window associate with `a_widget'.
3347 require
3348 a_widget_not_void: a_widget /= Void
3349 do
3350 if all_tool_windows /= Void then
3351 from
3352 all_tool_windows.start
3353 until
3354 all_tool_windows.off
3355 loop
3356 if all_tool_windows.item.tool = a_widget then
3357 all_tool_windows.remove
3358 all_tool_windows.finish
3359 end
3360 all_tool_windows.forth
3361 end
3362 end
3363 end
3364
3365 remove_all_tool_windows is
3366 -- Ensure `all_tool_windows' is empty if non Void.
3367 do
3368 if all_tool_windows /= Void then
3369 all_tool_windows.wipe_out
3370 end
3371 ensure
3372 tool_windows_empty: all_tool_windows /= Void implies all_tool_windows.is_empty
3373 end
3374
3375 window_moved (x_pos, y_pos: INTEGER) is
3376 -- `Current' has been moved, so move all associated tool windows within `all_tool_windows'.
3377 local
3378 tool_window: EB_TOOL_WINDOW
3379 do
3380 if all_tool_windows /= Void then
3381 from
3382 all_tool_windows.start
3383 until
3384 all_tool_windows.off
3385 loop
3386 tool_window := all_tool_windows.item
3387 check
3388 not_destroyed: not tool_window.window.is_destroyed
3389 end
3390 if preferences.development_window_data.dock_tracking then
3391 tool_window.window.move_actions.block
3392 tool_window.window.set_x_position (x_pos + tool_window.x_position)
3393 tool_window.window.set_y_position (y_pos + tool_window.y_position)
3394 tool_window.window.move_actions.resume
3395 else
3396 -- If we are not performing dock tracking, we must update the relative position
3397 -- of the tool window, so that if dock tracking is enabled, the relative
3398 -- positions are correct.
3399 tool_window.set_x_position ( tool_window.window.screen_x - x_pos)
3400 tool_window.set_y_position ( tool_window.window.screen_y - y_pos)
3401 end
3402 all_tool_windows.forth
3403 end
3404 end
3405 end
3406
3407 feature {NONE} -- Execution
3408
3409 Kcst: EV_KEY_CONSTANTS is
3410 -- A way to access key constants.
3411 once
3412 create Result
3413 end
3414
3415 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
3416 -- Action called when the user right-click in the toolbar.
3417 -- Display a popup menu to show/hide toolbars and customize the general toolbar.
3418 local
3419 popup_menu: EV_MENU
3420 do
3421 if a_button = 3 then
3422 popup_menu := build_toolbar_menu
3423 popup_menu.show
3424 end
3425 end
3426
3427 enable_commands_on_project_created is
3428 -- Enable commands when a new project has been created (not yet compiled)
3429 do
3430 system_info_cmd.enable_sensitive
3431 if
3432 stone /= Void and then
3433 not unified_stone
3434 then
3435 send_stone_to_context_cmd.enable_sensitive
3436 end
3437 end
3438
3439 enable_commands_on_project_loaded is
3440 -- Enable commands when a new project has been created and compiled
3441 do
3442 if has_profiler then
3443 show_profiler.enable_sensitive
3444 end
3445 if has_dll_generation then
3446 show_dynamic_lib_tool.enable_sensitive
3447 end
3448 open_cmd.enable_sensitive
3449 new_class_cmd.enable_sensitive
3450 new_cluster_cmd.enable_sensitive
3451 system_info_cmd.enable_sensitive
3452 if unified_stone then
3453 send_stone_to_context_cmd.disable_sensitive
3454 elseif stone /= Void then
3455 send_stone_to_context_cmd.enable_sensitive
3456 end
3457 new_class_cmd.enable_sensitive
3458 new_cluster_cmd.enable_sensitive
3459 delete_class_cluster_cmd.enable_sensitive
3460 c_workbench_compilation_cmd.enable_sensitive
3461 c_finalized_compilation_cmd.enable_sensitive
3462 end
3463
3464 disable_commands_on_project_unloaded is
3465 -- Enable commands when a project has been closed.
3466 do
3467 if has_dll_generation then
3468 show_dynamic_lib_tool.disable_sensitive
3469 end
3470 if has_profiler then
3471 show_profiler.disable_sensitive
3472 end
3473 open_cmd.disable_sensitive
3474 new_class_cmd.disable_sensitive
3475 new_cluster_cmd.disable_sensitive
3476 if not project_manager.is_created then
3477 system_info_cmd.disable_sensitive
3478 send_stone_to_context_cmd.disable_sensitive
3479 end
3480 delete_class_cluster_cmd.disable_sensitive
3481 c_workbench_compilation_cmd.disable_sensitive
3482 c_finalized_compilation_cmd.disable_sensitive
3483 end
3484
3485 end -- class EB_DEVELOPMENT_WINDOW
3486

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23