| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : NT_cb.cxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #include "NT_local.h" |
|---|
| 12 | #include "NT_cb.h" |
|---|
| 13 | #include "ad_trees.h" |
|---|
| 14 | |
|---|
| 15 | #include <awt_canvas.hxx> |
|---|
| 16 | #include <awt_sel_boxes.hxx> |
|---|
| 17 | #include <aw_awars.hxx> |
|---|
| 18 | #include <aw_root.hxx> |
|---|
| 19 | #include <aw_question.hxx> |
|---|
| 20 | #include <aw_msg.hxx> |
|---|
| 21 | #include <arbdbt.h> |
|---|
| 22 | |
|---|
| 23 | #include <map> |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | // AISC_MKPT_PROMOTE:#ifndef ARBDB_BASE_H |
|---|
| 27 | // AISC_MKPT_PROMOTE:#include <arbdb_base.h> |
|---|
| 28 | // AISC_MKPT_PROMOTE:#endif |
|---|
| 29 | // AISC_MKPT_PROMOTE:#ifndef AW_BASE_HXX |
|---|
| 30 | // AISC_MKPT_PROMOTE:#include <aw_base.hxx> |
|---|
| 31 | // AISC_MKPT_PROMOTE:#endif |
|---|
| 32 | // AISC_MKPT_PROMOTE:class AWT_canvas; |
|---|
| 33 | |
|---|
| 34 | #define AWT_TREE(ntw) DOWNCAST(AWT_graphic_tree *, (ntw)->tree_disp) |
|---|
| 35 | |
|---|
| 36 | void NT_delete_mark_all_cb(void *, AWT_canvas *ntw) { |
|---|
| 37 | if (aw_ask_sure("delete_marked_species", |
|---|
| 38 | "Are you sure to delete species ??\n" |
|---|
| 39 | "This will destroy primary data !!!")) |
|---|
| 40 | { |
|---|
| 41 | { |
|---|
| 42 | GB_ERROR error = 0; |
|---|
| 43 | GB_transaction ta(ntw->gb_main); |
|---|
| 44 | |
|---|
| 45 | GBDATA *gb_species, *gb_next; |
|---|
| 46 | for (gb_species = GBT_first_marked_species(ntw->gb_main); |
|---|
| 47 | gb_species && !error; |
|---|
| 48 | gb_species = gb_next) |
|---|
| 49 | { |
|---|
| 50 | gb_next = GBT_next_marked_species(gb_species); |
|---|
| 51 | error = GB_delete(gb_species); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | if (error) { |
|---|
| 55 | error = ta.close(error); |
|---|
| 56 | aw_message(error); |
|---|
| 57 | } |
|---|
| 58 | } |
|---|
| 59 | ntw->refresh(); |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | AW_window *NT_create_select_tree_window(AW_root *awr, const char *awar_tree) { |
|---|
| 65 | static std::map<std::string,AW_window*> tree_select_windows; |
|---|
| 66 | if (tree_select_windows.find(awar_tree) == tree_select_windows.end()) { |
|---|
| 67 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 68 | |
|---|
| 69 | const char *id = strrchr(awar_tree, '/'); |
|---|
| 70 | nt_assert(id); |
|---|
| 71 | id++; // use name-part of awar_tree as id (results in 'SELECT_tree_name', 'SELECT_tree_name_1', ...) |
|---|
| 72 | |
|---|
| 73 | aws->init(awr, GBS_global_string("SELECT_%s", id), "SELECT A TREE"); |
|---|
| 74 | aws->load_xfig("select_simple.fig"); |
|---|
| 75 | |
|---|
| 76 | aws->at("selection"); |
|---|
| 77 | awt_create_selection_list_on_trees(GLOBAL.gb_main, aws, awar_tree, true); |
|---|
| 78 | |
|---|
| 79 | aws->auto_space(5, 5); |
|---|
| 80 | aws->button_length(6); |
|---|
| 81 | |
|---|
| 82 | aws->at("button"); |
|---|
| 83 | aws->callback(AW_POPDOWN); |
|---|
| 84 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 85 | |
|---|
| 86 | aws->callback(popup_tree_admin_window); |
|---|
| 87 | aws->help_text("treeadm.hlp"); |
|---|
| 88 | aws->create_button("MODIFY", "ADMIN", "A"); |
|---|
| 89 | |
|---|
| 90 | tree_select_windows[awar_tree] = aws; |
|---|
| 91 | } |
|---|
| 92 | return tree_select_windows[awar_tree]; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | void NT_select_bottom_tree(AW_window *aww, const char *awar_tree) { |
|---|
| 96 | GB_transaction ta(GLOBAL.gb_main); |
|---|
| 97 | const char *ltree = GBT_name_of_bottom_tree(GLOBAL.gb_main); |
|---|
| 98 | if (ltree) aww->get_root()->awar(awar_tree)->write_string(ltree); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | AW_window *NT_create_select_alignment_window(AW_root *awr) |
|---|
| 102 | { |
|---|
| 103 | static AW_window_simple *aws = 0; |
|---|
| 104 | if (!aws) { |
|---|
| 105 | aws = new AW_window_simple; |
|---|
| 106 | |
|---|
| 107 | aws->init(awr, "SELECT_ALIGNMENT", "SELECT AN ALIGNMENT"); |
|---|
| 108 | aws->load_xfig("select_simple.fig"); |
|---|
| 109 | |
|---|
| 110 | aws->at("selection"); |
|---|
| 111 | aws->callback((AW_CB0)AW_POPDOWN); |
|---|
| 112 | awt_create_selection_list_on_alignments(GLOBAL.gb_main, (AW_window *)aws, AWAR_DEFAULT_ALIGNMENT, "*="); |
|---|
| 113 | |
|---|
| 114 | aws->auto_space(5, 5); |
|---|
| 115 | aws->button_length(6); |
|---|
| 116 | |
|---|
| 117 | aws->at("button"); |
|---|
| 118 | aws->callback(AW_POPDOWN); |
|---|
| 119 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 120 | |
|---|
| 121 | aws->callback(makeCreateWindowCallback(NT_create_alignment_window, static_cast<AW_window*>(aws))); |
|---|
| 122 | aws->help_text("ad_align.hlp"); |
|---|
| 123 | aws->create_button("MODIFY", "ADMIN", "A"); |
|---|
| 124 | |
|---|
| 125 | aws->window_fit(); |
|---|
| 126 | } |
|---|
| 127 | return aws; |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | void NT_system_cb(AW_window *aww, AW_CL cl_command, AW_CL cl_auto_help_file) { |
|---|
| 131 | AW_system(aww, (const char *)cl_command, (const char *)cl_auto_help_file); |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | void NT_system_in_xterm_cb(AW_window *aww, AW_CL cl_command, AW_CL cl_auto_help_file) { |
|---|
| 135 | char *command = (char *)cl_command; |
|---|
| 136 | const char *autohelpfile = (const char *)cl_auto_help_file; |
|---|
| 137 | if (autohelpfile) AW_help_popup(aww, autohelpfile); |
|---|
| 138 | |
|---|
| 139 | GB_ERROR error = GB_xcmd(command, true, true); |
|---|
| 140 | if (error) aw_message(error); |
|---|
| 141 | } |
|---|