/[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 47281 - (show annotations)
Tue Dec 28 19:31:21 2004 UTC (15 years ago) by bennob
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
File size: 8528 byte(s)
Initial commit of the new diagram tool.

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