/[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 47394 - (show annotations)
Thu Jan 6 03:33:31 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: 8660 byte(s)
Using internal_links instead of the twined 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 do
154 from
155 start
156 until
157 after
158 loop
159 linkable_figure ?= item
160 if linkable_figure /= Void then
161 if linkable_figure.is_show_requested then
162 linkable_figure.hide
163 linkable_figure.disable_sensitive
164 from
165 linkable_figure.internal_links.start
166 until
167 linkable_figure.internal_links.after
168 loop
169 linkable_figure.internal_links.item.hide
170 linkable_figure.internal_links.item.disable_sensitive
171 linkable_figure.internal_links.forth
172 end
173 cluster_figure ?= linkable_figure
174 if cluster_figure /= Void and then not cluster_figure.is_iconified then
175 cluster_figure.collapse
176 end
177 end
178 end
179 forth
180 end
181 resizer_top_left.disable_sensitive
182 resizer_top_right.disable_sensitive
183 resizer_bottom_right.disable_sensitive
184 resizer_bottom_left.disable_sensitive
185 end
186
187 expand is
188 -- Show all not iconified elements in `Current'.
189 local
190 linkable_figure: EG_LINKABLE_FIGURE
191 l_other: EG_LINKABLE_FIGURE
192 l_link: EG_LINK_FIGURE
193 cluster_figure: EIFFEL_CLUSTER_FIGURE
194 e_item: ES_ITEM
195 do
196 from
197 start
198 until
199 after
200 loop
201 linkable_figure ?= item
202 if linkable_figure /= Void then
203 e_item ?= linkable_figure.model
204 if e_item = Void or else e_item.is_needed_on_diagram then
205 linkable_figure.show
206 linkable_figure.enable_sensitive
207 from
208 linkable_figure.internal_links.start
209 until
210 linkable_figure.internal_links.after
211 loop
212 l_link := linkable_figure.internal_links.item
213 if l_link.source = linkable_figure then
214 l_other := l_link.target
215 else
216 l_other := l_link.source
217 end
218 if l_other.is_show_requested then
219 l_link.show
220 l_link.enable_sensitive
221 end
222 linkable_figure.internal_links.forth
223 end
224 cluster_figure ?= linkable_figure
225 if cluster_figure /= Void and then not cluster_figure.is_iconified then
226 cluster_figure.expand
227 end
228 end
229 end
230 forth
231 end
232 resizer_top_left.enable_sensitive
233 resizer_top_right.enable_sensitive
234 resizer_bottom_right.enable_sensitive
235 resizer_bottom_left.enable_sensitive
236 end
237
238 feature {NONE} -- Implementation
239
240 on_needed_on_diagram_changed is
241 -- `model'.`is_needed_on_diagram' changed.
242 do
243 if model.is_needed_on_diagram then
244 show
245 enable_sensitive
246 else
247 hide
248 disable_sensitive
249 end
250 request_update
251 end
252
253 save_position is
254 -- Make a backup of current coordinates.
255 do
256 saved_x := port_x
257 saved_y := port_y
258
259 end
260
261 saved_x, saved_y: INTEGER
262 -- Saved positions.
263
264 on_move (ax, ay: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
265 -- Cluster is moving.
266 do
267 world.context_editor.restart_force_directed
268 if world.is_right_angles then
269 apply_right_angles
270 end
271 end
272
273 extend_history is
274 -- Register move in the history.
275 local
276 ce: EB_CONTEXT_EDITOR
277 do
278 ce := world.context_editor
279 world.context_editor.history.do_named_undoable (
280 interface_names.t_Diagram_move_cluster_cmd,
281 [<<agent set_port_position (port_x, port_y), agent ce.restart_force_directed>>],
282 [<<agent set_port_position (saved_x, saved_y), agent ce.restart_force_directed>>])
283 if world.context_editor.is_force_directed_used then
284 set_is_fixed (True)
285 end
286 end
287
288 on_linkable_add (a_linkable: EG_LINKABLE) is
289 -- `a_linkable' was added to the cluster.
290 local
291 l_world: like world
292 linkable_fig: EG_LINKABLE_FIGURE
293 link_fig: EG_LINK_FIGURE
294 scsc: EG_CLUSTER_FIGURE
295 e_item: ES_ITEM
296 cs_link: EIFFEL_CLIENT_SUPPLIER_FIGURE
297 i_link: EIFFEL_INHERITANCE_FIGURE
298 c_fig: EG_LINKABLE_FIGURE
299 do
300 l_world := world
301 if l_world /= Void then
302 linkable_fig ?= l_world.items_to_figure_lookup_table.item (a_linkable)
303 check
304 linkable_fig_is_in_view_but_not_in_cluster: linkable_fig /= Void not has (linkable_fig)
305 end
306 extend (linkable_fig)
307 linkable_fig.set_cluster (Current)
308
309 from
310 l_world.links.start
311 until
312 l_world.links.after
313 loop
314 link_fig := l_world.links.item
315 if link_fig.source /= Void and then link_fig.target /= Void then
316 e_item ?= link_fig.model
317 if e_item = Void or else e_item.is_needed_on_diagram then
318 scsc := world.smallest_common_supercluster (link_fig.source, link_fig.target)
319 if scsc /= Void and then not scsc.has (link_fig) then
320 scsc.go_i_th (scsc.number_of_figures)
321 cs_link ?= link_fig
322 if cs_link /= Void or else scsc.index = scsc.count then
323 scsc.put_right (link_fig)
324 else
325 from
326 i_link := Void
327 c_fig := Void
328 until
329 i_link /= Void or else c_fig /= Void
330 loop
331 scsc.forth
332 i_link ?= scsc.item
333 c_fig ?= scsc.item
334 end
335 scsc.put_left (link_fig)
336 end
337 end
338 end
339 end
340 l_world.links.forth
341 end
342 end
343 request_update
344 end
345
346 on_handle_start is
347 -- User started to move `Current'.
348 do
349 was_fixed := is_fixed
350 if world.context_editor.is_force_directed_used then
351 set_is_fixed (True)
352 end
353 end
354
355 on_handle_end is
356 -- User ended to move `Current'.
357 do
358 set_is_fixed (was_fixed)
359 end
360
361 update_links is
362 -- Update all links in `Current'.
363 local
364 i, nb: INTEGER
365 l_link: EG_LINK_FIGURE
366 do
367 from
368 i := 1
369 until
370 i > nb
371 loop
372 l_link ?= i_th (i)
373 if l_link /= Void then
374 l_link.update
375 end
376 i := i + 1
377 end
378 end
379
380 on_pebble_request: CLUSTER_STONE is
381 -- Pebble request.
382 do
383 if model /= Void then
384 create Result.make (model.cluster_i)
385 end
386 end
387
388 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