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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_delete_class_cluster_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: 10044 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description: "Command that allows the user to remove a class or a cluster %
3 %from the system (deletion is permanent and a confirmation dialog %
4 %is popped up)"
5 legal: "See notice at end of class."
6 status: "See notice at end of class."
7 author: "Xavier Rousselot"
8 date: "$Date$"
9 revision: "$Revision$"
10
11 class
12 EB_DELETE_CLASS_CLUSTER_COMMAND
13
14 inherit
15 EB_TOOLBARABLE_AND_MENUABLE_COMMAND
16 redefine
17 mini_pixmap,
18 new_toolbar_item,
19 new_mini_toolbar_item,
20 new_sd_toolbar_item,
21 tooltext
22 end
23
24 EB_CLUSTER_MANAGER_OBSERVER
25
26 EB_SHARED_WINDOW_MANAGER
27
28 EB_SHARED_DEBUG_TOOLS
29
30 SHARED_APPLICATION_EXECUTION
31
32 EB_RECYCLABLE
33
34 create
35 make
36
37 feature {NONE} -- Initialization
38
39 make (a_window: like window) is
40 -- Initialize `Current' and associate it with `a_window'.
41 do
42 default_create
43 enable_sensitive
44 window := a_window
45 end
46
47 feature -- Access
48
49 new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is
50 -- Create a new toolbar button for this command.
51 --
52 -- Call `recycle' on the result when you don't need it anymore otherwise
53 -- it will never be garbage collected.
54 do
55 Result := Precursor (display_text)
56 Result.drop_actions.extend (agent drop_class)
57 Result.drop_actions.extend (agent drop_cluster)
58 end
59
60 new_mini_toolbar_item: EB_COMMAND_TOOL_BAR_BUTTON is
61 -- Create a new toolbar button for this command.
62 --
63 -- Call `recycle' on the result when you don't need it anymore otherwise
64 -- it will never be garbage collected.
65 do
66 Result := Precursor
67 Result.drop_actions.extend (agent drop_class)
68 Result.drop_actions.extend (agent drop_cluster)
69 end
70
71 new_sd_toolbar_item (display_text: BOOLEAN): EB_SD_COMMAND_TOOL_BAR_BUTTON is
72 -- Create tool bar button for docking.
73 do
74 Result := Precursor (display_text)
75 Result.drop_actions.extend (agent drop_class)
76 Result.drop_actions.extend (agent drop_cluster)
77 end
78
79 feature -- Properties
80
81 description: STRING is
82 -- Comment about `Current' for customization.
83 do
84 Result := Interface_names.e_Remove_class_cluster
85 end
86
87 menu_name: STRING is
88 -- Name of the menu corresponding to `Current'.
89 do
90 Result := Interface_names.m_Remove_class_cluster
91 end
92
93 name: STRING is "Remove_class_cluster"
94 -- Internal identifier of `Current'.
95
96 pixmap: EV_PIXMAP is
97 -- Pixmap representing `Current' in toolbars.
98 do
99 Result := pixmaps.icon_pixmaps.general_delete_icon
100 end
101
102 pixel_buffer: EV_PIXEL_BUFFER is
103 -- Pixel buffer representing the command.
104 do
105 Result := pixmaps.icon_pixmaps.general_delete_icon_buffer
106 end
107
108 mini_pixmap: EV_PIXMAP is
109 -- Pixmap representing `Current' in toolbars.
110 do
111 Result := pixmaps.mini_pixmaps.general_delete_icon
112 end
113
114 tooltip: STRING is
115 -- Text string that appears when focus is given to `Current's buttons.
116 once
117 Result := description
118 end
119
120 tooltext: STRING is
121 -- Text that appears on toolbar button
122 once
123 Result := Interface_names.B_remove_class_cluster
124 end
125
126 feature -- Events
127
128 drop_class (st: CLASSI_STONE) is
129 -- Extract the class that should be removed from `st' and erase it.
130 do
131 class_i := st.class_i
132 real_execute
133 end
134
135 drop_cluster (st: CLUSTER_STONE) is
136 -- Extract the cluster that should be removed from `st' and erase it.
137 do
138 group := st.group
139 path := st.path
140 real_execute
141 end
142
143 feature -- Basic operations
144
145 execute is
146 -- Button has been pressed.
147 local
148 classst: CLASSI_STONE
149 clust: CLUSTER_STONE
150 wd: EV_WARNING_DIALOG
151 do
152 classst ?= window.stone
153 if classst /= Void then
154 drop_class (classst)
155 if not could_not_delete then
156 window.set_stone (Void)
157 end
158 else
159 clust ?= window.stone
160 if clust /= Void then
161 drop_cluster (clust)
162 real_execute
163 if not could_not_delete then
164 window.set_stone (Void)
165 end
166 else
167 create wd.make_with_text (Warning_messages.w_Select_class_cluster_to_remove)
168 wd.show_modal_to_window (window.window)
169 end
170 end
171 end
172
173 feature -- Recyclable
174
175 recycle is
176 -- Recycle
177 do
178 window := Void
179 end
180
181 feature {NONE} -- Implementation
182
183 real_execute is
184 -- Ask confirmation before removing `class_i' or `group'
185 -- from the system and from the disk.
186 local
187 cd: EV_CONFIRMATION_DIALOG
188 wd: EV_WARNING_DIALOG
189 str: STRING
190 l_cluster: CONF_CLUSTER
191 l_sort_cl: EB_SORTED_CLUSTER
192 l_empty: BOOLEAN
193 l_sub_cl: DS_ARRAYED_LIST [CLASS_I]
194 do
195 could_not_delete := True
196 if class_i /= Void then
197 if
198 not class_i.is_read_only
199 then
200 str := class_i.name_in_upper
201 if eb_debugger_manager.application_is_executing then
202 create cd.make_with_text_and_actions (Warning_messages.W_stop_debugger, <<agent delete_class>>)
203 cd.show_modal_to_window (window.window)
204 else
205 create cd.make_with_text_and_actions (Warning_messages.w_Confirm_delete_class (str),
206 <<agent delete_class>>)
207 cd.show_modal_to_window (window.window)
208 end
209 class_i := Void
210 else
211 create wd.make_with_text (Warning_messages.w_cannot_delete_read_only_class (class_i.name_in_upper))
212 wd.show_modal_to_window (window.window)
213 class_i := Void
214 end
215 elseif group /= Void then
216 str := group.name.twin
217 str.append (path)
218 if
219 not group.is_readonly
220 then
221
222 if group.is_cluster and not path.is_empty then
223 -- create an EB_SORTED_CLUSTER because this allows as to easily access information about subfolders
224 create l_sort_cl.make (group)
225 l_sort_cl.initialize
226 l_sub_cl := l_sort_cl.sub_classes.item (path+"/")
227 l_empty := l_sub_cl = Void or else l_sub_cl.is_empty
228 else
229 if group.is_cluster then
230 l_cluster ?= group
231 check cluster: l_cluster /= Void end
232 l_empty := l_cluster.children = Void or else l_cluster.children.is_empty
233 end
234 l_empty := l_empty and group.classes = Void or else group.classes.is_empty
235 end
236
237 if
238 l_empty
239 then
240 if group.target.system.date_has_changed then
241 create wd.make_with_text (Warning_messages.w_cannot_delete_need_recompile)
242 wd.show_modal_to_window (window.window)
243 else
244 if eb_debugger_manager.application_is_executing then
245 create cd.make_with_text_and_actions (Warning_messages.W_Confirm_delete_cluster_debug (str),
246 <<agent delete_cluster>>)
247 cd.show_modal_to_window (window.window)
248 else
249 create cd.make_with_text_and_actions (Warning_messages.w_Confirm_delete_cluster (str),
250 <<agent delete_cluster>>)
251 cd.show_modal_to_window (window.window)
252 end
253 end
254 else
255 create wd.make_with_text (Warning_messages.w_cannot_delete_none_empty_cluster (str))
256 wd.show_modal_to_window (window.window)
257 end
258 group := Void
259 else
260 create wd.make_with_text (Warning_messages.w_Cannot_delete_library_cluster (str))
261 wd.show_modal_to_window (window.window)
262 group := Void
263 end
264 end
265 end
266
267 delete_class is
268 -- Remove `class_i' from the system.
269 require
270 classi_non_void: class_i /= Void
271 could_not_delete_initialized: could_not_delete
272 local
273 file: PLAIN_TEXT_FILE
274 wd: EV_WARNING_DIALOG
275 retried: BOOLEAN
276 do
277 if not retried then
278 if eb_debugger_manager.application_is_executing then
279 eb_debugger_manager.Application.kill
280 end
281 Eb_debugger_manager.disable_debug
282 create file.make (class_i.file_name)
283 if
284 file.exists and then
285 file.is_writable
286 then
287 file.delete
288 manager.remove_class (class_i)
289 could_not_delete := False
290 end
291 Eb_debugger_manager.resynchronize_breakpoints
292 Window_manager.synchronize_all
293 end
294 if could_not_delete then
295 -- We were not able to delete the file.
296 create wd.make_with_text (Warning_messages.w_Not_writable (class_i.file_name))
297 wd.show_modal_to_window (window.window)
298 end
299 rescue
300 retried := True
301 retry
302 end
303
304 delete_cluster is
305 -- Remove `group' from the system.
306 do
307 if eb_debugger_manager.application_is_executing then
308 eb_debugger_manager.application.kill
309 end
310 Eb_debugger_manager.disable_debug
311 manager.remove_group (group, path)
312 Eb_debugger_manager.resynchronize_breakpoints
313 Window_manager.synchronize_all
314 could_not_delete := False
315 end
316
317 class_i: CLASS_I
318 -- Class that should be removed.
319
320 group: CONF_GROUP
321 -- Cluster that should be removed.
322
323 path: STRING
324 -- Subfolder path taht should be removed.
325
326 window: EB_DEVELOPMENT_WINDOW
327 -- Default window `Current' communicates with.
328
329 could_not_delete: BOOLEAN;
330 -- Was the class/cluster impossible to delete?
331
332 invariant
333 cluster_i_implies_path: group /= Void implies path /= Void
334
335 indexing
336 copyright: "Copyright (c) 1984-2006, Eiffel Software"
337 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
338 licensing_options: "http://www.eiffel.com/licensing"
339 copying: "[
340 This file is part of Eiffel Software's Eiffel Development Environment.
341
342 Eiffel Software's Eiffel Development Environment is free
343 software; you can redistribute it and/or modify it under
344 the terms of the GNU General Public License as published
345 by the Free Software Foundation, version 2 of the License
346 (available at the URL listed under "license" above).
347
348 Eiffel Software's Eiffel Development Environment is
349 distributed in the hope that it will be useful, but
350 WITHOUT ANY WARRANTY; without even the implied warranty
351 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
352 See the GNU General Public License for more details.
353
354 You should have received a copy of the GNU General Public
355 License along with Eiffel Software's Eiffel Development
356 Environment; if not, write to the Free Software Foundation,
357 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
358 ]"
359 source: "[
360 Eiffel Software
361 356 Storke Road, Goleta, CA 93117 USA
362 Telephone 805-685-1006, Fax 805-685-6869
363 Website http://www.eiffel.com
364 Customer support http://support.eiffel.com
365 ]"
366
367 end -- class EB_DELETE_CLASS_CLUSTER_COMMAND

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23