"Fossies" - the Fresh Open Source Software Archive

Member "ldapexplorertool-2.0.1/src/attribute_add_dlg.cc" (1 Sep 2006, 2427 Bytes) of package /linux/privat/old/ldapexplorertool-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "attribute_add_dlg.cc" see the Fossies "Dox" file reference documentation.

    1 #include "wx/wxprec.h"
    2 
    3 #ifdef __BORLANDC__
    4     #pragma hdrstop
    5 #endif
    6 
    7 #ifndef WX_PRECOMP
    8     #include "wx/wx.h"
    9 #endif
   10 
   11 #include <wx/xrc/xmlres.h>
   12 #include <wx/splitter.h>
   13 #include <wx/treectrl.h>
   14 #include <wx/listctrl.h>
   15 #include <wx/config.h>
   16 
   17 #include "ldapentry.h"
   18 #include "ldapclass.h"
   19 #include "config_fct.h"
   20 #include "attribute_add_dlg.h"
   21 
   22 
   23 BEGIN_EVENT_TABLE( Attribute_Add_Dlg, wxDialog )
   24 EVT_BUTTON( XRCID( "button_save" ), Attribute_Add_Dlg::OnSave )
   25 EVT_BUTTON( XRCID( "button_cancel" ), Attribute_Add_Dlg::OnCancel )
   26 
   27 END_EVENT_TABLE()
   28 
   29 
   30 
   31 Attribute_Add_Dlg::Attribute_Add_Dlg( wxWindow* p_Parent, const wxString& p_Dn, const wxString& p_ObjectClass, SchemaUtil& p_Ldap )
   32 {
   33     int Err ;
   34     wxXmlResource::Get()->LoadDialog( this, p_Parent, wxT( "attribute_add" ) );
   35     InitControls();
   36     m_Ldap = &p_Ldap ;
   37 
   38     m_Dn = p_Dn ;
   39     
   40     if( !m_Ldap->HasSchema() )
   41     {
   42         SetManual( true );
   43     }
   44     else
   45     {
   46         SetManual( false );
   47         wxArrayString   MayAt ;
   48         
   49         m_Ldap->GetMAYAttributeTypes( p_ObjectClass, MayAt );
   50     
   51         attributes_list_box->Clear();
   52         attributes_list_box->InsertItems( MayAt, 0 );
   53     }
   54     
   55     
   56 }
   57 
   58 void Attribute_Add_Dlg::InitControls()
   59 {
   60     attributes_list_box=(wxListBox*)FindWindowById( XRCID("attributes_list_box"),this );
   61     attribute_text_ctrl=(wxTextCtrl*)FindWindowById( XRCID("attribute_text_ctrl"),this );
   62     value_text_ctrl=(wxTextCtrl*)FindWindowById( XRCID("value_text_ctrl"),this );
   63     button_save=(wxButton*)FindWindowById( XRCID("button_save"),this );
   64     button_cancel=(wxButton*)FindWindowById( XRCID("button_cancel"),this );
   65 
   66 }
   67 
   68 void Attribute_Add_Dlg::OnSave( wxCommandEvent& WXUNUSED( p_Event ) )
   69 {
   70     LdapEntry   Entry ;
   71     wxString    Att;
   72     Entry.SetDn( m_Dn );
   73     wxString    Value ;
   74     
   75     if( attributes_list_box->IsEnabled() )
   76     {
   77         Att = attributes_list_box->GetStringSelection();
   78     }
   79     else
   80     {
   81         Att = attribute_text_ctrl->GetValue() ;
   82     }
   83 
   84     if( Att.Len() == 0 )
   85     {
   86         ::wxMessageBox( _("You must select an attribute"), _( "Error" ) ) ;
   87         return ;
   88     }
   89     Value =  value_text_ctrl->GetValue();
   90     if( Value.Len() == 0 )
   91     {
   92         ::wxMessageBox( _("You must enter a value for the attribute"), Att ) ;
   93         return ;
   94     }
   95     
   96     Entry.AddValue( Att, Value );
   97     int Err = m_Ldap->AddAttribute( Entry );
   98     if( Err != LDAP_SUCCESS )
   99     {
  100         ::wxMessageBox( m_Ldap->GetErrorStr(), Att );
  101         return ;
  102     }
  103     EndModal( wxID_OK );
  104 }
  105 void Attribute_Add_Dlg::SetManual( bool p_Manual )
  106 {
  107     attributes_list_box->Enable( !p_Manual );
  108     
  109     attribute_text_ctrl->Enable( p_Manual );
  110 }