/[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 52172 - (show annotations)
Wed Jun 15 19:23:36 2005 UTC (14 years, 8 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/windows/eb_development_window.e
File size: 102634 byte(s)
Added studio specific version of EV_SCREEN that handles better multiple displays.
  If main window is off display, then we will ensure it is displayed within the display.
  Updated code to not use EV_SCREEN, but the virtual_XXX routines of EB_STUDIO_SCREEN.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23