Thread: SVN Commit by dpage: r4884 - in trunk/pgadmin3: . docs/en_US src src/frm src/include

SVN Commit by dpage: r4884 - in trunk/pgadmin3: . docs/en_US src src/frm src/include

From
svn@pgadmin.org
Date:
Author: dpage
Date: 2006-01-09 10:38:49 +0000 (Mon, 09 Jan 2006)
New Revision: 4884

Added:
   trunk/pgadmin3/docs/en_US/commandline.html
Modified:
   trunk/pgadmin3/CHANGELOG.txt
   trunk/pgadmin3/docs/en_US/pgadmin3.hhc
   trunk/pgadmin3/docs/en_US/pgadmin3.hhp.cached
   trunk/pgadmin3/docs/en_US/using.html
   trunk/pgadmin3/src/frm/frmMain.cpp
   trunk/pgadmin3/src/include/frmMain.h
   trunk/pgadmin3/src/pgAdmin3.cpp
Log:
Add -a and -q command line options to auto connect to a server and open a query window respectively [Magnus Hagander]

Modified: trunk/pgadmin3/CHANGELOG.txt
===================================================================
--- trunk/pgadmin3/CHANGELOG.txt    2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/CHANGELOG.txt    2006-01-09 10:38:49 UTC (rev 4884)
@@ -18,6 +18,7 @@
 </ul>
 <br>
 <ul>
+    <li>2006-01-09 DP         Add -a and -q command line options to auto connect to a server and open a query window
respectively[Magnus Hagander] 
     <li>2006-01-09 DP  1.4.2  Honour the copy quoting setting properly in the SQL results pane [Magnus Hagander]
     <li>2006-01-09 DP         Use Ctrl-A to select all results in the query results pane. [Magnus Hagander]
     <li>2006-01-09 DP  1.4.2  Set the initial Unicode/Local charset options correctly in the Export dialogue [Magnus
Hagander]

Added: trunk/pgadmin3/docs/en_US/commandline.html
===================================================================
--- trunk/pgadmin3/docs/en_US/commandline.html    2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/docs/en_US/commandline.html    2006-01-09 10:38:49 UTC (rev 4884)
@@ -0,0 +1,40 @@
+<html>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
+<link rel="STYLESHEET" type="text/css" href="pgadmin3.css">
+<title>Command Line Parameters</title>
+</head>
+
+<body>
+
+<h3>Command Line Parameters</h3>
+<p>
+There are a number of command line options that may be passed to the pgAdmin executable
+when starting it.
+</p>
+
+<ul>
+  <li><b>-h</b> Display command line option help.<br /> </li>
+
+  <li><b>-s <server description></b> Auto connect to the specified server. <server description> is the
description 
+      entered when you added the server to the treeview in pgAdmin, quoted if required. If multiple servers are
registeredwith  
+      the same description, the first found will be auto-connected.<br /> </li>
+
+  <li><b>-q</b> Open a <a href="query.html">Query Tool</a> window upon connection. This option requires the
+      <b>-s <server description></b> option.<br /> </li>
+
+  <li><b>-cm <config file></b> Edit the specified postgresql.conf config file.<br /> </li>
+
+  <li><b>-ch <hba file></b> Edit the specified pg_hba.conf config file.<br /> </li>
+
+  <li><b>-c <file></b> Edit the specified config file. pgAdmin will attempt to auto-detect what type of config
fileis  
+      being editted.<br /> </li>
+
+  <li><b>-t</b> Start in dialogue translation test mode. This mode allows each dialogue to be viewed without running
the 
+       application to assist with string translation.<br /> </li>
+</ul>
+
+</body>
+
+</html>

Modified: trunk/pgadmin3/docs/en_US/pgadmin3.hhc
===================================================================
--- trunk/pgadmin3/docs/en_US/pgadmin3.hhc    2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/docs/en_US/pgadmin3.hhc    2006-01-09 10:38:49 UTC (rev 4884)
@@ -106,6 +106,10 @@
                 <param name="Name" value="Guru Hints">
                 <param name="Local" value="guruhints.html">
                 </OBJECT>
