| 217 | } |
| 218 | |
| 219 | void TableFrame::DisplayPopupMenu( wxGridEvent& ev ) |
| 220 | { |
| 221 | wxMenu* optMenu = wxXmlResource::Get()->LoadMenu("ID_TABLE_VIEW_MENU_CONTEXT"); |
| 222 | |
| 223 | TableInterface* ti = table_base->GetTableInt(); |
| 224 | SetEncodingCheckmarks(optMenu, ti->GetFontEncoding()); |
| 225 | |
| 226 | popup_col = ev.GetCol(); |
| 227 | |
| 228 | // Set Group item |
| 229 | std::vector<int> sel_cols; |
| 230 | table_base->GetSelectedCols(sel_cols); |
| 231 | bool any_sel_time_variant = false; |
| 232 | for (int i=0; i<sel_cols.size(); i++) { |
| 233 | if (ti->IsColTimeVariant(sel_cols[i])) { |
| 234 | any_sel_time_variant = true; |
| 235 | break; |
| 236 | } |
| 237 | } |
| 238 | bool all_sel_compatible = false; |
| 239 | if (!any_sel_time_variant && sel_cols.size() > 1) { |
| 240 | // check for compatible types |
| 241 | all_sel_compatible = true; |
| 242 | for (int i=0; i<sel_cols.size(); ++i) { |
| 243 | if (!ti->IsColNumeric(sel_cols[i])) { |
| 244 | all_sel_compatible = false; |
| 245 | break; |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | // Set Rename item |
| 250 | wxString rename_str(_("Rename Variable")); |
| 251 | if (popup_col != -1) { |
| 252 | rename_str << " \"" << ti->GetColName(popup_col) << "\""; |
| 253 | } |
| 254 | wxMenuItem* rename_mu = optMenu->FindItem(XRCID("ID_TABLE_RENAME_VARIABLE")); |
| 255 | rename_mu->SetItemLabel(rename_str); |
| 256 | bool enable_rename = false; |
| 257 | if (popup_col!=-1) { |
| 258 | if (ti->IsColTimeVariant(popup_col)) { |
| 259 | enable_rename = true; |
| 260 | } else { |
| 261 | enable_rename = ti->PermitRenameSimpleCol(); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | rename_mu->Enable(enable_rename); |
| 266 | |
| 267 | // Set meta-data |
| 268 | std::map<wxString, wxString> meta_data = ti->GetMetaData(popup_col); |
| 269 | if (meta_data.empty() == false) { |
| 270 | wxMenu* imp = new wxMenu; |
| 271 | std::map<wxString, wxString>::iterator it; |
| 272 | for (it = meta_data.begin(); it != meta_data.end(); it++) { |
| 273 | wxString lbl = it->first + ": " + it->second; |
| 274 | imp->Append(XRCID(lbl), lbl); |
| 275 | } |
| 276 | optMenu->AppendSubMenu(imp, _("Meta-data")); |
nothing calls this directly
no test coverage detected