NCBI C++ ToolKit
editingbtnspanel.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: editingbtnspanel.cpp 47479 2023-05-02 13:24:02Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Colleen Bollin and Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 
33 ////@begin includes
34 ////@end includes
35 
42 #include <gui/core/app_dialogs.hpp>
44 
45 #include <objmgr/bioseq_ci.hpp>
46 #include <objmgr/bioseq_handle.hpp>
47 #include <util/checksum.hpp>
48 #include <connect/ncbi_util.h>
49 
52 
53 #include <wx/icon.h>
54 #include <wx/msgdlg.h>
55 #include <wx/stattext.h>
56 #include <wx/settings.h>
57 #include <wx/event.h>
58 #include <wx/clipbrd.h>
59 #include <wx/display.h>
60 #include <wx/hashmap.h>
61 #include <wx/image.h>
62 #include <wx/colordlg.h>
63 #include <wx/stdpaths.h>
64 
72 #include <gui/objutils/utils.hpp>
75 
79 
107 #include <gui/utils/app_popup.hpp>
123 #include <gui/core/table_view.hpp>
124 #include <gui/widgets/edit/init.hpp>
158 #include "edit_table_views.hpp"
181 
186 
192 #include "gui_core_helper_impl.hpp"
193 
194 ////@begin XPM images
195 ////@end XPM images
196 
198 using namespace objects;
199 
200 #ifdef NCBI_OS_MSWIN
201 #define BUTTON_WIDTH 119
202 #define BUTTON_HEIGHT 23
203 #else // NCBI_OS_LINUX NCBI_OS_DARWIN
204 #define BUTTON_WIDTH 150
205 #define BUTTON_HEIGHT 23
206 #endif
207 
208 #define DIST_BETWEEN_BUTTONS 5
209 
210 IMovableButton::IMovableButton(wxPanel* parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style) : wxButton(parent,wxID_ANY,label,pos,size,style),
211  m_OrigId(id), m_Position(pos), m_dragging(false),
212  m_locked(true),m_removed(false),m_Sizer(parent->GetSizer())
213 {
214  m_menu.Append(ID_POPUP_A, "Tab A");
215  m_menu.Append(ID_POPUP_B, "Tab B");
216  m_menu.Append(ID_POPUP_C, "Tab C");
217  Bind(wxEVT_COMMAND_BUTTON_CLICKED, &IMovableButton::onMouseClick, this, wxID_ANY); // workaround for pre-2.9.5 wxWidgets which do not have wxEVT_BUTTON yet.
218  Bind(wxEVT_CONTEXT_MENU,&IMovableButton::OnRightClick,this, wxID_ANY);
220  Bind(wxEVT_UPDATE_UI, &IMovableButton::OnPopupClickUpdate, this, ID_POPUP_REMOVE);
221  Bind(wxEVT_KEY_DOWN,&IMovableButton::OnKeyDown,this, wxID_ANY);
222 }
223 
225 {
226  m_menu.Append(ID_POPUP_REMOVE, "Delete Button");
227  m_menu.Append(ID_POPUP_EDIT, "Edit Script");
228 }
229 
230 void IMovableButton::SetLocked(bool locked)
231 {
232  m_locked = locked;
233  if (m_locked)
234  m_dragging = false;
235 }
236 
237 void IMovableButton::SetRemoved(bool removed)
238 {
239  m_removed = removed;
240 }
241 
242 void IMovableButton::SetDragging(bool dragging)
243 {
244  m_dragging = dragging;
245 }
246 
247 void IMovableButton::SetSizers( wxWindow *win_top, wxSizer *sizer1, wxSizer *sizer2, wxSizer *sizer3, wxSizer *sizer_removed_actual)
248 {
249  if (win_top) m_win_top = win_top;
250  if (sizer1) m_TopSizer1 = sizer1;
251  if (sizer2) m_TopSizer2 = sizer2;
252  if (sizer3) m_TopSizer3 = sizer3;
253  if (sizer_removed_actual) m_TopSizerRemoved = sizer_removed_actual;
254 }
255 
257 {
258  bool occupied = false;
259  wxRect r = GetRect();
260 
261  wxSizerItemList& children = m_Sizer->GetChildren();
262  for (wxSizerItemList::iterator child = children.begin(); child != children.end(); ++child)
263  {
264  wxWindow* w = (*child)->GetWindow();
265  if (w)
266  {
267  if (w == dynamic_cast<wxWindow*>(this))
268  {
269  continue;
270  }
271  wxRect r1 = w->GetRect();
272 
273  if (r.Intersects(r1))
274  {
275  occupied = true;
276  }
277  }
278  }
279  return occupied;
280 }
281 
283 {
284  if (sizer == NULL) sizer = m_Sizer;
286  int width = GetRect().GetWidth();
287  int height = GetRect().GetHeight();
288 
289  int row = 1;
290  wxSizerItemList& children = sizer->GetChildren();
291  for (wxSizerItemList::iterator child = children.begin(); child != children.end(); ++child)
292  {
293  wxRect r(x,y,width,height);
294  wxWindow* w = (*child)->GetWindow();
295  if (w)
296  {
297  if (w == dynamic_cast<wxWindow*>(this))
298  {
299  break;
300  }
301  wxRect r1 = w->GetRect();
302  if (r1.GetTop() > r.GetTop())
303  {
305  y = r1.GetBottom() + DIST_BETWEEN_BUTTONS;
306  row = 1;
307  continue;
308  }
309  if (r.Intersects(r1))
310  {
311  x = r1.GetRight() + DIST_BETWEEN_BUTTONS;
312  row++;
313  if (x+width > sizer->GetContainingWindow()->GetRect().GetWidth() || row > 2)
314  {
316  y = r1.GetBottom() + DIST_BETWEEN_BUTTONS;
317  row = 1;
318  }
319  }
320  }
321  }
322 
323  return wxPoint(x,y);
324 }
325 
326 void IMovableButton::SetScrollPos(wxPoint scrollpos)
327 {
328  m_ScrollPos = scrollpos;
329 }
330 
331 void IMovableButton::CopyButton(wxSizer *sizer, wxPoint p)
332 {
333  CButtonPanel * panel = dynamic_cast<CButtonPanel*>(sizer->GetContainingWindow());
334  if (p == wxDefaultPosition)
335  p = FindUnoccupiedPosition(sizer);
336  wxPoint scrollpos = panel->GetScrollPos();
337  SetScrollPos(scrollpos);
338  if (p.x < 0)
339  p.x += scrollpos.x;
340  if (p.y < 0)
341  p.y += scrollpos.y;
342  IMovableButton *button = panel->CreateButton(this,p.x,p.y);
343  int bottom = panel->GetVirtualSize().y;
344  int button_bottom = button->GetRect().GetBottom() + DIST_BETWEEN_BUTTONS;
345  if (button_bottom > bottom)
346  panel->SetVirtualSize(panel->GetVirtualSize().x, button_bottom);
348  button->SetLocked(m_locked);
349 }
350 
351 void IMovableButton::OnPopupClick(wxCommandEvent &evt)
352 {
353  switch(evt.GetId())
354  {
355  case ID_POPUP_A:
356  CopyButton(m_TopSizer1,wxDefaultPosition);
357  break;
358  case ID_POPUP_B:
359  CopyButton(m_TopSizer2,wxDefaultPosition);
360  break;
361  case ID_POPUP_C:
362  CopyButton(m_TopSizer3,wxDefaultPosition);
363  break;
364  case ID_POPUP_REMOVE:
365  CallAfter(&IMovableButton::RemoveButton);
366  break;
367  case ID_POPUP_EDIT:
368  {
369  CEditingBtnsPanel* e = dynamic_cast<CEditingBtnsPanel*> (m_win_top);
370  if (e)
371  e->EditButton(this);
372  }
373  break;
374  }
375  }
376 
377 void IMovableButton::OnPopupClickUpdate(wxUpdateUIEvent& event)
378 {
379  event.Enable(m_OrigId >= ID_BUTTON_DYNAMIC);
380 }
381 
383 {
384  CEditingBtnsPanel* e = dynamic_cast<CEditingBtnsPanel*> (m_win_top);
385  if (e)
386  e->RemoveButton(this);
387 }
388 
390 {
391  if (!m_locked && !m_removed)
392  {
393  CButtonPanel * panel = dynamic_cast<CButtonPanel*>(m_Sizer->GetContainingWindow());
394  panel->SetMovingButton(NULL,false);
395  Destroy();
396  }
397 }
398 
399 void IMovableButton::OnRightClick(wxContextMenuEvent &evt)
400 {
401  wxPoint mouseOnScreen = wxGetMousePosition();
402  wxRect r = GetScreenRect();
403  if (r.Contains(mouseOnScreen.x,mouseOnScreen.y))
404  {
405  if (!m_locked && !m_removed)
406  DeleteButton();
407  else if (m_removed)
408  PopupMenu(&m_menu);
409  else
410  evt.Skip();
411  }
412 }
413 
414 void IMovableButton::onMouseClick(wxCommandEvent& evt)
415 {
416  if (!IsShownOnScreen())
417  return;
418  wxPoint mouseOnScreen = wxGetMousePosition();
419  wxRect r = GetScreenRect();
420  if (r.Contains(mouseOnScreen.x,mouseOnScreen.y))
421  {
422  if (m_locked)
423  {
424  CEditingBtnsPanel* e = dynamic_cast<CEditingBtnsPanel*> (m_win_top);
425  if (e)
426  {
427  if (VerifySelection(e))
428  {
429  evt.SetId(m_OrigId);
430  evt.Skip();
431  }
432  }
433  }
434  else if (!m_removed)
435  {
436  wxPoint mouseOnScreen = wxGetMousePosition();
438  CButtonPanel * panel = dynamic_cast<CButtonPanel*>(m_Sizer->GetContainingWindow());
439  panel->SetMovingButton(this,m_dragging);
440  }
441  }
442 }
443 
444 
445 void IMovableButton::MoveButton(wxPoint mousePos)
446 {
447  if(m_dragging && !m_removed)
448  {
449  CButtonPanel *w = dynamic_cast<CButtonPanel *>(GetParent());
450  wxPoint scrollpos = w->GetScrollPos();
451  SetScrollPos(scrollpos);
452 
453  int cx,cy;
454  GetPosition(&cx,&cy);
455 
456 
457 // Might have to do the same for mouse coordinates in case of scrolled window
458  int sdx,sdy;
459  GetSize(&sdx,&sdy);
460 
461  int dx = 0;
462  int dy = 0;
463 
464 
465  if (mousePos.x > cx + sdx) dx = sdx+DIST_BETWEEN_BUTTONS;
466  if (mousePos.x < cx ) dx = -(sdx+DIST_BETWEEN_BUTTONS);
467  if (mousePos.y > cy + sdy) dy = (sdy+DIST_BETWEEN_BUTTONS);
468  if (mousePos.y < cy ) dy = -(sdy+DIST_BETWEEN_BUTTONS);
469 
470  cx += dx;
471  cy += dy;
472 
473  wxRect r = w->GetScreenRect();
474  if (cx > r.GetWidth())
475  cx -= (sdx+DIST_BETWEEN_BUTTONS);
476  if (cx < 0)
477  cx += (sdx+DIST_BETWEEN_BUTTONS);
478  //if (cy+sdy > r.GetHeight())
479  // cy -= (sdy+DIST_BETWEEN_BUTTONS);
480  if (cy < 0)
481  cy += (sdy+DIST_BETWEEN_BUTTONS);
482 
483  SetPosition( wxPoint(cx, cy) );
484  m_Position = wxPoint(w->CalcUnscrolledPosition(GetPosition()));
485  int bottom = w->GetVirtualSize().y;
486  int button_bottom = GetRect().GetBottom() + DIST_BETWEEN_BUTTONS;
487  if (button_bottom > bottom)
488  {
489  w->SetVirtualSize(w->GetVirtualSize().x, button_bottom);
490  }
491  }
492 }
493 
494 void IMovableButton::OnKeyDown(wxKeyEvent& event)
495 {
496  OnChar(event);
497 }
498 
499 bool IMovableButton::OnChar(wxKeyEvent& event)
500 {
501  bool found = false;
502  CButtonPanel *w = dynamic_cast<CButtonPanel *>(GetParent());
503  wxPoint scrollpos = w->GetScrollPos();
504  SetScrollPos(scrollpos);
505 
506  int cx,cy;
507  GetPosition(&cx,&cy);
508  wxPoint pos(cx,cy);
509  int sdx,sdy;
510  GetSize(&sdx,&sdy);
511  switch ( event.GetKeyCode() )
512  {
513  case WXK_LEFT : pos.x--; MoveButton(pos); found = true; break;
514  case WXK_RIGHT : pos.x += sdx+1; MoveButton(pos); found = true; break;
515  case WXK_UP : pos.y--; MoveButton(pos); found = true; break;
516  case WXK_DOWN : pos.y += sdy+1; MoveButton(pos); found = true; break;
517  case WXK_RETURN: m_dragging = !m_dragging; found = true; break;
518  default: event.Skip(); break;
519  }
520  return found;
521 }
522 
523 IMPLEMENT_ABSTRACT_CLASS( IMovableButton, wxButton )
524 
526 {
527 public:
529 
530  CMovableButton(wxPanel* parent, wxWindowID id, const wxString &label=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0) : IMovableButton(parent,id,label,pos,size,style) {}
531 
532  virtual ~CMovableButton() {}
534  {
535  return e->OnDataChange();
536  }
537  DECLARE_DYNAMIC_CLASS( CMovableButton )
538 };
539 
540 IMPLEMENT_DYNAMIC_CLASS( CMovableButton, IMovableButton )
541 
543 {
544 public:
546  CFeatureSubtypeSelector(CSeqFeatData::ESubtype subtype) : m_Subtype(subtype) {}
548  virtual CSeqFeatData::ESubtype GetSubtype() {return m_Subtype;}
549 private:
551 };
552 
554 {
555 public:
557 
558  CFeatureMovableButton(wxPanel* parent, wxWindowID id, CSeqFeatData::ESubtype subtype, const wxString &label=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0) : IMovableButton(parent,id,label,pos,size,style), CFeatureSubtypeSelector(subtype) {}
559 
562  {
563  return e->IsLocationSelected();
564  }
565  DECLARE_DYNAMIC_CLASS( CFeatureMovableButton )
566 };
567 
568 IMPLEMENT_DYNAMIC_CLASS( CFeatureMovableButton, IMovableButton )
569 
571 {
572 public:
574 
575  CFeatureMovableButtonNa(wxPanel* parent, wxWindowID id, CSeqFeatData::ESubtype subtype, const wxString &label=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0) : IMovableButton(parent,id,label,pos,size,style), CFeatureSubtypeSelector(subtype) {}
576 
579  {
580  return e->IsLocationSelectedNa();
581  }
582  DECLARE_DYNAMIC_CLASS( CFeatureMovableButtonNa )
583 };
584 
585 IMPLEMENT_DYNAMIC_CLASS( CFeatureMovableButtonNa, IMovableButton )
586 
588 {
589 public:
591 
592  CFeatureMovableButtonAa(wxPanel* parent, wxWindowID id, CSeqFeatData::ESubtype subtype, const wxString &label=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0) : IMovableButton(parent,id,label,pos,size,style), CFeatureSubtypeSelector(subtype) {}
593 
596  {
597  return e->IsLocationSelectedAa();
598  }
599  DECLARE_DYNAMIC_CLASS( CFeatureMovableButtonAa )
600 };
601 
602 IMPLEMENT_DYNAMIC_CLASS( CFeatureMovableButtonAa, IMovableButton )
603 
604 
605 CButtonPanel::CButtonPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) : wxScrolledWindow(parent,id, pos, size)
606 {
607  m_MovingButton = NULL;
608  Bind(wxEVT_LEFT_UP, &CButtonPanel::onMouseClick, this, wxID_ANY);
609  Bind(wxEVT_KEY_DOWN,&CButtonPanel::OnKeyDown,this, wxID_ANY);
610 }
611 
613 {
614 }
615 
616 void CButtonPanel::OnKeyDown(wxKeyEvent& event)
617 {
618  OnChar(event);
619 }
620 
621 bool CButtonPanel::OnChar(wxKeyEvent& evt)
622 {
623  bool found = false;
624  if (m_MovingButton)
625  {
626  found = m_MovingButton->OnChar(evt);
627  }
628 
629  if (!found)
630  evt.Skip();
631  return found;
632 }
633 
635 {
636  wxWindow* main = GetGrandParent()->GetParent();
637  CEditingBtnsPanel* e = dynamic_cast<CEditingBtnsPanel*> (main);
638  if (!e) return false;
639  Scroll(0,0);
640  wxSizer* sizer = GetSizer();
641  wxSizerItemList& children = sizer->GetChildren();
642  int max_y = 0;
643  int bottom = GetVirtualSize().y;
644  for (wxSizerItemList::iterator child = children.begin(); child != children.end(); ++child)
645  {
646  wxWindow* w = (*child)->GetWindow();
647  if (w)
648  {
649  IMovableButton* button = dynamic_cast<IMovableButton*>(w);
650  if (button)
651  {
652  wxPoint p = button->GetOrigPosition();
653  if (p.x < 0 || p.y < 0)
654  p = button->FindUnoccupiedPosition();
655  if (p.y > max_y)
656  max_y = p.y;
657  button->SetPosition(CalcScrolledPosition(p));
658  }
659  else
660  {
661  w->SetPosition(CalcScrolledPosition(wxPoint(DIST_BETWEEN_BUTTONS, max_y+BUTTON_HEIGHT+DIST_BETWEEN_BUTTONS)));
662  }
663  bottom = max(bottom, w->GetRect().GetBottom() + DIST_BETWEEN_BUTTONS);
664  }
665  }
666  bool auto_layout = GetAutoLayout();
667  SetAutoLayout(false);
668  SetVirtualSize(GetVirtualSize().x, bottom);
669  SetAutoLayout(auto_layout);
670  return true;
671 }
672 
673 
674 void CButtonPanel::onMouseClick(wxMouseEvent& evt)
675 {
676  if (m_MovingButton)
677  {
678  wxPoint p = evt.GetPosition();
680  }
681  evt.Skip();
682 }
683 
685 {
686  wxPoint scrollpos = GetViewStart();
687  int x,y;
688  GetScrollPixelsPerUnit(&x,&y);
689  scrollpos.x *= x;
690  scrollpos.y *= y;
691  return scrollpos;
692 }
693 
695 {
696  if (m_MovingButton && btn != m_MovingButton)
697  m_MovingButton->SetDragging(false);
698 
699  if (dragging)
700  {
701  m_MovingButton = btn;
703  }
704  else
705  {
707  }
708 }
709 
710 IMovableButton* CButtonPanel::CreateButton(wxWindow *w, int x, int y)
711 {
712  IMovableButton *b = NULL;
713  CMovableButton *b1 = dynamic_cast<CMovableButton*>(w);
714  if (b1)
715  {
716  CMovableButton* button = new CMovableButton( this, b1->GetOrigId(), b1->GetLabel(), wxPoint(x,y), wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
717  GetSizer()->Add(button, 0, wxALIGN_LEFT|wxALL, DIST_BETWEEN_BUTTONS);
718  b = button;
719  }
720  CFeatureMovableButton *b2 = dynamic_cast<CFeatureMovableButton*>(w);
721  if (b2)
722  {
723  CFeatureMovableButton* button = new CFeatureMovableButton( this, b2->GetOrigId(), b2->GetSubtype(), b2->GetLabel(), wxPoint(x,y), wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
724  GetSizer()->Add(button, 0, wxALIGN_LEFT|wxALL, DIST_BETWEEN_BUTTONS);
725  b = button;
726  }
727  CFeatureMovableButtonNa *b3 = dynamic_cast<CFeatureMovableButtonNa*>(w);
728  if (b3)
729  {
730  CFeatureMovableButtonNa* button = new CFeatureMovableButtonNa( this, b3->GetOrigId(), b3->GetSubtype(), b3->GetLabel(), wxPoint(x,y), wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
731  GetSizer()->Add(button, 0, wxALIGN_LEFT|wxALL, DIST_BETWEEN_BUTTONS);
732  b = button;
733  }
734  CFeatureMovableButtonAa *b4 = dynamic_cast<CFeatureMovableButtonAa*>(w);
735  if (b4)
736  {
737  CFeatureMovableButtonAa* button = new CFeatureMovableButtonAa( this, b4->GetOrigId(), b4->GetSubtype(), b4->GetLabel(), wxPoint(x,y), wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
738  GetSizer()->Add(button, 0, wxALIGN_LEFT|wxALL, DIST_BETWEEN_BUTTONS);
739  b = button;
740  }
741  Refresh();
742 
743  return b;
744 }
745 
746 static bool comp_buttons(const IMovableButton* a, const IMovableButton* b)
747 {
748  wxString a_label = a->GetLabel();
749  wxString b_label = b->GetLabel();
750  if (a_label[0].GetValue() == '*' && b_label[0].GetValue() != '*')
751  return false;
752  if (a_label[0].GetValue() != '*' && b_label[0].GetValue() == '*')
753  return true;
754  return a_label.CmpNoCase(b_label) < 0;
755 }
756 
757 IMPLEMENT_DYNAMIC_CLASS( CButtonPanel, wxScrolledWindow )
758 
759 /*!
760  * CEditingBtnsPanel type definition
761  */
762 
763 IMPLEMENT_DYNAMIC_CLASS( CEditingBtnsPanel, wxFrame )
764 
765 
766 /*!
767  * CEditingBtnsPanel event table definition
768  */
769 
770 BEGIN_EVENT_TABLE( CEditingBtnsPanel, wxFrame)
771 
779  EVT_SEARCHCTRL_SEARCH_BTN( ID_FIND_BUTTON, CEditingBtnsPanel::OnFindButton )
780  EVT_SEARCHCTRL_CANCEL_BTN( ID_FIND_BUTTON, CEditingBtnsPanel::OnCancelFindButton )
782  EVT_CHAR_HOOK(CEditingBtnsPanel::OnChar)
783 
784 ////@begin CEditingBtnsPanel event table entries
855  EVT_BUTTON( ID_BUTTON75, CEditingBtnsPanel::Save )
904 ////@end CEditingBtnsPanel event table entries
905 
907 
908 
909 /*!
910  * CEditingBtnsPanel constructors
911  */
912 
914 
915 void CEditingBtnsPanel::GetInstance( wxWindow* parent, IWorkbench* workbench, bool autostart, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
916 {
917  if (!m_Instance)
918  m_Instance = new CEditingBtnsPanel(parent, workbench, id, pos, size, style);
919  // Instantiated on first use.
920  if (autostart && !m_Instance->ShouldAutoStart())
921  {
922  m_Instance->Destroy();
923  m_Instance = NULL;
924  return;
925  }
926  m_Instance->Show(true);
927  m_Instance->SetFocus();
928 }
929 
930 
932 {
933  Init();
934 }
935 
936 CEditingBtnsPanel::CEditingBtnsPanel( wxWindow* parent, IWorkbench* workbench, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : m_Workbench(workbench)
937 {
938  Init();
939  Create(parent, id, pos, size, style);
940  SetRegistryPath("Workbench.Services.Views.Generic.Sequin Buttons");
941  LoadSettings();
943  PlaceButtons();
945  string instance = CSysPath::GetInst();
946  if (!instance.empty())
947  {
948  wxString title = GetTitle();
949  title << " (" << instance << ")";
950  SetTitle(title);
951  }
952 }
953 
954 
955 /*!
956  * CEditingBtnsPanel creator
957  */
958 
959 bool CEditingBtnsPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
960 {
961 ////@begin CEditingBtnsPanel creation
962  wxFrame::Create( parent, id, _("Editing Buttons"), pos, size, style );
963  CreateControls();
964  if (GetSizer())
965  {
966  GetSizer()->SetSizeHints(this);
967  }
968  Centre();
969 ////@end CEditingBtnsPanel creation
970 
971  return true;
972 }
973 
974 
975 /*!
976  * CEditingBtnsPanel destructor
977  */
978 
980 {
981 ////@begin CEditingBtnsPanel destruction
982 ////@end CEditingBtnsPanel destruction
983  SaveSettings();
984  m_Instance = NULL;
985 }
986 
987 
988 /*!
989  * Member initialisation
990  */
991 
993 {
994 ////@begin CEditingBtnsPanel member initialisation
995 ////@end CEditingBtnsPanel member initialisation
996  m_CheckBox = NULL;
997  m_AutoStart = NULL;
998  m_Sizer1 = NULL;
999  m_Sizer2 = NULL;
1000  m_Sizer3 = NULL;
1001  m_SizerRemoved = NULL;
1006  m_findButton = NULL;
1007  m_Notebook = NULL;
1008 
1009  m_FrameSize = wxSize(600,400);
1010  m_FramePosition = wxPoint(5,5);
1011 
1012  m_bg_color_set = false;
1013  m_panel1 = NULL;
1014  m_panel2 = NULL;
1015  m_panel3 = NULL;
1017 }
1018 
1020 {
1021 /* unsigned long hash = wxStringHash::stringHash(instance.c_str());
1022  wxColour old = *wxGREEN; //notebook->GetBackgroundColour();
1023  wxImage::HSVValue hsv = wxImage::RGBtoHSV(wxImage::RGBValue(old.Red(), old.Green(), old.Blue()));
1024  hsv.hue = double(hash % 360) / 360;
1025  wxImage::RGBValue rgb = wxImage::HSVtoRGB(hsv);
1026  wxColour upd(rgb.red, rgb.green, rgb.blue);
1027 */
1028  if (m_bg_color_set)
1029  {
1032  m_Notebook->SetBackgroundColour(m_bg_color);
1033  m_panel1->SetBackgroundColour(m_bg_color);
1034  m_panel2->SetBackgroundColour(m_bg_color);
1035  m_panel3->SetBackgroundColour(m_bg_color);
1036  m_panel_removed->SetBackgroundColour(m_bg_color);
1037  }
1038  else
1039  {
1040  CTextPanel::SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
1041  SetTextViewBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
1042  wxColour bg_color = wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK);
1043  m_Notebook->SetBackgroundColour(bg_color);
1044  m_panel1->SetBackgroundColour(bg_color);
1045  m_panel2->SetBackgroundColour(bg_color);
1046  m_panel3->SetBackgroundColour(bg_color);
1047  m_panel_removed->SetBackgroundColour(bg_color);
1048  }
1049  Refresh();
1050 }
1051 
1053 {
1054  if (m_Workbench)
1055  {
1056 
1058  if (view_srv)
1059  {
1060 
1062  view_srv->GetViews(views);
1064  {
1065  IProjectView* project_view = dynamic_cast<IProjectView*>((*it).GetPointer());
1066  if (project_view) // && project_view->GetLabel(IProjectView::eType) == "Text View")
1067  {
1068 
1069  CTextPanel *text_panel = dynamic_cast<CTextPanel*>(project_view->GetWindow());
1070  if (text_panel)
1071  {
1072  text_panel->GetWidget()->SetBackgroundColour(color);
1073  text_panel->GetWidget()->Refresh();
1074  }
1075  }
1076  }
1077  }
1078  }
1079 }
1080 
1081 void CEditingBtnsPanel::OnSetBackground(wxHyperlinkEvent& event)
1082 {
1083  wxColourDialog dlg(this);
1084  if (dlg.ShowModal() == wxID_OK)
1085  {
1086  m_bg_color = dlg.GetColourData().GetColour();
1087  m_bg_color_set = true;
1089  SaveSettings();
1090  }
1091 }
1092 
1093 void CEditingBtnsPanel::OnResetBackground(wxHyperlinkEvent& event)
1094 {
1095  m_bg_color_set = false;
1097  SaveSettings();
1098 }
1099 
1100 /*!
1101  * Control creation for CEditingBtnsPanel
1102  */
1103 
1105 {
1106 ////@begin CEditingBtnsPanel content construction
1107  // Generated by DialogBlocks, 26/10/2012 15:32:03 (unregistered)
1108 
1109  wxPanel* itemPanel1 = new wxPanel(this, wxID_ANY,wxPoint(0,20),wxSize(600,380));
1110 
1111  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
1112  itemPanel1->SetSizer(itemBoxSizer1);
1113 
1114  m_Notebook = new wxNotebook(itemPanel1, ID_NOTEBOOK_PANEL,wxDefaultPosition,wxSize(600,280));
1115  itemBoxSizer1->Add(m_Notebook, 2, wxALL|wxGROW, 0);
1116 
1117  m_panel1 = new CButtonPanel(m_Notebook,ID_TAB1,wxDefaultPosition,wxSize(600,260));
1118  m_panel1->SetVirtualSize(-1, 1500);
1119  m_panel1->SetScrollRate(0, 30);
1120  m_Notebook->AddPage(m_panel1,_("A"));
1121 
1122  m_panel2 = new CButtonPanel(m_Notebook,ID_TAB2,wxDefaultPosition,wxSize(600,260));
1123  m_panel2->SetVirtualSize(-1, 1500);
1124  m_panel2->SetScrollRate(0, 30);
1125  m_Notebook->AddPage(m_panel2,_("B"));
1126 
1127  m_panel3 = new CButtonPanel(m_Notebook,ID_TAB3,wxDefaultPosition,wxSize(600,260));
1128  m_panel3->SetVirtualSize(-1, 1500);
1129  m_panel3->SetScrollRate(0, 30);
1130  m_Notebook->AddPage(m_panel3,_("C"));
1131 
1132  m_panel_removed = new CButtonPanel(m_Notebook,ID_TAB_REMOVED,wxDefaultPosition,wxSize(600,260));
1133  m_panel_removed->SetVirtualSize(-1, 1500);
1134  m_panel_removed->SetScrollRate(0, 30);
1135  m_Notebook->AddPage(m_panel_removed,_("All"));
1136 
1137  m_Sizer1 = new wxBoxSizer(wxVERTICAL);
1138  m_panel1->SetSizer(m_Sizer1);
1139 
1140  m_Sizer2 = new wxBoxSizer(wxVERTICAL);
1141  m_panel2->SetSizer(m_Sizer2);
1142 
1143  m_Sizer3 = new wxBoxSizer(wxVERTICAL);
1144  m_panel3->SetSizer(m_Sizer3);
1145 
1146  m_SizerRemoved = new wxBoxSizer(wxVERTICAL);
1147  m_panel_removed->SetSizer(m_SizerRemoved);
1148 
1149  CMovableButton* itemButton1 = new CMovableButton( m_panel_removed, ID_BUTTON1, _("Rev Author Names"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1150  m_SizerRemoved->Add(itemButton1, 0, wxALL, 5);
1151  CMovableButton* itemButton2 = new CMovableButton( m_panel_removed, ID_BUTTON2, _("Edit Pubs"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1152  m_SizerRemoved->Add(itemButton2, 0, wxALL, 5);
1153  CMovableButton* itemButton3 = new CMovableButton( m_panel_removed, ID_BUTTON3, _("Local ID->Src"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1154  m_SizerRemoved->Add(itemButton3, 0, wxALL, 5);
1155  CMovableButton* itemButton4 = new CMovableButton( m_panel_removed, ID_BUTTON4, _("Fix Caps"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1156  m_SizerRemoved->Add(itemButton4, 0, wxALL, 5);
1157  CMovableButton* itemButton5 = new CMovableButton( m_panel_removed, ID_BUTTON5, _("Fix Caps Authors"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1158  m_SizerRemoved->Add(itemButton5, 0, wxALL, 5);
1159  CMovableButton* itemButton6 = new CMovableButton( m_panel_removed, ID_BUTTON6, _("Fix Caps Titles"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1160  m_SizerRemoved->Add(itemButton6, 0, wxALL, 5);
1161  CMovableButton* itemButton7 = new CMovableButton( m_panel_removed, ID_BUTTON7, _("Fix Caps Affil"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1162  m_SizerRemoved->Add(itemButton7, 0, wxALL, 5);
1163  CMovableButton* itemButton8 = new CMovableButton( m_panel_removed, ID_BUTTON8, _("SUC"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1164  m_SizerRemoved->Add(itemButton8, 0, wxALL, 5);
1165  CMovableButton* itemButton9 = new CMovableButton( m_panel_removed, ID_BUTTON9, _("Remove Unpub"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1166  m_SizerRemoved->Add(itemButton9, 0, wxALL, 5);
1167  CMovableButton* itemButton10 = new CMovableButton( m_panel_removed, ID_BUTTON10, _("Table Reader Clip"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1168  m_SizerRemoved->Add(itemButton10, 0, wxALL, 5);
1169  CMovableButton* itemButton11 = new CMovableButton( m_panel_removed, ID_BUTTON11, _("Tax_fix/Clean_up"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1170  m_SizerRemoved->Add(itemButton11, 0, wxALL, 5);
1171  CMovableButton* itemButton12 = new CMovableButton( m_panel_removed, ID_BUTTON12, _("Remove All Features"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1172  m_SizerRemoved->Add(itemButton12, 0, wxALL, 5);
1173  CMovableButton* itemButton13 = new CMovableButton( m_panel_removed, ID_BUTTON13, _("Strip Suffix"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1174  m_SizerRemoved->Add(itemButton13, 0, wxALL, 5);
1175  CMovableButton* itemButton14 = new CMovableButton( m_panel_removed, ID_BUTTON14, _("Rm Consortium"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1176  m_SizerRemoved->Add(itemButton14, 0, wxALL, 5);
1177  CMovableButton* itemButton16 = new CMovableButton( m_panel_removed, ID_BUTTON16, _("Trim N-rich"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1178  m_SizerRemoved->Add(itemButton16, 0, wxALL, 5);
1179  CMovableButton* itemButton17 = new CMovableButton( m_panel_removed, ID_BUTTON17, _("Add Comment"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1180  m_SizerRemoved->Add(itemButton17, 0, wxALL, 5);
1181  CMovableButton* itemButton18 = new CMovableButton( m_panel_removed, ID_BUTTON18, _("mrna_CDS"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1182  m_SizerRemoved->Add(itemButton18, 0, wxALL, 5);
1183  CMovableButton* itemButton19 = new CMovableButton( m_panel_removed, ID_BUTTON19, _("cit-sub-upd"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1184  m_SizerRemoved->Add(itemButton19, 0, wxALL, 5);
1185  CMovableButton* itemButton20 = new CMovableButton( m_panel_removed, ID_BUTTON20, _("Remove Seqs"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1186  m_SizerRemoved->Add(itemButton20, 0, wxALL, 5);
1187  CMovableButton* itemButton21 = new CMovableButton( m_panel_removed, ID_BUTTON21, _("Remove GPID"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1188  m_SizerRemoved->Add(itemButton21, 0, wxALL, 5);
1189  CMovableButton* itemButton22 = new CMovableButton( m_panel_removed, ID_BUTTON22, _("rem_prot_titles"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1190  m_SizerRemoved->Add(itemButton22, 0, wxALL, 5);
1191  CMovableButton* itemButton23 = new CMovableButton( m_panel_removed, ID_BUTTON23, _("Rm Culture Notes"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1192  m_SizerRemoved->Add(itemButton23, 0, wxALL, 5);
1193  CMovableButton* itemButton24 = new CMovableButton( m_panel_removed, ID_BUTTON24, _("Revcomp 16S"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1194  m_SizerRemoved->Add(itemButton24, 0, wxALL, 5);
1195  CMovableButton* itemButton25 = new CMovableButton( m_panel_removed, ID_BUTTON25, _("Remove Descriptors"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) ); // not found
1196  m_SizerRemoved->Add(itemButton25, 0, wxALL, 5);
1197  CMovableButton* itemButton26 = new CMovableButton( m_panel_removed, ID_BUTTON26, _("Strain to sp."), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1198  m_SizerRemoved->Add(itemButton26, 0, wxALL, 5);
1199  CMovableButton* itemButton27 = new CMovableButton( m_panel_removed, ID_BUTTON27, _("RemoveStructCmt"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1200  m_SizerRemoved->Add(itemButton27, 0, wxALL, 5);
1201  CMovableButton* itemButton28 = new CMovableButton( m_panel_removed, ID_BUTTON28, _("Bulk Edit CDS"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1202  m_SizerRemoved->Add(itemButton28, 0, wxALL, 5);
1203  CMovableButton* itemButton29 = new CMovableButton( m_panel_removed, ID_BUTTON29, _("Add Tsl Excepts Cmt"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1204  m_SizerRemoved->Add(itemButton29, 0, wxALL, 5);
1205  CMovableButton* itemButton30 = new CMovableButton( m_panel_removed, ID_BUTTON30, _("RemoveSelectFeats"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1206  m_SizerRemoved->Add(itemButton30, 0, wxALL, 5);
1207  CMovableButton* itemButton31 = new CMovableButton( m_panel_removed, ID_BUTTON31, _("Bulk Edit Gene"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1208  m_SizerRemoved->Add(itemButton31, 0, wxALL, 5);
1209  CMovableButton* itemButton32 = new CMovableButton( m_panel_removed, ID_BUTTON32, _("Segregate"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1210  m_SizerRemoved->Add(itemButton32, 0, wxALL, 5);
1211  CMovableButton* itemButton33 = new CMovableButton( m_panel_removed, ID_BUTTON33, _("Add Set"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1212  m_SizerRemoved->Add(itemButton33, 0, wxALL, 5);
1213  CMovableButton* itemButton34 = new CMovableButton( m_panel_removed, ID_BUTTON34, _("StructKeyword"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1214  m_SizerRemoved->Add(itemButton34, 0, wxALL, 5);
1215  CMovableButton* itemButton35 = new CMovableButton( m_panel_removed, ID_BUTTON35, _("Reorder Strct Cmt"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1216  m_SizerRemoved->Add(itemButton35, 0, wxALL, 5);
1217  CMovableButton* itemButton36 = new CMovableButton( m_panel_removed, ID_BUTTON36, _("cSUC"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1218  m_SizerRemoved->Add(itemButton36, 0, wxALL, 5);
1219  CMovableButton* itemButton37 = new CMovableButton( m_panel_removed, ID_BUTTON37, _("PT Cleanup"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1220  m_SizerRemoved->Add(itemButton37, 0, wxALL, 5);
1221  CMovableButton* itemButton38 = new CMovableButton( m_panel_removed, ID_BUTTON38, _("On-Caller Tool"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1222  m_SizerRemoved->Add(itemButton38, 0, wxALL, 5);
1223  CMovableButton* itemButton39 = new CMovableButton( m_panel_removed, ID_BUTTON39, _("Select Target"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1224  m_SizerRemoved->Add(itemButton39, 0, wxALL, 5);
1225  CMovableButton* itemButton40 = new CMovableButton( m_panel_removed, ID_BUTTON40, _("Label rRNAs"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1226  m_SizerRemoved->Add(itemButton40, 0, wxALL, 5);
1227  CMovableButton* itemButton41 = new CMovableButton( m_panel_removed, ID_BUTTON41, _("Retranslate CDS"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1228  m_SizerRemoved->Add(itemButton41, 0, wxALL, 5);
1229  CMovableButton* itemButton42 = new CMovableButton( m_panel_removed, ID_BUTTON42, _("RetransCDS-NoStp"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1230  m_SizerRemoved->Add(itemButton42, 0, wxALL, 5);
1231  CMovableButton* itemButton43 = new CMovableButton( m_panel_removed, ID_BUTTON43, _("Bulk Edit RNA"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1232  m_SizerRemoved->Add(itemButton43, 0, wxALL, 5);
1233  CMovableButton* itemButton44 = new CMovableButton( m_panel_removed, ID_BUTTON44, _("Autofix"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1234  m_SizerRemoved->Add(itemButton44, 0, wxALL, 5);
1235  CMovableButton* itemButton48 = new CMovableButton( m_panel_removed, ID_BUTTON48, _("Uncul TaxTool"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1236  m_SizerRemoved->Add(itemButton48, 0, wxALL, 5);
1237  CMovableButton* itemButton49 = new CMovableButton( m_panel_removed, ID_BUTTON49, _("Append to Organism"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1238  m_SizerRemoved->Add(itemButton49, 0, wxALL, 5);
1239  CMovableButton* itemButton50 = new CMovableButton( m_panel_removed, ID_BUTTON50, _("Remove SrcNotes"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1240  m_SizerRemoved->Add(itemButton50, 0, wxALL, 5);
1241  CMovableButton* itemButton51 = new CMovableButton( m_panel_removed, ID_BUTTON51, _("Add Isol Source"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1242  m_SizerRemoved->Add(itemButton51, 0, wxALL, 5);
1243  CMovableButton* itemButton52 = new CMovableButton( m_panel_removed, ID_BUTTON52, _("ExtPartialsConstraint"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1244  m_SizerRemoved->Add(itemButton52, 0, wxALL, 5);
1245  CMovableButton* itemButton53 = new CMovableButton( m_panel_removed, ID_BUTTON53, _("Extend Partials Ends"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1246  m_SizerRemoved->Add(itemButton53, 0, wxALL, 5);
1247  CMovableButton* itemButton54 = new CMovableButton( m_panel_removed, ID_BUTTON54, _("Add 16S"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1248  m_SizerRemoved->Add(itemButton54, 0, wxALL, 5);
1249  CMovableButton* itemButton55 = new CMovableButton( m_panel_removed, ID_BUTTON55, _("Add 18S"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1250  m_SizerRemoved->Add(itemButton55, 0, wxALL, 5);
1251  CMovableButton* itemButton56 = new CMovableButton( m_panel_removed, ID_BUTTON56, _("Add 23S"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1252  m_SizerRemoved->Add(itemButton56, 0, wxALL, 5);
1253  CMovableButton* itemButton57 = new CMovableButton( m_panel_removed, ID_BUTTON57, _("Remove DefLines"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1254  m_SizerRemoved->Add(itemButton57, 0, wxALL, 5);
1255  CMovableButton* itemButton58 = new CMovableButton( m_panel_removed, ID_BUTTON58, _("Convert CDS to MiscFeat"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1256  m_SizerRemoved->Add(itemButton58, 0, wxALL, 5);
1257  CMovableButton* itemButton59 = new CMovableButton( m_panel_removed, ID_BUTTON59, _("Add CDS"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1258  m_SizerRemoved->Add(itemButton59, 0, wxALL, 5);
1259  CMovableButton* itemButton60 = new CMovableButton( m_panel_removed, ID_BUTTON60, _("Add RNA"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1260  m_SizerRemoved->Add(itemButton60, 0, wxALL, 5);
1261  CMovableButton* itemButton61 = new CMovableButton( m_panel_removed, ID_BUTTON61, _("Add Other Feature"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1262  m_SizerRemoved->Add(itemButton61, 0, wxALL, 5);
1263  CMovableButton* itemButton62 = new CMovableButton( m_panel_removed, ID_BUTTON62, _("Validate"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1264  m_SizerRemoved->Add(itemButton62, 0, wxALL, 5);
1265  CMovableButton* itemButton63 = new CMovableButton( m_panel_removed, ID_BUTTON63, _("LC Quals"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1266  m_SizerRemoved->Add(itemButton63, 0, wxALL, 5);
1267  CMovableButton* itemButton64 = new CMovableButton( m_panel_removed, ID_BUTTON64, _("Discrepancy Report"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1268  m_SizerRemoved->Add(itemButton64, 0, wxALL, 5);
1269  CMovableButton* itemButton65 = new CMovableButton( m_panel_removed, ID_BUTTON65, _("Apply Source Qual"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1270  m_SizerRemoved->Add(itemButton65, 0, wxALL, 5);
1271  CMovableButton* itemButton66 = new CMovableButton( m_panel_removed, ID_BUTTON66, _("Edit Source Qual"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1272  m_SizerRemoved->Add(itemButton66, 0, wxALL, 5);
1273  CMovableButton* itemButton67 = new CMovableButton( m_panel_removed, ID_BUTTON67, _("Rm Text Out String"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1274  m_SizerRemoved->Add(itemButton67, 0, wxALL, 5);
1275  CMovableButton* itemButton68 = new CMovableButton( m_panel_removed, ID_BUTTON68, _("Correct Gene for CDS"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1276  m_SizerRemoved->Add(itemButton68, 0, wxALL, 5);
1277  CMovableButton* itemButton69 = new CMovableButton( m_panel_removed, ID_BUTTON69, _("Add Gnm Asmb Cmt"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1278  m_SizerRemoved->Add(itemButton69, 0, wxALL, 5);
1279  CMovableButton* itemButton70 = new CMovableButton( m_panel_removed, ID_BUTTON70, _("EC Number Cleanup"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1280  m_SizerRemoved->Add(itemButton70, 0, wxALL, 5);
1281  CMovableButton* itemButton71 = new CMovableButton( m_panel_removed, ID_BUTTON71, _("Edit RNA Qual"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1282  m_SizerRemoved->Add(itemButton71, 0, wxALL, 5);
1283  CMovableButton* itemButton72 = new CMovableButton( m_panel_removed, ID_BUTTON72, _("rRNA"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1284  m_SizerRemoved->Add(itemButton72, 0, wxALL, 5);
1285  CMovableButton* itemButton73 = new CMovableButton( m_panel_removed, ID_BUTTON73, _("misc_feat"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1286  m_SizerRemoved->Add(itemButton73, 0, wxALL, 5);
1287  CMovableButton* itemButton74 = new CMovableButton( m_panel_removed, ID_BUTTON74, _("gene"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1288  m_SizerRemoved->Add(itemButton74, 0, wxALL, 5);
1289  CMovableButton* itemButton75 = new CMovableButton( m_panel_removed, ID_BUTTON75, _("Save"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1290  m_SizerRemoved->Add(itemButton75, 0, wxALL, 5);
1291  CMovableButton* itemButton76 = new CMovableButton( m_panel_removed, ID_BUTTON76, _("Edit CDS qual"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1292  m_SizerRemoved->Add(itemButton76, 0, wxALL, 5);
1293  CMovableButton* itemButton77 = new CMovableButton( m_panel_removed, ID_BUTTON77, _("Export Table"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1294  m_SizerRemoved->Add(itemButton77, 0, wxALL, 5);
1295  CMovableButton* itemButton79 = new CMovableButton( m_panel_removed, ID_BUTTON79, _("Sequester"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1296  m_SizerRemoved->Add(itemButton79, 0, wxALL, 5);
1297  CMovableButton* itemButton80 = new CMovableButton( m_panel_removed, ID_BUTTON80, _("Add G Set"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1298  m_SizerRemoved->Add(itemButton80, 0, wxALL, 5);
1299  CMovableButton* itemButton81 = new CMovableButton( m_panel_removed, ID_BUTTON81, _("Edit Feat Qual"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1300  m_SizerRemoved->Add(itemButton81, 0, wxALL, 5);
1301  CMovableButton* itemButton82 = new CMovableButton( m_panel_removed, ID_BUTTON82, _("sub_affil"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1302  m_SizerRemoved->Add(itemButton82, 0, wxALL, 5);
1303  CMovableButton* itemButton83 = new CMovableButton( m_panel_removed, ID_BUTTON83, _("rRNA->DNA"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1304  m_SizerRemoved->Add(itemButton83, 0, wxALL, 5);
1305  CMovableButton* itemButton84 = new CMovableButton( m_panel_removed, ID_BUTTON84, _("IllegalQuals to Note"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1306  m_SizerRemoved->Add(itemButton84, 0, wxALL, 5);
1307  CMovableButton* itemButton85 = new CMovableButton( m_panel_removed, ID_BUTTON85, _("Remove Illegal Quals"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1308  m_SizerRemoved->Add(itemButton85, 0, wxALL, 5);
1309  CMovableButton* itemButton86 = new CMovableButton( m_panel_removed, ID_BUTTON86, _("Parse Text"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1310  m_SizerRemoved->Add(itemButton86, 0, wxALL, 5);
1311  CMovableButton* itemButton87 = new CMovableButton( m_panel_removed, ID_BUTTON87, _("WrongQuals to Note"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1312  m_SizerRemoved->Add(itemButton87, 0, wxALL, 5);
1313  CMovableButton* itemButton88 = new CMovableButton( m_panel_removed, ID_BUTTON88, _("Parse Defline"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1314  m_SizerRemoved->Add(itemButton88, 0, wxALL, 5);
1315  CMovableButton* itemButton89 = new CMovableButton( m_panel_removed, ID_BUTTON89, _("Edit Location"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1316  m_SizerRemoved->Add(itemButton89, 0, wxALL, 5);
1317  CMovableButton* itemButton90 = new CMovableButton( m_panel_removed, ID_BUTTON90, _("Table Reader"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1318  m_SizerRemoved->Add(itemButton90, 0, wxALL, 5);
1319  CMovableButton* itemButton91 = new CMovableButton( m_panel_removed, ID_BUTTON91, _("Bulk Edit Source"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1320  m_SizerRemoved->Add(itemButton91, 0, wxALL, 5);
1321  CMovableButton* itemButton92 = new CMovableButton( m_panel_removed, ID_BUTTON92, _("Edit Mol Info"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1322  m_SizerRemoved->Add(itemButton92, 0, wxALL, 5);
1323  CMovableButton* itemButton93 = new CMovableButton( m_panel_removed, ID_BUTTON93,_("Auto_Def"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1324  m_SizerRemoved->Add(itemButton93, 0, wxALL, 5);
1325  CMovableButton* itemButton94 = new CMovableButton( m_panel_removed, ID_BUTTON94, _("Auto_Def Options"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1326  m_SizerRemoved->Add(itemButton94, 0, wxALL, 5);
1327  CMovableButton* itemButton95 = new CMovableButton( m_panel_removed, ID_BUTTON95,_("Ad_misc"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1328  m_SizerRemoved->Add(itemButton95, 0, wxALL, 5);
1329  CMovableButton* itemButton96 = new CMovableButton( m_panel_removed, ID_BUTTON96, _("Ad_ID"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1330  m_SizerRemoved->Add(itemButton96, 0, wxALL, 5);
1331  CMovableButton* itemButton97 = new CMovableButton( m_panel_removed, ID_BUTTON97, _("Remove Wrong Quals"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1332  m_SizerRemoved->Add(itemButton97, 0, wxALL, 5);
1333  CMovableButton* itemButton98 = new CMovableButton( m_panel_removed, ID_BUTTON98, _("Group Explode"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1334  m_SizerRemoved->Add(itemButton98, 0, wxALL, 5);
1335  CMovableButton* itemButton99 = new CMovableButton( m_panel_removed, ID_BUTTON99, _("Rm Text In String"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1336  m_SizerRemoved->Add(itemButton99, 0, wxALL, 5);
1337  CMovableButton* itemButton100 = new CMovableButton( m_panel_removed, ID_BUTTON100, _("Find ASN.1"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1338  m_SizerRemoved->Add(itemButton100, 0, wxALL, 5);
1339  CMovableButton* itemButton101 = new CMovableButton( m_panel_removed, ID_BUTTON101, _("Remove Dup Feats"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1340  m_SizerRemoved->Add(itemButton101, 0, wxALL, 5);
1341  CMovableButton* itemButton102 = new CMovableButton( m_panel_removed, ID_BUTTON102, _("Rm WrongIllegal Qual"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1342  m_SizerRemoved->Add(itemButton102, 0, wxALL, 5);
1343  CMovableButton* itemButton103 = new CMovableButton( m_panel_removed, ID_BUTTON103, _("Edit Struct Field"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1344  m_SizerRemoved->Add(itemButton103, 0, wxALL, 5);
1345  CMovableButton* itemButton110 = new CMovableButton( m_panel_removed, ID_BUTTON110, _("Update SeqClip"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1346  m_SizerRemoved->Add(itemButton110, 0, wxALL, 5);
1347  CMovableButton* itemButton113 = new CMovableButton( m_panel_removed, ID_BUTTON113, _("Remove Unverified"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1348  m_SizerRemoved->Add(itemButton113, 0, wxALL, 5);
1349  CMovableButton* itemButton125 = new CMovableButton(m_panel_removed, ID_BUTTON125, _("Feature Table"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1350  m_SizerRemoved->Add(itemButton125, 0, wxALL, 5);
1351  CMovableButton* itemButton127 = new CMovableButton(m_panel_removed, ID_BUTTON127, _("Update MultSeqClip"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1352  m_SizerRemoved->Add(itemButton127, 0, wxALL, 5);
1353  CMovableButton* itemButton132 = new CMovableButton(m_panel_removed, ID_BUTTON132, _("*Autofix WGS"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1354  m_SizerRemoved->Add(itemButton132, 0, wxALL, 5);
1355  CMovableButton* itemButton133 = new CMovableButton(m_panel_removed, ID_BUTTON133, _("Auto_Def Refresh"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1356  m_SizerRemoved->Add(itemButton133, 0, wxALL, 5);
1357  CMovableButton* itemButton134 = new CMovableButton( m_panel_removed, ID_BUTTON134, _("Mega Report"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1358  m_SizerRemoved->Add(itemButton134, 0, wxALL, 5);
1359  CMovableButton* itemButton137 = new CMovableButton(m_panel_removed, ID_BUTTON137, _("Autofix-R"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1360  m_SizerRemoved->Add(itemButton137, 0, wxALL, 5);
1361  CMovableButton* itemButton138 = new CMovableButton(m_panel_removed, ID_BUTTON138, _("Import Feature Table"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1362  m_SizerRemoved->Add(itemButton138, 0, wxALL, 5);
1363  CMovableButton* itemButton140 = new CMovableButton(m_panel_removed, ID_BUTTON140, _("Desktop"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1364  m_SizerRemoved->Add(itemButton140, 0, wxALL, 5);
1365  CMovableButton* itemButton142 = new CMovableButton(m_panel_removed, ID_BUTTON142, _("Cleanup"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1366  m_SizerRemoved->Add(itemButton142, 0, wxALL, 5);
1367  CMovableButton* itemButton149 = new CMovableButton(m_panel_removed, ID_BUTTON149, _("BARCODE"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1368  m_SizerRemoved->Add(itemButton149, 0, wxALL, 5);
1369  CMovableButton* itemButton150 = new CMovableButton(m_panel_removed, ID_BUTTON150, _("Trim Term Ns"), wxDefaultPosition, wxSize(BUTTON_WIDTH,BUTTON_HEIGHT) );
1370  m_SizerRemoved->Add(itemButton150, 0, wxALL, 5);
1371  CMovableButton* itemButton156 = new CMovableButton(m_panel_removed, ID_BUTTON156, _("Edit Sequence"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1372  m_SizerRemoved->Add(itemButton156, 0, wxALL, 5);
1373  CMovableButton* itemButton159 = new CMovableButton(m_panel_removed, ID_BUTTON159, _("Macro Editor"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1374  m_SizerRemoved->Add(itemButton159, 0, wxALL, 5);
1375  CMovableButton* itemButton160 = new CMovableButton(m_panel_removed, ID_BUTTON160, _("Import Features (Clipboard)"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1376  m_SizerRemoved->Add(itemButton160, 0, wxALL, 5);
1377  CMovableButton* itemButton171 = new CMovableButton(m_panel_removed, ID_BUTTON171, _("*Autofix TSA"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1378  m_SizerRemoved->Add(itemButton171, 0, wxALL, 5);
1379  CMovableButton* itemButton172 = new CMovableButton(m_panel_removed, ID_BUTTON172, _("Save ASN.1"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1380  m_SizerRemoved->Add(itemButton172, 0, wxALL, 5);
1381  CMovableButton* itemButton173 = new CMovableButton(m_panel_removed, ID_BUTTON173, _("Apply Dbxrefs"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1382  m_SizerRemoved->Add(itemButton173, 0, wxALL, 5);
1383  CMovableButton* itemButton174 = new CMovableButton(m_panel_removed, ID_BUTTON174, _("Bulk Edit MiscFeat"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1384  m_SizerRemoved->Add(itemButton174, 0, wxALL, 5);
1385  CMovableButton* itemButton175 = new CMovableButton(m_panel_removed, ID_BUTTON175, _("Remove Unreviewed"), wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1386  m_SizerRemoved->Add(itemButton175, 0, wxALL, 5);
1387 
1388 
1390  m_SizerRemoved->Add(itemButton15, 0, wxALL, 5);
1391 
1392 ////@end CEditingBtnsPanel content construction
1393 
1394  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
1395  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALL|wxEXPAND, 0);
1396 
1397  m_CheckBox = new wxCheckBox( itemPanel1, ID_CHECKBOX_COLLAPSE, _("Lock layout"));
1398  m_CheckBox->SetValue(true);
1399  itemBoxSizer2->Add(m_CheckBox, 0, wxALIGN_LEFT|wxALL, 5);
1400 
1401  m_resetTabsButton = new wxButton( itemPanel1, ID_RESET_TABS, _("Reset Layout"), wxDefaultPosition, wxDefaultSize );
1402  m_resetTabsButton->Enable(false);
1403  itemBoxSizer2->Add(m_resetTabsButton, 0, wxALIGN_LEFT|wxALL, 5);
1404 
1405  m_importTabsButton = new wxButton( itemPanel1, ID_IMPORT_TABS, _("Import Layout"), wxDefaultPosition, wxDefaultSize );
1406  m_importTabsButton->Enable(false);
1407  itemBoxSizer2->Add(m_importTabsButton, 0, wxALIGN_LEFT|wxALL, 5);
1408 
1409  m_exportTabsButton = new wxButton( itemPanel1, ID_EXPORT_TABS, _("Export Layout"), wxDefaultPosition, wxDefaultSize );
1410  m_exportTabsButton->Enable(false);
1411  itemBoxSizer2->Add(m_exportTabsButton, 0, wxALIGN_LEFT|wxALL, 5);
1412 
1413  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
1414  itemBoxSizer1->Add(itemBoxSizer3, 0, wxALL|wxEXPAND, 0);
1415 
1416  m_AutoStart = new wxCheckBox( itemPanel1, ID_CHECKBOX_AUTOSTART, _("Auto start"));
1417  m_AutoStart->SetValue(false);
1418  itemBoxSizer3->Add(m_AutoStart, 0, wxALIGN_LEFT|wxALL, 5);
1419 
1420  m_findButton = new wxSearchCtrl( itemPanel1, ID_FIND_BUTTON,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_PROCESS_ENTER);// _("Find"), wxDefaultPosition, wxDefaultSize );
1421  m_findButton->Enable(false);
1422  m_findButton->ShowSearchButton(true);
1423  m_findButton->ShowCancelButton(true);
1424  itemBoxSizer3->Add(m_findButton, 0, wxALIGN_LEFT|wxALL, 5);
1425 
1426  m_AddMacroButton = new wxButton( itemPanel1, ID_ADD_MACRO, _("Add Macro"), wxDefaultPosition, wxDefaultSize );
1427  m_AddMacroButton->Enable(false);
1428  itemBoxSizer3->Add(m_AddMacroButton, 0, wxALIGN_LEFT|wxALL, 5);
1429 
1430  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
1431  itemBoxSizer1->Add(itemBoxSizer4, 0, wxALL|wxEXPAND, 0);
1432 
1433  wxHyperlinkCtrl* itemHyperLink1 = new wxHyperlinkCtrl(itemPanel1, ID_SET_BG_COLOR, wxT("Set Background"), wxT(""));
1434  itemHyperLink1->SetVisitedColour(itemHyperLink1->GetNormalColour());
1435  itemBoxSizer4->Add(itemHyperLink1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
1436 
1437  wxHyperlinkCtrl* itemHyperLink2 = new wxHyperlinkCtrl(itemPanel1, ID_RESET_BG_COLOR, wxT("Reset Background"), wxT(""));
1438  itemHyperLink2->SetVisitedColour(itemHyperLink2->GetNormalColour());
1439  itemBoxSizer4->Add(itemHyperLink2, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
1440 
1441 
1442  wxSizerItemList& children1 = m_SizerRemoved->GetChildren();
1443  for (wxSizerItemList::iterator child = children1.begin(); child != children1.end(); ++child)
1444  {
1445  wxWindow* w = (*child)->GetWindow();
1446  if (w)
1447  {
1448  IMovableButton* button = dynamic_cast<IMovableButton*>(w);
1449  if (button)
1450  {
1452  button->SetRemoved(true);
1453  m_all_buttons.push_back(button);
1454  }
1455  }
1456  }
1459 }
1460 
1461 
1463 {
1464  m_panel_removed->Scroll(0,0);
1465  m_SizerRemoved->Clear();
1466  bool first = true;
1467  for (unsigned int i=0; i<m_all_buttons.size(); i++)
1468  {
1469  if (m_all_buttons[i]->GetLabel()[0].GetValue() == '*' && first)
1470  {
1471  wxStaticLine *hl = new wxStaticLine (m_all_buttons[i]->GetParent(),wxID_ANY,wxDefaultPosition,wxSize(2*BUTTON_WIDTH,1),wxLI_HORIZONTAL,wxStaticLineNameStr);
1472  m_SizerRemoved->Add(hl, 1, wxALL, DIST_BETWEEN_BUTTONS);
1473  first = false;
1474  }
1475  m_all_buttons[i]->Show();
1477  }
1478 }
1479 
1480 
1481 /*!
1482  * Transfer data to the window
1483  */
1484 
1486 {
1487  return wxFrame::TransferDataToWindow();
1488 }
1489 
1490 void CEditingBtnsPanel::x_LockButtons(wxSizer *sizer, bool locked)
1491 {
1492  wxSizerItemList& children = sizer->GetChildren();
1493  for (wxSizerItemList::iterator child = children.begin(); child != children.end(); ++child)
1494  {
1495  wxWindow* w = (*child)->GetWindow();
1496  if (w)
1497  {
1498  IMovableButton* button = dynamic_cast<IMovableButton*>(w);
1499  if (button)
1500  {
1501  button->SetLocked(locked);
1502 
1503  }
1504  }
1505  }
1506 }
1507 
1508 void CEditingBtnsPanel::OnClickLock( wxCommandEvent& event )
1509 {
1510  bool locked = m_CheckBox->GetValue();
1511  x_LockButtons(m_Sizer1,locked);
1512  x_LockButtons(m_Sizer2,locked);
1513  x_LockButtons(m_Sizer3,locked);
1514  x_LockButtons(m_SizerRemoved,locked);
1515  m_resetTabsButton->Enable(!locked);
1516  m_importTabsButton->Enable(!locked);
1517  m_exportTabsButton->Enable(!locked);
1518 
1519  if (m_Notebook->GetSelection() == m_Notebook->GetPageCount() - 1)
1520  {
1521  m_findButton->Enable(!locked);
1522  m_AddMacroButton->Enable(!locked);
1523  }
1524  if (locked)
1525  SaveSettings();
1526 }
1527 
1528 void CEditingBtnsPanel::OnNotebookTabChanged(wxBookCtrlEvent &event) // TODO search window placement on resize/move
1529 {
1530  if (m_Notebook)
1531  {
1532  int old = event.GetOldSelection();
1533 
1534  if (old >=0)
1535  {
1536  wxWindow *win = m_Notebook->GetPage(old);
1537  CButtonPanel * panel = dynamic_cast<CButtonPanel*>(win);
1538  if (panel)
1539  {
1540  panel->Scroll(0,0);
1541  }
1542  }
1543  int current = event.GetSelection();
1544  if (current >= 0)
1545  {
1546  if (current == m_Notebook->GetPageCount() - 1 && m_CheckBox)
1547  {
1548  bool locked = m_CheckBox->GetValue();
1549  if (m_findButton)
1550  m_findButton->Enable(!locked);
1551  if (m_AddMacroButton)
1552  m_AddMacroButton->Enable(!locked);
1553  }
1554  else
1555  {
1556  if ( m_findButton )
1557  m_findButton->Enable(false);
1558  if ( m_AddMacroButton )
1559  m_AddMacroButton->Enable(false);
1560  }
1561  }
1562  }
1563  event.Skip();
1564 }
1565 
1566 void CEditingBtnsPanel::OnChar(wxKeyEvent& evt)
1567 {
1568  bool found = false;
1569  if (m_Notebook)
1570  {
1571  int sel = m_Notebook->GetSelection();
1572  if (sel != wxNOT_FOUND)
1573  {
1574  wxWindow *win = m_Notebook->GetPage(sel);
1575  CButtonPanel * panel = dynamic_cast<CButtonPanel*>(win);
1576  if (panel)
1577  found = panel->OnChar(evt);
1578  }
1579  }
1580  if (!found)
1581  evt.Skip();
1582 }
1583 
1584 
1585 void CEditingBtnsPanel::OnResetTabs ( wxCommandEvent& event)
1586 {
1588  ResetTabs();
1589 }
1590 
1592 {
1593  vector<wxSizer*> sizers;
1594  sizers.push_back(m_Sizer1);
1595  sizers.push_back(m_Sizer2);
1596  sizers.push_back(m_Sizer3);
1597  vector<IMovableButton*> buttons;
1598  for (unsigned int i=0; i<sizers.size(); i++)
1599  {
1600  wxSizer *sz = sizers[i];
1601  if (sz)
1602  {
1603  CButtonPanel * panel = dynamic_cast<CButtonPanel*>(sz->GetContainingWindow());
1604  if (panel)
1605  {
1606  panel->Scroll(0,0);
1607  panel->SetMovingButton(NULL,false);
1608  }
1609  wxSizerItemList& children = sz->GetChildren();
1610  for (wxSizerItemList::iterator child = children.begin(); child != children.end(); ++child)
1611  {
1612  wxWindow* w = (*child)->GetWindow();
1613  if (w)
1614  {
1615  IMovableButton* button = dynamic_cast<IMovableButton*>(w);
1616  if (button)
1617  buttons.push_back(button);
1618  }
1619  }
1620 
1621  }
1622  }
1623 
1624  for (unsigned int i=0; i<buttons.size(); i++)
1625  buttons[i]->DeleteButton();
1626 
1627  for (unsigned int i=0; i<m_all_buttons.size(); i++)
1628  m_all_buttons[i]->Show();
1629  m_findButton->Clear();
1630 }
1631 
1632 void CEditingBtnsPanel::OnFindButton ( wxCommandEvent& event)
1633 {
1634  wxString str = event.GetString().Lower();
1635  if (!str.IsEmpty())
1636  {
1637  for (unsigned int i=0; i<m_all_buttons.size(); i++)
1638  {
1639  wxString label = m_all_buttons[i]->GetLabel();
1640  if (label.Lower().Find(str) == wxNOT_FOUND)
1641  m_all_buttons[i]->Hide();
1642  }
1643  }
1644  event.Skip();
1645 }
1646 
1647 void CEditingBtnsPanel::OnCancelFindButton ( wxCommandEvent& event)
1648 {
1649  for (unsigned int i=0; i<m_all_buttons.size(); i++)
1650  m_all_buttons[i]->Show();
1651  event.Skip();
1652 }
1653 
1655 {
1656  ResetTabs();
1657 
1658  for (auto btn : m_dynamic_buttons_filename)
1659  {
1660  int button_id = btn.first;
1661  string filename = btn.second;
1662  wxString button_name = wxString(m_dynamic_buttons_name[button_id]);
1663  bool report_required = (m_dynamic_buttons_title.find(button_id) != m_dynamic_buttons_title.end());
1664 
1665  CMovableButton* button = new CMovableButton(m_panel_removed, button_id, _("*") + button_name, wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1667  button->AddDynamicMenu();
1668  button->SetRemoved(true);
1669  button->SetLocked(m_CheckBox->GetValue());
1670  if (report_required)
1671  {
1672  Connect(button_id, wxEVT_BUTTON, wxCommandEventHandler(CEditingBtnsPanel::RunMacroWithReport), NULL, this);
1673  }
1674  else
1675  {
1676  Connect(button_id, wxEVT_BUTTON, wxCommandEventHandler(CEditingBtnsPanel::RunMacro), NULL, this);
1677  }
1678  m_all_buttons.push_back(button);
1679  }
1682  Layout();
1683  m_panel_removed->FitInside();
1684 
1685  map<int,IMovableButton*> id_to_win;
1686  wxSizerItemList& children = m_SizerRemoved->GetChildren();
1687  for (wxSizerItemList::iterator child = children.begin(); child != children.end(); ++child)
1688  {
1689  wxWindow* w = (*child)->GetWindow();
1690  if (w)
1691  {
1692  IMovableButton* button = dynamic_cast<IMovableButton*>(w);
1693  if (button)
1694  id_to_win[button->GetOrigId()] = button;
1695  }
1696  }
1697 
1698 
1699  for (map<int,vector<pair<int, wxPoint> > >::const_iterator i = m_MovableButtonPosition.begin(); i != m_MovableButtonPosition.end(); i++)
1700  {
1701  int win_id = i->first;
1702  CButtonPanel *win = dynamic_cast<CButtonPanel*>(FindWindow(win_id));
1703  if (win)
1704  {
1705  for (vector<pair<int,wxPoint> >::const_iterator j = i->second.begin(); j != i->second.end(); ++j)
1706  {
1707  int x = j->second.x;
1708  int y = j->second.y;
1709  int id = j->first;
1710  IMovableButton *parent_button = id_to_win[id];
1711  if (parent_button)
1712  {
1713  IMovableButton *button = win->CreateButton(parent_button,x,y);
1714  if (button)
1715  {
1717  button->SetLocked(m_CheckBox->GetValue());
1718  if (button->IsOccupiedPosition())
1719  {
1720  wxPoint p = parent_button->FindUnoccupiedPosition(win->GetSizer());
1721  button->SetPosition(win->CalcScrolledPosition(p));
1722  button->SetOriginalPosition(p);
1723  }
1724  }
1725  }
1726  }
1727  win->Layout();
1728  }
1729  }
1730 // m_findButton->Hide();
1731 }
1732 
1734 {
1735  if (m_FrameSize != wxDefaultSize)
1736  SetSize(m_FrameSize);
1737  SetPosition(m_FramePosition); // For dual display may need wxDisplay and this comments: https://forums.wxwidgets.org/viewtopic.php?t=9100&highlight=dual+monitor
1738  // https://forums.wxwidgets.org/viewtopic.php?t=18353
1739 }
1740 
1741 static const char* kSettingsVersion = "VERSION";
1742 static const char* kCoordsArray = "Button Coordinates";
1743 static const char* kFrameWidth = "Frame Width";
1744 static const char* kFrameHeight = "Frame Height";
1745 static const char* kFramePosX = "Frame Position X";
1746 static const char* kFramePosY = "Frame Position Y";
1747 static const char* kAutoStart = "Auto Start";
1748 static const char* kEditingButtonsPanelLayout = "EditingButtonsLayout";
1749 static const char* kBGColor = "BG Color";
1750 static const char* kBGColorSet = "BG Color Set";
1751 static const char* kDynIdsArray = "Dynamic Button Ids";
1752 static const char* kFilenamesArray = "Dynamic Button Filenames";
1753 static const char* kNamesArray = "Dynamic Button Names";
1754 static const char* kTitlesArray = "Dynamic Button Report Titles";
1755 
1756 void CEditingBtnsPanel::SetRegistryPath(const string& reg_path)
1757 {
1759 }
1760 
1762 {
1763  wxString path = CSysPath::ResolvePath( wxT("<home>/toolbar_buttons_layout.asn") );
1764  LoadSettings(path);
1765 }
1766 
1768 {
1769  if (m_RegPath.empty()) return;
1770 
1772 
1773  string action = "Loading toolbar buttons layout registry - ";
1774 
1775  if( !path.empty() ){
1776  if( wxFileName::FileExists( path ) ){
1777  CNcbiIfstream istr( string(path.ToUTF8()) );
1778  if( istr ){
1779  gui_reg.AddSite(istr, CGuiRegistry::ePriority_Local - 2);
1780 
1781  } else {
1782  LOG_POST( Error << action << "registry file is invalid " << path );
1783  }
1784  } else {
1785  LOG_POST( Info << action << "skipping, no file " << path );
1786  }
1787  } else {
1788  LOG_POST( Info << action << "skipping, path is empty." );
1789  }
1790 
1791  CRegistryReadView view = gui_reg.GetReadView(m_RegPath);
1792 
1793  int version = view.GetInt(kSettingsVersion, 1);
1794  vector<int> coords;
1795  view.GetIntVec(kCoordsArray, coords);
1797  if (!coords.empty())
1798  {
1799  unsigned int i = 0;
1800  while ( i < coords.size()-3 )
1801  {
1802  int id = coords[i];
1803  int x = coords[i+1];
1804  int y = coords[i+2];
1805  int win = coords[i+3];
1806  i += 4;
1807  if (version == 1)
1808  m_MovableButtonPosition[win].push_back(pair<int,wxPoint>(id,wxPoint(x,y)));
1809  else
1811  }
1812  }
1813 
1814 
1815  int width = 600,height = 400;
1816  width = view.GetInt(kFrameWidth,width);
1817  height = view.GetInt(kFrameHeight,height);
1818  m_FrameSize = wxSize(width,height);
1819  int pos_x = 5, pos_y = 5;
1820  pos_x = view.GetInt(kFramePosX,pos_x);
1821  pos_y = view.GetInt(kFramePosY,pos_y);
1822 
1823  int max_x = 0;
1824  for (unsigned int i = 0; i < wxDisplay::GetCount(); i++) // also see gui/widgets/wx/wx_utils.cpp:CorrectWindowRect() for alternative window position validation
1825  {
1826  wxDisplay display(i);
1827  max_x += display.GetGeometry().GetWidth();
1828  }
1829  if (pos_x + width > max_x) pos_x = wxGetDisplaySize().GetWidth()-width-5;
1830  if (pos_x < 0) pos_x = 5;
1831  if (pos_y + height > wxGetDisplaySize().GetHeight()) pos_y = wxGetDisplaySize().GetHeight()-height-5;
1832  if (pos_y < 0) pos_y = 5;
1833  m_FramePosition = wxPoint(pos_x,pos_y);
1834 
1835  if (m_AutoStart)
1836  m_AutoStart->SetValue(view.GetBool(kAutoStart));
1837  m_bg_color_set = view.GetBool(kBGColorSet, false);
1838  m_bg_color = wxColour(wxString(view.GetString(kBGColor, "white")));
1839 
1840  vector<int> ids;
1841  view.GetIntVec(kDynIdsArray, ids);
1842  vector<string> filenames;
1844  vector<string> button_names;
1845  view.GetStringVec(kNamesArray, button_names);
1846  vector<string> titles;
1847  view.GetStringVec(kTitlesArray, titles);
1848 
1852 
1853  RemoveStaticButtons(ids, filenames, button_names, titles);
1854  if (RunningInsideNCBI()) {
1856  }
1857 
1858  for (size_t i = 0; i < ids.size(); i++)
1859  {
1860  int id = ids[i];
1861  string filename = filenames[i];
1862  string button_name = button_names[i];
1863  string title = titles[i];
1864  m_dynamic_buttons_filename[id] = filename;
1865  m_dynamic_buttons_name[id] = button_name;
1866  if (!title.empty())
1867  m_dynamic_buttons_title[id] = title;
1868  }
1869 }
1870 
1871 void CEditingBtnsPanel::RemoveStaticButtons( vector<int> &ids, vector<string> &filenames, vector<string> &button_names, vector<string> &titles)
1872 {
1873  if (ids.empty())
1874  return;
1875  for (long i = ids.size() - 1; i >= 0; i--)
1876  {
1877  int id = ids[i];
1878  if (id < ID_BUTTON_DYNAMIC)
1879  {
1880  ids.erase(ids.begin() + i);
1881  filenames.erase(filenames.begin() + i);
1882  button_names.erase(button_names.begin() + i);
1883  titles.erase(titles.begin() + i);
1884  }
1885  }
1886 }
1887 
1889 {
1890  wxString path = CSysPath::ResolvePath( wxT("<home>/toolbar_buttons_layout.asn") );
1891  SaveSettings(path);
1892 }
1893 
1894 
1895 void CEditingBtnsPanel::SaveSettings(wxString path) const
1896 {
1897  if (m_RegPath.empty())
1898  return;
1899 
1901 
1902 
1903 
1905  vector<int> coords;
1906 
1907  vector<wxSizer*> sizers;
1908  sizers.push_back(m_Sizer1);
1909  sizers.push_back(m_Sizer2);
1910  sizers.push_back(m_Sizer3);
1911  for (unsigned int i=0; i<sizers.size(); i++)
1912  {
1913  wxSizer *sz = sizers[i];
1914  if (sz)
1915  {
1916  CButtonPanel * panel = dynamic_cast<CButtonPanel*>(sz->GetContainingWindow());
1917  if (panel)
1918  {
1919  wxSizerItemList& children = sz->GetChildren();
1920  for (wxSizerItemList::iterator child = children.begin(); child != children.end(); ++child)
1921  {
1922  wxWindow* w = (*child)->GetWindow();
1923  if (w)
1924  {
1925  IMovableButton* button = dynamic_cast<IMovableButton*>(w);
1926  if (button)
1927  {
1928  coords.push_back(button->GetOrigId());
1929  int col = int (0.5 + double(button->GetOrigPosition().x - DIST_BETWEEN_BUTTONS) / (BUTTON_WIDTH + DIST_BETWEEN_BUTTONS));
1930  int row = int (0.5 + double(button->GetOrigPosition().y - DIST_BETWEEN_BUTTONS) / (BUTTON_HEIGHT + DIST_BETWEEN_BUTTONS));
1931  coords.push_back(col);
1932  coords.push_back(row);
1933  coords.push_back(panel->GetId());
1934  }
1935  }
1936  }
1937  }
1938  }
1939  }
1940 
1941  vector<int> ids;
1942  vector<string> filenames;
1943  vector<string> button_names;
1944  vector<string> titles;
1945  for (auto btn : m_dynamic_buttons_filename)
1946  {
1947  int button_id = btn.first;
1948  string filename = btn.second;
1949  string button_name = m_dynamic_buttons_name[button_id];
1950  string title;
1952  title = m_dynamic_buttons_title[button_id];
1953  ids.push_back(button_id);
1954  filenames.push_back(filename);
1955  button_names.push_back(button_name);
1956  titles.push_back(title);
1957  }
1958 
1959  view.Set(kSettingsVersion, 4);
1960  view.Set(kCoordsArray, coords);
1961  view.Set(kFrameWidth,GetScreenRect().GetWidth());
1962  view.Set(kFrameHeight,GetScreenRect().GetHeight());
1963  view.Set(kFramePosX,GetScreenPosition().x);
1964  view.Set(kFramePosY,GetScreenPosition().y);
1965  view.Set(kAutoStart, m_AutoStart->GetValue());
1967  view.Set(kBGColor, m_bg_color.GetAsString().ToStdString());
1968  view.Set(kDynIdsArray, ids);
1969  view.Set(kFilenamesArray, filenames);
1970  view.Set(kNamesArray, button_names);
1971  view.Set(kTitlesArray, titles);
1972 
1973  if( !path.empty() ){
1974  CNcbiOfstream ostr( string(path.ToUTF8()) );
1975  gui_reg.Write( ostr , CGuiRegistry::ePriority_Local - 2 );
1976  }
1977  else {
1978  LOG_POST( Info << "Saving window layout registry - skipping, path is empty" );
1979  }
1980 }
1981 
1982 void CEditingBtnsPanel::OnAddMacroClick( wxCommandEvent& event )
1983 {
1984  CAddMacroButton dlg(this);
1985  if (dlg.ShowModal() == wxID_OK)
1986  {
1987  wxString button_name = dlg.GetName();
1988  bool report_required = dlg.GetReportRequred();
1989  string filename = dlg.GetFileName();
1990  if (filename.empty())
1991  return;
1992  string title = dlg.GetTitle();
1993  int button_id = ID_BUTTON_DYNAMIC + static_cast<int>(m_dynamic_buttons_filename.size());
1994  CMovableButton* button = new CMovableButton(m_panel_removed, button_id, _("*") + button_name, wxDefaultPosition, wxSize(BUTTON_WIDTH, BUTTON_HEIGHT));
1995  button->SetSizers(this,m_Sizer1,m_Sizer2,m_Sizer3,m_SizerRemoved);
1996  button->AddDynamicMenu();
1997  button->SetRemoved(true);
1998  button->SetLocked(m_CheckBox->GetValue());
1999  if (report_required)
2000  {
2001  Connect(button_id, wxEVT_BUTTON, wxCommandEventHandler(CEditingBtnsPanel::RunMacroWithReport), NULL, this);
2002  m_dynamic_buttons_title[button_id] = title;
2003  }
2004  else
2005  {
2006  Connect(button_id, wxEVT_BUTTON, wxCommandEventHandler(CEditingBtnsPanel::RunMacro), NULL, this);
2007  }
2008  m_dynamic_buttons_filename[button_id] = filename;
2009  m_dynamic_buttons_name[button_id] = button_name;
2010  m_all_buttons.push_back(button);
2013  Layout();
2014  m_panel_removed->FitInside();
2015  int y;
2016  button->GetPosition(NULL, &y);
2017  int py;
2018  m_panel_removed->GetScrollPixelsPerUnit(NULL, &py);
2019  m_panel_removed->Scroll(-1, y / py);
2020  Refresh();
2021  Raise();
2022  button->SetFocus();
2023  }
2024 }
2025 
2027 {
2028  int id = button->GetOrigId();
2030  {
2031  Disconnect(id, wxEVT_BUTTON, wxCommandEventHandler(CEditingBtnsPanel::RunMacroWithReport), NULL, this);
2032  }
2033  else
2034  {
2035  Disconnect(id, wxEVT_BUTTON, wxCommandEventHandler(CEditingBtnsPanel::RunMacro), NULL, this);
2036  }
2040  int pos = -1;
2041  for (size_t i = 0; i < m_all_buttons.size(); i++)
2042  {
2043  if (m_all_buttons[i] == button)
2044  {
2045  pos = static_cast<int>(i);
2046  break;
2047  }
2048  }
2049  if (pos >= 0)
2050  m_all_buttons.erase(m_all_buttons.begin() + pos);
2051  vector<wxSizer *> sizers;
2052  sizers.push_back(m_Sizer1);
2053  sizers.push_back(m_Sizer2);
2054  sizers.push_back(m_Sizer3);
2055  vector<IMovableButton *> buttons;
2056  for (unsigned int i = 0; i < sizers.size(); i++)
2057  {
2058  wxSizer *sz = sizers[i];
2059  if (sz)
2060  {
2061  CButtonPanel * panel = dynamic_cast<CButtonPanel*>(sz->GetContainingWindow());
2062  if (panel)
2063  {
2064  panel->Scroll(0,0);
2065  panel->SetMovingButton(NULL,false);
2066  }
2067  wxSizerItemList& children = sz->GetChildren();
2068  for (wxSizerItemList::iterator child = children.begin(); child != children.end(); ++child)
2069  {
2070  wxWindow* w = (*child)->GetWindow();
2071  if (w)
2072  {
2073  IMovableButton* btn = dynamic_cast<IMovableButton*>(w);
2074  if (btn->GetOrigId() == id)
2075  buttons.push_back(btn);
2076  }
2077  }
2078 
2079  }
2080  }
2081 
2082  for (size_t i=0; i<buttons.size(); i++)
2083  buttons[i]->Destroy();
2084 
2085  m_SizerRemoved->Detach(button);
2086  button->Destroy();
2087  Layout();
2088  Refresh();
2089  m_panel_removed->FitInside();
2090 }
2091 
2093 {
2094  int id = button->GetOrigId();
2096  return;
2097 
2098  wxWindow* main_window = NULL;
2099  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
2100  if (wb_frame)
2101  main_window = wb_frame->GetMainWindow();
2102 
2103  CRef<IGuiCoreHelper> gui_core_helper(new CGuiCoreHelper(m_Workbench));
2104  CMacroFlowEditor *frame = CMacroFlowEditor::GetInstance(main_window, gui_core_helper);
2105  frame->OpenScript(m_dynamic_buttons_filename[id], false, true);
2106 }
2107 
2108 void CEditingBtnsPanel::OnExportBtnClick( wxCommandEvent& event )
2109 {
2110  wxFileDialog asn_save_file(this, wxT("Export settings to file"), wxEmptyString, wxEmptyString,
2113  wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
2114 
2115  if (asn_save_file.ShowModal() == wxID_OK)
2116  {
2117  wxString path = asn_save_file.GetPath();
2118  if( !path.empty() )
2119  SaveSettings(path);
2120  }
2121 }
2122 
2123 void CEditingBtnsPanel::OnImportBtnClick( wxCommandEvent& event )
2124 {
2125  wxFileDialog asn_save_file(this, wxT("Import settings from file"), wxEmptyString, wxEmptyString,
2128  wxFD_OPEN|wxFD_FILE_MUST_EXIST);
2129 
2130  if (asn_save_file.ShowModal() == wxID_OK)
2131  {
2132  wxString path = asn_save_file.GetPath();
2133  if( !path.empty() )
2134  {
2135  LoadSettings(path);
2137  PlaceButtons();
2138  }
2139  }
2140 }
2141 
2142 
2143 /*!
2144  * Should we show tooltips?
2145  */
2146 
2148 {
2149  return true;
2150 }
2151 
2152 /*!
2153  * Get bitmap resources
2154  */
2155 
2156 wxBitmap CEditingBtnsPanel::GetBitmapResource( const wxString& name )
2157 {
2158  // Bitmap retrieval
2159 ////@begin CEditingBtnsPanel bitmap retrieval
2160  wxUnusedVar(name);
2161  return wxNullBitmap;
2162 ////@end CEditingBtnsPanel bitmap retrieval
2163 }
2164 
2165 /*!
2166  * Get icon resources
2167  */
2168 
2169 wxIcon CEditingBtnsPanel::GetIconResource( const wxString& name )
2170 {
2171  // Icon retrieval
2172 ////@begin CEditingBtnsPanel icon retrieval
2173  wxUnusedVar(name);
2174  return wxNullIcon;
2175 ////@end CEditingBtnsPanel icon retrieval
2176 }
2177 
2178 
2180 {
2181  m_TopSeqEntry.Reset();
2182  m_WorkDir.Clear();
2185  m_Locations.clear();
2186  if (!m_Workbench) return false;
2187 
2190  if (sel_srv)
2191  {
2192  sel_srv->GetActiveObjects(objects);
2193  }
2194  if (objects.empty())
2195  {
2197  }
2199  const CSeq_submit* const_sub = dynamic_cast<const CSeq_submit*>((*it).object.GetPointer());
2200  if (const_sub) {
2201  // CSeq_submit* sub = const_cast<CSeq_submit*>(const_sub);
2202  m_SeqSubmit.Reset(const_sub);
2203  }
2204 
2205  if (!m_TopSeqEntry) {
2207  if (seh) {
2208  m_TopSeqEntry = seh;
2209  if (m_SeqSubmit) {
2210  break;
2211  }
2212  }
2213  }
2214  }
2215 
2216  if (!m_TopSeqEntry) return false;
2218  if (srv)
2219  {
2220  CRef<CGBWorkspace> ws = srv->GetGBWorkspace();
2221  if (!ws) return false;
2222 
2223  CGBDocument* doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(m_TopSeqEntry.GetScope()));
2224  if (doc) {
2225  m_CmdProccessor = &doc->GetUndoManager();
2226  m_WorkDir = doc->GetWorkDir();
2227  }
2228  }
2229 
2230  if (!m_CmdProccessor) return false;
2231 
2232  return true;
2233 }
2234 
2236 {
2237  m_Locations.clear();
2239  return !m_Locations.empty();
2240 }
2241 
2243 {
2244  vector<CRef<CSeq_loc> > locs = x_GetSelectedLocations();
2245  m_Locations.clear();
2246  ITERATE(vector<CRef<CSeq_loc> >, lit, locs) {
2247  CScope& scope = m_TopSeqEntry.GetScope();
2248  CBioseq_Handle bsh = scope.GetBioseqHandle(**lit);
2249  if (bsh) {
2250  if (bsh.IsAa()) { // For Prot commands
2251  m_Locations.push_back(*lit);
2252  }
2253  }
2254  }
2255  return !m_Locations.empty();
2256 }
2257 
2259 {
2260  vector<CRef<CSeq_loc> > locs = x_GetSelectedLocations();
2261 
2262  m_Locations.clear();
2263  ITERATE(vector<CRef<CSeq_loc> >, lit, locs) {
2264  CScope& scope = m_TopSeqEntry.GetScope();
2265  CBioseq_Handle bsh = scope.GetBioseqHandle(**lit);
2266  if (bsh) {
2267  if (bsh.IsNa()) { // For Nuc commands
2268  m_Locations.push_back(*lit);
2269  }
2270  }
2271  }
2272  return !m_Locations.empty();
2273 }
2274 
2276 {
2277  vector<CRef<CSeq_loc> > locs;
2278  if (!m_Workbench) {
2279  return locs;
2280  }
2281 
2284  if (!sel_srv) return locs;
2285  sel_srv->GetCurrentSelection(objects);
2286  if (objects.empty())
2287  {
2288  sel_srv->GetActiveObjects(objects);
2289  }
2290  if (objects.empty())
2291  {
2293  }
2294 
2295  if (objects.empty()) return locs;
2296 
2297 
2299  const CObject* ptr = it->object.GetPointer();
2300 
2301  /// CSeq_entry
2302  const objects::CSeq_feat* seqfeat = dynamic_cast<const objects::CSeq_feat*>(ptr);
2303  const objects::CSeq_loc* seqloc = dynamic_cast<const objects::CSeq_loc*>(ptr);
2304  const objects::CBioseq* bioseq = dynamic_cast<const objects::CBioseq*>(ptr);
2305  const objects::CSeqdesc* seqdesc = dynamic_cast<const objects::CSeqdesc*>(ptr);
2306  const objects::CPubdesc* pubdesc = dynamic_cast<const objects::CPubdesc*>(ptr);
2307  const objects::CSeq_id* seq_id = dynamic_cast<const objects::CSeq_id*>(ptr);
2308 
2309  if (seqfeat) {
2310  if (seqfeat->IsSetLocation()) {
2311  CRef<CSeq_loc> loc(new CSeq_loc());
2312  loc->Assign(seqfeat->GetLocation());
2313  locs.push_back(loc);
2314  }
2315  } else if (seq_id) {
2316  CBioseq_Handle bsh = it->scope->GetBioseqHandle(*seq_id);
2317  if (bsh) {
2318  CRef<CSeq_id> new_id(new CSeq_id());
2319  new_id->Assign(*seq_id);
2320  CRef<CSeq_loc> loc(new CSeq_loc(*new_id, 0, bsh.GetInst_Length() - 1));
2321  locs.push_back(loc);
2322  }
2323  } else if (seqloc) {
2324  CRef<CSeq_loc> loc(new CSeq_loc());
2325  loc->Assign(*seqloc);
2326  locs.push_back(loc);
2327  } else if (bioseq) {
2328  CRef<CSeq_loc> loc(new CSeq_loc());
2329  loc->SetInt().SetId().Assign(*(bioseq->GetId().front()));
2330  loc->SetInt().SetFrom(0);
2331  loc->SetInt().SetTo(bioseq->GetLength() - 1);
2332  locs.push_back(loc);
2333  } else if (seqdesc) {
2334  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(it->scope, *seqdesc);
2335  CBioseq_CI bi(seh);
2336  while (bi) {
2337  CRef<CSeq_loc> loc(new CSeq_loc());
2338  loc->SetInt().SetId().Assign(*(bi->GetId().front().GetSeqId()));
2339  loc->SetInt().SetFrom(0);
2340  loc->SetInt().SetTo(bi->GetInst_Length() - 1);
2341  locs.push_back(loc);
2342  ++bi;
2343  }
2344  } else if (pubdesc) {
2345  CSeq_entry_Handle seh = GetSeqEntryForPubdesc(it->scope, *pubdesc);
2346  CBioseq_CI bi(seh);
2347  while (bi) {
2348  CRef<CSeq_loc> loc(new CSeq_loc());
2349  loc->SetInt().SetId().Assign(*(bi->GetId().front().GetSeqId()));
2350  loc->SetInt().SetFrom(0);
2351  loc->SetInt().SetTo(bi->GetInst_Length() - 1);
2352  locs.push_back(loc);
2353  ++bi;
2354  }
2355  }
2356  }
2357  if (!m_TopSeqEntry && !locs.empty()) {
2358  CBioseq_Handle bsh = objects.front().scope->GetBioseqHandle(*(locs.front()->GetId()));
2360  }
2361 
2362  if (m_TopSeqEntry && m_Workbench)
2363  {
2365  if (srv)
2366  {
2367  CRef<CGBWorkspace> ws = srv->GetGBWorkspace();
2368  if (ws)
2369  {
2370  CGBDocument* doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(m_TopSeqEntry.GetScope()));
2371  if (doc)
2372  m_CmdProccessor = &doc->GetUndoManager();
2373  }
2374  }
2375  }
2376  return locs;
2377 }
2378 
2379 
2380 
2381 /*!
2382  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1
2383  */
2384 
2386 {
2387  CReverseAuthorNames worker;
2388 
2389  CRef<CCmdComposite> composite(new CCmdComposite("Reverse Author Last and First Name"));
2390  bool found = false;
2393  if (sel_srv)
2394  {
2395  sel_srv->GetCurrentSelection(objects);
2396  if (objects.empty())
2397  {
2398  sel_srv->GetActiveObjects(objects);
2399  }
2400  if (objects.empty())
2401  {
2403  }
2404 
2405  if (!objects.empty())
2406  {
2408  {
2409  found |= worker.ApplyToPubdesc(it->object, m_TopSeqEntry, *composite);
2410  }
2411  }
2412  }
2413 
2414  if (found) {
2415  m_CmdProccessor->Execute(composite.GetPointer());
2416  }
2417  else
2418  {
2420  if (cmd) {
2422  }
2423  }
2424 }
2425 
2426 
2427 /*!
2428  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2
2429  */
2430 
2431 void CEditingBtnsPanel::EditPubs( wxCommandEvent& event )
2432 {
2433  CEditPubDlg * dlg = new CEditPubDlg(NULL, m_Workbench);
2434  dlg->Show(true);
2435 }
2436 
2437 
2438 /*!
2439  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON3
2440  */
2441 
2442 void CEditingBtnsPanel::ParseLocalIdToSrc( wxCommandEvent& event )
2443 {
2447  dlg->Show(true);
2448 }
2449 
2450 
2451 /*!
2452  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON4
2453  */
2454 
2455 void CEditingBtnsPanel::OnFixCapitalizationAll( wxCommandEvent& event )
2456 {
2457  CFixAllCap worker;
2459  if (cmd) {
2461  }
2462 }
2463 
2464 
2465 /*!
2466  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON5
2467  */
2468 
2470 {
2471  CFixAuthorCap worker;
2473  if (cmd) {
2475  }
2476 }
2477 
2478 
2479 /*!
2480  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON6
2481  */
2482 
2484 {
2485  CFixTitleCap worker;
2487  if (cmd) {
2489  }
2490 }
2491 
2492 
2493 /*!
2494  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON7
2495  */
2496 
2498 {
2499  CFixAffilCap worker;
2501  if (cmd) {
2503  }
2504 }
2505 
2506 
2507 /*!
2508  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON8
2509  */
2510 
2511 void CEditingBtnsPanel::SortUniqueCount( wxCommandEvent& event )
2512 {
2513  wxWindow* main_window = NULL;
2514  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
2515  if (wb_frame)
2516  main_window = wb_frame->GetMainWindow();
2517 
2518  IRefreshCntrl * suc_refresh = new CSUCRefreshCntrl(m_Workbench);
2519  CGenericReportDlg* report = new CGenericReportDlg(main_window, m_Workbench, wxID_ANY, _("SUC"));
2520  report->SetRefresh(suc_refresh);
2521  report->RefreshData();
2522  report->Show(true);
2523 }
2524 
2525 void CEditingBtnsPanel::ClickableSortUniqueCount( wxCommandEvent& event )
2526 {
2527  wxWindow* main_window = NULL;
2528  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
2529  if (wb_frame)
2530  main_window = wb_frame->GetMainWindow();
2531 
2533  dlg->Show(true);
2534 }
2535 
2536 /*!
2537  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON9
2538  */
2539 
2541 {
2542  CRemoveUnpublishedPubs worker;
2544  if (cmd) {
2546  }
2547 }
2548 
2549 
2550 /*!
2551  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON10
2552  */
2553 
2554 static const char* kFrameDlgWidth = "Frame Width";
2555 static const char* kFrameDlgHeight = "Frame Height";
2556 static const char* kFrameDlgPosX = "Frame Position X";
2557 static const char* kFrameDlgPosY = "Frame Position Y";
2558 
2559 
2560 void CEditingBtnsPanel::SaveSettings(const string &regpath, wxWindow *dlg) const
2561 {
2562  if (regpath.empty() || !dlg)
2563  return;
2564 
2566  CRegistryWriteView view = gui_reg.GetWriteView(regpath);
2567 
2568  view.Set(kFrameDlgWidth, dlg->GetScreenRect().GetWidth());
2569  view.Set(kFrameDlgHeight, dlg->GetScreenRect().GetHeight());
2570  view.Set(kFrameDlgPosX, dlg->GetScreenPosition().x);
2571  view.Set(kFrameDlgPosY, dlg->GetScreenPosition().y);
2572 }
2573 
2574 
2575 void CEditingBtnsPanel::LoadSettings(const string &regpath, wxWindow *dlg)
2576 {
2577  if (regpath.empty() || !dlg)
2578  return;
2579 
2581  CRegistryReadView view = gui_reg.GetReadView(regpath);
2582 
2583  int width = view.GetInt(kFrameDlgWidth, -1);
2584  int height = view.GetInt(kFrameDlgHeight, -1);
2585  if (width >= 0 && height >= 0)
2586  dlg->SetSize(wxSize(width,height));
2587 
2588  int pos_x = view.GetInt(kFrameDlgPosX, -1);
2589  int pos_y = view.GetInt(kFrameDlgPosY, -1);
2590 
2591  if (pos_x >= 0 && pos_y >= 0)
2592  {
2593  size_t max_x = 0;
2594  for (auto i = 0; i < wxDisplay::GetCount(); i++) // also see gui/widgets/wx/wx_utils.cpp:CorrectWindowRect() for alternative window position validation
2595  {
2596  wxDisplay display(i);
2597  max_x += display.GetGeometry().GetWidth();
2598  }
2599  if (pos_x + width > max_x) pos_x = wxGetDisplaySize().GetWidth()-width-5;
2600  if (pos_y + height > wxGetDisplaySize().GetHeight()) pos_y = wxGetDisplaySize().GetHeight()-height-5;
2601 
2602  dlg->SetPosition(wxPoint(pos_x,pos_y));
2603  }
2604  wxTopLevelWindow* top_win = dynamic_cast<wxTopLevelWindow*>(dlg);
2605  if (top_win)
2606  {
2607  wxRect rc = dlg->GetRect();
2608  CorrectWindowRect(top_win, rc);
2609  dlg->SetSize(rc);
2610  dlg->Move(rc.GetLeftTop());
2611  }
2612 }
2613 
2614 void CEditingBtnsPanel::TableReaderFromClipboard( wxCommandEvent& event )
2615 {
2616  CQualTableLoadManager* qual_mgr = NULL;
2617  if (!m_TopSeqEntry || ! m_CmdProccessor) return;
2618 
2619  vector< CIRef<IFileLoadPanelClientFactory> > file_formats;
2620  GetExtensionAsInterface("file_load_panel_client", file_formats);
2621  CIRef<IFileLoadPanelClient> format_manager;
2622 
2623  for (size_t i = 0; i < file_formats.size(); ++i) {
2624  if (file_formats[i]->GetFileLoaderId() == "file_loader_qual_table") {
2625  format_manager.Reset(file_formats[i]->CreateInstance());
2626 
2627  if ("file_loader_qual_table" == format_manager->GetFileLoaderId()) {
2628  const CQualTableLoadManager* const_qual_mgr = dynamic_cast<const CQualTableLoadManager*>(format_manager.GetPointer());
2629  if (const_qual_mgr) {
2630  qual_mgr = const_cast<CQualTableLoadManager*>(const_qual_mgr);
2631  qual_mgr->SetTopLevelEntry(m_TopSeqEntry);
2632  qual_mgr->SetServiceLocator(m_Workbench);
2633  }
2634  }
2635  }
2636  }
2637 
2638 
2639  string fname;
2640  {
2641  wxTextDataObject data;
2642  if (wxTheClipboard->Open())
2643  {
2644  if (wxTheClipboard->IsSupported( wxDF_UNICODETEXT ))
2645  wxTheClipboard->GetData( data );
2646  wxTheClipboard->Close();
2647  }
2648 
2649  if (data.GetText().length() == 0) {
2650  wxMessageBox("No data in clipboard for table");
2651  return;
2652  }
2653 
2655  f.AsOutputFile(CTmpFile::eIfExists_ReturnCurrent) << data.GetText();
2656  fname = f.GetFileName();
2657  }
2658 
2659  vector<wxString> fnames;
2660  fnames.push_back(ToWxString(fname));
2661 
2662  // This also causes windows to be created it seems, and so it must happen after
2663  // create is called....
2664  qual_mgr->SetFilenames(fnames);
2665 
2667  dlg.SetSize(760, 940);
2668  dlg.Centre(wxBOTH | wxCENTRE_ON_SCREEN);
2669  dlg.SetMinSize(wxSize(760, 750));
2670  dlg.SetRegistryPath("Dialogs.Edit.OpenTables");
2671  LoadSettings("Dialogs.Edit.OpenTables", &dlg);
2672 
2673  if (dlg.ShowModal() == wxID_OK) {
2674  qual_mgr->x_GetColumnIdPanel()->x_TableReaderMacro();
2675  }
2676 
2677  CFile tmp_file(fname);
2678  tmp_file.Remove();
2679 
2680  SaveSettings("Dialogs.Edit.OpenTables", &dlg);
2681 }
2682 
2683 
2684 /*!
2685  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON11
2686  */
2687 
2688 void CEditingBtnsPanel::TaxFixCleanup( wxCommandEvent& event )
2689 {
2690  CRef<CCmdComposite> cmd = CleanupCommand(m_TopSeqEntry, true, (event.GetId() == ID_BUTTON11));
2691  if (cmd) {
2693  }
2694 }
2695 
2696 
2697 /*!
2698  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON12
2699  */
2700 
2701 void CEditingBtnsPanel::RemoveAllFeatures( wxCommandEvent& event )
2702 {
2704 }
2705 
2706 /*!
2707  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON13
2708  */
2709 
2710 void CEditingBtnsPanel::OnStripAuthorSuffixes( wxCommandEvent& event )
2711 {
2712  CStripAuthorSuffix worker;
2714  if (cmd) {
2716  }
2717 }
2718 
2719 
2720 /*!
2721  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON14
2722  */
2724 {
2725  CRemoveAuthorConsortium worker;
2727  if (cmd) {
2729  }
2730 }
2731 
2732 /*!
2733  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON16
2734  */
2735 
2736 void CEditingBtnsPanel::TrimNsRich( wxCommandEvent& event )
2737 {
2738  wxWindow* main_window = NULL;
2739  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
2740  if (wb_frame)
2741  main_window = wb_frame->GetMainWindow();
2742 
2743  CTrimN worker;
2744  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Trim Ns Rich", main_window, m_WorkDir))
2745  event.Skip();
2746 }
2747 
2748 void CEditingBtnsPanel::TrimNsTerminal( wxCommandEvent& event )
2749 {
2751  trim_rules.push_back(CSequenceAmbigTrimmer::STrimRule{ 1, 0 });
2752 
2753  wxWindow* main_window = NULL;
2754  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
2755  if (wb_frame)
2756  main_window = wb_frame->GetMainWindow();
2757 
2758  CTrimN worker;
2759  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Trim Ns Terminal", main_window, m_WorkDir, trim_rules))
2760  event.Skip();
2761 }
2762 
2763 
2764 /*!
2765  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON17
2766  */
2767 
2769 {
2771  if (!m_Locations.empty())
2772  {
2773  CBioseq_Handle bsh = m_TopSeqEntry.GetScope().GetBioseqHandle(*m_Locations.front());
2774  seh = bsh.GetSeq_entry_Handle();
2775  }
2776  CRef<CSeqdesc> seqdesc(new CSeqdesc());
2777  seqdesc->SetComment();
2778  CIRef<IEditObject> editor(new CEditObjectSeq_desc(*seqdesc, seh, m_TopSeqEntry.GetScope(), true));
2779  CEditObjViewDlg* edit_dlg = new CEditObjViewDlg(NULL, true);
2780  edit_dlg->SetUndoManager(m_CmdProccessor);
2781  wxWindow* editorWindow = editor->CreateWindow(edit_dlg);
2782  edit_dlg->SetEditorWindow(editorWindow);
2783  edit_dlg->SetEditor(editor);
2784  edit_dlg->SetWorkDir(m_WorkDir);
2785  edit_dlg->Show(true);
2786 }
2787 
2788 
2789 /*!
2790  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON18
2791  */
2792 
2793 void CEditingBtnsPanel::MrnaCds( wxCommandEvent& event )
2794 {
2795  CMRnaForCDS worker;
2796  if (!worker.apply(m_Workbench,m_CmdProccessor,"Create mRNA for CDS",m_TopSeqEntry.GetScope()))
2797  event.Skip();
2798 }
2799 
2800 /*!
2801  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON19
2802  */
2803 
2804 void CEditingBtnsPanel::OnAddCitSubForUpdate( wxCommandEvent& event )
2805 {
2806  CAddCitSubForUpdate worker;
2807  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Add Cit-sub for update"))
2808  event.Skip();
2809 }
2810 
2811 
2812 /*!
2813  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON20
2814  */
2815 
2816 void CEditingBtnsPanel::OnRemoveSequences( wxCommandEvent& event )
2817 {
2818 
2819  wxWindow* main_window = NULL;
2820  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
2821  if (wb_frame)
2822  main_window = wb_frame->GetMainWindow();
2823 
2824  CRemoveSequencesDlg dlg(main_window, m_TopSeqEntry);
2825 
2826  if (dlg.ShowModal() == wxID_OK) {
2828  if (cmd) {
2830  }
2831  }
2832 
2833 
2834 }
2835 
2836 
2837 /*!
2838  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON21
2839  */
2840 
2841 void CEditingBtnsPanel::OnRemoveGenomeProjectsDB( wxCommandEvent& event )
2842 {
2843  CRemoveGenomeProjectsDB worker;
2844  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Remove GenomeProjectsDB"))
2845  event.Skip();
2846 }
2847 
2848 
2849 /*!
2850  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON22
2851  */
2852 
2853 void CEditingBtnsPanel::RemProtTitles( wxCommandEvent& event )
2854 {
2855  CRemProtTitles worker;
2856  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Remove Protein Titles"))
2857  event.Skip();
2858 }
2859 
2860 /*!
2861  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON23
2862  */
2863 
2864 void CEditingBtnsPanel::RmCultureNotes( wxCommandEvent& event )
2865 {
2867  if (cmd) m_CmdProccessor->Execute(cmd);
2868 }
2869 
2870 
2871 /*!
2872  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON26
2873  */
2874 
2875 void CEditingBtnsPanel::StrainToSp( wxCommandEvent& event )
2876 {
2877  CAppendModToOrg worker(true,COrgMod::eSubtype_strain,"",true,true,false,false,false,false,true);
2878  CRef<CCmdComposite> composite = worker.GetCommand(m_TopSeqEntry);
2879  if (composite) {
2880  m_CmdProccessor->Execute(composite);
2881  }
2882 }
2883 
2884 
2885 /*!
2886  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON24
2887  */
2888 
2889 void CEditingBtnsPanel::RevComp16S(wxCommandEvent& event)
2890 {
2892  dlg->Show(true);
2893 }
2894 
2895 void CEditingBtnsPanel::OnRemoveDescriptors( wxCommandEvent& event )
2896 {
2898  if (dlg.ShowModal() == wxID_OK)
2899  {
2901  if (cmd) m_CmdProccessor->Execute(cmd);
2902  dlg.Close();
2903  }
2904 }
2905 
2906 
2907 /*!
2908  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON27
2909  */
2910 
2912 {
2914  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Remove All Structured Comments"))
2915  event.Skip();
2916 }
2917 
2918 /*!
2919  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON28
2920  */
2921 
2922 void CEditingBtnsPanel::BulkEditCDS( wxCommandEvent& event )
2923 {
2925  /* vector<CRef<CSeq_loc> > locs = x_GetSelectedLocations();
2926  if (!locs.empty()) {
2927  try
2928  {
2929  seh = m_TopSeqEntry.GetScope().GetBioseqHandle(*locs.front()).GetParentBioseq_set().GetParentEntry();
2930  } catch (CException&) {}
2931  }
2932  */
2933  try
2934  {
2935  CBulkCDS dlg(NULL, seh, m_Workbench, m_SeqSubmit);
2936  bool done = false;
2937  while (!done) {
2938  if (dlg.ShowModal() == wxID_OK) {
2940  if (cmd) {
2942  //dlg.Close();
2943  done = true;
2944  } else {
2945  wxString error = ToWxString(dlg.GetErrorMessage());
2946  wxMessageBox(error, wxT("Error"),
2947  wxOK | wxICON_ERROR, NULL);
2948  }
2949  } else {
2950  done = true;
2951  }
2952  }
2953  } catch (CException&) {}
2954 }
2955 
2956 
2957 void CEditingBtnsPanel::AddTranslExcept( wxCommandEvent& event )
2958 {
2960  dlg->Show(true);
2961 }
2962 
2963 void CEditingBtnsPanel::OnRemoveFeatures( wxCommandEvent& event )
2964 {
2965  if (!m_Workbench) return;
2966  wxWindow* main_window = NULL;
2967  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
2968  if (wb_frame)
2969  main_window = wb_frame->GetMainWindow();
2970  CRemoveFeaturesDlg *dlg = new CRemoveFeaturesDlg(main_window, m_Workbench);
2971  dlg->Show(true);
2972 }
2973 
2974 /*!
2975  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON31
2976  */
2977 
2978 void CEditingBtnsPanel::BulkGeneEdit( wxCommandEvent& event )
2979 {
2981 
2982  try
2983  {
2985 
2986  bool done = false;
2987  while (!done) {
2988  if (dlg.ShowModal() == wxID_OK) {
2990  if (cmd) {
2992  //dlg.Close();
2993  done = true;
2994  } else {
2995  wxString error = ToWxString(dlg.GetErrorMessage());
2996  wxMessageBox(error, wxT("Error"),
2997  wxOK | wxICON_ERROR, NULL);
2998  }
2999  } else {
3000  done = true;
3001  }
3002  }
3003  } catch (CException&) {}
3004 }
3005 
3006 void CEditingBtnsPanel::OnRemoveBankitComment( wxCommandEvent& event )
3007 {
3008  CRemoveBankitComment worker;
3009  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Remove Bankit Comment"))
3010  event.Skip();
3011 }
3012 
3014 {
3016  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Remove Structured Comment Keyword"))
3017  event.Skip();
3018 }
3019 
3021 {
3023  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Add Structured Comment Keyword"))
3024  event.Skip();
3025 }
3026 
3028 {
3030  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Reorder Structured Comment"))
3031  event.Skip();
3032 }
3033 
3034 void CEditingBtnsPanel::OnReorderSequences( wxCommandEvent& event )
3035 {
3037  if (dlg.ShowModal() == wxID_OK)
3038  {
3040  if (cmd) m_CmdProccessor->Execute(cmd);
3041  dlg.Close();
3042  }
3043 }
3044 
3045 void CEditingBtnsPanel::OnConvertComment( wxCommandEvent& event )
3046 {
3047  CConvertComment worker;
3048  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Convert Comment to Structured Comment", "::"," "))
3049  event.Skip();
3050 }
3051 
3052 void CEditingBtnsPanel::OnParseComment( wxCommandEvent& event )
3053 {
3054  CConvertComment worker;
3055  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Parse Comment to Structured Comment", "=",";"))
3056  event.Skip();
3057 }
3058 
3059 void CEditingBtnsPanel::OnAssignFeatureIds( wxCommandEvent& event )
3060 {
3061  CAssignFeatureId worker;
3062  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Assign Feature Ids"))
3063  event.Skip();
3064 }
3065 
3066 void CEditingBtnsPanel::LabelrRNAs( wxCommandEvent& event )
3067 {
3068  wxWindow* main_window = NULL;
3069  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
3070  if (wb_frame)
3071  main_window = wb_frame->GetMainWindow();
3072 
3073  CLabelRna worker;
3074  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Label RNA", main_window))
3075  event.Skip();
3076 }
3077 
3078 void CEditingBtnsPanel::BulkEditRNA( wxCommandEvent& event )
3079 {
3081 
3082  try
3083  {
3084  CBulkRna dlg(NULL, seh,m_Workbench, m_SeqSubmit);
3085 
3086  bool done = false;
3087  while (!done) {
3088  if (dlg.ShowModal() == wxID_OK) {
3090  if (cmd) {
3092  //dlg.Close();
3093  done = true;
3094  } else {
3095  wxString error = ToWxString(dlg.GetErrorMessage());
3096  wxMessageBox(error, wxT("Error"),
3097  wxOK | wxICON_ERROR, NULL);
3098  }
3099  } else {
3100  done = true;
3101  }
3102  }
3103  } catch (CException&) {}
3104 }
3105 
3106 void CEditingBtnsPanel::OnFixiInPrimerSeqs( wxCommandEvent& event )
3107 {
3108  CPCRPrimerFixI worker;
3110  if (cmd) {
3112  }
3113 }
3114 
3115 void CEditingBtnsPanel::OnFixOrgModInstitution( wxCommandEvent& event )
3116 {
3117  CFixOrgModInst worker;
3119  if (cmd) {
3121  }
3122 }
3123 
3124 void CEditingBtnsPanel::OnSwapPrimerSeqName( wxCommandEvent& event )
3125 {
3126  CSwapPrimerNameSeq worker;
3128  if (cmd) {
3130  }
3131 }
3132 
3133 void CEditingBtnsPanel::OnMergePrimerSets(wxCommandEvent& event)
3134 {
3135  CMergePrimerSets worker;
3137  if (cmd) {
3139  }
3140 }
3141 
3142 void CEditingBtnsPanel::OnSplitPrimerSets(wxCommandEvent& event)
3143 {
3144  CSplitPrimerSets worker;
3146  if (cmd) {
3148  }
3149 }
3150 
3151 void CEditingBtnsPanel::OnAppendModToOrg( wxCommandEvent& event )
3152 {
3154  if (dlg.ShowModal() == wxID_OK)
3155  {
3157  if (cmd) m_CmdProccessor->Execute(cmd);
3158  dlg.Close();
3159  }
3160 }
3161 
3163 {
3166  if (cmd) {
3168  }
3169 }
3170 
3172 {
3175  if (cmd) {
3177  }
3178 }
3179 
3180 void CEditingBtnsPanel::OnCountryFixupCap(wxCommandEvent& event)
3181 {
3182  CCountryFixup worker;
3184  if (cmd) {
3186  }
3187 }
3188 
3189 void CEditingBtnsPanel::OnCountryFixupNoCap(wxCommandEvent& event)
3190 {
3191  CCountryFixup worker;
3193  if (cmd) {
3195  }
3196 }
3197 
3198 void CEditingBtnsPanel::OnAddrRNA16S ( wxCommandEvent& event )
3199 {
3200  bool ispartial5 = true, ispartial3 = true;
3201  CRef<CCmdComposite> cmd = AddNamedrRna(m_TopSeqEntry, "16S ribosomal RNA", ispartial5, ispartial3);
3202  if (cmd) m_CmdProccessor->Execute(cmd);
3203  else
3204  event.Skip();
3205 
3206 }
3207 
3208 void CEditingBtnsPanel::OnAddrRNA18S ( wxCommandEvent& event )
3209 {
3210  bool ispartial5 = true, ispartial3 = true;
3211  CRef<CCmdComposite> cmd = AddNamedrRna(m_TopSeqEntry, "18S ribosomal RNA", ispartial5, ispartial3);
3212  if (cmd) m_CmdProccessor->Execute(cmd);
3213  else
3214  event.Skip();
3215 
3216 }
3217 
3218 void CEditingBtnsPanel::OnAddrRNA23S ( wxCommandEvent& event )
3219 {
3220  bool ispartial5 = true, ispartial3 = true;
3221  CRef<CCmdComposite> cmd = AddNamedrRna(m_TopSeqEntry, "23S ribosomal RNA", ispartial5, ispartial3);
3222  if (cmd) m_CmdProccessor->Execute(cmd);
3223  else
3224  event.Skip();
3225 
3226 }
3227 
3228 void CEditingBtnsPanel::OnRemoveDefLines ( wxCommandEvent& event)
3229 {
3230  CRef<CCmdComposite> composite(new CCmdComposite("Removing DefLines"));
3231  if (composite){
3232  RemoveTitlesSeqEntry(m_TopSeqEntry, *(m_TopSeqEntry.GetCompleteSeq_entry()), composite);
3233  m_CmdProccessor->Execute(composite);
3235  dlg->Show(true);
3236  }else
3237  event.Skip();
3238 }
3239 
3240 
3241 // Added 09-30-2013
3242 
3243 void CEditingBtnsPanel::VectorTrim( wxCommandEvent& event )
3244 {
3245  wxWindow* main_window = NULL;
3246  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
3247  if (wb_frame)
3248  main_window = wb_frame->GetMainWindow();
3249  CVectorTrimDlg* dlg = new CVectorTrimDlg(main_window, m_TopSeqEntry, m_CmdProccessor);
3250  dlg->Show(true);
3251 }
3252 
3253 void CEditingBtnsPanel::AddCDS( wxCommandEvent& event )
3254 {
3256  m_Workbench);
3258  dlg->Show(true);
3259 /* if (dlg.ShowModal() == wxID_OK)
3260  {
3261  CRef<CCmdComposite> cmd = dlg.GetCommand();
3262  if (cmd) {
3263  m_CmdProccessor->Execute(cmd);
3264  } else {
3265  string errmsg = dlg.GetErrorMessage();
3266  if (!NStr::IsBlank(errmsg)) {
3267  wxString error = ToWxString(errmsg);
3268  wxMessageBox(error, wxT("Error"),
3269  wxOK | wxICON_ERROR, NULL);
3270  }
3271  }
3272  dlg.Close();
3273  }
3274 */
3275 }
3276 
3277 
3278 void CEditingBtnsPanel::AddRNA( wxCommandEvent& event )
3279 {
3280 
3282  m_Workbench);
3284 // dlg->CenterOnParent();
3285  dlg->Show(true);
3286 /*
3287  if (dlg.ShowModal() == wxID_OK)
3288  {
3289  CRef<CCmdComposite> cmd = dlg.GetCommand();
3290  if (cmd) {
3291  m_CmdProccessor->Execute(cmd);
3292  } else {
3293  string errmsg = dlg.GetErrorMessage();
3294  if (!NStr::IsBlank(errmsg)) {
3295  wxString error = ToWxString(errmsg);
3296  wxMessageBox(error, wxT("Error"),
3297  wxOK | wxICON_ERROR, NULL);
3298  }
3299  }
3300  dlg.Close();
3301  }
3302 */
3303 }
3304 
3305 
3306 void CEditingBtnsPanel::AddOtherFeature( wxCommandEvent& event )
3307 {
3308 
3310  m_Workbench);
3312  //dlg.CenterOnParent();
3313  dlg->Show(true);
3314 /*
3315  if (dlg.ShowModal() == wxID_OK)
3316  {
3317  CRef<CCmdComposite> cmd = dlg.GetCommand();
3318  if (cmd) {
3319  m_CmdProccessor->Execute(cmd);
3320  } else {
3321  string errmsg = dlg.GetErrorMessage();
3322  if (!NStr::IsBlank(errmsg)) {
3323  wxString error = ToWxString(errmsg);
3324  wxMessageBox(error, wxT("Error"),
3325  wxOK | wxICON_ERROR, NULL);
3326  }
3327  }
3328  dlg.Close();
3329  }
3330 */
3331 }
3332 
3333 
3334 void CEditingBtnsPanel::ValidateSeq( wxCommandEvent& event )
3335 {
3336  CRef<CUser_object> params(new CUser_object());
3339 
3340  wxWindow* main_window = NULL;
3341  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
3342  if (wb_frame)
3343  main_window = wb_frame->GetMainWindow();
3344 
3345  CValidateFrame::GetInstance(main_window, m_Workbench, params);
3346 }
3347 
3348 
3349 void CEditingBtnsPanel::DiscrepancyReport ( wxCommandEvent& event )
3350 {
3351  if (m_TopSeqEntry) {
3353  }
3354 }
3355 
3356 
3357 void CEditingBtnsPanel::AddSequences( wxCommandEvent& event )
3358 {
3359  CAddSequences worker;
3361 }
3362 
3363 void CEditingBtnsPanel::ShowAfter(wxWindow* dlg)
3364 {
3365  dlg->Show();
3366 }
3367 
3368 void CEditingBtnsPanel::ApplySourceQual( wxCommandEvent& evt )
3369 {
3372  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3373  dlg->SetInitParameters(aecr_action_type, aecr_field_type);
3374 
3375  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3376 }
3377 
3378 void CEditingBtnsPanel::EditSourceQual( wxCommandEvent& evt )
3379 {
3382  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3383  dlg->SetInitParameters(aecr_action_type, aecr_field_type);
3384 
3385  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3386 }
3387 
3388 void CEditingBtnsPanel::ConvertSourceQual( wxCommandEvent& evt )
3389 {
3392  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3393  dlg->SetInitParameters(aecr_action_type, aecr_field_type);
3394 
3395  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3396 }
3397 
3398 void CEditingBtnsPanel::SwapSourceQual( wxCommandEvent& evt )
3399 {
3402  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3403  dlg->SetInitParameters(aecr_action_type, aecr_field_type);
3404 
3405  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3406 }
3407 
3408 void CEditingBtnsPanel::RemoveSourceQual( wxCommandEvent& evt )
3409 {
3412  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3413  dlg->SetInitParameters(aecr_action_type, aecr_field_type);
3414 
3415  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3416 }
3417 
3418 void CEditingBtnsPanel::ApplyRNAQual( wxCommandEvent& evt )
3419 {
3422  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3423 
3424  dlg->SetInitParameters(action_type, field_type);
3425  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3426 }
3427 
3428 void CEditingBtnsPanel::EditRNAQual( wxCommandEvent& evt )
3429 {
3432  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3433 
3434  dlg->SetInitParameters(action_type, field_type);
3435  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3436 }
3437 
3438 void CEditingBtnsPanel::ConvertRNAQual( wxCommandEvent& evt )
3439 {
3442  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3443 
3444  dlg->SetInitParameters(action_type, field_type);
3445  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3446 }
3447 
3448 void CEditingBtnsPanel::SwapRNAQual( wxCommandEvent& evt )
3449 {
3452  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3453 
3454  dlg->SetInitParameters(action_type, field_type);
3455  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3456 }
3457 
3458 void CEditingBtnsPanel::RemoveRNAQual( wxCommandEvent& evt )
3459 {
3462  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3463 
3464  dlg->SetInitParameters(action_type, field_type);
3465  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3466 }
3467 
3468 void CEditingBtnsPanel::ApplyCGPQual( wxCommandEvent& evt )
3469 {
3472  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3473 
3474  dlg->SetInitParameters(action_type, field_type);
3475  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3476 }
3477 
3478 void CEditingBtnsPanel::EditCGPQual( wxCommandEvent& evt )
3479 {
3482  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3483 
3484  dlg->SetInitParameters(action_type, field_type);
3485  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3486 }
3487 
3488 void CEditingBtnsPanel::ConvertCGPQual( wxCommandEvent& evt )
3489 {
3492  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3493 
3494  dlg->SetInitParameters(action_type, field_type);
3495  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3496 }
3497 
3498 void CEditingBtnsPanel::SwapCGPQual( wxCommandEvent& evt )
3499 {
3502  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3503 
3504  dlg->SetInitParameters(action_type, field_type);
3505  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3506 }
3507 
3508 void CEditingBtnsPanel::RemoveCGPQual( wxCommandEvent& evt )
3509 {
3512  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3513 
3514  dlg->SetInitParameters(action_type, field_type);
3515  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3516 }
3517 
3518 void CEditingBtnsPanel::ApplyFeatQual( wxCommandEvent& evt )
3519 {
3522  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3523 
3524  dlg->SetInitParameters(action_type, field_type);
3525  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3526 }
3527 
3528 void CEditingBtnsPanel::EditFeatQual( wxCommandEvent& evt )
3529 {
3532  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3533 
3534  dlg->SetInitParameters(action_type, field_type);
3535  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3536 }
3537 
3538 void CEditingBtnsPanel::ConvertFeatQual( wxCommandEvent& evt )
3539 {
3542  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3543 
3544  dlg->SetInitParameters(action_type, field_type);
3545  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3546 }
3547 
3548 void CEditingBtnsPanel::SwapFeatQual( wxCommandEvent& evt )
3549 {
3552  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3553 
3554  dlg->SetInitParameters(action_type, field_type);
3555  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3556 }
3557 
3558 void CEditingBtnsPanel::RemoveFeatQual( wxCommandEvent& evt )
3559 {
3562  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3563 
3564  dlg->SetInitParameters(action_type, field_type);
3565  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3566 }
3567 
3568 void CEditingBtnsPanel::EditStructField( wxCommandEvent& evt)
3569 {
3572  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
3573 
3574  dlg->SetInitParameters(action_type, field_type);
3575  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
3576 }
3577 
3578 void CEditingBtnsPanel::EditFeatureEvidence( wxCommandEvent& evt )
3579 {
3580  try
3581  {
3584  dlg->Show(true);
3585  }
3586  catch (CException& e)
3587  {
3588  wxMessageBox(e.GetMsg(), wxT("Error"), wxOK | wxICON_ERROR, NULL);
3589  }
3590 }
3591 
3592 void CEditingBtnsPanel::EditFeatureLocation( wxCommandEvent& evt )
3593 {
3594  try
3595  {
3598  dlg->Show(true);
3599  }
3600  catch (CException& e)
3601  {
3602  wxMessageBox(e.GetMsg(), wxT("Error"), wxOK | wxICON_ERROR, NULL);
3603  }
3604 }
3605 
3606 
3607 void CEditingBtnsPanel::ParseTextFromDefline( wxCommandEvent& evt )
3608 {
3612  dlg->Show(true);
3613 }
3614 
3615 void CEditingBtnsPanel::ParseText( wxCommandEvent& evt )
3616 {
3618  dlg->Show(true);
3619 }
3620 
3621 
3622 void CEditingBtnsPanel::ConvertFeatures( wxCommandEvent& evt )
3623 {
3625  dlg->Show(true);
3626 }
3627 
3628 
3629 void CEditingBtnsPanel::TableReader( wxCommandEvent& event )
3630 {
3632  CQualTableLoadManager* qual_mgr = NULL;
3633 
3634  if (!m_TopSeqEntry || ! m_CmdProccessor) return;
3635 
3636  CRef<CFileLoadWizard> fileManager(new CFileLoadWizard());
3637  vector<string> format_ids;
3638  format_ids.push_back("file_loader_qual_table");
3639  fileManager->LoadFormats(format_ids);
3640  fileManager->SetWorkDir(m_WorkDir);
3641 
3642  for( size_t i = 0; i < fileManager->GetFormatManagers().size(); ++i ) {
3643  const IFileLoadPanelClient* mgr = fileManager->GetFormatManagers()[0].GetPointerOrNull();
3644 
3645  if ("file_loader_qual_table" == mgr->GetFileLoaderId()) {
3646  const CQualTableLoadManager* const_qual_mgr = dynamic_cast<const CQualTableLoadManager*>(mgr);
3647  if (const_qual_mgr) {
3648  qual_mgr = const_cast<CQualTableLoadManager*>(const_qual_mgr);
3649  qual_mgr->SetTopLevelEntry(m_TopSeqEntry);
3650  qual_mgr->SetServiceLocator(m_Workbench);
3651  }
3652  }
3653  }
3654 
3655  vector<CIRef<IOpenObjectsPanelClient> > loadManagers;
3656  loadManagers.push_back(CIRef<IOpenObjectsPanelClient>(fileManager.GetPointer()));
3657 
3658  COpenObjectsDlg dlg(NULL);
3659  dlg.SetSize(760, 940);
3660  dlg.Centre(wxBOTH | wxCENTRE_ON_SCREEN);
3661  dlg.SetMinSize(wxSize(760, 750));
3662  dlg.SetRegistryPath("Dialogs.Edit.OpenTables");
3663  dlg.SetManagers(loadManagers);
3664  LoadSettings("Dialogs.Edit.OpenTables", &dlg);
3665 
3666  if (dlg.ShowModal() == wxID_OK) {
3667  qual_mgr->x_GetColumnIdPanel()->x_TableReaderMacro();
3668  }
3669  SaveSettings("Dialogs.Edit.OpenTables", &dlg);
3670 }
3671 
3672 
3673 void CEditingBtnsPanel::BulkEdit( wxCommandEvent& event )
3674 {
3675 
3676  try
3677  {
3679  dlg.SetWorkDir(m_WorkDir);
3680  if (dlg.ShowModal() == wxID_OK) {
3683  // dlg.Close();
3684  }
3685  } catch (CException&) {}
3686 }
3687 
3688 void CEditingBtnsPanel::MolInfoEdit(wxCommandEvent& evt)
3689 {
3691  if (dlg.ShowModal() == wxID_OK)
3692  {
3694  if (cmd)
3695  {
3697  }
3698  dlg.Close();
3699  }
3700 }
3701 
3702 
3704 {
3705  SAutodefParams params;
3709 }
3710 
3712 {
3713  return first->Compare(*second);
3714 }
3715 
3716 
3718 {
3719  return first->Equals(*second);
3720 }
3721 
3722 
3723 void CEditingBtnsPanel::AutodefOptions(wxCommandEvent& evt)
3724 {
3725  SAutodefParams params;
3727  CAutodefDlg dlg(NULL);
3728  dlg.SetParams(&params);
3729  if (dlg.ShowModal() == wxID_OK) {
3730 
3731  dlg.PopulateParams(params);
3733  if (dlg.OnlyTargeted()) {
3734  vector<CRef<CSeq_loc> > orig_locs = x_GetSelectedLocations();
3735  vector<CRef<CSeq_loc> > cpy = orig_locs;
3736  vector<CRef<CSeq_loc> >::iterator lit = cpy.begin();
3737  while (lit != cpy.end()) {
3738  CBioseq_Handle b = m_TopSeqEntry.GetScope().GetBioseqHandle(**lit);
3739  if (!b || b.IsAa()) {
3740  lit = cpy.erase(lit);
3741  }
3742  else {
3743  ++lit;
3744  }
3745  }
3746 
3747  if (cpy.empty()) {
3748  dlg.Close();
3749  return;
3750  }
3751  stable_sort(cpy.begin(), cpy.end(), CompLoc);
3752  cpy.erase(unique(cpy.begin(), cpy.end(), EqualLoc), cpy.end());
3753 
3754  cmd.Reset(new CCmdComposite("Autodef"));
3755  ITERATE(vector<CRef<CSeq_loc> >, b, cpy) {
3756  CBioseq_Handle bsh = m_TopSeqEntry.GetScope().GetBioseqHandle(**b);
3758  if (subcmd) {
3759  cmd->AddCommand(*subcmd);
3760  }
3761  }
3762  }
3763  else {
3765  }
3767  dlg.Close();
3768  }
3769 }
3770 
3771 void CEditingBtnsPanel::AutodefMisc(wxCommandEvent& evt)
3772 {
3773  SAutodefParams params;
3775  params.m_MiscFeatRule = 1;
3778 }
3779 
3780 void CEditingBtnsPanel::AutodefId(wxCommandEvent& evt)
3781 {
3782  SAutodefParams params;
3786 }
3787 
3788 void CEditingBtnsPanel::AutodefNoMods(wxCommandEvent& evt)
3789 {
3790  SAutodefParams params;
3793 }
3794 
3795 void CEditingBtnsPanel::AutodefPopset(wxCommandEvent& evt)
3796 {
3797  SAutodefParams params;
3799  CAutodefDlg dlg(NULL);
3800  dlg.SetParams(&params);
3801  dlg.ShowSourceOptions(false);
3802  if (dlg.ShowModal() == wxID_OK)
3803  {
3804  dlg.PopulateParams(params);
3807  dlg.Close();
3808  }
3809 }
3810 
3811 void CEditingBtnsPanel::AutodefRefresh(wxCommandEvent& evt)
3812 {
3813  CRef<CCmdComposite> cmd = macro::CMacroFunction_RefreshDefline::s_RefreshDeflineCommand(m_TopSeqEntry);
3814  if (cmd) m_CmdProccessor->Execute(cmd);
3815 }
3816 
3818 {
3820  CRef<CCmdComposite> composite = worker.GetCommand(m_TopSeqEntry, "Parse Strain Serotype from Names");
3821  if (composite) {
3822  m_CmdProccessor->Execute(composite);
3823  }
3824 }
3825 
3826 
3828 {
3830  CRef<CCmdComposite> composite = worker.GetCommand(m_TopSeqEntry, "Add Strain Serotype to Names");
3831  if (composite) {
3832  m_CmdProccessor->Execute(composite);
3833  }
3834 }
3835 
3836 
3837 void CEditingBtnsPanel::FixupOrganismNames (wxCommandEvent& event)
3838 {
3840  CRef<CCmdComposite> composite = worker.GetCommand(m_TopSeqEntry, "Fixup Organism Names");
3841  if (composite) {
3842  m_CmdProccessor->Execute(composite);
3843  }
3844 }
3845 
3846 
3848 {
3850  CRef<CCmdComposite> composite = worker.GetCommand(m_TopSeqEntry, "Split Quals at Commas");
3851  if (composite) {
3852  m_CmdProccessor->Execute(composite);
3853  }
3854 }
3855 
3857 {
3859  CRef<CCmdComposite> composite = worker.GetCommand(m_TopSeqEntry, "Split Structured Collections at Semicolon");
3860  if (composite) {
3861  m_CmdProccessor->Execute(composite);
3862  }
3863 }
3864 
3865 
3866 void CEditingBtnsPanel::TrimOrganismNames (wxCommandEvent& event)
3867 {
3869  CRef<CCmdComposite> composite = worker.GetCommand(m_TopSeqEntry, "Trim Organism Names");
3870  if (composite) {
3871  m_CmdProccessor->Execute(composite);
3872  }
3873 }
3874 
3875 
3876 void CEditingBtnsPanel::AddNamedrRNA12S(wxCommandEvent& event)
3877 {
3878  bool ispartial5 = true;
3879  bool ispartial3 = true;
3880  CRef<CCmdComposite> composite = AddNamedrRna(m_TopSeqEntry, "12S ribosomal RNA", ispartial5, ispartial3);
3881  if (composite){
3882  m_CmdProccessor->Execute(composite);
3883  }
3884 }
3885 
3886 void CEditingBtnsPanel::AddNamedrRNA28S(wxCommandEvent& event)
3887 {
3888  bool ispartial5 = true;
3889  bool ispartial3 = true;
3890  CRef<CCmdComposite> composite = AddNamedrRna(m_TopSeqEntry, "28S ribosomal RNA", ispartial5, ispartial3);
3891  if (composite){
3892  m_CmdProccessor->Execute(composite);
3893  }
3894 }
3895 
3896 void CEditingBtnsPanel::AddNamedrRNA26S(wxCommandEvent& event)
3897 {
3898  bool ispartial5 = true;
3899  bool ispartial3 = true;
3900  CRef<CCmdComposite> composite = AddNamedrRna(m_TopSeqEntry, "26S ribosomal RNA", ispartial5, ispartial3);
3901  if (composite){
3902  m_CmdProccessor->Execute(composite);
3903  }
3904 }
3905 
3906 void CEditingBtnsPanel::AddNamedrRNASmall(wxCommandEvent& event)
3907 {
3908  bool ispartial5 = true;
3909  bool ispartial3 = true;
3910  CRef<CCmdComposite> composite = AddNamedrRna(m_TopSeqEntry, "small subunit ribosomal RNA", ispartial5, ispartial3);
3911  if (composite){
3912  m_CmdProccessor->Execute(composite);
3913  }
3914 }
3915 
3916 void CEditingBtnsPanel::AddNamedrRNALarge(wxCommandEvent& event)
3917 {
3918  bool ispartial5 = true;
3919  bool ispartial3 = true;
3920  CRef<CCmdComposite> composite = AddNamedrRna(m_TopSeqEntry, "large subunit ribosomal RNA", ispartial5, ispartial3);
3921  if (composite){
3922  m_CmdProccessor->Execute(composite);
3923  }
3924 }
3925 
3926 
3927 void CEditingBtnsPanel::AddControlRegion ( wxCommandEvent& event)
3928 {
3930  if (composite){
3931  m_CmdProccessor->Execute(composite);
3932  }
3933 }
3934 
3935 void CEditingBtnsPanel::AddMicrosatellite ( wxCommandEvent& event)
3936 {
3938  if (composite){
3939  m_CmdProccessor->Execute(composite);
3940  }
3941 }
3942 
3943 void CEditingBtnsPanel::RemoveUnverified( wxCommandEvent& event )
3944 {
3945  CRemoveUnverified worker;
3946  if (!worker.apply(m_TopSeqEntry,m_CmdProccessor,"Remove Unverified"))
3947  event.Skip();
3948 }
3949 
3950 void CEditingBtnsPanel::RemoveUnreviewed(wxCommandEvent& event)
3951 {
3952  CRemoveUnreviewed worker;
3955 }
3956 
3957 void CEditingBtnsPanel::AddDefLine ( wxCommandEvent& event)
3958 {
3960  dlg->Show(true);
3961 }
3962 
3963 
3964 void CEditingBtnsPanel::PrefixOrgToDefLine ( wxCommandEvent& event)
3965 {
3966  CRef<CCmdComposite> composite(new CCmdComposite("Prefix Organism Name to Definition Line"));
3967  if (AddOrgToDefline(m_TopSeqEntry, composite))
3968  m_CmdProccessor->Execute(composite);
3969 }
3970 
3971 void CEditingBtnsPanel::PrefixStrainToDefLine ( wxCommandEvent& event)
3972 {
3973  CRef<CCmdComposite> composite(new CCmdComposite("Prefix Strain to Definition Line"));
3975  bool show_label = true;
3976  if (AddModToDefline(m_TopSeqEntry, composite, modifier, show_label))
3977  m_CmdProccessor->Execute(composite);
3978 }
3979 
3980 void CEditingBtnsPanel::PrefixCloneToDefLine ( wxCommandEvent& event)
3981 {
3982  CRef<CCmdComposite> composite(new CCmdComposite("Prefix Clone to Definition Line"));
3984  bool show_label = true;
3985  if (AddModToDefline(m_TopSeqEntry, composite, modifier, show_label))
3986  m_CmdProccessor->Execute(composite);
3987 }
3988 
3989 void CEditingBtnsPanel::PrefixIsolateToDefLine ( wxCommandEvent& event)
3990 {
3991  CRef<CCmdComposite> composite(new CCmdComposite("Prefix Isolate to Definition Line"));
3993  bool show_label = true;
3994  if (AddModToDefline(m_TopSeqEntry, composite, modifier, show_label))
3995  m_CmdProccessor->Execute(composite);
3996 }
3997 
3998 void CEditingBtnsPanel::PrefixHaplotToDefLine ( wxCommandEvent& event)
3999 {
4000  CRef<CCmdComposite> composite(new CCmdComposite("Prefix Haplotype to Definition Line"));
4002  bool show_label = true;
4003  if (AddModToDefline(m_TopSeqEntry, composite, modifier, show_label))
4004  m_CmdProccessor->Execute(composite);
4005 }
4006 
4007 void CEditingBtnsPanel::PrefixCultivarToDefLine ( wxCommandEvent& event)
4008 {
4009  CRef<CCmdComposite> composite(new CCmdComposite("Prefix Cultivar to Definition Line"));
4011  bool show_label = true;
4012  if (AddModToDefline(m_TopSeqEntry, composite, modifier, show_label))
4013  m_CmdProccessor->Execute(composite);
4014 }
4015 
4016 void CEditingBtnsPanel::PrefixListToDefLine ( wxCommandEvent& event)
4017 {
4018  SAutodefParams params;
4019  unsigned int found = ConfigureParamsForPrefixCombo(params, m_TopSeqEntry);
4020  CPrefixDeflinedlg dlg(NULL, m_TopSeqEntry, found);
4021  if (found > 0) {
4022  dlg.SetParams(&params);
4023  dlg.PopulateModifierCombo();
4024  }
4025  if (dlg.ShowModal() == wxID_OK){
4026  CRef<CCmdComposite> composite = dlg.GetCommand();
4027  if (composite){
4028  m_CmdProccessor->Execute(composite);
4029  }
4030  dlg.Close();
4031  }
4032 }
4033 
4034 void CEditingBtnsPanel::CreateFeature ( wxCommandEvent& event)
4035 {
4036  if (m_Locations.size() != 1)
4037  {
4038  wxMessageBox(_("Please select a single Bioseq"), wxT("Error"), wxOK | wxICON_ERROR, NULL);
4039  return;
4040  }
4041 
4042  CRef<CSeq_loc> lit = m_Locations.front();
4043  CFeatureSubtypeSelector *button = dynamic_cast<CFeatureSubtypeSelector*>(event.GetEventObject());
4044  if (button)
4045  {
4046  CSeqFeatData::ESubtype subtype = button->GetSubtype();
4048  feat->SetLocation().Assign(*lit);
4049 
4050  CBioseq_Handle bsh = m_TopSeqEntry.GetScope().GetBioseqHandle(*lit);
4052  CIRef<IEditObject> editor(new CEditObjectSeq_feat(*feat, seh, seh.GetScope(), true));
4053  CEditObjViewDlg* edit_dlg = new CEditObjViewDlg(NULL, true);
4054  edit_dlg->SetUndoManager(m_CmdProccessor);
4055  wxWindow* editorWindow = editor->CreateWindow(edit_dlg);
4056  edit_dlg->SetEditorWindow(editorWindow);
4057  edit_dlg->SetEditor(editor);
4058  edit_dlg->SetWorkDir(m_WorkDir);
4059  edit_dlg->Show(true);
4060  }
4061 
4062 }
4063 
4064 
4065 void CEditingBtnsPanel::SegregateSets( wxCommandEvent& event )
4066 {
4067  wxWindow* main_window = NULL;
4068  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
4069  if (wb_frame)
4070  main_window = wb_frame->GetMainWindow();
4071  CSegregateSets* dlg = new CSegregateSets(main_window, m_TopSeqEntry, m_CmdProccessor);
4072  dlg->Show(true);
4073 }
4074 
4075 void CEditingBtnsPanel::PT_Cleanup (wxCommandEvent& event)
4076 {
4078  if (cmd) {
4080  }
4081 }
4082 
4083 static string s_GetMacroScriptLocation(const string& filename)
4084 {
4085  wxFileName macro_dir = wxFileName::DirName(wxStandardPaths::Get().GetDocumentsDir() + wxFileName::GetPathSeparator() + "GbenchMacro");
4086 
4087  if (!macro_dir.DirExists()) {
4088  if (!macro_dir.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) {
4089  LOG_POST(Error << "Cannot create directory '" << string(macro_dir.GetPath().ToUTF8()) << "'");
4090  return kEmptyStr;
4091  }
4092  }
4093 
4094  wxFileName macro_file(macro_dir.GetPath(), filename);
4095  if (!macro_file.FileExists()) {
4096  const string orig_location = "<std>/etc/macro_scripts/";
4097  wxFileName orig_path = CSysPath::ResolvePath(orig_location);
4098  if (!orig_path.DirExists()) {
4099  return kEmptyStr;
4100  }
4101 
4102  wxFileName orig_file(orig_path.GetPath(), filename);
4103  wxFileName dst_file(macro_dir.GetPath(), filename);
4104  if (!wxCopyFile(orig_file.GetFullPath(), dst_file.GetFullPath())) {
4105  LOG_POST(Error << "Cannot copy '" << filename << "' to location '" << string(macro_dir.GetPath().ToUTF8()) << "'");
4106  return kEmptyStr;
4107  }
4108  }
4109  return string(macro_file.GetFullPath().ToUTF8());
4110 }
4111 
4112 static Uint4 s_GetCheckSumForFile(const string& filename)
4113 {
4114  CChecksum chksum(CChecksum::eCRC32);
4115  chksum.AddFile(filename);
4116  return chksum.GetChecksum();
4117 }
4118 
4119 static string s_GetUsername()
4120 {
4121  char username[1024];
4122  CORE_GetUsername(username, sizeof(username));
4123  return string(username);
4124 }
4125 
4126 static void s_UpdateMacros()
4127 {
4128  string orig_dir_path{ wxFileName::DirName(CSysPath::ResolvePath(wxT("<std>/etc/macro_scripts"))).GetPath().ToUTF8() };
4129  string upd_dir_path{ wxFileName::DirName(CSysPath::ResolvePath(wxT("<std>/etc/macro_scripts/Updates"))).GetPath().ToUTF8() };
4130 
4131  if (orig_dir_path.empty() || upd_dir_path.empty()) {
4132  return;
4133  }
4134 
4135  CDir dir(upd_dir_path);
4136  CDir::TEntries files(dir.GetEntries("*.mql", CDir::eFile));
4137  for (auto& it : files) {
4138  if (!it->IsFile())
4139  continue;
4140 
4141  string filename = it->GetName();
4142  string upd_filename = CDirEntry::MakePath(upd_dir_path, filename);
4143  auto upd_chksum = s_GetCheckSumForFile(upd_filename);
4144 
4145  string orig_filename = CDirEntry::MakePath(orig_dir_path, filename);
4146  auto orig_chksum = s_GetCheckSumForFile(orig_filename);
4147 
4148  wxFileName lcl_dir = wxFileName::DirName(wxStandardPaths::Get().GetDocumentsDir() + wxFileName::GetPathSeparator() + "GbenchMacro");
4149  const string lcl_filename = CDirEntry::ConcatPathEx(string(lcl_dir.GetPath().ToUTF8()), filename);
4150  auto lcl_chksum = s_GetCheckSumForFile(lcl_filename);
4151 
4152  if (lcl_chksum == upd_chksum) {
4153  // do nothing
4154  }
4155  else if (lcl_chksum == orig_chksum) {
4156  // update
4157  CFile lcl(lcl_filename);
4159  CFile upd(upd_filename);
4160  if (upd.CopyToDir(string(lcl_dir.GetFullPath().ToUTF8()))) {
4161  string username = s_GetUsername();
4162  if (!username.empty()) {
4163  NMacroStats::ReportMacroToBeUpdated(username, filename, "updated");
4164  }
4165  } else {
4166  LOG_POST(Error << "Cannot copy '" << upd_filename << "' to location '" << string(lcl_dir.GetFullPath().ToUTF8()) << "'");
4167  }
4168  }
4169  else {
4170  // report to applog
4171  string username = s_GetUsername();
4172  if (!username.empty()) {
4173  NMacroStats::ReportMacroToBeUpdated(username, filename, "manual_update");
4174  }
4175  }
4176  }
4177 }
4178 
4179 
4181 {
4183  m_dynamic_buttons_name[ID_BUTTON46] = "Flu Segment";
4184  m_dynamic_buttons_title[ID_BUTTON46] = "Flu Segment";
4185 
4187  m_dynamic_buttons_name[ID_BUTTON47] = "GB_mito Macro";
4188  m_dynamic_buttons_title[ID_BUTTON47] = "GB_mito";
4189 
4190  m_dynamic_buttons_filename[ID_BUTTON104] = s_GetMacroScriptLocation("fixsource_underscores.mql");
4191  m_dynamic_buttons_name[ID_BUTTON104] = "FixSrcUnderscores";
4192  m_dynamic_buttons_title[ID_BUTTON104] = "FixSourceUnderscores";
4193 
4195  m_dynamic_buttons_name[ID_BUTTON106] = "Remove Location";
4196  m_dynamic_buttons_title[ID_BUTTON106] = "Remove Location";
4197 
4199  m_dynamic_buttons_name[ID_BUTTON112] = "RemoveFullLength";
4200  m_dynamic_buttons_title[ID_BUTTON112] = "Remove (CDS, gene, miscRNA, rRNA) Full Length";
4201 
4203  m_dynamic_buttons_name[ID_BUTTON114] = "UnculTax Macro";
4204  m_dynamic_buttons_title[ID_BUTTON114] = "Uncultured Tax Tool";
4205 
4207  m_dynamic_buttons_name[ID_BUTTON116] = "Parse2Strain";
4208  m_dynamic_buttons_title[ID_BUTTON116] = "Parse to strain";
4209 
4211  m_dynamic_buttons_name[ID_BUTTON119] = "RmvXtraGeneInfo";
4212  m_dynamic_buttons_title[ID_BUTTON119] = "Remove extra gene info";
4213 
4215  m_dynamic_buttons_name[ID_BUTTON120] = "RmvMolComplete";
4216  m_dynamic_buttons_title[ID_BUTTON120] = "RemoveMolComplete";
4217 
4219  m_dynamic_buttons_name[ID_BUTTON121] = "Apply-gDNA";
4220  m_dynamic_buttons_title[ID_BUTTON121] = "Apply-gDNA";
4221 
4223  m_dynamic_buttons_name[ID_BUTTON122] = "Cytbmacro";
4224  m_dynamic_buttons_title[ID_BUTTON122] = "CytbMacro";
4225 
4227  m_dynamic_buttons_name[ID_BUTTON124] = "Join Short tRNAs";
4228  m_dynamic_buttons_title[ID_BUTTON124] = "Join short tRNAs";
4229 
4231  m_dynamic_buttons_name[ID_BUTTON126] = "GPIPE Uncultured";
4232  m_dynamic_buttons_title[ID_BUTTON126] = "Composite Uncultured Tax Tool (GPIPE)";
4233 
4235  m_dynamic_buttons_name[ID_BUTTON128] = "rRNAmacro";
4237 
4239  m_dynamic_buttons_name[ID_BUTTON129] = "Personal macro";
4240  m_dynamic_buttons_title[ID_BUTTON129] = "Personal macro";
4241 
4243  m_dynamic_buttons_name[ID_BUTTON131] = "Apply Mito";
4244  m_dynamic_buttons_title[ID_BUTTON131] = "Apply Mito";
4245 
4246  m_dynamic_buttons_filename[ID_BUTTON135] = s_GetMacroScriptLocation("gpipe_cultured_macro.mql");
4247  m_dynamic_buttons_name[ID_BUTTON135] = "GPIPE Cultured";
4248  m_dynamic_buttons_title[ID_BUTTON135] = "Cultured Tax Tool";
4249 
4251  m_dynamic_buttons_name[ID_BUTTON136] = "Parse ATCC";
4252  m_dynamic_buttons_title[ID_BUTTON136] = "Parse ATCC";
4253 
4255  m_dynamic_buttons_name[ID_BUTTON141] = "GPIPE ITS";
4257 
4259  m_dynamic_buttons_name[ID_BUTTON146] = "tRNAcodon Macro";
4260  m_dynamic_buttons_title[ID_BUTTON146] = "tRNAcodon";
4261 
4263  m_dynamic_buttons_name[ID_BUTTON147] = "tRNAmacro";
4265 
4267  m_dynamic_buttons_name[ID_BUTTON148] = "chloroprod";
4268  m_dynamic_buttons_title[ID_BUTTON148] = "Chloroprod";
4269 
4271  m_dynamic_buttons_name[ID_BUTTON45] = "Fix Altitude";
4272 
4273  m_dynamic_buttons_filename[ID_BUTTON78] = s_GetMacroScriptLocation("apply_genbank_to_wgs_set.mql");
4274  m_dynamic_buttons_name[ID_BUTTON78] = "WGS to Genbank";
4275 
4276  m_dynamic_buttons_filename[ID_BUTTON105] = s_GetMacroScriptLocation("lowercase_isolationsrc.mql");
4277  m_dynamic_buttons_name[ID_BUTTON105] = "LowerIsolSrc";
4278 
4280  m_dynamic_buttons_name[ID_BUTTON107] = "LocalID_Clone";
4281 
4283  m_dynamic_buttons_name[ID_BUTTON108] = "LocalID_Isolate";
4284 
4286  m_dynamic_buttons_name[ID_BUTTON109] = "LocalID_Strain";
4287 
4288  m_dynamic_buttons_filename[ID_BUTTON111] = s_GetMacroScriptLocation("remove_intronlessgene.mql");
4289  m_dynamic_buttons_name[ID_BUTTON111] = "RmvIntronlessGene";
4290 
4292  m_dynamic_buttons_name[ID_BUTTON117] = "Rmv IdentifiedBy";
4293 
4295  m_dynamic_buttons_name[ID_BUTTON118] = "Rmv Gene";
4296 
4298  m_dynamic_buttons_name[ID_BUTTON123] = "TSANote";
4299 
4301  m_dynamic_buttons_name[ID_BUTTON130] = "Flip Host";
4302 
4304  m_dynamic_buttons_name[ID_BUTTON139] = "Complete Phage";
4305 
4307  m_dynamic_buttons_name[ID_BUTTON143] = "Parse bla allele";
4308 
4309  m_dynamic_buttons_filename[ID_BUTTON144] = s_GetMacroScriptLocation("fix_allauthors_affil.mql");
4310  m_dynamic_buttons_name[ID_BUTTON144] = "FixAllAuthorsAffil";
4311 
4313  m_dynamic_buttons_name[ID_BUTTON145] = "ComCirc Macro";
4314 
4316  m_dynamic_buttons_name[ID_BUTTON151] = "SetGenePartial";
4317 
4319  m_dynamic_buttons_name[ID_BUTTON152] = "SetPartialAndExtend";
4320 
4322  m_dynamic_buttons_name[ID_BUTTON153] = "PB1 GeneXref";
4323 
4325  m_dynamic_buttons_name[ID_BUTTON154] = "RmvAllAdd16S";
4326 
4329 
4331  m_dynamic_buttons_name[ID_BUTTON157] = "IsolateToStrain";
4332 
4333  m_dynamic_buttons_filename[ID_BUTTON158] = s_GetMacroScriptLocation("remove_assembly_name.mql");
4334  m_dynamic_buttons_name[ID_BUTTON158] = "RmvAssemblyName";
4335 
4336  m_dynamic_buttons_filename[ID_BUTTON165] = s_GetMacroScriptLocation("extendCDSgene_nearEnds.mql");
4337  m_dynamic_buttons_name[ID_BUTTON165] = "ExtendCDSgeneNE";
4338 
4340  m_dynamic_buttons_name[ID_BUTTON166] = "FixRNAITSpartials";
4341 
4343  m_dynamic_buttons_name[ID_BUTTON161] = "MeaslesSourceH";
4344  m_dynamic_buttons_title[ID_BUTTON161] = "MeaslesSourceH";
4345 
4347  m_dynamic_buttons_name[ID_BUTTON162] = "MeaslesSourceN";
4348  m_dynamic_buttons_title[ID_BUTTON162] = "MeaslesSourceN";
4349 
4350  m_dynamic_buttons_filename[ID_BUTTON163] = s_GetMacroScriptLocation("remove_location_wotaxlookup.mql");
4351  m_dynamic_buttons_name[ID_BUTTON163] = "RemoveLoc(noTax)";
4352 
4354  m_dynamic_buttons_name[ID_BUTTON164] = "RubellaSourceSH";
4355  m_dynamic_buttons_title[ID_BUTTON164] = "RubellaSourceSH";
4356 
4358  m_dynamic_buttons_name[ID_BUTTON167] = "TrimGeneLocus2";
4359 
4361  m_dynamic_buttons_name[ID_BUTTON168] = "TrimGeneLocus4";
4362 
4364  m_dynamic_buttons_name[ID_BUTTON169] = "RmOrgFromStrain";
4365 
4367  m_dynamic_buttons_name[ID_BUTTON170] = "RmOrgFromIsolate";
4368 
4369  s_UpdateMacros();
4370 }
4371 
4372 void CEditingBtnsPanel::RunMacroWithReport( wxCommandEvent& event )
4373 {
4374  string title, filename;
4376  bool add_user_object = false;
4377 
4378  switch (event.GetId()) {
4379  case ID_BUTTON132:
4381  title = "Autofix(WGS)";
4382  break;
4383  case ID_BUTTON137:
4385  title = "Autofix";
4386  add_user_object = true;
4387  break;
4388  case ID_BUTTON171:
4390  title = "Autofix(TSA)";
4391  break;
4392  default:
4393  break;
4394  }
4395 
4396  int id = event.GetId();
4398  filename = m_dynamic_buttons_filename[id];
4399  }
4401  title = m_dynamic_buttons_title[id];
4402 
4403  if (macros.empty() && filename.empty()) {
4404  NcbiMessageBox("The macro script was not found.");
4405  return;
4406  }
4407 
4408  wxWindow* main_window = NULL;
4409  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
4410  if (wb_frame)
4411  main_window = wb_frame->GetMainWindow();
4412 
4413  const string kMacroReport(" Macro Report");
4414  CGenericReportDlg* report = nullptr;
4415 
4416  ITERATE(wxWindowList, wit, main_window->GetChildren()){
4417  wxWindow* child = *wit;
4418  if (NStr::EndsWith(ToStdString(child->GetLabel()), kMacroReport)) {
4419  report = wxDynamicCast(child, CGenericReportDlg);
4420  break;
4421  }
4422  }
4423 
4425  bool status = false;
4427  if (!macros.empty()) {
4428  status = worker.ExecuteMacros(macros, log, add_user_object);
4429  }
4430  else if (!filename.empty()) {
4431  status = worker.ExecuteMacros(filename, log, add_user_object);
4432  }
4433 
4434  string report_msg = CNcbiOstrstreamToString(log);
4435 
4436  if (!status || report_msg.empty()) {
4437  report_msg.assign("Macro had no effect");
4438  }
4439 
4440  title.append(kMacroReport);
4441  if (report) {
4442  report->SetTitle(ToWxString(title));
4443  report->SetText(ToWxString(report_msg));
4444  report->RefreshData();
4445  report->SetFocus();
4446  } else {
4447  report = new CGenericReportDlg(main_window, m_Workbench, wxID_ANY, ToWxString(title));
4448  report->SetText(ToWxString(report_msg));
4449  report->Show(true);
4450  }
4451 }
4452 
4453 void CEditingBtnsPanel::RunMacro ( wxCommandEvent& event )
4454 {
4455  vector<string> macro;
4456  string filename;
4457  bool add_user_object = false;
4458  bool resolve_vars = false;
4459  switch (event.GetId()) {
4460  case ID_BUTTON44:
4462  add_user_object = true;
4463  break;
4464  case ID_BUTTON143:
4465  resolve_vars = true;
4466  break;
4467  }
4468 
4469  int id = event.GetId();
4471  filename = m_dynamic_buttons_filename[id];
4472  }
4473 
4474  if (macro.empty() && filename.empty()) {
4475  NcbiMessageBox("The macro script was not found.");
4476  return;
4477  }
4478 
4481  if (!macro.empty()) {
4482  worker.ExecuteMacros(macro, log, add_user_object);
4483  }
4484  else if (!filename.empty()) {
4485  worker.ExecuteMacros(filename, log, add_user_object, resolve_vars);
4486  }
4487 }
4488 
4489 void CEditingBtnsPanel::AddSet( wxCommandEvent& event )
4490 {
4491  CChooseSetClassDlg dlg(NULL);
4492  if (dlg.ShowModal() == wxID_OK)
4493  {
4494  CBioseq_set::EClass new_class = dlg.GetClass();
4496  if (cmd) m_CmdProccessor->Execute(cmd);
4497  }
4498 }
4499 
4500 void CEditingBtnsPanel::AddGSet( wxCommandEvent& event )
4501 {
4502  CBioseq_set::EClass new_class = ncbi::objects::CBioseq_set::eClass_genbank;
4504  if (cmd) m_CmdProccessor->Execute(cmd);
4505 }
4506 
4507 void CEditingBtnsPanel::RetranslateCDS( wxCommandEvent& evt )
4508 {
4509 
4510  CRetranslateCDS worker;
4512 }
4513 
4514 void CEditingBtnsPanel::RetranslateCDS_NoStp( wxCommandEvent& evt )
4515 {
4516  CRetranslateCDS worker;
4517  worker.apply( m_TopSeqEntry, m_CmdProccessor, "Retranslate coding regions", CRetranslateCDS::eRetranslateCDSChooseFrame);
4518 }
4519 
4520 
4521 void CEditingBtnsPanel::OnCallerTool(wxCommandEvent& event)
4522 {
4523  if (m_TopSeqEntry) {
4525  }
4526 };
4527 
4528 void CEditingBtnsPanel::SelectTarget( wxCommandEvent& event )
4529 {
4531  dlg->Show();
4532 }
4533 
4534 void CEditingBtnsPanel::UnculTaxTool( wxCommandEvent& event )
4535 {
4536  wxWindow* main_window = NULL;
4537  CWorkbench* wb_frame = dynamic_cast<CWorkbench*>(m_Workbench);
4538  if (wb_frame)
4539  main_window = wb_frame->GetMainWindow();
4540  try
4541  {
4542  CUnculTaxTool *dlg = new CUnculTaxTool(main_window, m_TopSeqEntry, m_Workbench);
4543  dlg->Show(true);
4544  } catch (CException&) {}
4545 }
4546 
4547 void CEditingBtnsPanel::RemoveSrcNotes( wxCommandEvent& evt )
4548 {
4549  CRemoveSrcNotes worker;
4551  if (cmd) {
4553  }
4554 }
4555 
4556 void CEditingBtnsPanel::AddIsolSource( wxCommandEvent& evt )
4557 {
4560  CAECRFrame * dlg = new CAECRFrame(NULL, m_Workbench);
4561 
4562  dlg->SetInitParameters(action_type, field_type, "isolation-source");
4563  CallAfter(&CEditingBtnsPanel::ShowAfter, dlg);
4564 }
4565 
4566 void CEditingBtnsPanel::ExtendPartialsConstr( wxCommandEvent& evt )
4567 {
4569  dlg->Show(true);
4570 }
4571 
4572 void CEditingBtnsPanel::ExtendPartialsAll( wxCommandEvent& evt )
4573 {
4575  dlg->ApplyToAllAndDie();
4576 }
4577 
4578 void CEditingBtnsPanel::ConvertCdsToMiscFeat( wxCommandEvent& evt )
4579 {
4581  dlg->Show(true);
4582 }
4583 
4584 void CEditingBtnsPanel::LowercaseQuals( wxCommandEvent& evt )
4585 {
4586  CLowerQuals* dlg = new CLowerQuals(NULL, m_Workbench);
4587  dlg->Show(true);
4588 }
4589 
4590 
4592 {
4593 
4596 
4597  CAECRFrame * dlg = new CAECRFrame(NULL,