/[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 52263 - (show annotations)
Thu Jun 16 22:11:34 2005 UTC (14 years, 8 months ago) by neilc
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 102170 byte(s)
Removed unused routines and unneeded manual setting of editor focus

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23