41 #include <wx/stattext.h>
42 #include <wx/statbox.h>
43 #include <wx/scrolwin.h>
44 #include <wx/textctrl.h>
45 #include <wx/filedlg.h>
46 #include <wx/radiobut.h>
47 #include <wx/listctrl.h>
86 : m_FieldType(field_type)
100 SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
101 wxPanel::Create( parent,
id, pos,
size, style );
106 GetSizer()->SetSizeHints(
this);
156 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
157 itemPanel1->SetSizer(itemBoxSizer2);
159 wxBoxSizer* itemBoxSizer4 =
new wxBoxSizer(wxHORIZONTAL);
160 itemBoxSizer2->Add(itemBoxSizer4, 0, wxGROW|wxALL, 0);
162 wxFlexGridSizer* itemFlexGridSizer5 =
new wxFlexGridSizer(0, 1, 0, 0);
163 itemBoxSizer4->Add(itemFlexGridSizer5, 0, wxGROW|wxALL, 0);
165 wxBoxSizer* itemBoxSizer6 =
new wxBoxSizer(wxHORIZONTAL);
166 itemFlexGridSizer5->Add(itemBoxSizer6, 0, wxGROW|wxALL, 0);
168 wxStaticText* itemStaticText7 =
new wxStaticText( itemPanel1, wxID_STATIC,
_(
"Table:"), wxDefaultPosition, wxDefaultSize, 0 );
169 itemBoxSizer6->Add(itemStaticText7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5);
172 itemBoxSizer6->Add(
m_Filename, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
174 wxBitmapButton* itemBitmapButton9 =
new wxBitmapButton( itemPanel1,
ID_APPLYSRCTBLBTMBTN, wxArtProvider::GetBitmap(
wxT(
"menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
175 itemBoxSizer6->Add(itemBitmapButton9, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5);
178 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxHORIZONTAL);
179 itemFlexGridSizer5->Add(itemBoxSizer1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0);
181 m_QualLabel =
new wxStaticText( itemPanel1, wxID_STATIC,
_(
"Qualifiers"), wxDefaultPosition, wxDefaultSize, 0 );
182 itemBoxSizer1->Add(
m_QualLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
184 itemBoxSizer1->Add(110, 5, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 0);
186 wxStaticText* itemStaticText5 =
new wxStaticText( itemPanel1, wxID_STATIC,
_(
"Column"), wxDefaultPosition, wxDefaultSize, 0 );
187 itemBoxSizer1->Add(itemStaticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
189 wxStaticText* itemStaticText8 =
new wxStaticText( itemPanel1, wxID_STATIC,
_(
"Match"), wxDefaultPosition, wxDefaultSize, 0 );
190 itemBoxSizer1->Add(itemStaticText8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM|wxTOP, 5);
192 wxHyperlinkCtrl* itemHyperlinkCtrl10 =
new wxHyperlinkCtrl( itemPanel1,
ID_APPLYSRCTBLADDQUAL,
_(
"Add qualifier"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
193 itemBoxSizer1->Add(itemHyperlinkCtrl10, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
194 itemHyperlinkCtrl10->SetForegroundColour(wxColour(128, 128, 128));
198 itemFlexGridSizer5->Add(
m_ScrolledWindow, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 2);
199 m_Sizer =
new wxFlexGridSizer(0, 2, 0, 0);
204 wxStaticBox* itemStaticBoxSizer2Static =
new wxStaticBox(itemPanel1,
wxID_ANY,
_(
"Delimiter"));
205 wxStaticBoxSizer* itemStaticBoxSizer2 =
new wxStaticBoxSizer(itemStaticBoxSizer2Static, wxVERTICAL);
206 itemBoxSizer4->Add(itemStaticBoxSizer2, 0, wxALIGN_TOP|wxLEFT|wxRIGHT|wxBOTTOM, 5);
210 itemStaticBoxSizer2->Add(
m_Tabdel, 0, wxALIGN_LEFT|wxALL, 5);
214 itemStaticBoxSizer2->Add(
m_Semidel, 0, wxALIGN_LEFT|wxALL, 5);
218 itemStaticBoxSizer2->Add(
m_Commadel, 0, wxALIGN_LEFT|wxALL, 5);
222 itemStaticBoxSizer2->Add(
m_Spacedel, 0, wxALIGN_LEFT|wxALL, 5);
224 wxBoxSizer* itemBoxSizer10 =
new wxBoxSizer(wxHORIZONTAL);
225 itemStaticBoxSizer2->Add(itemBoxSizer10, 0, wxALIGN_LEFT|wxALL, 0);
229 itemBoxSizer10->Add(
m_Otherdel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
232 itemBoxSizer10->Add(
m_OtherText, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
234 wxStaticBox* itemStaticBoxSizer1Static =
new wxStaticBox(itemPanel1,
wxID_ANY,
_(
"Options"));
235 wxStaticBoxSizer* itemStaticBoxSizer1 =
new wxStaticBoxSizer(itemStaticBoxSizer1Static, wxVERTICAL);
236 itemBoxSizer4->Add(itemStaticBoxSizer1, 0, wxALIGN_TOP|wxRIGHT|wxBOTTOM, 5);
238 m_MergeDel =
new wxCheckBox( itemPanel1,
ID_APPLYTBLCB1,
_(
"Merge adjacent delimiters"), wxDefaultPosition, wxDefaultSize, 0 );
240 itemStaticBoxSizer1->Add(
m_MergeDel, 0, wxALIGN_LEFT|wxALL, 5);
248 itemStaticBoxSizer1->Add(
m_ConvertMulti, 0, wxALIGN_LEFT|wxALL, 5);
252 itemStaticBoxSizer1->Add(
m_MergeTwoCols, 0, wxALIGN_LEFT|wxALL, 5);
273 m_Sizer->Add(
row, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
275 itemHyperLink->SetVisitedColour(itemHyperLink->GetNormalColour());
276 m_Sizer->Add(itemHyperLink, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 0);
324 bool found_match =
false;
325 for (
auto it = list.begin(); it != list.end(); ++it) {
328 if (
row->IsMatchingRow()) {
337 auto field =
row->m_FieldFirst->GetStringSelection();
338 auto col =
row->m_Column->GetValue();
339 if (!field.empty() && !col.empty())
350 while (
m_Sizer->GetItemCount() > 0) {
352 m_Sizer->GetItem(pos)->DeleteWindows();
357 for (
const auto& it : values) {
359 all_set = all_set &&
row->InsertField(get<0>(it), get<1>(it), get<2>(it), get<3>(it));
363 NcbiWarningBox(
"Some fieldnames could not be properly displayed");
373 for (
auto it = list.begin(); it != list.end(); ++it) {
375 if (
row &&
row->IsMatchingRow()) {
376 return row->GetField();
422 wxFileDialog dlg(
this,
wxT(
"Select table file"), wxEmptyString, wxEmptyString,
_(
"All files (*.*)|*.*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
424 if (dlg.ShowModal() == wxID_OK) {
464 if (line_reader.
Empty()) {
477 vector<pair<string, int>> fields;
478 unsigned int nr_line = 0;
485 while (!line_reader->
AtEOF() && nr_line < 30) {
501 cols[0] = cols[0] +
"/" + cols[1];
502 cols.erase(cols.begin() + 1);
506 string first, second;
509 cols.insert(cols.begin() + 1, second);
514 nr_cols = cols.size();
516 for (
size_t i = 0;
i < cols.size(); ++
i) {
517 fields.emplace_back(cols[
i],
i + 1);
522 for (
size_t index = 1; index < nr_cols; ++index) {
523 if (index < cols.size())
530 for (
int index = 0; index <
m_TablePreview->GetColumnCount(); ++index) {
534 if (!update_only_table) {
536 while (
m_Sizer->GetItemCount() > 0) {
538 m_Sizer->GetItem(pos)->DeleteWindows();
542 for (
auto& it : fields) {
544 if (it.first ==
"organism") it.first =
"taxname";
545 row->SetField(it.first, it.second);
555 if (event.GetURL() !=
wxT(
"delete")) {
560 wxWindow *win =
dynamic_cast<wxWindow*
>(
event.GetEventObject());
564 wxWindow*
prev =
nullptr;
565 for (wxWindowList::iterator child = children.begin(); child != children.end(); ++child) {
567 wxSizer *sizer = win->GetContainingSizer();
EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX, CAdjustFeaturesForGaps::OnKnownUnknownSelected) EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX1
CMacroApplySrcTablePanel()
Constructors.
void x_AddRowToWindow(wxWindow *row)
SFieldFromTable GetMatchField() const
string GetDelimiter() const
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxScrolledWindow * m_ScrolledWindow
void OnOpenFile(wxCommandEvent &event)
wxBitmap GetBitmapResource(const wxString &name)
@end CMacroApplySrcTablePanel event handler declarations
wxCheckBox * m_MergeTwoCols
bool Create(wxWindow *parent, wxWindowID id=ID_CMACROAPPLYSRCTABLEPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Creation.
void Init()
Initialises member variables.
TStringPairsVector GetValues() const
vector< tuple< string, int, EMacroFieldType, bool > > TAddValue
void SetDelimiter(const string &del)
wxListCtrl * m_TablePreview
wxRadioButton * m_Spacedel
wxFlexGridSizer * m_Sizer
CSingleQualPanel * x_AddEmptyRow()
void OnHyperlinkClicked(wxHyperlinkEvent &event)
string GetFilename() const
wxRadioButton * m_Otherdel
static bool ShowToolTips()
Should we show tooltips?
void SetFilename(const string &fname)
wxRadioButton * m_Semidel
wxRadioButton * m_Commadel
void SetValues(const TAddValue &values)
~CMacroApplySrcTablePanel()
Destructor.
wxStaticText * m_QualLabel
void x_ProcessFirstLine(bool update_only_table=false)
void CreateControls()
Creates the controls and sizers.
void OnNewFileEntered(wxCommandEvent &event)
wxCheckBox * m_SplitFirstCol
wxCheckBox * m_ConvertMulti
void OnDelete(wxHyperlinkEvent &event)
void OnDelimiterSelected(wxCommandEvent &event)
EMacroFieldType m_FieldType
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
void ConvertMultiSpaces(string &line, const string &delimiter)
replace any instance of 2 or more spaces with a single instance of 'delimiter'
void NcbiWarningBox(const string &message, const string &title="Warning")
specialized Message Box function for reporting non-critical errors
CTempString GetCurrentLine(void) const
static CRef< ILineReader > New(const string &filename)
Return a new ILineReader object corresponding to the given filename, taking "-" (but not "....
virtual bool AtEOF(void) const =0
Indicates (negatively) whether there is any more input.
void Reset(void)
Reset reference object.
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static list< string > & SplitByPattern(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Variation of Split() with fSplit_ByPattern flag applied by default.
vector< pair< string, string > > TStringPairsVector
int TSplitFlags
Bitwise OR of ESplitFlags.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
Lightweight interface for getting lines of data with minimal memory copying.
const struct ncbi::grid::netcache::search::fields::SIZE size
static const char delimiter[]
#define row(bind, expected)
wxString GetAbsolutePath(const wxString &localpath)
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)