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