/[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 47281 - (hide annotations)
Tue Dec 28 19:31:21 2004 UTC (15 years, 1 month 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 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 47281
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     set_pebble (create {CLUSTER_STONE}.make (model.cluster_i))
48     model.needed_on_diagram_changed_actions.extend (agent on_needed_on_diagram_changed)
49 manus 26913 end
50 bennob 47281
51 manus 26913
52 bennob 47281 feature -- Status report
53 manus 26913
54 bennob 47281 is_iconified: BOOLEAN
55     -- Is `Current' iconified.
56    
57     feature -- Access
58 manus 26913
59 bennob 47281 model: ES_CLUSTER
60     -- Model for `Current'.
61    
62     world: EIFFEL_WORLD is
63     -- World `Current' is part of.
64 manus 26913 do
65 bennob 47281 Result ?= Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
66 manus 26913 end
67 bennob 47281
68 manus 26913 feature -- Element change
69    
70 bennob 47281 recycle is
71     -- Free `Current's resources.
72 manus 26913 do
73 bennob 47281 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 manus 26913 end
79 bennob 47281
80    
81     apply_right_angles is
82     -- Apply right angles to all links in `links' and all elements in `Current'.
83 manus 26913 local
84 bennob 47281 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 manus 26913 do
90 bennob 47281 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 manus 26913 end
101 bennob 47281 i := i + 1
102 manus 26913 end
103 bennob 47281 from
104     start
105     until
106     after
107     loop
108     clu ?= item
109     if clu /= Void then
110     clu.apply_right_angles
111 manus 26913 else
112 bennob 47281 cla ?= item
113     if cla /= Void then
114     cla.apply_right_angles
115     end
116 manus 26913 end
117 bennob 47281 forth
118 manus 26913 end
119     end
120    
121 bennob 47281 feature {EG_LAYOUT} -- Layouting
122 manus 26913
123 bennob 47281 set_to_minimum_size is
124     -- Set `Current's to `minimum_size'.
125     deferred
126 manus 26913 end
127 bennob 47281
128     feature {EIFFEL_WORLD} -- Show/Hide
129 manus 26913
130 bennob 47281 disable_shown is
131     -- Hide `Current'.
132     deferred
133     ensure
134     set: not is_shown
135 manus 26913 end
136 bennob 47281
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 manus 26913
149 bennob 47281 collapse is
150     -- Hide all elements in `Current' and minimize `Current'.
151 manus 26913 local
152 bennob 47281 linkable_figure: EG_LINKABLE_FIGURE
153     cluster_figure: EIFFEL_CLUSTER_FIGURE
154     e_item: ES_ITEM
155 manus 26913 do
156     from
157 bennob 47281 start
158 manus 26913 until
159 bennob 47281 after
160 manus 26913 loop
161 bennob 47281 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 manus 26913 end
182 bennob 47281 forth
183 manus 26913 end
184 bennob 47281 resizer_top_left.disable_sensitive
185     resizer_top_right.disable_sensitive
186     resizer_bottom_right.disable_sensitive
187     resizer_bottom_left.disable_sensitive
188 manus 26913 end
189 bennob 47281
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 manus 26913 do
199     from
200 bennob 47281 start
201 manus 26913 until
202 bennob 47281 after
203 manus 26913 loop
204 bennob 47281 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 manus 26913 end
235 bennob 47281 resizer_top_left.enable_sensitive
236     resizer_top_right.enable_sensitive
237     resizer_bottom_right.enable_sensitive
238     resizer_bottom_left.enable_sensitive
239 manus 26913 end
240 bennob 47281
241     feature {NONE} -- Implementation
242 manus 26913
243 bennob 47281 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 manus 26913 end
255    
256 bennob 47281 save_position is
257     -- Make a backup of current coordinates.
258 manus 26913 do
259 bennob 47281 saved_x := port_x
260     saved_y := port_y
261    
262 manus 26913 end
263 bennob 47281
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 manus 26913 do
270 bennob 47281 world.context_editor.restart_force_directed
271     if world.is_right_angles then
272     apply_right_angles
273 manus 26913 end
274     end
275    
276 bennob 47281 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 manus 26913 end
290 bennob 47281
291     on_linkable_add (a_linkable: EG_LINKABLE) is
292     -- `a_linkable' was added to the cluster.
293 manus 26913 local
294 bennob 47281 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 manus 26913 do
303 bennob 47281 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 manus 26913 from
313 bennob 47281 l_world.links.start
314 manus 26913 until
315 bennob 47281 l_world.links.after
316 manus 26913 loop
317 bennob 47281 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 manus 26913 end
343 bennob 47281 l_world.links.forth
344 manus 26913 end
345     end
346 bennob 47281 request_update
347 manus 26913 end
348 bennob 47281
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 manus 26913
364 bennob 47281 update_links is
365     -- Update all links in `Current'.
366 manus 26913 local
367 bennob 47281 i, nb: INTEGER
368     l_link: EG_LINK_FIGURE
369 manus 26913 do
370     from
371 bennob 47281 i := 1
372 manus 26913 until
373 bennob 47281 i > nb
374 manus 26913 loop
375 bennob 47281 l_link ?= i_th (i)
376     if l_link /= Void then
377     l_link.update
378 manus 26913 end
379 bennob 47281 i := i + 1
380 manus 26913 end
381     end
382 bennob 47281
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