/[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 53967 - (show annotations)
Tue Aug 2 05:35:06 2005 UTC (14 years, 5 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
File size: 8771 byte(s)
Protected call to `model' in `recycle' as it is Void when figure is created
  using `default_create' only.

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