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 <item_sel_list.h> |
---|
22 | #include <info_window.h> |
---|
23 | |
---|
24 | #include <awt_prompt.hxx> |
---|
25 | #include <awt_sel_boxes.hxx> |
---|
26 | |
---|
27 | #include <aw_awar_defs.hxx> |
---|
28 | #include <aw_root.hxx> |
---|
29 | #include <aw_msg.hxx> |
---|
30 | #include <aw_question.hxx> |
---|
31 | |
---|
32 | using namespace std; |
---|
33 | |
---|
34 | #define AD_F_ALL AWM_ALL |
---|
35 | |
---|
36 | static GBDATA* get_current_experiment_data(GBDATA *gb_main) { |
---|
37 | GBDATA *gb_species = GEN_get_current_organism(gb_main); |
---|
38 | GBDATA *gb_experiment_data = NULp; |
---|
39 | |
---|
40 | if (gb_species) gb_experiment_data = EXP_get_experiment_data(gb_species); |
---|
41 | |
---|
42 | return gb_experiment_data; |
---|
43 | } |
---|
44 | |
---|
45 | static void EXP_select_experiment(GBDATA* /* gb_main */, AW_root *aw_root, const char *item_name) { |
---|
46 | char *name = ARB_strdup(item_name); |
---|
47 | char *slash = strchr(name, '/'); |
---|
48 | |
---|
49 | if (slash) { |
---|
50 | slash[0] = 0; |
---|
51 | aw_root->awar(AWAR_ORGANISM_NAME)->write_string(name); |
---|
52 | aw_root->awar(AWAR_EXPERIMENT_NAME)->write_string(slash+1); |
---|
53 | } |
---|
54 | free(name); |
---|
55 | } |
---|
56 | |
---|
57 | static char *EXP_get_experiment_id(GBDATA * /* gb_main */, GBDATA *gb_experiment) { |
---|
58 | GBDATA *gb_species = GB_get_grandfather(gb_experiment); |
---|
59 | return GBS_global_string_copy("%s/%s", GBT_get_name_or_description(gb_species), GBT_get_name_or_description(gb_experiment)); |
---|
60 | } |
---|
61 | |
---|
62 | static GBDATA *EXP_find_experiment_by_id(GBDATA *gb_main, const char *id) { |
---|
63 | char *organism = ARB_strdup(id); |
---|
64 | char *exp = strchr(organism, '/'); |
---|
65 | GBDATA *result = NULp; |
---|
66 | |
---|
67 | if (exp) { |
---|
68 | *exp++ = 0; |
---|
69 | GBDATA *gb_organism = GEN_find_organism(gb_main, organism); |
---|
70 | if (gb_organism) { |
---|
71 | result = EXP_find_experiment(gb_organism, exp); |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | free(organism); |
---|
76 | return result; |
---|
77 | } |
---|
78 | |
---|
79 | static char *old_species_marks = NULp; // configuration storing marked species |
---|
80 | |
---|
81 | inline void exp_restore_old_species_marks(GBDATA *gb_main) { |
---|
82 | if (old_species_marks) { |
---|
83 | GBT_restore_marked_species(gb_main, old_species_marks); |
---|
84 | freenull(old_species_marks); |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | static GBDATA *EXP_get_first_experiment_data(GBDATA *gb_main, AW_root *aw_root, QUERY_RANGE range) { |
---|
89 | GBDATA *gb_organism = NULp; |
---|
90 | GB_ERROR error = NULp; |
---|
91 | |
---|
92 | gen_assert(!old_species_marks); // old_species_marks may be out of date (better call EXP_get_(first|next)_experiment_data until it returns NULp!) |
---|
93 | exp_restore_old_species_marks(gb_main); |
---|
94 | |
---|
95 | switch (range) { |
---|
96 | case QUERY_CURRENT_ITEM: { |
---|
97 | char *species_name = aw_root->awar(AWAR_ORGANISM_NAME)->read_string(); |
---|
98 | gb_organism = GBT_find_species(gb_main, species_name); |
---|
99 | free(species_name); |
---|
100 | break; |
---|
101 | } |
---|
102 | case QUERY_MARKED_ITEMS: { |
---|
103 | GBDATA *gb_pseudo = GEN_first_marked_pseudo_species(gb_main); |
---|
104 | |
---|
105 | if (gb_pseudo) { // there are marked pseudo-species.. |
---|
106 | old_species_marks = GBT_store_marked_species(gb_main, true); // store and unmark marked species |
---|
107 | error = GBT_with_stored_species(gb_main, old_species_marks, GEN_mark_organism_or_corresponding_organism, NULp); // mark organisms related with stored |
---|
108 | |
---|
109 | if (!error) { |
---|
110 | gb_organism = GEN_first_marked_organism(gb_main); |
---|
111 | if (!gb_organism) exp_restore_old_species_marks(gb_main); // got all -> clean up |
---|
112 | } |
---|
113 | } |
---|
114 | else { |
---|
115 | gb_organism = GEN_first_marked_organism(gb_main); |
---|
116 | } |
---|
117 | break; |
---|
118 | } |
---|
119 | case QUERY_ALL_ITEMS: { |
---|
120 | gb_organism = GBT_first_species(gb_main); |
---|
121 | break; |
---|
122 | } |
---|
123 | default: { |
---|
124 | gen_assert(0); |
---|
125 | break; |
---|
126 | } |
---|
127 | } |
---|
128 | |
---|
129 | if (error) GB_export_error(error); |
---|
130 | return gb_organism ? EXP_get_experiment_data(gb_organism) : NULp; |
---|
131 | } |
---|
132 | |
---|
133 | static GBDATA *EXP_get_next_experiment_data(GBDATA *gb_experiment_data, QUERY_RANGE range) { |
---|
134 | GBDATA *gb_organism = NULp; |
---|
135 | switch (range) { |
---|
136 | case QUERY_CURRENT_ITEM: { |
---|
137 | break; |
---|
138 | } |
---|
139 | case QUERY_MARKED_ITEMS: { |
---|
140 | GBDATA *gb_last_species = GB_get_father(gb_experiment_data); |
---|
141 | gb_organism = GEN_next_marked_organism(gb_last_species); |
---|
142 | |
---|
143 | if (!gb_organism) exp_restore_old_species_marks(GB_get_root(gb_experiment_data)); // got all -> clean up |
---|
144 | break; |
---|
145 | } |
---|
146 | case QUERY_ALL_ITEMS: { |
---|
147 | GBDATA *gb_last_species = GB_get_father(gb_experiment_data); |
---|
148 | gb_organism = GBT_next_species(gb_last_species); |
---|
149 | break; |
---|
150 | } |
---|
151 | default: { |
---|
152 | gen_assert(0); |
---|
153 | break; |
---|
154 | } |
---|
155 | } |
---|
156 | |
---|
157 | return gb_organism ? EXP_get_experiment_data(gb_organism) : NULp; |
---|
158 | } |
---|
159 | |
---|
160 | static GBDATA *EXP_get_current_experiment(GBDATA *gb_main, AW_root *aw_root) { |
---|
161 | GBDATA *gb_organism = GEN_get_current_organism(gb_main); |
---|
162 | GBDATA *gb_experiment = NULp; |
---|
163 | |
---|
164 | if (gb_organism) { |
---|
165 | char *experiment_name = aw_root->awar(AWAR_EXPERIMENT_NAME)->read_string(); |
---|
166 | gb_experiment = EXP_find_experiment(gb_organism, experiment_name); |
---|
167 | free(experiment_name); |
---|
168 | } |
---|
169 | |
---|
170 | return gb_experiment; |
---|
171 | } |
---|
172 | |
---|
173 | static void add_selected_experiment_changed_cb(AW_root *aw_root, const RootCallback& cb) { |
---|
174 | aw_root->awar(AWAR_EXPERIMENT_NAME)->add_callback(cb); |
---|
175 | ORGANISM_get_selector().add_selection_changed_cb(aw_root, cb); |
---|
176 | } |
---|
177 | |
---|
178 | static GBDATA *first_experiment_in_range(GBDATA *gb_experiment_data, QUERY_RANGE range) { |
---|
179 | GBDATA *gb_first = NULp; |
---|
180 | switch (range) { |
---|
181 | case QUERY_ALL_ITEMS: gb_first = EXP_first_experiment_rel_exp_data(gb_experiment_data); break; |
---|
182 | case QUERY_MARKED_ITEMS: gb_first = GB_first_marked(gb_experiment_data, "experiment"); break; |
---|
183 | case QUERY_CURRENT_ITEM: gb_first = EXP_get_current_experiment(GB_get_root(gb_experiment_data), AW_root::SINGLETON); break; |
---|
184 | } |
---|
185 | return gb_first; |
---|
186 | } |
---|
187 | static GBDATA *next_experiment_in_range(GBDATA *gb_prev, QUERY_RANGE range) { |
---|
188 | GBDATA *gb_next = NULp; |
---|
189 | switch (range) { |
---|
190 | case QUERY_ALL_ITEMS: gb_next = EXP_next_experiment(gb_prev); break; |
---|
191 | case QUERY_MARKED_ITEMS: gb_next = GB_next_marked(gb_prev, "experiment"); break; |
---|
192 | case QUERY_CURRENT_ITEM: gb_next = NULp; break; |
---|
193 | } |
---|
194 | return gb_next; |
---|
195 | } |
---|
196 | |
---|
197 | static void refresh_displayed_experiments() {} // nothing todo here |
---|
198 | |
---|
199 | static struct MutableItemSelector EXP_item_selector = { // @@@ move to SL/ITEMS |
---|
200 | QUERY_ITEM_EXPERIMENTS, |
---|
201 | EXP_select_experiment, |
---|
202 | EXP_get_experiment_id, |
---|
203 | EXP_find_experiment_by_id, |
---|
204 | experiment_field_selection_list_update_cb, |
---|
205 | -1, // unknown |
---|
206 | CHANGE_KEY_PATH_EXPERIMENTS, |
---|
207 | "experiment", |
---|
208 | "experiments", |
---|
209 | "name", |
---|
210 | EXP_get_first_experiment_data, |
---|
211 | EXP_get_next_experiment_data, |
---|
212 | first_experiment_in_range, |
---|
213 | next_experiment_in_range, |
---|
214 | EXP_get_current_experiment, |
---|
215 | add_selected_experiment_changed_cb, |
---|
216 | &ORGANISM_get_selector(), GB_get_grandfather, |
---|
217 | refresh_displayed_experiments, |
---|
218 | }; |
---|
219 | |
---|
220 | ItemSelector& EXP_get_selector() { return EXP_item_selector; } |
---|
221 | |
---|
222 | static QUERY::DbQuery *GLOBAL_experiment_query = NULp; |
---|
223 | |
---|
224 | AW_window *EXP_create_experiment_query_window(AW_root *aw_root, GBDATA *gb_main) { // @@@ move to SL/DB_UI |
---|
225 | static AW_window_simple_menu *aws = NULp; |
---|
226 | if (!aws) { |
---|
227 | aws = new AW_window_simple_menu; |
---|
228 | aws->init(aw_root, "EXPERIMENT_QUERY", "Experiment SEARCH and QUERY"); |
---|
229 | aws->create_menu("More functions", "f"); |
---|
230 | aws->load_xfig("ad_query.fig"); |
---|
231 | |
---|
232 | QUERY::query_spec awtqs(EXP_get_selector()); |
---|
233 | |
---|
234 | awtqs.gb_main = gb_main; |
---|
235 | awtqs.species_name = AWAR_SPECIES_NAME; |
---|
236 | awtqs.tree_name = AWAR_TREE; |
---|
237 | awtqs.select_bit = GB_USERFLAG_QUERY; |
---|
238 | awtqs.use_menu = 1; |
---|
239 | awtqs.ere_pos_fig = "ere3"; |
---|
240 | awtqs.where_pos_fig = "where3"; |
---|
241 | awtqs.by_pos_fig = "by3"; |
---|
242 | awtqs.qbox_pos_fig = "qbox"; |
---|
243 | awtqs.key_pos_fig = NULp; |
---|
244 | awtqs.query_pos_fig = "content"; |
---|
245 | awtqs.result_pos_fig = "result"; |
---|
246 | awtqs.count_pos_fig = "count"; |
---|
247 | awtqs.do_query_pos_fig = "doquery"; |
---|
248 | awtqs.config_pos_fig = "doconfig"; |
---|
249 | awtqs.do_mark_pos_fig = "domark"; |
---|
250 | awtqs.do_unmark_pos_fig = "dounmark"; |
---|
251 | awtqs.do_delete_pos_fig = "dodelete"; |
---|
252 | awtqs.do_set_pos_fig = "doset"; |
---|
253 | awtqs.do_refresh_pos_fig = "dorefresh"; |
---|
254 | awtqs.open_parser_pos_fig = "openparser"; |
---|
255 | awtqs.popup_info_window = EXP_popup_experiment_window; |
---|
256 | |
---|
257 | QUERY::DbQuery *query = create_query_box(aws, &awtqs, "exp"); |
---|
258 | GLOBAL_experiment_query = query; |
---|
259 | |
---|
260 | aws->create_menu("More search", "s"); |
---|
261 | aws->insert_menu_topic("exp_search_equal_fields_within_db", "Search For Equal Fields and Mark Duplicates", "E", "search_duplicates.hlp", AWM_ALL, makeWindowCallback(QUERY::search_duplicated_field_content, query, false)); |
---|
262 | 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, makeWindowCallback(QUERY::search_duplicated_field_content, query, true)); |
---|
263 | |
---|
264 | aws->button_length(7); |
---|
265 | |
---|
266 | aws->at("close"); |
---|
267 | aws->callback(AW_POPDOWN); |
---|
268 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
269 | |
---|
270 | aws->at("help"); |
---|
271 | aws->callback(makeHelpCallback("experiment_search.hlp")); |
---|
272 | aws->create_button("HELP", "HELP", "H"); |
---|
273 | } |
---|
274 | return aws; |
---|
275 | } |
---|
276 | |
---|
277 | static void experiment_delete_cb(AW_window *aww, GBDATA *gb_main) { |
---|
278 | if (aw_ask_sure("experiment_delete", "Are you sure to delete the experiment")) { |
---|
279 | GB_transaction ta(gb_main); |
---|
280 | GBDATA *gb_experiment = EXP_get_current_experiment(gb_main, aww->get_root()); |
---|
281 | |
---|
282 | GB_ERROR error = gb_experiment ? GB_delete(gb_experiment) : "Please select a experiment first"; |
---|
283 | if (error) { |
---|
284 | error = ta.close(error); |
---|
285 | aw_message(error); |
---|
286 | } |
---|
287 | } |
---|
288 | } |
---|
289 | |
---|
290 | static GB_ERROR experiment_create_handler(const char *dest, GBDATA *gb_main) { |
---|
291 | GB_ERROR error = GB_begin_transaction(gb_main); |
---|
292 | |
---|
293 | if (!error) { |
---|
294 | AW_root *aw_root = AW_root::SINGLETON; |
---|
295 | GBDATA *gb_experiment_data = get_current_experiment_data(gb_main); |
---|
296 | |
---|
297 | if (!gb_experiment_data) error = "Please select an organism"; |
---|
298 | else { |
---|
299 | GBDATA *gb_dest = EXP_find_experiment_rel_exp_data(gb_experiment_data, dest); |
---|
300 | if (gb_dest) { |
---|
301 | error = GBS_global_string("Experiment '%s' already exists", dest); |
---|
302 | } |
---|
303 | else { |
---|
304 | gb_dest = EXP_find_or_create_experiment_rel_exp_data(gb_experiment_data, dest); |
---|
305 | if (!gb_dest) error = GB_await_error(); |
---|
306 | else aw_root->awar(AWAR_EXPERIMENT_NAME)->write_string(dest); |
---|
307 | } |
---|
308 | } |
---|
309 | } |
---|
310 | |
---|
311 | error = GB_end_transaction(gb_main, error); |
---|
312 | return error; |
---|
313 | } |
---|
314 | static GB_ERROR experiment_rename_handler(const char *dest, GBDATA *gb_main) { |
---|
315 | AW_root *awr = AW_root::SINGLETON; |
---|
316 | const char *source = awr->awar(AWAR_EXPERIMENT_NAME)->read_char_pntr(); |
---|
317 | GB_ERROR error = NULp; |
---|
318 | |
---|
319 | if (strcmp(source, dest) != 0) { |
---|
320 | error = GB_begin_transaction(gb_main); |
---|
321 | if (!error) { |
---|
322 | GBDATA *gb_experiment_data = get_current_experiment_data(gb_main); |
---|
323 | |
---|
324 | if (!gb_experiment_data) error = "Please select an organism"; |
---|
325 | else { |
---|
326 | GBDATA *gb_source = EXP_find_experiment_rel_exp_data(gb_experiment_data, source); |
---|
327 | GBDATA *gb_dest = EXP_find_experiment_rel_exp_data(gb_experiment_data, dest); |
---|
328 | |
---|
329 | if (!gb_source) error = "Please select an experiment"; |
---|
330 | else if (gb_dest) error = GB_export_errorf("Experiment '%s' already exists", dest); |
---|
331 | else { |
---|
332 | GBDATA *gb_name = GB_search(gb_source, "name", GB_STRING); |
---|
333 | if (!gb_name) error = GB_await_error(); |
---|
334 | else { |
---|
335 | error = GB_write_string(gb_name, dest); |
---|
336 | if (!error) awr->awar(AWAR_EXPERIMENT_NAME)->write_string(dest); |
---|
337 | } |
---|
338 | } |
---|
339 | } |
---|
340 | } |
---|
341 | error = GB_end_transaction(gb_main, error); |
---|
342 | } |
---|
343 | |
---|
344 | return error; |
---|
345 | } |
---|
346 | static GB_ERROR experiment_copy_handler(const char *dest, GBDATA *gb_main) { |
---|
347 | AW_root *awr = AW_root::SINGLETON; |
---|
348 | const char *source = awr->awar(AWAR_EXPERIMENT_NAME)->read_char_pntr(); |
---|
349 | GB_ERROR error = GB_begin_transaction(gb_main); |
---|
350 | |
---|
351 | if (!error) { |
---|
352 | GBDATA *gb_experiment_data = get_current_experiment_data(gb_main); |
---|
353 | |
---|
354 | if (!gb_experiment_data) error = "Please select an organism"; |
---|
355 | else { |
---|
356 | GBDATA *gb_source = EXP_find_experiment_rel_exp_data(gb_experiment_data, source); |
---|
357 | GBDATA *gb_dest = EXP_find_experiment_rel_exp_data(gb_experiment_data, dest); |
---|
358 | |
---|
359 | if (!gb_source) error = "Please select an experiment"; |
---|
360 | else if (gb_dest) error = GB_export_errorf("Experiment '%s' already exists", dest); |
---|
361 | else { |
---|
362 | gb_dest = GB_create_container(gb_experiment_data, "experiment"); |
---|
363 | if (!gb_dest) error = GB_await_error(); |
---|
364 | else error = GB_copy_dropProtectMarksAndTempstate(gb_dest, gb_source); |
---|
365 | |
---|
366 | if (!error) { |
---|
367 | error = GBT_write_string(gb_dest, "name", dest); |
---|
368 | if (!error) awr->awar(AWAR_EXPERIMENT_NAME)->write_string(dest); |
---|
369 | } |
---|
370 | } |
---|
371 | } |
---|
372 | } |
---|
373 | |
---|
374 | error = GB_end_transaction(gb_main, error); |
---|
375 | return error; |
---|
376 | } |
---|
377 | static void experiment_create_cb(AW_window *aww, GBDATA *gb_main) { |
---|
378 | ResultHandler handler = makeResultHandler(experiment_create_handler, gb_main); |
---|
379 | const char *source = aww->get_root()->awar(AWAR_EXPERIMENT_NAME)->read_char_pntr(); |
---|
380 | AWT_activate_prompt("Create experiment", "Enter name of new experiment:", source, "Create", handler); |
---|
381 | } |
---|
382 | static void experiment_rename_cb(AW_window *aww, GBDATA *gb_main) { |
---|
383 | ResultHandler handler = makeResultHandler(experiment_rename_handler, gb_main); |
---|
384 | const char *source = aww->get_root()->awar(AWAR_EXPERIMENT_NAME)->read_char_pntr(); |
---|
385 | AWT_activate_prompt("Rename experiment", "Enter new experiment name:", source, "Rename", handler); |
---|
386 | } |
---|
387 | static void experiment_copy_cb(AW_window *aww, GBDATA *gb_main) { |
---|
388 | ResultHandler handler = makeResultHandler(experiment_copy_handler, gb_main); |
---|
389 | const char *source = aww->get_root()->awar(AWAR_EXPERIMENT_NAME)->read_char_pntr(); |
---|
390 | AWT_activate_prompt("Copy experiment", "Enter name of new experiment:", source, "Copy", handler); |
---|
391 | } |
---|
392 | |
---|
393 | static void EXP_create_field_items(AW_window *aws, GBDATA *gb_main) { |
---|
394 | static BoundItemSel *bis = new BoundItemSel(gb_main, EXP_get_selector()); |
---|
395 | exp_assert(bis->gb_main == gb_main); |
---|
396 | |
---|
397 | aws->insert_menu_topic(aws->local_id("exp_reorder_fields"), "Reorder fields ...", "R", "spaf_reorder.hlp", AD_F_ALL, makeCreateWindowCallback(DBUI::create_fields_reorder_window, bis)); |
---|
398 | aws->insert_menu_topic(aws->local_id("exp_delete_field"), "Delete/Hide Field ...", "D", "spaf_delete.hlp", AD_F_ALL, makeCreateWindowCallback(DBUI::create_field_delete_window, bis)); |
---|
399 | aws->insert_menu_topic(aws->local_id("exp_create_field"), "Create fields ...", "C", "spaf_create.hlp", AD_F_ALL, makeCreateWindowCallback(DBUI::create_field_create_window, bis)); |
---|
400 | aws->sep______________(); |
---|
401 | 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)); |
---|
402 | aws->insert_menu_topic("exp_refresh_fields", "Refresh fields", "f", "scandb.hlp", AD_F_ALL, makeWindowCallback(experiment_field_selection_list_update_cb, gb_main)); |
---|
403 | } |
---|
404 | |
---|
405 | static AW_window *popup_new_experiment_window(AW_root *aw_root, GBDATA *gb_main, int detach_id); |
---|
406 | |
---|
407 | static void popup_detached_experiment_window(AW_window *aw_parent, const InfoWindow *infoWin) { |
---|
408 | const InfoWindow *reusable = InfoWindowRegistry::infowin.find_reusable_of_same_type_as(*infoWin); |
---|
409 | if (reusable) { |
---|
410 | reusable->reuse(); |
---|
411 | } |
---|
412 | else { // create a new window if none is reusable |
---|
413 | popup_new_experiment_window(aw_parent->get_root(), |
---|
414 | infoWin->get_gbmain(), |
---|
415 | InfoWindowRegistry::infowin.allocate_detach_id(*infoWin)); |
---|
416 | } |
---|
417 | } |
---|
418 | |
---|
419 | static AW_window *popup_new_experiment_window(AW_root *aw_root, GBDATA *gb_main, int detach_id) { // INFO_WINDOW_CREATOR |
---|
420 | AW_window_simple_menu *aws = new AW_window_simple_menu; |
---|
421 | const ItemSelector& itemType = EXP_get_selector(); |
---|
422 | |
---|
423 | DBUI::init_info_window(aw_root, aws, itemType, detach_id); |
---|
424 | aws->load_xfig("ad_spec.fig"); |
---|
425 | |
---|
426 | aws->button_length(8); |
---|
427 | |
---|
428 | aws->at("close"); |
---|
429 | aws->callback(AW_POPDOWN); |
---|
430 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
431 | |
---|
432 | aws->at("search"); |
---|
433 | aws->callback(makeCreateWindowCallback(EXP_create_experiment_query_window, gb_main)); |
---|
434 | aws->create_button("SEARCH", "SEARCH", "S", "+"); |
---|
435 | |
---|
436 | aws->at("help"); |
---|
437 | aws->callback(makeHelpCallback("experiment_info.hlp")); |
---|
438 | aws->create_button("HELP", "HELP", "H"); |
---|
439 | |
---|
440 | DbScanner *scanner = DbScanner::create(gb_main, |
---|
441 | InfoWindowRegistry::localize_scanner_id("experiment", detach_id), |
---|
442 | aws, "box", "field", "enable", DB_KEYVIEWER, "mark", itemType); |
---|
443 | |
---|
444 | const InfoWindow& infoWin = InfoWindowRegistry::infowin.registerInfoWindow(aws, scanner, detach_id); |
---|
445 | |
---|
446 | if (infoWin.is_maininfo()) { |
---|
447 | aws->create_menu("EXPERIMENT", "E", AD_F_ALL); |
---|
448 | aws->insert_menu_topic("experiment_delete", "Delete", "D", "spa_delete.hlp", AD_F_ALL, makeWindowCallback(experiment_delete_cb, gb_main)); |
---|
449 | aws->insert_menu_topic("experiment_rename", "Rename ...", "R", "spa_rename.hlp", AD_F_ALL, makeWindowCallback(experiment_rename_cb, gb_main)); |
---|
450 | aws->insert_menu_topic("experiment_copy", "Copy ...", "y", "spa_copy.hlp", AD_F_ALL, makeWindowCallback(experiment_copy_cb, gb_main)); |
---|
451 | aws->insert_menu_topic("experiment_create", "Create ...", "C", "spa_create.hlp", AD_F_ALL, makeWindowCallback(experiment_create_cb, gb_main)); |
---|
452 | } |
---|
453 | |
---|
454 | aws->create_menu("FIELDS", "F", AD_F_ALL); |
---|
455 | EXP_create_field_items(aws, gb_main); |
---|
456 | |
---|
457 | aws->at("detach"); |
---|
458 | infoWin.add_detach_area(popup_detached_experiment_window); |
---|
459 | |
---|
460 | aws->show(); |
---|
461 | infoWin.attach_selected_item(); |
---|
462 | |
---|
463 | return aws; |
---|
464 | } |
---|
465 | |
---|
466 | void EXP_popup_experiment_window(AW_root *aw_root, GBDATA *gb_main) { // @@@ move to SL/DB_UI |
---|
467 | static AW_window *aws = NULp; |
---|
468 | if (!aws) { |
---|
469 | aws = popup_new_experiment_window(aw_root, gb_main, InfoWindow::MAIN_WINDOW); |
---|
470 | } |
---|
471 | else { |
---|
472 | InfoWindowRegistry::reactivate(aws); |
---|
473 | } |
---|
474 | } |
---|