/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/properties/eb_fileable.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/properties/eb_fileable.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61928 - (show annotations)
Sun Jul 30 05:57:18 2006 UTC (13 years, 4 months ago) by manus
File size: 6580 byte(s)
EiffelStudio docking branch. It only contains modified classes needed to get the docking version of EiffelStudio.
1 indexing
2 description : "Tool or window associated with a text file."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date : "$Date$"
6 revision : "$Revision$"
7 author : "Arnaud PICHERY [ aranud@mail.dotcom.fr ]"
8
9 deferred class
10 EB_FILEABLE
11
12 inherit
13 EB_STONABLE
14
15 SHARED_EIFFEL_PROJECT
16 export
17 {NONE} all
18 end
19
20 feature -- Access
21
22 stone: STONE
23 -- Stone for current.
24
25 file_name: FILE_NAME
26 -- Name of the file being displayed.
27 -- This attribute is useful when `stone'
28 -- is Void (this case occurs after loading
29 -- a file with the "open" command, or after
30 -- saving a file with the "save as" command).
31
32 last_saving_date: INTEGER is
33 -- Date of last save
34 require
35 file_name_not_void: file_name /= Void
36 do
37 Result := internal_last_saving_date
38 end
39
40 changed: BOOLEAN is
41 -- Has the content changed since last save?
42 deferred
43 end
44
45 is_empty: BOOLEAN is
46 -- Does `Current' have no text loaded?
47 deferred
48 end
49
50 text: STRING is
51 -- Text representing Current
52 deferred
53 end
54
55 feature -- Status Settings
56
57 set_file_name (a_filename: FILE_NAME) is
58 -- Make `f' the name of the file associated with tool.
59 -- If `f' is Void, the tool is associated with no file.
60 do
61 file_name := a_filename
62 ensure
63 file_name_set: equal (file_name, a_filename)
64 end
65
66 set_last_saving_date (a_timestamp: INTEGER) is
67 -- make `a_timestamp' the value of `last_saving_date'
68 require
69 file_name_not_void: file_name /= Void
70 do
71 internal_last_saving_date := a_timestamp
72 end
73
74 set_stone (new_stone: STONE) is
75 -- Make `s' the new value of stone.
76 -- Change file name as a consequence, to keep invariant.
77 local
78 filed_stone: FILED_STONE
79 do
80 stone := new_stone
81 filed_stone ?= new_stone
82 if filed_stone /= Void then
83 set_file_name_from_stone (filed_stone)
84 else
85 file_name := Void
86 end
87 --| FIXME ARNAUD
88 -- if stone_b /= Void then
89 -- stone_b.set_pebble (new_stone)
90 -- end
91 --| END FIXME
92 end
93
94 reset_stone is
95 -- Reset the stone to Void, without resetting display.
96 -- Only usable for starting to edit a file without using stones.
97 require
98 file_being_edited: (file_name /= Void) and then (not file_name.is_empty)
99 do
100 stone := Void
101 ensure
102 stone = Void
103 end
104
105 on_text_saved is
106 -- Notify the editor that the text has been saved.
107 do
108 end
109
110 feature {NONE} -- Status Settings
111
112 set_file_name_from_stone (s: FILED_STONE) is
113 -- Update `file_name' using information from `s'.
114 local
115 f: RAW_FILE
116 do
117 if (s = Void) or else (s.file_name = Void) then
118 set_file_name (Void)
119 else
120 set_file_name (s.file_name)
121 create f.make (file_name)
122 if f.exists then
123 set_last_saving_date (f.date)
124 else
125 set_file_name (Void)
126 end
127 end
128 end
129
130 feature -- Basic Operations
131
132 show_file (f: PLAIN_TEXT_FILE) is
133 -- Display content of file `f' and its name as the title
134 -- of the ancestor tool. Forget about clicking and stones.
135 require
136 file_no_void: f /= Void
137 valid_file: f.exists and then f.is_readable and then f.is_plain
138 local
139 filename: FILE_NAME
140 do
141 f.open_read
142 f.read_stream (f.count)
143 f.close
144 update_save_symbol
145 create filename.make_from_string (f.name)
146 set_file_name (filename)
147 set_last_saving_date (f.date)
148 reset_stone
149 ensure
150 up_to_date: not changed
151 no_stone: stone = Void
152 end
153
154 reset is
155 -- Reset the window contents.
156 do
157 update_save_symbol
158 end
159
160 feature -- "Save command" related features
161
162 update_save_symbol is
163 -- Update the save symbol in tool.
164 do
165 if changed then
166 save_cmd.enable_sensitive
167 else
168 save_cmd.disable_sensitive
169 end
170 end
171
172 save_text is
173 -- Launch the save command.
174 local
175 cst: CLASSC_STONE
176 do
177 save_cmd.execute
178 cst ?= stone
179 if cst /= Void then
180 Eiffel_project.Workbench.change_class (cst.class_i)
181 cst.class_i.set_date
182 Eiffel_project.Workbench.set_changed
183 end
184 end
185
186 perform_check_before_save is
187 -- Perform checks, if any, before saving
188 do
189 end
190
191 check_passed: BOOLEAN is
192 do
193 Result := True
194 end
195
196 feature -- Commands
197
198 open_cmd: EB_OPEN_FILE_COMMAND
199 -- Command to open a file in the tool
200
201 save_cmd: EB_SAVE_FILE_COMMAND
202 -- Command to save current text in the associated file.
203 -- If no file is associated, `save_as_cmd' is executed.
204
205 feature {NONE} -- Execution
206
207 take_focus is
208 -- Check if a save has been by a different tool or editor.
209 -- If yes, prompt user for updating text.
210 -- This function is called when mouse cames on tool window.
211 local
212 f: PLAIN_TEXT_FILE
213 qd: EV_QUESTION_DIALOG
214 do
215 if file_name /= Void then
216 create f.make (file_name)
217 if f.exists and then f.date > last_saving_date then
218 create qd.make_with_text ("File has been changed by another tool/editor%NDo you want to load the changes?")
219 qd.button ("Yes").select_actions.extend (agent revert)
220 qd.button ("Cancel").hide
221 set_last_saving_date (f.date)
222 end
223 end
224 end
225
226 revert is
227 -- Upload text from file associated with Current
228 local
229 f: PLAIN_TEXT_FILE
230 do
231 create f.make (file_name)
232 show_file (f)
233 refresh
234 end
235
236 feature {NONE} -- Implementation
237
238 internal_last_saving_date: INTEGER;
239 -- Date of last save
240
241 indexing
242 copyright: "Copyright (c) 1984-2006, Eiffel Software"
243 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
244 licensing_options: "http://www.eiffel.com/licensing"
245 copying: "[
246 This file is part of Eiffel Software's Eiffel Development Environment.
247
248 Eiffel Software's Eiffel Development Environment is free
249 software; you can redistribute it and/or modify it under
250 the terms of the GNU General Public License as published
251 by the Free Software Foundation, version 2 of the License
252 (available at the URL listed under "license" above).
253
254 Eiffel Software's Eiffel Development Environment is
255 distributed in the hope that it will be useful, but
256 WITHOUT ANY WARRANTY; without even the implied warranty
257 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
258 See the GNU General Public License for more details.
259
260 You should have received a copy of the GNU General Public
261 License along with Eiffel Software's Eiffel Development
262 Environment; if not, write to the Free Software Foundation,
263 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
264 ]"
265 source: "[
266 Eiffel Software
267 356 Storke Road, Goleta, CA 93117 USA
268 Telephone 805-685-1006, Fax 805-685-6869
269 Website http://www.eiffel.com
270 Customer support http://support.eiffel.com
271 ]"
272
273 end -- class EB_FILEABLE

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23