(parent,
id, caption, pos,
size, style);
110 bool CEditMacroDlg::Create( wxWindow* parent, wxWindowID
id,
constwxString& caption,
constwxPoint& pos,
constwxSize&
size,
longstyle )
113SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
114CDialog::Create( parent,
id, caption, pos,
size, style );
119GetSizer()->SetSizeHints(
this);
160wxBoxSizer* bs_vertical =
newwxBoxSizer(wxVERTICAL);
161SetSizer(bs_vertical);
163wxBoxSizer* bs_hor_top =
newwxBoxSizer(wxHORIZONTAL);
164wxBoxSizer* bs_hor_bottom =
newwxBoxSizer(wxHORIZONTAL);
166bs_vertical->Add(bs_hor_top, 1, wxEXPAND | wxALL, 5);
169wxArrayString wxMacrolist;
170 m_MacroList=
newwxListBox(
this,
ID_LISTBOX, wxDefaultPosition, wxSize(-1, 250), wxMacrolist, wxLB_SINGLE );
171bs_hor_top->Add(
m_MacroList, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxALL, 5);
173 m_TextCtrl=
newwxTextCtrl(
this,
ID_TEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 250), wxTE_MULTILINE );
174bs_hor_top->Add(
m_TextCtrl, 1, wxEXPAND | wxALL, 5);
176wxBoxSizer* syn_sizer =
newwxBoxSizer(wxHORIZONTAL);
177bs_vertical->Add(syn_sizer, 0, wxEXPAND | wxALL, 0);
179wxStaticText* syn_text =
newwxStaticText(
this, wxID_STATIC,
_(
"Synonym file:"), wxDefaultPosition, wxDefaultSize, 0);
180syn_sizer->Add(syn_text, 0, wxALIGN_LEFT | wxALL, 5);
182 m_SynFile=
newwxTextCtrl(
this,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(270, -1));
183syn_sizer->Add(
m_SynFile, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
185wxButton* itemButton12 =
newwxBitmapButton(
this,
ID_LOADSYNFILE, wxArtProvider::GetBitmap(
wxT(
"menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW);
186syn_sizer->Add(itemButton12, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
189wxButton* itemButton13 =
newwxButton(
this,
wxID_ANY,
_(
"Update macro with new syn file"), wxDefaultPosition, wxDefaultSize, 0);
190syn_sizer->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
193wxButton* itemButton14 =
newwxButton(
this,
wxID_ANY,
_(
"Store synonyms from file"), wxDefaultPosition, wxDefaultSize, 0);
194itemButton14->SetToolTip(
"Store synonyms from selected file before executing the macro");
195syn_sizer->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
198bs_vertical->Add(bs_hor_bottom, 0, wxEXPAND | wxALL, 5);
201wxButton* Autofix_GB =
newwxButton(
this,
ID_AUTOFIXGB,
_(
"Autofix(GB)"), wxDefaultPosition, wxDefaultSize, 0);
202bs_hor_bottom->Add(Autofix_GB, 0, wxALIGN_LEFT | wxALL, 5);
204wxButton* Autofix_TSA =
newwxButton(
this,
ID_AUTOFIXTSA,
_(
"Autofix(TSA)"), wxDefaultPosition, wxDefaultSize, 0);
205bs_hor_bottom->Add(Autofix_TSA, 0, wxALIGN_LEFT | wxALL, 5);
207wxButton* Autofix_WGS =
newwxButton(
this,
ID_AUTOFIXWGS,
_(
"Autofix(WGS)"), wxDefaultPosition, wxDefaultSize, 0);
208bs_hor_bottom->Add(Autofix_WGS, 0, wxALIGN_LEFT | wxALL, 5);
210wxButton* Other =
newwxButton(
this,
ID_OTHERMACROS,
_(
"Other Macros"), wxDefaultPosition, wxDefaultSize, 0);
211bs_hor_bottom->Add(Other, 0, wxALIGN_LEFT | wxALL, 5);
213bs_hor_bottom->AddStretchSpacer();
215wxButton* RunButton =
newwxButton(
this,
ID_RUN,
_(
"Run"), wxDefaultPosition, wxDefaultSize, 0 );
216bs_hor_bottom->Add(RunButton, 0, wxALL, 5);
218wxButton* PrintButton =
newwxButton(
this,
ID_PRINT,
_(
"Print"), wxDefaultPosition, wxDefaultSize, 0);
219bs_hor_bottom->Add(PrintButton, 0, wxALL, 5);
221wxButton* PrintParallelButton =
newwxButton(
this,
ID_PRINTPARALLEL,
_(
"Parallel_Print"), wxDefaultPosition, wxDefaultSize, 0);
222bs_hor_bottom->Add(PrintParallelButton, 0, wxALL, 5);
224wxButton* CloseButton =
newwxButton(
this, wxID_CANCEL,
_(
"Close"), wxDefaultPosition, wxDefaultSize, 0 );
225bs_hor_bottom->Add(CloseButton, 0, wxALL, 5);
274wxFileDialog file_dlg(
this,
_(
"Select Synonym File"), wxEmptyString, wxEmptyString,
_(
"All files (*.*)|*.*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
275 if(file_dlg.ShowModal() == wxID_OK) {
284 boolmodified =
false;
287 while(pos != string::npos) {
288 size_tright_end = pos + search.length();
289 if(pos > 0 &&
str.c_str()[pos - 1] ==
'"'&&
str.data()[right_end] ==
'"') {
290 stringthis_replace = replace;
291 str=
str.substr(0, pos) + this_replace +
str.substr(right_end);
292right_end = pos + this_replace.length();
313vector<CRef<CMacroRep>> macros = { macro_rep };
316 if(syn_files.empty()) {
317 NcbiInfoBox(
"No synonym file is found in the macro");
321 if(syn_files.size() > 1) {
322 string msg=
"Multiple synonym files are found:";
323 for(
const auto& it : syn_files) {
331 for(
const auto& syn_it : syn_files) {
343 if(syn_file.empty()) {
350 NcbiInfoBox(
"Synonym file was successfully stored");
373 boolbResolved =
true;
384macro_engine.
Exec(*macro_rep, bio_data,
cmd,
true);
391 if(!report.GetLog().empty()) {
392 log<< report.GetName() <<
":\n"<< report.GetLog() <<
"\n";
395 const auto& logs = macro_stat.GetFunctionsLog();
397 log<< report.GetName() <<
":\n";
399 for(
const auto& it : logs) {
400 log<< it->Print() <<
"\n";
404 if(!report.GetErrorLog().empty()) {
405 log<<
"\nERRORS:\n"<< report.GetErrorLog();
408 const auto& unmatched_entries = macro_stat.GetUnmatchedTableEntries();
409 if(!unmatched_entries.empty()) {
410 log<<
"\nUnmatched entries:\n";
411 log<< unmatched_entries.front().first;
414 string msg(
"Execution succeeded\n");
417 msg.append(
"Macro had no effect.");
430 string msg=
"Execution of macro "+ macro_rep->
GetName() +
" has failed:";
434errorDlg.ShowModal();
446wxFileDialog dlg(
this,
wxT(
"Save CSV file"), wxEmptyString, wxEmptyString,
448wxFD_SAVE |wxFD_OVERWRITE_PROMPT);
450 if(dlg.ShowModal() != wxID_OK)
453unique_ptr<CNcbiOstream> ostr;
454wxString path = dlg.GetPath();
455 if(!path.IsEmpty()) {
468 autostart = chrono::steady_clock::now();
480macro_engine.
Exec(*macro_rep, bio_data,
cmd,
true, ostr.get());
484 autostop = chrono::steady_clock::now();
485chrono::duration<double> elapsed = stop - start;
486 LOG_POST(
Info<<
"Time to execute macro (normal): "<< elapsed.count());
496 string msg=
"Execution of macro "+ macro_rep->
GetName() +
" has failed:";
500errorDlg.ShowModal();
506wxFileDialog dlg(
this,
wxT(
"Select file"), wxEmptyString, wxEmptyString,
508wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
510 if(dlg.ShowModal() != wxID_OK)
513unique_ptr<CNcbiOstream> ostr;
514wxString path = dlg.GetPath();
515 if(!path.IsEmpty()) {
528 autostart = chrono::steady_clock::now();
540macro_engine.
Exec(*macro_rep, bio_data,
cmd,
true, ostr.get());
544 autostop = chrono::steady_clock::now();
545chrono::duration<double> elapsed = stop - start;
546 LOG_POST(
Info<<
"Time to parallel execute macro: "<< elapsed.count());
555 string msg=
"Execution of macro "+ macro_rep->
GetName() +
" has failed:";
559errorDlg.ShowModal();
virtual void SetRegistryPath(const string &path)
void LoadAutofix_WGS(wxCommandEvent &event)
void OnPrintParallelClick(wxCommandEvent &event)
void x_LoadAutofixMacro(const string &name)
ICommandProccessor * m_CmdProccessor
static bool ShowToolTips()
Should we show tooltips?
vector< string > m_Macros
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void StoreSynonyms(wxCommandEvent &event)
void CreateControls()
Creates the controls and sizers.
CEditMacroDlg()
Constructors.
~CEditMacroDlg()
Destructor.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void Init()
Initialises member variables.
CConstRef< objects::CSeq_submit > m_SeqSubmit
void LoadAutofix_GB(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=ID_CEDITMACRODLG, const wxString &caption=_("Run Macro"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
void OnRunClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
void LoadOtherMacros(wxCommandEvent &event)
void LoadAutofix_TSA(wxCommandEvent &event)
void OpenSynonymFile(wxCommandEvent &event)
void UpdateMacroWithSynFile(wxCommandEvent &event)
void OnListItemSelected(wxCommandEvent &event)
objects::CSeq_entry_Handle m_TopSeqEntry
void OnPrintClick(wxCommandEvent &event)
static wxString GetDialogFilter(EFileType fileType)
The following asn-selectors are defined to be used in the FOR EACH statement:
implements special composite command, which does not call to its internal commands when run the very ...
void SetException(const string &message, const CException &error)
Class for parsed macro representation.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
static bool s_ReplaceInPlaceBetweenQuotes(string &str, const string &search, const string &replace)
std::ofstream out("events_result.xml")
main entry point for tests
static const char * str(char *buf, int n)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
string ReportAll(TDiagPostFlags flags=eDPF_Exception) const
Report all exceptions.
void Info(CExceptionArgs_Base &args)
bool GetStatus() const
Get status of most recent command.
bool StoreSynonymList(const string &filename)
Function builds a map of words and their corresponding synonyms.
bool Exec(const CMacroRep ¯o_rep, const CMacroBioData &data, CRef< CMacroCmdComposite > CmdComposite, bool throw_on_error=false, CNcbiOstream *ostream=nullptr)
Execute a macro.
const string & GetName() const
Return macro name.
const string & GetParsingErrorMessage() const
Get error message in case previous command was unsuccessful.
const CMacroStat & GetStatistics() const
Gets the most recently executed macro statistics.
bool AreThereGUIResolvableVars() const
Return true if there are any GUI variables.
CMacroRep * GetMacroRep(const string ¯o_name) const
Function gets the macro representation to let the gui resolve "ask" and "choice" variables.
CMacroRep * Parse(const string ¯o_text)
Parse the macro script into its binary representation.
bool GetParsingStatus() const
Get status of most recent command.
static CMacroLib & GetInstance()
const CMacroLog & GetMacroReport() const
void GetMacroNames(vector< string > ¯o_names) const
Function builds a list of macro names in the library to use for example in the toolbar.
const string & GetErrorMessage() const
Get error message in case previous command was unsuccessful.
vector< string > GetSynonymFilenames(const vector< CRef< CMacroRep >> ¯o_list) const
Extracts synonym files present in the list of macros.
bool Exec(const CMacroRep ¯o_rep, const CMacroBioData &data, CRef< CMacroCmdComposite > CmdComposite, bool throw_on_error=false, CNcbiOstream *ostream=nullptr)
Executes a macro.
const string & GetSource() const
CMacroRep * Parse(const string ¯o_text)
Parses macro script into its binary representation.
EDialogReturnValue NcbiInfoBox(const string &message, const string &title="Info")
specialized Message Box function for reporting general information messages
void NcbiWarningBox(const string &message, const string &title="Warning")
specialized Message Box function for reporting non-critical errors
EDialogReturnValue NcbiMessageBox(const string &message, TDialogType type=eDialog_Ok, EDialogIcon icon=eIcon_Exclamation, const string &title="Error", EDialogTextMode text_mode=eRaw)
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
EDialogReturnValue
enumerated return values for dialog boxes, starting from 1 to undermine attempts to cast it "bool"
Lightweight interface for getting lines of data with minimal memory copying.
Macro library for storing parsed macros.
const struct ncbi::grid::netcache::search::fields::SIZE size
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
wxString GetAbsolutePath(const wxString &localpath)
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4