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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/eiffel_class_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: 9889 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "BON view for a CLASS_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_CLASS_DIAGRAM
11
12 inherit
13 EIFFEL_WORLD
14 redefine
15 default_create,
16 model,
17 xml_element,
18 xml_node_name,
19 set_with_xml_element,
20 recycle
21 end
22
23 SHARED_WORKBENCH
24 export
25 {NONE} all
26 undefine
27 default_create
28 end
29
30 EB_CLUSTER_MANAGER_OBSERVER
31 undefine
32 default_create
33 redefine
34 on_class_added
35 end
36
37 EB_SHARED_ID_SOLUTION
38 export
39 {NONE} all
40 undefine
41 default_create
42 end
43
44 create
45 default_create
46
47 create {EIFFEL_CLASS_DIAGRAM}
48 make_filled
49
50 feature {NONE} -- Initialization
51
52 default_create is
53 -- Create a EIFFEL_CLASS_GRAPH.
54 do
55 Precursor {EIFFEL_WORLD}
56 drop_actions.extend (agent on_class_drop)
57 drop_actions.extend (agent on_new_class_drop)
58 manager.add_observer (Current)
59 end
60
61 feature -- Access
62
63 model: ES_CLASS_GRAPH
64 -- Model for current view.
65
66 feature -- Element change
67
68 recycle is
69 -- Free `Current's resources.
70 do
71 Precursor {EIFFEL_WORLD}
72 drop_actions.prune_all (agent on_class_drop)
73 drop_actions.prune_all (agent on_new_class_drop)
74 manager.remove_observer (Current)
75 end
76
77 feature {EB_CONTEXT_EDITOR} -- Save/Restore
78
79 xml_node_name: STRING is
80 -- Name of the node returned by `xml_element'.
81 do
82 Result := "EIFFEL_CLASS_DIAGRAM"
83 end
84
85 xml_element (node: XM_ELEMENT): XM_ELEMENT is
86 -- Xml node representing `Current's state.
87 do
88 node.add_attribute ("NAME", xml_namespace, current_view)
89 node.put_last (Xml_routines.xml_node (node, "ANCESTOR_DEPTH", model.ancestor_depth.out))
90 node.put_last (Xml_routines.xml_node (node, "DESCENDANT_DEPTH", model.descendant_depth.out))
91 node.put_last (Xml_routines.xml_node (node, "CLIENT_DEPTH", model.client_depth.out))
92 node.put_last (Xml_routines.xml_node (node, "SUPPLIER_DEPTH", model.supplier_depth.out))
93 node.put_last (Xml_routines.xml_node (node, "ALL_CLASSES_IN_CLUSTER", model.include_all_classes_of_cluster.out))
94 node.put_last (Xml_routines.xml_node (node, "ONLY_CLASSES_IN_CLUSTER", model.include_only_classes_of_cluster.out))
95 node.put_last (xml_routines.xml_node (node, "CENTER_CLASS_NAME", model.center_class.class_i.name_in_upper))
96 node.put_last (xml_routines.xml_node (node, "CENTER_CLASS_GROUP_ID", model.center_class.group_id))
97
98 Result := Precursor {EIFFEL_WORLD} (node)
99 end
100
101 set_with_xml_element (node: XM_ELEMENT) is
102 -- Retrive state from `node'.
103 local
104 ccn, cccn: STRING
105 cc: CLASS_I
106 cl: CONF_GROUP
107 esc: ES_CLASS
108 l_classes: LINKED_SET [CONF_CLASS]
109 do
110 node.forth
111 model.set_ancestor_depth (xml_routines.xml_integer (node, "ANCESTOR_DEPTH"))
112 model.set_descendant_depth (xml_routines.xml_integer (node, "DESCENDANT_DEPTH"))
113 model.set_client_depth (xml_routines.xml_integer (node, "CLIENT_DEPTH"))
114 model.set_supplier_depth (xml_routines.xml_integer (node, "SUPPLIER_DEPTH"))
115 model.set_include_all_classes_of_cluster (xml_routines.xml_boolean (node, "ALL_CLASSES_IN_CLUSTER"))
116 model.set_include_only_classes_of_cluster (xml_routines.xml_boolean (node, "ONLY_CLASSES_IN_CLUSTER"))
117 ccn := xml_routines.xml_string (node, "CENTER_CLASS_NAME")
118 cccn := xml_routines.xml_string (node, "CENTER_CLASS_GROUP_ID")
119
120 Precursor {EIFFEL_WORLD} (node)
121
122 -- Check if cluster still exists
123 if cccn /= Void and then ccn /= Void then
124 cl := group_of_id (cccn)
125 if cl /= Void then
126 l_classes := cl.class_by_name (ccn, False)
127 -- Check if class still exists
128 if not l_classes.is_empty then
129 cc ?= l_classes.first
130 check
131 cc_not_void: cc /= Void
132 end
133 esc := class_from_interface (cc)
134 if esc = Void then
135 create esc.make (cc)
136 model.add_node (esc)
137 model.add_node_relations (esc)
138 end
139 model.set_center_class (esc)
140 end
141 end
142 end
143 end
144
145 feature {NONE} -- Implementation
146
147 class_from_interface (a_class: CLASS_I): ES_CLASS is
148 -- Class from interface.
149 require
150 a_class_not_void: a_class /= Void
151 local
152 l_classes: ARRAYED_LIST [ES_CLASS]
153 do
154 l_classes := model.class_from_interface (a_class)
155 if not l_classes.is_empty then
156 check
157 class_is_unique: l_classes.count = 1
158 end
159 Result := l_classes.first
160 end
161 end
162
163 on_class_drop (a_stone: CLASSI_STONE) is
164 -- `a_stone' was dropped on `Current'
165 -- Add to diagram if not already present.
166 local
167 drop_x, drop_y, old_x, old_y: INTEGER
168 cf: EIFFEL_CLASS_FIGURE
169 cm: ES_CLASS
170 remove_links: LIST [ES_ITEM]
171 do
172 if a_stone.is_valid then
173 if not model.is_empty then
174 cm := class_from_interface (a_stone.class_i)
175 if cm = Void or else not cm.is_needed_on_diagram then
176 -- add it
177 if cm = Void then
178 create cm.make (a_stone.class_i)
179 model.add_node (cm)
180 else
181 cm.enable_needed_on_diagram
182 enable_all_links (cm)
183
184 end
185 model.add_node_relations (cm)
186 cf ?= figure_from_model (cm)
187 check
188 class_was_inserted: cf /= Void
189 end
190 drop_x := context_editor.pointer_position.x
191 drop_y := context_editor.pointer_position.y
192 cf.set_port_position (drop_x, drop_y)
193 remove_links := cm.needed_links
194 update_cluster_legend
195 context_editor.history.register_named_undoable (
196 Interface_names.t_Diagram_include_class_cmd (cm.name),
197 [<<agent reinclude_class (cf, remove_links, drop_x, drop_y), agent update_cluster_legend>>],
198 [<<agent remove_class_virtual (cf, remove_links), agent update_cluster_legend>>])
199 else
200 -- move it
201 cf ?= figure_from_model (cm)
202 check
203 class_was_inserted: cf /= Void
204 end
205 drop_x := context_editor.pointer_position.x
206 drop_y := context_editor.pointer_position.y
207 old_x := cf.port_x
208 old_y := cf.port_y
209 cf.set_port_position (drop_x, drop_y)
210 context_editor.history.register_named_undoable (
211 interface_names.t_diagram_move_class_cmd (cm.name),
212 agent cf.set_port_position (drop_x, drop_y),
213 agent cf.set_port_position (old_x, old_y))
214 end
215 if is_right_angles then
216 apply_right_angles
217 end
218 end
219 end
220 end
221
222 on_new_class_drop (a_stone: CREATE_CLASS_STONE) is
223 -- `a_stone' was dropped on `Current'
224 -- Display create class dialog and add to diagram.
225 local
226 dial: EB_CREATE_CLASS_DIALOG
227 drop_x, drop_y: INTEGER
228 l_cluster: CONF_CLUSTER
229 do
230 is_new_dropped := True
231 drop_x := context_editor.pointer_position.x
232 drop_y := context_editor.pointer_position.y
233 create dial.make_default (context_editor.develop_window)
234 l_cluster ?= model.center_class.class_i.group
235 check
236 l_cluster_not_void: l_cluster /= Void
237 end
238 dial.preset_cluster (l_cluster)
239 dial.call_default
240 if not dial.cancelled then
241 include_new_class (dial.class_i, drop_x, drop_y)
242 end
243 is_new_dropped := False
244 end
245
246 is_new_dropped: BOOLEAN
247 -- Is new added class to system dropped by user onto the diagram tool?
248
249 include_new_class (a_class: CLASS_I; a_x, a_y: INTEGER) is
250 -- Add `a_class' to the diagram if not already present.
251 require
252 a_class_exists: a_class /= Void
253 local
254 cf: EIFFEL_CLASS_FIGURE
255 es_class: ES_CLASS
256 remove_links: LIST [ES_ITEM]
257 do
258 if a_class /= Void then
259 es_class := class_from_interface (a_class)
260 if es_class = Void then
261 create es_class.make (a_class)
262 model.add_node (es_class)
263 else
264 es_class.enable_needed_on_diagram
265 enable_all_links (es_class)
266 end
267 model.add_node_relations (es_class)
268 cf ?= figure_from_model (es_class)
269 check cf_not_void: cf /= Void end
270 cf.set_port_position (a_x, a_y)
271 remove_links := es_class.needed_links
272 update_cluster_legend
273 context_editor.history.register_named_undoable (
274 interface_names.t_diagram_include_class_cmd (es_class.name),
275 [<<agent reinclude_class (cf, remove_links, a_x, a_y), agent update_cluster_legend>>],
276 [<<agent remove_class_virtual (cf, remove_links), agent update_cluster_legend>>])
277 end
278 if is_right_angles then
279 apply_right_angles
280 end
281 end
282
283 on_class_added (a_class: CLASS_I) is
284 -- `a_class' was added to the system.
285 local
286 ax, ay: INTEGER
287 do
288 if not is_new_dropped and then model.center_class /= Void then
289 ax := context_editor.widget.width // 2 + context_editor.projector.area_x
290 ay := context_editor.widget.height // 2 + context_editor.projector.area_y
291 include_new_class (a_class, ax, ay)
292 end
293 end
294
295 indexing
296 copyright: "Copyright (c) 1984-2006, Eiffel Software"
297 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
298 licensing_options: "http://www.eiffel.com/licensing"
299 copying: "[
300 This file is part of Eiffel Software's Eiffel Development Environment.
301
302 Eiffel Software's Eiffel Development Environment is free
303 software; you can redistribute it and/or modify it under
304 the terms of the GNU General Public License as published
305 by the Free Software Foundation, version 2 of the License
306 (available at the URL listed under "license" above).
307
308 Eiffel Software's Eiffel Development Environment is
309 distributed in the hope that it will be useful, but
310 WITHOUT ANY WARRANTY; without even the implied warranty
311 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
312 See the GNU General Public License for more details.
313
314 You should have received a copy of the GNU General Public
315 License along with Eiffel Software's Eiffel Development
316 Environment; if not, write to the Free Software Foundation,
317 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
318 ]"
319 source: "[
320 Eiffel Software
321 356 Storke Road, Goleta, CA 93117 USA
322 Telephone 805-685-1006, Fax 805-685-6869
323 Website http://www.eiffel.com
324 Customer support http://support.eiffel.com
325 ]"
326
327 end -- class EIFFEL_CLASS_DIAGRAM

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23