39 #include <wx/stattext.h>
40 #include <wx/statline.h>
41 #include <wx/listbook.h>
42 #include <wx/checkbox.h>
43 #include <wx/checklst.h>
45 #include <wx/textctrl.h>
46 #include <wx/button.h>
47 #include <wx/bmpbuttn.h>
48 #include <wx/filedlg.h>
49 #include <wx/wupdlock.h>
50 #include <wx/artprov.h>
80 : m_SynonymFile(syn_filename)
89 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
90 wxFrame::Create( parent,
id, caption, pos,
size, style );
95 GetSizer()->SetSizeHints(
this);
97 Centre(wxBOTH|wxCENTRE_ON_SCREEN);
120 wxBoxSizer* itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
121 SetSizer(itemBoxSizer1);
123 wxPanel* itemCBulkCmdDlg1 =
new wxPanel(
this,
wxID_ANY);
124 itemBoxSizer1->Add(itemCBulkCmdDlg1, 1, wxGROW, 0);
126 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
127 itemCBulkCmdDlg1->SetSizer(itemBoxSizer2);
129 wxFlexGridSizer* itemFlexGridSizer3 =
new wxFlexGridSizer(0, 2, 0, 0);
130 itemBoxSizer2->Add(itemFlexGridSizer3, 1, wxGROW | wxALL, 0);
132 wxStaticText* itemStaticText31 =
new wxStaticText(itemCBulkCmdDlg1, wxID_STATIC,
_(
"Substitution File"), wxDefaultPosition, wxDefaultSize, 0);
133 itemFlexGridSizer3->Add(itemStaticText31, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 3);
135 itemFlexGridSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 0);
138 itemFlexGridSizer3->Add(
m_SynFile, 1, wxEXPAND | wxALL, 5);
140 wxButton* itemButton32 =
new wxBitmapButton(itemCBulkCmdDlg1,
ID_OPENSYNFILEBTN, wxArtProvider::GetBitmap(
wxT(
"menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW);
141 itemButton32->SetToolTip(
wxT(
"Choose a substitution file..."));
142 itemFlexGridSizer3->Add(itemButton32, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 3);
144 wxStaticText* itemStaticText5 =
new wxStaticText( itemCBulkCmdDlg1, wxID_STATIC,
_(
"Pattern Word"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
145 itemFlexGridSizer3->Add(itemStaticText5, 0, wxALIGN_LEFT| wxALIGN_CENTER_VERTICAL | wxALL, 3);
147 itemFlexGridSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 0);
149 m_Pattern =
new wxTextCtrl(itemCBulkCmdDlg1,
ID_MACROPATTERN, wxEmptyString, wxDefaultPosition, wxSize(380, -1), 0);
150 itemFlexGridSizer3->Add(
m_Pattern, 1, wxGROW | wxALL, 5);
152 itemFlexGridSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 0);
154 wxStaticText* itemStaticText51 =
new wxStaticText(itemCBulkCmdDlg1, wxID_STATIC,
_(
"Substitution List"), wxDefaultPosition, wxDefaultSize, 0);
155 itemFlexGridSizer3->Add(itemStaticText51, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 3);
157 itemFlexGridSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 0);
159 wxBoxSizer* itemBoxSizer12 =
new wxBoxSizer(wxVERTICAL);
160 itemFlexGridSizer3->Add(itemBoxSizer12, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 0);
162 m_Subst =
new wxTextCtrl( itemCBulkCmdDlg1,
wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(250, 90), wxTE_MULTILINE );
163 itemBoxSizer12->Add(
m_Subst, 0, wxGROW|wxALL, 5);
165 wxBoxSizer* itemBoxSizer14 =
new wxBoxSizer(wxHORIZONTAL);
166 itemBoxSizer12->Add(itemBoxSizer14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
168 m_IgnoreCase =
new wxCheckBox( itemCBulkCmdDlg1,
wxID_ANY,
_(
"Ignore Case"), wxDefaultPosition, wxDefaultSize, 0 );
170 itemBoxSizer14->Add(
m_IgnoreCase, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
172 m_WholeWord =
new wxCheckBox( itemCBulkCmdDlg1,
wxID_ANY,
_(
"Whole Word"), wxDefaultPosition, wxDefaultSize, 0 );
174 itemBoxSizer14->Add(
m_WholeWord, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
176 wxButton* clearbtn =
new wxButton(itemCBulkCmdDlg1,
ID_CLEARLIST,
_(
"Clear List"), wxDefaultPosition, wxDefaultSize, 0);
177 itemBoxSizer14->Add(clearbtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
179 wxBoxSizer* itemBoxSizer17 =
new wxBoxSizer(wxHORIZONTAL);
180 itemBoxSizer2->Add(itemBoxSizer17, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
182 wxButton* itemButton13 =
new wxButton(itemCBulkCmdDlg1,
ID_MACROWORDSUBST_ADD,
_(
"Add Word Substitution"), wxDefaultPosition, wxDefaultSize, 0);
183 itemBoxSizer17->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
185 wxButton* itemButton18 =
new wxButton(itemCBulkCmdDlg1,
ID_MACROWORDSUBST_DELETEWORD,
_(
"Remove Word from File"), wxDefaultPosition, wxDefaultSize, 0);
186 itemButton18->SetToolTip(
"Removes the selected word pattern only upon clicking Accept");
187 itemBoxSizer17->Add(itemButton18, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
192 wxButton* itemButton14 =
new wxButton( itemCBulkCmdDlg1,
ID_MACROWORDSUBST_REMOVE,
_(
"Remove Word Substitution"), wxDefaultPosition, wxDefaultSize, 0 );
193 itemBoxSizer2->Add(itemButton14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
195 wxBoxSizer* itemBoxSizer3 =
new wxBoxSizer(wxHORIZONTAL);
196 itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL, 0);
198 wxButton* itemButton15 =
new wxButton( itemCBulkCmdDlg1, wxID_OK,
_(
"Accept"), wxDefaultPosition, wxDefaultSize, 0 );
199 itemBoxSizer3->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
201 wxButton* itemButton16 =
new wxButton( itemCBulkCmdDlg1, wxID_CANCEL,
_(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
202 itemBoxSizer3->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
205 wxWindow* w = this->GetParent();
219 macro::CMacroLib::GetInstance().StoreSynonymList(
m_SynonymFile);
227 if (subst_list && subst_list->
IsSet()) {
228 for (
const auto& ws : subst_list->
Get()) {
270 wxFileDialog file_dlg(
this,
_(
"Select Substitution File"), wxEmptyString, wxEmptyString,
_(
"All files (*.*)|*.*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
271 if (file_dlg.ShowModal() == wxID_OK) {
277 if (!
NStr::EndsWith(filename,
"/synonyms.txt") && filename !=
"synonyms.txt") {
278 macro::CMacroLib::GetInstance().StoreSynonymList(filename);
298 for (
const auto& word_it : it->second) {
317 event.Enable(empty_constr || (!empty_constr && !syn_file.empty() && syn_file !=
"synonyms.txt"));
325 word_subst->
Set().push_back(ws);
330 wxWindow* parent = GetParent();
356 if (wxFileExists(path)) {
357 if (!wxRemoveFile(path)) {
367 ostr <<
"word: " << it.first << endl;
368 for (
const auto& syn_it : it.second) {
369 ostr << syn_it << endl;
391 ws->SetWord(pattern);
393 vector<string> lines;
396 for (
auto& l : lines) {
400 ws->SetSynonyms().push_back(
str);
407 if (!
label.empty()) {
426 m_Id =
event.GetInt();
433 for (
const auto& it : ws->GetSynonyms()) {
446 wxArrayInt checked_items;
449 for (
size_t i = 0;
i < checked_items.GetCount();
i++) {
450 int j = checked_items.Item(
i);
456 for (
auto rit = to_delete.rbegin(); rit != to_delete.rend(); ++rit) {
459 if (checked_items.GetCount() > 0) {
480 for (
auto index = 0; index <
m_CheckListBox->GetCount(); ++index) {
498 str =
"allow '" + ws.
GetWord() +
"' to be replaced by ";
500 str +=
"'" + it +
"', ";
506 str +=
", case-sensitive";
508 str +=
", whole word";
User-defined methods of the data storage class.
const string GetSynonymFile() const
static bool ShowToolTips()
~CMacroWordSubstitutionDlg()
void OnAccept(wxCommandEvent &event)
void OnOpenFile(wxCommandEvent &event)
bool x_UpdateSynonymFile()
void OnRemove(wxCommandEvent &event)
void OnEditSubstitutionList(wxCommandEvent &event)
void OnAdd(wxCommandEvent &event)
wxCheckListBox * m_CheckListBox
static string GetDescription(const objects::CWord_substitution &ws)
void x_UpdateMap(CRef< objects::CWord_substitution > ws)
@ ID_MACROWORDSUBST_DELETEWORD
@ ID_MACROWORDSUBST_REMOVE
macro::CMacroLib::TStrSynList m_SynonymMap
wxIcon GetIconResource(const wxString &name)
void OnPatternUpdate(wxCommandEvent &event)
void OnUpdateAccept(wxUpdateUIEvent &event)
void OnRemoveFromFile(wxCommandEvent &event)
void OnClearList(wxCommandEvent &event)
void SetSubstitutionList(const CRef< objects::CWord_substitution_set > &subst_list)
void OnCancel(wxCommandEvent &event)
CMacroWordSubstitutionDlg()
wxBitmap GetBitmapResource(const wxString &name)
wxCheckBox * m_IgnoreCase
map< string, CRef< objects::CWord_substitution > > m_LabelToSubst
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("Word Substitution List"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX|wxTAB_TRAVERSAL)
virtual void AddWordSubstSet(const string &filename, CRef< objects::CWord_substitution_set > word_subst)=0
CWord_substitution_set –.
iterator_bool insert(const value_type &val)
std::ofstream out("events_result.xml")
main entry point for tests
void NcbiErrorBox(const string &message, const string &title="Error")
specialized Message Box function for reporting critical errors
#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 list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
static const char label[]
TWhole_word GetWhole_word(void) const
Get the Whole_word member data.
const TWord & GetWord(void) const
Get the Word member data.
bool IsSetSynonyms(void) const
Check if a value has been assigned to Synonyms data member.
const TSynonyms & GetSynonyms(void) const
Get the Synonyms member data.
bool IsSetWhole_word(void) const
Check if a value has been assigned to Whole_word data member.
Tdata & Set(void)
Assign a value to data member.
const Tdata & Get(void) const
Get the member data.
bool IsSet(void) const
Check if a value has been assigned to data member.
bool IsSetWord(void) const
Check if a value has been assigned to Word data member.
bool IsSetCase_sensitive(void) const
Check if a value has been assigned to Case_sensitive data member.
TCase_sensitive GetCase_sensitive(void) const
Get the Case_sensitive member data.
const struct ncbi::grid::netcache::search::fields::SIZE size
static const char * str(char *buf, int n)
wxString GetAbsolutePath(const wxString &localpath)
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)