add publication

Add view publications.
Change shortkeys Commit/Rollback
This commit is contained in:
levinsv 2018-11-01 21:43:08 +05:00
parent f494f68237
commit 6f68d6f22b
13 changed files with 1568 additions and 1103 deletions

View file

@ -24,3 +24,7 @@ This text Russian language.
Удалено отображение узлов имеющих статус (Never execute) на закладке графического плана, но в табличном виде они присутствуют.
01.11.2018
Добавлено отображение publications
Добавлено изменение фона при при не закоммиченой транзакции
У Commit/Rollback измененены горячие клавиши

Binary file not shown.

View file

@ -76,7 +76,16 @@ ctlSQLBox::ctlSQLBox(wxWindow *parent, wxWindowID id, const wxPoint &pos, const
Create(parent, id, pos, size, style);
}
wxColour ctlSQLBox::SetSQLBoxColourBackground(bool transaction) {
wxColour bgColor = settings->GetSQLBoxColourBackground();
if (settings->GetSQLBoxUseSystemBackground())
{
bgColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
}
if (transaction) bgColor = wxColour(241, 241, 186);
StyleSetBackground(wxSTC_STYLE_DEFAULT, bgColor);
return bgColor;
}
void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
{
wxStyledTextCtrl::Create(parent, id , pos, size, style);
@ -87,19 +96,19 @@ void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
// Font
extern sysSettings *settings;
wxFont fntSQLBox = settings->GetSQLFont();
wxColour bgColor = settings->GetSQLBoxColourBackground();
if (settings->GetSQLBoxUseSystemBackground())
{
bgColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
}
wxColour bgColor=SetSQLBoxColourBackground(false);
//wxColour bgColor = settings->GetSQLBoxColourBackground();
//if (settings->GetSQLBoxUseSystemBackground())
//{
// bgColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
//}
wxColour frColor = settings->GetSQLBoxColourForeground();
if (settings->GetSQLBoxUseSystemForeground())
{
frColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
}
StyleSetBackground(wxSTC_STYLE_DEFAULT, bgColor);
// StyleSetBackground(wxSTC_STYLE_DEFAULT, bgColor);
StyleSetForeground(wxSTC_STYLE_DEFAULT, frColor);
StyleSetFont(wxSTC_STYLE_DEFAULT, fntSQLBox);

View file

@ -127,6 +127,7 @@
#define pickerSQLColour11 CTRL_COLOURPICKER("pickerSQLColour11")
#define pickerSQLCaretColour CTRL_COLOURPICKER("pickerSQLCaretColour")
#define chkKeywordsInUppercase CTRL_CHECKBOX("chkKeywordsInUppercase")
#define chkASUTPstyle CTRL_CHECKBOX("chkASUTPstyle")
#define menus CTRL_TREE("menus")
#define pnlBrowserDisplay CTRL_PANEL("pnlBrowserDisplay")
#define pnlBrowserProperties CTRL_PANEL("pnlBrowserProperties")
@ -355,7 +356,7 @@ frmOptions::frmOptions(frmMain *parent)
pickerSQLColour11->SetColour(settings->GetSQLBoxColour(11));
chkKeywordsInUppercase->SetValue(settings->GetSQLKeywordsInUppercase());
chkASUTPstyle->SetValue(settings->GetASUTPstyle());
cbLanguage->Append(_("Default"));
int sel = 0;
wxLanguage langId = settings->GetCanonicalLanguage();
@ -392,6 +393,7 @@ frmOptions::frmOptions(frmMain *parent)
lstDisplay->Append(_("Casts"));
lstDisplay->Append(_("Event Triggers"));
lstDisplay->Append(_("Extensions"));
lstDisplay->Append(_("Publications"));
lstDisplay->Append(_("Foreign Data Wrappers"));
lstDisplay->Append(_("Foreign Servers"));
lstDisplay->Append(_("User Mappings"));
@ -854,10 +856,10 @@ void frmOptions::OnOK(wxCommandEvent &ev)
changed = true;
settings->SetSQLBoxColour(11, pickerSQLColour11->GetColourString());
if (settings->GetSQLKeywordsInUppercase() != chkKeywordsInUppercase->GetValue())
if (settings->GetASUTPstyle() != chkASUTPstyle->GetValue())
{
changed = true;
settings->SetSQLKeywordsInUppercase(chkKeywordsInUppercase->GetValue());
settings->SetASUTPstyle(chkASUTPstyle->GetValue());
}
// Change the language last, as it will affect our tests for changes

View file

@ -349,8 +349,8 @@ frmQuery::frmQuery(frmMain *form, const wxString &_title, pgConn *_conn, const w
queryMenu->AppendSeparator();
queryMenu->Append(MNU_CANCEL, _("&Cancel\tAlt-Break"), _("Cancel query"));
queryMenu->AppendSeparator();
queryMenu->Append(MNU_DOCOMMIT, _("Commit\tCtrl-Shift-C"), _("Commit"));
queryMenu->Append(MNU_DOROLLBACK, _("Rollback\tCtrl-Shift-R"), _("Rollback"));
queryMenu->Append(MNU_DOCOMMIT, _("Commit\tF10"), _("Commit"));
queryMenu->Append(MNU_DOROLLBACK, _("Rollback\tShift-F10"), _("Rollback"));
menuBar->Append(queryMenu, _("&Query"));
favouritesMenu = new wxMenu();
@ -2664,6 +2664,7 @@ void frmQuery::setTools(const bool running)
fileMenu->Enable(MNU_QUICKREPORT, sqlResult->CanExport());
fileMenu->Enable(MNU_RECENT, (recentFileMenu->GetMenuItemCount() > 0));
sqlQuery->EnableAutoComp(running);
sqlQuery->SetSQLBoxColourBackground(canEndTransaction);
}

View file

@ -79,6 +79,7 @@ public:
// Having multiple SQL tabs warrants the following properties to be tracked per tab
void SetChanged(bool b);
bool IsChanged();
wxColor SetSQLBoxColourBackground(bool transaction);
void SetOrigin(int origin);
int GetOrigin();
void SetFilename(wxString &filename);

View file

@ -0,0 +1,128 @@
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// pgExtension.h PostgreSQL Extension
//
//////////////////////////////////////////////////////////////////////////
#ifndef PGPUBLICATION_H
#define PGPUBLICATION_H
#include "pgDatabase.h"
class pgCollection;
class pgPublicationFactory : public pgDatabaseObjFactory
{
public:
pgPublicationFactory();
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);
};
extern pgPublicationFactory publicationFactory;
class pgPublication : public pgDatabaseObject
{
public:
pgPublication(const wxString &newName = wxT(""));
wxString GetTranslatedMessage(int kindOfMessage) const;
void ShowTreeDetail(ctlTree *browser, frmMain *form = 0, ctlListView *properties = 0, ctlSQLBox *sqlPane = 0);
bool CanDropCascaded()
{
return true;
}
wxString GetTablesStr() const
{
return tables;
}
void iSetTablesStr(const wxString &s)
{
tables = s;
}
wxString GetVersion() const
{
return version;
}
void iSetVersion(const wxString &s)
{
version = s;
}
bool GetIsAll() const
{
return all;
}
void iSetIsAll(const bool b)
{
all = b;
}
bool GetIsIns() const
{
return ins;
}
void iSetIsIns(const bool b)
{
ins = b;
}
bool GetIsUpd() const
{
return upd;
}
void iSetIsUpd(const bool b)
{
upd = b;
}
bool GetIsDel() const
{
return del;
}
wxString GetStrOper() const
{
wxString s = wxT("");
if (GetIsIns()) s += wxT("insert");
if (GetIsUpd()&&(!s.IsEmpty())) s += wxT(", ");
if (GetIsUpd()) s += wxT("update");
if (GetIsDel()&&(!s.IsEmpty())) s += wxT(", ");
if (GetIsDel()) s += wxT("delete");
return s;
}
void iSetIsDel(const bool b)
{
del = b;
}
bool DropObject(wxFrame *frame, ctlTree *browser, bool cascaded);
wxString GetSql(ctlTree *browser);
pgObject *Refresh(ctlTree *browser, const wxTreeItemId item);
bool HasStats()
{
return false;
}
bool HasDepends()
{
return false;
}
bool HasReferences()
{
return false;
}
private:
wxString tables, version;
bool all,ins,upd,del;
};
class pgPublicationCollection : public pgDatabaseObjCollection
{
public:
pgPublicationCollection(pgaFactory *factory, pgDatabase *db);
wxString GetTranslatedMessage(int kindOfMessage) const;
};
#endif

