/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_add_class_figure_relations_command.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_add_class_figure_relations_command.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62171 - (show annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 4 months ago) by larryl
File size: 14550 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Command used for adding a certain class relations to diagram class figure"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: ""
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EB_ADD_CLASS_FIGURE_RELATIONS_COMMAND
11
12 inherit
13 EB_CONTEXT_DIAGRAM_COMMAND
14 redefine
15 new_toolbar_item,
16 description
17 end
18
19 create
20 make_for_clients, make_for_suppliers, make_for_descendents, make_for_ancestors
21
22 feature {NONE} -- Initialization
23
24 make_for_clients (a_target: like tool) is
25 -- Initialize the command with target `a_target' to handle client relations.
26 require
27 a_target_not_void: a_target /= Void
28 do
29 selected_implementation := adds_clients
30 make (a_target)
31 end
32
33 make_for_suppliers (a_target: like tool) is
34 -- Initialize the command with target `a_target' to handle supplier relations.
35 require
36 a_target_not_void: a_target /= Void
37 do
38 selected_implementation := adds_suppliers
39 make (a_target)
40 end
41
42 make_for_ancestors (a_target: like tool) is
43 -- Initialize the command with target `a_target' to handle ancestor relations.
44 require
45 a_target_not_void: a_target /= Void
46 do
47 selected_implementation := adds_ancestors
48 make (a_target)
49 end
50
51 make_for_descendents (a_target: like tool) is
52 -- Initialize the command with target `a_target' to handle descendent relations.
53 require
54 a_target_not_void: a_target /= Void
55 do
56 selected_implementation := adds_descendents
57 make (a_target)
58 end
59
60 feature -- Basic operations
61
62 execute is
63 -- Perform operation.
64 local
65 l_sel_figures: ARRAYED_LIST [EG_FIGURE]
66 l_class_list: ARRAYED_LIST [ES_CLASS]
67 l_class: ES_CLASS
68 l_class_added: BOOLEAN
69 explain_dialog: EB_INFORMATION_DIALOG
70 do
71 if is_sensitive then
72 -- Show relations for selected classes.
73 l_sel_figures := tool.world.selected_figures
74 if l_sel_figures /= Void and then not l_sel_figures.is_empty then
75 from
76 create l_class_list.make (5)
77 l_sel_figures.start
78 until
79 l_sel_figures.after
80 loop
81 l_class ?= l_sel_figures.item.model
82 if l_class /= Void then
83 if l_class.class_i.compiled then
84 l_class_list.extend (l_class)
85 l_class_added := True
86 end
87 end
88 l_sel_figures.forth
89 end
90 if l_class_added then
91 calculate_relations_for_classes (l_class_list)
92 end
93 else
94 create explain_dialog.make_with_text (Interface_names.e_Diagram_add_class_figure_relations)
95 explain_dialog.show_modal_to_window (tool.develop_window.window)
96 end
97 end
98 end
99
100 relations_list_from_class_c (a_class: CLASS_C): LIST [CLASS_C] is
101 -- Return all of the compiled relations for `a_class'.
102 require
103 a_class_not_void: a_class /= Void
104 do
105 inspect
106 selected_implementation
107 when adds_suppliers then
108 Result := a_class.syntactical_suppliers
109 when adds_clients then
110 Result := a_class.syntactical_clients
111 when adds_ancestors then
112 Result := a_class.parents_classes
113 when adds_descendents then
114 Result := a_class.descendants
115 end
116 end
117
118 calculate_relations_for_classes (a_classes: ARRAYED_LIST [ES_CLASS]) is
119 -- Calculate relations for `a_classes'.
120 require
121 a_classes_not_void: a_classes /= Void
122 a_classes_not_empty: not a_classes.is_empty
123 local
124 l_relations_list: LIST [CLASS_C]
125 l_added_class_relations_list: ARRAYED_LIST [ES_CLASS]
126 l_added_class_relations_list_list: ARRAYED_LIST [ARRAYED_LIST [ES_CLASS]]
127 l_class_graph: ES_CLASS_GRAPH
128 l_added_class: ES_CLASS
129 l_class_added: BOOLEAN
130 l_cluster: ES_CLUSTER
131 l_classes: ARRAYED_LIST [ES_CLASS]
132 do
133 l_class_graph := tool.class_graph
134 if l_class_graph /= Void then
135 from
136 create l_added_class_relations_list_list.make (5)
137 a_classes.start
138 until
139 a_classes.after
140 loop
141 l_cluster := a_classes.item.cluster
142 l_relations_list := relations_list_from_class_c (a_classes.item.class_i.compiled_class)
143 if l_relations_list /= Void then
144 create l_added_class_relations_list.make (5)
145 from
146 l_relations_list.start
147 until
148 l_relations_list.after
149 loop
150 l_classes := l_class_graph.class_from_interface (l_relations_list.item.lace_class)
151 l_added_class := Void
152 if not l_classes.is_empty then
153 l_added_class := l_classes.first
154 end
155 if l_added_class = Void then
156 -- Class has not been generated on to the diagram so we need to add it.
157 create l_added_class.make (l_relations_list.item.lace_class)
158 l_class_graph.add_node (l_added_class)
159 l_class_graph.add_node_relations (l_added_class)
160 l_added_class.disable_needed_on_diagram
161 end
162
163 if not l_added_class.is_needed_on_diagram then
164 -- Class has been generated but is not presently shown
165 l_added_class_relations_list.extend (l_added_class)
166 l_class_added := True
167 else
168 -- Class is already present and shown on the diagram
169 -- Links from current may need to be added
170 end
171 l_relations_list.forth
172 end
173 l_added_class_relations_list_list.extend (l_added_class_relations_list)
174 end
175 a_classes.forth
176 end
177 if l_class_added then
178 tool.history.do_named_undoable (undo_name, agent add_and_position_classes (a_classes, l_added_class_relations_list_list), agent hide_classes_from_diagram (l_added_class_relations_list_list))
179 end
180 end
181 end
182
183 undo_name: STRING is
184 -- Undo name for operation of `Current'.
185 do
186 inspect
187 selected_implementation
188 when adds_suppliers then
189 Result := "Class Figure Suppliers Added"
190 when adds_clients then
191 Result := "Class Figure Clients Added"
192 when adds_ancestors then
193 Result := "Class Figure Ancestors Added"
194 when adds_descendents then
195 Result := "Class Figure Descendents Added"
196 end
197 end
198
199 hide_classes_from_diagram (a_class_list_list: ARRAYED_LIST [ARRAYED_LIST [ES_CLASS]]) is
200 -- Hide all classes in `a_class_list_list' on diagram.
201 local
202 l_list: ARRAYED_LIST [ES_CLASS]
203 a_links: LIST [ES_ITEM]
204 do
205 from
206 a_class_list_list.start
207 until
208 a_class_list_list.after
209 loop
210 from
211 l_list := a_class_list_list.item
212 l_list.start
213 until
214 l_list.after
215 loop
216 l_list.item.disable_needed_on_diagram
217 a_links := l_list.item.needed_links
218 from
219 a_links.start
220 until
221 a_links.after
222 loop
223 a_links.item.disable_needed_on_diagram
224 a_links.forth
225 end
226 l_list.forth
227 end
228 a_class_list_list.forth
229 end
230 tool.projector.full_project
231 end
232
233
234 add_and_position_classes (a_class_list: ARRAYED_LIST [ES_CLASS]; a_class_list_list: ARRAYED_LIST [ARRAYED_LIST [ES_CLASS]]) is
235 --
236 require
237 a_class_list_not_void: a_class_list /= Void and then not a_class_list.is_empty
238 a_class_list_list_valid: a_class_list_list /= Void and then not a_class_list_list.is_empty
239 local
240 l_class_figure, l_supplier_class_figure: EIFFEL_CLASS_FIGURE
241 l_x, l_y, l_x_offset, l_y_offset: INTEGER
242 l_class_graph: ES_CLASS_GRAPH
243 l_list: ARRAYED_LIST [ES_CLASS]
244 do
245 from
246 a_class_list.start
247 l_class_graph := tool.class_graph
248 l_x_offset := tool.layout.horizontal_spacing
249 l_y_offset := tool.layout.vertical_spacing
250 until
251 a_class_list.after or l_class_graph = Void
252 loop
253 from
254 l_class_figure ?= tool.world.figure_from_model (a_class_list.item)
255 l_list := a_class_list_list @ a_class_list.index
256 l_list.start
257 inspect
258 selected_implementation
259 when adds_suppliers then
260 l_x := l_class_figure.x + l_class_figure.width + l_x_offset
261 l_y := l_class_figure.y - ((l_list.count - 1) * ((l_y_offset + l_class_figure.height) // 2))
262 when adds_clients then
263 l_x := l_class_figure.x - l_class_figure.width - l_x_offset
264 l_y := l_class_figure.y - ((l_list.count - 1) * ((l_y_offset + l_class_figure.height) // 2))
265 when adds_ancestors then
266 l_x := l_class_figure.x - ((l_list.count - 1) * ((l_x_offset + l_class_figure.width) // 2))
267 l_y := l_class_figure.y - l_class_figure.height - l_y_offset
268 when adds_descendents then
269 l_x := l_class_figure.x - ((l_list.count - 1) * ((l_x_offset + l_class_figure.width) // 2))
270 l_y := l_class_figure.y + l_class_figure.height + l_y_offset
271 end
272 until
273 l_list.after
274 loop
275 l_list.item.enable_needed_on_diagram
276 l_class_graph.add_client_relations (l_list.item)
277 l_class_graph.add_supplier_relations (l_list.item)
278 l_class_graph.add_descendant_relations (l_list.item)
279 l_class_graph.add_ancestor_relations (l_list.item)
280 l_supplier_class_figure ?= tool.world.figure_from_model (l_list.item)
281 l_supplier_class_figure.set_x_y (l_x, l_y)
282 inspect
283 selected_implementation
284 when adds_suppliers then
285 l_y := l_y + l_y_offset + l_class_figure.height
286 when adds_clients then
287 l_y := l_y + l_y_offset + l_class_figure.height
288 when adds_ancestors then
289 l_x := l_x + l_x_offset + l_class_figure.width
290 when adds_descendents then
291 l_x := l_x + l_x_offset + l_class_figure.width
292 end
293 l_list.forth
294 end
295 a_class_list.forth
296 end
297 tool.projector.full_project
298 end
299
300 execute_with_class_stone (a_stone: CLASSI_STONE) is
301 -- Handle pick and drop for `a_stone'.
302 local
303 a_class_list: ARRAYED_LIST [ES_CLASS]
304 es_class: ES_CLASS
305 cf: CLASSI_FIGURE_STONE
306 do
307 cf ?= a_stone
308 if cf /= Void then
309 es_class := cf.source.model
310 end
311 if es_class /= Void then
312 if es_class.is_compiled then
313 create a_class_list.make (1)
314 a_class_list.extend (es_class)
315 calculate_relations_for_classes (a_class_list)
316 end
317 end
318 end
319
320 execute_with_class_list (a_stone: CLASS_FIGURE_LIST_STONE) is
321 -- Handle pick and drop for `a_stone'.
322 local
323 a_class_list: ARRAYED_LIST [ES_CLASS]
324 l_classes: LIST [EIFFEL_CLASS_FIGURE]
325 es_class: ES_CLASS
326 do
327 from
328 l_classes := a_stone.classes
329 l_classes.start
330 create a_class_list.make (5)
331 until
332 l_classes.after
333 loop
334 es_class := l_classes.item.model
335 if es_class.is_compiled then
336 a_class_list.extend (es_class)
337 end
338 l_classes.forth
339 end
340 if not a_class_list.is_empty then
341 calculate_relations_for_classes (a_class_list)
342 end
343 end
344
345 new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is
346 -- Create a new toolbar button for this command.
347 --
348 -- Call `recycle' on the result when you don't need it anymore otherwise
349 -- it will never be garbage collected.
350 do
351 create Result.make (Current)
352 current_button := Result
353 initialize_toolbar_item (Result, display_text)
354 Result.select_actions.extend (agent execute)
355 Result.drop_actions.extend (agent execute_with_class_stone)
356 Result.drop_actions.extend (agent execute_with_class_list)
357 end
358
359 feature -- Access
360
361 tooltip: STRING is
362 -- Tooltip for the toolbar button.
363 do
364 inspect
365 selected_implementation
366 when adds_suppliers then
367 Result := interface_names.l_diagram_add_suppliers
368 when adds_clients then
369 Result := interface_names.l_diagram_add_clients
370 when adds_descendents then
371 Result := interface_names.l_diagram_add_descendents
372 when adds_ancestors then
373 Result := interface_names.l_diagram_add_ancestors
374 end
375 end
376
377 feature {NONE} -- Implementation
378
379 pixmap: EV_PIXMAP is
380 -- Pixmap representing the command.
381 do
382 inspect
383 selected_implementation
384 when adds_suppliers then
385 Result := pixmaps.icon_pixmaps.class_supliers_icon
386 when adds_clients then
387 Result := pixmaps.icon_pixmaps.class_clients_icon
388 when adds_descendents then
389 Result := pixmaps.icon_pixmaps.class_descendents_icon
390 when adds_ancestors then
391 Result := pixmaps.icon_pixmaps.class_ancestors_icon
392 end
393 end
394
395 pixel_buffer: EV_PIXEL_BUFFER is
396 -- Pixel buffer representing the command.
397 do
398 inspect
399 selected_implementation
400 when adds_suppliers then
401 Result := pixmaps.icon_pixmaps.class_supliers_icon_buffer
402 when adds_clients then
403 Result := pixmaps.icon_pixmaps.class_clients_icon_buffer
404 when adds_descendents then
405 Result := pixmaps.icon_pixmaps.class_descendents_icon_buffer
406 when adds_ancestors then
407 Result := pixmaps.icon_pixmaps.class_ancestors_icon_buffer
408 end
409 end
410
411 description: STRING is
412 -- Description for this command.
413 do
414 inspect
415 selected_implementation
416 when adds_suppliers then
417 Result := interface_names.l_diagram_add_suppliers
418 when adds_clients then
419 Result := interface_names.l_diagram_add_clients
420 when adds_descendents then
421 Result := interface_names.l_diagram_add_descendents
422 when adds_ancestors then
423 Result := interface_names.l_diagram_add_ancestors
424 end
425 end
426
427 Name: STRING is "Supplier_visibility"
428 -- Name of the command. Used to store the command in the
429 -- preferences.
430
431 feature {EB_CONTEXT_EDITOR} -- Implementation
432
433 selected_implementation: INTEGER
434 -- Implementation used for `Current', set in creation procedure.
435
436 adds_clients, adds_suppliers, adds_descendents, adds_ancestors: INTEGER is unique
437 -- Constants used to define the behavior of `Current'.
438
439 current_button: EB_COMMAND_TOOL_BAR_BUTTON;
440 -- Current toggle button.
441
442 indexing
443 copyright: "Copyright (c) 1984-2006, Eiffel Software"
444 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
445 licensing_options: "http://www.eiffel.com/licensing"
446 copying: "[
447 This file is part of Eiffel Software's Eiffel Development Environment.
448
449 Eiffel Software's Eiffel Development Environment is free
450 software; you can redistribute it and/or modify it under
451 the terms of the GNU General Public License as published
452 by the Free Software Foundation, version 2 of the License
453 (available at the URL listed under "license" above).
454
455 Eiffel Software's Eiffel Development Environment is
456 distributed in the hope that it will be useful, but
457 WITHOUT ANY WARRANTY; without even the implied warranty
458 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
459 See the GNU General Public License for more details.
460
461 You should have received a copy of the GNU General Public
462 License along with Eiffel Software's Eiffel Development
463 Environment; if not, write to the Free Software Foundation,
464 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
465 ]"
466 source: "[
467 Eiffel Software
468 356 Storke Road, Goleta, CA 93117 USA
469 Telephone 805-685-1006, Fax 805-685-6869
470 Website http://www.eiffel.com
471 Customer support http://support.eiffel.com
472 ]"
473 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date ID Revision

  ViewVC Help
Powered by ViewVC 1.1.23