///////////////////////////////////////////////////////////////////////////// // Name: dbproject.cc // Purpose: Database Objects // Author: Daniel Horak // Modified by: // RCS-ID: $Id: dbproject.cc,v 1.2 2003/12/28 18:53:10 horakdan Exp $ // Copyright: (c) Daniel Horak // Licence: GPL ///////////////////////////////////////////////////////////////////////////// // ============================================================================ // declarations // ============================================================================ // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- // For compilers that support precompilation, includes "wx/wx.h". #include #ifdef __BORLANDC__ #pragma hdrstop #endif // for all others, include the necessary headers (this file is usually all you // need because it includes almost all "standard" wxWindows headers #ifndef WX_PRECOMP #include #endif #include "config.h" #include "xml.h" #include "dbobject.h" #include "dbproject.h" #include "servers/dbserver.h" DBProject::DBProject(DataDesignerProject *project) :DBObject(DBProjectType, "project", project, NULL) { } wxDialog *DBProject::Editor(bool edit) { return new DBProjectEditor(this, edit); } void DBProject::LoadXmlNode(wxXmlNode *node) { if (node->GetName() == m_typestr) { DBObject::LoadXmlNode(node); m_author = node->GetPropVal("author", wxEmptyString); m_copyright = node->GetPropVal("copyright", wxEmptyString); m_dbserver = node->GetPropVal("dbserver", wxEmptyString); wxXmlNode *child = node->GetChildren(); wxString name; while (child) { name = child->GetName(); if (name == "author") LoadTextNode(child, "author", m_author); else if (name == "copyright") LoadTextNode(child, "copyright", m_copyright); else if (name == "dbserver") LoadTextNode(child, "dbserver", m_dbserver); child = child->GetNext(); } } else { wxLogMessage("wrong type '%s'", node->GetName().c_str()); } } wxXmlNode *DBProject::GetXmlNode() { wxXmlNode *node = DBObject::GetXmlNode(); node->AddChild(GetTextNode("author", m_author)); node->AddChild(GetTextNode("copyright", m_copyright)); node->AddChild(GetTextNode("dbserver", m_dbserver)); return node; } /* * Editor */ DBProjectEditor::DBProjectEditor(DBObject *object, bool edit) : DBObjectEditor(_("Project"), wxSize(500,200), object, edit) { wxString *names; it4->Disable(); names = GetServerNames(); new wxStaticText(m_page_general, -1, _("Server"), wxPoint(10,60), wxSize(80,-1), wxALIGN_RIGHT); c1 = new wxComboBox(m_page_general, -1, wxEmptyString, wxPoint(100,60), wxSize(150,-1), GetServerCount(), names, wxCB_SORT | wxCB_READONLY); if (object->GetProject()->IsInitialized()) c1->Disable(); } DBProjectEditor::~DBProjectEditor() { } bool DBProjectEditor::TransferDataFromWindow() { DBProject *object = (DBProject *)GetObject(); DBObjectEditor::TransferDataFromWindow(); object->m_dbserver = c1->GetValue(); return TRUE; } bool DBProjectEditor::TransferDataToWindow() { DBProject *object = (DBProject *)GetObject(); DBObjectEditor::TransferDataToWindow(); c1->SetValue(object->m_dbserver); return TRUE; } bool DBProjectEditor::Validate() { if (GetServerByName(c1->GetValue()) == NULL) { wxMessageBox(_("Unknown server"), _("Error"), wxOK | wxICON_ERROR); return FALSE; } return TRUE; }