View file

@ -784,7 +784,18 @@ public:
{
WriteBool(wxT("ShowNotices"), newval);
}
bool GetASUTPstyle() const
{
bool b;
Read(wxT("ASUTPstyle"), &b, false);
return b;
}
void SetASUTPstyle(const bool newval)
{
WriteBool(wxT("ASUTPstyle"), newval);
}
wxString GetOptionsLastTreeItem() const
{
wxString s;

View file

@ -20,6 +20,7 @@
#include "schema/edbSynonym.h"
#include "schema/pgCast.h"
#include "schema/pgExtension.h"
#include "schema/pgPublication.h"
#include "schema/pgForeignDataWrapper.h"
#include "schema/pgLanguage.h"
#include "schema/pgSchema.h"
@ -144,6 +145,8 @@ wxMenu *pgDatabase::GetNewMenu()
castFactory.AppendMenu(menu);
if (settings->GetDisplayOption(_("Extensions")) && GetConnection()->BackendMinimumVersion(9, 1))
extensionFactory.AppendMenu(menu);
if (settings->GetDisplayOption(_("Publications")) && GetConnection()->BackendMinimumVersion(10, 0))
publicationFactory.AppendMenu(menu);
if (settings->GetDisplayOption(_("Foreign Data Wrappers")) && GetConnection()->BackendMinimumVersion(8, 4))
foreignDataWrapperFactory.AppendMenu(menu);
if (settings->GetDisplayOption(_("Languages")))
@ -622,6 +625,8 @@ void pgDatabase::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *pr
browser->AppendCollection(this, eventTriggerFactory);
if (settings->GetDisplayOption(_("Extensions")) && GetConnection()->BackendMinimumVersion(9, 1))
browser->AppendCollection(this, extensionFactory);
if (settings->GetDisplayOption(_("Publications")) && GetConnection()->BackendMinimumVersion(10, 0))
browser->AppendCollection(this, publicationFactory);
if (settings->GetDisplayOption(_("Foreign Data Wrappers")) && GetConnection()->BackendMinimumVersion(8, 4))
browser->AppendCollection(this, foreignDataWrapperFactory);
if (settings->GetDisplayOption(_("Languages")))

253
schema/pgPublication.cpp Normal file
View file

@ -0,0 +1,253 @@
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// pgPublication.cpp - Publication class
//
//////////////////////////////////////////////////////////////////////////
// wxWindows headers
#include <wx/wx.h>
// App headers
#include "pgAdmin3.h"
#include "utils/misc.h"
#include "schema/pgPublication.h"
pgPublication::pgPublication(const wxString &newName)
: pgDatabaseObject(publicationFactory, newName)
{
}
wxString pgPublication::GetTranslatedMessage(int kindOfMessage) const
{
wxString message = wxEmptyString;
switch (kindOfMessage)
{
case RETRIEVINGDETAILS:
message = _("Retrieving details on publication");
message += wxT(" ") + GetName();
break;
case REFRESHINGDETAILS:
message = _("Refreshing publication");
message += wxT(" ") + GetName();
break;
case DROPINCLUDINGDEPS:
message = wxString::Format(_("Are you sure you wish to drop publication \"%s\" including all objects that depend on it?"),
GetFullIdentifier().c_str());
break;
case DROPEXCLUDINGDEPS:
message = wxString::Format(_("Are you sure you wish to drop publication \"%s\"?"),
GetFullIdentifier().c_str());
break;
case DROPCASCADETITLE:
message = _("Drop publication cascaded?");
break;
case DROPTITLE:
message = _("Drop publication?");
break;
case PROPERTIESREPORT:
message = _("Publication properties report");
message += wxT(" - ") + GetName();
break;
case PROPERTIES:
message = _("Publication properties");
break;
case DDLREPORT:
message = _("Publication DDL report");
message += wxT(" - ") + GetName();
break;
case DDL:
message = _("Publication DDL");
break;
case DEPENDENCIESREPORT:
message = _("Publication dependencies report");
message += wxT(" - ") + GetName();
break;
case DEPENDENCIES:
message = _("Publication dependencies");
break;
case DEPENDENTSREPORT:
message = _("Publication dependents report");
message += wxT(" - ") + GetName();
break;
case DEPENDENTS:
message = _("Publication dependents");
break;
}
return message;
}
bool pgPublication::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
wxString sql = wxT("DROP PUBLICATION ") + GetQuotedIdentifier();
if (cascaded)
sql += wxT(" CASCADE");
return GetDatabase()->ExecuteVoid(sql);
}
wxString pgPublication::GetSql(ctlTree *browser)
{
if (sql.IsNull())
{
sql = wxT("-- Publication: ") + GetQuotedIdentifier() + wxT("\n\n")
+ wxT("-- DROP PUBLICATION ") + GetQuotedIdentifier() + wxT(";")
+ wxT("\n\n CREATE PUBLICATION ") + GetName();
if (GetIsAll())
{
sql += wxT("\n FOR ALL TABLES ");
} else
{
sql += wxT("\n FOR TABLE ");
if (!GetTablesStr().IsEmpty())
sql += wxT("") + GetTablesStr();
}
if (GetIsIns()&&GetIsUpd()&&GetIsDel())
{
} else
{
sql += wxT("\n WITH (publish = '") + GetStrOper() + wxT("')");
}
sql += wxT(";\n");
}
return sql;
}
void pgPublication::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
if (properties)
{
CreateListColumns(properties);
properties->AppendItem(_("Name"), GetName());
properties->AppendItem(_("OID"), GetOid());
properties->AppendItem(_("Owner"), GetOwner());
properties->AppendItem(_("Tables"), GetTablesStr());
//properties->AppendYesNoItem(_("Relocatable?"), GetIsRelocatable());
//properties->AppendItem(_("Version"), GetVersion());
properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
}
}
pgObject *pgPublication::Refresh(ctlTree *browser, const wxTreeItemId item)
{
pgObject *language = 0;
pgCollection *coll = browser->GetParentCollection(item);
if (coll)
language = publicationFactory.CreateObjects(coll, 0, wxT("\n WHERE x.oid=") + GetOidStr());
return language;
}
pgObject *pgPublicationFactory::CreateObjects(pgCollection *collection, ctlTree *browser, const wxString &restriction)
{
wxString sql;
pgPublication *publication = 0;
sql = wxT("select x.oid,x.pubname, pg_get_userbyid(x.pubowner) AS owner, x.puballtables, x.pubinsert, x.pubupdate, x.pubdelete, obj_description(x.oid,'pg_publication') AS comment, t.t")
wxT(" FROM pg_publication x\n")
wxT(" LEFT JOIN LATERAL (select string_agg(schemaname||'.'||tablename,', ') t from pg_publication_tables where pubname=x.pubname) t on true \n")
wxT(" ")
+ restriction + wxT("\n")
wxT(" ORDER BY x.pubname");
pgSet *publications = collection->GetDatabase()->ExecuteSet(sql);
if (publications)
{
while (!publications->Eof())
{
publication = new pgPublication(publications->GetVal(wxT("pubname")));
publication->iSetDatabase(collection->GetDatabase());
publication->iSetOid(publications->GetOid(wxT("oid")));
publication->iSetOwner(publications->GetVal(wxT("owner")));
publication->iSetTablesStr(publications->GetVal(wxT("t")));
publication->iSetIsAll(publications->GetBool(wxT("puballtables")));
publication->iSetIsIns(publications->GetBool(wxT("pubinsert")));
publication->iSetIsUpd(publications->GetBool(wxT("pubupdate")));
publication->iSetIsDel(publications->GetBool(wxT("pubdelete")));
//publication->iSetVersion(publications->GetVal(wxT("extversion")));
publication->iSetComment(publications->GetVal(wxT("comment")));
if (browser)
{
browser->AppendObject(collection, publication);
publications->MoveNext();
}
else
break;
}
delete publications;
}
return publication;
}
/////////////////////////////
pgPublicationCollection::pgPublicationCollection(pgaFactory *factory, pgDatabase *db)
: pgDatabaseObjCollection(factory, db)
{
}
wxString pgPublicationCollection::GetTranslatedMessage(int kindOfMessage) const
{
wxString message = wxEmptyString;
switch (kindOfMessage)
{
case RETRIEVINGDETAILS:
message = _("Retrieving details on publications");
break;
case REFRESHINGDETAILS:
message = _("Refreshing publications");
break;
case OBJECTSLISTREPORT:
message = _("Publications list report");
break;
}
return message;
}
///////////////////////////////////////////////////
#include "images/extension.pngc"
#include "images/extension-sm.pngc"
#include "images/extensions.pngc"
pgPublicationFactory::pgPublicationFactory()
: pgDatabaseObjFactory(__("Publication"), __("New Publication..."), __("Create a new Publication."), extension_png_img, extension_sm_png_img)
{
}
pgCollection *pgPublicationFactory::CreateCollection(pgObject *obj)
{
return new pgPublicationCollection(GetCollectionFactory(), (pgDatabase *)obj);
}
dlgProperty *pgPublicationFactory::CreateDialog(frmMain *frame, pgObject *node, pgObject *parent)
{
return NULL;
}
pgPublicationFactory publicationFactory;
static pgaCollectionFactory cf(&publicationFactory, __("Publications"), extensions_png_img);

