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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_save_file_as_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: 4660 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description : "Command to save a file under a different name."
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_SAVE_FILE_AS_COMMAND
10
11 inherit
12 EB_FILEABLE_COMMAND
13
14 EB_MENUABLE_COMMAND
15
16 EB_CONSTANTS
17 export
18 {NONE} all
19 end
20
21 SYSTEM_CONSTANTS
22 export
23 {NONE} all
24 end
25
26 EB_SHARED_PREFERENCES
27 export
28 {NONE} all
29 end
30
31 EB_FILE_OPENER_CALLBACK
32 export
33 {NONE} all
34 end
35
36 EB_SHARED_WINDOW_MANAGER
37 export
38 {NONE} all
39 end
40
41 TEXT_OBSERVER
42 redefine
43 on_text_reset, on_text_edited,
44 on_text_back_to_its_last_saved_state,
45 on_text_fully_loaded
46 end
47
48 create
49 make
50
51 feature -- Execution
52
53 execute is
54 -- Execute the command. Prompt the user for the new filenane and save it.
55 do
56 execute_with_dialog (Void)
57 end
58
59 execute_with_filename (new_filename: STRING) is
60 -- Save a file with a chosen name.
61 require
62 valid_filename: new_filename /= Void and then not new_filename.is_empty
63 local
64 file_opener: EB_FILE_OPENER
65 do
66 create file_opener.make_with_parent (Current, new_filename, window_manager.last_focused_development_window.window)
67 end
68
69 feature -- Status setting
70
71 on_text_reset is
72 -- Disable `Current'.
73 do
74 if target.is_empty then
75 disable_sensitive
76 else
77 enable_sensitive
78 end
79 end
80
81 on_text_back_to_its_last_saved_state is
82 -- Disable `Current'.
83 do
84 if target.is_empty then
85 disable_sensitive
86 else
87 enable_sensitive
88 end
89 end
90
91 on_text_edited (directly_edited: BOOLEAN) is
92 -- Enable `Current'.
93 do
94 -- Do nothing
95 end
96
97 on_text_fully_loaded is
98 -- Enable `Current'.
99 do
100 enable_sensitive
101 end
102
103 feature {EB_FILE_OPENER} -- Callbacks
104
105 save_file (new_file: RAW_FILE) is
106 local
107 to_write: STRING
108 do
109 to_write := target.text
110 new_file.open_write
111 if not to_write.is_empty then
112 to_write.prune_all ('%R')
113 if to_write.item (to_write.count) /= '%N' then
114 -- Add a carriage return like `vi' if there's none at the end
115 to_write.extend ('%N')
116 end
117 if preferences.misc_data.text_mode_is_windows then
118 to_write.replace_substring_all ("%N", "%R%N")
119 end
120 new_file.put_string (to_write)
121 end
122 new_file.close
123 end
124
125 feature {EB_SAVE_FILE_COMMAND} -- Implementation
126
127 execute_with_dialog (argument: EB_FILE_SAVE_DIALOG) is
128 -- Save a file with the chosen name.
129 local
130 fsd: EB_FILE_SAVE_DIALOG
131 do
132 if argument = Void then
133 create fsd.make_with_preference (preferences.dialog_data.last_saved_save_file_as_directory_preference)
134 fsd.save_actions.extend (agent execute_with_dialog (fsd))
135 fsd.show_modal_to_window (window_manager.last_focused_development_window.window)
136 else
137 execute_with_filename (argument.file_name)
138 end
139 end
140
141 feature {NONE} -- Implementation
142
143 menu_name: STRING is
144 -- Name as it appears in the menu (with & symbol).
145 do
146 Result := Interface_names.m_Export_to
147 end
148
149 pixmap: EV_PIXMAP
150 -- Pixmap
151
152 feature -- Obsolete
153
154 save_it (fn: STRING) is
155 -- Save a file with a chosen name.
156 obsolete "use `save_as' instead"
157 do
158 save_as (fn)
159 end
160
161 save_as (new_filename: STRING) is
162 -- Save a file with a chosen name.
163 obsolete "use `execute_with_filename' instead"
164 do
165 execute_with_filename (new_filename)
166 end
167
168 indexing
169 copyright: "Copyright (c) 1984-2006, Eiffel Software"
170 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
171 licensing_options: "http://www.eiffel.com/licensing"
172 copying: "[
173 This file is part of Eiffel Software's Eiffel Development Environment.
174
175 Eiffel Software's Eiffel Development Environment is free
176 software; you can redistribute it and/or modify it under
177 the terms of the GNU General Public License as published
178 by the Free Software Foundation, version 2 of the License
179 (available at the URL listed under "license" above).
180
181 Eiffel Software's Eiffel Development Environment is
182 distributed in the hope that it will be useful, but
183 WITHOUT ANY WARRANTY; without even the implied warranty
184 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
185 See the GNU General Public License for more details.
186
187 You should have received a copy of the GNU General Public
188 License along with Eiffel Software's Eiffel Development
189 Environment; if not, write to the Free Software Foundation,
190 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
191 ]"
192 source: "[
193 Eiffel Software
194 356 Storke Road, Goleta, CA 93117 USA
195 Telephone 805-685-1006, Fax 805-685-6869
196 Website http://www.eiffel.com
197 Customer support http://support.eiffel.com
198 ]"
199
200 end -- class EB_SAVE_FILE_AS_COMMAND

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23