1 | // ==================================================================== // |
---|
2 | // // |
---|
3 | // File : EXP_interface.cxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // // |
---|
7 | // Coded by Ralf Westram (coder@reallysoft.de) in September 2001 // |
---|
8 | // Copyright Department of Microbiology (Technical University Munich) // |
---|
9 | // // |
---|
10 | // Visit our web site at: http://www.arb-home.de/ // |
---|
11 | // // |
---|
12 | // // |
---|
13 | // ==================================================================== // |
---|
14 | |
---|
15 | #include "EXP_local.hxx" |
---|
16 | #include "GEN_local.hxx" |
---|
17 | |
---|
18 | #include <db_query.h> |
---|
19 | #include <db_scanner.hxx> |
---|
20 | #include <dbui.h> |
---|
21 | #include <awt_sel_boxes.hxx> |
---|
22 | #include <item_sel_list.h> |
---|
23 | #include <aw_awar_defs.hxx> |
---|
24 | #include <aw_root.hxx> |
---|
25 | #include <aw_awar.hxx> |
---|
26 | #include <aw_msg.hxx> |
---|
27 | #include <aw_question.hxx> |
---|
28 | #include <arbdbt.h> |
---|
29 | #include <info_window.h> |
---|
30 | |
---|
31 | using namespace std; |
---|
32 | |
---|
33 | #define AD_F_ALL AWM_ALL |
---|
34 | |
---|
35 | static GBDATA* EXP_get_current_experiment_data(GBDATA *gb_main, AW_root *aw_root) { |
---|
36 | GBDATA *gb_species = GEN_get_current_organism(gb_main, aw_root); |
---|
37 | GBDATA *gb_experiment_data = 0; |
---|
38 | |
---|
39 | if (gb_species) gb_experiment_data = EXP_get_experiment_data(gb_species); |
---|
40 | |
---|
41 | return gb_experiment_data; |
---|
42 | } |
---|
43 | |
---|
44 | static void EXP_select_experiment(GBDATA* /* gb_main */, AW_root *aw_root, const char *item_name) { |
---|
45 | char *name = strdup(item_name); |
---|
46 | char *slash = strchr(name, '/'); |
---|
47 | |
---|
48 | if (slash) { |
---|
49 | slash[0] = 0; |
---|
50 | aw_root->awar(AWAR_ORGANISM_NAME)->write_string(name); |
---|
51 | aw_root->awar(AWAR_EXPERIMENT_NAME)->write_string(slash+1); |
---|
52 | } |
---|
53 | free(name); |
---|
54 | } |
---|
55 | |
---|
56 | static char *EXP_get_experiment_id(GBDATA * /* gb_main */, GBDATA *gb_experiment) { |
---|
57 | GBDATA *gb_species = GB_get_grandfather(gb_experiment); |
---|
58 | return GBS_global_string_copy("%s/%s", GBT_read_name(gb_species), GBT_read_name(gb_experiment)); |
---|
59 | } |
---|
60 | |
---|
61 | static GBDATA *EXP_find_experiment_by_id(GBDATA *gb_main, const char *id) { |
---|
62 | char *organism = strdup(id); |
---|
63 | char *exp = strchr(organism, '/'); |
---|
64 | GBDATA *result = 0; |
---|
65 | |
---|
66 | if (exp) { |
---|
67 | *exp++ = 0; |
---|
68 | GBDATA *gb_organism = GEN_find_organism(gb_main, organism); |
---|
69 | if (gb_organism) { |
---|
70 | result = EXP_find_experiment(gb_organism, exp); |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | free(organism); |
---|
75 | return result; |
---|
76 | } |
---|
77 | |
---|
78 | static char *old_species_marks = 0; // configuration storing marked species |
---|
79 | |
---|
80 | inline void exp_restore_old_species_marks(GBDATA *gb_main) { |
---|
81 | if (old_species_marks) { |
---|
82 | GBT_restore_marked_species(gb_main, old_species_marks); |
---|
83 | freenull(old_species_marks); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | static GBDATA *EXP_get_first_experiment_data(GBDATA *gb_main, AW_root *aw_root, QUERY_RANGE range) { |
---|
88 | GBDATA *gb_organism = 0; |
---|
89 | GB_ERROR error = 0; |
---|
90 | |
---|
91 | exp_restore_old_species_marks(gb_main); |
---|
92 | |
---|
93 | switch (range) { |
---|
94 | case QUERY_CURRENT_ITEM: { |
---|
95 | char *species_name = aw_root->awar(AWAR_ORGANISM_NAME)->read_string(); |
---|
96 | gb_organism = GBT_find_species(gb_main, species_name); |
---|
97 | free(species_name); |
---|
98 | break; |
---|
99 | } |
---|
100 | case QUERY_MARKED_ITEMS: { |
---|
101 | GBDATA *gb_pseudo = GEN_first_marked_pseudo_species(gb_main); |
---|
102 | |
---|
103 | if (gb_pseudo) { // there are marked pseudo-species.. |
---|
104 | old_species_marks = GBT_store_marked_species(gb_main, 1); // store and unmark marked species |
---|
105 | error = GBT_with_stored_species(gb_main, old_species_marks, GEN_mark_organism_or_corresponding_organism, 0); // mark organisms related with stored |
---|
106 | |
---|
107 | if (!error) gb_organism = GEN_first_marked_organism(gb_main); |
---|
108 | } |
---|
109 | else { |
---|
110 | gb_organism = GEN_first_marked_organism(gb_main); |
---|
111 | } |
---|
112 | |
---|
113 | break; |
---|
114 | } |
---|
115 | case QUERY_ALL_ITEMS: { |
---|
116 | gb_organism = GBT_first_species(gb_main); |
---|
117 | break; |
---|
118 | } |
---|
119 | default: { |
---|
120 | gen_assert(0); |
---|
121 | break; |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | if (error) GB_export_error(error); |
---|
126 | return gb_organism ? EXP_get_experiment_data(gb_organism) : 0; |
---|
127 | } |
---|
128 | |
---|
129 | static GBDATA *EXP_get_next_experiment_data(GBDATA *gb_experiment_data, QUERY_RANGE range) { |
---|
130 | GBDATA *gb_organism = 0; |
---|
131 | switch (range) { |
---|
132 | case QUERY_CURRENT_ITEM: { |
---|
133 | break; |
---|
134 | } |
---|
135 | case QUERY_MARKED_ITEMS: { |
---|
136 | GBDATA *gb_last_species = GB_get_father(gb_experiment_data); |
---|
137 | gb_organism = GEN_next_marked_organism(gb_last_species); |
---|
138 | |
---|
139 | if (!gb_organism) exp_restore_old_species_marks(GB_get_root(gb_experiment_data)); // got all -> clean up |
---|
140 | |
---|
141 | break; |
---|
142 | } |
---|
143 | case QUERY_ALL_ITEMS: { |
---|
144 | GBDATA *gb_last_species = GB_get_father(gb_experiment_data); |
---|
145 | gb_organism = GBT_next_species(gb_last_species); |
---|
146 | break; |
---|
147 | } |
---|
148 | default: { |
---|
149 | gen_assert(0); |
---|
150 | break; |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | return gb_organism ? EXP_get_experiment_data(gb_organism) : 0; |
---|
155 | } |
---|
156 | |
---|
157 | static GBDATA *EXP_get_current_experiment(GBDATA *gb_main, AW_root *aw_root) { |
---|
158 | GBDATA *gb_organism = GEN_get_current_organism(gb_main, aw_root); |
---|
159 | GBDATA *gb_experiment = 0; |
---|
160 | |
---|
161 | if (gb_organism) { |
---|
162 | char *experiment_name = aw_root->awar(AWAR_EXPERIMENT_NAME)->read_string(); |
---|
163 | gb_experiment = EXP_find_experiment(gb_organism, experiment_name); |
---|
164 | free(experiment_name); |
---|
165 | } |
---|
166 | |
---|
167 | return gb_experiment; |
---|
168 | } |
---|
169 | |
---|
170 | static void add_selected_experiment_changed_cb(AW_root *aw_root, const RootCallback& cb) { |
---|
171 | aw_root->awar(AWAR_EXPERIMENT_NAME)->add_callback(cb); |
---|
172 | ORGANISM_get_selector().add_selection_changed_cb(aw_root, cb); |
---|
173 | } |
---|
174 | |
---|
175 | static GBDATA *first_experiment_in_range(GBDATA *gb_experiment_data, QUERY_RANGE range) { |
---|
176 | GBDATA *gb_first = NULL; |
---|
177 | switch (range) { |
---|
178 | case QUERY_ALL_ITEMS: gb_first = EXP_first_experiment_rel_exp_data(gb_experiment_data); break; |
---|
179 | case QUERY_MARKED_ITEMS: gb_first = GB_first_marked(gb_experiment_data, "experiment"); break; |
---|
180 | case QUERY_CURRENT_ITEM: gb_first = EXP_get_current_experiment(GB_get_root(gb_experiment_data), AW_root::SINGLETON); break; |
---|
181 | } |
---|
182 | return gb_first; |
---|
183 | } |
---|
184 | static GBDATA *next_experiment_in_range(GBDATA *gb_prev, QUERY_RANGE range) { |
---|
185 | GBDATA *gb_next = NULL; |
---|
186 | switch (range) { |
---|
187 | case QUERY_ALL_ITEMS: gb_next = EXP_next_experiment(gb_prev); break; |
---|
188 | case QUERY_MARKED_ITEMS: gb_next = GB_next_marked(gb_prev, "experiment"); break; |
---|
189 | case QUERY_CURRENT_ITEM: gb_next = NULL; break; |
---|
190 | } |
---|
191 | return gb_next; |
---|
192 | } |
---|
193 | |
---|
194 | #if defined(WARN_TODO) |
---|
195 | #warning move EXP_item_selector to SL/ITEMS |
---|
196 | #endif |
---|
197 | |
---|
198 | static struct MutableItemSelector EXP_item_selector = { |
---|
199 | QUERY_ITEM_EXPERIMENTS, |
---|
200 | EXP_select_experiment, |
---|
201 | EXP_get_experiment_id, |
---|
202 | EXP_find_experiment_by_id, |
---|
203 | experiment_field_selection_list_update_cb, |
---|
204 | -1, // unknown |
---|
205 | CHANGE_KEY_PATH_EXPERIMENTS, |
---|
206 | "experiment", |
---|
207 | "experiments", |
---|
208 | "name", |
---|
209 | EXP_get_first_experiment_data, |
---|
210 | EXP_get_next_experiment_data, |
---|
211 | first_experiment_in_range, |
---|
212 | next_experiment_in_range, |
---|
213 | EXP_get_current_experiment, |
---|
214 | add_selected_experiment_changed_cb, |
---|
215 | &ORGANISM_get_selector(), GB_get_grandfather, |
---|
216 | }; |
---|
217 | |
---|
218 | ItemSelector& EXP_get_selector() { return EXP_item_selector; } |
---|
219 | |
---|
220 | static QUERY::DbQuery *GLOBAL_experiment_query = 0; |
---|
221 | |
---|
222 | #if defined(WARN_TODO) |
---|
223 | #warning move EXP_create_experiment_query_window to SL/DB_UI |
---|
224 | #endif |
---|
225 | |
---|
226 | AW_window *EXP_create_experiment_query_window(AW_root *aw_root, AW_CL cl_gb_main) { |
---|
227 | static AW_window_simple_menu *aws = 0; |
---|
228 | if (!aws) { |
---|
229 | GBDATA *gb_main = (GBDATA*)cl_gb_main; |
---|
230 | |
---|
231 | aws = new AW_window_simple_menu; |
---|
232 | aws->init(aw_root, "EXPERIMENT_QUERY", "Experiment SEARCH and QUERY"); |
---|
233 | aws->create_menu("More functions", "f"); |
---|
234 | aws->load_xfig("ad_query.fig"); |
---|
235 | |
---|
236 | QUERY::query_spec awtqs(EXP_get_selector()); |
---|
237 | |
---|
238 | awtqs.gb_main = gb_main; |
---|
239 | awtqs.species_name = AWAR_SPECIES_NAME; |
---|
240 | awtqs.tree_name = AWAR_TREE; |
---|
241 | awtqs.select_bit = GB_USERFLAG_QUERY; |
---|
242 | awtqs.use_menu = 1; |
---|
243 | awtqs.ere_pos_fig = "ere3"; |
---|
244 | awtqs.where_pos_fig = "where3"; |
---|
245 | awtqs.by_pos_fig = "by3"; |
---|
246 | awtqs.qbox_pos_fig = "qbox"; |
---|
247 | awtqs.rescan_pos_fig = 0; |
---|
248 | awtqs.key_pos_fig = 0; |
---|
249 | awtqs.query_pos_fig = "content"; |
---|
250 | awtqs.result_pos_fig = "result"; |
---|
251 | awtqs.count_pos_fig = "count"; |
---|
252 | awtqs.do_query_pos_fig = "doquery"; |
---|
253 | awtqs.config_pos_fig = "doconfig"; |
---|
254 | awtqs.do_mark_pos_fig = "domark"; |
---|
255 | awtqs.do_unmark_pos_fig = "dounmark"; |
---|
256 | awtqs.do_delete_pos_fig = "dodelete"; |
---|
257 | awtqs.do_set_pos_fig = "doset"; |
---|
258 | awtqs.do_refresh_pos_fig = "dorefresh"; |
---|
259 | awtqs.open_parser_pos_fig = "openparser"; |
---|
260 | awtqs.popup_info_window = EXP_popup_experiment_window; |
---|
261 | |
---|
262 | QUERY::DbQuery *query = create_query_box(aws, &awtqs, "exp"); |
---|
263 | GLOBAL_experiment_query = query; |
---|
264 | |
---|
265 | aws->create_menu("More search", "s"); |
---|
266 | aws->insert_menu_topic("exp_search_equal_fields_within_db", "Search For Equal Fields and Mark Duplicates", "E", "search_duplicates.hlp", AWM_ALL, (AW_CB)QUERY::search_duplicated_field_content, (AW_CL)query, 0); |
---|
267 | aws->insert_menu_topic("exp_search_equal_words_within_db", "Search For Equal Words Between Fields and Mark Duplicates", "W", "search_duplicates.hlp", AWM_ALL, (AW_CB)QUERY::search_duplicated_field_content, (AW_CL)query, 1); |
---|
268 | |
---|
269 | aws->button_length(7); |
---|
270 | |
---|
271 | aws->at("close"); |
---|
272 | aws->callback((AW_CB0)AW_POPDOWN); |
---|
273 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
274 | aws->at("help"); |
---|
275 | aws->callback(makeHelpCallback("experiment_search.hlp")); |
---|
276 | aws->create_button("HELP", "HELP", "H"); |
---|
277 | } |
---|
278 | return aws; |
---|
279 | } |
---|
280 | |
---|
281 | static void experiment_delete_cb(AW_window *aww, AW_CL cl_gb_main) { |
---|
282 | if (aw_ask_sure("experiment_delete", "Are you sure to delete the experiment")) { |
---|
283 | GBDATA *gb_main = (GBDATA*)cl_gb_main; |
---|
284 | GB_transaction ta(gb_main); |
---|
285 | GBDATA *gb_experiment = EXP_get_current_experiment(gb_main, aww->get_root()); |
---|
286 | |
---|
287 | GB_ERROR error = gb_experiment ? GB_delete(gb_experiment) : "Please select a experiment first"; |
---|
288 | if (error) { |
---|
289 | error = ta.close(error); |
---|
290 | aw_message(error); |
---|
291 | } |
---|
292 | } |
---|
293 | } |
---|
294 | |
---|
295 | static void experiment_create_cb(AW_window *aww, AW_CL cl_gb_main) { |
---|
296 | GBDATA *gb_main = (GBDATA*)cl_gb_main; |
---|
297 | GB_ERROR error = GB_begin_transaction(gb_main); |
---|
298 | |
---|
299 | if (!error) { |
---|
300 | AW_root *aw_root = aww->get_root(); |
---|
301 | GBDATA *gb_experiment_data = EXP_get_current_experiment_data(gb_main, aw_root); |
---|
302 | |
---|
303 | if (!gb_experiment_data) { |
---|
304 | error = "Please select an organism"; |
---|
305 | } |
---|
306 | else { |
---|
307 | char *dest = aw_root->awar(AWAR_EXPERIMENT_DEST)->read_string(); |
---|
308 | GBDATA *gb_dest = EXP_find_experiment_rel_exp_data(gb_experiment_data, dest); |
---|
309 | |
---|
310 | if (gb_dest) { |
---|
311 | error = GBS_global_string("Experiment '%s' already exists", dest); |
---|
312 | } |
---|
313 | else { |
---|
314 | gb_dest = EXP_find_or_create_experiment_rel_exp_data(gb_experiment_data, dest); |
---|
315 | if (!gb_dest) error = GB_await_error(); |
---|
316 | else aww->get_root()->awar(AWAR_EXPERIMENT_NAME)->write_string(dest); |
---|
317 | } |
---|
318 | free(dest); |
---|
319 | } |
---|
320 | } |
---|
321 | |
---|
322 | GB_end_transaction_show_error(gb_main, error, aw_message); |
---|
323 | } |
---|
324 | |
---|
325 | static void experiment_rename_cb(AW_window *aww, AW_CL cl_gb_main) { |
---|
326 | AW_root *aw_root = aww->get_root(); |
---|
327 | char *source = aw_root->awar(AWAR_EXPERIMENT_NAME)->read_string(); |
---|
328 | char *dest = aw_root->awar(AWAR_EXPERIMENT_DEST)->read_string(); |
---|
329 | |
---|
330 | if (strcmp(source, dest) != 0) { |
---|
331 | GBDATA *gb_main = (GBDATA*)cl_gb_main; |
---|
332 | GB_ERROR error = GB_begin_transaction(gb_main); |
---|
333 | |
---|
334 | if (!error) { |
---|
335 | GBDATA *gb_experiment_data = EXP_get_current_experiment_data(gb_main, aww->get_root()); |
---|
336 | |
---|
337 | if (!gb_experiment_data) error = "Please select a species first"; |
---|
338 | else { |
---|
339 | GBDATA *gb_source = EXP_find_experiment_rel_exp_data(gb_experiment_data, source); |
---|
340 | GBDATA *gb_dest = EXP_find_experiment_rel_exp_data(gb_experiment_data, dest); |
---|
341 | |
---|
342 | if (!gb_source) error = "Please select an experiment"; |
---|
343 | else if (gb_dest) error = GB_export_errorf("Experiment '%s' already exists", dest); |
---|
344 | else { |
---|
345 | GBDATA *gb_name = GB_search(gb_source, "name", GB_STRING); |
---|
346 | if (!gb_name) error = GB_await_error(); |
---|
347 | else { |
---|
348 | error = GB_write_string(gb_name, dest); |
---|
349 | if (!error) aww->get_root()->awar(AWAR_EXPERIMENT_NAME)->write_string(dest); |
---|
350 | } |
---|
351 | } |
---|
352 | } |
---|
353 | } |
---|
354 | error = GB_end_transaction(gb_main, error); |
---|
355 | aww->hide_or_notify(error); |
---|
356 | } |
---|
357 | |
---|
358 | free(source); |
---|
359 | free(dest); |
---|
360 | } |
---|
361 | |
---|
362 | static void experiment_copy_cb(AW_window *aww, AW_CL cl_gb_main) { |
---|
363 | char *source = aww->get_root()->awar(AWAR_EXPERIMENT_NAME)->read_string(); |
---|
364 | char *dest = aww->get_root()->awar(AWAR_EXPERIMENT_DEST)->read_string(); |
---|
365 | GBDATA *gb_main = (GBDATA*)cl_gb_main; |
---|
366 | GB_ERROR error = GB_begin_transaction(gb_main); |
---|
367 | |
---|
368 | if (!error) { |
---|
369 | GBDATA *gb_experiment_data = EXP_get_current_experiment_data(gb_main, aww->get_root()); |
---|
370 | |
---|
371 | if (!gb_experiment_data) { |
---|
372 | error = "Please select a species first."; |
---|
373 | } |
---|
374 | else { |
---|
375 | GBDATA *gb_source = EXP_find_experiment_rel_exp_data(gb_experiment_data, source); |
---|
376 | GBDATA *gb_dest = EXP_find_experiment_rel_exp_data(gb_experiment_data, dest); |
---|
377 | |
---|
378 | if (!gb_source) error = "Please select a experiment"; |
---|
379 | else if (gb_dest) error = GB_export_errorf("Experiment '%s' already exists", dest); |
---|
380 | else { |
---|
381 | gb_dest = GB_create_container(gb_experiment_data, "experiment"); |
---|
382 | if (!gb_dest) error = GB_await_error(); |
---|
383 | else error = GB_copy(gb_dest, gb_source); |
---|
384 | |
---|
385 | if (!error) { |
---|
386 | error = GBT_write_string(gb_dest, "name", dest); |
---|
387 | if (!error) aww->get_root()->awar(AWAR_EXPERIMENT_NAME)->write_string(dest); |
---|
388 | } |
---|
389 | } |
---|
390 | } |
---|
391 | } |
---|
392 | |
---|
393 | error = GB_end_transaction(gb_main, error); |
---|
394 | aww->hide_or_notify(error); |
---|
395 | |
---|
396 | free(source); |
---|
397 | free(dest); |
---|
398 | } |
---|
399 | |
---|
400 | static AW_window *create_experiment_rename_window(AW_root *root, AW_CL cl_gb_main) { |
---|
401 | AW_window_simple *aws = new AW_window_simple; |
---|
402 | aws->init(root, "RENAME_EXPERIMENT", "EXPERIMENT RENAME"); |
---|
403 | aws->load_xfig("ad_al_si.fig"); |
---|
404 | |
---|
405 | aws->callback((AW_CB0)AW_POPDOWN); |
---|
406 | aws->at("close"); |
---|
407 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
408 | |
---|
409 | aws->at("label"); |
---|
410 | aws->create_autosize_button(0, "Please enter the new name\nof the experiment"); |
---|
411 | |
---|
412 | aws->at("input"); |
---|
413 | aws->create_input_field(AWAR_EXPERIMENT_DEST, 15); |
---|
414 | aws->at("ok"); |
---|
415 | aws->callback(experiment_rename_cb, cl_gb_main); |
---|
416 | aws->create_button("GO", "GO", "G"); |
---|
417 | |
---|
418 | return (AW_window *)aws; |
---|
419 | } |
---|
420 | |
---|
421 | static AW_window *create_experiment_copy_window(AW_root *root, AW_CL cl_gb_main) { |
---|
422 | AW_window_simple *aws = new AW_window_simple; |
---|
423 | aws->init(root, "COPY_EXPERIMENT", "EXPERIMENT COPY"); |
---|
424 | aws->load_xfig("ad_al_si.fig"); |
---|
425 | |
---|
426 | aws->callback((AW_CB0)AW_POPDOWN); |
---|
427 | aws->at("close"); |
---|
428 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
429 | |
---|
430 | aws->at("label"); |
---|
431 | aws->create_autosize_button(0, "Please enter the name\nof the new experiment"); |
---|
432 | |
---|
433 | aws->at("input"); |
---|
434 | aws->create_input_field(AWAR_EXPERIMENT_DEST, 15); |
---|
435 | |
---|
436 | aws->at("ok"); |
---|
437 | aws->callback(experiment_copy_cb, cl_gb_main); |
---|
438 | aws->create_button("GO", "GO", "G"); |
---|
439 | |
---|
440 | return (AW_window *)aws; |
---|
441 | } |
---|
442 | |
---|
443 | static AW_window *create_experiment_create_window(AW_root *root, AW_CL cl_gb_main) { |
---|
444 | AW_window_simple *aws = new AW_window_simple; |
---|
445 | aws->init(root, "CREATE_EXPERIMENT", "EXPERIMENT CREATE"); |
---|
446 | aws->load_xfig("ad_al_si.fig"); |
---|
447 | |
---|
448 | aws->callback((AW_CB0)AW_POPDOWN); |
---|
449 | aws->at("close"); |
---|
450 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
451 | |
---|
452 | aws->at("label"); aws->create_autosize_button(0, "Please enter the name\nof the new experiment"); |
---|
453 | aws->at("input"); aws->create_input_field(AWAR_EXPERIMENT_DEST, 15); |
---|
454 | |
---|
455 | aws->at("ok"); |
---|
456 | aws->callback(experiment_create_cb, cl_gb_main); |
---|
457 | aws->create_button("GO", "GO", "G"); |
---|
458 | |
---|
459 | return aws; |
---|
460 | } |
---|
461 | |
---|
462 | static void EXP_create_field_items(AW_window *aws, GBDATA *gb_main) { |
---|
463 | static BoundItemSel *bis = new BoundItemSel(gb_main, EXP_get_selector()); |
---|
464 | exp_assert(bis->gb_main == gb_main); |
---|
465 | |
---|
466 | aws->insert_menu_topic("exp_reorder_fields", "Reorder fields ...", "R", "spaf_reorder.hlp", AD_F_ALL, AW_POPUP, (AW_CL)DBUI::create_fields_reorder_window, (AW_CL)bis); |
---|
467 | aws->insert_menu_topic("exp_delete_field", "Delete/Hide Field ...", "D", "spaf_delete.hlp", AD_F_ALL, AW_POPUP, (AW_CL)DBUI::create_field_delete_window, (AW_CL)bis); |
---|
468 | aws->insert_menu_topic("exp_create_field", "Create fields ...", "C", "spaf_create.hlp", AD_F_ALL, AW_POPUP, (AW_CL)DBUI::create_field_create_window, (AW_CL)bis); |
---|
469 | aws->sep______________(); |
---|
470 | aws->insert_menu_topic("exp_unhide_fields", "Show all hidden fields", "S", "scandb.hlp", AD_F_ALL, makeWindowCallback(experiment_field_selection_list_unhide_all_cb, gb_main, FIELD_FILTER_NDS)); |
---|
471 | aws->insert_menu_topic("exp_refresh_fields", "Refresh fields", "f", "scandb.hlp", AD_F_ALL, makeWindowCallback(experiment_field_selection_list_update_cb, gb_main, FIELD_FILTER_NDS)); |
---|
472 | } |
---|
473 | |
---|
474 | #if defined(WARN_TODO) |
---|
475 | #warning move EXP_create_experiment_window to SL/DB_UI |
---|
476 | #endif |
---|
477 | |
---|
478 | static AW_window *popup_new_experiment_window(AW_root *aw_root, GBDATA *gb_main, int detach_id); |
---|
479 | |
---|
480 | static void popup_detached_experiment_window(AW_window *aw_parent, const InfoWindow *infoWin) { |
---|
481 | const InfoWindow *reusable = InfoWindowRegistry::infowin.find_reusable_of_same_type_as(*infoWin); |
---|
482 | if (reusable) reusable->reuse(); |
---|
483 | else { // create a new window if none is reusable |
---|
484 | popup_new_experiment_window(aw_parent->get_root(), |
---|
485 | infoWin->get_gbmain(), |
---|
486 | InfoWindowRegistry::infowin.allocate_detach_id(*infoWin)); |
---|
487 | } |
---|
488 | } |
---|
489 | |
---|
490 | static AW_window *popup_new_experiment_window(AW_root *aw_root, GBDATA *gb_main, int detach_id) { // INFO_WINDOW_CREATOR |
---|
491 | AW_window_simple_menu *aws = new AW_window_simple_menu; |
---|
492 | const ItemSelector& itemType = EXP_get_selector(); |
---|
493 | |
---|
494 | DBUI::init_info_window(aw_root, aws, itemType, detach_id); |
---|
495 | aws->load_xfig("ad_spec.fig"); |
---|
496 | |
---|
497 | aws->button_length(8); |
---|
498 | |
---|
499 | aws->at("close"); |
---|
500 | aws->callback((AW_CB0)AW_POPDOWN); |
---|
501 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
502 | |
---|
503 | aws->at("search"); |
---|
504 | aws->callback(AW_POPUP, (AW_CL)EXP_create_experiment_query_window, (AW_CL)gb_main); |
---|
505 | aws->create_button("SEARCH", "SEARCH", "S"); |
---|
506 | |
---|
507 | aws->at("help"); |
---|
508 | aws->callback(makeHelpCallback("experiment_info.hlp")); |
---|
509 | aws->create_button("HELP", "HELP", "H"); |
---|
510 | |
---|
511 | DbScanner *scanner = create_db_scanner(gb_main, aws, "box", 0, "field", "enable", DB_VIEWER, 0, "mark", FIELD_FILTER_NDS, itemType); |
---|
512 | const InfoWindow& infoWin = InfoWindowRegistry::infowin.registerInfoWindow(aws, scanner, detach_id); |
---|
513 | |
---|
514 | aws->create_menu("EXPERIMENT", "E", AD_F_ALL); |
---|
515 | aws->insert_menu_topic("experiment_delete", "Delete", "D", "spa_delete.hlp", AD_F_ALL, (AW_CB)experiment_delete_cb, (AW_CL)gb_main, 0); |
---|
516 | aws->insert_menu_topic("experiment_rename", "Rename ...", "R", "spa_rename.hlp", AD_F_ALL, AW_POPUP, (AW_CL)create_experiment_rename_window, (AW_CL)gb_main); |
---|
517 | aws->insert_menu_topic("experiment_copy", "Copy ...", "y", "spa_copy.hlp", AD_F_ALL, AW_POPUP, (AW_CL)create_experiment_copy_window, (AW_CL)gb_main); |
---|
518 | aws->insert_menu_topic("experiment_create", "Create ...", "C", "spa_create.hlp", AD_F_ALL, AW_POPUP, (AW_CL)create_experiment_create_window, (AW_CL)gb_main); |
---|
519 | aws->sep______________(); |
---|
520 | |
---|
521 | aws->create_menu("FIELDS", "F", AD_F_ALL); |
---|
522 | EXP_create_field_items(aws, gb_main); |
---|
523 | |
---|
524 | aws->at("detach"); |
---|
525 | infoWin.add_detachOrGet_button(popup_detached_experiment_window); |
---|
526 | |
---|
527 | aws->show(); |
---|
528 | infoWin.attach_selected_item(); |
---|
529 | |
---|
530 | return aws; |
---|
531 | } |
---|
532 | |
---|
533 | void EXP_popup_experiment_window(AW_root *aw_root, GBDATA *gb_main) { |
---|
534 | static AW_window *aws = 0; |
---|
535 | if (!aws) { |
---|
536 | aws = popup_new_experiment_window(aw_root, gb_main, InfoWindow::MAIN_WINDOW); |
---|
537 | } |
---|
538 | else { |
---|
539 | aws->activate(); |
---|
540 | } |
---|
541 | } |
---|