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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_delete_diagram_item_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: 12910 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Command to delete diagram components and to remove corresponding code in system."
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_DELETE_DIAGRAM_ITEM_COMMAND
11
12 inherit
13 EB_CONTEXT_DIAGRAM_COMMAND
14 rename
15 make as make_context_diagram
16 undefine
17 menu_name
18 redefine
19 new_toolbar_item,
20 new_sd_toolbar_item,
21 description
22 select
23 name
24 end
25
26 EB_DELETE_CLASS_CLUSTER_COMMAND
27 rename
28 name as dup_name,
29 make as dup_make
30 export
31 {ANY} class_i, could_not_delete
32 undefine
33 enable_sensitive,
34 disable_sensitive,
35 new_toolbar_item,
36 new_mini_toolbar_item,
37 new_sd_toolbar_item,
38 mini_pixmap,
39 description,
40 tooltip,
41 tooltext,
42 pixmap
43 redefine
44 drop_class,
45 delete_class,
46 delete_cluster,
47 execute
48 end
49
50 create
51 make
52
53 feature -- Initialization
54
55 make (a_target: like tool; a_window: EB_DEVELOPMENT_WINDOW) is
56 -- Initialize with `a_target' and `a_window'.
57 do
58 make_context_diagram (a_target)
59 window := a_window
60 end
61
62 feature -- Access
63
64 execute is
65 -- Display information about `Current'.
66 do
67 create explain_dialog.make_with_text (Interface_names.e_Diagram_delete_item)
68 explain_dialog.show_modal_to_window (tool.develop_window.window)
69 end
70
71 new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is
72 -- Create a new toolbar button for this command.
73 do
74 Result := Precursor {EB_CONTEXT_DIAGRAM_COMMAND} (display_text)
75 Result.drop_actions.extend (agent execute_with_inherit_stone)
76 Result.drop_actions.extend (agent execute_with_client_stone)
77 Result.drop_actions.extend (agent drop_class)
78 Result.drop_actions.extend (agent drop_cluster)
79 end
80
81 new_sd_toolbar_item (display_text: BOOLEAN): EB_SD_COMMAND_TOOL_BAR_BUTTON is
82 -- Create a new toolbar button for docking.
83 do
84 Result := Precursor {EB_CONTEXT_DIAGRAM_COMMAND}(display_text)
85 Result.drop_actions.extend (agent execute_with_inherit_stone)
86 Result.drop_actions.extend (agent execute_with_client_stone)
87 Result.drop_actions.extend (agent drop_class)
88 Result.drop_actions.extend (agent drop_cluster)
89 end
90
91 pixmap: EV_PIXMAP is
92 -- Pixmap representing the command.
93 do
94 Result := pixmaps.icon_pixmaps.general_delete_icon
95 end
96
97 tooltip: STRING is
98 -- Tooltip for the toolbar button.
99 do
100 Result := Interface_names.f_diagram_delete
101 end
102
103 description: STRING is
104 -- Description for this command.
105 do
106 Result := Interface_names.l_diagram_delete
107 end
108
109 name: STRING is "Delete_item"
110 -- Name of the command. Used to store the command in the
111 -- preferences.
112
113 feature {NONE} -- Implementation
114
115 drop_class (st: CLASSI_STONE) is
116 -- Extract the class that should be removed from `st' and erase it.
117 local
118 fs: CLASSI_FIGURE_STONE
119 es_class: ES_CLASS
120 wd: EV_WARNING_DIALOG
121 referenced_classes: STRING
122 msg: STRING
123 l_ss: LIST [CLASS_C]
124 l_item: CLASS_C
125 do
126 fs ?= st
127 if fs /= Void then
128 es_class := fs.source.model
129 if es_class /= Void then
130 if es_class.class_c /= Void then
131 create referenced_classes.make_empty
132 from
133 l_ss := es_class.class_c.syntactical_clients
134 l_ss.start
135 until
136 l_ss.after
137 loop
138 l_item := l_ss.item
139 referenced_classes.append ("%N" + l_item.name_in_upper)
140 l_ss.forth
141 end
142 if referenced_classes.is_empty then
143 Precursor {EB_DELETE_CLASS_CLUSTER_COMMAND} (st)
144 else
145 msg := warning_messages.w_still_referenced (es_class.name, referenced_classes)
146 create wd.make_with_text (msg)
147 wd.show_modal_to_window (window.window)
148 end
149 else
150 -- there are now clients and now descendants, otherwise it would be compiled
151 Precursor {EB_DELETE_CLASS_CLUSTER_COMMAND} (st)
152 end
153 else
154 check
155 delete_only_diagram_items: False
156 end
157 end
158 end
159 end
160
161 delete_class is
162 -- Remove `class_i' from the system.
163 local
164 file: PLAIN_TEXT_FILE
165 wd: EV_WARNING_DIALOG
166 retried: BOOLEAN
167 es_class: ES_CLASS
168 es_classes: ARRAYED_LIST [ES_CLASS]
169 l_links: LIST [EG_LINK]
170 do
171 if not retried then
172 if eb_debugger_manager.application_is_executing then
173 eb_debugger_manager.application.kill
174 end
175 Eb_debugger_manager.disable_debug
176 create file.make (class_i.file_name)
177 if
178 file.exists and then
179 file.is_writable
180 then
181 file.delete
182 manager.remove_class (class_i)
183 could_not_delete := False
184 end
185 Eb_debugger_manager.resynchronize_breakpoints
186 window_manager.synchronize_all
187 end
188 if could_not_delete then
189 -- We were not able to delete the file.
190 create wd.make_with_text (Warning_messages.w_Not_writable (class_i.file_name))
191 wd.show_modal_to_window (window.window)
192 else
193 es_classes := tool.graph.class_from_interface (class_i)
194 from
195 es_classes.start
196 until
197 es_classes.after
198 loop
199 es_class := es_classes.item
200 from
201 l_links := es_class.links
202 l_links.start
203 until
204 l_links.after
205 loop
206 tool.graph.remove_link (l_links.item)
207 l_links.forth
208 end
209 tool.graph.remove_node (es_class)
210 es_classes.forth
211 end
212 tool.reset_history
213 end
214 rescue
215 retried := True
216 retry
217 end
218
219 delete_cluster is
220 -- Remove `group' from the system.
221 do
222 tool.reset_history
223 Precursor {EB_DELETE_CLASS_CLUSTER_COMMAND}
224 end
225
226 execute_with_inherit_stone (a_stone: INHERIT_STONE) is
227 -- Remove `a_stone' from diagram.
228 local
229 ctm: CLASS_TEXT_MODIFIER
230 descendant, ancestor: ES_CLASS
231 e_item: ES_INHERITANCE_LINK
232 link: EIFFEL_INHERITANCE_FIGURE
233 do
234 link := a_stone.source
235 descendant := link.model.descendant
236 ancestor := link.model.ancestor
237 if ancestor /= Void and then descendant /= Void then
238 ctm := descendant.code_generator
239
240 e_item ?= a_stone.source.model
241 check
242 e_item_not_void: e_item /= Void
243 end
244 e_item.disable_needed_on_diagram
245
246 tool.history.do_named_undoable (
247 interface_names.t_diagram_delete_inheritance_link_cmd (ancestor.name, descendant.name),
248 agent remove_ancestor (ctm, ancestor.name, e_item),
249 agent add_ancestor (ctm, ancestor.name, e_item))
250 end
251 end
252
253 remove_ancestor (a_ctm: CLASS_TEXT_MODIFIER; a_name: STRING; a_link: ES_INHERITANCE_LINK) is
254 -- Remove ancestor with `a_name' and hide `a_link' if succesfull.
255 do
256 a_ctm.remove_ancestor (a_name)
257 if not a_ctm.class_modified_outside_diagram then
258 a_link.disable_needed_on_diagram
259 end
260 end
261
262 add_ancestor (a_ctm: CLASS_TEXT_MODIFIER; a_name: STRING; a_link: ES_INHERITANCE_LINK) is
263 --Add ancestor with `a_name' and show `a_link' if succesfull.
264 do
265 a_ctm.add_ancestor (a_name)
266 if not a_ctm.class_modified_outside_diagram then
267 a_link.enable_needed_on_diagram
268 end
269 end
270
271 execute_with_client_stone (a_stone: CLIENT_STONE) is
272 -- Delete feature in `a_stone'.
273 local
274 features: LIST [FEATURE_AS]
275 selected_features: ARRAYED_LIST [FEATURE_AS]
276 cancelled: BOOLEAN
277 dial: EB_DELETE_CLIENT_LINK_DIALOG
278 names: LIST [STRING]
279 l_item: FEATURE_AS
280 do
281 features := a_stone.source.model.features
282 if features.count = 1 then
283 delete_features (features.twin, a_stone.source)
284 else
285 -- Let user select a subset
286 dial := delete_client_link_dialog
287 dial.set_strings (a_stone.source.feature_names)
288 dial.show_modal_to_window (window.window)
289 if
290 not dial.cancelled and then
291 not dial.selected_item.is_empty
292 then
293 names := dial.selected_items
294 from
295 names.start
296 create selected_features.make (features.count)
297 until
298 names.after
299 loop
300 l_item := item_from_name (features, names.item)
301 if l_item /= Void then
302 selected_features.extend (l_item)
303 end
304 names.forth
305 end
306 else
307 cancelled := True
308 end
309 dial.destroy
310 if not cancelled then
311 delete_features (selected_features, a_stone.source)
312 end
313 end
314 end
315
316 item_from_name (a_list: LIST [FEATURE_AS]; a_name: STRING): FEATURE_AS is
317 -- Feature with `a_name' in `a_list' or Void if none.
318 require
319 a_list_not_void: a_list /= Void
320 a_name_not_void: a_name /= Void
321 do
322 from
323 a_list.start
324 until
325 Result /= Void or else a_list.after
326 loop
327 if a_name.is_equal (a_list.item.feature_name) then
328 Result := a_list.item
329 end
330 a_list.forth
331 end
332 end
333
334 delete_features (a_features: LIST [FEATURE_AS]; a_link: EIFFEL_CLIENT_SUPPLIER_FIGURE) is
335 -- Delete features in `a_features'.
336 require
337 a_features_not_void: a_features /= Void
338 a_link_not_void: a_link /= Void
339 local
340 ctm: CLASS_TEXT_MODIFIER
341 undo_list: LIST [TUPLE [STRING, INTEGER]]
342 l_model: ES_CLIENT_SUPPLIER_LINK
343 l_client: ES_CLASS
344 fne: FEATURE_NAME_EXTRACTOR
345 do
346 if not a_features.is_empty then
347 ctm := a_link.model.client.code_generator
348 ctm.remove_features (a_features)
349 if not ctm.class_modified_outside_diagram then
350 undo_list := ctm.last_removed_code.twin
351 create fne
352 l_model := a_link.model
353 if a_link.model.features.count = a_features.count then
354 l_model.disable_needed_on_diagram
355
356 history.register_named_undoable (
357 interface_names.t_diagram_delete_client_link_cmd (fne.feature_name (a_features.first)),
358 agent remove_features_and_link (ctm, a_features, l_model),
359 agent reinclude_code_and_link (ctm, undo_list, l_model))
360 else
361 l_client := l_model.client
362 l_client.remove_queries (a_features)
363 l_model.synchronize
364
365 history.register_named_undoable (
366 interface_names.t_diagram_delete_client_link_cmd (fne.feature_name (a_features.first)),
367 agent remove_features (ctm, a_features, l_model, l_client),
368 agent reinclude_features (ctm, a_features, undo_list, l_model, l_client))
369 end
370 end
371 end
372 end
373
374 remove_features (a_ctm: CLASS_TEXT_MODIFIER; a_features: LIST [FEATURE_AS]; a_link: ES_CLIENT_SUPPLIER_LINK; a_client: ES_CLASS) is
375 -- Remove `a_features' from `a_ctm' and remove `a_features' from `a_client'.
376 do
377 a_ctm.remove_features (a_features)
378 if not a_ctm.class_modified_outside_diagram then
379 a_client.remove_queries (a_features)
380 a_link.synchronize
381 end
382 end
383
384 reinclude_features (a_ctm: CLASS_TEXT_MODIFIER; a_features: LIST [FEATURE_AS]; code: LIST [TUPLE [STRING, INTEGER]]; a_link: ES_CLIENT_SUPPLIER_LINK; a_client: ES_CLASS) is
385 -- Reinclude `code' to `a_ctm' and add `a_features' to `a_link'.
386 do
387 a_ctm.undelete_code (code)
388 if not a_ctm.class_modified_outside_diagram then
389 a_client.add_queries (a_features)
390 a_link.synchronize
391 end
392 end
393
394 remove_features_and_link (a_ctm: CLASS_TEXT_MODIFIER; a_features: LIST [FEATURE_AS]; a_link: ES_CLIENT_SUPPLIER_LINK) is
395 -- Remove `a_features' from `a_ctm' and disable `a_link' in diagram.
396 do
397 a_ctm.remove_features (a_features)
398 if not a_ctm.class_modified_outside_diagram then
399 a_link.disable_needed_on_diagram
400 end
401 end
402
403 reinclude_code_and_link (a_ctm: CLASS_TEXT_MODIFIER; code: LIST [TUPLE [STRING, INTEGER]]; a_link: ES_CLIENT_SUPPLIER_LINK) is
404 -- Reinclude `code' to `a_ctm' and enable `a_link' on diagram.
405 do
406 a_ctm.undelete_code (code)
407 if not a_ctm.class_modified_outside_diagram then
408 a_link.enable_needed_on_diagram
409 end
410 end
411
412 delete_client_link_dialog: EB_DELETE_CLIENT_LINK_DIALOG is
413 -- Associated widget.
414 do
415 create Result
416 end
417
418 explain_dialog: EB_INFORMATION_DIALOG;
419 -- Dialog explaining how to use `Current'.
420
421 indexing
422 copyright: "Copyright (c) 1984-2006, Eiffel Software"
423 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
424 licensing_options: "http://www.eiffel.com/licensing"
425 copying: "[
426 This file is part of Eiffel Software's Eiffel Development Environment.
427
428 Eiffel Software's Eiffel Development Environment is free
429 software; you can redistribute it and/or modify it under
430 the terms of the GNU General Public License as published
431 by the Free Software Foundation, version 2 of the License
432 (available at the URL listed under "license" above).
433
434 Eiffel Software's Eiffel Development Environment is
435 distributed in the hope that it will be useful, but
436 WITHOUT ANY WARRANTY; without even the implied warranty
437 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
438 See the GNU General Public License for more details.
439
440 You should have received a copy of the GNU General Public
441 License along with Eiffel Software's Eiffel Development
442 Environment; if not, write to the Free Software Foundation,
443 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
444 ]"
445 source: "[
446 Eiffel Software
447 356 Storke Road, Goleta, CA 93117 USA
448 Telephone 805-685-1006, Fax 805-685-6869
449 Website http://www.eiffel.com
450 Customer support http://support.eiffel.com
451 ]"
452
453 end -- class EB_DELETE_DIAGRAM_ITEM_COMMAND

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23