Index: TODO.txt
===================================================================
RCS file: /projects/pgadmin3/TODO.txt,v
retrieving revision 1.104
retrieving revision 1.105
diff -LTODO.txt -LTODO.txt -u -w -r1.104 -r1.105
--- TODO.txt
+++ TODO.txt
@@ -4,7 +4,6 @@
recreate views after column type change
pgDatatype to encapsulate all typmod handling, rewrite all other classes to use it
Improve database connection docs for newbies.
- refactor tree context menu: create instead of en/disable items
Enhancements
Index: CHANGELOG.txt
===================================================================
RCS file: /projects/pgadmin3/CHANGELOG.txt,v
retrieving revision 1.120
retrieving revision 1.121
diff -LCHANGELOG.txt -LCHANGELOG.txt -u -w -r1.120 -r1.121
--- CHANGELOG.txt
+++ CHANGELOG.txt
@@ -16,8 +16,10 @@
-
+ - 2004-08-05 AP win32 service control
+
- 2004-08-05 AP refactor tree context menu: create instead of en/disable items
- 2004-08-02 DP Auto-discover locally installed servers when registered by the Win32 binary installer.
+
- 2004-07-30 AP Tablespace usage fix for objects using the database's default tablespace
- 2004-07-27 AP Reworked schema prefixing
- 2004-07-25 AP support of pg_xxx_size if available
- 2004-07-21 AP Improved disconnect handling
Index: pgAdmin3.dsp
===================================================================
RCS file: /projects/pgadmin3/src/pgAdmin3.dsp,v
retrieving revision 1.106
retrieving revision 1.107
diff -Lsrc/pgAdmin3.dsp -Lsrc/pgAdmin3.dsp -u -w -r1.106 -r1.107
--- src/pgAdmin3.dsp
+++ src/pgAdmin3.dsp
@@ -1566,89 +1566,5 @@
SOURCE=..\TODO.txt
# End Source File
# End Group
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\blank.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\bullseye.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\cdrom.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\computer.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\drive.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\file1.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\floppy.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\folder1.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\folder2.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\hand.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\magnif1.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\noentry.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\pbrush.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\pencil.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\pntleft.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\pntright.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\query.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\removble.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\rightarr.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\roller.cur
-# End Source File
-# Begin Source File
-
-SOURCE=.\ui\wx\msw\watch1.cur
-# End Source File
# End Target
# End Project
Index: pgFunction.h
===================================================================
RCS file: /projects/pgadmin3/src/include/pgFunction.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -Lsrc/include/pgFunction.h -Lsrc/include/pgFunction.h -u -w -r1.25 -r1.26
--- src/include/pgFunction.h
+++ src/include/pgFunction.h
@@ -35,8 +35,6 @@
static pgObject *ReadObjects(pgCollection *collection, wxTreeCtrl *browser);
static pgFunction *pgFunction::AppendFunctions(pgObject *obj, pgSchema *schema, wxTreeCtrl *browser, const wxString &restriction);
- bool ReloadLibrary();
-
wxString GetFullName() const {return GetName()+wxT("(")+GetArgTypes()+wxT(")"); }
wxString GetArgTypeNames() const { return argTypeNames; }
void iSetArgTypeNames(const wxString& s) { argTypeNames=s; }
@@ -69,7 +67,6 @@
bool GetIsStrict() const { return isStrict; }
void iSetIsStrict(bool b) { isStrict = b; }
- bool CanReload();
bool CanRestore() { return true; }
bool DropObject(wxFrame *frame, wxTreeCtrl *browser);
wxString GetSql(wxTreeCtrl *browser);
Index: frmMain.h
===================================================================
RCS file: /projects/pgadmin3/src/include/frmMain.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -Lsrc/include/frmMain.h -Lsrc/include/frmMain.h -u -w -r1.48 -r1.49
--- src/include/frmMain.h
+++ src/include/frmMain.h
@@ -123,13 +123,15 @@
void OnDrop(wxCommandEvent &ev);
void OnDelete(wxCommandEvent &ev);
void OnProperties(wxCommandEvent &ev);
- void OnReload(wxCommandEvent &ev);
+ void OnStartService(wxCommandEvent &ev);
+ void OnStopService(wxCommandEvent &ev);
void OnRefresh(wxCommandEvent &ev);
void OnDisconnect(wxCommandEvent &ev);
void OnQueryBuilder(wxCommandEvent &ev);
void OnCheckAlive(wxCommandEvent& event);
+ void doPopup(wxPoint point, pgObject *object);
void execSelChange(wxTreeItemId item, bool currentNode);
bool checkAlive();
void setDisplay(pgObject *data, ctlListView *props=0, ctlSQLBox *sqlbox=0);
Index: pgServer.h
===================================================================
RCS file: /projects/pgadmin3/src/include/pgServer.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -Lsrc/include/pgServer.h -Lsrc/include/pgServer.h -u -w -r1.35 -r1.36
--- src/include/pgServer.h
+++ src/include/pgServer.h
@@ -34,6 +34,11 @@
int Connect(frmMain *form, bool lockFields = FALSE);
bool Disconnect();
+ bool StartService();
+ bool StopService();
+ bool GetServerRunning();
+ bool GetServerControllable();
+
pgServer *GetServer() const;
wxString GetIdentifier() const;
@@ -49,7 +54,7 @@
bool GetDiscovered() const { return discovered; }
void iSetDiscovered(const bool b) { discovered=b; }
wxString GetServiceID() const { return serviceId; }
- void iSetServiceID(const wxString& s) { serviceId=s; }
+ void iSetServiceID(const wxString& s);
bool GetCreatePrivilege() const { return createPrivilege; }
void iSetCreatePrivilege(const bool b) { createPrivilege=b; }
@@ -104,6 +109,11 @@
OID lastSystemOID;
wxString versionNum;
frmMain *parentWin;
+
+#ifdef WIN32
+ SC_HANDLE scmHandle;
+ SC_HANDLE serviceHandle;
+#endif
};
#endif
Index: menu.h
===================================================================
RCS file: /projects/pgadmin3/src/include/menu.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -Lsrc/include/menu.h -Lsrc/include/menu.h -u -w -r1.17 -r1.18
--- src/include/menu.h
+++ src/include/menu.h
@@ -77,7 +77,8 @@
MNU_EXPLAINOPTIONS,
MNU_VERBOSE,
MNU_ANALYZE,
- MNU_RELOAD,
+ MNU_STARTSERVICE,
+ MNU_STOPSERVICE,
MNU_CLEARHISTORY,
MNU_SAVEHISTORY,
MNU_CHECKALIVE,
Index: pgFunction.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgFunction.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -Lsrc/schema/pgFunction.cpp -Lsrc/schema/pgFunction.cpp -u -w -r1.36 -r1.37
--- src/schema/pgFunction.cpp
+++ src/schema/pgFunction.cpp
@@ -46,18 +46,6 @@
}
-bool pgFunction::CanReload()
-{
- return GetLanguage().IsSameAs(wxT("C"), false);
-}
-
-
-bool pgFunction::ReloadLibrary()
-{
- return ExecuteVoid(wxT("LOAD ") + qtString(GetBin()));
-}
-
-
wxString pgFunction::GetSql(wxTreeCtrl *browser)
{
if (sql.IsNull())
Index: pgServer.cpp
===================================================================
RCS file: /projects/pgadmin3/src/schema/pgServer.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -Lsrc/schema/pgServer.cpp -Lsrc/schema/pgServer.cpp -u -w -r1.44 -r1.45
--- src/schema/pgServer.cpp
+++ src/schema/pgServer.cpp
@@ -40,6 +40,10 @@
trusted=_trusted;
superUser=false;
createPrivilege=false;
+#ifdef WIN32
+ scmHandle = 0;
+ serviceHandle = 0;
+#endif
}
pgServer::~pgServer()
@@ -49,6 +53,12 @@
if (conn)
delete conn;
+#ifdef WIN32
+ if (serviceHandle)
+ CloseServiceHandle(serviceHandle);
+ if (scmHandle)
+ CloseServiceHandle(scmHandle);
+#endif
wxLogInfo(wxT("Destroying a pgServer object"));
}
@@ -118,6 +128,105 @@
}
+bool pgServer::StartService()
+{
+ bool done=false;
+#ifdef WIN32
+ if (serviceHandle)
+ {
+ done = (::StartService(serviceHandle, 0, 0) != 0);
+ if (!done)
+ {
+ DWORD rc = ::GetLastError();
+ if (rc == ERROR_SERVICE_ALREADY_RUNNING)
+ return true;
+
+ // report error
+ }
+ else
+ GetServerRunning(); // ignore result, just to wait for startup
+ }
+#endif
+ return done;
+}
+
+
+bool pgServer::StopService()
+{
+ bool done=false;
+#ifdef WIN32
+ if (serviceHandle)
+ {
+ SERVICE_STATUS st;
+ done = (::ControlService(serviceHandle, SERVICE_CONTROL_STOP, &st) != 0);
+ if (!done)
+ {
+ DWORD rc = ::GetLastError();
+ // report error
+ }
+ }
+#endif
+ return done;
+}
+
+bool pgServer::GetServerRunning()
+{
+ bool done=false;
+#ifdef WIN32
+ if (serviceHandle)
+ {
+ SERVICE_STATUS st;
+ int loops;
+
+ for (loops=0 ; loops < 20 ; loops++)
+ {
+ if (::QueryServiceStatus(serviceHandle, &st) == 0)
+ {
+ DWORD rc = ::GetLastError();
+ CloseServiceHandle(serviceHandle);
+ CloseServiceHandle(scmHandle);
+ serviceHandle=0;
+ scmHandle=0;
+
+ return false;
+ }
+ done = (st.dwCurrentState == SERVICE_RUNNING);
+ if (st.dwCurrentState == SERVICE_START_PENDING)
+ Sleep(100);
+ else
+ break;
+ }
+ }
+#endif
+ return done;
+}
+
+
+void pgServer::iSetServiceID(const wxString& s)
+{
+ serviceId = s;
+#ifdef WIN32
+ if (serviceId.Find('\\') < 0)
+ scmHandle = OpenSCManager(0, SERVICES_ACTIVE_DATABASE, GENERIC_EXECUTE);
+ else
+ scmHandle = OpenSCManager(serviceId.BeforeFirst('\\'), SERVICES_ACTIVE_DATABASE, GENERIC_EXECUTE|GENERIC_READ);
+
+ if (scmHandle)
+ serviceHandle=OpenService(scmHandle, serviceId.AfterLast('\\'), GENERIC_EXECUTE|GENERIC_READ);
+#endif
+}
+
+
+bool pgServer::GetServerControllable()
+{
+#ifdef WIN32
+ return serviceHandle != 0;
+#else
+ return false;
+#endif
+}
+
+
int pgServer::Connect(frmMain *form, bool lockFields)
{
wxLogInfo(wxT("Attempting to create a connection object..."));
@@ -370,7 +479,9 @@
properties->AppendItem(_("Version number"), GetVersionNumber());
properties->AppendItem(_("Last system OID"), GetLastSystemOID());
}
- properties->AppendItem(_("Connected?"), BoolToYesNo(GetConnected()));
+ properties->AppendItem(_("Connected?"), GetConnected());
+ if (GetServerControllable())
+ properties->AppendItem(_("Running?"), GetServerRunning());
}
if(!GetConnected())
Index: events.cpp
===================================================================
RCS file: /projects/pgadmin3/src/ui/events.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -Lsrc/ui/events.cpp -Lsrc/ui/events.cpp -u -w -r1.99 -r1.100
--- src/ui/events.cpp
+++ src/ui/events.cpp
@@ -88,7 +88,8 @@
EVT_MENU(MNU_SYSTEMOBJECTS, frmMain::OnShowSystemObjects)
EVT_MENU(MNU_TIPOFTHEDAY, frmMain::OnTipOfTheDay)
EVT_MENU(MNU_QUERYBUILDER, frmMain::OnQueryBuilder)
- EVT_MENU(MNU_RELOAD, frmMain::OnReload)
+ EVT_MENU(MNU_STARTSERVICE, frmMain::OnStartService)
+ EVT_MENU(MNU_STOPSERVICE, frmMain::OnStopService)
EVT_MENU(MNU_NEW+PG_DATABASE, frmMain::OnNew)
EVT_MENU(MNU_NEW+PG_USER, frmMain::OnNew)
EVT_MENU(MNU_NEW+PG_GROUP, frmMain::OnNew)
@@ -227,13 +228,29 @@
}
-void frmMain::OnReload(wxCommandEvent& WXUNUSED(event))
+void frmMain::OnStartService(wxCommandEvent& WXUNUSED(event))
{
- pgFunction *func = (pgFunction*)GetSelectedObject();
- if (func)
+ pgServer *server= (pgServer*)GetSelectedObject();
+ if (server && server->GetType() == PG_SERVER)
{
- StartMsg(wxT("Reloading library ") + func->GetBin());
- func->ReloadLibrary();
+ StartMsg(_("Starting service"));
+ bool rc = server->StartService();
+ if (rc)
+ execSelChange(server->GetId(), true);
+ EndMsg();
+ }
+}
+
+
+void frmMain::OnStopService(wxCommandEvent& WXUNUSED(event))
+{
+ pgServer *server= (pgServer*)GetSelectedObject();
+ if (server && server->GetType() == PG_SERVER)
+ {
+ StartMsg(_("Stopping service"));
+ bool rc = server->StopService();
+ if (rc)
+ execSelChange(server->GetId(), true);
EndMsg();
}
}
@@ -702,13 +719,14 @@
pgServer *server=0;
- bool canReload=false;
- bool canConnect=false;
- bool canDisconnect=false;
- bool canReindex=false;
- bool canIndexCheck=false;
- bool canGrantWizard=false;
- bool canCount=false;
+ bool canStart=false,
+ canStop=false,
+ canConnect=false,
+ canDisconnect=false,
+ canReindex=false,
+ canIndexCheck=false,
+ canGrantWizard=false,
+ canCount=false;
bool showTree=true;
@@ -718,6 +736,14 @@
StartMsg(_("Retrieving server properties"));
server = (pgServer *)data;
+
+ if (server->GetServerControllable())
+ {
+ if (server->GetServerRunning())
+ canStop = true;
+ else
+ canStart = true;
+ }
if (!server->GetConnected())
{
canConnect=true;
@@ -732,12 +758,6 @@
EndMsg();
break;
- case PG_FUNCTION:
- case PG_TRIGGERFUNCTION:
- {
- canReload=((pgFunction*)data)->CanReload();
- break;
- }
case PG_DATABASE:
case PG_SCHEMAS:
case PG_SCHEMA:
@@ -838,7 +858,6 @@
}
editMenu->Enable(MNU_NEWOBJECT, false);
- treeContextMenu->Enable(MNU_NEWOBJECT, false);
wxMenu *indivMenu=data->GetNewMenu();
if (indivMenu)
@@ -846,7 +865,6 @@
if (indivMenu->GetMenuItemCount())
{
editMenu->Enable(MNU_NEWOBJECT, true);
- treeContextMenu->Enable(MNU_NEWOBJECT, true);
for (i=0 ; i < indivMenu->GetMenuItemCount() ; i++)
{
@@ -860,19 +878,14 @@
else
{
}
- toolsMenu->Enable(MNU_RELOAD, canReload);
- treeContextMenu->Enable(MNU_RELOAD, canReload);
toolsMenu->Enable(MNU_CONNECT, canConnect);
- treeContextMenu->Enable(MNU_CONNECT, canConnect);
toolsMenu->Enable(MNU_DISCONNECT, canDisconnect);
-// toolsMenu->Enable(MNU_INDEXCHECK, canIndexCheck);
-// treeContextMenu->Enable(MNU_INDEXCHECK, canIndexCheck);
toolsMenu->Enable(MNU_GRANTWIZARD, canGrantWizard);
- treeContextMenu->Enable(MNU_GRANTWIZARD, canGrantWizard);
- treeContextMenu->Enable(MNU_DISCONNECT, canDisconnect);
+ toolsMenu->Enable(MNU_STARTSERVICE, canStart);
+ toolsMenu->Enable(MNU_STOPSERVICE, canStop);
fileMenu->Enable(MNU_PASSWORD, canDisconnect);
viewMenu->Enable(MNU_COUNT, canCount);
- treeContextMenu->Enable(MNU_COUNT, canCount);
+// toolsMenu->Enable(MNU_INDEXCHECK, canIndexCheck);
}
@@ -947,16 +960,94 @@
}
+void frmMain::doPopup(wxPoint point, pgObject *object)
+{
+ if (treeContextMenu)
+ delete treeContextMenu;
+
+ treeContextMenu = new wxMenu();
+ if (object)
+ treeContextMenu->Append(MNU_REFRESH, _("Re&fresh\tF5"), _("Refresh the selected object."));
+
+ if (viewMenu->IsEnabled(MNU_COUNT))
+ treeContextMenu->Append(MNU_COUNT, _("&Count"), _("Count rows in the selected object."));
+
+ if (object)
+ {
+ wxMenu *indivMenu=object->GetNewMenu();
+ if (indivMenu)
+ {
+ if (indivMenu->GetMenuItemCount())
+ treeContextMenu->Append(MNU_NEWOBJECT, _("New &Object"), indivMenu, _("Create a new object."));
+ else
+ delete indivMenu;
+ }
+ }
+
+ bool canView = toolsMenu->IsEnabled(MNU_VIEWDATA),
+ canViewFiltered = toolsMenu->IsEnabled(MNU_VIEWFILTEREDDATA),
+ canMaint = toolsMenu->IsEnabled(MNU_MAINTENANCE),
+ canIndex = toolsMenu->IsEnabled(MNU_INDEXCHECK),
+ canGrant = toolsMenu->IsEnabled(MNU_GRANTWIZARD),
+ canConnect = toolsMenu->IsEnabled(MNU_CONNECT),
+ canDisconnect = toolsMenu->IsEnabled(MNU_DISCONNECT),
+ canStart = toolsMenu->IsEnabled(MNU_STARTSERVICE),
+ canStop = toolsMenu->IsEnabled(MNU_STOPSERVICE);
+
+ if (canView || canViewFiltered || canMaint || canIndex || canGrant || canConnect || canDisconnect || canStart || canStop)
+ {
+ treeContextMenu->AppendSeparator();
+ if (canView)
+ treeContextMenu->Append(MNU_VIEWDATA, _("View &Data"), _("View the data in the selected object."));
+ if (canViewFiltered)
+ treeContextMenu->Append(MNU_VIEWFILTEREDDATA, _("View F&iltered Data"), _("Apply a filter and view the data in the selected object."));
+ if (canMaint)
+ treeContextMenu->Append(MNU_MAINTENANCE, _("&Maintenance"), _("Maintain the current database or table."));
+ if (canIndex)
+ treeContextMenu->Append(MNU_INDEXCHECK, _("&FK Index check"), _("Checks existence of foreign key indexes"));
+ if (canGrant)
+ treeContextMenu->Append(MNU_GRANTWIZARD, _("&Grant Wizard"), _("Grants rights to multiple objects"));
+ if (canStart)
+ treeContextMenu->Append(MNU_STARTSERVICE, _("Start service"), _("Start PostgreSQL Service"));
+ if (canStop)
+ treeContextMenu->Append(MNU_STOPSERVICE, _("Stop service"), _("Stop PostgreSQL Service"));
+ if (canConnect)
+ treeContextMenu->Append(MNU_CONNECT, _("&Connect..."), _("Connect to the selected server."));
+ if (canDisconnect)
+ treeContextMenu->Append(MNU_DISCONNECT, _("&Disconnect"), _("Disconnect from the selected server."));
+ }
+
+
+ bool canDrop = editMenu->IsEnabled(MNU_DROP),
+ canEdit = editMenu->IsEnabled(MNU_PROPERTIES);
+
+ if (canDrop || canEdit)
+ {
+ treeContextMenu->AppendSeparator();
+ if (canDrop)
+ treeContextMenu->Append(MNU_DROP, _("&Delete/Drop"), _("Delete/Drop the selected object."));
+ if (canEdit)
+ treeContextMenu->Append(MNU_PROPERTIES, _("&Properties"), _("Display/edit the properties of the selected object."));
+ }
+
+ PopupMenu(treeContextMenu, point);
+}
+
////////////////////////////////////////////////////////////////////////////////
// This handler will display a popup menu for the currently selected item
////////////////////////////////////////////////////////////////////////////////
void frmMain::OnContextMenu(wxCommandEvent& event)
{
+ wxPoint point;
+ wxObject *object=0;
+
if (FindFocus() == browser)
{
wxRect rect;
- browser->GetBoundingRect(browser->GetSelection(), rect);
- wxPoint point = rect.GetPosition();
+ wxTreeItemId item=browser->GetSelection();
+
+ browser->GetBoundingRect(item, rect);
+ point = rect.GetPosition();
wxPoint origin = GetClientAreaOrigin();
// Because this Tree is inside a vertical splitter, we
@@ -964,9 +1055,9 @@
point.x += origin.x;
point.y += origin.y;
- // popup the menu
- PopupMenu(treeContextMenu, point);
+ doPopup(point, (pgObject*)browser->GetItemData(item));
}
+
}
@@ -990,10 +1081,11 @@
point.y += origin.y;
// popup the menu
- PopupMenu(treeContextMenu, point);
+ doPopup(point, (pgObject*)browser->GetItemData(item));
}
+
void frmMain::OnDelete(wxCommandEvent &ev)
{
wxWindow *current=wxWindow::FindFocus();
Index: frmMain.cpp
===================================================================
RCS file: /projects/pgadmin3/src/ui/frmMain.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -Lsrc/ui/frmMain.cpp -Lsrc/ui/frmMain.cpp -u -w -r1.100 -r1.101
--- src/ui/frmMain.cpp
+++ src/ui/frmMain.cpp
@@ -175,6 +175,8 @@
// Tools Menu
toolsMenu = new wxMenu();
+ toolsMenu->Append(MNU_STARTSERVICE, _("Start service"), _("Start PostgreSQL Service"));
+ toolsMenu->Append(MNU_STOPSERVICE, _("Stop service"), _("Stop PostgreSQL Service"));
toolsMenu->Append(MNU_CONNECT, _("&Connect..."), _("Connect to the selected server."));
toolsMenu->Append(MNU_DISCONNECT, _("Disconnec&t"), _("Disconnect from the selected server."));
toolsMenu->AppendSeparator();
@@ -187,7 +189,6 @@
toolsMenu->Append(MNU_RESTORE, _("&Restore"), _("Restores a backup from a local file"));
toolsMenu->Append(MNU_INDEXCHECK, _("&FK Index check"), _("Checks existence of foreign key indexes"));
toolsMenu->Append(MNU_GRANTWIZARD, _("&Grant Wizard"), _("Grants rights to multiple objects"));
- toolsMenu->Append(MNU_RELOAD, _("Re&load module"), _("Reload library module which implements this function."));
toolsMenu->Append(MNU_STATUS, _("&Server Status"), _("Displays the current database status."));
menuBar->Append(toolsMenu, _("&Tools"));
@@ -214,32 +215,13 @@
#endif
menuBar->Append(helpMenu, _("&Help"));
- treeContextMenu = new wxMenu();
- // Tree Context Menu
newContextMenu = new wxMenu();
- treeContextMenu->Append(MNU_REFRESH, _("Re&fresh\tF5"), _("Refresh the selected object."));
- treeContextMenu->Append(MNU_COUNT, _("&Count"), _("Count rows in the selected object."));
- treeContextMenu->Append(MNU_RELOAD, _("Re&load module"), _("Reload library module which implements this function."));
- treeContextMenu->Append(MNU_NEWOBJECT, _("New &Object"), newContextMenu, _("Create a new object."));
- treeContextMenu->AppendSeparator();
- treeContextMenu->Append(MNU_VIEWDATA, _("View &Data"), _("View the data in the selected object."));
- treeContextMenu->Append(MNU_VIEWFILTEREDDATA, _("View F&iltered Data"), _("Apply a filter and view the data in the selected object."));
- treeContextMenu->Append(MNU_MAINTENANCE, _("&Maintenance"), _("Maintain the current database or table."));
- treeContextMenu->Append(MNU_INDEXCHECK, _("&FK Index check"), _("Checks existence of foreign key indexes"));
- treeContextMenu->Append(MNU_GRANTWIZARD, _("&Grant Wizard"), _("Grants rights to multiple objects"));
- treeContextMenu->Append(MNU_CONNECT, _("&Connect..."), _("Connect to the selected server."));
- treeContextMenu->Append(MNU_DISCONNECT, _("&Disconnect"), _("Disconnect from the selected server."));
- treeContextMenu->AppendSeparator();
- treeContextMenu->Append(MNU_CREATE, _("&Create"), _("Create a new object of the same type as the selected object."));
- treeContextMenu->Append(MNU_DROP, _("&Delete/Drop"), _("Delete/Drop the selected object."));
- treeContextMenu->Append(MNU_PROPERTIES, _("&Properties"), _("Display/edit the properties of the selected object."));
-
+ treeContextMenu = 0;
// Add the Menubar and set some options
SetMenuBar(menuBar);
editMenu->Enable(MNU_NEWOBJECT, false);
- treeContextMenu->Enable(MNU_NEWOBJECT, false);
fileMenu->Enable(MNU_PASSWORD, false);
viewMenu->Check(MNU_SYSTEMOBJECTS, settings->GetShowSystemObjects());
@@ -402,6 +384,7 @@
// Clear the treeview
browser->DeleteAllItems();
+ if (treeContextMenu)
delete treeContextMenu;
delete images;
}
@@ -793,6 +776,10 @@
key.Printf(wxT("Servers/Description%d"), numServers);
settings->Write(key, server->GetDescription());
+ // Service ID
+ key.Printf(wxT("Servers/ServiceID%d"), numServers);
+ settings->Write(key, server->GetServiceID());
+
// Port
key.Printf(wxT("Servers/Port%d"), numServers);
settings->Write(key, server->GetPort());
@@ -879,9 +866,11 @@
long numServers=settings->Read(wxT("Servers/Count"), 0L);
int loop, port, ssl=0;
- wxString key, servername, description, database, username, lastDatabase, lastSchema, trusted;
+ wxString key, servername, description, database, username, lastDatabase, lastSchema, trusted, serviceID;
pgServer *server;
+ wxArrayString servicedServers;
+
// Get the hostname for later...
char buf[255];
gethostname(buf, 255);
@@ -893,6 +882,10 @@
key.Printf(wxT("Servers/Server%d"), loop);
settings->Read(key, &servername, wxT(""));
+ // service location
+ key.Printf(wxT("Servers/ServiceID%d"), loop);
+ settings->Read(key, &serviceID, wxT(""));
+
// Comment
key.Printf(wxT("Servers/Description%d"), loop);
settings->Read(key, &description, wxT(""));
@@ -931,8 +924,22 @@
server = new pgServer(servername, description, database, username, port, StrToBool(trusted), ssl);
server->iSetLastDatabase(lastDatabase);
server->iSetLastSchema(lastSchema);
+ server->iSetServiceID(serviceID);
server->iSetDiscovered(false);
browser->AppendItem(servers, server->GetFullName(), PGICON_SERVERBAD, -1, server);
+
+
+#ifdef WIN32
+ int bspos = serviceID.Find('\\');
+ if (bspos >= 0)
+ {
+ if (serviceID.Left(2) != wxT(".\\") && !serviceID.Matches(wxGetHostName() + wxT("\\*")))
+ serviceID = wxEmptyString;
+ }
+ if (!serviceID.IsEmpty())
+ servicedServers.Add(serviceID);
+#endif
+
}
#ifdef WIN32
@@ -952,6 +959,8 @@
while (flag != false)
{
+ if (servicedServers.Index(svcName, false) < 0)
+ {
key.Printf(wxT("HKEY_LOCAL_MACHINE\\Software\\PostgreSQL\\Services\\%s"), svcName);
wxRegKey *svcKey = new wxRegKey(key);
@@ -1002,7 +1011,7 @@
server->iSetDiscovered(true);
server->iSetServiceID(svcName);
browser->AppendItem(servers, server->GetFullName(), PGICON_SERVERBAD, -1, server);
-
+ }
// Get the next one...
flag = pgKey->GetNextKey(svcName, cookie);
}
@@ -1089,23 +1098,10 @@
toolsMenu->Enable(MNU_STATUS, status);
toolsMenu->Enable(MNU_VIEWDATA, viewData);
toolsMenu->Enable(MNU_VIEWFILTEREDDATA, viewData);
+ toolsMenu->Enable(MNU_STARTSERVICE, false);
+ toolsMenu->Enable(MNU_STOPSERVICE, false);
viewMenu->Enable(MNU_REFRESH, refresh);
viewMenu->Enable(MNU_COUNT, false);
- toolsMenu->Enable(MNU_RELOAD, false);
-
- treeContextMenu->Enable(MNU_CREATE, create);
- treeContextMenu->Enable(MNU_DROP, drop);
- treeContextMenu->Enable(MNU_CONNECT, false);
- treeContextMenu->Enable(MNU_DISCONNECT, false);
- treeContextMenu->Enable(MNU_REFRESH, refresh);
- treeContextMenu->Enable(MNU_PROPERTIES, properties);
- treeContextMenu->Enable(MNU_MAINTENANCE, maintenance);
- treeContextMenu->Enable(MNU_INDEXCHECK, false);
- treeContextMenu->Enable(MNU_GRANTWIZARD, false);
- treeContextMenu->Enable(MNU_VIEWDATA, viewData);
- treeContextMenu->Enable(MNU_VIEWFILTEREDDATA, viewData);
- treeContextMenu->Enable(MNU_RELOAD, false);
- treeContextMenu->Enable(MNU_COUNT, false);
}