diff --git a/pgadmin/include/images/module.mk b/pgadmin/include/images/module.mk index 0fe12cf..a7670eb 100644 --- a/pgadmin/include/images/module.mk +++ b/pgadmin/include/images/module.mk @@ -189,6 +189,8 @@ pgadmin3_SOURCES += \ include/images/language.png \ include/images/languages.png \ include/images/loginroles.png \ + include/images/mview.png \ + include/images/mview-sm.png \ include/images/namespace-sm.png \ include/images/namespace.png \ include/images/namespaces.png \ diff --git a/pgadmin/include/schema/pgView.h b/pgadmin/include/schema/pgView.h index 281f68b..66ce60d 100644 --- a/pgadmin/include/schema/pgView.h +++ b/pgadmin/include/schema/pgView.h @@ -23,6 +23,14 @@ public: virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent); virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr = wxEmptyString); virtual pgCollection *CreateCollection(pgObject *obj); + int GetClosedIconId() + { + return WantSmallIcon() ? smallClosedId : closedId; + } + +protected: + int closedId, smallClosedId; + }; extern pgViewFactory viewFactory; @@ -33,6 +41,8 @@ public: pgView(pgSchema *newSchema, const wxString &newName = wxT("")); ~pgView(); + int GetIconId(); + wxString GetTranslatedMessage(int kindOfMessage) const; void ShowTreeDetail(ctlTree *browser, frmMain *form = 0, ctlListView *properties = 0, ctlSQLBox *sqlPane = 0); bool CanDropCascaded() diff --git a/pgadmin/pgAdmin3.vcxproj b/pgadmin/pgAdmin3.vcxproj index 2b5566d..0414e5f 100644 --- a/pgadmin/pgAdmin3.vcxproj +++ b/pgadmin/pgAdmin3.vcxproj @@ -3408,6 +3408,8 @@ + + diff --git a/pgadmin/pgAdmin3.vcxproj.filters b/pgadmin/pgAdmin3.vcxproj.filters index 1fc4929..42c731a 100644 --- a/pgadmin/pgAdmin3.vcxproj.filters +++ b/pgadmin/pgAdmin3.vcxproj.filters @@ -4097,6 +4097,12 @@ include\images + + include\images + + + include\images + include\images diff --git a/pgadmin/schema/pgView.cpp b/pgadmin/schema/pgView.cpp index 113c782..54b8d75 100644 --- a/pgadmin/schema/pgView.cpp +++ b/pgadmin/schema/pgView.cpp @@ -646,6 +646,14 @@ bool pgView::IsMaterializedView(wxString schemaName, wxString viewName) return false; } +int pgView::GetIconId() +{ + if (IsMaterializedView(this->GetSchema()->GetName(),this->GetName())) + return viewFactory.GetClosedIconId(); + else + return viewFactory.GetIconId(); +} + /////////////////////////////////////////////////// @@ -760,6 +768,30 @@ pgObject *pgViewFactory::CreateObjects(pgCollection *collection, ctlTree *browse { while (!views->Eof()) { + bool matViewFlag = false; + + if (collection->GetConnection()->BackendMinimumVersion(9, 3)) + { + wxString viewName = views->GetVal(wxT("relname")); + viewName.Replace(wxT("\\"), wxT("\\\\")); + viewName.Replace(wxT("'"), wxT("''")); + viewName.Append(wxT("'")); + viewName.Prepend(wxT("'")); + + wxString schemaName = collection->GetSchema()->GetName(); + schemaName.Replace(wxT("\\"), wxT("\\\\")); + schemaName.Replace(wxT("'"), wxT("''")); + schemaName.Append(wxT("'")); + schemaName.Prepend(wxT("'")); + + wxString sql = wxT("SELECT count(*) FROM pg_matviews WHERE matviewname = ") + viewName + wxT(" AND schemaname = ") + schemaName; + // If it materialized view then enable the flag + if (!collection->GetDatabase()->GetConnection() || collection->GetDatabase()->ExecuteScalar(sql) == wxT("0")) + matViewFlag = false; + else + matViewFlag = true; + } + view = new pgView(collection->GetSchema(), views->GetVal(wxT("relname"))); view->iSetOid(views->GetOid(wxT("oid"))); @@ -845,6 +877,9 @@ pgObject *pgViewFactory::CreateObjects(pgCollection *collection, ctlTree *browse if (browser) { collection->AppendBrowserItem(browser, view); + // If it is materialized view then display the materialized view icon + if (matViewFlag) + browser->SetItemImage(view->GetId(),viewFactory.GetClosedIconId()); views->MoveNext(); } else @@ -860,11 +895,15 @@ pgObject *pgViewFactory::CreateObjects(pgCollection *collection, ctlTree *browse #include "images/view.pngc" #include "images/view-sm.pngc" #include "images/views.pngc" +#include "images/mview.pngc" +#include "images/mview-sm.pngc" pgViewFactory::pgViewFactory() : pgSchemaObjFactory(__("View"), __("New View..."), __("Create a new View."), view_png_img, view_sm_png_img) { metaType = PGM_VIEW; + closedId = addIcon(mview_png_img); + smallClosedId = addIcon(mview_sm_png_img); }