+            <LI> <OBJECT type="text/sitemap">
+                <param name="Name" value="Command Line Options">
+                <param name="Local" value="commandline.html">
+                </OBJECT>
         </UL>
         <LI> <OBJECT type="text/sitemap">
             <param name="Name" value="pgAgent">

Modified: trunk/pgadmin3/docs/en_US/pgadmin3.hhp.cached
===================================================================
(Binary files differ)

Modified: trunk/pgadmin3/docs/en_US/using.html
===================================================================
--- trunk/pgadmin3/docs/en_US/using.html    2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/docs/en_US/using.html    2006-01-09 10:38:49 UTC (rev 4884)
@@ -10,7 +10,7 @@

 <H3>Using pgAdmin</H3>
 <P>This section explains how you can use pgAdmin to maintain your
-PostgreSQL databases. PgAdmin supports database server versions
+PostgreSQL databases. pgAdmin supports database server versions
 7.3 and up. Versions older than 7.3 are not supported, please use
 pgAdmin II for these.</P>
 <UL>
@@ -44,6 +44,7 @@
     <LI><P>The <A HREF="options.html">Options</A> dialogue will allow
     you to configure pgAdmin.</P>
     <LI><P><A HREF="guruhints.html">Guru Hints</A> help you perfect your databases.</P>
+        <LI><P><A HREF="commandline.html">Command Line Options</A> to start pgAdmin in the most convenient mode.</P>
 </UL>
 <P>When editing the properties of a database object, pgAdmin will
 support you with help about the underlying PostgreSQL SQL commands,

Modified: trunk/pgadmin3/src/frm/frmMain.cpp
===================================================================
--- trunk/pgadmin3/src/frm/frmMain.cpp    2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/src/frm/frmMain.cpp    2006-01-09 10:38:49 UTC (rev 4884)
@@ -630,7 +630,7 @@
 }


