/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/metric_tool/metric_interface/eb_new_metric_panel.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/metric_tool/metric_interface/eb_new_metric_panel.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62175 - (show annotations)
Tue Aug 1 01:51:00 2006 UTC (13 years, 4 months ago) by larryl
File size: 15616 byte(s)
Added missing class.
1 indexing
2 description: "Objects that represent an EV_TITLED_WINDOW.%
3 %The original version of this class was generated by EiffelBuild."
4 legal: "See notice at end of class."
5 status: "See notice at end of class."
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EB_NEW_METRIC_PANEL
11
12 inherit
13 EB_NEW_METRIC_PANEL_IMP
14
15 EB_CONSTANTS
16 undefine
17 is_equal,
18 copy,
19 default_create
20 end
21
22 QL_SHARED_UNIT
23 undefine
24 is_equal,
25 copy,
26 default_create
27 end
28
29 CONF_REFACTORING
30 undefine
31 is_equal,
32 copy,
33 default_create
34 end
35
36 EB_METRIC_SHARED
37 undefine
38 is_equal,
39 copy,
40 default_create
41 end
42
43 QL_OBSERVER
44 undefine
45 is_equal,
46 copy,
47 default_create
48 end
49
50 EB_METRIC_PANEL
51 undefine
52 is_equal,
53 copy,
54 default_create
55 end
56
57 EB_METRIC_INTERFACE_PROVIDER
58 undefine
59 is_equal,
60 copy,
61 default_create
62 end
63
64 EB_SHARED_PREFERENCES
65 undefine
66 is_equal,
67 copy,
68 default_create
69 end
70
71 EV_SHARED_APPLICATION
72 undefine
73 is_equal,
74 copy,
75 default_create
76 end
77
78 create
79 make
80
81 feature {NONE} -- Initialization
82
83 make (a_tool: like metric_tool) is
84 -- Initialize `metric_tool' with `a_tool'.
85 require
86 a_tool_attached: a_tool /= Void
87 do
88 metric_tool := a_tool
89 default_create
90 ensure
91 metric_tool_set: metric_tool = a_tool
92 end
93
94 user_initialization is
95 -- Called by `initialize'.
96 -- Any custom user initialization that
97 -- could not be performed in `initialize',
98 -- (due to regeneration of implementation class)
99 -- can be added here.
100 do
101 create metric_selector.make (False)
102 metric_selector_area.extend (metric_selector)
103 -- Initialize toolbar
104 new_metric_btn.remove_text
105 new_metric_btn.set_pixmap (pixmaps.icon_pixmaps.new_metric_icon)
106 new_metric_btn.set_tooltip (metric_names.f_new)
107
108 remove_metric_btn.remove_text
109 remove_metric_btn.set_pixmap (pixmaps.icon_pixmaps.general_remove_icon)
110 remove_metric_btn.set_tooltip (metric_names.f_remove)
111
112 save_metric_btn.remove_text
113 save_metric_btn.set_pixmap (pixmaps.icon_pixmaps.general_save_icon)
114 save_metric_btn.set_tooltip (metric_names.f_save)
115
116 -- Setup actions
117 new_metric_btn.select_actions.extend (agent on_new_metric_button_pressed)
118 new_metric_btn.pointer_button_press_actions.extend (agent on_new_metric_button_is_right_clicked)
119 metric_selector.metric_selected_actions.extend (agent on_metric_selected)
120 save_metric_btn.select_actions.extend (agent on_save_metric)
121 remove_metric_btn.select_actions.extend (agent on_remove_metric)
122
123 metric_selector.group_selected_actions.extend (agent on_group_selected)
124 save_metric_btn.disable_sensitive
125 remove_metric_btn.disable_sensitive
126
127 no_metric_lbl.set_text (metric_names.e_no_metric_is_selected)
128 end
129
130 feature -- Status report
131
132 is_valid_metric_type (a_type: INTEGER): BOOLEAN is
133 -- Is `a_type' a valid metric type?
134 do
135 Result := a_type = basic_metric_type or a_type = linear_metric_type or a_type = ratio_metric_type
136 end
137
138 is_metric_changed: BOOLEAN
139 -- Is definition of current metric changed?
140
141 is_current_metric_editor_reusable (a_type: INTEGER): BOOLEAN is
142 -- Is `current_metric_editor' reusable for metric of type `a_type'?
143 require
144 a_type_valid: is_valid_metric_type (a_type)
145 do
146 if current_metric_editor /= Void then
147 Result :=
148 (current_metric_editor.is_basic_metric_editor and then a_type = basic_metric_type) or
149 (current_metric_editor.is_linear_metric_editor and then a_type = linear_metric_type) or
150 (current_metric_editor.is_ratio_metric_editor and then a_type = ratio_metric_type)
151 end
152 end
153
154 feature -- Basic operations
155
156 synchronize_when_compile_start is
157 -- Synchronize when Eiffel compilation starts.
158 do
159 disable_sensitive
160 end
161
162 synchronize_when_compile_stop is
163 -- Synchronize when Eiffel compilation stops.
164 do
165 enable_sensitive
166 end
167
168 feature -- Actions
169
170 on_new_metric_button_is_right_clicked (a_x, a_y, a_button: INTEGER; a_x_tilt, a_y_tilt, a_pressure: DOUBLE; a_screen_x, a_screen_y: INTEGER) is
171 -- Action to be performed when new metric button is right clicked
172 local
173 l_editor: like current_metric_editor
174 l_metric: EB_METRIC
175 do
176 if a_button = 3 then
177 l_editor := current_metric_editor
178 if l_editor /= Void then
179 l_metric := l_editor.metric
180 l_metric.set_name (metric_manager.next_metric_name ("Unnamed metric"))
181 metric_selector.remove_selection
182 metric_selector.remove_selection
183 load_metric_definition (l_metric, metric_type_id (l_metric), l_metric.unit, True)
184 end
185 end
186 end
187
188
189 on_new_metric_button_pressed is
190 -- Action to be performed when new metric button is pressed
191 local
192 l_menu: EV_MENU
193 do
194 l_menu := new_metric_menu
195 l_menu.show_at (new_metric_toolbar, 0, new_metric_toolbar.height - 3)
196 l_menu.destroy
197 end
198
199 on_metric_selected (a_metric: EB_METRIC) is
200 -- Action to be performed when a metric is selected
201 require
202 a_metric_attached: a_metric /= Void
203 do
204 load_metric_definition (a_metric, metric_type (a_metric), a_metric.unit, False)
205 end
206
207 on_save_metric is
208 -- Action to be performed when save a metric.
209 local
210 l_old_metric: EB_METRIC
211 l_new_metric: EB_METRIC
212 l_dlg: EV_ERROR_DIALOG
213 l_ok: BOOLEAN
214 l_message: STRING
215 do
216 check current_metric_editor /= Void end
217 l_old_metric := original_metric
218 l_new_metric := current_metric_editor.metric
219 l_ok := True
220 if l_new_metric.name.is_empty then
221 l_ok := False
222 l_message := metric_names.t_metric_name_can_not_be_empty
223 elseif
224 current_metric_editor.mode = {EB_METRIC_EDITOR}.new_mode and then
225 metric_manager.has_metric (l_new_metric.name)
226 then
227 l_ok := False
228 l_message := metric_names.t_metric_with_name + " %"" + l_new_metric.name + "%" " + metric_names.t_metric_exists
229 elseif
230 current_metric_editor.mode = {EB_METRIC_EDITOR}.edit_mode and then
231 l_old_metric /= Void and then
232 not l_old_metric.name.is_case_insensitive_equal (l_new_metric.name) and then
233 metric_manager.has_metric (l_new_metric.name)
234 then
235 l_ok := False
236 l_message := metric_names.t_metric_with_name + " %"" + l_new_metric.name + "%" " + metric_names.t_metric_exists
237 end
238 if l_ok then
239 metric_manager.save_metric (l_new_metric, current_metric_editor.mode = {EB_METRIC_EDITOR}.new_mode, l_old_metric)
240 metric_tool.store_metrics
241 metric_selector.set_last_selected_metric (l_new_metric.name)
242 metric_tool.load_metrics (True)
243 else
244 create l_dlg.make_with_text (l_message + "%N" + metric_names.t_metric_not_saved)
245 l_dlg.set_buttons (<<metric_names.t_ok>>)
246 l_dlg.show_modal_to_window (metric_tool.development_window.window)
247 end
248 end
249
250 on_select is
251 -- Action to be performed when current is selected
252 do
253 end
254
255 on_create_new_metric (a_type: INTEGER; a_unit: QL_METRIC_UNIT) is
256 -- Action to be performed when create a new metric of type `a_type' and unit `a_unit'.
257 -- For metric type information, see `basic_metric_type', `linear_metric_type' and `ratio_metric_type'.
258 require
259 a_type_valid: is_valid_metric_type (a_type)
260 a_unit_attached: a_unit /= Void
261 do
262 metric_selector.remove_selection
263 load_metric_definition (Void, a_type, a_unit, True)
264 end
265
266 on_remove_metric is
267 -- Action to be performed when user wants to remove selected metric
268 local
269 l_dlg: STANDARD_DISCARDABLE_CONFIRMATION_DIALOG
270 do
271 check
272 original_metric /= Void
273 current_metric_editor /= Void
274 end
275 create l_dlg.make_initialized (
276 2, preferences.dialog_data.confirm_remove_metric_string,
277 metric_names.t_remove_metric + "%"" + current_metric_editor.name_area.name.twin + "%"?",
278 metric_names.t_discard_remove_prompt,
279 preferences.preferences
280 )
281 l_dlg.set_ok_action (agent remove_metric)
282 l_dlg.show_modal_to_window (metric_tool.development_window.window)
283 end
284
285 remove_metric is
286 -- Remove current editing metric.
287 do
288 check
289 original_metric /= Void
290 current_metric_editor /= Void
291 end
292 metric_manager.remove_metric (original_metric.name)
293 metric_tool.store_metrics
294 metric_selector.select_first_metric
295 metric_tool.load_metrics (True)
296 end
297
298 on_group_selected is
299 -- Action to be performed when a group in `metric_selector' is selected
300 do
301 remove_metric_btn.disable_sensitive
302 end
303
304 on_metric_changed is
305 -- Action to be performed when definition or description of current metric changes
306 do
307 is_metric_changed := True
308 save_metric_btn.enable_sensitive
309 ensure
310 definition_changed: is_metric_changed
311 end
312
313 feature -- Basic operations
314
315 load_metric_definition (a_metric: EB_METRIC; a_type: INTEGER; a_unit: QL_METRIC_UNIT; a_new: BOOLEAN) is
316 -- Load `a_metric' definition whose type is `a_type' and unit is `a_unit'.
317 -- `a_new' is True indicates that we are creating a new metric.
318 require
319 a_type_valid: is_valid_metric_type (a_type)
320 a_new_valid: not a_new implies a_metric /= Void
321 a_unit_attached: a_unit /= Void
322 local
323 l_mode: INTEGER
324 do
325 -- Decide editor mode: read-only, edit or new.
326 if a_new then
327 l_mode := new_mode
328 else
329 if a_metric.is_predefined then
330 l_mode := readonly_mode
331 else
332 l_mode := edit_mode
333 end
334 end
335 is_metric_changed := (l_mode = new_mode)
336
337 -- Synchronize interface.
338 inspect
339 l_mode
340 when new_mode then
341 save_metric_btn.enable_sensitive
342 remove_metric_btn.disable_sensitive
343 when readonly_mode then
344 save_metric_btn.disable_sensitive
345 remove_metric_btn.disable_sensitive
346 when edit_mode then
347 save_metric_btn.disable_sensitive
348 remove_metric_btn.enable_sensitive
349 end
350 original_metric := a_metric
351 -- Refresh metric definition area.
352 if not is_current_metric_editor_reusable (a_type) then
353 current_metric_editor := new_metric_editor (a_type)
354 current_metric_editor.change_actions.extend (agent on_metric_changed)
355 metric_definition_area.wipe_out
356 metric_definition_area.extend (current_metric_editor.widget)
357 end
358 current_metric_editor.initialize_editor (a_metric, l_mode, a_unit)
359 end
360
361 metric_type (a_metric: EB_METRIC): INTEGER is
362 -- Type name of `a_metric'
363 require
364 a_metric_attached: a_metric /= Void
365 do
366 if a_metric.is_basic then
367 Result := basic_metric_type
368 elseif a_metric.is_linear then
369 Result := linear_metric_type
370 elseif a_metric.is_ratio then
371 Result := ratio_metric_type
372 end
373 end
374
375 feature -- Notification
376
377 update (a_observable: QL_OBSERVABLE; a_data: ANY) is
378 -- Notification from `a_observable' indicating that `a_data' changed.
379 local
380 l_data: BOOLEAN_REF
381 do
382 metric_selector.load_metrics (True)
383 metric_selector.try_to_selected_last_metric
384 if metric_selector.selected_metric = Void then
385 metric_definition_area.wipe_out
386 metric_definition_area.extend (no_metric_frame)
387 save_metric_btn.disable_sensitive
388 remove_metric_btn.disable_sensitive
389 current_metric_editor := Void
390 end
391 if a_data /= Void then
392 l_data ?= a_data
393 if l_data /= Void then
394 if l_data.item then
395 -- This is an update when Eiffel compilation starts.
396 synchronize_when_compile_start
397 else
398 -- This is an update when Eiffel compilation stops.
399 synchronize_when_compile_stop
400 end
401 end
402 end
403 end
404
405 feature -- Access
406
407 metric_selector: EB_METRIC_SELECTOR
408 -- Metric selector
409
410 feature{NONE} -- Access
411
412 new_basic_metric_panel: EB_BASIC_METRIC_DEFINITION_AREA
413
414 current_metric_editor: EB_METRIC_EDITOR
415 -- Current metric editor
416
417 original_metric: EB_METRIC
418 -- Current metric
419
420 feature{NONE} -- Implementation
421
422 new_metric_menu: EV_MENU is
423 -- Menu for creating new metrics
424 local
425 l_submenu: EV_MENU
426 l_menu_item: EV_MENU_ITEM
427 l_unit_list: LIST [TUPLE [l_unit: QL_METRIC_UNIT; l_pixmap: EV_PIXMAP]]
428 l_type: INTEGER_REF
429 do
430 l_unit_list := unit_list (False)
431
432 create Result
433 create l_submenu.make_with_text (displayed_name (metric_names.t_basic) + " metric")
434 l_submenu.set_data (basic_metric_type)
435 l_submenu.set_pixmap (pixmaps.icon_pixmaps.metric_basic_icon)
436 Result.extend (l_submenu)
437
438 create l_submenu.make_with_text (displayed_name (metric_names.t_linear) + " metric")
439 l_submenu.set_data (linear_metric_type)
440 l_submenu.set_pixmap (pixmaps.icon_pixmaps.metric_linear_icon)
441 Result.extend (l_submenu)
442
443 from
444 Result.start
445 until
446 Result.index > 2
447 loop
448 l_type ?= Result.item.data
449 from
450 l_unit_list.start
451 until
452 l_unit_list.after
453 loop
454 l_submenu ?= Result.item
455 create l_menu_item.make_with_text_and_action (displayed_name (l_unit_list.item.l_unit.name), agent on_create_new_metric (l_type.item, l_unit_list.item.l_unit))
456 l_menu_item.set_pixmap (l_unit_list.item.l_pixmap)
457 l_submenu.extend (l_menu_item)
458 l_unit_list.forth
459 end
460 Result.forth
461 end
462 create l_menu_item.make_with_text_and_action (displayed_name (ratio_unit.name + " metric"), agent on_create_new_metric (ratio_metric_type, ratio_unit))
463 l_menu_item.set_pixmap (pixmaps.icon_pixmaps.metric_ratio_icon)
464 Result.extend (l_menu_item)
465 ensure
466 result_attached: Result /= Void
467 end
468
469 new_metric_editor (a_type: INTEGER): like current_metric_editor is
470 -- New metric editor for metric of type `a_type'
471 require
472 a_type_valid: is_valid_metric_type (a_type)
473 do
474 if a_type = basic_metric_type then
475 create {EB_BASIC_METRIC_DEFINITION_AREA} Result.make (metric_tool)
476 elseif a_type = linear_metric_type then
477 create {EB_LINEAR_METRIC_DEFINITION_AREA} Result.make (metric_tool)
478 elseif a_type = ratio_metric_type then
479 create {EB_RATIO_METRIC_DEFINITION_AREA} Result.make (metric_tool)
480 end
481 ensure
482 result_attached: Result /= Void
483 end
484
485 invariant
486 metric_tool_attached: metric_tool /= Void
487
488 indexing
489 copyright: "Copyright (c) 1984-2006, Eiffel Software"
490 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
491 licensing_options: "http://www.eiffel.com/licensing"
492 copying: "[
493 This file is part of Eiffel Software's Eiffel Development Environment.
494
495 Eiffel Software's Eiffel Development Environment is free
496 software; you can redistribute it and/or modify it under
497 the terms of the GNU General Public License as published
498 by the Free Software Foundation, version 2 of the License
499 (available at the URL listed under "license" above).
500
501 Eiffel Software's Eiffel Development Environment is
502 distributed in the hope that it will be useful, but
503 WITHOUT ANY WARRANTY; without even the implied warranty
504 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
505 See the GNU General Public License for more details.
506
507 You should have received a copy of the GNU General Public
508 License along with Eiffel Software's Eiffel Development
509 Environment; if not, write to the Free Software Foundation,
510 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
511 ]"
512 source: "[
513 Eiffel Software
514 356 Storke Road, Goleta, CA 93117 USA
515 Telephone 805-685-1006, Fax 805-685-6869
516 Website http://www.eiffel.com
517 Customer support http://support.eiffel.com
518 ]"
519
520
521 end -- class EB_NEW_METRIC_PANEL
522

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23