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

Go to the SVN repository for this file.

1 /* $Id: bulk_cmd_dlg.cpp 42432 2019-02-22 18:44:43Z filippov $
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
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 ////@begin includes
33 ////@end includes
34 
38 #include <gui/objutils/utils.hpp>
45 
48 
49 #include <wx/msgdlg.h>
50 #include <wx/sizer.h>
51 #include <wx/app.h>
52 
53 ////@begin XPM images
54 ////@end XPM images
55 
57 
59 
60 IMPLEMENT_ABSTRACT_CLASS( CBulkCmdDlg, wxFrame )
61 
62 BEGIN_EVENT_TABLE( CBulkCmdDlg, wxFrame )
63 
64 EVT_COMMAND(wxID_CANCEL, wxEVT_BUTTON, CBulkCmdDlg::onCancelPressed)
65 
67 
68 bool CBulkCmdDlg::Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style, const wxString &name)
69 {
70  if ( !parent )
71  {
72  parent = wxTheApp->GetTopWindow();
73  }
74 
75  bool res = wxFrame::Create(parent, id, title, pos, size, style, name);
76  wxVisualAttributes attr = wxPanel::GetClassDefaultAttributes();
77  if (attr.colBg != wxNullColour)
78  SetOwnBackgroundColour(attr.colBg);
79  return res;
80 }
81 
82 bool CBulkCmdDlg::Create (wxWindow *parent, IWorkbench* wb, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style, const wxString &name)
83 {
84  m_Workbench = wb;
85  if ( !parent )
86  {
87  parent = wxTheApp->GetTopWindow();
88  }
89  return wxFrame::Create(parent, id, title, pos, size, style, name);
90 }
91 
92 void CBulkCmdDlg::onCancelPressed( wxCommandEvent& event )
93 {
94  Destroy();
95 }
96 
98 {
99  m_TopSeqEntry.Reset();
102  if (!m_Workbench) return false;
103 
106  if (!sel_srv) return false;
107  sel_srv->GetActiveObjects(objects);
108  if (objects.empty())
109  {
111  }
112  if (objects.empty())
113  return false;
115  const CSeq_submit* sub = dynamic_cast<const CSeq_submit*>((*it).object.GetPointer());
116  if (sub) {
117  m_SeqSubmit.Reset(sub);
118  }
120 
121  if (seh) {
122  m_TopSeqEntry = seh;
123  }
124  }
125  if (!m_TopSeqEntry) return false;
127  if (srv)
128  {
129  CRef<CGBWorkspace> ws = srv->GetGBWorkspace();
130  if (!ws) return false;
131 
132  CGBDocument* doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(m_TopSeqEntry.GetScope()));
133  if (doc)
134  m_CmdProccessor = &doc->GetUndoManager();
135  }
136  return true;
137 }
138 
139 
141 {
143 }
144 
146 {
147  TConstScopedObjects sel_objects;
148  if (!m_Workbench) {
149  return sel_objects;
150  }
151 
153  if (sel_srv)
154  {
155  sel_srv->GetActiveObjects(sel_objects);
156  }
157  if (sel_objects.empty())
158  {
159  GetViewObjects(m_Workbench, sel_objects);
160  }
161  return sel_objects;
162 }
163 
165 {
166  wxSizerItemList& slist = sizer->GetChildren();
167  int n =0;
168  for (wxSizerItemList::iterator iter = slist.begin(); iter != slist.end(); ++iter, ++n) {
169  if ((*iter)->IsSizer()) {
170  UpdateChildrenFeaturePanels((*iter)->GetSizer());
171  } else if ((*iter)->IsWindow()) {
172  wxWindow* child = (*iter)->GetWindow();
173  if (child) {
174  CFeatureTypePanel* panel = dynamic_cast<CFeatureTypePanel*>(child);
175  if (panel) {
178  } else {
179  wxSizer* subsizer = child->GetSizer();
180  if (subsizer) {
181  UpdateChildrenFeaturePanels(subsizer);
182  } else {
183  // do nothing
184  }
185  }
186  }
187  }
188  }
189 }
190 
191 
192 edit::EExistingText CBulkCmdDlg::x_GetExistingTextHandling (int num_conflicts, bool allow_multiple)
193 {
195  if (num_conflicts > 0) {
196  string msg = "Do you want to overwrite " + NStr::NumericToString(num_conflicts) + " existing values?";
197  int answer = wxMessageBox(ToWxString(msg), wxT("Existing Text"),
198  wxYES_NO | wxCANCEL | wxICON_QUESTION, this);
199  if (answer == wxCANCEL) {
200  existing_text = edit::eExistingText_cancel;
201  } else if (answer == wxYES) {
202  existing_text = edit::eExistingText_replace_old;
203  } else {
204  CExistingTextDlg dlg(this);
205  dlg.AllowAdditionalQual(allow_multiple);
206  if (dlg.ShowModal() == wxID_OK) {
207  existing_text = dlg.GetExistingTextHandler();
208  } else {
209  existing_text = edit::eExistingText_cancel;
210  }
211  dlg.Close();
212  }
213  }
214 
215  return existing_text;
216 }
217 
218 
219 void AddSize(wxSize& orig, const wxSize& add, int borders)
220 {
221  if (orig.GetWidth() < add.GetWidth() + borders) {
222  orig.SetWidth(add.GetWidth() + borders);
223  }
224  orig.SetHeight(orig.GetHeight() + add.GetHeight() + borders);
225 }
226 
227 
228 
230 
231 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
#define bool
Definition: bool.h:34
void AddSize(wxSize &orig, const wxSize &add, int borders)
USING_SCOPE(ncbi::objects)
TConstScopedObjects GetSelectedObjects()
virtual void ExecuteCmd(CRef< CCmdComposite > cmd)
void onCancelPressed(wxCommandEvent &event)
CConstRef< objects::CSeq_submit > m_SeqSubmit
objects::CSeq_entry_Handle m_TopSeqEntry
bool Create(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxFrameNameStr)
IWorkbench * m_Workbench
bool GetTopLevelSeqEntryAndProcessor()
ICommandProccessor * m_CmdProccessor
void UpdateChildrenFeaturePanels(wxSizer *sizer)
edit::EExistingText x_GetExistingTextHandling(int num_conflicts, bool allow_multiple=false)
objects::edit::EExistingText GetExistingTextHandler()
void AllowAdditionalQual(bool val)
void ListPresentFeaturesFirst(const objects::CSeq_entry_Handle &entry, vector< const objects::CFeatListItem * > *featlist=nullptr)
CGBDocument.
Definition: document.hpp:113
CUndoManager & GetUndoManager()
Definition: document.hpp:158
CProjectService - a service providing API for operations with Workspaces and Projects.
CRef –.
Definition: ncbiobj.hpp:618
CSeq_entry_Handle –.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
Definition: service.hpp:91
objects::CSeq_entry_Handle GetTopSeqEntryFromScopedObject(SConstScopedObject &obj)
Definition: utils.cpp:2542
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
END_EVENT_TABLE()
yy_size_t n
void GetViewObjects(IWorkbench *workbench, TConstScopedObjects &objects)
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
EExistingText
@ eExistingText_cancel
@ eExistingText_replace_old
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
#define const
Definition: zconf.h:230
Modified on Fri Dec 01 04:45:36 2023 by modify_doxy.py rev. 669887