/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
ViewVC logotype

Annotation 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 47417 - (hide annotations)
Thu Jan 6 07:44:44 2005 UTC (15 years ago) by manus
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
File size: 8579 byte(s)
Renamed `internal_links' into `links' as it was previously integrated by
  mistake since the graph library as not yet been integrated with this change.

1 manus 26913 indexing
2 bennob 47281 description: "Common functionality for all views of ES_CLUSTERs"
3     author: ""
4 manus 26913 date: "$Date$"
5     revision: "$Revision$"
6    
7     deferred class
8 bennob 47281 EIFFEL_CLUSTER_FIGURE
9    
10 manus 26913 inherit
11 bennob 47281 EG_RESIZABLE_CLUSTER_FIGURE
12 manus 26913 redefine
13 bennob 47281 default_create,
14     initialize,
15     model,
16 manus 26913 world,
17 bennob 47281 on_linkable_add,
18     on_handle_start,
19     on_handle_end,
20     recycle
21 manus 26913 end
22 bennob 47281
23     EB_CONSTANTS
24 manus 26913 undefine
25 bennob 47281 default_create
26 manus 26913 end
27 bennob 47394
28 manus 26913 feature {NONE} -- Initialization
29    
30 bennob 47281 default_create is
31     -- Create an CLUSTER_FIGURE.
32 manus 26913 do
33 bennob 47281 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 manus 26913 end
42 bennob 47281
43 manus 26913 initialize is
44 bennob 47281 -- Initialize `Current' with `model'.
45 manus 26913 do
46 bennob 47281 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
47 bennob 47394 pebble_function := agent on_pebble_request
48 bennob 47281 model.needed_on_diagram_changed_actions.extend (agent on_needed_on_diagram_changed)
49 manus 26913 end
50    
51 bennob 47281 feature -- Status report
52 manus 26913
53 bennob 47281 is_iconified: BOOLEAN
54     -- Is `Current' iconified.
55    
56     feature -- Access
57 manus 26913
58 bennob 47281 model: ES_CLUSTER
59     -- Model for `Current'.
60    
61     world: EIFFEL_WORLD is
62     -- World `Current' is part of.
63 manus 26913 do
64 bennob 47281 Result ?= Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
65 manus 26913 end
66 bennob 47281
67 manus 26913 feature -- Element change
68    
69 bennob 47281 recycle is
70     -- Free `Current's resources.
71 manus 26913 do
72 bennob 47281 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 manus 26913 end
78 bennob 47281
79    
80     apply_right_angles is
81     -- Apply right angles to all links in `links' and all elements in `Current'.
82 manus 26913 local
83 bennob 47281 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 manus 26913 do
89 bennob 47281 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 manus 26913 end
100 bennob 47281 i := i + 1
101 manus 26913 end
102 bennob 47281 from
103     start
104     until
105     after
106     loop
107     clu ?= item
108     if clu /= Void then
109     clu.apply_right_angles
110 manus 26913 else
111 bennob 47281 cla ?= item
112     if cla /= Void then
113     cla.apply_right_angles
114     end
115 manus 26913 end
116 bennob 47281 forth
117 manus 26913 end
118     end
119    
120 bennob 47281 feature {EG_LAYOUT} -- Layouting
121 manus 26913
122 bennob 47281 set_to_minimum_size is
123     -- Set `Current's to `minimum_size'.
124     deferred
125 manus 26913 end
126 bennob 47281
127     feature {EIFFEL_WORLD} -- Show/Hide
128 manus 26913
129 bennob 47281 disable_shown is
130     -- Hide `Current'.
131     deferred
132     ensure
133     set: not is_shown
134 manus 26913 end
135 bennob 47281
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 manus 26913
148 bennob 47281 collapse is
149     -- Hide all elements in `Current' and minimize `Current'.
150 manus 26913 local
151 bennob 47281 linkable_figure: EG_LINKABLE_FIGURE
152     cluster_figure: EIFFEL_CLUSTER_FIGURE
153 manus 26913 do
154     from
155 bennob 47281 start
156 manus 26913 until
157 bennob 47281 after
158 manus 26913 loop
159 bennob 47281 linkable_figure ?= item
160     if linkable_figure /= Void then
161 bennob 47394 if linkable_figure.is_show_requested then
162 bennob 47281 linkable_figure.hide
163     linkable_figure.disable_sensitive
164     from
165 manus 47417 linkable_figure.links.start
166 bennob 47281 until
167 manus 47417 linkable_figure.links.after
168 bennob 47281 loop
169 manus 47417 linkable_figure.links.item.hide
170     linkable_figure.links.item.disable_sensitive
171     linkable_figure.links.forth
172 bennob 47281 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 manus 26913 end
179 bennob 47281 forth
180 manus 26913 end
181 bennob 47281 resizer_top_left.disable_sensitive
182     resizer_top_right.disable_sensitive
183     resizer_bottom_right.disable_sensitive
184     resizer_bottom_left.disable_sensitive
185 manus 26913 end
186 bennob 47281
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 manus 26913 do
196     from
197 bennob 47281 start
198 manus 26913 until
199 bennob 47281 after
200 manus 26913 loop
201 bennob 47281 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 manus 47417 linkable_figure.links.start
209 bennob 47281 until
210 manus 47417 linkable_figure.links.after
211 bennob 47281 loop
212 manus 47417 l_link := linkable_figure.links.item
213 bennob 47281 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 manus 47417 linkable_figure.links.forth
223 bennob 47281 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 manus 26913 end
232 bennob 47281 resizer_top_left.enable_sensitive
233     resizer_top_right.enable_sensitive
234     resizer_bottom_right.enable_sensitive
235     resizer_bottom_left.enable_sensitive
236 manus 26913 end
237 bennob 47281
238     feature {NONE} -- Implementation
239 manus 26913
240 bennob 47281 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 manus 26913 end
252    
253 bennob 47281 save_position is
254     -- Make a backup of current coordinates.
255 manus 26913 do
256 bennob 47281 saved_x := port_x
257     saved_y := port_y
258    
259 manus 26913 end
260 bennob 47281
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 manus 26913 do
267 bennob 47281 world.context_editor.restart_force_directed
268     if world.is_right_angles then
269     apply_right_angles
270 manus 26913 end
271     end
272    
273 bennob 47281 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 manus 26913 end
287 bennob 47281
288     on_linkable_add (a_linkable: EG_LINKABLE) is
289     -- `a_linkable' was added to the cluster.
290 manus 26913 local
291 bennob 47281 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 manus 26913 do
300 bennob 47281 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 manus 26913 from
310 bennob 47281 l_world.links.start
311 manus 26913 until
312 bennob 47281 l_world.links.after
313 manus 26913 loop
314 bennob 47281 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 manus 26913 end
340 bennob 47281 l_world.links.forth
341 manus 26913 end
342     end
343 bennob 47281 request_update
344 manus 26913 end
345 bennob 47281
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 manus 26913
361 bennob 47281 update_links is
362     -- Update all links in `Current'.
363 manus 26913 local
364 bennob 47281 i, nb: INTEGER
365     l_link: EG_LINK_FIGURE
366 manus 26913 do
367     from
368 bennob 47281 i := 1
369 manus 26913 until
370 bennob 47281 i > nb
371 manus 26913 loop
372 bennob 47281 l_link ?= i_th (i)
373     if l_link /= Void then
374     l_link.update
375 manus 26913 end
376 bennob 47281 i := i + 1
377 manus 26913 end
378     end
379 bennob 47281
380 bennob 47394 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 bennob 47281 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