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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.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: 11022 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Common functionality for all views of ES_CLUSTERs"
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 deferred class
10 EIFFEL_CLUSTER_FIGURE
11
12 inherit
13 EG_RESIZABLE_CLUSTER_FIGURE
14 redefine
15 default_create,
16 initialize,
17 model,
18 world,
19 on_linkable_add,
20 on_handle_start,
21 on_handle_end,
22 recycle,
23 xml_element,
24 set_with_xml_element
25 end
26
27 EB_CONSTANTS
28 undefine
29 default_create
30 end
31
32 EB_PIXMAPABLE_ITEM_PIXMAP_FACTORY
33 undefine
34 default_create
35 end
36
37 feature {NONE} -- Initialization
38
39 default_create is
40 -- Create an CLUSTER_FIGURE.
41 do
42 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
43
44 set_accept_cursor (cursors.cur_cluster)
45 set_deny_cursor (cursors.cur_x_cluster)
46
47 start_actions.extend (agent save_position)
48 end_actions.extend (agent extend_history)
49 move_actions.extend (agent on_move)
50 create label_pixmap
51 end
52
53 initialize is
54 -- Initialize `Current' with `model'.
55 do
56 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
57 pebble_function := agent on_pebble_request
58 model.needed_on_diagram_changed_actions.extend (agent on_needed_on_diagram_changed)
59 end
60
61 feature -- Status report
62
63 is_iconified: BOOLEAN
64 -- Is `Current' iconified.
65
66 feature -- Access
67
68 model: ES_CLUSTER
69 -- Model for `Current'.
70
71 world: EIFFEL_WORLD is
72 -- World `Current' is part of.
73 do
74 Result ?= Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
75 end
76
77 label_pixmap: EV_MODEL_PICTURE
78 -- The pixmap for the label.
79
80 feature -- Element change
81
82 recycle is
83 -- Free `Current's resources.
84 do
85 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
86 start_actions.prune_all (agent save_position)
87 end_actions.prune_all (agent extend_history)
88 move_actions.prune_all (agent on_move)
89 if model /= Void then
90 model.needed_on_diagram_changed_actions.prune_all (agent on_needed_on_diagram_changed)
91 end
92 end
93
94
95 apply_right_angles is
96 -- Apply right angles to all links in `links' and all elements in `Current'.
97 local
98 l_item: EIFFEL_LINK_FIGURE
99 l_links: like links
100 i, nb: INTEGER
101 clu: EIFFEL_CLUSTER_FIGURE
102 cla: EIFFEL_CLASS_FIGURE
103 do
104 from
105 l_links := links
106 i := 1
107 nb := l_links.count
108 until
109 i > nb
110 loop
111 l_item ?= l_links.i_th (i)
112 if l_item /= Void then
113 l_item.apply_right_angles
114 end
115 i := i + 1
116 end
117 from
118 start
119 until
120 after
121 loop
122 clu ?= item
123 if clu /= Void then
124 clu.apply_right_angles
125 else
126 cla ?= item
127 if cla /= Void then
128 cla.apply_right_angles
129 end
130 end
131 forth
132 end
133 end
134
135 feature -- XML
136
137 group_id_string: STRING is "GROUP_ID"
138 -- Group id
139
140 cluster_id_string: STRING is "CLUSTER_ID"
141 -- ES_CLUSTER id string
142
143 xml_element (node: XM_ELEMENT): XM_ELEMENT is
144 -- Xml element representing `Current's state.
145 do
146 Result := Precursor {EG_RESIZABLE_CLUSTER_FIGURE} (node)
147 node.add_attribute (group_id_string, xml_namespace, model.group_id)
148 node.add_attribute (cluster_id_string, xml_namespace, model.cluster_id)
149 end
150
151 set_with_xml_element (node: XM_ELEMENT) is
152 -- Retrive state from `node'.
153 do
154 node.forth
155 node.forth
156 Precursor {EG_RESIZABLE_CLUSTER_FIGURE} (node)
157 -- Discard "CLUSTER_ID" and "GROUP_ID", since they have been read in factory.
158 end
159
160 feature {EG_LAYOUT} -- Layouting
161
162 set_to_minimum_size is
163 -- Set `Current's to `minimum_size'.
164 deferred
165 end
166
167 feature {EIFFEL_WORLD} -- Show/Hide
168
169 disable_shown is
170 -- Hide `Current'.
171 deferred
172 ensure
173 set: not is_shown
174 end
175
176 enable_shown is
177 -- Show `Current'.
178 deferred
179 ensure
180 set: is_shown
181 end
182
183 is_shown: BOOLEAN
184 -- Is `Current' shown?
185
186 feature {EIFFEL_CLUSTER_FIGURE} -- Expand/Collapse
187
188 collapse is
189 -- Hide all elements in `Current' and minimize `Current'.
190 local
191 linkable_figure: EG_LINKABLE_FIGURE
192 cluster_figure: EIFFEL_CLUSTER_FIGURE
193 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
194 l_item: EG_LINK_FIGURE
195 i, nb: INTEGER
196 do
197 from
198 start
199 until
200 after
201 loop
202 linkable_figure ?= item
203 if linkable_figure /= Void then
204 if linkable_figure.is_show_requested then
205 linkable_figure.hide
206 linkable_figure.disable_sensitive
207 from
208 l_links := linkable_figure.links
209 i := 1
210 nb := l_links.count
211 until
212 i > nb
213 loop
214 l_item := l_links.i_th (i)
215 l_item.hide
216 l_item.disable_sensitive
217 i := i + 1
218 end
219 cluster_figure ?= linkable_figure
220 if cluster_figure /= Void and then not cluster_figure.is_iconified then
221 cluster_figure.collapse
222 end
223 end
224 end
225 forth
226 end
227 resizer_top_left.disable_sensitive
228 resizer_top_right.disable_sensitive
229 resizer_bottom_right.disable_sensitive
230 resizer_bottom_left.disable_sensitive
231 end
232
233 expand is
234 -- Show all not iconified elements in `Current'.
235 local
236 linkable_figure: EG_LINKABLE_FIGURE
237 l_other: EG_LINKABLE_FIGURE
238 l_link: EG_LINK_FIGURE
239 cluster_figure: EIFFEL_CLUSTER_FIGURE
240 e_item: ES_ITEM
241 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
242 i, nb: INTEGER
243 do
244 from
245 start
246 until
247 after
248 loop
249 linkable_figure ?= item
250 if linkable_figure /= Void then
251 e_item ?= linkable_figure.model
252 if e_item = Void or else e_item.is_needed_on_diagram then
253 linkable_figure.show
254 linkable_figure.enable_sensitive
255 from
256 l_links := linkable_figure.links
257 i := 1
258 nb := l_links.count
259 until
260 i > nb
261 loop
262 l_link := l_links.i_th (i)
263 if l_link.source = linkable_figure then
264 l_other := l_link.target
265 else
266 l_other := l_link.source
267 end
268 if l_other.is_show_requested then
269 l_link.show
270 l_link.enable_sensitive
271 end
272 i := i + 1
273 end
274 cluster_figure ?= linkable_figure
275 if cluster_figure /= Void and then not cluster_figure.is_iconified then
276 cluster_figure.expand
277 end
278 end
279 end
280 forth
281 end
282 resizer_top_left.enable_sensitive
283 resizer_top_right.enable_sensitive
284 resizer_bottom_right.enable_sensitive
285 resizer_bottom_left.enable_sensitive
286 end
287
288 feature {NONE} -- Implementation
289
290 on_needed_on_diagram_changed is
291 -- `model'.`is_needed_on_diagram' changed.
292 do
293 if model.is_needed_on_diagram then
294 show
295 enable_sensitive
296 else
297 hide
298 disable_sensitive
299 end
300 request_update
301 end
302
303 save_position is
304 -- Make a backup of current coordinates.
305 do
306 saved_x := port_x
307 saved_y := port_y
308
309 end
310
311 saved_x, saved_y: INTEGER
312 -- Saved positions.
313
314 on_move (ax, ay: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
315 -- Cluster is moving.
316 do
317 world.context_editor.restart_force_directed
318 if world.is_right_angles then
319 apply_right_angles
320 end
321 end
322
323 extend_history is
324 -- Register move in the history.
325 local
326 ce: EB_DIAGRAM_TOOL
327 do
328 ce := world.context_editor
329 world.context_editor.history.do_named_undoable (
330 interface_names.t_Diagram_move_cluster_cmd (model.name),
331 [<<agent set_port_position (port_x, port_y), agent ce.restart_force_directed>>],
332 [<<agent set_port_position (saved_x, saved_y), agent ce.restart_force_directed>>])
333 if world.context_editor.is_force_directed_used then
334 set_is_fixed (True)
335 end
336 end
337
338 on_linkable_add (a_linkable: EG_LINKABLE) is
339 -- `a_linkable' was added to the cluster.
340 local
341 l_world: like world
342 linkable_fig: EG_LINKABLE_FIGURE
343 link_fig: EG_LINK_FIGURE
344 scsc: EG_CLUSTER_FIGURE
345 e_item: ES_ITEM
346 cs_link: EIFFEL_CLIENT_SUPPLIER_FIGURE
347 i_link: EIFFEL_INHERITANCE_FIGURE
348 c_fig: EG_LINKABLE_FIGURE
349 do
350 l_world := world
351 if l_world /= Void then
352 linkable_fig ?= l_world.items_to_figure_lookup_table.item (a_linkable)
353 check
354 linkable_fig_is_in_view_but_not_in_cluster: linkable_fig /= Void not has (linkable_fig)
355 end
356 extend (linkable_fig)
357 linkable_fig.set_cluster (Current)
358
359 from
360 l_world.links.start
361 until
362 l_world.links.after
363 loop
364 link_fig := l_world.links.item
365 if link_fig.source /= Void and then link_fig.target /= Void then
366 e_item ?= link_fig.model
367 if e_item = Void or else e_item.is_needed_on_diagram then
368 scsc := world.smallest_common_supercluster (link_fig.source, link_fig.target)
369 if scsc /= Void and then not scsc.has (link_fig) then
370 scsc.go_i_th (scsc.number_of_figures)
371 cs_link ?= link_fig
372 if cs_link /= Void or else scsc.index = scsc.count then
373 scsc.put_right (link_fig)
374 else
375 from
376 i_link := Void
377 c_fig := Void
378 until
379 i_link /= Void or else c_fig /= Void
380 loop
381 scsc.forth
382 i_link ?= scsc.item
383 c_fig ?= scsc.item
384 end
385 scsc.put_left (link_fig)
386 end
387 end
388 end
389 end
390 l_world.links.forth
391 end
392 end
393 request_update
394 end
395
396 on_handle_start is
397 -- User started to move `Current'.
398 do
399 was_fixed := is_fixed
400 if world.context_editor.is_force_directed_used then
401 set_is_fixed (True)
402 end
403 end
404
405 on_handle_end is
406 -- User ended to move `Current'.
407 do
408 set_is_fixed (was_fixed)
409 end
410
411 update_links is
412 -- Update all links in `Current'.
413 local
414 i, nb: INTEGER
415 l_link: EG_LINK_FIGURE
416 do
417 from
418 i := 1
419 until
420 i > nb
421 loop
422 l_link ?= i_th (i)
423 if l_link /= Void then
424 l_link.update
425 end
426 i := i + 1
427 end
428 end
429
430 on_pebble_request: CLUSTER_FIGURE_STONE is
431 -- Pebble request.
432 do
433 if model /= Void then
434 create Result.make (Current)
435 end
436 end
437
438 indexing
439 copyright: "Copyright (c) 1984-2006, Eiffel Software"
440 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
441 licensing_options: "http://www.eiffel.com/licensing"
442 copying: "[
443 This file is part of Eiffel Software's Eiffel Development Environment.
444
445 Eiffel Software's Eiffel Development Environment is free
446 software; you can redistribute it and/or modify it under
447 the terms of the GNU General Public License as published
448 by the Free Software Foundation, version 2 of the License
449 (available at the URL listed under "license" above).
450
451 Eiffel Software's Eiffel Development Environment is
452 distributed in the hope that it will be useful, but
453 WITHOUT ANY WARRANTY; without even the implied warranty
454 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
455 See the GNU General Public License for more details.
456
457 You should have received a copy of the GNU General Public
458 License along with Eiffel Software's Eiffel Development
459 Environment; if not, write to the Free Software Foundation,
460 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
461 ]"
462 source: "[
463 Eiffel Software
464 356 Storke Road, Goleta, CA 93117 USA
465 Telephone 805-685-1006, Fax 805-685-6869
466 Website http://www.eiffel.com
467 Customer support http://support.eiffel.com
468 ]"
469
470 end -- class EIFFEL_CLUSTER_FIGURE

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23