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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62007 - (show annotations)
Sun Jul 30 06:12:50 2006 UTC (13 years, 4 months ago) by manus
File size: 6993 byte(s)
EiffelStudio docking branch. It only contains modified classes needed to get the docking version of EiffelStudio.
1 indexing
2 description: "Command to save last calculated measure."
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_ADD_CMD
11
12 inherit
13 EB_METRIC_COMMAND
14
15 EB_CONSTANTS
16
17 create
18 make
19
20 feature -- Initialization
21
22 execute is
23 -- Add and save latest calculated measure.
24 do
25 on_add_click
26 end
27
28 pixmap: EV_PIXMAP is
29 -- Pixmaps representing the command.
30 do
31 Result := Pixmaps.Icon_save_measure
32 end
33
34 tooltip: STRING is
35 -- Tooltip for the toolbar button.
36 do
37 Result := "Add current measure to the list and save it"
38 end
39
40 description: STRING is
41 -- Description for this command.
42 do
43 Result := "Add metrics"
44 end
45
46 name: STRING is "add"
47 -- Name of the command. Used to store the command in the
48 -- preferences.
49
50
51 feature -- Action
52
53 fill_and_save_multi_column_list is
54 -- Fill `multi_column_list' with metrics on 'add' click and save measure in file.
55 require
56 existing_tool: tool /= Void
57 calculation_done: tool.is_calculation_done
58 name_correct: not name_error
59 valid_scope: tool.scope (scope_type) /= Void
60 valid_metric: tool.metric (tool.selected_metric) /= Void
61 local
62 row_array: ARRAY [STRING_32]
63 row: EV_MULTI_COLUMN_LIST_ROW
64 a_percentage: BOOLEAN
65 a_metric: EB_METRIC
66 archive_measure: STRING
67 do
68 create row_array.make (1, 6)
69 row_array.put (tool.name.text, 1)
70 row_array.put (scope_type, 2)
71 row_array.put (scope_name, 3)
72 row_array.put (tool.selected_metric, 4)
73
74 a_metric := tool.metric (tool.selected_metric)
75 a_percentage := a_metric.percentage
76 row_array.put (tool.metric_result.out, 5)
77 -- Fill archive comparison column.
78 if tool.default_archive then
79 row_array.put ("-", 6)
80 else
81 archive_measure := tool.archive.retrieve_archived_result (a_metric, tool.archive.archived_file, tool.archive.archived_root_element, tool.archive_mode, tool.metric_result)
82 row_array.put (archive_measure, 6)
83 end
84
85
86 create row
87 row.fill (row_array)
88 -- Create file for saving if not yet created.
89 if not tool.file_manager.metric_file.exists then
90 tool.file_manager.destroy_file_name
91 tool.set_file_loaded (False)
92 tool.file_handler.load_files
93 end
94 check tool.file_manager.metric_file.exists end
95 tool.file_manager.add_row (row, "new")
96 tool.file_manager.store
97 tool.file_manager.measure_notify_all_but (tool)
98 row.put_i_th (tool.fix_decimals_and_percentage (tool.metric_result, a_metric.percentage), 5)
99 row.set_pixmap (pixmaps.icon_pixmaps.general_tick_icon)
100 tool.multi_column_list.extend (row)
101 tool.resize_column_list_to_content (tool.multi_column_list)
102 ensure
103 measure_saved: equal (tool.file_manager.measure_header.count , old tool.file_manager.measure_header.count + 1)
104 end
105
106 name_error: BOOLEAN is
107 -- Has measure name been used for a previously recorded measure?
108 require
109 existing_tool: tool /= Void
110 local
111 list: EV_MULTI_COLUMN_LIST
112 do
113 Result:= tool.name.text = Void or else tool.name.text.is_empty
114 if not Result then
115 Result := tool.name.text.has ('<') or tool.name.text.has ('>')
116 end
117 list := tool.multi_column_list
118 from
119 list.start
120 until
121 list.after or Result
122 loop
123 Result := Result or equal (list.item.i_th (1), tool.name.text)
124 list.forth
125 end
126 end
127
128 path_shown: BOOLEAN
129 -- Has `tool.file_manager.metric_file' path been shown once at least?
130
131 scope_name: STRING
132 -- Name of selected scope in `tool'.
133
134 set_scope_name (str: STRING) is
135 -- Assign `str' to `scope_name'.
136 require
137 correct_name: str /= Void and then not str.is_empty
138 do
139 scope_name := str
140 end
141
142 scope_type: STRING
143 -- Type of selected scope in `tool'.
144
145 set_scope_type (str: STRING) is
146 -- Assign `str' to `scope_type'.
147 require
148 correct_type: str /= Void and then not str.is_empty
149 do
150 scope_type := str
151 ensure
152 valid_scope: tool.scope (scope_type) /= Void
153 end
154
155 added: BOOLEAN
156 -- Has calculated result been added?
157
158 set_added (bool: BOOLEAN) is
159 -- Assign `bool' to `added'.
160 do
161 added := bool
162 end
163
164 on_add_click is
165 -- Add calculated metric in `multi_column_list' and save it in file.
166 require
167 existing_tool: tool /= Void
168 Result_not_added: not added
169 local
170 x_pos, y_pos, local_index: INTEGER
171 measure_name: STRING
172 error_dialog: EB_INFORMATION_DIALOG
173 do
174 if tool.is_calculation_done then
175 x_pos := tool.development_window.window.x_position + 100
176 y_pos := tool.development_window.window.y_position + 100
177
178 if not name_error then
179 fill_and_save_multi_column_list
180 added := True
181 tool.add.disable_sensitive
182 tool.add_cmd_in_menu.disable_sensitive
183 measure_name := tool.name.text
184 if equal (measure_name.substring (1, 6), "Result") then
185 local_index := measure_name.substring (7, measure_name.count).to_integer
186 end
187 tool.set_name_index (local_index.max (tool.name_index) + 1)
188 tool.name.set_text ("Result" + tool.name_index.out)
189 if not path_shown then
190 create error_dialog.make_with_text ("Measures are saved in file:%N" + tool.file_manager.metric_file_name)
191 error_dialog.set_position (x_pos, y_pos)
192 error_dialog.show_modal_to_window (tool.development_window.window)
193 path_shown := True
194 end
195 else
196 create error_dialog.make_with_text ("Metric name already exists or is empty%N%
197 %or contains invalid characters (<, >)%N%
198 %Please change it before saving.")
199 error_dialog.set_position (x_pos, y_pos)
200 error_dialog.show_modal_to_window (tool.development_window.window)
201 end
202 end
203 end
204
205 indexing
206 copyright: "Copyright (c) 1984-2006, Eiffel Software"
207 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
208 licensing_options: "http://www.eiffel.com/licensing"
209 copying: "[
210 This file is part of Eiffel Software's Eiffel Development Environment.
211
212 Eiffel Software's Eiffel Development Environment is free
213 software; you can redistribute it and/or modify it under
214 the terms of the GNU General Public License as published
215 by the Free Software Foundation, version 2 of the License
216 (available at the URL listed under "license" above).
217
218 Eiffel Software's Eiffel Development Environment is
219 distributed in the hope that it will be useful, but
220 WITHOUT ANY WARRANTY; without even the implied warranty
221 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
222 See the GNU General Public License for more details.
223
224 You should have received a copy of the GNU General Public
225 License along with Eiffel Software's Eiffel Development
226 Environment; if not, write to the Free Software Foundation,
227 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
228 ]"
229 source: "[
230 Eiffel Software
231 356 Storke Road, Goleta, CA 93117 USA
232 Telephone 805-685-1006, Fax 805-685-6869
233 Website http://www.eiffel.com
234 Customer support http://support.eiffel.com
235 ]"
236
237 end -- class EB_METRIC_ADD_CMD

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23