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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_delete_figure_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: 10796 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description : "Command to delete diagram components."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date : "$Date$"
6 revision : "$Revision$"
7
8 class
9 EB_DELETE_FIGURE_COMMAND
10
11 inherit
12 EB_CONTEXT_DIAGRAM_COMMAND
13 redefine
14 new_toolbar_item,
15 description
16 end
17
18 create
19 make
20
21 feature -- Basic operations
22
23 execute is
24 -- Display information about `Current'.
25 do
26 create explain_dialog.make_with_text (Interface_names.e_Diagram_delete_figure)
27 explain_dialog.show_modal_to_window (tool.develop_window.window)
28 end
29
30 feature -- Access
31
32 new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is
33 -- Create a new toolbar button for this command.
34 do
35 Result := Precursor (display_text)
36 Result.drop_actions.extend (agent execute_with_class_stone)
37 Result.drop_actions.extend (agent execute_with_cluster_stone)
38 Result.drop_actions.extend (agent execute_with_link_midpoint)
39 Result.drop_actions.extend (agent execute_with_inheritance_stone)
40 Result.drop_actions.extend (agent execute_with_client_stone)
41 Result.drop_actions.extend (agent execute_with_class_list)
42 end
43
44 pixmap: EV_PIXMAP is
45 -- Pixmap representing the command.
46 do
47 Result := pixmaps.icon_pixmaps.general_reset_icon
48 end
49
50 pixel_buffer: EV_PIXEL_BUFFER is
51 -- Pixel buffer representing the command.
52 do
53 -- Currently there is no pixel buffer for this command.
54 end
55
56 tooltip: STRING is
57 -- Tooltip for the toolbar button.
58 do
59 Result := Interface_names.f_diagram_remove
60 end
61
62 description: STRING is
63 -- Description for this command.
64 do
65 Result := Interface_names.l_diagram_remove
66 end
67
68 name: STRING is "Delete_hole"
69 -- Name of the command. Used to store the command in the
70 -- preferences.
71
72 explain_dialog: EB_INFORMATION_DIALOG
73 -- Dialog explaining how to use `Current'.
74
75 feature {NONE} -- Implementation
76
77 execute_with_class_stone (a_stone: CLASSI_FIGURE_STONE) is
78 -- Remove `a_stone' from diagram.
79 -- (And its relations.)
80 local
81 l_world: EIFFEL_WORLD
82 es_class: ES_CLASS
83 class_fig: EIFFEL_CLASS_FIGURE
84 old_x, old_y: INTEGER
85 l_projector: EIFFEL_PROJECTOR
86 remove_links: LIST [ES_ITEM]
87 do
88 l_world := tool.world
89 class_fig ?= a_stone.source
90 if class_fig /= Void then
91 old_x := class_fig.port_x
92 old_y := class_fig.port_y
93 l_projector := tool.projector
94 es_class := class_fig.model
95 remove_links := es_class.needed_links
96 tool.restart_force_directed
97 history.do_named_undoable (
98 interface_names.t_diagram_erase_class_cmd (es_class.name),
99 [<<agent l_world.remove_class_virtual (class_fig, remove_links), agent l_projector.full_project, agent tool.restart_force_directed, agent l_world.update_cluster_legend>>],
100 [<<agent l_world.reinclude_class (class_fig, remove_links, old_x, old_y), agent l_projector.full_project, agent tool.restart_force_directed, agent l_world.update_cluster_legend>>])
101 end
102 end
103
104 execute_with_class_list (a_stone: CLASS_FIGURE_LIST_STONE) is
105 -- Remove `a_stone' from diagram.
106 local
107 undo_list: ARRAYED_LIST [TUPLE [INTEGER, INTEGER, LIST [ES_ITEM]]]
108 l_classes: LIST [EIFFEL_CLASS_FIGURE]
109 l_world: EIFFEL_WORLD
110 do
111 from
112 l_classes := a_stone.classes
113 create undo_list.make (l_classes.count)
114 l_classes.start
115 until
116 l_classes.after
117 loop
118 undo_list.extend ([l_classes.item.port_x, l_classes.item.port_y, l_classes.item.model.needed_links])
119 l_classes.forth
120 end
121
122 l_world := tool.world
123
124 history.do_named_undoable (
125 interface_names.t_diagram_erase_classes_cmd,
126 [<<agent remove_class_list (a_stone.classes), agent tool.restart_force_directed, agent l_world.update_cluster_legend>>],
127 [<<agent reinclude_class_list (a_stone.classes, undo_list), agent tool.restart_force_directed, agent l_world.update_cluster_legend>>])
128 end
129
130 remove_class_list (a_list: LIST [EIFFEL_CLASS_FIGURE]) is
131 -- Remove all classes in `a_list'.
132 local
133 l_world: EIFFEL_WORLD
134 es_class: ES_CLASS
135 class_fig: EIFFEL_CLASS_FIGURE
136 l_links: LIST [ES_ITEM]
137 do
138 l_world := tool.world
139 from
140 a_list.start
141 until
142 a_list.after
143 loop
144 class_fig := a_list.item
145 es_class := class_fig.model
146 es_class.disable_needed_on_diagram
147 from
148 l_links := es_class.needed_links
149 l_links.start
150 until
151 l_links.after
152 loop
153 l_links.item.disable_needed_on_diagram
154 l_links.forth
155 end
156 a_list.forth
157 end
158 tool.projector.full_project
159 end
160
161 reinclude_class_list (a_list: LIST [EIFFEL_CLASS_FIGURE]; undo_list: LIST [TUPLE [INTEGER, INTEGER, LIST [ES_ITEM]]]) is
162 -- Reinclude all classes in `a_list' to position in `undo_list' TUPLE and reinclude all links in `undo_list'.
163 local
164 l_world: EIFFEL_WORLD
165 es_class: ES_CLASS
166 class_fig: EIFFEL_CLASS_FIGURE
167 remove_links: LIST [ES_ITEM]
168 l_item: TUPLE [INTEGER, INTEGER, LIST [ES_ITEM]]
169 do
170 l_world := tool.world
171 from
172 a_list.start
173 undo_list.start
174 until
175 a_list.after
176 loop
177 class_fig := a_list.item
178 es_class := class_fig.model
179 l_item := undo_list.item
180 remove_links ?= l_item.item (3)
181 l_world.reinclude_class (class_fig, remove_links, l_item.integer_item (1), l_item.integer_item (2))
182 a_list.forth
183 undo_list.forth
184 end
185 tool.projector.full_project
186 end
187
188 execute_with_cluster_stone (a_stone: CLUSTER_FIGURE_STONE) is
189 -- Remove `a_stone' from diagram.
190 -- (And its relations.)
191 local
192 l_world: EIFFEL_WORLD
193 es_cluster: ES_CLUSTER
194 cluster_fig: EIFFEL_CLUSTER_FIGURE
195 l_projector: EIFFEL_PROJECTOR
196 remove_links: LIST [ES_ITEM]
197 remove_classes: LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]]
198 cf: EIFFEL_CLASS_FIGURE
199 do
200 l_world := tool.world
201 es_cluster := a_stone.source.model
202 cluster_fig := a_stone.source
203 if cluster_fig /= Void then
204 l_projector := tool.projector
205
206 remove_links := es_cluster.needed_links
207 remove_classes := classes_to_remove_in_cluster (es_cluster)
208 from
209 remove_classes.start
210 until
211 remove_classes.after
212 loop
213 cf ?= remove_classes.item.item (1)
214 remove_links.append (cf.model.needed_links)
215 remove_classes.forth
216 end
217
218 history.do_named_undoable (
219 interface_names.t_diagram_erase_cluster_cmd (es_cluster.name),
220 [<<agent l_world.remove_cluster_virtual (cluster_fig, remove_links, remove_classes), agent tool.restart_force_directed, agent l_world.update_cluster_legend>>],
221 [<<agent l_world.reinclude_cluster (cluster_fig, remove_links, remove_classes), agent tool.restart_force_directed, agent l_world.update_cluster_legend>>])
222 end
223 end
224
225 classes_to_remove_in_cluster (a_cluster: ES_CLUSTER): LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]] is
226 -- All class figures in `a_cluster' that are needed on diagram plus ther positions.
227 local
228 l_linkables: LIST [EG_LINKABLE]
229 es_class: ES_CLASS
230 class_fig: EIFFEL_CLASS_FIGURE
231 do
232 from
233 create {ARRAYED_LIST [TUPLE [EIFFEL_CLASS_FIGURE, INTEGER, INTEGER]]} Result.make (5)
234 l_linkables := a_cluster.flat_linkables
235 l_linkables.start
236 until
237 l_linkables.after
238 loop
239 es_class ?= l_linkables.item
240 if es_class /= Void and then es_class.is_needed_on_diagram then
241 class_fig ?= tool.world.figure_from_model (es_class)
242 if class_fig /= Void then
243 Result.extend ([class_fig, class_fig.port_x, class_fig.port_y])
244 end
245 end
246 l_linkables.forth
247 end
248 end
249
250 execute_with_link_midpoint (a_stone: EG_EDGE) is
251 -- Remove `a_stone' from diagram.
252 local
253 line: EIFFEL_LINK_FIGURE
254 old_edges, new_edges: LIST [EG_EDGE]
255 l_projector: EIFFEL_PROJECTOR
256 do
257 line ?= a_stone.corresponding_line
258 if line /= Void then
259 old_edges := line.edges
260 new_edges := old_edges.twin
261 if new_edges.has (a_stone) then
262 new_edges.prune_all (a_stone)
263 a_stone.hide
264 l_projector := tool.projector
265 history.do_named_undoable (
266 interface_names.t_diagram_delete_midpoint_cmd,
267 [<<agent line.reset, agent line.retrieve_edges (new_edges), agent l_projector.full_project>>],
268 [<<agent line.reset, agent line.retrieve_edges (old_edges), agent l_projector.full_project>>])
269 end
270 end
271 end
272
273 execute_with_inheritance_stone (a_stone: INHERIT_STONE) is
274 -- Remove `a_stone' from diagram.
275 local
276 l_item: ES_ITEM
277 fig: EIFFEL_INHERITANCE_FIGURE
278 l_projector: EIFFEL_PROJECTOR
279 do
280 fig := a_stone.source
281 l_item ?= fig.model
282 if l_item /= Void then
283 l_projector := tool.projector
284 history.do_named_undoable (
285 interface_names.t_diagram_delete_inheritance_link_cmd (fig.model.ancestor.name, fig.model.descendant.name),
286 [<<agent l_item.disable_needed_on_diagram, agent l_projector.full_project>>],
287 [<<agent l_item.enable_needed_on_diagram, agent l_projector.full_project>>])
288 end
289 end
290
291 execute_with_client_stone (a_stone: CLIENT_STONE) is
292 -- Remove `a_stone' from diagram.
293 local
294 l_item: ES_ITEM
295 fig: EIFFEL_CLIENT_SUPPLIER_FIGURE
296 l_projector: EIFFEL_PROJECTOR
297 do
298 fig := a_stone.source
299 l_item ?= fig.model
300 if l_item /= Void then
301 l_projector := tool.projector
302 history.do_named_undoable (
303 interface_names.t_diagram_delete_client_link_cmd (fig.model.name),
304 [<<agent l_item.disable_needed_on_diagram, agent l_projector.full_project>>],
305 [<<agent l_item.enable_needed_on_diagram, agent l_projector.full_project>>])
306 end
307 end
308
309 indexing
310 copyright: "Copyright (c) 1984-2006, Eiffel Software"
311 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
312 licensing_options: "http://www.eiffel.com/licensing"
313 copying: "[
314 This file is part of Eiffel Software's Eiffel Development Environment.
315
316 Eiffel Software's Eiffel Development Environment is free
317 software; you can redistribute it and/or modify it under
318 the terms of the GNU General Public License as published
319 by the Free Software Foundation, version 2 of the License
320 (available at the URL listed under "license" above).
321
322 Eiffel Software's Eiffel Development Environment is
323 distributed in the hope that it will be useful, but
324 WITHOUT ANY WARRANTY; without even the implied warranty
325 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
326 See the GNU General Public License for more details.
327
328 You should have received a copy of the GNU General Public
329 License along with Eiffel Software's Eiffel Development
330 Environment; if not, write to the Free Software Foundation,
331 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
332 ]"
333 source: "[
334 Eiffel Software
335 356 Storke Road, Goleta, CA 93117 USA
336 Telephone 805-685-1006, Fax 805-685-6869
337 Website http://www.eiffel.com
338 Customer support http://support.eiffel.com
339 ]"
340
341 end -- class EB_DELETE_FIGURE_COMMAND
342

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23