View file

@ -535,6 +535,21 @@
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="stASUTPstyle">
<label>Enable ASUTP style</label>
</object>
<flag>wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
<object class="sizeritem">
<object class="wxCheckBox" name="chkASUTPstyle">
<label></label>
<checked>1</checked>
</object>
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
</object>
</object>
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>

File diff suppressed because it is too large Load diff

View file

@ -123,6 +123,8 @@ bool sysSettings::GetDisplayOption(const wxString &objtype, bool GetDefault)
}
else if (objtype == _("Extensions"))
engtype = wxT("Extensions");
else if (objtype == _("Publications"))
engtype = wxT("Publications");
else if (objtype == _("Synonyms"))
engtype = wxT("Synonyms");
else if (objtype == _("Schemas"))
@ -217,6 +219,7 @@ void sysSettings::SetDisplayOption(const wxString &objtype, bool display)
else if (objtype == _("Languages")) engtype = wxT("Languages");
else if (objtype == _("Event Triggers")) engtype = wxT("Event Triggers");
else if (objtype == _("Extensions")) engtype = wxT("Extensions");
else if (objtype == _("Publications")) engtype = wxT("Publications");
else if (objtype == _("Synonyms")) engtype = wxT("Synonyms");
else if (objtype == _("Schemas")) engtype = wxT("Schemas");
else if (objtype == _("Slony-I Clusters")) engtype = wxT("Slony-I Clusters");