/[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 53967 - (hide 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 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 manus 53967 if model /= Void then
77     model.needed_on_diagram_changed_actions.prune_all (agent on_needed_on_diagram_changed)
78     end
79 manus 26913 end
80 bennob 47281
81    
82     apply_right_angles is
83     -- Apply right angles to all links in `links' and all elements in `Current'.
84 manus 26913 local
85 bennob 47281 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 manus 26913 do
91 bennob 47281 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 manus 26913 end
102 bennob 47281 i := i + 1
103 manus 26913 end
104 bennob 47281 from
105     start
106     until
107     after
108     loop
109     clu ?= item
110     if clu /= Void then
111     clu.apply_right_angles
112 manus 26913 else
113 bennob 47281 cla ?= item
114     if cla /= Void then
115     cla.apply_right_angles
116     end
117 manus 26913 end
118 bennob 47281 forth
119 manus 26913 end
120     end
121    
122 bennob 47281 feature {EG_LAYOUT} -- Layouting
123 manus 26913
124 bennob 47281 set_to_minimum_size is
125     -- Set `Current's to `minimum_size'.
126     deferred
127 manus 26913 end
128 bennob 47281
129     feature {EIFFEL_WORLD} -- Show/Hide
130 manus 26913
131 bennob 47281 disable_shown is
132     -- Hide `Current'.
133     deferred
134     ensure
135     set: not is_shown
136 manus 26913 end
137 bennob 47281
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 manus 26913
150 bennob 47281 collapse is
151     -- Hide all elements in `Current' and minimize `Current'.
152 manus 26913 local
153 bennob 47281 linkable_figure: EG_LINKABLE_FIGURE
154     cluster_figure: EIFFEL_CLUSTER_FIGURE
155 bennob 47431 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
156     l_item: EG_LINK_FIGURE
157     i, nb: INTEGER
158 manus 26913 do
159     from
160 bennob 47281 start
161 manus 26913 until
162 bennob 47281 after
163 manus 26913 loop
164 bennob 47281 linkable_figure ?= item
165     if linkable_figure /= Void then
166 bennob 47394 if linkable_figure.is_show_requested then
167 bennob 47281 linkable_figure.hide
168     linkable_figure.disable_sensitive
169     from
170 bennob 47431 l_links := linkable_figure.links
171     i := 1
172     nb := l_links.count
173 bennob 47281 until
174 bennob 47431 i > nb
175 bennob 47281 loop
176 bennob 47431 l_item := l_links.i_th (i)
177     l_item.hide
178     l_item.disable_sensitive
179     i := i + 1
180 bennob 47281 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 manus 26913 end
187 bennob 47281 forth
188 manus 26913 end
189 bennob 47281 resizer_top_left.disable_sensitive
190     resizer_top_right.disable_sensitive
191     resizer_bottom_right.disable_sensitive
192     resizer_bottom_left.disable_sensitive
193 manus 26913 end
194 bennob 47281
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 bennob 47431 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
204     i, nb: INTEGER
205 manus 26913 do
206     from
207 bennob 47281 start
208 manus 26913 until
209 bennob 47281 after
210 manus 26913 loop
211 bennob 47281 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 bennob 47431 l_links := linkable_figure.links
219     i := 1
220     nb := l_links.count
221 bennob 47281 until
222 bennob 47431 i > nb
223 bennob 47281 loop
224 bennob 47431 l_link := l_links.i_th (i)
225 bennob 47281 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 bennob 47431 i := i + 1
235 bennob 47281 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 manus 26913 end
244 bennob 47281 resizer_top_left.enable_sensitive
245     resizer_top_right.enable_sensitive
246     resizer_bottom_right.enable_sensitive
247     resizer_bottom_left.enable_sensitive
248 manus 26913 end
249 bennob 47281
250     feature {NONE} -- Implementation
251 manus 26913
252 bennob 47281 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 manus 26913 end
264    
265 bennob 47281 save_position is
266     -- Make a backup of current coordinates.
267 manus 26913 do
268 bennob 47281 saved_x := port_x
269     saved_y := port_y
270    
271 manus 26913 end
272 bennob 47281
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 manus 26913 do
279 bennob 47281 world.context_editor.restart_force_directed
280     if world.is_right_angles then
281     apply_right_angles
282 manus 26913 end
283     end
284    
285 bennob 47281 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 bennob 47615 interface_names.t_Diagram_move_cluster_cmd (model.name),
293 bennob 47281 [<<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 manus 26913 end
299 bennob 47281
300     on_linkable_add (a_linkable: EG_LINKABLE) is
301     -- `a_linkable' was added to the cluster.
302 manus 26913 local
303 bennob 47281 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 manus 26913 do
312 bennob 47281 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 manus 26913 from
322 bennob 47281 l_world.links.start
323 manus 26913 until
324 bennob 47281 l_world.links.after
325 manus 26913 loop
326 bennob 47281 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 manus 26913 end
352 bennob 47281 l_world.links.forth
353 manus 26913 end
354     end
355 bennob 47281 request_update
356 manus 26913 end
357 bennob 47281
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 manus 26913
373 bennob 47281 update_links is
374     -- Update all links in `Current'.
375 manus 26913 local
376 bennob 47281 i, nb: INTEGER
377     l_link: EG_LINK_FIGURE
378 manus 26913 do
379     from
380 bennob 47281 i := 1
381 manus 26913 until
382 bennob 47281 i > nb
383 manus 26913 loop
384 bennob 47281 l_link ?= i_th (i)
385     if l_link /= Void then
386     l_link.update
387 manus 26913 end
388 bennob 47281 i := i + 1
389 manus 26913 end
390     end
391 bennob 47281
392 bennob 47394 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 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