/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/eiffel_cluster_diagram.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/eiffel_cluster_diagram.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62171 - (show annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 4 months ago) by larryl
File size: 38713 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Objects that is view for a CLUSTER_GRAPH"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: ""
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EIFFEL_CLUSTER_DIAGRAM
11
12 inherit
13 EIFFEL_WORLD
14 redefine
15 default_create,
16 model,
17 xml_node_name,
18 xml_element,
19 set_with_xml_element,
20 recycle
21 end
22
23 SHARED_ERROR_HANDLER
24 undefine
25 default_create
26 end
27
28 SHARED_WORKBENCH
29 export
30 {NONE} all
31 undefine
32 default_create
33 end
34
35 EB_CLUSTER_MANAGER_OBSERVER
36 undefine
37 default_create
38 redefine
39 on_class_added,
40 on_cluster_added,
41 on_class_moved,
42 on_cluster_changed
43 end
44
45 create
46 default_create
47
48 create {EIFFEL_CLUSTER_DIAGRAM}
49 make_filled
50
51 feature {NONE} -- Initialization
52
53 default_create is
54 -- Create an EIFFEL_CLUSTER_DIAGRAM.
55 do
56 Precursor {EIFFEL_WORLD}
57 drop_actions.extend (agent on_class_drop)
58 drop_actions.extend (agent on_group_drop)
59 drop_actions.extend (agent on_new_class_drop)
60 drop_actions.set_veto_pebble_function (agent veto_function)
61 manager.add_observer (Current)
62 end
63
64 feature -- Access
65
66 model: ES_CLUSTER_GRAPH
67 -- Model for `Current'.
68
69 feature -- Store/Retrive
70
71 xml_node_name: STRING is
72 -- Name of the node returned by `xml_element'.
73 do
74 Result := "EIFFEL_CLUSTER_DIAGRAM"
75 end
76
77 xml_element (node: XM_ELEMENT): XM_ELEMENT is
78 -- Xml node representing `Current's state.
79 do
80 node.add_attribute ("NAME", xml_namespace, current_view)
81 node.put_last (Xml_routines.xml_node (node, "SUBCLUSTER_DEPTH", model.subcluster_depth.out))
82 node.put_last (Xml_routines.xml_node (node, "SUPERCLUSTER_DEPTH", model.supercluster_depth.out))
83 node.put_last (xml_routines.xml_node (node, "CENTER_CLUSTER_ID", model.center_cluster.cluster_id))
84 Result := Precursor {EIFFEL_WORLD} (node)
85 end
86
87 set_with_xml_element (node: XM_ELEMENT) is
88 -- Retrive state from `node'.
89 local
90 l_cluster_id: STRING
91 esc: ES_CLUSTER
92 do
93 node.forth
94 model.set_subcluster_depth (xml_routines.xml_integer (node, "SUBCLUSTER_DEPTH"))
95 model.set_supercluster_depth (xml_routines.xml_integer (node, "SUPERCLUSTER_DEPTH"))
96 l_cluster_id := xml_routines.xml_string (node, "CENTER_CLUSTER_ID")
97 Precursor {EIFFEL_WORLD} (node)
98
99 esc := model.cluster_of_id (l_cluster_id)
100 model.set_center_cluster (esc)
101 end
102
103 feature -- Element change
104
105 recycle is
106 -- Free `Current's resources.
107 do
108 Precursor {EIFFEL_WORLD}
109 drop_actions.prune_all (agent on_class_drop)
110 drop_actions.prune_all (agent on_group_drop)
111 drop_actions.prune_all (agent on_new_class_drop)
112 manager.remove_observer (Current)
113 end
114
115 feature -- Status
116
117 classes_in_same_scope (a_source, a_target: ES_CLASS): BOOLEAN is
118 -- Are `a_source' and `a_target' in the same scope.
119 require
120 a_source_not_void: a_source /= Void
121 a_target_not_void: a_target /= Void
122 local
123 l_classes: ARRAYED_LIST [ES_CLASS]
124 do
125 l_classes := model.possible_linkable_node (a_source)
126 if l_classes.has (a_target) then
127 Result := True
128 end
129 end
130
131 feature {EB_DIAGRAM_HTML_GENERATOR} -- Load view
132
133 change_view (view_name: STRING; file_name: STRING) is
134 -- Change view to `view_name' load from `file_name' without saving `Current'.
135 local
136 f: RAW_FILE
137 do
138 current_view := view_name
139 create f.make (file_name)
140 if f.exists then
141 f.open_read
142 if f.readable then
143 retrieve (f)
144 end
145 end
146 end
147
148 feature {NONE} -- Implementation
149
150 on_group_drop (a_stone: CLUSTER_STONE) is
151 -- Add to diagram.
152 local
153 l_cluster: CONF_CLUSTER
154 l_lib: CONF_LIBRARY
155 do
156 if a_stone.is_valid then
157 if a_stone.group.is_cluster then
158 l_cluster ?= a_stone.group
159 on_cluster_drop (l_cluster)
160 elseif a_stone.group.is_library then
161 l_lib ?= a_stone.group
162 on_library_drop (l_lib)
163 end
164 end
165 end
166
167 on_cluster_drop (a_cluster: CONF_CLUSTER) is
168 local
169 l_clusters: ARRAYED_LIST [ES_CLUSTER]
170 parent: ES_CLUSTER
171 l_classes: HASH_TABLE [CONF_CLASS, STRING]
172 l_cluster, es_cluster : ES_CLUSTER
173 l_status_bar: EB_DEVELOPMENT_WINDOW_STATUS_BAR
174 nr_of_items: INTEGER
175 cluster_fig, parent_fig: EIFFEL_CLUSTER_FIGURE
176 cluster_added: BOOLEAN
177 remove_classes: LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]]
178 remove_links: LIST [ES_ITEM]
179 l_array_redo, l_array_undo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
180 do
181 l_clusters := parents_of_group (a_cluster)
182
183 context_editor.projector.disable_painting
184 context_editor.disable_resize
185 context_editor.update_excluded_class_figures
186 l_status_bar := window_status_bar
187 l_classes := a_cluster.classes
188 if l_classes = Void then
189 create l_classes.make (0)
190 end
191 l_status_bar.progress_bar.set_value (0)
192 l_status_bar.display_message ("Including Cluster: Adding Classes into Cluster")
193
194 if not l_clusters.is_empty and any_clusters_needed (l_clusters) then
195 nr_of_items := l_classes.count * l_clusters.count
196 l_status_bar.progress_bar.reset_with_range (0 |..| nr_of_items)
197 create l_array_redo.make (5)
198 create l_array_undo.make (5)
199 from
200 l_clusters.start
201 until
202 l_clusters.after
203 loop
204 cluster_added := False
205 parent := l_clusters.item
206 parent_fig ?= figure_from_model (parent)
207 l_cluster := parent.sub_cluster_of (a_cluster)
208 if parent.is_needed_on_diagram and then l_cluster = Void then
209 create es_cluster.make (a_cluster)
210 model.add_cluster (es_cluster)
211 parent.extend (es_cluster)
212 model.add_children_relations (es_cluster, parent)
213 add_classes_of_cluster (es_cluster, True, True)
214 cluster_fig ?= figure_from_model (es_cluster)
215 cluster_fig.set_port_position (parent_fig.port_x, parent_fig.port_y)
216
217 check
218 fig_inserted: cluster_fig /= Void
219 end
220 cluster_added := True
221 context_editor.layout.layout_cluster (cluster_fig, 1)
222 elseif parent.is_needed_on_diagram and then not l_cluster.is_needed_on_diagram then
223 add_classes_of_cluster (l_cluster, False, True)
224 model.add_children_relations (l_cluster, parent)
225 cluster_fig ?= figure_from_model (l_cluster)
226 cluster_fig.set_port_position (parent_fig.port_x, parent_fig.port_y)
227 check
228 fig_inserted: cluster_fig /= Void
229 end
230 cluster_added := True
231 context_editor.layout.layout_cluster (cluster_fig, 1)
232 else
233 l_status_bar.progress_bar.set_value (l_status_bar.progress_bar.value + l_classes.count)
234 end
235 if cluster_added then
236 update_cluster_legend
237 remove_classes := classes_to_remove_in_cluster (es_cluster)
238 remove_links := links_to_remove_in_classes (remove_classes)
239 l_array_redo.extend (agent reinclude_cluster (cluster_fig, remove_links, remove_classes))
240 l_array_undo.extend (agent remove_cluster_virtual (cluster_fig, remove_links, remove_classes))
241 l_array_redo.extend (agent update_cluster_legend)
242 l_array_undo.extend (agent update_cluster_legend)
243 end
244 l_clusters.forth
245 end
246 if not l_array_redo.is_empty and then not l_array_undo.is_empty then
247 context_editor.history.register_named_undoable (interface_names.t_diagram_include_cluster_cmd (a_cluster.name),
248 [l_array_redo], [l_array_undo])
249 end
250 else
251 nr_of_items := l_classes.count
252 l_status_bar.progress_bar.reset_with_range (0 |..| nr_of_items)
253 check_and_add_on_top (a_cluster, False)
254 end
255
256 l_status_bar.reset
257 context_editor.enable_resize
258 context_editor.projector.enable_painting
259 update
260
261 if is_right_angles then
262 apply_right_angles
263 end
264 context_editor.projector.full_project
265 end
266
267 on_library_drop (a_lib: CONF_LIBRARY) is
268 local
269 l_clusters: ARRAYED_LIST [ES_CLUSTER]
270 parent: ES_CLUSTER
271 es_cluster : ES_CLUSTER
272 cluster_fig, parent_fig: EIFFEL_CLUSTER_FIGURE
273 cluster_added: BOOLEAN
274 remove_classes: LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]]
275 remove_links: LIST [ES_ITEM]
276 l_array_redo, l_array_undo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
277 do
278 l_clusters := parents_of_group (a_lib)
279
280 context_editor.projector.disable_painting
281 context_editor.disable_resize
282 context_editor.update_excluded_class_figures
283
284 if not l_clusters.is_empty and then any_clusters_needed (l_clusters) then
285 create l_array_redo.make (5)
286 create l_array_undo.make (5)
287 from
288 l_clusters.start
289 until
290 l_clusters.after
291 loop
292 cluster_added := False
293 parent := l_clusters.item
294 if parent.is_needed_on_diagram then
295 parent_fig ?= figure_from_model (parent)
296 es_cluster := parent.sub_cluster_of (a_lib)
297 if es_cluster = Void then
298 create es_cluster.make (a_lib)
299 model.add_cluster (es_cluster)
300 parent.extend (es_cluster)
301 model.add_children_relations (es_cluster, parent)
302 cluster_fig ?= figure_from_model (es_cluster)
303 cluster_fig.set_port_position (parent_fig.port_x, parent_fig.port_y)
304
305 check
306 fig_inserted: cluster_fig /= Void
307 end
308 cluster_added := True
309 context_editor.layout.layout_cluster (cluster_fig, 1)
310 elseif not es_cluster.is_needed_on_diagram then
311 es_cluster.enable_needed_on_diagram
312 enable_all_links (es_cluster)
313 model.add_children_relations (es_cluster, parent)
314 cluster_fig ?= figure_from_model (es_cluster)
315 cluster_fig.set_port_position (parent_fig.port_x, parent_fig.port_y)
316 check
317 fig_inserted: cluster_fig /= Void
318 end
319 cluster_added := True
320 context_editor.layout.layout_cluster (cluster_fig, 1)
321 end
322 if cluster_added then
323 update_cluster_legend
324 remove_classes := classes_to_remove_in_cluster (es_cluster)
325 remove_links := links_to_remove_in_classes (remove_classes)
326 l_array_redo.extend (agent reinclude_cluster (cluster_fig, remove_links, remove_classes))
327 l_array_undo.extend (agent remove_cluster_virtual (cluster_fig, remove_links, remove_classes))
328 l_array_redo.extend (agent update_cluster_legend)
329 l_array_undo.extend (agent update_cluster_legend)
330 end
331 end
332 l_clusters.forth
333 end
334 if not l_array_redo.is_empty and then not l_array_undo.is_empty then
335 context_editor.history.register_named_undoable (interface_names.t_diagram_include_library_cmd (a_lib.name),
336 [l_array_redo], [l_array_undo])
337 end
338 else
339 check_and_add_on_top (a_lib, True)
340 end
341
342 context_editor.enable_resize
343 context_editor.projector.enable_painting
344 update
345
346 if is_right_angles then
347 apply_right_angles
348 end
349 context_editor.projector.full_project
350 end
351
352 on_class_drop (a_stone: CLASSI_STONE) is
353 -- `a_stone' was dropped on `Current'
354 local
355 l_class_fig_stone: CLASSI_FIGURE_STONE
356 do
357 if a_stone.is_valid then
358 l_class_fig_stone ?= a_stone
359 is_dropped_on_diagram := True
360 if l_class_fig_stone /= Void then
361 move_class (l_class_fig_stone.source, context_editor.pointer_position.x, context_editor.pointer_position.y)
362 else
363 add_to_diagram (a_stone.class_i)
364 end
365 is_dropped_on_diagram := False
366 end
367 end
368
369 on_class_added (a_class: CLASS_I) is
370 -- `a_class' was added to the system.
371 do
372 if not is_dropped_on_diagram then
373 add_to_diagram (a_class)
374 end
375 end
376
377 on_cluster_added (a_cluster: CLUSTER_I) is
378 -- `a_cluster' was added to the system.
379 local
380 parent, es_cluster: ES_CLUSTER
381 parent_fig, cluster_fig: EG_CLUSTER_FIGURE
382 l_clusters: ARRAYED_LIST [ES_CLUSTER]
383 l_array_redo, l_array_undo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
384 do
385 l_clusters := parents_of_group (a_cluster)
386 if not l_clusters.is_empty then
387 create l_array_redo.make (5)
388 create l_array_undo.make (5)
389 from
390 l_clusters.start
391 until
392 l_clusters.after
393 loop
394 parent := l_clusters.item
395 parent_fig ?= figure_from_model (parent)
396 create es_cluster.make (a_cluster)
397 model.add_cluster (es_cluster)
398 parent.extend (es_cluster)
399 update_cluster_legend
400 cluster_fig ?= figure_from_model (es_cluster)
401 cluster_fig.set_port_position (parent_fig.port_x, parent_fig.port_y)
402 l_array_redo.extend (agent es_cluster.enable_needed_on_diagram)
403 l_array_undo.extend (agent es_cluster.disable_needed_on_diagram)
404 l_array_redo.extend (agent update_cluster_legend)
405 l_array_undo.extend (agent update_cluster_legend)
406 l_clusters.forth
407 end
408 if not l_array_redo.is_empty and then not l_array_undo.is_empty then
409 context_editor.history.register_named_undoable (interface_names.t_diagram_include_cluster_cmd (a_cluster.cluster_name),
410 [l_array_redo], [l_array_undo])
411 end
412 else
413 check_and_add_on_top (a_cluster, False)
414 end
415 update
416 end
417
418 on_new_class_drop (a_stone: CREATE_CLASS_STONE) is
419 -- `a_stone' was dropped on `Current'
420 -- Display create class dialog and add to diagram.
421 local
422 dial: EB_CREATE_CLASS_DIALOG
423 drop_x, drop_y: INTEGER
424 clf: EIFFEL_CLUSTER_FIGURE
425 l_cluster: CONF_CLUSTER
426 do
427 drop_x := context_editor.pointer_position.x
428 drop_y := context_editor.pointer_position.y
429 is_dropped_on_diagram := True
430 clf := top_cluster_at (Current, drop_x, drop_y)
431 create dial.make_default (context_editor.develop_window)
432 if clf /= Void then
433 l_cluster ?= clf.model.group
434 if l_cluster /= Void then
435 dial.preset_cluster (l_cluster)
436 end
437 end
438 dial.call_default
439 include_new_dropped_class (dial, drop_x, drop_y)
440 is_dropped_on_diagram := False
441 end
442
443 feature {NONE} -- Cluster manger observer
444
445 on_class_moved (a_class: CONF_CLASS; old_cluster: CONF_GROUP; old_path: STRING) is
446 -- `a_class' has been moved away from `old_cluster'.
447 -- `old_path' is old relative path in `old_group'
448 local
449 es_class: ES_CLASS
450 l_class_i: CLASS_I
451 new_cluster_i: CONF_CLUSTER
452 old_cluster_i: CONF_CLUSTER
453 l_clusters: ARRAYED_LIST [ES_CLUSTER]
454 l_cluster: ES_CLUSTER
455 l_classes: ARRAYED_LIST [ES_CLASS]
456 l_remove_links: LIST [ES_ITEM]
457 fig: EIFFEL_CLASS_FIGURE
458 l_array_redo, l_array_undo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
459 l_manager: EB_CLUSTERS
460 do
461 if not is_dropped_on_diagram then
462 l_class_i ?= a_class
463 check
464 l_class_i_not_void: l_class_i /= Void
465 end
466 new_cluster_i ?= l_class_i.group
467 old_cluster_i ?= old_cluster
468
469 l_classes := model.class_from_interface (l_class_i)
470 l_clusters := model.cluster_from_interface (l_class_i.group)
471
472 l_manager := manager
473 create l_array_redo.make (10)
474 create l_array_undo.make (10)
475 from
476 l_classes.start
477 until
478 l_classes.after
479 loop
480 es_class := l_classes.item
481 l_remove_links := es_class.needed_links
482 update_cluster_legend
483 fig ?= figure_from_model (es_class)
484 fig.request_update
485 l_remove_links := es_class.needed_links
486 l_array_redo.extend (agent remove_class_virtual (fig, l_remove_links))
487 l_array_redo.extend (agent update_cluster_legend)
488 l_array_undo.extend (agent reinclude_class (fig, l_remove_links, fig.x, fig.y))
489 l_array_undo.extend (agent update_cluster_legend)
490 l_classes.forth
491 end
492
493 from
494 l_clusters.start
495 until
496 l_clusters.after
497 loop
498 l_cluster := l_clusters.item
499 es_class := l_cluster.node_of (l_class_i)
500 if es_class = Void then
501 create es_class.make (l_class_i)
502 l_cluster.extend (es_class)
503 update_cluster_legend
504 fig ?= figure_from_model (es_class)
505 fig.request_update
506 l_remove_links := es_class.needed_links
507 l_array_redo.extend (agent reinclude_class (fig, l_remove_links, fig.x, fig.y))
508 l_array_undo.extend (agent remove_class_virtual (fig, l_remove_links))
509 l_array_redo.extend (agent update_cluster_legend)
510 l_array_undo.extend (agent update_cluster_legend)
511 elseif not es_class.is_needed_on_diagram then
512 es_class.enable_needed_on_diagram
513 enable_all_links (es_class)
514 if es_class.class_i.is_compiled then
515 model.add_ancestor_relations (es_class)
516 model.add_descendant_relations (es_class)
517 model.add_client_relations (es_class)
518 model.add_supplier_relations (es_class)
519 end
520 update_cluster_legend
521 fig ?= figure_from_model (es_class)
522 fig.request_update
523 l_remove_links := es_class.needed_links
524 l_array_redo.extend (agent reinclude_class (fig, l_remove_links, fig.x, fig.y))
525 l_array_undo.extend (agent remove_class_virtual (fig, l_remove_links))
526 l_array_redo.extend (agent update_cluster_legend)
527 l_array_undo.extend (agent update_cluster_legend)
528 end
529 l_clusters.forth
530 end
531
532 if not context_editor.history.is_redo_undoing then
533 l_array_redo.extend (agent l_manager.move_class (l_class_i.config_class, old_cluster_i, new_cluster_i, l_class_i.path))
534 l_array_undo.extend (agent l_manager.move_class (l_class_i.config_class, new_cluster_i, old_cluster_i, old_path))
535 context_editor.history.register_named_undoable (interface_names.t_diagram_move_class_cmd (l_class_i.name),
536 [l_array_redo], [l_array_undo])
537 end
538 end
539 end
540
541 on_cluster_changed (a_cluster: CLUSTER_I) is
542 -- `a_cluster' was renamed.
543 local
544 l_clusters: ARRAYED_LIST [ES_CLUSTER]
545 do
546 l_clusters := model.cluster_from_interface (a_cluster)
547 from
548 l_clusters.start
549 until
550 l_clusters.after
551 loop
552 l_clusters.item.set_name (a_cluster.cluster_name)
553 l_clusters.forth
554 end
555 end
556
557 feature {NONE} -- Implementation
558
559 window_status_bar: EB_DEVELOPMENT_WINDOW_STATUS_BAR is
560 -- Status bar of window
561 do
562 Result := context_editor.develop_window.status_bar
563 ensure
564 Result_not_void: Result /= Void
565 end
566
567 add_to_diagram (a_class: CLASS_I) is
568 -- Add `a_class' to diagram
569 local
570 parent: ES_CLUSTER
571 new_class: ES_CLASS
572 new_cluster: ES_CLUSTER
573 remove_links: LIST [ES_ITEM]
574 l_clusters: ARRAYED_LIST [ES_CLUSTER]
575 class_cluster: CONF_GROUP
576 es_cluster: ES_CLUSTER
577 fig: EIFFEL_CLASS_FIGURE
578 l_array_redo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
579 l_array_undo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
580 do
581 class_cluster := a_class.group
582 l_clusters := model.cluster_from_interface (class_cluster)
583 create l_array_redo.make (5)
584 create l_array_undo.make (5)
585 if not l_clusters.is_empty then
586 from
587 l_clusters.start
588 until
589 l_clusters.after
590 loop
591 es_cluster := l_clusters.item
592 if not es_cluster.is_needed_on_diagram then
593 es_cluster.enable_needed_on_diagram
594 l_array_redo.extend (agent es_cluster.enable_needed_on_diagram)
595 l_array_undo.extend (agent es_cluster.disable_needed_on_diagram)
596 end
597 new_class := es_cluster.node_of (a_class)
598 if new_class = Void then
599 create new_class.make (a_class)
600 es_cluster.extend (new_class)
601 model.add_node_relations (new_class)
602 update_cluster_legend
603 fig ?= figure_from_model (new_class)
604 fig.request_update
605 remove_links := new_class.needed_links
606 l_array_redo.extend (agent reinclude_class (fig, remove_links, fig.x, fig.y))
607 l_array_undo.extend (agent remove_class_virtual (fig, remove_links))
608 l_array_redo.extend (agent update_cluster_legend)
609 l_array_undo.extend (agent update_cluster_legend)
610 elseif not new_class.is_needed_on_diagram then
611 new_class.enable_needed_on_diagram
612 enable_all_links (new_class)
613 model.add_node_relations (new_class)
614 update_cluster_legend
615 fig ?= figure_from_model (new_class)
616 fig.request_update
617 remove_links := new_class.needed_links
618 l_array_redo.extend (agent reinclude_class (fig, remove_links, fig.x, fig.y))
619 l_array_undo.extend (agent remove_class_virtual (fig, remove_links))
620 l_array_redo.extend (agent update_cluster_legend)
621 l_array_undo.extend (agent update_cluster_legend)
622 end
623 l_clusters.forth
624 end
625 else
626 l_clusters := parents_of_group (class_cluster)
627 if not l_clusters.is_empty then
628 from
629 l_clusters.start
630 until
631 l_clusters.after
632 loop
633 parent := l_clusters.item
634 if not parent.is_needed_on_diagram then
635 parent.enable_needed_on_diagram
636 l_array_redo.extend (agent parent.enable_needed_on_diagram)
637 l_array_undo.extend (agent parent.disable_needed_on_diagram)
638 end
639 create es_cluster.make (class_cluster)
640 parent.extend (es_cluster)
641 model.add_cluster (es_cluster)
642 update_cluster_legend
643 l_array_redo.extend (agent es_cluster.enable_needed_on_diagram)
644 l_array_undo.extend (agent es_cluster.disable_needed_on_diagram)
645 l_array_redo.extend (agent update_cluster_legend)
646 l_array_undo.extend (agent update_cluster_legend)
647
648 create new_class.make (a_class)
649 es_cluster.extend (new_class)
650 model.add_node_relations (new_class)
651 update_cluster_legend
652 fig ?= figure_from_model (new_class)
653 fig.request_update
654 remove_links := new_class.needed_links
655 l_array_redo.extend (agent reinclude_class (fig, remove_links, fig.x, fig.y))
656 l_array_undo.extend (agent remove_class_virtual (fig, remove_links))
657 l_array_redo.extend (agent update_cluster_legend)
658 l_array_undo.extend (agent update_cluster_legend)
659 l_clusters.forth
660 end
661 else
662 create new_cluster.make (class_cluster)
663 model.add_cluster (new_cluster)
664 l_array_redo.extend (agent parent.enable_needed_on_diagram)
665 l_array_undo.extend (agent parent.disable_needed_on_diagram)
666
667 create new_class.make (a_class)
668 new_cluster.extend (new_class)
669 model.add_node_relations (new_class)
670 update_cluster_legend
671 fig ?= figure_from_model (new_class)
672 fig.request_update
673 remove_links := new_class.needed_links
674 l_array_redo.extend (agent reinclude_class (fig, remove_links, fig.x, fig.y))
675 l_array_undo.extend (agent remove_class_virtual (fig, remove_links))
676 l_array_redo.extend (agent update_cluster_legend)
677 l_array_undo.extend (agent update_cluster_legend)
678 l_clusters.forth
679 end
680 end
681 if not l_array_redo.is_empty and then not l_array_undo.is_empty then
682 context_editor.history.register_named_undoable (interface_names.t_Diagram_include_class_cmd (a_class.name),
683 [l_array_redo], [l_array_undo])
684 end
685 if is_right_angles then
686 apply_right_angles
687 end
688 end
689
690 move_class (a_fig: EIFFEL_CLASS_FIGURE; drop_x, drop_y: INTEGER) is
691 --
692 local
693 dropped_on_cluster: EIFFEL_CLUSTER_FIGURE
694 fig: EIFFEL_CLASS_FIGURE
695 remove_links: LIST [ES_ITEM]
696 new_cluster_i, old_cluster_i: CONF_CLUSTER
697 l_manager: EB_CLUSTERS
698 l_clusters: ARRAYED_LIST [ES_CLUSTER]
699 l_cluster : ES_CLUSTER
700 l_classes: ARRAYED_LIST [ES_CLASS]
701 l_class_i: CLASS_I
702 es_class: ES_CLASS
703 l_array_redo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
704 l_array_undo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
705 l_old_path: STRING
706 do
707 dropped_on_cluster := top_cluster_at (Current, drop_x, drop_y)
708 if dropped_on_cluster /= Void then
709 l_cluster := dropped_on_cluster.model
710 l_class_i := a_fig.model.class_i
711 l_old_path := l_class_i.config_class.path
712 if l_cluster /= Void and
713 l_cluster.group.is_cluster and then
714 (l_cluster.group.classes = Void or else
715 not l_cluster.group.classes.has (l_class_i.name))
716 then
717 l_clusters := model.cluster_from_interface (l_cluster.group)
718 l_classes := model.class_from_interface (l_class_i)
719 new_cluster_i ?= l_cluster.group
720 old_cluster_i ?= l_class_i.group
721 l_manager := manager
722 create l_array_redo.make (10)
723 create l_array_undo.make (10)
724 from
725 l_classes.start
726 until
727 l_classes.after
728 loop
729 es_class := l_classes.item
730 fig ?= figure_from_model (es_class)
731 remove_links := es_class.needed_links
732 remove_class_virtual (fig, remove_links)
733 update_cluster_legend
734 l_array_redo.extend (agent remove_class_virtual (fig, remove_links))
735 l_array_redo.extend (agent update_cluster_legend)
736 l_array_undo.extend (agent reinclude_class (fig, remove_links, fig.x, fig.y))
737 l_array_undo.extend (agent update_cluster_legend)
738 l_classes.forth
739 end
740
741 from
742 l_clusters.start
743 until
744 l_clusters.after
745 loop
746 l_cluster := l_clusters.item
747 es_class := l_cluster.node_of (l_class_i)
748 if es_class = Void then
749 create es_class.make (l_class_i)
750 l_cluster.extend (es_class)
751 update_cluster_legend
752 fig ?= figure_from_model (es_class)
753 fig.request_update
754 remove_links := es_class.needed_links
755 l_array_redo.extend (agent reinclude_class (fig, remove_links, fig.x, fig.y))
756 l_array_undo.extend (agent remove_class_virtual (fig, remove_links))
757 l_array_redo.extend (agent update_cluster_legend)
758 l_array_undo.extend (agent update_cluster_legend)
759 elseif not es_class.is_needed_on_diagram then
760 es_class.enable_needed_on_diagram
761 enable_all_links (es_class)
762 model.add_node_relations (es_class)
763 update_cluster_legend
764 fig ?= figure_from_model (es_class)
765 fig.request_update
766 remove_links := es_class.needed_links
767 l_array_redo.extend (agent reinclude_class (fig, remove_links, fig.x, fig.y))
768 l_array_undo.extend (agent remove_class_virtual (fig, remove_links))
769 l_array_redo.extend (agent update_cluster_legend)
770 l_array_undo.extend (agent update_cluster_legend)
771 end
772 l_clusters.forth
773 end
774
775 l_manager.move_class (l_class_i.config_class, old_cluster_i, new_cluster_i, "")
776 if new_cluster_i.classes /= Void and then new_cluster_i.classes.has (l_class_i.name) then
777 l_array_redo.extend (agent l_manager.move_class (l_class_i.config_class, old_cluster_i, new_cluster_i, ""))
778 l_array_undo.extend (agent l_manager.move_class (l_class_i.config_class, new_cluster_i, old_cluster_i, l_old_path))
779 context_editor.history.register_named_undoable (interface_names.t_diagram_move_class_cmd (l_class_i.name),
780 [l_array_redo], [l_array_undo])
781 else
782 from
783 l_array_undo.start
784 until
785 l_array_undo.after
786 loop
787 l_array_undo.item.call ([])
788 l_array_undo.forth
789 end
790 end
791 end
792 end
793 end
794
795 classes_to_remove_in_cluster (a_cluster: ES_CLUSTER): LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]] is
796 -- All class figures in `a_cluster' that are needed on diagram plus ther positions.
797 local
798 l_linkables: LIST [EG_LINKABLE]
799 es_class: ES_CLASS
800 class_fig: EIFFEL_CLASS_FIGURE
801 do
802 from
803 create {ARRAYED_LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]]} Result.make (5)
804 l_linkables := a_cluster.linkables
805 until
806 l_linkables.after
807 loop
808 es_class ?= l_linkables.item
809 if es_class /= Void and then es_class.is_needed_on_diagram then
810 class_fig ?= figure_from_model (es_class)
811 if class_fig /= Void then
812 Result.extend ([class_fig, class_fig.port_x, class_fig.port_y])
813 end
814 end
815 l_linkables.forth
816 end
817 ensure
818 result_not_void: Result /= Void
819 end
820
821 links_to_remove_in_classes (a_classes: like classes_to_remove_in_cluster): LIST [ES_ITEM] is
822 -- All links to remove in `a_cluster'
823 require
824 a_classes_not_void: a_classes /= Void
825 local
826 fig: EIFFEL_CLASS_FIGURE
827 do
828 from
829 create {ARRAYED_LIST [ES_ITEM]}Result.make (a_classes.count * 2)
830 a_classes.start
831 until
832 a_classes.after
833 loop
834 fig ?= a_classes.item.item (1)
835 Result.append (fig.model.needed_links)
836 a_classes.forth
837 end
838 ensure
839 result_not_void: Result /= Void
840 end
841
842 is_dropped_on_diagram: BOOLEAN
843 -- Is a class added to a cluster dropped on diagram by user?
844
845 include_new_dropped_class (a_create_class_dialog: EB_CREATE_CLASS_DIALOG; a_x, a_y: INTEGER) is
846 -- Add `a_class' to the diagram if not already present.
847 require
848 a_create_class_dialog: a_create_class_dialog /= Void
849 local
850 a_class: CLASS_I
851 do
852 if not a_create_class_dialog.cancelled then
853 a_class := a_create_class_dialog.class_i
854 if a_class /= Void then
855 add_to_diagram (a_class)
856 end
857 end
858 end
859
860 top_cluster_at (a_group: EV_MODEL_GROUP; ax, ay: INTEGER): EIFFEL_CLUSTER_FIGURE is
861 -- Top cluster at `ax', `ay'. Void if none.
862 local
863 l_item: EIFFEL_CLUSTER_FIGURE
864 do
865 from
866 a_group.start
867 until
868 a_group.after
869 loop
870 l_item ?= a_group.item
871 if l_item /= Void and then l_item.model.is_needed_on_diagram
872 and then
873 (ax >= l_item.left and then ax <= l_item.right)
874 and then
875 (ay >= l_item.top and then ay <= l_item.bottom)
876 then
877 Result := top_cluster_at (l_item, ax, ay)
878 if Result = Void then
879 Result := l_item
880 end
881 end
882 a_group.forth
883 end
884 end
885
886 parents_of_group (a_cluster: CONF_GROUP): ARRAYED_LIST [ES_CLUSTER] is
887 -- Parents of `a_cluster', clusters and libs included
888 require
889 a_cluster_not_void: a_cluster /= Void
890 local
891 l_cluster: CONF_CLUSTER
892 l_lib: CONF_LIBRARY
893 l_libs: ARRAYED_LIST [CONF_LIBRARY]
894 do
895 l_cluster ?= a_cluster
896 l_lib ?= a_cluster
897 if l_cluster /= Void then
898 if l_cluster.parent /= Void then
899 Result := model.cluster_from_interface (l_cluster.parent)
900 else
901 create Result.make (5)
902 l_libs := l_cluster.target.used_in_libraries
903 if l_libs /= Void then
904 from
905 l_libs.start
906 until
907 l_libs.after
908 loop
909 Result.append (model.cluster_from_interface (l_libs.item))
910 l_libs.forth
911 end
912 end
913 end
914 elseif l_lib /= Void then
915 create Result.make (5)
916 l_libs := l_lib.target.used_in_libraries
917 if l_libs /= Void then
918 from
919 l_libs.start
920 until
921 l_libs.after
922 loop
923 Result.append (model.cluster_from_interface (l_libs.item))
924 l_libs.forth
925 end
926 end
927 else
928 check error: False end
929 end
930 ensure
931 Result_not_void: Result /= Void
932 end
933
934 add_classes_of_cluster (a_cluster: ES_CLUSTER; a_new_cluster: BOOLEAN; with_status_bar: BOOLEAN) is
935 -- Add classes of `a_cluster'
936 require
937 a_cluster_not_void: a_cluster /= Void
938 a_cluster_is_cluster: a_cluster.group.is_cluster
939 local
940 l_classes: HASH_TABLE [CONF_CLASS, STRING]
941 new_class: ES_CLASS
942 l_item: CLASS_I
943 a_status_bar: EB_DEVELOPMENT_WINDOW_STATUS_BAR
944 do
945 a_status_bar := window_status_bar
946 l_classes := a_cluster.group.classes
947 if a_new_cluster then
948 if l_classes /= Void then
949 from
950 l_classes.start
951 until
952 l_classes.after
953 loop
954 l_item ?= l_classes.item_for_iteration
955 check
956 l_item_not_void: l_item /= Void
957 end
958 if context_editor.ignore_excluded_figures or else not context_editor.is_excluded_in_preferences (l_item.name_in_upper) then
959 create new_class.make (l_item)
960 a_cluster.extend (new_class)
961 model.add_node_relations (new_class)
962 end
963 if with_status_bar then
964 a_status_bar.progress_bar.set_value (a_status_bar.progress_bar.value + 1)
965 end
966 l_classes.forth
967 end
968 end
969 elseif not a_cluster.is_needed_on_diagram then
970 a_cluster.enable_needed_on_diagram
971 enable_all_links (a_cluster)
972 if l_classes /= Void then
973 from
974 l_classes.start
975 until
976 l_classes.after
977 loop
978 l_item ?= l_classes.item_for_iteration
979 check
980 l_item_not_void: l_item /= Void
981 end
982 new_class := a_cluster.node_of (l_item)
983 if new_class = Void then
984 l_item ?= l_classes.item_for_iteration
985 if context_editor.ignore_excluded_figures or else not context_editor.is_excluded_in_preferences (l_item.name_in_upper) then
986 create new_class.make (l_item)
987 model.add_node (new_class)
988 model.add_node_relations (new_class)
989 a_cluster.extend (new_class)
990 end
991 else
992 l_item := new_class.class_i
993 if context_editor.ignore_excluded_figures or else not context_editor.is_excluded_in_preferences (l_item.name_in_upper) then
994 if not new_class.is_needed_on_diagram then
995 new_class.enable_needed_on_diagram
996 enable_all_links (new_class)
997 model.add_node_relations (new_class)
998 end
999 if not a_cluster.has (new_class) then
1000 a_cluster.extend (new_class)
1001 model.add_node_relations (new_class)
1002 end
1003 end
1004 end
1005 if with_status_bar then
1006 a_status_bar.progress_bar.set_value (a_status_bar.progress_bar.value + 1)
1007 end
1008 l_classes.forth
1009 end
1010 end
1011 end
1012 end
1013
1014 veto_function (a_any: ANY): BOOLEAN is
1015 -- Veto function.
1016 -- CREATE_CLASS_STONE, CLASSI_STONE, CLUSTER_STONE none assemble accepted.
1017 local
1018 l_cc_stone: CREATE_CLASS_STONE
1019 l_class_stone: CLASSI_STONE
1020 l_cluster_stone: CLUSTER_STONE
1021 l_pointer_position: EV_COORDINATE
1022 l_class_fig_stone: CLASSI_FIGURE_STONE
1023 l_cluster: EIFFEL_CLUSTER_FIGURE
1024 l_cluster_fig_stone: CLUSTER_FIGURE_STONE
1025 do
1026 l_cc_stone ?= a_any
1027 l_class_stone ?= a_any
1028 l_cluster_stone ?= a_any
1029 l_cluster_fig_stone ?= a_any
1030 if l_cc_stone /= Void or l_cluster_stone /= Void or l_class_stone /= Void then
1031 Result := True
1032 if l_cluster_stone /= Void then
1033 if l_cluster_stone.group.is_assembly then
1034 Result := False
1035 end
1036 end
1037 -- Only a figure is picked, we check it.
1038 if l_class_stone /= Void then
1039 l_class_fig_stone ?= l_class_stone
1040 if l_class_fig_stone /= Void then
1041 l_pointer_position := context_editor.pointer_position
1042 l_cluster := top_cluster_at (Current, l_pointer_position.x, l_pointer_position.y)
1043 if l_cluster /= Void then
1044 -- If the figure is readonly or contains the same group, we deny dropping
1045 if l_cluster.model.group.is_readonly or else l_cluster.model.group.is_library then
1046 Result := False
1047 else
1048 if l_cluster.model.group = l_class_fig_stone.class_i.group then
1049 Result := False
1050 end
1051 end
1052 else
1053 Result := False
1054 end
1055 end
1056 end
1057 if l_cluster_fig_stone /= Void then
1058 Result := False
1059 end
1060 end
1061 end
1062
1063 check_and_add_on_top (a_group: CONF_GROUP; with_status_bar: BOOLEAN) is
1064 -- Check if `a_cluster' exist on top.
1065 -- Add it if no.
1066 require
1067 a_cluster_not_void: a_group /= Void
1068 local
1069 l_clusters: ARRAYED_LIST [ES_CLUSTER]
1070 l_found: BOOLEAN
1071 es_cluster: ES_CLUSTER
1072 cluster_fig: EIFFEL_CLUSTER_FIGURE
1073 l_found_cluster: ES_CLUSTER
1074 l_array_redo, l_array_undo: ARRAYED_LIST [PROCEDURE [ANY, TUPLE]]
1075 remove_classes: LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]]
1076 remove_links: LIST [ES_ITEM]
1077 l_string: STRING
1078 do
1079 l_clusters := model.top_level_clusters
1080 create l_array_redo.make (5)
1081 create l_array_undo.make (5)
1082 from
1083 l_clusters.start
1084 until
1085 l_clusters.after or l_found
1086 loop
1087 l_found := (a_group = l_clusters.item.group)
1088 if l_found then
1089 l_found_cluster := l_clusters.item
1090 end
1091 l_clusters.forth
1092 end
1093 if not l_found then
1094 create es_cluster.make (a_group)
1095 model.add_cluster (es_cluster)
1096 model.add_children_relations (es_cluster, Void)
1097 if a_group.is_cluster then
1098 add_classes_of_cluster (es_cluster, True, with_status_bar)
1099 end
1100 cluster_fig ?= figure_from_model (es_cluster)
1101 check
1102 fig_inserted: cluster_fig /= Void
1103 end
1104 cluster_fig.set_port_position (context_editor.pointer_position.x, context_editor.pointer_position.y)
1105 update_cluster_legend
1106 remove_classes := classes_to_remove_in_cluster (es_cluster)
1107 remove_links := links_to_remove_in_classes (remove_classes)
1108 l_array_redo.extend (agent reinclude_cluster (cluster_fig, remove_links, remove_classes))
1109 l_array_undo.extend (agent remove_cluster_virtual (cluster_fig, remove_links, remove_classes))
1110 l_array_redo.extend (agent update_cluster_legend)
1111 l_array_undo.extend (agent update_cluster_legend)
1112 context_editor.layout.layout_cluster (cluster_fig, 1)
1113 elseif not l_found_cluster.is_needed_on_diagram then
1114 if l_found_cluster.group.is_cluster then
1115 add_classes_of_cluster (l_found_cluster, False, with_status_bar)
1116 else
1117 l_found_cluster.enable_needed_on_diagram
1118 enable_all_links (l_found_cluster)
1119 end
1120 cluster_fig ?= figure_from_model (l_found_cluster)
1121 update_cluster_legend
1122 remove_classes := classes_to_remove_in_cluster (l_found_cluster)
1123 remove_links := links_to_remove_in_classes (remove_classes)
1124 l_array_redo.extend (agent reinclude_cluster (cluster_fig, remove_links, remove_classes))
1125 l_array_undo.extend (agent remove_cluster_virtual (cluster_fig, remove_links, remove_classes))
1126 l_array_redo.extend (agent update_cluster_legend)
1127 l_array_undo.extend (agent update_cluster_legend)
1128 end
1129 if not l_array_redo.is_empty and then not l_array_undo.is_empty then
1130 if a_group.is_library then
1131 l_string := interface_names.t_diagram_include_library_cmd (a_group.name)
1132 else
1133 l_string := interface_names.t_diagram_include_cluster_cmd (a_group.name)
1134 end
1135 context_editor.history.register_named_undoable (l_string,
1136 [l_array_redo], [l_array_undo])
1137 end
1138 end
1139
1140 any_clusters_needed (a_clusters: ARRAYED_LIST [ES_CLUSTER]): BOOLEAN is
1141 -- Any class needed in `a_clusters'?
1142 require
1143 a_clusters_not_void: a_clusters /= Void
1144 do
1145 from
1146 a_clusters.start
1147 until
1148 a_clusters.after or Result
1149 loop
1150 Result := a_clusters.item.is_needed_on_diagram
1151 a_clusters.forth
1152 end
1153 end
1154
1155 indexing
1156 copyright: "Copyright (c) 1984-2006, Eiffel Software"
1157 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
1158 licensing_options: "http://www.eiffel.com/licensing"
1159 copying: "[
1160 This file is part of Eiffel Software's Eiffel Development Environment.
1161
1162 Eiffel Software's Eiffel Development Environment is free
1163 software; you can redistribute it and/or modify it under
1164 the terms of the GNU General Public License as published
1165 by the Free Software Foundation, version 2 of the License
1166 (available at the URL listed under "license" above).
1167
1168 Eiffel Software's Eiffel Development Environment is
1169 distributed in the hope that it will be useful, but
1170 WITHOUT ANY WARRANTY; without even the implied warranty
1171 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1172 See the GNU General Public License for more details.
1173
1174 You should have received a copy of the GNU General Public
1175 License along with Eiffel Software's Eiffel Development
1176 Environment; if not, write to the Free Software Foundation,
1177 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1178 ]"
1179 source: "[
1180 Eiffel Software
1181 356 Storke Road, Goleta, CA 93117 USA
1182 Telephone 805-685-1006, Fax 805-685-6869
1183 Website http://www.eiffel.com
1184 Customer support http://support.eiffel.com
1185 ]"
1186
1187 end -- class EIFFEL_CLUSTER_DIAGRAM

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23