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

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_metric_management_cmd.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62049 - (show annotations)
Sun Jul 30 06:20:54 2006 UTC (13 years, 4 months ago) by manus
File size: 35051 byte(s)
EiffelStudio docking branch. It only contains modified classes needed to get the docking version of EiffelStudio.
1 indexing
2 description: "Dialog that allows to reorder, delete or import metrics."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 author: "Tanit Talbi"
6 date: "$Date$"
7 revision: "$Revision$"
8
9 class
10 EB_METRIC_MANAGEMENT_CMD
11
12 inherit
13 EB_METRIC_COMMAND
14 redefine
15 make
16 end
17
18 SHARED_XML_ROUTINES
19
20 EV_KEY_CONSTANTS
21
22 create
23 make
24
25 feature -- Initialization
26
27 make (a_target: like tool) is
28 -- Initialize the command with target `a_target'.
29 -- Create `import'.
30 do
31 Precursor (a_target)
32 create import.make (Current)
33 create ev_list
34 ev_list.set_minimum_height (100)
35 ev_list.key_press_actions.extend (agent key_delete_action)
36 ev_list.select_actions.extend (agent on_select)
37 end
38
39 pixmap: EV_PIXMAP is
40 -- Pixmap representing the command.
41 do
42 Result := pixmaps.icon_pixmaps.tool_metric_icon
43 end
44
45 tooltip: STRING is
46 -- Tooltip for the toolbar button.
47 do
48 Result := "Reorder, delete, import metrics."
49 end
50
51 description: STRING is
52 -- Description for this command.
53 do
54 Result := "Metric management"
55 end
56
57 name: STRING is "management"
58 -- Name of the command. Used to store the command in the
59 -- preferences.
60
61 feature -- Widget
62
63 build_management_dialog is
64 -- Build `management_dialog' to reorder, delete, edit or import metrics.
65 local
66 hb, hb1: EV_HORIZONTAL_BOX
67 vb1, vb2: EV_VERTICAL_BOX
68 frame: EV_FRAME
69 label: EV_LABEL
70 ev_any: EV_WIDGET
71 exit_button: EV_BUTTON
72 do
73 create management_dialog
74 management_dialog.set_title ("Management")
75 management_dialog.set_icon_pixmap (pixmaps.icon_pixmaps.general_dialog_icon)
76
77 create vb1
78 vb1.set_padding (5)
79 vb1.set_border_width (5)
80 create hb
81 hb.set_padding (5)
82 create frame.make_with_text ("Metrics")
83 frame.set_minimum_size (170, 240)
84 create vb2
85 vb2.set_border_width (5)
86 vb2.set_padding (5)
87 create label.make_with_text ("Available composite metrics:")
88 label.align_text_left
89 vb2.extend (label)
90 vb2.disable_item_expand (label)
91
92 ev_list.wipe_out
93 create hb1
94 hb1.extend (ev_list)
95 vb2.extend (hb1)
96
97 create label.make_with_text ("Formula:")
98 label.align_text_left
99 vb2.extend (label)
100 vb2.disable_item_expand (label)
101
102 create formula_field
103 formula_field.disable_edit
104 vb2.extend (formula_field)
105 vb2.disable_item_expand (formula_field)
106
107 create label.make_with_text ("Unit:")
108 label.align_text_left
109 vb2.extend (label)
110 vb2.disable_item_expand (label)
111
112 create unit_field
113 unit_field.disable_edit
114 vb2.extend (unit_field)
115 vb2.disable_item_expand (unit_field)
116
117 frame.extend (vb2)
118
119 hb.extend (frame)
120
121 create vb2
122 vb2.set_minimum_width (75)
123 vb2.set_padding (5)
124
125 create {EV_CELL} ev_any
126 vb2.extend (ev_any)
127
128 create hb1
129 hb1.set_border_width (5)
130 create up_button.make_with_text_and_action ("Up", agent up_action)
131 up_button.set_minimum_size (60, 22)
132 hb1.extend (up_button)
133 hb1.disable_item_expand (up_button)
134 vb2.extend (hb1)
135 vb2.disable_item_expand (hb1)
136
137 create hb1
138 hb1.set_border_width (5)
139 create down_button.make_with_text_and_action ("Down", agent down_action)
140 down_button.set_minimum_size (60, 22)
141 hb1.extend (down_button)
142 hb1.disable_item_expand (down_button)
143 vb2.extend (hb1)
144 vb2.disable_item_expand (hb1)
145
146 create hb1
147 hb1.set_border_width (5)
148 create delete_button.make_with_text_and_action ("Delete", agent delete_action)
149 delete_button.set_minimum_size (60, 22)
150 hb1.extend (delete_button)
151 hb1.disable_item_expand (delete_button)
152 vb2.extend (hb1)
153 vb2.disable_item_expand (hb1)
154
155 create hb1
156 hb1.set_border_width (5)
157 create edit_button.make_with_text_and_action ("Edit", agent edit_action)
158 edit_button.set_minimum_size (60, 22)
159 hb1.extend (edit_button)
160 hb1.disable_item_expand (edit_button)
161 vb2.extend (hb1)
162 vb2.disable_item_expand (hb1)
163
164 create {EV_CELL} ev_any
165 vb2.extend (ev_any)
166
167 hb.extend (vb2)
168 hb.disable_item_expand (vb2)
169 vb1.extend (hb)
170
171 create hb
172 create save_button.make_with_text_and_action ("Save", agent save_action)
173 save_button.set_minimum_width (60)
174 hb.extend (create {EV_CELL})
175 hb.extend (save_button)
176 hb.disable_item_expand (save_button)
177
178 -- create import.make (Current)
179
180 create import_button.make_with_text_and_action ("Import...", agent import.import_action)
181 import_button.set_minimum_width (60)
182 create {EV_CELL} ev_any
183 ev_any.set_minimum_width (10)
184 hb.extend (ev_any)
185 hb.disable_item_expand (ev_any)
186 hb.extend (import_button)
187 hb.disable_item_expand (import_button)
188
189 create exit_button.make_with_text_and_action ("Exit", agent exit_action)
190 exit_button.set_minimum_width (60)
191 create {EV_CELL} ev_any
192 ev_any.set_minimum_width (10)
193 hb.extend (ev_any)
194 hb.disable_item_expand (ev_any)
195 hb.extend (exit_button)
196 hb.disable_item_expand (exit_button)
197 hb.extend (create {EV_CELL})
198
199 vb1.extend (hb)
200 vb1.disable_item_expand (hb)
201
202 management_dialog.extend (vb1)
203 management_dialog.set_default_push_button (exit_button)
204 management_dialog.set_default_cancel_button (exit_button)
205 end
206
207
208 feature -- Access
209
210 management_dialog: EV_DIALOG
211 -- Dialog to reorder, delete, edit or import metrics.
212
213 ev_list: EV_LIST
214 -- List of available non basic metrics in current system.
215
216 deleted_metrics: ARRAYED_LIST [EV_LIST_ITEM]
217 -- List of deleted metrics.
218
219 import: EB_METRIC_MANAGEMENT_IMPORT
220 -- Interface for importation.
221
222 up_button, down_button: EV_BUTTON
223 -- Buttons to change non basic metrics order.
224
225 delete_button: EV_BUTTON
226 -- Button to delete selected metric.
227
228 edit_button: EV_BUTTON
229 -- Button to edit selected metric.
230
231 save_button: EV_BUTTON
232 -- Button to save changes.
233
234 import_button: EV_BUTTON
235 -- Button to import a setof metric definitions.
236
237 formula_field: EV_TEXT_FIELD
238 -- Text_field to display selected metric's formula in `management_dialog'.
239
240 unit_field: EV_TEXT_FIELD
241 -- Text field to display selected metric's unit in `management_dialog'.
242
243 delete_confirmation_shown: BOOLEAN
244 -- Has `confirm_dialog' been displayed at least once when user decided to remove metric?
245
246 confirm_dialog: EV_CONFIRMATION_DIALOG
247 -- Dialog to confirm actions.
248
249 feature -- Setting
250
251 fill_ev_list (a_list: EV_LIST) is
252 -- Fill `ev_list' with available non basic metrics of current system.
253 require
254 existing_metrics: tool.metrics /= Void
255 check_non_basic: tool.metrics.count - tool.nb_basic_metrics = tool.user_metrics_xml_list.count
256 local
257 metric_list: ARRAYED_LIST [EB_METRIC]
258 metric_xml_list: ARRAYED_LIST [XM_ELEMENT]
259 list_item_data: CELL2 [EB_METRIC, XM_ELEMENT]
260 list_item: EV_LIST_ITEM
261 i: INTEGER
262 do
263 metric_list := tool.metrics
264 metric_xml_list := tool.user_metrics_xml_list
265 i := tool.nb_basic_metrics
266 from
267 metric_list.go_i_th (i + 1)
268 metric_xml_list.start
269 until
270 metric_list.after and
271 metric_xml_list.after
272 loop
273 create list_item.make_with_text (metric_list.item.name)
274 create list_item_data.make (metric_list.item, metric_xml_list.item)
275 list_item.set_data (list_item_data)
276 list_item.set_pebble (list_item)
277 list_item.drop_actions.extend (agent drop_action_in_list (?, list_item))
278 list_item.pointer_double_press_actions.extend (agent double_click_edit)
279 a_list.extend (list_item)
280 metric_list.forth
281 metric_xml_list.forth
282 end
283 ev_list.drop_actions.extend (agent move_to_list (?, ev_list))
284 end
285
286 metric (str: STRING; list: EV_LIST): EB_METRIC is
287 -- Return the metric object whose name is `str'.
288 require
289 list_not_void: list /= Void
290 local
291 cursor: CURSOR
292 cell: CELL2 [EB_METRIC, XM_ELEMENT]
293 do
294 cursor := list.cursor
295 from
296 list.start
297 until
298 list.after or Result /= Void
299 loop
300 cell ?= list.item.data
301 if equal (cell.item1.name, str) then
302 Result := cell.item1
303 end
304 list.forth
305 end
306 list.go_to (cursor)
307 end
308
309 feature -- Drop actions
310
311 drop_action_in_list (new_item, old_item: EV_LIST_ITEM) is
312 -- Drop `new_item' to the left of `old_item'.
313 require
314 effective_new_item: new_item /= Void
315 effective_old_item: old_item /= Void
316 local
317 new_parent, old_parent: EV_LIST
318 drop_successful: BOOLEAN
319 do
320 new_parent ?= new_item.parent
321 old_parent ?= old_item.parent
322 if new_parent /= Void and old_parent /= Void then
323 if not equal (new_parent, old_parent) then
324 if equal (new_parent, import.importable_metric_list) and then import.add_button.is_sensitive then
325 import.add_metric
326 elseif equal (new_parent, import.current_metric_list) and then import.remove_button.is_sensitive then
327 import.remove_metric
328 end
329 drop_successful := new_item.parent = old_parent
330 if drop_successful then
331 insert_item_at (new_item, old_item)
332 end
333 else
334 insert_item_at (new_item, old_item)
335 end
336 save_button.enable_sensitive
337 end
338 ensure
339 same_parent: new_item.parent = old_item.parent
340 end
341
342 insert_item_at (new_item, old_item: EV_LIST_ITEM) is
343 -- Put `new_item' to the left of `old_item'.
344 require
345 effective_new_item: new_item /= Void
346 effective_old_item: old_item /= Void
347 do
348 if not equal (new_item, old_item) then
349 new_item.parent.start
350 new_item.parent.prune (new_item)
351 old_item.parent.start
352 old_item.parent.search (old_item)
353 old_item.parent.put_right (new_item)
354 end
355 ensure
356 same_parent: new_item.parent = old_item.parent
357 end
358
359 move_to_list (an_item: EV_LIST_ITEM; list: EV_LIST) is
360 -- Add `an_item' to `list'.
361 require
362 effective_item: an_item /= Void
363 effective_list: list /= Void
364 local
365 parent: EV_LIST
366 do
367 parent ?= an_item.parent
368 if not equal (parent, list) then
369 if equal (list, import.current_metric_list) and then import.add_button.is_sensitive then
370 import.add_metric
371 elseif equal (list, import.importable_metric_list) and then import.remove_button.is_sensitive then
372 import.remove_metric
373 end
374 else
375 an_item.parent.start
376 an_item.parent.prune (an_item)
377 list.extend (an_item)
378 end
379 ensure
380 new_parent: an_item.parent = list
381 end
382
383 feature -- Action
384
385 on_select is
386 -- Action to be performed when selecting an `ev_list' item.
387 require
388 item_selected: ev_list.selected_item /= Void
389 local
390 a_formula: STRING
391 cell: CELL2 [EB_METRIC, XM_ELEMENT]
392 do
393 if ev_list.first = ev_list.selected_item then
394 up_button.disable_sensitive
395 else
396 up_button.enable_sensitive
397 end
398 if ev_list.last = ev_list.selected_item then
399 down_button.disable_sensitive
400 else
401 down_button.enable_sensitive
402 end
403 delete_button.enable_sensitive
404 edit_button.enable_sensitive
405 cell ?= ev_list.selected_item.data
406 a_formula := Xml_routines.xml_string (cell.item2, "FORMULA")
407 formula_field.set_text (a_formula)
408 unit_field.set_text (cell.item1.unit)
409 end
410
411 up_action is
412 -- Move selected metric to upper position.
413 require
414 item_selected: ev_list.selected_item /= Void
415 local
416 selected_item: EV_LIST_ITEM
417 i: INTEGER
418 do
419 selected_item := ev_list.selected_item
420 if selected_item /= Void and then ev_list.first /= selected_item then
421 i := ev_list.index_of (selected_item, 1)
422 ev_list.go_i_th (i)
423 ev_list.swap (i - 1)
424 ev_list.i_th (i - 1).enable_select
425 save_button.enable_sensitive
426 end
427 end
428
429 down_action is
430 -- Move selected metric to lower position.
431 require
432 item_selected: ev_list.selected_item /= Void
433 local
434 selected_item: EV_LIST_ITEM
435 i: INTEGER
436 do
437 selected_item := ev_list.selected_item
438 if selected_item /= Void and then ev_list.last /= selected_item then
439 i := ev_list.index_of (selected_item, 1)
440 ev_list.go_i_th (i)
441 ev_list.swap (i + 1)
442 ev_list.i_th (i + 1).enable_select
443 save_button.enable_sensitive
444 end
445 end
446
447 delete_action is
448 -- Delete selected metric.
449 require
450 item_selected: ev_list.selected_item /= Void
451 local
452 selected_item: EV_LIST_ITEM
453 actions_array: ARRAY [PROCEDURE [ANY, TUPLE]]
454 do
455 selected_item := ev_list.selected_item
456 if selected_item /= Void then
457 create actions_array.make (1, 2)
458 actions_array.put (agent delete_confirmed, 1)
459 actions_array.put (agent do_nothing, 2)
460 if not delete_confirmation_shown then
461 create confirm_dialog.make_with_text_and_actions (
462 "Clicking save will remove the selected metric%N%
463 %any composite metric that involves it and any%N%
464 %recorded measure that involves it.%NContinue?", actions_array)
465 confirm_dialog.show_modal_to_window (management_dialog)
466 delete_confirmation_shown := True
467 else
468 delete_confirmed
469 end
470 end
471 end
472
473 key_delete_action (a_key: EV_KEY) is
474 -- Action to be performed on pressing delete.
475 do
476 if a_key.code = Key_delete and then ev_list.selected_item /= Void then
477 delete_action
478 end
479 end
480
481 delete_confirmed is
482 -- Remove metric, associated metrics and measures.
483 require
484 item_selected: ev_list.selected_item /= Void
485 local
486 selected_item: EV_LIST_ITEM
487 i: INTEGER
488 do
489 selected_item := ev_list.selected_item
490 i := ev_list.index_of (selected_item, 1)
491 deleted_metrics.extend (ev_list.i_th (i))
492 ev_list.go_i_th (i)
493 ev_list.remove
494
495 remove_metrics
496
497 save_button.enable_sensitive
498 up_button.disable_sensitive
499 down_button.disable_sensitive
500 delete_button.disable_sensitive
501 edit_button.disable_sensitive
502 formula_field.remove_text
503 unit_field.remove_text
504 end
505
506 edit_action is
507 -- Open `tool.new_metric.new_metric_definition_dialog' with fields filled
508 -- according to selected metric properties.
509 require
510 item_selected: ev_list.selected_item /= Void
511 local
512 x_pos, y_pos: INTEGER
513 selected_item: EV_LIST_ITEM
514 type: STRING
515 cell: CELL2 [EB_METRIC, XM_ELEMENT]
516 do
517 selected_item := ev_list.selected_item
518 if selected_item /= Void then
519 tool.development_window.window.set_pointer_style (tool.development_window.Wait_cursor)
520
521 cell ?= selected_item.data
522 x_pos := tool.development_window.window.x_position + 200
523 y_pos := tool.development_window.window.y_position + 40
524 if tool.new_metric.new_metric_definition_dialog = Void then
525 tool.new_metric.build_new_metric_definition_dialog
526 end
527 tool.new_metric.new_metric_definition_dialog.set_position (x_pos, y_pos)
528 tool.new_metric.derived_tab.preset
529 tool.new_metric.linear_tab.preset
530 tool.new_metric.ratio_metric_tab.preset
531 tool.new_metric.ratio_scope_tab.preset
532 tool.new_metric.set_edition (True)
533
534 type := cell.item2.attribute_by_name ("Type").value
535 if equal (type, "Derived") then
536 fill_derived (tool.new_metric.derived_tab, cell)
537 tool.new_metric.notebook.select_item (tool.new_metric.derived_tab)
538 elseif equal (type, "Linear") then
539 fill_linear (tool.new_metric.linear_tab, cell)
540 tool.new_metric.notebook.select_item (tool.new_metric.linear_tab)
541 elseif equal (type, "MRatio") then
542 fill_mratio (tool.new_metric.ratio_metric_tab, cell)
543 tool.new_metric.notebook.select_item (tool.new_metric.ratio_metric_tab)
544 elseif equal (type, "SRatio") then
545 fill_sratio (tool.new_metric.ratio_scope_tab, cell)
546 tool.new_metric.notebook.select_item (tool.new_metric.ratio_scope_tab)
547 end
548
549 tool.development_window.window.set_pointer_style (tool.development_window.Standard_cursor)
550 tool.new_metric.new_metric_definition_dialog.show_modal_to_window (management_dialog)
551 save_button.enable_sensitive
552 end
553 end
554
555 save_action is
556 -- Save changes order, redefinition, deletion and importation if any.
557 require
558 check_non_basic: tool.metrics.count - tool.nb_basic_metrics = tool.user_metrics_xml_list.count
559 local
560 metric_list: ARRAYED_LIST [EB_METRIC]
561 metric_xml_list: ARRAYED_LIST [XM_ELEMENT]
562 cell: CELL2 [EB_METRIC, XM_ELEMENT]
563 i: INTEGER
564 do
565 metric_list := tool.metrics.twin
566 metric_xml_list := tool.user_metrics_xml_list.twin
567 i := tool.nb_basic_metrics + 1
568 from metric_list.go_i_th (i) until metric_list.after loop
569 metric_list.remove
570 end
571 metric_xml_list.wipe_out
572 tool.file_manager.metric_header.wipe_out
573 if management_dialog /= Void and then management_dialog.is_displayed then
574 -- Importation is also possible on archive comparison. in that case,
575 -- there are no deleted item.
576 if deleted_metrics.count > 0 then
577 remove_measures
578 deleted_metrics.wipe_out
579 end
580 end
581 from ev_list.start until ev_list.after loop
582 cell ?= ev_list.item.data
583 metric_list.extend (cell.item1)
584 metric_xml_list.extend (cell.item2)
585 tool.file_manager.metric_header.put_last (cell.item2)
586 ev_list.forth
587 end
588 if not tool.file_manager.metric_file.exists then
589 tool.file_manager.destroy_file_name
590 tool.set_file_loaded (False)
591 tool.file_handler.load_files
592 end
593 check tool.file_manager.metric_file.exists end
594 tool.file_manager.store
595 tool.file_manager.metric_file.close
596 check metric_list.count = tool.nb_basic_metrics + ev_list.count end
597 tool.file_manager.management_metric_notify_all (metric_list, metric_xml_list)
598 if management_dialog /= Void and then management_dialog.is_displayed then
599 -- Importation is also possible on archive comparison.
600 -- In that case `interface.management_dialog' may not exist.
601 save_button.disable_sensitive
602 end
603 ensure
604 check_non_basic: tool.metrics.count - tool.nb_basic_metrics = tool.user_metrics_xml_list.count
605 end
606
607 exit_action is
608 -- Exit `management_dialog'.
609 do
610 management_dialog.hide
611 end
612
613 feature -- Measures and metrics deletion.
614
615 remove_measures is
616 -- Remove recorded measures evaluated for removed metrics.
617 require
618 existing_tool: tool /= Void
619 deleted_items: deleted_metrics.count > 0
620 local
621 current_metric: STRING
622 i: INTEGER
623 do
624 from
625 tool.multi_column_list.start
626 i := 1
627 until
628 tool.multi_column_list.after
629 loop
630 current_metric := tool.multi_column_list.item.i_th (4)
631 if metric_is_deleted (current_metric) then
632 tool.multi_column_list.i_th (i).enable_select
633 end
634 i := i + 1
635 tool.multi_column_list.forth
636 end
637 tool.delete.on_delete_click
638 end
639
640 metric_is_deleted (current_metric: STRING): BOOLEAN is
641 -- Has `current_metric' been deleted?
642 require
643 deleted_items: deleted_metrics.count > 0
644 local
645 cell: CELL2 [EB_METRIC, XM_ELEMENT]
646 do
647 from
648 deleted_metrics.start
649 until
650 deleted_metrics.after or Result
651 loop
652 cell ?= deleted_metrics.item.data
653 check cell /= Void end
654 Result:= equal (cell.item1.name, current_metric)
655 deleted_metrics.forth
656 end
657 end
658
659 remove_metrics is
660 -- Remove composite metrics whose definition involves a deleted metric.
661 require
662 existing_tool: tool /= Void
663 deleted_items: deleted_metrics.count > 0
664 local
665 cell: CELL2 [EB_METRIC, XM_ELEMENT]
666 do
667 from
668 ev_list.start
669 until
670 ev_list.after
671 loop
672 cell ?= ev_list.item.data
673 if has_deleted_metric (Xml_routines.element_by_name (cell.item2, "DEFINITION")) then
674 deleted_metrics.extend (ev_list.item)
675 ev_list.remove
676 else
677 ev_list.forth
678 end
679 end
680 end
681
682 has_deleted_metric (xml_def: XM_ELEMENT): BOOLEAN is
683 -- Has `xml_element' been defined with a removed metric?
684 require
685 existing_tool: tool /= Void
686 valid_definition: xml_def /= Void
687 local
688 i: INTEGER
689 metric_el: XM_ELEMENT
690 do
691 from
692 xml_def.start
693 i := 1
694 until
695 xml_def.after or Result
696 loop
697 metric_el ?= xml_def.item (i)
698 check metric_el /= Void end
699 if metric_el.name.is_equal ("METRIC") then
700 Result := metric_is_deleted (metric_el.text)
701 end
702 xml_def.forth
703 i := i + 1
704 end
705 end
706
707 feature -- Edit
708
709 double_click_edit (a_x, a_y, a_button: INTEGER; a_x_tilt, a_y_tilt, a_pressure: DOUBLE; a_screen_x, a_screen_y: INTEGER) is
710 -- Open `tool.new_metric.new_metric_definition_dialog' with fields filled
711 -- according to selected metric properties.
712 require
713 item_selected: ev_list.selected_item /= Void
714 do
715 if a_button = 1 then
716 edit_action
717 end
718 end
719
720 refresh (edited_metric: EB_METRIC; edited_xml_element: XM_ELEMENT) is
721 -- Update metric_definition of `ev_list.selected_item' after edition.
722 require
723 item_selected: ev_list.selected_item /= Void
724 local
725 cell: CELL2 [EB_METRIC, XM_ELEMENT]
726 list_item: EV_LIST_ITEM
727 do
728 create cell.make (edited_metric, edited_xml_element)
729 if equal (ev_list.selected_item.text, edited_metric.name) then
730 ev_list.selected_item.set_data (cell)
731 else
732 create list_item.make_with_text (edited_metric.name)
733 list_item.set_data (cell)
734 list_item.set_pebble (list_item)
735 list_item.drop_actions.extend (agent drop_action_in_list (?, list_item))
736 list_item.pointer_double_press_actions.extend (agent double_click_edit)
737 ev_list.extend (list_item)
738 end
739 end
740
741 fill_linear (linear_tab: EB_METRIC_LINEAR_TAB; cell: CELL2 [EB_METRIC, XM_ELEMENT]) is
742 -- Fill `tool.new_metric.new_metric_definition_dialog' for linear metric.
743 require
744 effective_linear_tab: linear_tab /= Void
745 effective_cell: cell /= Void and then (cell.item1 /= Void and cell.item2 /= Void)
746 local
747 selected_metric: EB_METRIC_COMPOSITE
748 definition, element: XM_ELEMENT
749 i: INTEGER
750 do
751 selected_metric ?= cell.item1
752 linear_tab.name_field.set_text (selected_metric.name)
753 linear_tab.unit_field.set_text (selected_metric.unit)
754 definition := Xml_routines.element_by_name (cell.item2, "DEFINITION")
755 element ?= definition.item (1)
756 linear_tab.formula.extend (element.text)
757 element ?= definition.item (3)
758 linear_tab.formula.extend (element.text)
759 element ?= definition.item (2)
760 linear_tab.formula.extend (element.text)
761 from
762 i := 4
763 until
764 i > definition.count
765 loop
766 element ?= definition.item (i + 3)
767 linear_tab.formula.extend (element.text)
768 element ?= definition.item (i)
769 linear_tab.formula.extend (element.text)
770 element ?= definition.item (i + 2)
771 linear_tab.formula.extend (element.text)
772 element ?= definition.item (i + 1)
773 linear_tab.formula.extend (element.text)
774 i := i + 4
775 end
776 linear_tab.set_displayed_metric (Xml_routines.xml_string (cell.item2, "FORMULA"))
777 linear_tab.text_field.set_text (Xml_routines.xml_string (cell.item2, "FORMULA"))
778 linear_tab.keep_same_unit_metrics (selected_metric)
779 linear_tab.disable_save
780 end
781
782 divide: STRING is " / "
783
784 fill_mratio (mratio_tab: EB_METRIC_RATIO_TAB; cell: CELL2 [EB_METRIC, XM_ELEMENT]) is
785 -- Fill `tool.new_metric.new_metric_definition_dialog' for ratio of two metrics over one scope.
786 require
787 effective_mratio_tab: mratio_tab /= Void
788 effective_cell: cell /= Void and then (cell.item1 /= Void and cell.item2 /= Void)
789 local
790 selected_metric: EB_METRIC_COMPOSITE
791 definition, num_element, den_element: XM_ELEMENT
792 num, den: STRING
793 do
794 selected_metric ?= cell.item1
795 mratio_tab.name_field.set_text (selected_metric.name)
796 mratio_tab.unit_field.set_text (selected_metric.unit)
797 definition := Xml_routines.element_by_name (cell.item2, "DEFINITION")
798 num_element ?= definition.item (1)
799 den_element ?= definition.item (2)
800 num := num_element.text
801 den := den_element.text
802 mratio_tab.formula.put_i_th (num, 1)
803 mratio_tab.formula.put_i_th (divide, 2)
804 mratio_tab.formula.put_i_th (den, 3)
805 mratio_tab.put_item_with_text (mratio_tab.first_metric_combobox, num)
806 mratio_tab.put_item_with_text (mratio_tab.second_metric_combobox, den)
807 mratio_tab.set_displayed_metric (Xml_routines.xml_string (cell.item2, "FORMULA"))
808 mratio_tab.text_field.set_text (Xml_routines.xml_string (cell.item2, "FORMULA"))
809 if selected_metric.percentage then
810 mratio_tab.percentage_button.enable_select
811 else
812 mratio_tab.percentage_button.disable_select
813 end
814 mratio_tab.disable_save
815 end
816
817 fill_sratio (sratio_tab: EB_METRIC_RATIO_SCOPE_TAB; cell: CELL2 [EB_METRIC, XM_ELEMENT]) is
818 -- Fill `tool.new_metric.new_metric_definition_dialog' for ratio of one metric over two scopes.
819 require
820 effective_sratio_tab: sratio_tab /= Void
821 effective_cell: cell /= Void and then (cell.item1 /= Void and cell.item2 /= Void)
822 local
823 selected_metric: EB_METRIC_COMPOSITE
824 definition, metric_el, num_el, den_el: XM_ELEMENT
825 a_metric, num, den: STRING
826 do
827 selected_metric ?= cell.item1
828 sratio_tab.name_field.set_text (selected_metric.name)
829 sratio_tab.unit_field.set_text (selected_metric.unit)
830 definition := Xml_routines.element_by_name (cell.item2, "DEFINITION")
831 metric_el ?= definition.item (1)
832 num_el ?= definition.item (2)
833 den_el ?= definition.item (3)
834 a_metric := metric_el.text
835 num := num_el.text
836 den := den_el.text
837 sratio_tab.formula.put_i_th (a_metric, 1)
838 sratio_tab.formula.put_i_th (num, 2)
839 sratio_tab.formula.put_i_th (divide, 3)
840 sratio_tab.formula.put_i_th (den, 4)
841 sratio_tab.put_item_with_text (sratio_tab.metric_combobox, a_metric)
842 sratio_tab.select_metric
843 sratio_tab.put_item_with_text (sratio_tab.first_scope_combobox, num)
844 sratio_tab.put_item_with_text (sratio_tab.second_scope_combobox, den)
845 sratio_tab.set_displayed_metric (Xml_routines.xml_string (cell.item2, "FORMULA"))
846 sratio_tab.text_field.set_text (Xml_routines.xml_string (cell.item2, "FORMULA"))
847 if selected_metric.percentage then
848 sratio_tab.percentage_button.enable_select
849 else
850 sratio_tab.percentage_button.disable_select
851 end
852 sratio_tab.disable_save
853 end
854
855 fill_derived (derived_tab: EB_METRIC_DERIVED_TAB; cell: CELL2 [EB_METRIC, XM_ELEMENT]) is
856 -- Fill `tool.new_metric.new_metric_definition_dialog' for ratio of derived metric.
857 require
858 effective_derived_tab: derived_tab /= Void
859 effective_cell: cell /= Void and then (cell.item1 /= Void and cell.item2 /= Void)
860 local
861 selected_metric: EB_METRIC_DERIVED
862 definition: XM_ELEMENT
863 and_op: BOOLEAN
864 do
865 selected_metric ?= cell.item1
866 derived_tab.name_field.set_text (selected_metric.name)
867 derived_tab.unit_field.set_text (selected_metric.unit)
868 derived_tab.put_item_with_text (derived_tab.raw_metric_combobox, selected_metric.parent_name)
869 definition := Xml_routines.element_by_name (cell.item2, "DEFINITION")
870 and_op := Xml_routines.xml_boolean (definition, "And")
871 if and_op then
872 derived_tab.and_button.enable_select
873 end
874 if equal (selected_metric.parent_name, interface_names.metric_classes) then
875 derived_tab.build_classes_panel
876 enable_classes_buttons (derived_tab, definition)
877 elseif equal (selected_metric.parent_name, interface_names.metric_dependents) then
878 derived_tab.build_dependents_panel
879 enable_dependents_buttons (derived_tab, definition)
880 elseif equal (selected_metric.parent_name, interface_names.metric_features) then
881 derived_tab.build_features_panel
882 enable_features_buttons (derived_tab, definition)
883 end
884 derived_tab.set_agent_array (tool.file_handler.build_agent_array (definition, derived_tab.bf))
885 derived_tab.disable_save
886 end
887
888 enable_classes_buttons (derived_tab: EB_METRIC_DERIVED_TAB; definition: XM_ELEMENT) is
889 -- Select crietria on "classes" panel of `derived_tab'.
890 require
891 effective_derived_tab: derived_tab /= Void
892 effective_definition: definition /= Void
893 do
894 if Xml_routines.element_by_name (definition, "Deferred_class") /= Void then
895 if Xml_routines.xml_boolean (definition, "Deferred_class") then
896 derived_tab.deferred_class.enable_select
897 else
898 derived_tab.effective_class.enable_select
899 end
900 else
901 derived_tab.ignore_deferred_class.enable_select
902 end
903 if Xml_routines.element_by_name (definition, "Invariant") /= Void then
904 if Xml_routines.xml_boolean (definition, "Invariant") then
905 derived_tab.invariant_equi.enable_select
906 else
907 derived_tab.not_invariant_equi.enable_select
908 end
909 else
910 derived_tab.ignore_invariant.enable_select
911 end
912 if Xml_routines.element_by_name (definition, "Obsolete") /= Void then
913 if Xml_routines.xml_boolean (definition, "Obsolete") then
914 derived_tab.obsolete_class.enable_select
915 else
916 derived_tab.not_obsolete_class.enable_select
917 end
918 else
919 derived_tab.ignore_obsolete.enable_select
920 end
921 end
922
923 enable_dependents_buttons (derived_tab: EB_METRIC_DERIVED_TAB; definition: XM_ELEMENT) is
924 -- Select crietria on "dependents" panel of `derived_tab'.
925 require
926 effective_derived_tab: derived_tab /= Void
927 effective_definition: definition /= Void
928 do
929 if Xml_routines.element_by_name (definition, "Self") /= Void then
930 if Xml_routines.xml_boolean (definition, "Self") then
931 derived_tab.self.enable_select
932 else
933 derived_tab.not_self.enable_select
934 end
935 end
936 if Xml_routines.element_by_name (definition, "D_or_i_clients") /= Void then
937 if Xml_routines.xml_boolean (definition, "D_or_i_clients") then
938 derived_tab.direct_clients.enable_select
939 else
940 derived_tab.indirect_clients.enable_select
941 end
942 else
943 derived_tab.ignore_clients.enable_select
944 end
945 if Xml_routines.element_by_name (definition, "D_or_i_suppliers") /= Void then
946 if Xml_routines.xml_boolean (definition, "D_or_i_suppliers") then
947 derived_tab.direct_suppliers.enable_select
948 else
949 derived_tab.indirect_suppliers.enable_select
950 end
951 else
952 derived_tab.ignore_suppliers.enable_select
953 end
954 if Xml_routines.element_by_name (definition, "D_or_i_heirs") /= Void then
955 if Xml_routines.xml_boolean (definition, "D_or_i_heirs") then
956 derived_tab.direct_heirs.enable_select
957 else
958 derived_tab.indirect_heirs.enable_select
959 end
960 else
961 derived_tab.ignore_heirs.enable_select
962 end
963 if Xml_routines.element_by_name (definition, "D_or_i_parents") /= Void then
964 if Xml_routines.xml_boolean (definition, "D_or_i_parents") then
965 derived_tab.direct_parents.enable_select
966 else
967 derived_tab.indirect_parents.enable_select
968 end
969 else
970 derived_tab.ignore_parents.enable_select
971 end
972 end
973
974 enable_features_buttons (derived_tab: EB_METRIC_DERIVED_TAB; definition: XM_ELEMENT) is
975 -- Select crietria on "features" panel of `derived_tab'.
976 require
977 effective_derived_tab: derived_tab /= Void
978 effective_definition: definition /= Void
979 do
980 if Xml_routines.element_by_name (definition, "Attr_or_rout") /= Void then
981 if Xml_routines.xml_boolean (definition, "Attr_or_rout") then
982 derived_tab.attr.enable_select
983 else
984 derived_tab.rout.enable_select
985 end
986 else
987 derived_tab.ignore_attr_rout.enable_select
988 end
989 if Xml_routines.element_by_name (definition, "Quer_or_comm") /= Void then
990 if Xml_routines.xml_boolean (definition, "Quer_or_comm") then
991 derived_tab.quer.enable_select
992 else
993 derived_tab.comm.enable_select
994 end
995 else
996 derived_tab.ignore_quer_comm.enable_select
997 end
998 if Xml_routines.element_by_name (definition, "Function") /= Void then
999 if Xml_routines.xml_boolean (definition, "Function") then
1000 derived_tab.func.enable_select
1001 else
1002 derived_tab.not_func.enable_select
1003 end
1004 else
1005 derived_tab.ignore_func.enable_select
1006 end
1007 if Xml_routines.element_by_name (definition, "Deferred_feat") /= Void then
1008 if Xml_routines.xml_boolean (definition, "Deferred_feat") then
1009 derived_tab.deferred_feat.enable_select
1010 else
1011 derived_tab.effective_feat.enable_select
1012 end
1013 else
1014 derived_tab.ignore_deferred_feat.enable_select
1015 end
1016 if Xml_routines.element_by_name (definition, "Exported") /= Void then
1017 if Xml_routines.xml_boolean (definition, "Exported") then
1018 derived_tab.exported.enable_select
1019 else
1020 derived_tab.not_exported.enable_select
1021 end
1022 else
1023 derived_tab.ignore_exported.enable_select
1024 end
1025 if Xml_routines.element_by_name (definition, "Pre_equi") /= Void then
1026 if Xml_routines.xml_boolean (definition, "Pre_equi") then
1027 derived_tab.pre_equi.enable_select
1028 else
1029 derived_tab.not_pre_equi.enable_select
1030 end
1031 else
1032 derived_tab.ignore_pre_equi.enable_select
1033 end
1034 if Xml_routines.element_by_name (definition, "Post_equi") /= Void then
1035 if Xml_routines.xml_boolean (definition, "Post_equi") then
1036 derived_tab.post_equi.enable_select
1037 else
1038 derived_tab.not_post_equi.enable_select
1039 end
1040 else
1041 derived_tab.ignore_post_equi.enable_select
1042 end
1043 if Xml_routines.element_by_name (definition, "Inherited") /= Void then
1044 if Xml_routines.xml_boolean (definition, "Inherited") then
1045 derived_tab.inherited.enable_select
1046 else
1047 derived_tab.not_inherited.enable_select
1048 end
1049 else
1050 derived_tab.ignore_inherited.enable_select
1051 end
1052 end
1053
1054 execute is
1055 -- Display `management_dialog'
1056 -- Reset needed objects.
1057 local
1058 x_pos, y_pos: INTEGER
1059 do
1060 x_pos := tool.development_window.window.x_position + 200
1061 y_pos := tool.development_window.window.y_position + 40
1062 if management_dialog = Void then
1063 build_management_dialog
1064 end
1065 management_dialog.set_position (x_pos, y_pos)
1066 ev_list.wipe_out
1067 fill_ev_list (ev_list)
1068 if import.importable_metric_list /= Void and import.current_metric_list /= Void then
1069 import.importable_metric_list.wipe_out
1070 import.current_metric_list.wipe_out
1071 end
1072 create deleted_metrics.make (1)
1073 up_button.disable_sensitive
1074 down_button.disable_sensitive
1075 delete_button.disable_sensitive
1076 edit_button.disable_sensitive
1077 save_button.disable_sensitive
1078 delete_confirmation_shown := False
1079 management_dialog.show_modal_to_window (tool.development_window.window)
1080 end
1081
1082 indexing
1083 copyright: "Copyright (c) 1984-2006, Eiffel Software"
1084 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
1085 licensing_options: "http://www.eiffel.com/licensing"
1086 copying: "[
1087 This file is part of Eiffel Software's Eiffel Development Environment.
1088
1089 Eiffel Software's Eiffel Development Environment is free
1090 software; you can redistribute it and/or modify it under
1091 the terms of the GNU General Public License as published
1092 by the Free Software Foundation, version 2 of the License
1093 (available at the URL listed under "license" above).
1094
1095 Eiffel Software's Eiffel Development Environment is
1096 distributed in the hope that it will be useful, but
1097 WITHOUT ANY WARRANTY; without even the implied warranty
1098 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1099 See the GNU General Public License for more details.
1100
1101 You should have received a copy of the GNU General Public
1102 License along with Eiffel Software's Eiffel Development
1103 Environment; if not, write to the Free Software Foundation,
1104 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1105 ]"
1106 source: "[
1107 Eiffel Software
1108 356 Storke Road, Goleta, CA 93117 USA
1109 Telephone 805-685-1006, Fax 805-685-6869
1110 Website http://www.eiffel.com
1111 Customer support http://support.eiffel.com
1112 ]"
1113
1114 end -- class EB_METRIC_MANAGEMENT_CMD

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23