/[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 62171 - (hide annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 5 months ago) by larryl
File size: 11022 byte(s)
First commit docking tabbed Eiffel Studio.
1 manus 26913 indexing
2 bennob 47281 description: "Common functionality for all views of ES_CLUSTERs"
3 manus 56535 legal: "See notice at end of class."
4     status: "See notice at end of class."
5 bennob 47281 author: ""
6 manus 26913 date: "$Date$"
7     revision: "$Revision$"
8    
9     deferred class
10 bennob 47281 EIFFEL_CLUSTER_FIGURE
11 tedf 58518
12 manus 26913 inherit
13 bennob 47281 EG_RESIZABLE_CLUSTER_FIGURE
14 manus 26913 redefine
15 bennob 47281 default_create,
16     initialize,
17     model,
18 manus 26913 world,
19 bennob 47281 on_linkable_add,
20     on_handle_start,
21     on_handle_end,
22 tedf 58518 recycle,
23     xml_element,
24     set_with_xml_element
25 manus 26913 end
26 tedf 58518
27 bennob 47281 EB_CONSTANTS
28 manus 26913 undefine
29 bennob 47281 default_create
30 manus 26913 end
31 bennob 47394
32 tedf 58518 EB_PIXMAPABLE_ITEM_PIXMAP_FACTORY
33     undefine
34     default_create
35     end
36    
37 manus 26913 feature {NONE} -- Initialization
38    
39 bennob 47281 default_create is
40     -- Create an CLUSTER_FIGURE.
41 manus 26913 do
42 bennob 47281 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
43 tedf 58518
44 bennob 47281 set_accept_cursor (cursors.cur_cluster)
45     set_deny_cursor (cursors.cur_x_cluster)
46 tedf 58518
47 bennob 47281 start_actions.extend (agent save_position)
48     end_actions.extend (agent extend_history)
49     move_actions.extend (agent on_move)
50 tedf 58518 create label_pixmap
51 manus 26913 end
52 tedf 58518
53 manus 26913 initialize is
54 bennob 47281 -- Initialize `Current' with `model'.
55 manus 26913 do
56 bennob 47281 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
57 bennob 47394 pebble_function := agent on_pebble_request
58 bennob 47281 model.needed_on_diagram_changed_actions.extend (agent on_needed_on_diagram_changed)
59 manus 26913 end
60    
61 bennob 47281 feature -- Status report
62 manus 26913
63 bennob 47281 is_iconified: BOOLEAN
64     -- Is `Current' iconified.
65 tedf 58518
66 bennob 47281 feature -- Access
67 manus 26913
68 bennob 47281 model: ES_CLUSTER
69     -- Model for `Current'.
70 tedf 58518
71 bennob 47281 world: EIFFEL_WORLD is
72     -- World `Current' is part of.
73 manus 26913 do
74 bennob 47281 Result ?= Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
75 manus 26913 end
76 tedf 58518
77     label_pixmap: EV_MODEL_PICTURE
78     -- The pixmap for the label.
79    
80 manus 26913 feature -- Element change
81    
82 bennob 47281 recycle is
83     -- Free `Current's resources.
84 manus 26913 do
85 bennob 47281 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
86     start_actions.prune_all (agent save_position)
87     end_actions.prune_all (agent extend_history)
88     move_actions.prune_all (agent on_move)
89 manus 53967 if model /= Void then
90     model.needed_on_diagram_changed_actions.prune_all (agent on_needed_on_diagram_changed)
91     end
92 manus 26913 end
93 tedf 58518
94    
95 bennob 47281 apply_right_angles is
96     -- Apply right angles to all links in `links' and all elements in `Current'.
97 manus 26913 local
98 bennob 47281 l_item: EIFFEL_LINK_FIGURE
99     l_links: like links
100     i, nb: INTEGER
101     clu: EIFFEL_CLUSTER_FIGURE
102     cla: EIFFEL_CLASS_FIGURE
103 manus 26913 do
104 bennob 47281 from
105     l_links := links
106     i := 1
107     nb := l_links.count
108     until
109     i > nb
110     loop
111     l_item ?= l_links.i_th (i)
112     if l_item /= Void then
113     l_item.apply_right_angles
114 manus 26913 end
115 bennob 47281 i := i + 1
116 manus 26913 end
117 bennob 47281 from
118     start
119     until
120     after
121     loop
122     clu ?= item
123     if clu /= Void then
124     clu.apply_right_angles
125 manus 26913 else
126 bennob 47281 cla ?= item
127     if cla /= Void then
128     cla.apply_right_angles
129     end
130 manus 26913 end
131 bennob 47281 forth
132 manus 26913 end
133     end
134    
135 tedf 58518 feature -- XML
136    
137     group_id_string: STRING is "GROUP_ID"
138     -- Group id
139    
140     cluster_id_string: STRING is "CLUSTER_ID"
141     -- ES_CLUSTER id string
142    
143     xml_element (node: XM_ELEMENT): XM_ELEMENT is
144     -- Xml element representing `Current's state.
145     do
146     Result := Precursor {EG_RESIZABLE_CLUSTER_FIGURE} (node)
147     node.add_attribute (group_id_string, xml_namespace, model.group_id)
148     node.add_attribute (cluster_id_string, xml_namespace, model.cluster_id)
149     end
150    
151     set_with_xml_element (node: XM_ELEMENT) is
152     -- Retrive state from `node'.
153     do
154     node.forth
155     node.forth
156     Precursor {EG_RESIZABLE_CLUSTER_FIGURE} (node)
157     -- Discard "CLUSTER_ID" and "GROUP_ID", since they have been read in factory.
158     end
159    
160 bennob 47281 feature {EG_LAYOUT} -- Layouting
161 manus 26913
162 bennob 47281 set_to_minimum_size is
163     -- Set `Current's to `minimum_size'.
164     deferred
165 manus 26913 end
166 tedf 58518
167 bennob 47281 feature {EIFFEL_WORLD} -- Show/Hide
168 manus 26913
169 bennob 47281 disable_shown is
170     -- Hide `Current'.
171     deferred
172     ensure
173     set: not is_shown
174 manus 26913 end
175 tedf 58518
176 bennob 47281 enable_shown is
177     -- Show `Current'.
178     deferred
179     ensure
180     set: is_shown
181     end
182 tedf 58518
183 bennob 47281 is_shown: BOOLEAN
184     -- Is `Current' shown?
185 tedf 58518
186 bennob 47281 feature {EIFFEL_CLUSTER_FIGURE} -- Expand/Collapse
187 manus 26913
188 bennob 47281 collapse is
189     -- Hide all elements in `Current' and minimize `Current'.
190 manus 26913 local
191 bennob 47281 linkable_figure: EG_LINKABLE_FIGURE
192     cluster_figure: EIFFEL_CLUSTER_FIGURE
193 bennob 47431 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
194     l_item: EG_LINK_FIGURE
195     i, nb: INTEGER
196 manus 26913 do
197     from
198 bennob 47281 start
199 manus 26913 until
200 bennob 47281 after
201 manus 26913 loop
202 tedf 58518 linkable_figure ?= item
203 bennob 47281 if linkable_figure /= Void then
204 bennob 47394 if linkable_figure.is_show_requested then
205 bennob 47281 linkable_figure.hide
206     linkable_figure.disable_sensitive
207     from
208 bennob 47431 l_links := linkable_figure.links
209     i := 1
210     nb := l_links.count
211 bennob 47281 until
212 bennob 47431 i > nb
213 bennob 47281 loop
214 bennob 47431 l_item := l_links.i_th (i)
215     l_item.hide
216     l_item.disable_sensitive
217     i := i + 1
218 bennob 47281 end
219     cluster_figure ?= linkable_figure
220     if cluster_figure /= Void and then not cluster_figure.is_iconified then
221     cluster_figure.collapse
222     end
223     end
224 manus 26913 end
225 bennob 47281 forth
226 manus 26913 end
227 bennob 47281 resizer_top_left.disable_sensitive
228     resizer_top_right.disable_sensitive
229     resizer_bottom_right.disable_sensitive
230     resizer_bottom_left.disable_sensitive
231 manus 26913 end
232 tedf 58518
233 bennob 47281 expand is
234     -- Show all not iconified elements in `Current'.
235     local
236     linkable_figure: EG_LINKABLE_FIGURE
237     l_other: EG_LINKABLE_FIGURE
238     l_link: EG_LINK_FIGURE
239     cluster_figure: EIFFEL_CLUSTER_FIGURE
240     e_item: ES_ITEM
241 bennob 47431 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
242     i, nb: INTEGER
243 manus 26913 do
244     from
245 bennob 47281 start
246 manus 26913 until
247 bennob 47281 after
248 manus 26913 loop
249 bennob 47281 linkable_figure ?= item
250     if linkable_figure /= Void then
251     e_item ?= linkable_figure.model
252     if e_item = Void or else e_item.is_needed_on_diagram then
253     linkable_figure.show
254     linkable_figure.enable_sensitive
255     from
256 bennob 47431 l_links := linkable_figure.links
257     i := 1
258     nb := l_links.count
259 bennob 47281 until
260 bennob 47431 i > nb
261 bennob 47281 loop
262 bennob 47431 l_link := l_links.i_th (i)
263 bennob 47281 if l_link.source = linkable_figure then
264     l_other := l_link.target
265     else
266     l_other := l_link.source
267     end
268     if l_other.is_show_requested then
269     l_link.show
270     l_link.enable_sensitive
271     end
272 bennob 47431 i := i + 1
273 bennob 47281 end
274     cluster_figure ?= linkable_figure
275     if cluster_figure /= Void and then not cluster_figure.is_iconified then
276     cluster_figure.expand
277     end
278     end
279     end
280     forth
281 manus 26913 end
282 bennob 47281 resizer_top_left.enable_sensitive
283     resizer_top_right.enable_sensitive
284     resizer_bottom_right.enable_sensitive
285     resizer_bottom_left.enable_sensitive
286 manus 26913 end
287 tedf 58518
288 bennob 47281 feature {NONE} -- Implementation
289 manus 26913
290 bennob 47281 on_needed_on_diagram_changed is
291     -- `model'.`is_needed_on_diagram' changed.
292     do
293     if model.is_needed_on_diagram then
294     show
295     enable_sensitive
296     else
297     hide
298     disable_sensitive
299     end
300     request_update
301 manus 26913 end
302    
303 bennob 47281 save_position is
304     -- Make a backup of current coordinates.
305 manus 26913 do
306 bennob 47281 saved_x := port_x
307     saved_y := port_y
308 tedf 58518
309 manus 26913 end
310 tedf 58518
311 bennob 47281 saved_x, saved_y: INTEGER
312     -- Saved positions.
313 tedf 58518
314 bennob 47281 on_move (ax, ay: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
315     -- Cluster is moving.
316 manus 26913 do
317 bennob 47281 world.context_editor.restart_force_directed
318     if world.is_right_angles then
319     apply_right_angles
320 manus 26913 end
321     end
322    
323 bennob 47281 extend_history is
324     -- Register move in the history.
325     local
326 larryl 62171 ce: EB_DIAGRAM_TOOL
327 bennob 47281 do
328     ce := world.context_editor
329     world.context_editor.history.do_named_undoable (
330 bennob 47615 interface_names.t_Diagram_move_cluster_cmd (model.name),
331 bennob 47281 [<<agent set_port_position (port_x, port_y), agent ce.restart_force_directed>>],
332     [<<agent set_port_position (saved_x, saved_y), agent ce.restart_force_directed>>])
333     if world.context_editor.is_force_directed_used then
334     set_is_fixed (True)
335     end
336 manus 26913 end
337 tedf 58518
338 bennob 47281 on_linkable_add (a_linkable: EG_LINKABLE) is
339     -- `a_linkable' was added to the cluster.
340 manus 26913 local
341 bennob 47281 l_world: like world
342     linkable_fig: EG_LINKABLE_FIGURE
343     link_fig: EG_LINK_FIGURE
344     scsc: EG_CLUSTER_FIGURE
345     e_item: ES_ITEM
346     cs_link: EIFFEL_CLIENT_SUPPLIER_FIGURE
347     i_link: EIFFEL_INHERITANCE_FIGURE
348     c_fig: EG_LINKABLE_FIGURE
349 manus 26913 do
350 bennob 47281 l_world := world
351     if l_world /= Void then
352     linkable_fig ?= l_world.items_to_figure_lookup_table.item (a_linkable)
353     check
354     linkable_fig_is_in_view_but_not_in_cluster: linkable_fig /= Void not has (linkable_fig)
355     end
356     extend (linkable_fig)
357     linkable_fig.set_cluster (Current)
358 tedf 58518
359 manus 26913 from
360 bennob 47281 l_world.links.start
361 manus 26913 until
362 bennob 47281 l_world.links.after
363 manus 26913 loop
364 bennob 47281 link_fig := l_world.links.item
365     if link_fig.source /= Void and then link_fig.target /= Void then
366     e_item ?= link_fig.model
367     if e_item = Void or else e_item.is_needed_on_diagram then
368     scsc := world.smallest_common_supercluster (link_fig.source, link_fig.target)
369     if scsc /= Void and then not scsc.has (link_fig) then
370     scsc.go_i_th (scsc.number_of_figures)
371     cs_link ?= link_fig
372     if cs_link /= Void or else scsc.index = scsc.count then
373     scsc.put_right (link_fig)
374     else
375     from
376     i_link := Void
377     c_fig := Void
378     until
379     i_link /= Void or else c_fig /= Void
380     loop
381     scsc.forth
382     i_link ?= scsc.item
383     c_fig ?= scsc.item
384     end
385     scsc.put_left (link_fig)
386     end
387     end
388     end
389 manus 26913 end
390 bennob 47281 l_world.links.forth
391 manus 26913 end
392     end
393 bennob 47281 request_update
394 manus 26913 end
395 tedf 58518
396 bennob 47281 on_handle_start is
397     -- User started to move `Current'.
398     do
399     was_fixed := is_fixed
400     if world.context_editor.is_force_directed_used then
401     set_is_fixed (True)
402     end
403     end
404 tedf 58518
405 bennob 47281 on_handle_end is
406     -- User ended to move `Current'.
407     do
408     set_is_fixed (was_fixed)
409     end
410 manus 26913
411 bennob 47281 update_links is
412     -- Update all links in `Current'.
413 manus 26913 local
414 bennob 47281 i, nb: INTEGER
415     l_link: EG_LINK_FIGURE
416 manus 26913 do
417     from
418 bennob 47281 i := 1
419 manus 26913 until
420 bennob 47281 i > nb
421 manus 26913 loop
422 bennob 47281 l_link ?= i_th (i)
423     if l_link /= Void then
424     l_link.update
425 manus 26913 end
426 bennob 47281 i := i + 1
427 manus 26913 end
428     end
429 tedf 58518
430     on_pebble_request: CLUSTER_FIGURE_STONE is
431 bennob 47394 -- Pebble request.
432     do
433     if model /= Void then
434 tedf 58518 create Result.make (Current)
435 bennob 47394 end
436     end
437    
438 manus 56535 indexing
439     copyright: "Copyright (c) 1984-2006, Eiffel Software"
440 manus 58027 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
441 manus 56535 licensing_options: "http://www.eiffel.com/licensing"
442     copying: "[
443     This file is part of Eiffel Software's Eiffel Development Environment.
444    
445     Eiffel Software's Eiffel Development Environment is free
446     software; you can redistribute it and/or modify it under
447     the terms of the GNU General Public License as published
448     by the Free Software Foundation, version 2 of the License
449     (available at the URL listed under "license" above).
450    
451     Eiffel Software's Eiffel Development Environment is
452     distributed in the hope that it will be useful, but
453     WITHOUT ANY WARRANTY; without even the implied warranty
454     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
455     See the GNU General Public License for more details.
456    
457     You should have received a copy of the GNU General Public
458     License along with Eiffel Software's Eiffel Development
459     Environment; if not, write to the Free Software Foundation,
460     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
461     ]"
462     source: "[
463     Eiffel Software
464     356 Storke Road, Goleta, CA 93117 USA
465     Telephone 805-685-1006, Fax 805-685-6869
466     Website http://www.eiffel.com
467     Customer support http://support.eiffel.com
468     ]"
469    
470 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