/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/tools/eb_features_tool.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/tools/eb_features_tool.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61957 - (show annotations)
Sun Jul 30 06:02:54 2006 UTC (13 years, 7 months ago) by manus
File size: 12808 byte(s)
EiffelStudio docking branch. It only contains modified classes needed to get the docking version of EiffelStudio.
1 indexing
2 description: "Tool to view features for current edited class."
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_FEATURES_TOOL
10
11 inherit
12 EB_TOOL
13 redefine
14 menu_name,
15 pixmap,
16 on_shown,
17 widget,
18 make
19 end
20
21 EB_SHARED_PREFERENCES
22 export
23 {NONE} all
24 end
25
26 SHARED_EIFFEL_PROJECT
27
28 create
29 make
30
31 feature {NONE} -- Initialization
32
33 make (a_manager: EB_TOOL_MANAGER) is
34 -- Make a new features tool.
35 do
36 development_window ?= a_manager
37 is_signature_enabled := Preferences.feature_tool_data.is_signature_enabled
38 is_alias_enabled := Preferences.feature_tool_data.is_alias_enabled
39 is_assigner_enabled := Preferences.feature_tool_data.is_assigner_enabled
40 Precursor (a_manager)
41 end
42
43 build_interface is
44 -- Build all the tool's widgets.
45 do
46 create tree.make (Current, True)
47 create widget
48 widget.set_background_color ((create {EV_STOCK_COLORS}).White)
49 widget.extend (tree)
50 end
51
52 build_mini_toolbar is
53 -- Build the associated toolbar
54 do
55 create mini_toolbar
56 mini_toolbar.extend (development_window.new_feature_cmd.new_mini_toolbar_item)
57 mini_toolbar.extend (development_window.toggle_feature_alias_cmd.new_mini_toolbar_item)
58 mini_toolbar.extend (development_window.toggle_feature_signature_cmd.new_mini_toolbar_item)
59 mini_toolbar.extend (development_window.toggle_feature_assigner_cmd.new_mini_toolbar_item)
60
61 development_window.toggle_feature_signature_cmd.set_select (is_signature_enabled)
62 development_window.toggle_feature_alias_cmd.set_select (is_alias_enabled)
63 development_window.toggle_feature_assigner_cmd.set_select (is_assigner_enabled)
64 ensure
65 mini_toolbar_exists: mini_toolbar /= Void
66 end
67
68 build_explorer_bar_item (explorer_bar: EB_EXPLORER_BAR) is
69 -- Build the associated explorer bar item and
70 -- Add it to `explorer_bar'
71 do
72 if mini_toolbar = Void then
73 build_mini_toolbar
74 end
75
76 create {EB_EXPLORER_BAR_ITEM} explorer_bar_item.make_with_mini_toolbar (
77 explorer_bar, widget, title, True, mini_toolbar
78 )
79 explorer_bar_item.set_menu_name (menu_name)
80 if pixmap /= Void then
81 explorer_bar_item.set_pixmap (pixmap)
82 end
83 explorer_bar_item.show_actions.extend (agent on_bar_item_shown)
84 explorer_bar.add (explorer_bar_item)
85 end
86
87 feature -- Access
88
89 mini_toolbar: EV_TOOL_BAR
90 -- Bar containing a button for a new feature.
91
92 widget: EV_CELL
93 -- Container.
94
95 tree: EB_FEATURES_TREE
96 -- Widget corresponding to the tree of features.
97
98 title: STRING is
99 -- Title of the tool
100 do
101 Result := Interface_names.t_features_tool
102 end
103
104 menu_name: STRING is
105 -- Name as it may appear in a menu.
106 do
107 Result := Interface_names.m_features_tool
108 end
109
110 pixmap: EV_PIXMAP is
111 -- Pixmap as it may appear in toolbars and menus.
112 do
113 Result := pixmaps.icon_pixmaps.tool_features_icon
114 end
115
116 feature -- Behavior
117
118 is_assigner_enabled: BOOLEAN
119 -- Is assigner command shown?
120
121 is_alias_enabled: BOOLEAN
122 -- Is alias name shown?
123
124 is_signature_enabled: BOOLEAN
125 -- Do we display signature of feature ?
126
127 update_tree is
128 do
129 if tree /= Void then
130 tree.update_all
131 end
132 end
133
134 toggle_signatures is
135 -- Toggle signature on/off
136 do
137 is_signature_enabled := not is_signature_enabled
138 if tree /= Void then
139 tree.update_all
140 end
141 end
142
143 toggle_alias is
144 -- Toggle alias name on/off
145 do
146 is_alias_enabled := not is_alias_enabled
147 if tree /= Void then
148 tree.update_all
149 end
150 end
151
152 toggle_assigner is
153 -- Toggle assigner command on/off
154 do
155 is_assigner_enabled := not is_assigner_enabled
156 if tree /= Void then
157 tree.update_all
158 end
159 end
160
161 feature -- Memory management
162
163 recycle is
164 -- Recycle `Current', but leave `Current' in an unstable state,
165 -- so that we know whether we're still referenced or not.
166 do
167 if explorer_bar_item /= Void then
168 explorer_bar_item.recycle
169 end
170 widget.destroy
171 widget := Void
172 tree := Void
173 manager := Void
174 development_window := Void
175 end
176
177 feature -- Element change
178
179 seek_item_in_feature_tool (a_feature: E_FEATURE) is
180 -- Seek and select item contains data of `a_feature' in features tool.
181 -- If `a_feature' is void, deselect item in features tool.
182 local
183 l_node: EV_TREE_NODE
184 l_selected_node: EV_TREE_NODE
185 do
186 if tree /= Void then
187 l_selected_node := tree.selected_item
188 if a_feature /= Void then
189 l_node := tree.retrieve_item_recursively_by_data (a_feature, true)
190 if l_node /= Void then
191 l_node.enable_select
192 if tree.is_displayed then
193 tree.ensure_item_visible (l_node)
194 end
195 else
196 if l_selected_node /= Void then
197 l_selected_node.disable_select
198 end
199 end
200 else
201 if l_selected_node /= Void then
202 l_selected_node.disable_select
203 end
204 end
205 end
206 end
207
208 seek_ast_item_in_feature_tool (a_feature: STRING) is
209 -- Seek item with `a_feature' in feature tree.
210 local
211 l_node: EV_TREE_NODE
212 l_selected_node: EV_TREE_NODE
213 do
214 if tree /= Void then
215 l_selected_node := tree.selected_item
216 l_node := tree.retrieve_item_recursively_by_data (a_feature, True)
217 if l_node /= Void then
218 l_node.enable_select
219 if tree.is_displayed then
220 tree.ensure_item_visible (l_node)
221 end
222 else
223 if l_selected_node /= Void then
224 l_selected_node.disable_select
225 end
226 end
227 end
228 end
229
230 synchronize is
231 -- Should be called after recompilations.
232 local
233 st: CLASSI_STONE
234 do
235 if current_stone /= Void then
236 st := current_stone.synchronized_stone
237 current_stone := Void
238 current_compiled_class := Void
239 set_stone (st)
240 end
241 end
242
243 set_stone (c: STONE) is
244 -- Set `current_class' if c is instance of CLASSC_STONE, `Void' otherwise.
245 local
246 classc_stone: CLASSC_STONE
247 external_classc: EXTERNAL_CLASS_C
248 feature_clauses: EIFFEL_LIST [FEATURE_CLAUSE_AS]
249 conv_cst: CLASSI_STONE
250 do
251 conv_cst ?= c
252 if conv_cst /= Void then
253 current_stone := conv_cst
254 end
255 classc_stone ?= c
256 if shown then
257 -- We put the tree off-screen to optimize performance only when something
258 -- will happen to the tree (check calls to `widget.wipe_out' and
259 -- `widget.extend (tree)'.
260 if classc_stone /= Void then
261 if
262 not classc_stone.e_class.is_external and then
263 classc_stone.e_class.has_ast
264 then
265 if classc_stone.e_class /= current_compiled_class then
266 widget.wipe_out
267 Eiffel_system.System.set_current_class (classc_stone.e_class)
268 if classc_stone.e_class.is_precompiled then
269 current_class := classc_stone.e_class.ast
270 else
271 current_class := classc_stone.e_class.eiffel_class_c.parsed_ast (False)
272 end
273 if current_class /= Void then
274 feature_clauses := current_class.features
275 -- Build the tree
276 if tree.selected_item /= Void then
277 tree.selected_item.disable_select
278 end
279 tree.wipe_out
280 current_compiled_class := classc_stone.e_class
281 if feature_clauses /= Void then
282 tree.build_tree (feature_clauses)
283 else
284 tree.extend (create {EV_TREE_ITEM}.make_with_text
285 (Warning_messages.W_no_feature_to_display))
286 end
287 Eiffel_system.System.set_current_class (Void)
288 widget.extend (tree)
289 if not tree.is_empty and then tree.is_displayed then
290 tree.ensure_item_visible (tree.first)
291 end
292 end
293 end
294 elseif classc_stone.class_i.is_external_class then
295 -- Special processing for a .NET type since has no 'ast' in the normal
296 -- sense.
297 external_classc ?= classc_stone.e_class
298 if
299 external_classc /= current_compiled_class and external_classc /= Void
300 then
301 Eiffel_system.System.set_current_class (classc_stone.e_class)
302 -- Build the tree
303 if tree.selected_item /= Void then
304 tree.selected_item.disable_select
305 end
306 tree.wipe_out
307 current_compiled_class := classc_stone.e_class
308 tree.build_tree_for_external (current_compiled_class)
309 end
310 else
311 tree.wipe_out
312 current_compiled_class := Void
313 end
314 else
315 -- Invalid stone, wipe out window content.
316 tree.wipe_out
317 current_compiled_class := Void
318 end
319 end
320 end
321
322 feature {EB_FEATURES_TREE} -- Status setting
323
324 go_to (a_feature: E_FEATURE) is
325 -- `a_feature' has been selected, the associated class
326 -- window should load corresponding feature.
327 require
328 a_feature_not_void: a_feature /= Void
329 local
330 feature_stone: FEATURE_STONE
331 do
332 -- if current_compiled_class /= Void and then current_compiled_class.has_feature_table then
333 -- ef := current_compiled_class.feature_with_name (a_feature.feature_name)
334 create feature_stone.make (a_feature)
335 development_window.set_feature_locating (true)
336 development_window.set_stone (feature_stone)
337 development_window.set_feature_locating (false)
338 -- end
339 end
340
341 go_to_clause (a_clause: FEATURE_CLAUSE_AS) is
342 -- `a_clause' has been selected, the associated class
343 -- window should display the corresponding feature clause.
344 -- the premise is that basic view is being used.
345 local
346 s: STRING
347 l_formatter: EB_BASIC_TEXT_FORMATTER
348 do
349 if a_clause.start_position > 0 then
350 s := current_compiled_class.text
351 if s = Void then
352 s := development_window.editor_tool.text_area.text
353 end
354 check
355 s_not_void: s /= Void
356 end
357 l_formatter ?= development_window.pos_container
358 if l_formatter /= Void then
359 development_window.editor_tool.text_area.display_line_at_top_when_ready (
360 character_line (a_clause.start_position, s))
361 end
362 end
363 end
364
365 go_to_line (a_line: INTEGER) is
366 -- Text at `a_line' has been selected, the associated class
367 -- window should display the corresponding line.
368 local
369 l_formatter: EB_BASIC_TEXT_FORMATTER
370 do
371 if a_line > 0 then
372 l_formatter ?= development_window.pos_container
373 if l_formatter = Void then
374 development_window.managed_main_formatters.first.execute
375 end
376 development_window.editor_tool.text_area.display_line_at_top_when_ready (
377 a_line)
378 end
379 end
380
381 go_to_feature_with_name (a_name: STRING) is
382 -- Go to feature with `a_name'
383 -- We use this to loacte a feature which is only parsed.
384 require
385 a_name_not_void: a_name /= Void
386 local
387 l_formatter: EB_BASIC_TEXT_FORMATTER
388 do
389 l_formatter ?= development_window.pos_container
390 if l_formatter = Void then
391 development_window.managed_main_formatters.first.execute
392 end
393 development_window.editor_tool.text_area.find_feature_named (a_name)
394 end
395
396 feature {EB_FEATURES_TREE} -- Implementation
397
398 current_class: CLASS_AS
399 -- Class currently opened.
400
401 current_compiled_class: CLASS_C
402 -- Class currently opened.
403
404 feature {NONE} -- Implementation
405
406 current_stone: CLASSI_STONE
407 -- Classc stone that was last dropped into `Current'.
408
409 development_window: EB_DEVELOPMENT_WINDOW
410 -- Associated development window.
411
412 character_line (pos: INTEGER; s: STRING): INTEGER is
413 -- Line number of character number `pos' in `s'.
414 require
415 valid_pos: pos > 0
416 valid_string: s /= Void
417 local
418 s2: STRING
419 do
420 if pos <= s.count then
421 s2 := s.substring (1, pos)
422 else
423 s2 := s
424 end
425 Result := s2.occurrences ('%N')
426 end
427
428 on_shown is
429 -- Update the display just before the tool is shown.
430 do
431 set_stone (current_stone)
432 end
433
434 indexing
435 copyright: "Copyright (c) 1984-2006, Eiffel Software"
436 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
437 licensing_options: "http://www.eiffel.com/licensing"
438 copying: "[
439 This file is part of Eiffel Software's Eiffel Development Environment.
440
441 Eiffel Software's Eiffel Development Environment is free
442 software; you can redistribute it and/or modify it under
443 the terms of the GNU General Public License as published
444 by the Free Software Foundation, version 2 of the License
445 (available at the URL listed under "license" above).
446
447 Eiffel Software's Eiffel Development Environment is
448 distributed in the hope that it will be useful, but
449 WITHOUT ANY WARRANTY; without even the implied warranty
450 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
451 See the GNU General Public License for more details.
452
453 You should have received a copy of the GNU General Public
454 License along with Eiffel Software's Eiffel Development
455 Environment; if not, write to the Free Software Foundation,
456 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
457 ]"
458 source: "[
459 Eiffel Software
460 356 Storke Road, Goleta, CA 93117 USA
461 Telephone 805-685-1006, Fax 805-685-6869
462 Website http://www.eiffel.com
463 Customer support http://support.eiffel.com
464 ]"
465
466 end -- class EB_FEATURES_TOOL

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23