/[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 47431 - (show annotations)
Fri Jan 7 17:47:24 2005 UTC (15 years ago) by bennob
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
File size: 8725 byte(s)
Optimized loop over linkable_figure.links

1 indexing
2 description: "Common functionality for all views of ES_CLUSTERs"
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7 deferred class
8 EIFFEL_CLUSTER_FIGURE
9
10 inherit
11 EG_RESIZABLE_CLUSTER_FIGURE
12 redefine
13 default_create,
14 initialize,
15 model,
16 world,
17 on_linkable_add,
18 on_handle_start,
19 on_handle_end,
20 recycle
21 end
22
23 EB_CONSTANTS
24 undefine
25 default_create
26 end
27
28 feature {NONE} -- Initialization
29
30 default_create is
31 -- Create an CLUSTER_FIGURE.
32 do
33 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
34
35 set_accept_cursor (cursors.cur_cluster)
36 set_deny_cursor (cursors.cur_x_cluster)
37
38 start_actions.extend (agent save_position)
39 end_actions.extend (agent extend_history)
40 move_actions.extend (agent on_move)
41 end
42
43 initialize is
44 -- Initialize `Current' with `model'.
45 do
46 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
47 pebble_function := agent on_pebble_request
48 model.needed_on_diagram_changed_actions.extend (agent on_needed_on_diagram_changed)
49 end
50
51 feature -- Status report
52
53 is_iconified: BOOLEAN
54 -- Is `Current' iconified.
55
56 feature -- Access
57
58 model: ES_CLUSTER
59 -- Model for `Current'.
60
61 world: EIFFEL_WORLD is
62 -- World `Current' is part of.
63 do
64 Result ?= Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
65 end
66
67 feature -- Element change
68
69 recycle is
70 -- Free `Current's resources.
71 do
72 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
73 start_actions.prune_all (agent save_position)
74 end_actions.prune_all (agent extend_history)
75 move_actions.prune_all (agent on_move)
76 model.needed_on_diagram_changed_actions.prune_all (agent on_needed_on_diagram_changed)
77 end
78
79
80 apply_right_angles is
81 -- Apply right angles to all links in `links' and all elements in `Current'.
82 local
83 l_item: EIFFEL_LINK_FIGURE
84 l_links: like links
85 i, nb: INTEGER
86 clu: EIFFEL_CLUSTER_FIGURE
87 cla: EIFFEL_CLASS_FIGURE
88 do
89 from
90 l_links := links
91 i := 1
92 nb := l_links.count
93 until
94 i > nb
95 loop
96 l_item ?= l_links.i_th (i)
97 if l_item /= Void then
98 l_item.apply_right_angles
99 end
100 i := i + 1
101 end
102 from
103 start
104 until
105 after
106 loop
107 clu ?= item
108 if clu /= Void then
109 clu.apply_right_angles
110 else
111 cla ?= item
112 if cla /= Void then
113 cla.apply_right_angles
114 end
115 end
116 forth
117 end
118 end
119
120 feature {EG_LAYOUT} -- Layouting
121
122 set_to_minimum_size is
123 -- Set `Current's to `minimum_size'.
124 deferred
125 end
126
127 feature {EIFFEL_WORLD} -- Show/Hide
128
129 disable_shown is
130 -- Hide `Current'.
131 deferred
132 ensure
133 set: not is_shown
134 end
135
136 enable_shown is
137 -- Show `Current'.
138 deferred
139 ensure
140 set: is_shown
141 end
142
143 is_shown: BOOLEAN
144 -- Is `Current' shown?
145
146 feature {EIFFEL_CLUSTER_FIGURE} -- Expand/Collapse
147
148 collapse is
149 -- Hide all elements in `Current' and minimize `Current'.
150 local
151 linkable_figure: EG_LINKABLE_FIGURE
152 cluster_figure: EIFFEL_CLUSTER_FIGURE
153 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
154 l_item: EG_LINK_FIGURE
155 i, nb: INTEGER
156 do
157 from
158 start
159 until
160 after
161 loop
162 linkable_figure ?= item
163 if linkable_figure /= Void then
164 if linkable_figure.is_show_requested then
165 linkable_figure.hide
166 linkable_figure.disable_sensitive
167 from
168 l_links := linkable_figure.links
169 i := 1
170 nb := l_links.count
171 until
172 i > nb
173 loop
174 l_item := l_links.i_th (i)
175 l_item.hide
176 l_item.disable_sensitive
177 i := i + 1
178 end
179 cluster_figure ?= linkable_figure
180 if cluster_figure /= Void and then not cluster_figure.is_iconified then
181 cluster_figure.collapse
182 end
183 end
184 end
185 forth
186 end
187 resizer_top_left.disable_sensitive
188 resizer_top_right.disable_sensitive
189 resizer_bottom_right.disable_sensitive
190 resizer_bottom_left.disable_sensitive
191 end
192
193 expand is
194 -- Show all not iconified elements in `Current'.
195 local
196 linkable_figure: EG_LINKABLE_FIGURE
197 l_other: EG_LINKABLE_FIGURE
198 l_link: EG_LINK_FIGURE
199 cluster_figure: EIFFEL_CLUSTER_FIGURE
200 e_item: ES_ITEM
201 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
202 i, nb: INTEGER
203 do
204 from
205 start
206 until
207 after
208 loop
209 linkable_figure ?= item
210 if linkable_figure /= Void then
211 e_item ?= linkable_figure.model
212 if e_item = Void or else e_item.is_needed_on_diagram then
213 linkable_figure.show
214 linkable_figure.enable_sensitive
215 from
216 l_links := linkable_figure.links
217 i := 1
218 nb := l_links.count
219 until
220 i > nb
221 loop
222 l_link := l_links.i_th (i)
223 if l_link.source = linkable_figure then
224 l_other := l_link.target
225 else
226 l_other := l_link.source
227 end
228 if l_other.is_show_requested then
229 l_link.show
230 l_link.enable_sensitive
231 end
232 i := i + 1
233 end
234 cluster_figure ?= linkable_figure
235 if cluster_figure /= Void and then not cluster_figure.is_iconified then
236 cluster_figure.expand
237 end
238 end
239 end
240 forth
241 end
242 resizer_top_left.enable_sensitive
243 resizer_top_right.enable_sensitive
244 resizer_bottom_right.enable_sensitive
245 resizer_bottom_left.enable_sensitive
246 end
247
248 feature {NONE} -- Implementation
249
250 on_needed_on_diagram_changed is
251 -- `model'.`is_needed_on_diagram' changed.
252 do
253 if model.is_needed_on_diagram then
254 show
255 enable_sensitive
256 else
257 hide
258 disable_sensitive
259 end
260 request_update
261 end
262
263 save_position is
264 -- Make a backup of current coordinates.
265 do
266 saved_x := port_x
267 saved_y := port_y
268
269 end
270
271 saved_x, saved_y: INTEGER
272 -- Saved positions.
273
274 on_move (ax, ay: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
275 -- Cluster is moving.
276 do
277 world.context_editor.restart_force_directed
278 if world.is_right_angles then
279 apply_right_angles
280 end
281 end
282
283 extend_history is
284 -- Register move in the history.
285 local
286 ce: EB_CONTEXT_EDITOR
287 do
288 ce := world.context_editor
289 world.context_editor.history.do_named_undoable (
290 interface_names.t_Diagram_move_cluster_cmd,
291 [<<agent set_port_position (port_x, port_y), agent ce.restart_force_directed>>],
292 [<<agent set_port_position (saved_x, saved_y), agent ce.restart_force_directed>>])
293 if world.context_editor.is_force_directed_used then
294 set_is_fixed (True)
295 end
296 end
297
298 on_linkable_add (a_linkable: EG_LINKABLE) is
299 -- `a_linkable' was added to the cluster.
300 local
301 l_world: like world
302 linkable_fig: EG_LINKABLE_FIGURE
303 link_fig: EG_LINK_FIGURE
304 scsc: EG_CLUSTER_FIGURE
305 e_item: ES_ITEM
306 cs_link: EIFFEL_CLIENT_SUPPLIER_FIGURE
307 i_link: EIFFEL_INHERITANCE_FIGURE
308 c_fig: EG_LINKABLE_FIGURE
309 do
310 l_world := world
311 if l_world /= Void then
312 linkable_fig ?= l_world.items_to_figure_lookup_table.item (a_linkable)
313 check
314 linkable_fig_is_in_view_but_not_in_cluster: linkable_fig /= Void not has (linkable_fig)
315 end
316 extend (linkable_fig)
317 linkable_fig.set_cluster (Current)
318
319 from
320 l_world.links.start
321 until
322 l_world.links.after
323 loop
324 link_fig := l_world.links.item
325 if link_fig.source /= Void and then link_fig.target /= Void then
326 e_item ?= link_fig.model
327 if e_item = Void or else e_item.is_needed_on_diagram then
328 scsc := world.smallest_common_supercluster (link_fig.source, link_fig.target)
329 if scsc /= Void and then not scsc.has (link_fig) then
330 scsc.go_i_th (scsc.number_of_figures)
331 cs_link ?= link_fig
332 if cs_link /= Void or else scsc.index = scsc.count then
333 scsc.put_right (link_fig)
334 else
335 from
336 i_link := Void
337 c_fig := Void
338 until
339 i_link /= Void or else c_fig /= Void
340 loop
341 scsc.forth
342 i_link ?= scsc.item
343 c_fig ?= scsc.item
344 end
345 scsc.put_left (link_fig)
346 end
347 end
348 end
349 end
350 l_world.links.forth
351 end
352 end
353 request_update
354 end
355
356 on_handle_start is
357 -- User started to move `Current'.
358 do
359 was_fixed := is_fixed
360 if world.context_editor.is_force_directed_used then
361 set_is_fixed (True)
362 end
363 end
364
365 on_handle_end is
366 -- User ended to move `Current'.
367 do
368 set_is_fixed (was_fixed)
369 end
370
371 update_links is
372 -- Update all links in `Current'.
373 local
374 i, nb: INTEGER
375 l_link: EG_LINK_FIGURE
376 do
377 from
378 i := 1
379 until
380 i > nb
381 loop
382 l_link ?= i_th (i)
383 if l_link /= Void then
384 l_link.update
385 end
386 i := i + 1
387 end
388 end
389
390 on_pebble_request: CLUSTER_STONE is
391 -- Pebble request.
392 do
393 if model /= Void then
394 create Result.make (model.cluster_i)
395 end
396 end
397
398 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