///////////////////////////////////////////////////////////////////////////// // Name: dbrelation.h // Purpose: Database Objects // Author: Daniel Horak // Modified by: // RCS-ID: $Id: dbrelation.h,v 1.3 2004/01/01 13:56:19 horakdan Exp $ // Copyright: (c) Daniel Horak // Licence: GPL ///////////////////////////////////////////////////////////////////////////// #ifndef __DBRELATION_H #define __DBRELATION_H #define DBO_RELATION_TYPE_IDENT 0 #define DBO_RELATION_TYPE_NONIDENT 1 #define DBO_RELATION_TYPE_INFORM 2 #define DBO_RELATION_PARCIALITY_MANDATORY 0 #define DBO_RELATION_PARCIALITY_NONMANDATORY 1 #define DBO_RELATION_REFINTEG_NONE 0 #define DBO_RELATION_REFINTEG_RESTRICT 1 #define DBO_RELATION_REFINTEG_CASCADE 2 #define DBO_RELATION_REFINTEG_SETNULL 3 #define DBO_RELATION_REFINTEG_SETDEFAULT 4 #define DBO_RELATION_REFINTEG_MATCH_FULL 0 #define DBO_RELATION_REFINTEG_MATCH_PARTIAL 1 class DBRelationAttributeContainer; class DBRelationAttributeListCtrl; class DBModelRelation; class DBRelation : public DBObject { public: DBRelation(DataDesignerProject *project, DataDesignerContainer *container); virtual ~DBRelation(); virtual wxTreeItemId AppendItem(); virtual wxDialog *Editor(bool edit); virtual void LoadXmlNode(wxXmlNode *node); virtual wxXmlNode *GetXmlNode(); virtual void CreateShape(); bool ParseParciality(const wxString& parc, int& var); bool ParseRefIntegParent(const wxString& refinteg, int& var); bool ParseRefIntegChild(const wxString& refinteg, int& var); void ParcialityToString(int parc, wxString& str); void RefIntegToString(int refinteg, wxString& str); void LinkAttributes(); void AddAttributesToKeys(const wxString& attr_parent, const wxString& attr_child); void AddModelRelation(DBModelRelation *rel); void DeleteModelRelation(DBModelRelation *rel); wxString m_parent; wxString m_child; int m_type; // identifying/non-identifying/informational int m_parciality_parent; int m_parciality_child; int m_refinteg_parent_update; int m_refinteg_parent_delete; int m_refinteg_child_insert; int m_refinteg_child_update; int m_refinteg_match; DBRelationAttributeContainer *m_keys; DBObjectList m_modelrelations; }; class DBRelationEditor : public DBObjectEditor { public: DBRelationEditor(DBObject *object, bool edit); virtual ~DBRelationEditor(); virtual bool TransferDataFromWindow(); virtual bool TransferDataToWindow(); virtual bool Validate(); void OnApply(wxCommandEvent& event); protected: wxPanel *m_page_refinteg; wxPanel *m_page_keys; DBRelationAttributeListCtrl *m_list_keys; private: wxComboBox *c1; // parent wxComboBox *c2; // child wxRadioBox *r3; // type wxRadioBox *r4; // parent parciality wxRadioBox *r5; // child parciality wxComboBox *c6; // ref.integrity parent - update wxComboBox *c7; // ref.integrity parent - delete wxComboBox *c8; // ref.integrity child - insert wxComboBox *c9; // ref.integrity child - update wxRadioBox *r10; // match full/partial static wxString m_type_str[]; static wxString m_parciality_str[]; static wxString m_refinteg_parent_str[]; static wxString m_refinteg_child_str[]; static wxString m_refinteg_match_str[]; DECLARE_EVENT_TABLE() }; class DBRelationContainer : public DataDesignerContainer { public: DBRelationContainer(DataDesignerProject *project, const wxTreeItemId& id); virtual ~DBRelationContainer() { } virtual DBObject *CreateObject(); virtual void ShowList(); }; class DBRelationListCtrl : public DBObjectListCtrl { public: DBRelationListCtrl(wxWindow *parent, DataDesignerContainer *container); virtual ~DBRelationListCtrl(); virtual void SetObject(long item, DBObject *object); }; class DBRelationShape : public wxLineShape { public: DBRelationShape(DBRelation *relation); private: wxShape *m_shape_from; wxShape *m_shape_to; }; #endif // __DBRELATION_H