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