/[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 51111 - (show annotations)
Tue May 17 18:04:25 2005 UTC (14 years, 9 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 101155 byte(s)
Pure cosmetics changes: removed extra spaces/tabs, fixed incorrect tabulation,
  fixed incorrect cases for string constants.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23