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

Go to the SVN repository for this file.

1 /* $Id: authorized_access_panel.cpp 31212 2014-09-12 12:45:01Z bollin $
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 ////@begin includes
32 ////@end includes
33 
38 #include <wx/stattext.h>
39 #include <wx/sizer.h>
40 
41 ////@begin XPM images
42 ////@end XPM images
43 
46 
47 /*!
48  * CAuthorizedAccessPanel type definition
49  */
50 
51 IMPLEMENT_DYNAMIC_CLASS( CAuthorizedAccessPanel, wxPanel )
52 
53 
54 /*!
55  * CAuthorizedAccessPanel event table definition
56  */
57 
58 BEGIN_EVENT_TABLE( CAuthorizedAccessPanel, wxPanel )
59 
60 ////@begin CAuthorizedAccessPanel event table entries
61 ////@end CAuthorizedAccessPanel event table entries
62 
64 
65 
66 /*!
67  * CAuthorizedAccessPanel constructors
68  */
69 
71 {
72  Init();
73 }
74 
75 CAuthorizedAccessPanel::CAuthorizedAccessPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
76 {
77  Init();
78  Create(parent, id, pos, size, style);
79 }
80 
81 
82 /*!
83  * CAuthorizedAccessPanel creator
84  */
85 
86 bool CAuthorizedAccessPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
87 {
88 ////@begin CAuthorizedAccessPanel creation
89  wxPanel::Create( parent, id, pos, size, style );
90 
92  if (GetSizer())
93  {
94  GetSizer()->SetSizeHints(this);
95  }
96  Centre();
97 ////@end CAuthorizedAccessPanel creation
98  return true;
99 }
100 
101 
102 /*!
103  * CAuthorizedAccessPanel destructor
104  */
105 
107 {
108 ////@begin CAuthorizedAccessPanel destruction
109 ////@end CAuthorizedAccessPanel destruction
110 }
111 
112 
113 /*!
114  * Member initialisation
115  */
116 
118 {
119 ////@begin CAuthorizedAccessPanel member initialisation
120  m_StudyTxt = NULL;
121 ////@end CAuthorizedAccessPanel member initialisation
122 }
123 
124 
125 /*!
126  * Control creation for CAuthorizedAccessPanel
127  */
128 
130 {
131 ////@begin CAuthorizedAccessPanel content construction
132  CAuthorizedAccessPanel* itemPanel1 = this;
133 
134  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
135  itemPanel1->SetSizer(itemBoxSizer2);
136 
137  wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(0, 2, 0, 0);
138  itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
139 
140  wxStaticText* itemStaticText4 = new wxStaticText( itemPanel1, wxID_STATIC, _("Study"), wxDefaultPosition, wxDefaultSize, 0 );
141  itemFlexGridSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
142 
143  m_StudyTxt = new wxTextCtrl( itemPanel1, ID_TEXTCTRL22, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
144  itemFlexGridSizer3->Add(m_StudyTxt, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
145 
146 ////@end CAuthorizedAccessPanel content construction
147 }
148 
149 
150 /*!
151  * Should we show tooltips?
152  */
153 
155 {
156  return true;
157 }
158 
159 /*!
160  * Get bitmap resources
161  */
162 
163 wxBitmap CAuthorizedAccessPanel::GetBitmapResource( const wxString& name )
164 {
165  // Bitmap retrieval
166 ////@begin CAuthorizedAccessPanel bitmap retrieval
167  wxUnusedVar(name);
168  return wxNullBitmap;
169 ////@end CAuthorizedAccessPanel bitmap retrieval
170 }
171 
172 /*!
173  * Get icon resources
174  */
175 
176 wxIcon CAuthorizedAccessPanel::GetIconResource( const wxString& name )
177 {
178  // Icon retrieval
179 ////@begin CAuthorizedAccessPanel icon retrieval
180  wxUnusedVar(name);
181  return wxNullIcon;
182 ////@end CAuthorizedAccessPanel icon retrieval
183 }
184 
185 static const string kStudy = "Study";
186 
188 {
189  if (user) {
190  m_User.Reset(new CUser_object());
191  m_User->Assign(*user);
192  } else {
193  m_User.Reset(NULL);
194  }
195 
196  string study = "";
197 
198  if (m_User) {
199  // search for fields in user object
200  ITERATE(CUser_object::TData, it, m_User->GetData()) {
201  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()) {
202  if (NStr::EqualNocase((*it)->GetLabel().GetStr(), kStudy)) {
203  if ((*it)->IsSetData() && (*it)->GetData().IsStr()) {
204  study = (*it)->GetData().GetStr();
205  }
206  }
207  }
208  }
209  }
210 
211  m_StudyTxt->SetValue(ToWxString(study));
212 }
213 
214 
216 {
217  CRef<CUser_object> user(new CUser_object());
218 
219  if (m_User) {
220  user->Assign(*m_User);
221  }
222 
223  user->SetType().SetStr("AuthorizedAccess");
224 
225  // remove previous fields
226  // remove previous fields
227  if (user->IsSetData()) {
228  CUser_object::TData::iterator it = user->SetData().begin();
229  while (it != user->SetData().end()) {
230  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr() && NStr::EqualNocase((*it)->GetLabel().GetStr(), kStudy)) {
231  it = user->SetData().erase(it);
232  } else {
233  ++it;
234  }
235  }
236  }
237  string study = ToStdString(m_StudyTxt->GetValue());
238  if (!NStr::IsBlank(study)) {
239  CRef<CUser_field> new_field(new CUser_field());
240  new_field->SetLabel().SetStr(kStudy);
241  new_field->SetData().SetStr(study);
242  user->SetData().push_back(new_field);
243  }
244 
245  return user;
246 }
247 
248 
249 void CAuthorizedAccessPanel::ChangeSeqdesc(const objects::CSeqdesc& desc)
250 {
252  tmp->Assign(desc.GetUser());
254  TransferDataToWindow();
255 }
256 
257 
258 void CAuthorizedAccessPanel::UpdateSeqdesc(objects::CSeqdesc& desc)
259 {
260  TransferDataFromWindow();
262  desc.SetUser(*user);
263 }
264 
265 
267 
USING_SCOPE(objects)
static const string kStudy
CRef< objects::CUser_object > m_User
void Init()
Initialises member variables.
CRef< objects::CUser_object > GetUser_object()
void SetUser_object(CRef< objects::CUser_object > user)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
static bool ShowToolTips()
Should we show tooltips?
void CreateControls()
Creates the controls and sizers.
bool Create(wxWindow *parent, wxWindowID id=ID_CAUTHORIZEDACCESSPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
virtual void UpdateSeqdesc(objects::CSeqdesc &desc)
virtual void ChangeSeqdesc(const objects::CSeqdesc &desc)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#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 bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5352
bool IsSetData(void) const
the object itself Check if a value has been assigned to Data data member.
TData & SetData(void)
Assign a value to Data data member.
void SetLabel(TLabel &value)
Assign a value to Label data member.
void SetType(TType &value)
Assign a value to Type data member.
void SetData(TData &value)
Assign a value to Data data member.
vector< CRef< CUser_field > > TData
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
static char tmp[2048]
Definition: utf8.c:42
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sat Dec 02 09:21:31 2023 by modify_doxy.py rev. 669887