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