1 ////////////////////////////////////////////////////////////////////////// 2 // 3 // pgAdmin III - PostgreSQL Tools 4 // 5 // Copyright (C) 2002 - 2016, The pgAdmin Development Team 6 // This software is released under the PostgreSQL Licence 7 // 8 // pgDomain.h PostgreSQL Domain 9 // 10 ////////////////////////////////////////////////////////////////////////// 11 12 #ifndef PGDOMAIN_H 13 #define PGDOMAIN_H 14 15 #include "pgSchema.h" 16 17 class pgCollection; 18 19 class pgDomainFactory : public pgSchemaObjFactory 20 { 21 public: 22 pgDomainFactory(); 23 virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent); 24 virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr = wxEmptyString); 25 virtual pgCollection *CreateCollection(pgObject *obj); 26 }; 27 extern pgDomainFactory domainFactory; 28 29 30 class pgDomain : public pgSchemaObject 31 { 32 public: 33 pgDomain(pgSchema *newSchema, const wxString &newName = wxT("")); 34 ~pgDomain(); 35 36 wxString GetTranslatedMessage(int kindOfMessage) const; 37 void ShowTreeDetail(ctlTree *browser, frmMain *form = 0, ctlListView *properties = 0, ctlSQLBox *sqlPane = 0); CanDropCascaded()38 bool CanDropCascaded() 39 { 40 return GetSchema()->GetMetaType() != PGM_CATALOG; 41 } 42 GetBasetype()43 wxString GetBasetype() const 44 { 45 return basetype; 46 } iSetBasetype(const wxString & s)47 void iSetBasetype(const wxString &s) 48 { 49 basetype = s; 50 } GetQuotedBasetype()51 wxString GetQuotedBasetype() const 52 { 53 return quotedBasetype; 54 } iSetQuotedBasetype(const wxString & s)55 void iSetQuotedBasetype(const wxString &s) 56 { 57 quotedBasetype = s; 58 } GetCollation()59 wxString GetCollation() const 60 { 61 return collation; 62 } iSetCollation(const wxString & s)63 void iSetCollation(const wxString &s) 64 { 65 collation = s; 66 } GetQuotedCollation()67 wxString GetQuotedCollation() const 68 { 69 return quotedCollation; 70 } iSetQuotedCollation(const wxString & s)71 void iSetQuotedCollation(const wxString &s) 72 { 73 quotedCollation = s; 74 } iSetIsDup(bool b)75 void iSetIsDup(bool b) 76 { 77 isDup = b; 78 } GetLength()79 long GetLength() const 80 { 81 return length; 82 } iSetLength(long l)83 void iSetLength(long l) 84 { 85 length = l; 86 } GetPrecision()87 long GetPrecision() const 88 { 89 return precision; 90 } iSetPrecision(long l)91 void iSetPrecision(long l) 92 { 93 precision = l; 94 } GetCheck()95 wxString GetCheck() const 96 { 97 return check; 98 } iSetCheck(const wxString & s)99 void iSetCheck(const wxString &s) 100 { 101 check = s; 102 } GetDefault()103 wxString GetDefault() const 104 { 105 return defaultVal; 106 } iSetDefault(const wxString & s)107 void iSetDefault(const wxString &s) 108 { 109 defaultVal = s; 110 } GetNotNull()111 bool GetNotNull() const 112 { 113 return notNull; 114 } iSetNotNull(bool b)115 void iSetNotNull(bool b) 116 { 117 notNull = b; 118 } GetDimensions()119 long GetDimensions() const 120 { 121 return dimensions; 122 } iSetDimensions(long l)123 void iSetDimensions(long l) 124 { 125 dimensions = l; 126 } GetDelimiter()127 wxString GetDelimiter() const 128 { 129 return delimiter; 130 } iSetDelimiter(const wxString & s)131 void iSetDelimiter(const wxString &s) 132 { 133 delimiter = s; 134 } GetBasetypeOid()135 OID GetBasetypeOid() const 136 { 137 return basetypeOid; 138 } iSetBasetypeOid(OID d)139 void iSetBasetypeOid(OID d) 140 { 141 basetypeOid = d; 142 } GetCollationOid()143 OID GetCollationOid() const 144 { 145 return collationOid; 146 } iSetCollationOid(OID d)147 void iSetCollationOid(OID d) 148 { 149 collationOid = d; 150 } GetTyplen()151 long GetTyplen() const 152 { 153 return typlen; 154 } iSetTyplen(const long l)155 void iSetTyplen(const long l) 156 { 157 typlen = l; 158 } GetTypmod()159 long GetTypmod() const 160 { 161 return typmod; 162 } iSetTypmod(const long l)163 void iSetTypmod(const long l) 164 { 165 typmod = l; 166 } GetValid()167 bool GetValid() const 168 { 169 return constraintvalid; 170 } iSetValid(const bool b)171 void iSetValid(const bool b) 172 { 173 constraintvalid = b; 174 } GetCheckConstraintName()175 wxString GetCheckConstraintName() const 176 { 177 return checkconstraintname; 178 } iSetCheckConstraintName(const wxString & s)179 void iSetCheckConstraintName(const wxString &s) 180 { 181 checkconstraintname = s; 182 } 183 184 bool DropObject(wxFrame *frame, ctlTree *browser, bool cascaded); 185 wxString GetSql(ctlTree *browser); 186 pgObject *Refresh(ctlTree *browser, const wxTreeItemId item); 187 wxMenu *GetNewMenu(); 188 HasStats()189 bool HasStats() 190 { 191 return false; 192 } HasDepends()193 bool HasDepends() 194 { 195 return true; 196 } HasReferences()197 bool HasReferences() 198 { 199 return true; 200 } 201 void Validate(frmMain *form); 202 203 private: 204 wxString basetype, quotedBasetype, defaultVal, delimiter, check, collation, quotedCollation, checkconstraintname; 205 long length, precision, dimensions; 206 long typlen, typmod; 207 bool notNull, isDup, constraintvalid; 208 OID basetypeOid, collationOid; 209 }; 210 211 class pgDomainCollection : public pgSchemaObjCollection 212 { 213 public: 214 pgDomainCollection(pgaFactory *factory, pgSchema *sch); 215 wxString GetTranslatedMessage(int kindOfMessage) const; 216 }; 217 218 class validateDomainCheckFactory : public contextActionFactory 219 { 220 public: 221 validateDomainCheckFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar); 222 wxWindow *StartDialog(frmMain *form, pgObject *obj); 223 bool CheckEnable(pgObject *obj); 224 }; 225 226 #endif 227