/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/tools/eb_context_editor.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/tools/eb_context_editor.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61942 - (show annotations)
Sun Jul 30 06:00:00 2006 UTC (13 years, 4 months ago) by manus
File size: 59657 byte(s)
EiffelStudio docking branch. It only contains modified classes needed to get the docking version of EiffelStudio.
1 indexing
2 description:
3 "Area in EB_CONTEXT_TOOL notebook designated to view%N%
4 %the context diagram of center class or center cluster."
5 legal: "See notice at end of class."
6 status: "See notice at end of class."
7 date: "$Date$"
8 revision: "$Revision$"
9
10 class
11 EB_CONTEXT_EDITOR
12
13 inherit
14 SHARED_EIFFEL_PROJECT
15
16 EB_WINDOW_MANAGER_OBSERVER
17 redefine
18 on_item_removed
19 end
20
21 TEXT_OBSERVER
22 redefine
23 on_text_edited
24 end
25
26 SHARED_ERROR_HANDLER
27
28 EB_RECYCLABLE
29
30 EB_SHARED_WINDOW_MANAGER
31
32 EB_CONSTANTS
33 undefine
34 pixmaps
35 end
36
37 SHARED_WORKBENCH
38 undefine
39 default_create
40 end
41
42 EB_SHARED_PREFERENCES
43
44 EV_SHARED_APPLICATION
45 undefine
46 default_create
47 end
48
49 EB_SHARED_ID_SOLUTION
50
51 create
52 make_with_tool
53
54 feature {NONE} -- Initialization
55
56 make_with_tool (a_tool: like tool) is
57 -- Set default values.
58 local
59 empty_world: BON_CLASS_DIAGRAM
60 border_frame: EV_FRAME
61 a_class_graph: ES_CLASS_GRAPH
62 do
63 tool := a_tool
64 create widget
65
66 -- Initialize undoable command history.
67 create history
68 history.do_actions.extend (agent on_history_do_command)
69 history.undo_actions.extend (agent on_history_undo_command)
70 history.undo_exhausted_actions.extend (agent on_history_undo_exhausted)
71 history.redo_exhausted_actions.extend (agent on_history_redo_exhausted)
72 project_close_agent := agent store
73 Eiffel_project.manager.close_agents.extend (project_close_agent)
74 development_window.window_manager.add_observer (Current)
75
76
77 create a_class_graph.make (Current)
78 create empty_world.make (a_class_graph, Current)
79 create world_cell.make_with_world_and_tool (empty_world, Current)
80 world_cell.horizontal_scrollbar.change_actions.extend (agent on_scroll)
81 world_cell.vertical_scrollbar.change_actions.extend (agent on_scroll)
82 create border_frame
83 border_frame.extend (world_cell)
84
85 graph := a_class_graph
86 create {EIFFEL_INHERITANCE_LAYOUT} layout.make_with_world (empty_world)
87 is_rebuild_world_needed := False
88 update_excluded_class_figures
89 empty_world.drop_actions.extend (agent on_cluster_drop)
90 empty_world.drop_actions.extend (agent on_class_drop)
91 create force_directed_layout.make_with_world (empty_world)
92 force_directed_layout.stop
93 force_directed_layout.stop_actions.extend (agent on_force_stop)
94 force_directed_layout.set_theta (50)
95
96 create shortcut_table.make (20)
97
98 init_commands
99 build_tool_bar
100 disable_toolbar
101 widget.extend (border_frame)
102
103 retrieve_depth_preferences
104
105 development_window.editor_tool.text_area.add_edition_observer (Current)
106 area.key_press_actions.extend (agent on_key_pressed)
107 end
108
109 init_commands is
110 -- Create command classes.
111 do
112
113 create toggle_selected_classes_ancestors_cmd.make_for_ancestors (Current)
114 toggle_selected_classes_ancestors_cmd.enable_displayed
115 toggle_selected_classes_ancestors_cmd.enable_sensitive
116 create toggle_selected_classes_descendents_cmd.make_for_descendents (Current)
117 toggle_selected_classes_descendents_cmd.enable_displayed
118 toggle_selected_classes_descendents_cmd.enable_sensitive
119 create toggle_selected_classes_clients_cmd.make_for_clients (Current)
120 toggle_selected_classes_clients_cmd.enable_displayed
121 toggle_selected_classes_clients_cmd.enable_sensitive
122 create toggle_selected_classes_suppliers_cmd.make_for_suppliers (Current)
123 toggle_selected_classes_suppliers_cmd.enable_displayed
124 toggle_selected_classes_suppliers_cmd.enable_sensitive
125
126 create center_diagram_cmd.make (Current)
127 center_diagram_cmd.enable_displayed
128 center_diagram_cmd.enable_sensitive
129
130 create create_class_cmd.make (Current)
131 create_class_cmd.enable_displayed
132 create delete_cmd.make (Current, development_window)
133 delete_cmd.enable_displayed
134 create create_new_links_cmd.make (Current)
135 create_new_links_cmd.enable_displayed
136 create_new_links_cmd.select_type (create_new_links_cmd.Inheritance)
137 create change_color_cmd.make (Current)
138 change_color_cmd.enable_displayed
139 create trash_cmd.make (Current)
140 trash_cmd.enable_displayed
141 create toggle_inherit_cmd.make (Current)
142 toggle_inherit_cmd.enable_displayed
143 create toggle_supplier_cmd.make (Current)
144 toggle_supplier_cmd.enable_displayed
145 create toggle_labels_cmd.make (Current)
146 toggle_labels_cmd.enable_displayed
147 create toggle_quality_cmd.make (Current)
148 toggle_quality_cmd.enable_displayed
149 create link_tool_cmd.make (Current)
150 link_tool_cmd.enable_displayed
151 create fill_cluster_cmd.make (Current)
152 fill_cluster_cmd.enable_displayed
153 create select_depth_cmd.make (Current)
154 select_depth_cmd.enable_displayed
155 create history_cmd.make (Current)
156 history_cmd.enable_displayed
157 create undo_cmd.make (Current)
158 undo_cmd.enable_displayed
159 create redo_cmd.make (Current)
160 redo_cmd.enable_displayed
161 create zoom_in_cmd.make (Current)
162 zoom_in_cmd.enable_displayed
163 create zoom_out_cmd.make (Current)
164 zoom_out_cmd.enable_displayed
165 create delete_view_cmd.make (Current)
166 delete_view_cmd.enable_displayed
167 create diagram_to_ps_cmd.make (Current)
168 diagram_to_ps_cmd.enable_displayed
169 create toggle_force_cmd.make (Current)
170 toggle_force_cmd.enable_displayed
171 create toggle_cluster_cmd.make (Current)
172 toggle_cluster_cmd.enable_displayed
173 create remove_anchor_cmd.make (Current)
174 remove_anchor_cmd.enable_displayed
175 create toggle_cluster_legend_cmd.make (Current)
176 toggle_cluster_legend_cmd.enable_displayed
177 create toggle_uml_cmd.make (Current)
178 toggle_uml_cmd.enable_sensitive
179 toggle_uml_cmd.enable_displayed
180 create fit_to_screen_cmd.make (Current)
181 fit_to_screen_cmd.enable_displayed
182 fit_to_screen_cmd.enable_sensitive
183 create reset_view_cmd.make (Current)
184 reset_view_cmd.enable_sensitive
185 reset_view_cmd.enable_displayed
186 create force_settings_cmd.make (Current)
187 force_settings_cmd.enable_sensitive
188 force_settings_cmd.enable_displayed
189 end
190
191 initialize_accelerators (a_command_list: LINKED_LIST [EB_TOOLBARABLE_COMMAND]) is
192 -- Initialize accelerators from commands held in `a_command_list'.
193 require
194 a_command_list_not_void: a_command_list /= Void
195 local
196 l_item: EB_TOOLBARABLE_COMMAND
197 do
198 from
199 a_command_list.start
200 until
201 a_command_list.after
202 loop
203 l_item := a_command_list.item
204 -- `l_item' may be Void to signify a separator for building the toolbar.
205 if l_item /= Void and then l_item.accelerator /= Void then
206 extend_shortcut_table (l_item.accelerator)
207 end
208 a_command_list.forth
209 end
210 end
211
212
213 build_tool_bar is
214 -- Create diagram option bar.
215 local
216 v_box: EV_VERTICAL_BOX
217 view_bar: EV_HORIZONTAL_BOX
218 view_toolbar: EB_TOOLBAR
219 drawing_bar: EV_HORIZONTAL_BOX
220 view_menu: EV_HORIZONTAL_BOX
221 customize_area: EV_CELL
222 draw_commands, view_commands: LINKED_LIST [EB_TOOLBARABLE_COMMAND]
223 zoom_cell: EV_CELL
224 h_box: EV_HORIZONTAL_BOX
225 label: EV_LABEL
226 view_label: EV_LABEL
227 do
228 create v_box
229 create view_bar
230 create drawing_bar
231
232 -- Create commands for view and draw toolbars.
233 create draw_commands.make
234 create view_commands.make
235
236 -- TODO: Remove and make create class in standart toolbar pick and dropable
237 draw_commands.extend (create_class_cmd)
238 draw_commands.extend (create_new_links_cmd)
239 draw_commands.extend (delete_cmd)
240 draw_commands.extend (trash_cmd)
241 draw_commands.extend (change_color_cmd)
242 draw_commands.extend (link_tool_cmd)
243 draw_commands.extend (fill_cluster_cmd)
244 draw_commands.extend (diagram_to_ps_cmd)
245
246 draw_commands.extend (remove_anchor_cmd)
247
248 view_commands.extend (toggle_selected_classes_ancestors_cmd)
249 view_commands.extend (toggle_selected_classes_descendents_cmd)
250 view_commands.extend (toggle_selected_classes_clients_cmd)
251 view_commands.extend (toggle_selected_classes_suppliers_cmd)
252
253
254 custom_toolbar := preferences.diagram_tool_data.retrieve_diagram_toolbar (draw_commands)
255
256
257 -- Extending `Void' to list will generate a toolbar separator in its place.
258
259 view_commands.extend (center_diagram_cmd)
260 view_commands.extend (toggle_uml_cmd)
261 view_commands.extend (Void)
262
263 view_commands.extend (toggle_cluster_cmd)
264 view_commands.extend (toggle_cluster_legend_cmd)
265 view_commands.extend (Void)
266
267 view_commands.extend (toggle_supplier_cmd)
268 view_commands.extend (toggle_inherit_cmd)
269 view_commands.extend (toggle_labels_cmd)
270 view_commands.extend (Void)
271
272 view_commands.extend (undo_cmd)
273 view_commands.extend (history_cmd)
274 view_commands.extend (redo_cmd)
275 view_commands.extend (Void)
276
277 view_commands.extend (toggle_quality_cmd)
278 view_commands.extend (select_depth_cmd)
279 view_commands.extend (Void)
280
281 view_commands.extend (toggle_force_cmd)
282 view_commands.extend (force_settings_cmd)
283 view_commands.extend (Void)
284
285 view_commands.extend (zoom_in_cmd)
286 view_commands.extend (fit_to_screen_cmd)
287 view_commands.extend (zoom_out_cmd)
288
289 from
290 create view_toolbar
291 view_commands.start
292 until
293 view_commands.after
294 loop
295 if view_commands.item /= Void then
296 view_toolbar.extend (view_commands.item)
297 else
298 view_toolbar.extend (create {EB_TOOLBARABLE_SEPARATOR})
299 end
300 view_commands.forth
301 end
302
303 view_toolbar.update_toolbar
304 view_bar.extend (view_toolbar.widget)
305 view_bar.disable_item_expand (view_bar.last)
306
307
308 initialize_accelerators (draw_commands)
309 initialize_accelerators (view_commands)
310
311 if reset_view_cmd.accelerator /= Void then
312 extend_shortcut_table (reset_view_cmd.accelerator)
313 end
314 if delete_view_cmd.accelerator /= Void then
315 extend_shortcut_table (delete_view_cmd.accelerator)
316 end
317
318 custom_toolbar.update_toolbar
319 drawing_bar.extend (custom_toolbar.widget)
320 drawing_bar.disable_item_expand (custom_toolbar.widget)
321
322 create zoom_cell
323
324 create h_box
325
326 create label.make_with_text ("Zoom ")
327 h_box.extend (label)
328 h_box.disable_item_expand (label)
329
330 create zoom_selector.make_default
331 zoom_selector.select_actions.extend (agent on_zoom_level_select)
332
333 h_box.extend (zoom_selector)
334 h_box.disable_item_expand (zoom_selector)
335
336 zoom_cell.extend (h_box)
337
338 -- view_bar.extend (zoom_cell)
339 -- view_bar.disable_item_expand (zoom_cell)
340
341 create customize_area
342 drawing_bar.extend (customize_area)
343
344 drawing_bar.extend (zoom_cell)
345 drawing_bar.disable_item_expand (zoom_cell)
346
347 -- Add toolbars to vertical box.
348 v_box.extend (view_bar)
349 v_box.disable_item_expand (view_bar)
350
351 v_box.extend (create {EV_HORIZONTAL_SEPARATOR})
352 v_box.disable_item_expand (v_box.last)
353
354 v_box.extend (drawing_bar)
355 v_box.disable_item_expand (drawing_bar)
356 widget.extend (v_box)
357 widget.disable_item_expand (v_box)
358
359
360
361 create view_menu
362
363 create view_label.make_with_text ("View ")
364 view_menu.extend (view_label)
365 view_menu.disable_item_expand (view_label)
366
367 create view_selector.make_with_text (world.default_view_name)
368 view_selector.return_actions.extend (agent on_view_changed)
369 view_selector.set_minimum_width (100)
370 view_menu.extend (view_selector)
371 view_menu.disable_item_expand (view_selector)
372
373 create view_menu_button
374 view_menu_button.set_pixmap (pixmaps.mini_pixmaps.toolbar_dropdown_icon)
375 --view_menu_button.set_minimum_size (15, 20)
376 view_menu.extend (view_menu_button)
377 view_menu.disable_item_expand (view_menu_button)
378 view_menu_button.select_actions.extend (agent show_view_menu)
379
380 -- We want view menu to be right aligned.
381 view_bar.extend (create {EV_CELL})
382 view_bar.extend (view_menu)
383 view_bar.disable_item_expand (view_menu)
384
385 customize_area.pointer_button_release_actions.extend (agent on_customize)
386 end
387
388
389 show_view_menu is
390 -- Display "View" menu.
391 local
392 view_menu: EV_MENU
393 l_list: LIST [STRING]
394 menu_item: EV_MENU_ITEM
395 do
396 create view_menu
397 view_menu.extend (reset_view_cmd.new_menu_item)
398 --TODO: Maybe a pop up dialog.
399 -- create menu_item.make_with_text_and_action ("Name view", agent name_view)
400 -- view_menu.extend (menu_item)
401 view_menu.extend (delete_view_cmd.new_menu_item)
402 if world.current_view.has_substring ("DEFAULT") then
403 delete_view_cmd.disable_sensitive
404 end
405 view_menu.extend (create {EV_MENU_SEPARATOR})
406 from
407 l_list := world.available_views
408 l_list.start
409 until
410 l_list.after
411 loop
412 create menu_item.make_with_text_and_action (l_list.item, agent select_view (l_list.item))
413 view_menu.extend (menu_item)
414 l_list.forth
415 end
416 view_menu.show_at (view_menu_button, 0, view_menu_button.height)
417 end
418
419 select_view (a_name: STRING) is
420 -- Select `a_name' as the current view and switch to that view.
421 do
422 view_selector.set_text (a_name)
423 on_view_changed
424 end
425
426 name_view is
427 -- Name the view.
428 do
429 view_selector.select_all
430 view_selector.set_focus
431 end
432
433 feature -- Status report
434
435 is_rebuild_world_needed: BOOLEAN
436 -- Is a rebuild of the world needed when a stone is dropped?
437
438 is_excluded_in_preferences (name: STRING): BOOLEAN is
439 -- Is class figure named `name' excluded in preferences?
440 do
441 Result := excluded_class_figures.has (name)
442 end
443
444 ignore_excluded_figures: BOOLEAN
445 -- Will `excluded_class_figures' be taken into account?
446
447 is_force_directed_used: BOOLEAN
448 -- Is force directed physics used to arrange classes?
449
450 feature -- Access
451
452 default_pixmaps: EV_STOCK_PIXMAPS is
453 do
454 create Result
455 end
456
457 development_window: EB_DEVELOPMENT_WINDOW is
458 -- Application main window.
459 do
460 Result ?= tool.manager
461 end
462
463 graph: ES_GRAPH
464 -- Current graph.
465
466 class_graph: ES_CLASS_GRAPH is
467 -- Current class graph if not Void.
468 do
469 Result ?= graph
470 end
471
472 cluster_graph: ES_CLUSTER_GRAPH is
473 -- Current cluster graph if not Void.
474 do
475 Result ?= graph
476 end
477
478 world: EIFFEL_WORLD is
479 -- Current world.
480 do
481 Result := world_cell.world
482 ensure
483 Result_not_void: Result /= Void
484 end
485
486 projector: EIFFEL_PROJECTOR is
487 -- Current projector
488 do
489 Result := world_cell.projector
490 ensure
491 Result_not_void: Result /= Void
492 end
493
494 layout: EIFFEL_INHERITANCE_LAYOUT
495 -- Current layout.
496
497 widget: EV_VERTICAL_BOX
498 -- Graphical object of `Current' containing `world_cell'.
499
500 history: EB_HISTORY_DIALOG
501 -- History of undoable commands.
502
503
504 pointer_position: EV_COORDINATE is
505 -- Position of the screen pointer relative to `area'.
506 do
507 create Result.set (
508 area_as_widget.pointer_position.x + projector.area_x,
509 area_as_widget.pointer_position.y + projector.area_y)
510 ensure
511 position_not_void: Result /= Void
512 end
513
514 class_view: EIFFEL_CLASS_DIAGRAM is
515 -- Class view currently displayed.
516 do
517 Result ?= world
518 end
519
520 cluster_view: EIFFEL_CLUSTER_DIAGRAM is
521 -- Cluster view currently displayed.
522 do
523 Result ?= world
524 end
525
526 force_directed_layout: EIFFEL_FORCE_LAYOUT
527 -- Layout used to force direct the graph.
528
529 feature -- Status settings.
530
531 update_excluded_class_figures is
532 -- Preferences may have changed.
533 -- Refresh `excluded_class_figures' and `ignore_excluded_figures'.
534 local
535 l_array: ARRAY [STRING]
536 i: INTEGER
537 do
538 ignore_excluded_figures := preferences.diagram_tool_data.ignore_excluded_class_figures
539 if not ignore_excluded_figures then
540 l_array := preferences.diagram_tool_data.excluded_class_figures
541 create excluded_class_figures.make (l_array.count)
542 from
543 i := l_array.lower
544 until
545 i > l_array.upper
546 loop
547 excluded_class_figures.put (l_array.item (i), l_array.item (i))
548 i := i + 1
549 end
550 else
551 create excluded_class_figures.make (0)
552 end
553 end
554
555 disable_resize is
556 -- Disable resizing world cell.
557 do
558 world_cell.disable_resize
559 end
560
561 enable_resize is
562 -- Enable resizing worl cell.
563 do
564 world_cell.enable_resize
565 end
566
567 set_is_rebuild_world_needed (b: BOOLEAN) is
568 -- Set `is_rebuild_world_needed' to `b'.
569 do
570 is_rebuild_world_needed := b
571 ensure
572 set: is_rebuild_world_needed = b
573 end
574
575 disable_toolbar is
576 -- Disable sensitive for all buttons except center diagram.
577 do
578 zoom_selector.disable_sensitive
579 create_class_cmd.disable_sensitive
580 delete_cmd.disable_sensitive
581 create_new_links_cmd.disable_sensitive
582 change_color_cmd.disable_sensitive
583 trash_cmd.disable_sensitive
584 link_tool_cmd.disable_sensitive
585 toggle_inherit_cmd.disable_sensitive
586 toggle_supplier_cmd.disable_sensitive
587 toggle_labels_cmd.disable_sensitive
588 select_depth_cmd.disable_sensitive
589 fill_cluster_cmd.disable_sensitive
590 undo_cmd.disable_sensitive
591 history_cmd.disable_sensitive
592 redo_cmd.disable_sensitive
593 zoom_in_cmd.disable_sensitive
594 zoom_out_cmd.disable_sensitive
595 delete_view_cmd.disable_sensitive
596 diagram_to_ps_cmd.disable_sensitive
597 toggle_force_cmd.disable_sensitive
598 toggle_cluster_cmd.disable_sensitive
599 remove_anchor_cmd.disable_sensitive
600 toggle_cluster_legend_cmd.disable_sensitive
601 toggle_uml_cmd.disable_sensitive
602 fit_to_screen_cmd.disable_sensitive
603 toggle_quality_cmd.disable_sensitive
604 reset_view_cmd.disable_sensitive
605 view_selector.disable_sensitive
606 view_menu_button.disable_sensitive
607 force_settings_cmd.disable_sensitive
608 end
609
610 enable_toolbar is
611 -- Enable toolbar.
612 do
613 if class_graph /= Void then
614 if world.is_uml then
615 reset_tool_bar_for_uml_class_view
616 else
617 reset_tool_bar_for_class_view
618 end
619 else
620 if world.is_uml then
621 reset_tool_bar_for_uml_cluster_view
622 else
623 reset_tool_bar_for_cluster_view
624 end
625 end
626 end
627
628 enable_force_directed is
629 -- Enable use of force directed physics.
630 local
631 min_box: EV_RECTANGLE
632 fig: EG_LINKABLE_FIGURE
633 do
634 if timer = Void then
635 create timer.make_with_interval (50)
636 else
637 timer.actions.wipe_out
638 end
639 timer.actions.extend (agent on_time_out)
640 is_force_directed_used := True
641 if class_graph = Void then
642 fig ?= world.figure_from_model (cluster_graph.center_cluster)
643 if fig /= Void then
644 min_box := fig.minimum_size
645 force_directed_layout.set_center (min_box.left + min_box.width // 2, min_box.top + min_box.height // 2)
646 end
647 else
648 fig ?= world.figure_from_model (class_graph.center_class)
649 if fig /= Void then
650 force_directed_layout.set_center (fig.port_x, fig.port_y)
651 fig.set_is_fixed (True)
652 end
653 end
654 if world.is_right_angles then
655 world.remove_right_angles
656 end
657 world.show_anchors
658 force_directed_layout.reset
659 ensure
660 is_force_directed_used: is_force_directed_used
661 end
662
663 disable_force_directed is
664 -- Disable use of force directed physics.
665 do
666 is_force_directed_used := False
667 world.hide_anchors
668 force_directed_layout.stop
669 toggle_force_cmd.disable_select
670 ensure
671 not_is_force_directed_used: not is_force_directed_used
672 end
673
674 restart_force_directed is
675 -- Restart using force directed physics after stop.
676 do
677 if is_force_directed_used then
678 force_directed_layout.reset
679 if timer = Void then
680 create timer.make_with_interval (50)
681 end
682 if timer.actions.is_empty then
683 timer.actions.extend (agent on_time_out)
684 end
685 timer.set_interval (50)
686 if world.is_right_angles then
687 world.remove_right_angles
688 end
689 end
690 ensure
691 not_stopped: is_force_directed_used implies not force_directed_layout.is_stopped
692 end
693
694 feature -- Element change
695
696 clear_area is
697 -- Make `area' empty.
698 local
699 a_class_graph: ES_CLASS_GRAPH
700 a_class_view: BON_CLASS_DIAGRAM
701 do
702 world.drop_actions.wipe_out
703 create a_class_graph.make (Current)
704 create a_class_view.make (a_class_graph, Current)
705 world_cell.set_world (a_class_view)
706 layout.set_world (a_class_view)
707 graph := a_class_graph
708 world.drop_actions.extend (agent on_class_drop)
709 world.drop_actions.extend (agent on_cluster_drop)
710 projector.full_project
711 crop_diagram
712 disable_toolbar
713 end
714
715 create_link_tool (a_stone: LINK_STONE) is
716 -- Create a new link tool with `a_stone'.
717 require
718 a_stone_exists: a_stone /= Void
719 do
720 link_tool_cmd.execute_with_link_stone (a_stone)
721 end
722
723 reset_history is
724 -- Forget about previous undoable commands.
725 do
726 history.wipe_out
727 undo_cmd.disable_sensitive
728 redo_cmd.disable_sensitive
729 end
730
731 create_class_view (a_class: CLASS_I; load_when_possible: BOOLEAN) is
732 -- Initialize diagram centered on `a_class', load from file if possible when `load_when_possible'.
733 require
734 a_class_exists: a_class /= Void
735 local
736 f: RAW_FILE
737 cancelled: BOOLEAN
738 a_class_graph: ES_CLASS_GRAPH
739 a_class_view: EIFFEL_CLASS_DIAGRAM
740 cf: EIFFEL_CLASS_FIGURE
741 es_class: ES_CLASS
742 was_legend_shown: BOOLEAN
743 do
744 history.wipe_out
745 disable_toolbar
746
747 if not cancelled then
748 development_window.status_bar.reset
749 development_window.status_bar.display_message ("Constructing Diagram for " + a_class.name_in_upper + " Class")
750
751 graph.wipe_out
752
753 world.drop_actions.wipe_out
754 create a_class_graph.make (Current)
755 if class_graph /= Void then
756 default_ancestor_depth := class_graph.ancestor_depth
757 default_descendant_depth := class_graph.descendant_depth
758 default_client_depth := class_graph.client_depth
759 default_supplier_depth := class_graph.supplier_depth
760 a_class_graph.set_include_all_classes_of_cluster (class_graph.include_all_classes_of_cluster)
761 a_class_graph.set_include_only_classes_of_cluster (class_graph.include_only_classes_of_cluster)
762 end
763 a_class_graph.set_ancestor_depth (default_ancestor_depth)
764 a_class_graph.set_descendant_depth (default_descendant_depth)
765 a_class_graph.set_client_depth (default_client_depth)
766 a_class_graph.set_supplier_depth (default_supplier_depth)
767 if world.is_uml then
768 create {UML_CLASS_DIAGRAM} a_class_view.make (a_class_graph, Current)
769 layout.set_spacing (default_uml_horizontal_spacing, default_uml_vertical_spacing)
770 else
771 create {BON_CLASS_DIAGRAM} a_class_view.make (a_class_graph, Current)
772 layout.set_spacing (default_bon_horizontal_spacing, default_bon_vertical_spacing)
773 end
774 a_class_view.scale (world.scale_factor)
775 if not world.is_high_quality then
776 a_class_view.disable_high_quality
777 end
778 if not world.is_labels_shown then
779 a_class_view.hide_labels
780 end
781 if not world.is_client_supplier_links_shown then
782 a_class_view.hide_client_supplier_links
783 end
784 if not world.is_inheritance_links_shown then
785 a_class_view.hide_inheritance_links
786 end
787 if not world.is_cluster_shown then
788 a_class_view.hide_clusters
789 end
790 if world.is_right_angles then
791 a_class_view.enable_right_angles
792 end
793 if world.is_legend_shown then
794 was_legend_shown := True
795 end
796
797 world.recycle
798 world_cell.set_world (a_class_view)
799 layout.set_world (a_class_view)
800 force_directed_layout.set_world (a_class_view)
801 graph := a_class_graph
802
803 if is_force_directed_used then
804 disable_force_directed
805 end
806
807 update_excluded_class_figures
808 world_cell.disable_resize
809 projector.disable_painting
810 create es_class.make (a_class)
811
812 class_graph.set_center_class (es_class)
813
814 create f.make (diagram_file_name (class_graph))
815
816 if load_when_possible and then is_valide_diagram_file (f) then
817 a_class_view.retrieve (f)
818 if class_graph.is_empty then
819 class_graph.explore_center_class
820 layout.layout
821 end
822 else
823 class_graph.explore_center_class
824 if is_valide_diagram_file (f) then
825 world.load_available_views (f)
826 end
827 world.set_current_view (view_selector.text)
828 if not world.available_views.has (world.current_view) then
829 world.available_views.extend (world.current_view)
830 end
831 layout.layout
832 end
833 cf ?= world.figure_from_model (class_graph.center_class)
834 if cf /= Void then
835 cf.set_is_fixed (True)
836 end
837
838 projector.enable_painting
839 world_cell.enable_resize
840 projector.full_project
841 development_window.status_bar.reset
842 crop_diagram
843 if world.is_uml then
844 reset_tool_bar_for_uml_class_view
845 else
846 reset_tool_bar_for_class_view
847 end
848 if was_legend_shown then
849 world.show_legend
850 end
851 reset_view_selector
852 reset_tool_bar_toggles
853 world.figure_change_end_actions.extend (agent on_figure_change_end)
854 world.figure_change_start_actions.extend (agent on_figure_change_start)
855 world.cluster_legend.move_actions.extend (agent on_cluster_legend_move)
856 world.cluster_legend.pin_actions.extend (agent on_cluster_legend_pin)
857 on_cluster_legend_pin
858
859 if world.is_right_angles then
860 world.apply_right_angles
861 end
862 end
863 rescue
864 cancelled := True
865 error_handler.error_list.wipe_out
866 projector.enable_painting
867 world_cell.enable_resize
868 clear_area
869 is_rebuild_world_needed := True
870 if is_force_directed_used then
871 toggle_force_cmd.current_button.disable_select
872 end
873 retry
874 end
875
876 create_cluster_view (a_group: CONF_GROUP; load_when_possible: BOOLEAN) is
877 -- Initialize diagram centered on `a_cluster', load from file if possible when `load_when_possible'.
878 require
879 a_group_exists: a_group /= Void
880 local
881 cancelled: BOOLEAN
882 l_cluster_view: EIFFEL_CLUSTER_DIAGRAM
883 l_cluster_graph: ES_CLUSTER_GRAPH
884 new_cluster: ES_CLUSTER
885 f: RAW_FILE
886 was_legend_shown: BOOLEAN
887 do
888 history.wipe_out
889 disable_toolbar
890
891 if not cancelled then
892 development_window.status_bar.reset
893 development_window.status_bar.display_message ("Constructing Diagram for " + a_group.name)
894
895 graph.wipe_out
896
897 world.drop_actions.wipe_out
898 create l_cluster_graph.make (Current)
899 if cluster_graph /= Void then
900 default_subcluster_depth := cluster_graph.subcluster_depth
901 default_supercluster_depth := cluster_graph.supercluster_depth
902 end
903 l_cluster_graph.set_subcluster_depth (default_subcluster_depth)
904 l_cluster_graph.set_supercluster_depth (default_supercluster_depth)
905 if world.is_uml then
906 create {UML_CLUSTER_DIAGRAM} l_cluster_view.make (l_cluster_graph, Current)
907 layout.set_spacing (default_uml_horizontal_spacing, default_uml_vertical_spacing)
908 else
909 create {BON_CLUSTER_DIAGRAM} l_cluster_view.make (l_cluster_graph, Current)
910 layout.set_spacing (default_uml_horizontal_spacing, default_bon_vertical_spacing)
911 end
912 l_cluster_view.scale (world.scale_factor)
913
914 if not world.is_high_quality then
915 l_cluster_view.disable_high_quality
916 end
917 if not world.is_labels_shown then
918 l_cluster_view.hide_labels
919 end
920 if not world.is_client_supplier_links_shown then
921 l_cluster_view.hide_client_supplier_links
922 end
923 if not world.is_inheritance_links_shown then
924 l_cluster_view.hide_inheritance_links
925 end
926 if not world.is_cluster_shown then
927 l_cluster_view.hide_clusters
928 end
929 if world.is_right_angles then
930 l_cluster_view.enable_right_angles
931 end
932 if world.is_legend_shown then
933 was_legend_shown := True
934 end
935
936 world.recycle
937 world_cell.set_world (l_cluster_view)
938 layout.set_world (l_cluster_view)
939 force_directed_layout.set_world (l_cluster_view)
940 graph := l_cluster_graph
941
942
943 if is_force_directed_used then
944 disable_force_directed
945 end
946
947 update_excluded_class_figures
948 world_cell.disable_resize
949 world.hide
950 create new_cluster.make (a_group)
951 cluster_graph.set_center_cluster (new_cluster)
952
953 create f.make (diagram_file_name (cluster_graph))
954
955 if load_when_possible and then is_valide_diagram_file (f) then
956 l_cluster_view.retrieve (f)
957 if cluster_graph.is_empty then
958 cluster_graph.explore_center_cluster
959 layout.layout
960 end
961 else
962 cluster_graph.explore_center_cluster
963 if is_valide_diagram_file (f) then
964 world.load_available_views (f)
965 end
966 world.set_current_view (view_selector.text)
967 if not world.available_views.has (world.current_view) then
968 world.available_views.extend (world.current_view)
969 end
970 layout.layout
971 end
972
973 world.show
974 world_cell.enable_resize
975
976 development_window.status_bar.reset
977 projector.full_project
978 crop_diagram
979 if world.is_uml then
980 reset_tool_bar_for_uml_cluster_view
981 else
982 reset_tool_bar_for_cluster_view
983 end
984 if world.is_right_angles then
985 world.apply_right_angles
986 end
987 reset_view_selector
988 reset_tool_bar_toggles
989 world.figure_change_end_actions.extend (agent on_figure_change_end)
990 world.figure_change_start_actions.extend (agent on_figure_change_start)
991 world.cluster_legend.move_actions.extend (agent on_cluster_legend_move)
992 world.cluster_legend.pin_actions.extend (agent on_cluster_legend_pin)
993 on_cluster_legend_pin
994
995 if was_legend_shown then
996 world.show_legend
997 end
998 end
999 rescue
1000 cancelled := True
1001 error_handler.error_list.wipe_out
1002 world.show
1003 world_cell.enable_resize
1004 clear_area
1005 is_rebuild_world_needed := True
1006 if is_force_directed_used then
1007 toggle_force_cmd.current_button.disable_select
1008 end
1009 retry
1010 end
1011
1012 synchronize is
1013 -- Contexts need to be updated because of recompilation
1014 -- or similar action that needs resynchonization.
1015 do
1016 if tool.is_diagram_selected then
1017 graph.synchronize
1018 reset_history
1019 projector.full_project
1020 else
1021 is_synchronization_needed := True
1022 end
1023 end
1024
1025 crop_diagram is
1026 -- Crop diagram.
1027 do
1028 world_cell.crop
1029 end
1030
1031 feature {EB_TOGGLE_UML_COMMAND} -- UML/BON toggle.
1032
1033 toggle_uml is
1034 -- Toggle between UML/BON mode
1035 local
1036 uml_class: UML_CLASS_DIAGRAM
1037 uml_cluster: UML_CLUSTER_DIAGRAM
1038 bon_class: BON_CLASS_DIAGRAM
1039 bon_cluster: BON_CLUSTER_DIAGRAM
1040 f: RAW_FILE
1041 do
1042
1043
1044 if is_force_directed_used then
1045 disable_force_directed
1046 end
1047 if world.is_uml then
1048 if world.available_views.has ("DEFAULT:BON") then
1049 view_selector.set_text ("DEFAULT:BON")
1050 on_view_changed
1051 else
1052 create f.make (diagram_file_name (graph))
1053 if f.exists then
1054 f.open_read
1055 else
1056 f.open_write
1057 end
1058 world.store (f)
1059 world.recycle
1060 if class_graph /= Void then
1061 create bon_class.make (class_graph, Current)
1062 if world.scale_factor /= 1.0 then
1063 bon_class.scale (world.scale_factor)
1064 end
1065 world_cell.set_world (bon_class)
1066 reset_tool_bar_for_class_view
1067 else
1068 create bon_cluster.make (cluster_graph, Current)
1069 if world.scale_factor /= 1.0 then
1070 bon_cluster.scale (world.scale_factor)
1071 end
1072 world_cell.set_world (bon_cluster)
1073 reset_tool_bar_for_cluster_view
1074 end
1075 layout.set_spacing (default_bon_horizontal_spacing, default_bon_vertical_spacing)
1076 layout.set_world (world)
1077 force_directed_layout.set_world (world)
1078 layout.layout
1079 world.load_available_views (f)
1080 reset_tool_bar_toggles
1081 reset_view_selector
1082 crop_diagram
1083 world.figure_change_end_actions.extend (agent on_figure_change_end)
1084 world.figure_change_start_actions.extend (agent on_figure_change_start)
1085 world.cluster_legend.move_actions.extend (agent on_cluster_legend_move)
1086 world.cluster_legend.pin_actions.extend (agent on_cluster_legend_pin)
1087 on_cluster_legend_pin
1088 end
1089 else
1090 if world.available_views.has ("DEFAULT:UML") then
1091 view_selector.set_text ("DEFAULT:UML")
1092 on_view_changed
1093 else
1094 create f.make (diagram_file_name (graph))
1095 if f.exists then
1096 f.open_read
1097 else
1098 f.open_write
1099 end
1100 world.store (f)
1101 world.recycle
1102 if class_graph /= Void then
1103 create uml_class.make (class_graph, Current)
1104 if world.scale_factor /= 1.0 then
1105 uml_class.scale (world.scale_factor)
1106 end
1107 world_cell.set_world (uml_class)
1108 reset_tool_bar_for_uml_class_view
1109 else
1110 create uml_cluster.make (cluster_graph, Current)
1111 if world.scale_factor /= 1.0 then
1112 uml_cluster.scale (world.scale_factor)
1113 end
1114 world_cell.set_world (uml_cluster)
1115 reset_tool_bar_for_uml_cluster_view
1116 end
1117 layout.set_spacing (default_uml_horizontal_spacing, default_uml_vertical_spacing)
1118 layout.set_world (world)
1119 force_directed_layout.set_world (world)
1120 layout.layout
1121 world.load_available_views (f)
1122 reset_tool_bar_toggles
1123 reset_view_selector
1124 crop_diagram
1125 world.figure_change_end_actions.extend (agent on_figure_change_end)
1126 world.figure_change_start_actions.extend (agent on_figure_change_start)
1127 world.cluster_legend.move_actions.extend (agent on_cluster_legend_move)
1128 world.cluster_legend.pin_actions.extend (agent on_cluster_legend_pin)
1129 on_cluster_legend_pin
1130 end
1131 end
1132 end
1133
1134 is_uml: BOOLEAN is
1135 -- Is diagram shown in UML.
1136 do
1137 Result := world.is_uml
1138 end
1139
1140 feature -- Memory management
1141
1142 recycle is
1143 -- Frees `Current's memory, and leave `Current' in an unstable state
1144 -- so that we know whether we're still referenced or not.
1145 do
1146 Eiffel_project.manager.close_agents.start
1147 Eiffel_project.manager.close_agents.prune_all (project_close_agent)
1148 development_window.window_manager.remove_observer (Current)
1149
1150 --| 'if' necessary because the editor may be recycled before the diagram.
1151 if development_window.editor_tool.text_area /= Void then
1152 development_window.editor_tool.text_area.remove_observer (Current)
1153 end
1154 recycle_commands
1155 world_cell.recycle
1156 world_cell := Void
1157 tool := Void
1158 end
1159
1160 recycle_commands is
1161 -- Recycle commands
1162 do
1163 delete_cmd.recycle
1164 end
1165
1166 feature {EB_CONTEXT_EDITOR, EB_CONTEXT_DIAGRAM_COMMAND, EIFFEL_CLASS_FIGURE} -- Toolbar actions
1167
1168 is_link_client, is_link_inheritance, is_link_aggregate: BOOLEAN
1169
1170 on_new_client_click is
1171 -- The user wants a new client-supplier link.
1172 do
1173 is_link_client := True
1174 is_link_inheritance := False
1175 is_link_aggregate := False
1176 end
1177
1178 on_new_agg_client_click is
1179 -- The user wants a new client-supplier link.
1180 do
1181 is_link_client := False
1182 is_link_inheritance := False
1183 is_link_aggregate := True
1184 end
1185
1186 on_new_inherit_click is
1187 -- The user wants a new inheritance link.
1188 do
1189 is_link_client := False
1190 is_link_inheritance := True
1191 is_link_aggregate := False
1192 end
1193
1194 feature {EB_CONTEXT_TOOL} -- Context tool
1195
1196 on_select is
1197 -- Current became selected in notebook.
1198 do
1199 if class_stone /= Void then
1200 set_stone (class_stone)
1201 elseif cluster_stone /= Void then
1202 set_stone (cluster_stone)
1203 end
1204 if is_synchronization_needed then
1205 graph.synchronize
1206 reset_history
1207 is_synchronization_needed := False
1208 end
1209 end
1210
1211 set_focus is
1212 -- Give the focus to the drawing_area.
1213 require
1214 focusable: widget.is_displayed and widget.is_sensitive
1215 do
1216 if area /= Void then
1217 area.set_focus
1218 else
1219 widget.set_focus
1220 end
1221 end
1222
1223 set_stone (a_stone: STONE) is
1224 -- Assign `a_stone' as new stone.
1225 do
1226 if a_stone /= Void then
1227 class_stone ?= a_stone
1228 cluster_stone ?= a_stone
1229 if tool.is_diagram_selected then
1230 if class_stone /= Void then
1231 -- create a new class view
1232 if
1233 is_rebuild_world_needed or else
1234 class_graph = Void or else
1235 class_graph.center_class = Void or else
1236 class_graph.center_class.class_i /= class_stone.class_i
1237 then
1238 is_rebuild_world_needed := False
1239 store
1240 create_class_view (class_stone.class_i, True)
1241 is_synchronization_needed := False
1242 end
1243 else
1244 if cluster_stone /= Void and then not cluster_stone.group.is_assembly then
1245 -- create a cluster view
1246 if
1247 is_rebuild_world_needed or else
1248 cluster_graph = Void or else
1249 cluster_graph.center_cluster = Void or else
1250 cluster_graph.center_cluster.group /= cluster_stone.group
1251 then
1252 is_rebuild_world_needed := False
1253 store
1254 create_cluster_view (cluster_stone.group, True)
1255 is_synchronization_needed := False
1256 end
1257 end
1258 end
1259 end
1260 else
1261 clear_area
1262 end
1263 end
1264
1265 feature {EB_CENTER_DIAGRAM_COMMAND, EIFFEL_CLASS_FIGURE} -- Center diagram command
1266
1267 class_stone: CLASSI_STONE
1268 -- Stone representing center class.
1269
1270 cluster_stone: CLUSTER_STONE
1271 -- Stone representing center cluster.
1272
1273 tool: EB_CONTEXT_TOOL
1274 -- Container of `Current'.
1275
1276 feature {EB_CLASS_HEADER_COMMAND} -- Class head command
1277
1278 area_as_widget: EV_WIDGET is
1279 -- `area' cast to EV_WIDGET.
1280 do
1281 Result ?= area
1282 ensure
1283 Result_not_void: Result /= Void
1284 end
1285
1286 feature {EB_DEVELOPMENT_WINDOW} -- Commands with global accelerators
1287
1288 undo_cmd: EB_UNDO_DIAGRAM_COMMAND
1289 -- Command to undo last action
1290
1291 redo_cmd: EB_REDO_DIAGRAM_COMMAND
1292 -- Command to redo last undone action
1293
1294 feature {EB_ZOOM_OUT_COMMAND, EB_ZOOM_IN_COMMAND, EIFFEL_FIGURE_WORLD_CELL, EB_FIT_TO_SCREEN_COMMAND} -- Zoom command.
1295
1296 zoom_selector: EB_ZOOM_SELECTOR
1297 -- Combo box that lets the user select a zoom level
1298
1299 feature {NONE} -- Views
1300
1301 reset_view_selector is
1302 -- Set entries in `view_selector' to `available_views' in `world'.
1303 do
1304 view_selector.set_text (world.current_view)
1305 end
1306
1307 feature {NONE} -- Commands
1308
1309 view_selector: EV_TEXT_FIELD
1310 -- Combo box that lets the user change views.
1311
1312 view_menu_button: EV_BUTTON
1313 -- Button for the view menu.
1314
1315 history_cmd: EB_DIAGRAM_HISTORY_COMMAND
1316 -- History command.
1317
1318 create_class_cmd: EB_CREATE_CLASS_DIAGRAM_COMMAND
1319 -- Command to create new classes.
1320
1321 delete_cmd: EB_DELETE_DIAGRAM_ITEM_COMMAND
1322 -- Command to remove an element from the system.
1323
1324 create_new_links_cmd: EB_CREATE_LINK_COMMAND
1325 -- Command to select the type of new links.
1326
1327 center_diagram_cmd: EB_CENTER_DIAGRAM_COMMAND
1328 -- Command to target the diagram to a class or a cluster.
1329
1330 change_color_cmd: EB_CHANGE_COLOR_COMMAND
1331 -- Command to change the color of a class or all the classes.
1332
1333 trash_cmd: EB_DELETE_FIGURE_COMMAND
1334 -- Command to hide an element.
1335
1336 toggle_inherit_cmd: EB_TOGGLE_INHERIT_COMMAND
1337 -- Command to show/hide inheritance links.
1338
1339 toggle_supplier_cmd: EB_TOGGLE_SUPPLIER_COMMAND
1340 -- Command to show/hide supplier links.
1341
1342 toggle_labels_cmd: EB_TOGGLE_LABELS_COMMAND
1343 -- Command to show/hide labels.
1344
1345 toggle_cluster_cmd: EB_TOGGLE_CLUSTER_COMMAND
1346 -- Command to show/hide clusters.
1347
1348 select_depth_cmd: EB_SELECT_DEPTH_COMMAND
1349 -- Command to select the depth of the diagram.
1350
1351 link_tool_cmd: EB_LINK_TOOL_COMMAND
1352 -- Toggle right angles.
1353
1354 fill_cluster_cmd: EB_FILL_CLUSTER_COMMAND
1355 -- Command to fill cluster with all classes.
1356
1357 zoom_in_cmd: EB_ZOOM_IN_COMMAND
1358 -- Zoom in command.
1359
1360 zoom_out_cmd: EB_ZOOM_OUT_COMMAND
1361 -- Zoom out command.
1362
1363 toggle_quality_cmd: EB_TOGGLE_QUALITY_COMMAND
1364 -- Toggle quality command.
1365
1366 diagram_to_ps_cmd: EB_DIAGRAM_TO_PS_COMMAND
1367 -- Save diagram as ps or png.
1368
1369 toggle_force_cmd: EB_TOGGLE_FORCE_COMMAND
1370 -- Toggle force directed layout.
1371
1372 remove_anchor_cmd: EB_REMOVE_ANCHOR_COMMAND
1373 -- Remove anchor from a fixed class.
1374
1375 toggle_cluster_legend_cmd: EB_SHOW_LEGEND_COMMAND
1376 -- Colorize clusters.
1377
1378 delete_view_cmd: EB_DELETE_VIEW_COMMAND
1379 -- Delete current view.
1380
1381 reset_view_cmd: EB_RESET_VIEW_COMMAND
1382 -- Reset current view.
1383
1384 toggle_uml_cmd: EB_TOGGLE_UML_COMMAND
1385 -- Toggle between UML/BON.
1386
1387 fit_to_screen_cmd: EB_FIT_TO_SCREEN_COMMAND
1388 -- Resize diagram such that it fits to screen.
1389
1390 force_settings_cmd: EB_SHOW_PHYSICS_SETTINGS_COMMAND
1391 -- Show settings dialog for force directed.
1392
1393 toggle_selected_classes_ancestors_cmd: EB_ADD_CLASS_FIGURE_RELATIONS_COMMAND
1394 toggle_selected_classes_descendents_cmd: EB_ADD_CLASS_FIGURE_RELATIONS_COMMAND
1395 toggle_selected_classes_clients_cmd: EB_ADD_CLASS_FIGURE_RELATIONS_COMMAND
1396 toggle_selected_classes_suppliers_cmd: EB_ADD_CLASS_FIGURE_RELATIONS_COMMAND
1397 -- Toggle showing ancestor, descendent, client and supplier classes for selected diagram classes.
1398
1399 feature {EG_FIGURE, EIFFEL_WORLD} -- Force directed.
1400
1401 on_time_out is
1402 -- `timer' has a timeout.
1403 local
1404 time: C_DATE
1405 l_ticks: INTEGER
1406 do
1407 if world.is_statistics then
1408 create time
1409 l_ticks := time.millisecond_now + time.second_now * 1000 + time.hour_now * 60000
1410
1411 projector.full_project
1412
1413 time.update
1414 world.set_last_physics_time (time.millisecond_now + time.second_now * 1000 + time.hour_now * 60000 - l_ticks)
1415
1416 time.update
1417 l_ticks := time.millisecond_now + time.second_now * 1000 + time.hour_now * 60000
1418
1419 force_directed_layout.layout
1420
1421 time.update
1422 world.set_last_draw_time (time.millisecond_now + time.second_now * 1000 + time.hour_now * 60000 - l_ticks)
1423 else
1424 projector.full_project
1425 force_directed_layout.layout
1426 end
1427 end
1428
1429 feature {NONE} -- Events
1430
1431 timer: EV_TIMEOUT
1432 -- Timer used to force direct the graph.
1433
1434 on_force_stop is
1435 -- `force_directed_layout' has stopped.
1436 do
1437 if timer /= Void then
1438 timer.actions.wipe_out
1439 timer := Void
1440 if world.is_right_angles and not is_right_angles_blocked then
1441 world.apply_right_angles
1442 end
1443 end
1444 end
1445
1446 on_customize (
1447 a_x: INTEGER;
1448 a_y: INTEGER;
1449 a_button: INTEGER;
1450 a_x_tilt: DOUBLE;
1451 a_y_tilt: DOUBLE;
1452 a_pressure: DOUBLE;
1453 a_screen_x: INTEGER;
1454 a_screen_y: INTEGER) is
1455 -- The user clicked on customizable toolbar.
1456 local
1457 mi: EV_MENU_ITEM
1458 do
1459 if a_button = 3 then
1460 create toolbar_menu
1461 create mi.make_with_text ("Customize...")
1462 toolbar_menu.extend (mi)
1463 mi.select_actions.extend (agent customize_toolbar)
1464 toolbar_menu.show
1465 end
1466 end
1467
1468 on_history_do_command is
1469 -- An undoable command has been done.
1470 -- Enable `undo_cmd'.
1471 do
1472 if not history.undo_exhausted then
1473 undo_cmd.enable_sensitive
1474 end
1475 end
1476
1477 on_history_undo_command is
1478 -- An undoable command has been undone.
1479 -- Enable `redo_cmd'.
1480 do
1481 if not history.redo_exhausted then
1482 redo_cmd.enable_sensitive
1483 end
1484 end
1485
1486 on_history_undo_exhausted is
1487 -- There is no more actions to undo.
1488 -- Disable `undo_cmd'.
1489 do
1490 undo_cmd.disable_sensitive
1491 ensure
1492 undo_cmd_not_sensitive: not undo_cmd.is_sensitive
1493 end
1494
1495 on_history_redo_exhausted is
1496 -- There is no more actions to redo.
1497 -- Disable `redo_cmd'.
1498 do
1499 redo_cmd.disable_sensitive
1500 ensure
1501 redo_cmd_not_sensitive: not redo_cmd.is_sensitive
1502 end
1503
1504 on_zoom_level_select is
1505 -- User selected a new zoom level.
1506 local
1507 level_text: STRING
1508 level, scale_factor: DOUBLE
1509 old_scale: INTEGER
1510 new_scale: INTEGER
1511 do
1512 level_text := zoom_selector.selected_item.text.twin
1513 level_text.keep_head (level_text.count - 1)
1514 check
1515 level_text_is_integer: level_text.is_integer
1516 end
1517 level := level_text.to_integer / 100
1518 scale_factor := level / world.scale_factor
1519 old_scale := (world.scale_factor * 100).rounded
1520 world.scale (scale_factor)
1521 crop_diagram
1522 new_scale := (world.scale_factor * 100).rounded
1523 restart_force_directed
1524 history.register_named_undoable (
1525 interface_names.t_diagram_zoom_cmd + " " + level_text.out + "%%",
1526 [<<agent world.scale (scale_factor), agent crop_diagram, agent zoom_selector.show_as_text (new_scale), agent restart_force_directed>>],
1527 [<<agent world.scale (1/scale_factor), agent crop_diagram, agent zoom_selector.show_as_text (old_scale), agent restart_force_directed>>])
1528 end
1529
1530 on_view_changed is
1531 -- The user wants to switch to another view.
1532 local
1533 cancelled: BOOLEAN
1534 do
1535 if not cancelled then--and not view_selector.is_empty then
1536 reset_history
1537
1538 development_window.status_bar.display_message ("Loading diagram for " + view_selector.text)
1539 development_window.status_bar.reset_progress_bar_with_range (0 |..| 0)
1540
1541 if is_force_directed_used then
1542 disable_force_directed
1543 end
1544
1545 update_excluded_class_figures
1546 world_cell.disable_resize
1547 projector.disable_painting
1548
1549 world.retrieve_view (view_selector.text)
1550
1551 projector.enable_painting
1552 world_cell.enable_resize
1553 projector.full_project
1554 development_window.status_bar.reset
1555 crop_diagram
1556
1557 if world.is_uml then
1558 if class_graph /= Void then
1559 reset_tool_bar_for_uml_class_view
1560 else
1561 reset_tool_bar_for_uml_cluster_view
1562 end
1563 else
1564 if class_graph /= Void then
1565 reset_tool_bar_for_class_view
1566 else
1567 reset_tool_bar_for_cluster_view
1568 end
1569 end
1570 reset_view_selector
1571 reset_tool_bar_toggles
1572 world.figure_change_end_actions.extend (agent on_figure_change_end)
1573 world.figure_change_start_actions.extend (agent on_figure_change_start)
1574 world.cluster_legend.move_actions.extend (agent on_cluster_legend_move)
1575 world.cluster_legend.pin_actions.extend (agent on_cluster_legend_pin)
1576 on_cluster_legend_pin
1577
1578 if world.is_right_angles then
1579 world.apply_right_angles
1580 end
1581 end
1582 rescue
1583 cancelled := True
1584 error_handler.error_list.wipe_out
1585 development_window.status_bar.reset
1586 projector.enable_painting
1587 world_cell.enable_resize
1588 clear_area
1589 is_rebuild_world_needed := True
1590 if is_force_directed_used then
1591 toggle_force_cmd.current_button.disable_select
1592 end
1593 retry
1594 end
1595
1596 on_text_edited (directly_edited: BOOLEAN) is
1597 -- Some text was inserted in the editor.
1598 -- If `directly_edited' is true, the user did.
1599 do
1600 if directly_edited then
1601 if has_diagram_edited_class then
1602 reset_history
1603 has_diagram_edited_class := False
1604 end
1605 else
1606 has_diagram_edited_class := True
1607 end
1608 end
1609
1610 on_item_removed (a_item: EB_WINDOW) is
1611 -- `a_item' has been removed.
1612 -- If it is parent development window, store diagram.
1613 do
1614 if a_item = development_window then
1615 store
1616 end
1617 end
1618
1619 feature {EB_DELETE_VIEW_COMMAND} -- View selector
1620
1621 remove_view (a_name: STRING) is
1622 -- Delete view of `a_name'.
1623 require
1624 a_name_not_void: a_name /= Void
1625 not_default: not a_name.has_substring ("DEFAULT")
1626 local
1627 cancelled: BOOLEAN
1628 do
1629 if not cancelled then
1630
1631 -- progress_dialog.set_title ("Loading view")
1632 -- progress_dialog.set_message ("Diagram for " + view_selector.text)
1633 -- progress_dialog.enable_cancel
1634 -- progress_dialog.show
1635
1636 if is_force_directed_used then
1637 disable_force_directed
1638 end
1639
1640 update_excluded_class_figures
1641 world_cell.disable_resize
1642 projector.disable_painting
1643
1644 world.remove_view (world.current_view)
1645
1646 reset_tool_bar_toggles
1647
1648 projector.enable_painting
1649 world_cell.enable_resize
1650 projector.full_project
1651 crop_diagram
1652
1653 if world.is_right_angles then
1654 world.apply_right_angles
1655 end
1656 view_selector.set_text (world.current_view)
1657 end
1658 rescue
1659 cancelled := True
1660 error_handler.error_list.wipe_out
1661 projector.enable_painting
1662 world_cell.enable_resize
1663 clear_area
1664 is_rebuild_world_needed := True
1665 if is_force_directed_used then
1666 toggle_force_cmd.current_button.disable_select
1667 end
1668 retry
1669 end
1670
1671 feature {EB_RESET_VIEW_COMMAND} -- Implementation
1672
1673 reset_current_view is
1674 -- Reset current view to default.
1675 do
1676 if class_graph /= Void then
1677 create_class_view (class_graph.center_class.class_i, False)
1678 else
1679 create_cluster_view (cluster_graph.center_cluster.group, False)
1680 end
1681 end
1682
1683 feature {EB_FIT_TO_SCREEN_COMMAND} -- Implementation
1684
1685 world_cell: EIFFEL_FIGURE_WORLD_CELL
1686 -- Cell showing the graph.
1687
1688 feature {EB_SHOW_LEGEND_COMMAND} -- Implementation
1689
1690 on_cluster_legend_pin is
1691 -- User pined `world'.`cluster_legend'.
1692 do
1693 cluster_legend_x := world.cluster_legend.point_x - projector.area_x
1694 cluster_legend_y := world.cluster_legend.point_y - projector.area_y
1695 end
1696
1697 feature -- Implementation
1698
1699 default_bon_horizontal_spacing: INTEGER is 25
1700 default_bon_vertical_spacing: INTEGER is 25
1701 default_uml_horizontal_spacing: INTEGER is 150
1702 default_uml_vertical_spacing: INTEGER is 150
1703 -- Default spacings used to layout generated figures.
1704
1705 feature {NONE} -- Implementation
1706
1707 default_subcluster_depth: INTEGER
1708 default_supercluster_depth: INTEGER
1709 default_client_depth: INTEGER
1710 default_supplier_depth: INTEGER
1711 default_ancestor_depth: INTEGER
1712 default_descendant_depth: INTEGER
1713
1714 retrieve_depth_preferences is
1715 -- Retrieve values for default depth from preferences.
1716 do
1717 default_subcluster_depth := preferences.diagram_tool_data.subcluster_depth
1718 default_supercluster_depth := preferences.diagram_tool_data.supercluster_depth
1719 default_client_depth := preferences.diagram_tool_data.client_depth
1720 default_supplier_depth := preferences.diagram_tool_data.supplier_depth
1721 default_ancestor_depth := preferences.diagram_tool_data.ancestor_depth
1722 default_descendant_depth := preferences.diagram_tool_data.descendant_depth
1723
1724 if class_graph /= Void then
1725 class_graph.set_descendant_depth (default_descendant_depth)
1726 class_graph.set_ancestor_depth (default_ancestor_depth)
1727 class_graph.set_supplier_depth (default_supplier_depth)
1728 class_graph.set_client_depth (default_client_depth)
1729 if class_graph.center_class /= Void then
1730 create_class_view (class_graph.center_class.class_i, False)
1731 end
1732 elseif cluster_graph /= Void then
1733 cluster_graph.set_subcluster_depth (default_subcluster_depth)
1734 cluster_graph.set_supercluster_depth (default_supercluster_depth)
1735 create_cluster_view (cluster_graph.center_cluster.group, False)
1736 end
1737 end
1738
1739 is_synchronization_needed: BOOLEAN
1740 -- Is synchronization needed when `Current' gets selected in the tabs?
1741
1742 is_right_angles_blocked: BOOLEAN
1743 -- Is not right angles applayed at force stop?
1744
1745 on_figure_change_start is
1746 -- User started to change position/shape of a figure.
1747 do
1748 is_right_angles_blocked := True
1749 end
1750
1751 on_figure_change_end is
1752 -- User finished to change position/shape of a figure.
1753 do
1754 is_right_angles_blocked := False
1755 if world.is_right_angles then
1756 world.apply_right_angles
1757 end
1758 end
1759
1760 on_scroll (value: INTEGER) is
1761 -- User scrolled scrollbars.
1762 local
1763 l_legend: EIFFEL_CLUSTER_LEGEND
1764 do
1765 if world.is_legend_shown and then world.cluster_legend.is_pined then
1766 l_legend := world.cluster_legend
1767 l_legend.set_point_position (projector.area_x + cluster_legend_x, projector.area_y + cluster_legend_y)
1768 end
1769 end
1770
1771 cluster_legend_x: INTEGER
1772 cluster_legend_y: INTEGER
1773 -- Position of pined cluster legend.
1774
1775 on_cluster_legend_move (x, y: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
1776 -- User moved `world'.`cluster_legend'.
1777 do
1778 cluster_legend_x := world.cluster_legend.point_x - projector.area_x
1779 cluster_legend_y := world.cluster_legend.point_y - projector.area_y
1780 end
1781
1782 has_diagram_edited_class: BOOLEAN
1783 -- Was a class edited through the Diagram.
1784 -- (Add remove feature, add remove inheritance link)
1785
1786 customize_toolbar is
1787 -- Customize diagram toolbar.
1788 do
1789 custom_toolbar.customize
1790 preferences.diagram_tool_data.save_diagram_toolbar (custom_toolbar)
1791 reset_tool_bar_toggles
1792 end
1793
1794 custom_toolbar: EB_TOOLBAR
1795 -- Part of toolbar that can be customized.
1796
1797 area: EV_DRAWING_AREA is
1798 -- Graphical surface displaying diagram.
1799 do
1800 Result := world_cell.drawing_area
1801 ensure
1802 Result_not_void: Result /= Void
1803 end
1804
1805 toolbar_menu: EV_MENU
1806 -- Popped up when user clicks left to the right of the toolbar.
1807
1808 on_class_drop (stone: CLASSI_STONE) is
1809 -- `stone' was dropped on an empty world.
1810 do
1811 if stone.is_valid then
1812 is_rebuild_world_needed := True
1813 tool.launch_stone (stone)
1814 end
1815 end
1816
1817 on_cluster_drop (stone: CLUSTER_STONE) is
1818 -- `stone' was dropped on an empty world
1819 do
1820 if stone.is_valid then
1821 is_rebuild_world_needed := True
1822 tool.launch_stone (stone)
1823 end
1824 end
1825
1826 reset_tool_bar_for_uml_class_view is
1827 -- Set toolbar for uml class view
1828 do
1829 reset_toolbar
1830
1831 change_color_cmd.disable_sensitive
1832 fill_cluster_cmd.disable_sensitive
1833 toggle_quality_cmd.disable_sensitive
1834 toggle_cluster_legend_cmd.disable_sensitive
1835 toggle_cluster_cmd.disable_sensitive
1836 end
1837
1838 reset_tool_bar_for_uml_cluster_view is
1839 -- Set toolbar for uml cluster view.
1840 do
1841 reset_tool_bar_for_uml_class_view
1842 fill_cluster_cmd.enable_sensitive
1843 toggle_cluster_cmd.enable_sensitive
1844 end
1845
1846 reset_tool_bar_for_class_view is
1847 -- Set toolbar for class_view.
1848 do
1849 reset_toolbar
1850
1851 remove_anchor_cmd.enable_sensitive
1852 toggle_cluster_legend_cmd.enable_sensitive
1853 change_color_cmd.enable_sensitive
1854 toggle_quality_cmd.enable_sensitive
1855
1856 fill_cluster_cmd.disable_sensitive
1857 toggle_cluster_cmd.disable_sensitive
1858 end
1859
1860 reset_tool_bar_for_cluster_view is
1861 -- Set toolbar for cluster_view.
1862 do
1863 reset_tool_bar_for_class_view
1864 fill_cluster_cmd.enable_sensitive
1865 toggle_cluster_cmd.enable_sensitive
1866 end
1867
1868 reset_toolbar is
1869 -- Set toolbar for all views.
1870 do
1871 zoom_selector.enable_sensitive
1872 create_class_cmd.enable_sensitive
1873 delete_cmd.enable_sensitive
1874 create_new_links_cmd.enable_sensitive
1875 trash_cmd.enable_sensitive
1876 link_tool_cmd.enable_sensitive
1877 toggle_inherit_cmd.enable_sensitive
1878 toggle_supplier_cmd.enable_sensitive
1879 toggle_labels_cmd.enable_sensitive
1880 select_depth_cmd.enable_sensitive
1881 if not history.undo_exhausted then
1882 undo_cmd.enable_sensitive
1883 else
1884 undo_cmd.disable_sensitive
1885 end
1886 history_cmd.enable_sensitive
1887 if not history.redo_exhausted then
1888 redo_cmd.enable_sensitive
1889 else
1890 redo_cmd.disable_sensitive
1891 end
1892 zoom_in_cmd.enable_sensitive
1893 zoom_out_cmd.enable_sensitive
1894 delete_view_cmd.enable_sensitive
1895 diagram_to_ps_cmd.enable_sensitive
1896 toggle_uml_cmd.enable_sensitive
1897 fit_to_screen_cmd.enable_sensitive
1898 reset_view_cmd.enable_sensitive
1899 view_selector.enable_sensitive
1900 view_menu_button.enable_sensitive
1901 toggle_force_cmd.enable_sensitive
1902 force_settings_cmd.enable_sensitive
1903 end
1904
1905 project_close_agent: PROCEDURE [ANY, TUPLE]
1906 -- The agent that is called when the project is closed.
1907
1908 pixmaps: EB_SHARED_PIXMAPS is
1909 once
1910 create Result
1911 end
1912
1913 excluded_class_figures: HASH_TABLE [STRING, STRING]
1914 -- Classes never present on the diagram (unless `ignore_excluded_figures' is False).
1915
1916 default_excluded_class_figures: ARRAY [STRING] is
1917 -- Default settings for `excluded_class_figures'.
1918 once
1919 Result := <<
1920 "INTEGER", "BOOLEAN", "STRING",
1921 "CHARACTER", "REAL", "DOUBLE"
1922 >>
1923 end
1924
1925 feature {EB_CONTEXT_TOOL, EIFFEL_WORLD} -- XML Output
1926
1927 store is
1928 -- Freeze state of `Current'.
1929 local
1930 ptf: RAW_FILE
1931 retried: BOOLEAN
1932 do
1933 if eiffel_project.initialized then
1934 if
1935 (class_graph /= Void and then class_graph.center_class /= Void) or else
1936 (cluster_graph /= Void and then cluster_graph.center_cluster /= Void)
1937 then
1938 if not retried then
1939 create ptf.make (diagram_file_name (graph))
1940 if ptf.exists then
1941 ptf.open_read
1942 else
1943 ptf.open_write
1944 end
1945 world.store (ptf)
1946 ptf.close
1947 end
1948 end
1949 end
1950 rescue
1951 retried := True
1952 retry
1953 end
1954
1955 diagram_file_name (esg: ES_GRAPH): FILE_NAME is
1956 -- Location of XML file.
1957 require
1958 diagram_exists: esg /= Void
1959 local
1960 clg: ES_CLUSTER_GRAPH
1961 cg: ES_CLASS_GRAPH
1962 l_class: CLASS_I
1963 do
1964 clg ?= esg
1965 if clg = Void then
1966 cg ?= esg
1967 check
1968 is_class_graph: cg /= Void
1969 end
1970 create Result.make_from_string (Eiffel_system.context_diagram_path)
1971 l_class := cg.center_class.class_i
1972 Result.extend (id_of_class (l_class.config_class))
1973 else
1974 create Result.make_from_string (Eiffel_system.context_diagram_path)
1975 Result.extend (clg.center_cluster.group_id)
1976 end
1977 Result.add_extension ("xml")
1978 end
1979
1980 is_valide_diagram_file (f: RAW_FILE): BOOLEAN is
1981 -- Is `f' referencing a valid diagram file?
1982 require
1983 f_not_void: f /= Void
1984 local
1985 is_retried: BOOLEAN
1986 do
1987 if not is_retried then
1988 if f.exists then
1989 f.open_read
1990 if f.readable then
1991 Result := True
1992 end
1993 end
1994 else
1995 Result := False
1996 end
1997 rescue
1998 is_retried := True
1999 retry
2000 end
2001
2002 reset_tool_bar_toggles is
2003 -- Set toolbar toggle buttons states according to worlds settings.
2004 do
2005 if world.is_client_supplier_links_shown then
2006 toggle_supplier_cmd.enable_select
2007 else
2008 toggle_supplier_cmd.disable_select
2009 end
2010 if world.is_inheritance_links_shown then
2011 toggle_inherit_cmd.enable_select
2012 else
2013 toggle_inherit_cmd.disable_select
2014 end
2015 if world.is_cluster_shown then
2016 toggle_cluster_cmd.enable_select
2017 else
2018 toggle_cluster_cmd.disable_select
2019 end
2020 if world.is_labels_shown then
2021 toggle_labels_cmd.enable_select
2022 else
2023 toggle_labels_cmd.disable_select
2024 end
2025 if world.is_high_quality then
2026 toggle_quality_cmd.enable_select
2027 else
2028 toggle_quality_cmd.disable_select
2029 end
2030 if world.is_legend_shown then
2031 toggle_cluster_legend_cmd.enable_select
2032 else
2033 toggle_cluster_legend_cmd.disable_select
2034 end
2035 if world.is_right_angles then
2036 link_tool_cmd.enable_select
2037 else
2038 link_tool_cmd.disable_select
2039 end
2040 if world.is_uml then
2041 toggle_uml_cmd.enable_select
2042 else
2043 toggle_uml_cmd.disable_select
2044 end
2045
2046 zoom_selector.show_as_text ((world.scale_factor * 100).rounded)
2047 end
2048
2049 feature {NONE} -- Implementation keyboard shortcuts
2050
2051 on_key_pressed (a_key: EV_KEY) is
2052 -- A key was pressed while focus is on `area'.
2053 local
2054 accelerators: LIST [EV_ACCELERATOR]
2055 l_item: EV_ACCELERATOR
2056 alt_pressed, ctrl_pressed, shift_pressed: BOOLEAN
2057 do
2058 accelerators := shortcut_table.item (a_key.code)
2059 if accelerators /= Void then
2060 alt_pressed := ev_application.alt_pressed
2061 ctrl_pressed := ev_application.ctrl_pressed
2062 shift_pressed := ev_application.shift_pressed
2063 from
2064 accelerators.start
2065 until
2066 accelerators.after
2067 loop
2068 l_item := accelerators.item
2069 if
2070 l_item.alt_required = alt_pressed and then
2071 l_item.control_required = ctrl_pressed and then
2072 l_item.shift_required = shift_pressed
2073 then
2074 l_item.actions.call (Void)
2075 end
2076 accelerators.forth
2077 end
2078 end
2079 end
2080
2081 shortcut_table: HASH_TABLE [LIST[EV_ACCELERATOR], INTEGER]
2082 -- List of accelerators and key codes.
2083
2084 extend_shortcut_table (an_accelerator: EV_ACCELERATOR) is
2085 -- Add `an_accelerator' to `shortcut_table'.
2086 require
2087 an_accelerator_exists: an_accelerator /= Void
2088 local
2089 l_list: LIST [EV_ACCELERATOR]
2090 l_code: INTEGER
2091 do
2092 l_code := an_accelerator.key.code
2093 l_list := shortcut_table.item (l_code)
2094 if l_list /= Void then
2095 l_list.extend (an_accelerator)
2096 else
2097 create {ARRAYED_LIST [EV_ACCELERATOR]} l_list.make (1)
2098 l_list.extend (an_accelerator)
2099 shortcut_table.put (l_list, l_code)
2100 end
2101 end
2102
2103 invariant
2104 world_cell_not_void: world_cell /= Void
2105 area_not_void: area /= Void
2106 area_as_widget_not_void: area_as_widget /= Void
2107 projector_not_void: projector /= Void
2108 shortcut_table_not_void: shortcut_table /= Void
2109
2110 indexing
2111 copyright: "Copyright (c) 1984-2006, Eiffel Software"
2112 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
2113 licensing_options: "http://www.eiffel.com/licensing"
2114 copying: "[
2115 This file is part of Eiffel Software's Eiffel Development Environment.
2116
2117 Eiffel Software's Eiffel Development Environment is free
2118 software; you can redistribute it and/or modify it under
2119 the terms of the GNU General Public License as published
2120 by the Free Software Foundation, version 2 of the License
2121 (available at the URL listed under "license" above).
2122
2123 Eiffel Software's Eiffel Development Environment is
2124 distributed in the hope that it will be useful, but
2125 WITHOUT ANY WARRANTY; without even the implied warranty
2126 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2127 See the GNU General Public License for more details.
2128
2129 You should have received a copy of the GNU General Public
2130 License along with Eiffel Software's Eiffel Development
2131 Environment; if not, write to the Free Software Foundation,
2132 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2133 ]"
2134 source: "[
2135 Eiffel Software
2136 356 Storke Road, Goleta, CA 93117 USA
2137 Telephone 805-685-1006, Fax 805-685-6869
2138 Website http://www.eiffel.com
2139 Customer support http://support.eiffel.com
2140 ]"
2141
2142 end -- class EB_CONTEXT_EDITOR
2143

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23