Allow server nodes to be added with no color, instead of using white, to prevent...
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Tue, 24 Feb 2009 17:49:22 +0000 (17:49 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Tue, 24 Feb 2009 17:49:22 +0000 (17:49 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7610 a7884b65-44f6-0310-8a51-81a127f17b15

pgadmin/dlg/dlgServer.cpp
pgadmin/frm/frmMain.cpp
pgadmin/include/schema/pgServer.h
pgadmin/schema/pgServer.cpp

index f7354584157f03b81c39bf473fb48ce55c1f10a0..14f9f117839bb774dea1c9106b15583a4b40c3f5 100644 (file)
@@ -147,7 +147,10 @@ void dlgServer::OnOK(wxCommandEvent &ev)
         server->iSetStorePwd(chkStorePwd->GetValue());
         server->iSetRestore(chkRestore->GetValue());
         server->iSetDbRestriction(txtDbRestriction->GetValue().Trim());
-               server->iSetColour(txtColour->GetValue());
+        if (txtColour->GetValue().Trim() == wxEmptyString)
+            server->iSetColour(wxEmptyString);
+        else
+                   server->iSetColour(wxColour(txtColour->GetValue().Trim()).GetAsString(wxC2S_HTML_SYNTAX));
         mainForm->execSelChange(server->GetId(), true);
         mainForm->GetBrowser()->SetItemText(item, server->GetFullName());
 
@@ -237,7 +240,7 @@ int dlgServer::Go(bool modal)
         chkStorePwd->SetValue(server->GetStorePwd());
         chkRestore->SetValue(server->GetRestore());
         txtDbRestriction->SetValue(server->GetDbRestriction());
-        txtColour->SetValue(server->GetColour().GetAsString(wxC2S_HTML_SYNTAX));
+        txtColour->SetValue(server->GetColour());
 
         stPassword->Disable();
         txtPassword->Disable();
@@ -320,7 +323,7 @@ void dlgServer::CheckChange()
                || chkStorePwd->GetValue() != server->GetStorePwd()
                || chkRestore->GetValue() != server->GetRestore()
                || txtDbRestriction->GetValue() != server->GetDbRestriction()
-                          || txtColour->GetValue() != server->GetColour().GetAsString(wxC2S_HTML_SYNTAX);
+                          || txtColour->GetValue() != wxColour(server->GetColour()).GetAsString(wxC2S_HTML_SYNTAX);
     }
 
 
index ca91240ff42eaf686057ae38f231d5732211dd30..297f6c40c7bf5636546c257face9501fea412703 100644 (file)
@@ -1041,7 +1041,7 @@ void frmMain::StoreServers()
             settings->Write(key + wxT("LastDatabase"), server->GetLastDatabase());
             settings->Write(key + wxT("LastSchema"), server->GetLastSchema());
             settings->Write(key + wxT("DbRestriction"), server->GetDbRestriction());
-                       settings->Write(key + wxT("Colour"), server->GetColour().GetAsString(wxC2S_HTML_SYNTAX));
+            settings->Write(key + wxT("Colour"), server->GetColour());
             settings->Write(key + wxT("SSL"), server->GetSSL());
 
             pgCollection *coll=browser->FindCollection(databaseFactory, server->GetId());
index 11d79c4cd86b17c3e89e674e66744062cf16468c..5ab11419e171e42f1c8ff662deef6a1f89b952a0 100644 (file)
@@ -38,7 +38,7 @@ extern pgServerFactory serverFactory;
 class pgServer : public pgObject
 {
 public:
-       pgServer(const wxString& newServer = wxT(""), const wxString& newDescription = wxT(""), const wxString& newDatabase = wxT(""), const wxString& newUsername = wxT(""), int newPort = 5432, bool storePwd=false, bool restore=true, int sslMode=0, const wxString &colour = wxT("#ffffff"));
+       pgServer(const wxString& newServer = wxT(""), const wxString& newDescription = wxT(""), const wxString& newDatabase = wxT(""), const wxString& newUsername = wxT(""), int newPort = 5432, bool storePwd=false, bool restore=true, int sslMode=0, const wxString &colour = wxEmptyString);
     ~pgServer();
     int GetIconId();
 
@@ -110,8 +110,8 @@ public:
     bool SetPassword(const wxString& newVal);
     wxDateTime GetUpSince() { return upSince; }
     void iSetUpSince(const wxDateTime &d) { upSince = d; }
-       void iSetColour(const wxString &s) { colour = s.Length() == 0 ? wxColour(wxT("#ffffff")) : wxColour(s); }
-       wxColour GetColour() { return colour; }
+       void iSetColour(const wxString &s) { colour = s; }
+       wxString GetColour() { return colour; }
 
     bool HasPrivilege(const wxString &objTyp, const wxString &objName, const wxString &priv) { return conn->HasPrivilege(objTyp, objName, priv); }
     bool ExecuteVoid(const wxString& sql) { return conn->ExecuteVoid(sql); }
@@ -152,7 +152,7 @@ private:
     OID dbOid;
     wxString versionNum;
     wxString dbRestriction;
-       wxColour colour;
+       wxString colour;
 
 #ifdef WIN32
     SC_HANDLE scmHandle;
index d864a6a718e15f37ee4a4bd9823d7d392f22f2d8..c9c2934cbd31ac1f668e4d1206685766b7b8352e 100644 (file)
@@ -46,7 +46,7 @@ pgServer::pgServer(const wxString& newName, const wxString& newDescription, cons
     username = newUsername;
     port = newPort;
     ssl=_ssl;
-    colour = _colour.IsEmpty() ? wxT("#FFFFFF") : wxColour(_colour);
+    colour = _colour;
     serverIndex=0;
 
     connected = false;
@@ -1080,7 +1080,11 @@ pgObject *pgServerFactory::CreateObjects(pgCollection *obj, ctlTree *browser, co
         settings->Read(key + wxT("LastDatabase"), &lastDatabase, wxEmptyString);
         settings->Read(key + wxT("LastSchema"), &lastSchema, wxEmptyString);
         settings->Read(key + wxT("DbRestriction"), &dbRestriction, wxEmptyString);
-        settings->Read(key + wxT("Colour"), &colour, wxT("#FFFFFF"));
+        settings->Read(key + wxT("Colour"), &colour, wxEmptyString);
+
+        // Sanitize the colour
+        if (!colour.IsEmpty())
+            colour = wxColour(colour.Trim()).GetAsString(wxC2S_HTML_SYNTAX);
 
         // SSL mode
 #ifdef SSL
@@ -1099,7 +1103,8 @@ pgObject *pgServerFactory::CreateObjects(pgCollection *obj, ctlTree *browser, co
         server->iSetServerIndex(loop);
         wxTreeItemId itm = browser->AppendItem(obj->GetId(), server->GetFullName(), server->GetIconId(), -1, server);
         browser->SortChildren(obj->GetId());
-        browser->SetItemBackgroundColour(itm, server->GetColour());
+        if (!server->GetColour().IsEmpty())
+            browser->SetItemBackgroundColour(itm, wxColour(server->GetColour()));
 
         // Note if we're reloading a discovered server
         if (!discoveryID.IsEmpty())