-int frmMain::ReconnectServer(pgServer *server)
+int frmMain::ReconnectServer(pgServer *server, bool restore)
 {
     // Create a server object and connect it.
     wxBusyInfo waiting(wxString::Format(_("Connecting to server %s (%s:%d)"),
@@ -644,26 +644,29 @@
     {
         case PGCONN_OK:
         {
-            StartMsg(_("Restoring previous environment"));
-            wxLogInfo(wxT("pgServer object initialised as required."));
+            if (restore)
+            {
+                StartMsg(_("Restoring previous environment"));
+                wxLogInfo(wxT("pgServer object initialised as required."));

-            server->ShowTreeDetail(browser);
-            browser->Freeze();
-            item=RestoreEnvironment(server);
-            browser->Thaw();
+                server->ShowTreeDetail(browser);
+                browser->Freeze();
+                item=RestoreEnvironment(server);
+                browser->Thaw();

-            if (item)
-            {
-                browser->SelectItem(item);
+                if (item)
+                {
+                    browser->SelectItem(item);

-                wxSafeYield();
-                browser->Expand(item);
-                browser->EnsureVisible(item);
-            }
-            if (item)
-                EndMsg(true);
-            else
-                EndMsg(false);
+                    wxSafeYield();
+                    browser->Expand(item);
+                    browser->EnsureVisible(item);
+                }
+                if (item)
+                    EndMsg(true);
+                else
+                    EndMsg(false);
+            }
             return res;
         }
         case PGCONN_DNSERR:
@@ -797,6 +800,24 @@
     browser->SetItemText(serversObj->GetId(), label);
 }

+pgServer *frmMain::ConnectToServer(const wxString& servername, bool restore)
+{
+    for (int i = 0; ; i++)
+    {
+        pgObject *o = serversObj->FindChild(browser, i);
+        if (!o)
+            return NULL;
+        if (o->IsCreatedBy(serverFactory))
+        {
+            pgServer *s = (pgServer *)o;
+            if (s->GetDescription() == servername)
+            {
+                ReconnectServer(s, restore);
+                return s;
+            }
+        }
+    }
+}

 void frmMain::StartMsg(const wxString& msg)
 {

Modified: trunk/pgadmin3/src/include/frmMain.h
===================================================================
--- trunk/pgadmin3/src/include/frmMain.h    2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/src/include/frmMain.h    2006-01-09 10:38:49 UTC (rev 4884)
@@ -59,9 +59,10 @@
     ctlListView *GetDependsOn();
     ctlListView *GetReferencedBy();
     void StoreServers();
-    int ReconnectServer(pgServer *server);
+    int ReconnectServer(pgServer *server, bool restore = true);
     void ReportConnError(pgServer *server);
     pgServerCollection *GetServerCollection() { return serversObj; }
+    pgServer *ConnectToServer(const wxString& servername, bool restore = false);

 private:
     ctlTree *browser;

Modified: trunk/pgadmin3/src/pgAdmin3.cpp
===================================================================
--- trunk/pgadmin3/src/pgAdmin3.cpp    2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/src/pgAdmin3.cpp    2006-01-09 10:38:49 UTC (rev 4884)
@@ -15,6 +15,7 @@
 // wxWindows headers
 #include <wx/wx.h>
 #include <wx/app.h>
+#include <wx/cmdline.h>
 #include <wx/dir.h>
 #include <wx/file.h>
 #include <wx/xrc/xmlres.h>
@@ -170,35 +171,46 @@
 // The Application!
 bool pgAdmin3::OnInit()
 {
+    static const wxCmdLineEntryDesc cmdLineDesc[] =
+    {
+        {wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("show this help message"), wxCMD_LINE_VAL_NONE,
wxCMD_LINE_OPTION_HELP}, 
+        {wxCMD_LINE_OPTION, wxT("s"), wxT("server"), wxT("auto-connect to specified server"), wxCMD_LINE_VAL_STRING},
+        {wxCMD_LINE_SWITCH, wxT("q"), wxT("query"), wxT("open query tool to auto-connected server"),
wxCMD_LINE_VAL_NONE},
+        {wxCMD_LINE_OPTION, wxT("cm"), NULL, wxT("edit main configuration file"), wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_MULTIPLE},
+        {wxCMD_LINE_OPTION, wxT("ch"), NULL, wxT("edit HBA configuration file"), wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_MULTIPLE},
+        {wxCMD_LINE_OPTION, wxT("c"), NULL, wxT("edit any configuration file"), wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_MULTIPLE},
+        {wxCMD_LINE_SWITCH, wxT("t"), NULL, wxT("dialog translation test mode"), wxCMD_LINE_VAL_NONE},
+        {wxCMD_LINE_NONE}
+    };
+
+
     // we are here
     InitPaths();

     frmConfig::tryMode configMode=frmConfig::NONE;
+    wxString configFile;

-    if (argc > 1 && *argv[1] == '-')
-    {
-        switch (argv[1][1])
-        {
-            case 'c':
-            {
-                // file configurator mode
-                if (argv[1][2]== 'm')
-                    configMode = frmConfig::MAINFILE;
-                else if (argv[1][2]== 'h')
-                    configMode = frmConfig::HBAFILE;
-                else
-                    configMode=frmConfig::ANYFILE;
+    wxCmdLineParser cmdParser(cmdLineDesc, argc, argv);
+    if (cmdParser.Parse() != 0)
+        return false;

-                break;
-            }
-            case 't':
-            {
-                dialogTestMode = true;
-                break;
-            }
-        }
-    }
+    if (cmdParser.Found(wxT("q")) && !cmdParser.Found(wxT("s")))
+    {
+        cmdParser.Usage();
+        return false;
+    }
+
+    if (cmdParser.Found(wxT("cm"), &configFile))
+        configMode = frmConfig::MAINFILE;
+    else if (cmdParser.Found(wxT("ch"), &configFile))
+        configMode = frmConfig::HBAFILE;
+    else if (cmdParser.Found(wxT("c"), &configFile))
+        configMode = frmConfig::ANYFILE;

+    if (cmdParser.Found(wxT("t")))
+        dialogTestMode = true;
+
+
     // evaluate all working paths

 #if defined(__WXMSW__)
@@ -351,29 +363,15 @@

     if (configMode)
     {
-        int i;
-
-        for (i=2 ; i < argc ; i++)
-        {
-            wxString str;
-            if (*argv[i] == '"')
-            {
-                wxString str=argv[i]+1;
-                str=str.Mid(0, str.Length()-1);
-            }
-            else
-                str = argv[i];
-
-            if (configMode == frmConfig::ANYFILE && wxDir::Exists(str))
-            {
-                frmConfig::Create(APPNAME_L, str + wxT("/pg_hba.conf"), frmConfig::HBAFILE);
-                frmConfig::Create(APPNAME_L, str + wxT("/postgresql.conf"), frmConfig::MAINFILE);
-            }
-            else
-            {
-                frmConfig::Create(APPNAME_L, str, configMode);
-            }
-        }
+        if (configMode == frmConfig::ANYFILE && wxDir::Exists(configFile))
+        {
+            frmConfig::Create(APPNAME_L, configFile + wxT("/pg_hba.conf"), frmConfig::HBAFILE);
+            frmConfig::Create(APPNAME_L, configFile + wxT("/postgresql.conf"), frmConfig::MAINFILE);
+        }
+        else
+        {
+            frmConfig::Create(APPNAME_L, configFile, configMode);
+        }
         if (winSplash)
         {
             winSplash->Close();
@@ -413,6 +411,17 @@
             delete winSplash;
         }

+        wxString str;
+        if (cmdParser.Found(wxT("s"), &str))
+        {
+            pgServer *srv = winMain->ConnectToServer(str, !cmdParser.Found(wxT("q")));
+            if (srv && cmdParser.Found(wxT("q")))
+            {
+                frmQuery *fq = new frmQuery(winMain, wxEmptyString, srv->CreateConn(), wxString(wxT("")));
+                fq->Go();
+            }
+        }
+
         // Display a Tip if required.
         extern sysSettings *settings;
         wxCommandEvent evt = wxCommandEvent();


Re: SVN Commit by dpage: r4884 - in trunk/pgadmin3:

From
Miha Radej
Date:
hi!

after checking out revision 4884 make fails with the following error:

[mcajvar@alrisha:/net/programs/pgadmin-svn/pgadmin3]$ make
make  all-recursive
make[1]: Entering directory `/usr/net/programs/pgadmin-svn/pgadmin3'
Making all in i18n
make[2]: Entering directory `/usr/net/programs/pgadmin-svn/pgadmin3/i18n'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/net/programs/pgadmin-svn/pgadmin3/i18n'
Making all in src
make[2]: Entering directory `/usr/net/programs/pgadmin-svn/pgadmin3/src'
if g++ -DHAVE_CONFIG_H -I. -I. -I..
-DDATA_DIR=\"/usr/local/pgadmin-svn/share/pgadmin3/\" -Wall
-Wno-non-virtual-dtor -I../src/include -I../src/agent/include
-I../src/slony/include -I/usr/include/pgsql -DSSL
-I/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.6
-I/usr/local/include/wx-2.6 -D__WXDEBUG__ -D__WXGTK__
-D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1 -g -O0
-DDATA_DIR=\"/usr/local/pgadmin-svn/share/pgadmin3/\" -Wall
-Wno-non-virtual-dtor -I../src/include -I../src/agent/include
-I../src/slony/include  -MT pgAdmin3.o -MD -MP -MF ".deps/pgAdmin3.Tpo"
-c -o pgAdmin3.o `test -f './pgAdmin3.cpp' || echo './'`./pgAdmin3.cpp; \
then mv -f ".deps/pgAdmin3.Tpo" ".deps/pgAdmin3.Po"; else rm -f
".deps/pgAdmin3.Tpo"; exit 1; fi
pgAdmin3.cpp: In member function `virtual bool pgAdmin3::OnInit()':
pgAdmin3.cpp:420: error: `frmQuery' undeclared (first use this function)
pgAdmin3.cpp:420: error: (Each undeclared identifier is reported only
once for
    each function it appears in.)
pgAdmin3.cpp:420: error: `fq' undeclared (first use this function)
pgAdmin3.cpp:420: error: syntax error before `(' token
make[2]: *** [pgAdmin3.o] Error 1
make[2]: Leaving directory `/usr/net/programs/pgadmin-svn/pgadmin3/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/net/programs/pgadmin-svn/pgadmin3'
make: *** [all] Error 2


revision 4883 makes just fine.

system is suse 9.3, gcc 3.3.4, wx 2.6.0.

regards,
Miha

svn@pgadmin.org wrote:
> Author: dpage
> Date: 2006-01-09 10:38:49 +0000 (Mon, 09 Jan 2006)
> New Revision: 4884
> ...