SVN Commit by andreas: r4451 - in trunk/pgadmin3/src: dlg include ui
От | svn@pgadmin.org |
---|---|
Тема | SVN Commit by andreas: r4451 - in trunk/pgadmin3/src: dlg include ui |
Дата | |
Msg-id | 200509181734.j8IHYGSY031216@developer.pgadmin.org обсуждение исходный текст |
Список | pgadmin-hackers |
Author: andreas Date: 2005-09-18 18:34:15 +0100 (Sun, 18 Sep 2005) New Revision: 4451 Added: trunk/pgadmin3/src/dlg/dlgSelectConnection.cpp trunk/pgadmin3/src/include/dlgSelectConnection.h trunk/pgadmin3/src/ui/dlgSelectConnection.xrc Log: Allow Query Tool to use multiple connections Added: trunk/pgadmin3/src/dlg/dlgSelectConnection.cpp =================================================================== --- trunk/pgadmin3/src/dlg/dlgSelectConnection.cpp 2005-09-18 16:47:02 UTC (rev 4450) +++ trunk/pgadmin3/src/dlg/dlgSelectConnection.cpp 2005-09-18 17:34:15 UTC (rev 4451) @@ -0,0 +1,140 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin III - PostgreSQL Tools +// RCS-ID: $Id: $ +// Copyright (C) 2002 - 2005, The pgAdmin Development Team +// This software is released under the Artistic Licence +// +// dlgSelectConnection.cpp - Connect to a database +// +////////////////////////////////////////////////////////////////////////// + + + +// App headers +#include "pgAdmin3.h" + +#include "dlgSelectConnection.h" +#include "pgConn.h" +#include "pgServer.h" +#include "sysLogger.h" + + + +BEGIN_EVENT_TABLE(dlgSelectConnection, DialogWithHelp) + EVT_COMBOBOX(XRCID("cbServer"), dlgSelectConnection::OnChangeServer) + EVT_COMBOBOX(XRCID("cbDatabase"), dlgSelectConnection::OnChangeDatabase) + EVT_BUTTON (wxID_OK, dlgSelectConnection::OnOK) + EVT_BUTTON (wxID_CANCEL, dlgSelectConnection::OnCancel) +END_EVENT_TABLE() + + +#define cbServer CTRL_COMBOBOX("cbServer") +#define cbDatabase CTRL_COMBOBOX("cbDatabase") + + + +dlgSelectConnection::dlgSelectConnection(frmMain *form) : +DialogWithHelp(form) +{ + wxLogInfo(wxT("Creating a select connection dialogue")); + + wxWindowBase::SetFont(settings->GetSystemFont()); + LoadResource((wxWindow*)form, wxT("dlgSelectConnection")); + + appearanceFactory->SetIcons(this); + CenterOnParent(); +} + + +dlgSelectConnection::~dlgSelectConnection() +{ + wxLogInfo(wxT("Destroying a select connection dialogue")); +} + + +wxString dlgSelectConnection::GetHelpPage() const +{ + return wxT("pg/server-connect"); +} + + +void dlgSelectConnection::OnChangeServer(wxCommandEvent& ev) +{ + cbDatabase->Clear(); + + int sel=cbServer->GetSelection(); + if (sel >= 0) + { + remoteServer = (pgServer*)cbServer->GetClientData(sel); + + if (!remoteServer->GetConnected()) + { + remoteServer->Connect(mainForm, remoteServer->GetStorePwd()); + if (!remoteServer->GetConnected()) + { + wxLogError(remoteServer->GetLastError()); + return; + } + } + if (remoteServer->GetConnected()) + { + pgSet *set=remoteServer->ExecuteSet( + wxT("SELECT DISTINCT datname\n") + wxT(" FROM pg_database db\n") + wxT(" WHERE datallowconn ORDER BY datname")); + if (set) + { + while (!set->Eof()) + { + cbDatabase->Append(set->GetVal(wxT("datname"))); + set->MoveNext(); + } + delete set; + + cbDatabase->SetSelection(0); + } + } + + } + OnChangeDatabase(ev); +} + + +wxString dlgSelectConnection::GetDatabase() +{ + return cbDatabase->GetValue(); +} + + +void dlgSelectConnection::OnChangeDatabase(wxCommandEvent& ev) +{ + btnOK->Enable(cbDatabase->GetCount() > 0 && cbDatabase->GetSelection() >= 0); +} + + +void dlgSelectConnection::OnOK(wxCommandEvent& ev) +{ + EndModal(wxID_OK); +} + + +void dlgSelectConnection::OnCancel(wxCommandEvent& ev) +{ + EndModal(wxID_CANCEL); +} + + +int dlgSelectConnection::Go() +{ + treeObjectIterator servers(mainForm->GetBrowser(), mainForm->GetServerCollection()); + pgServer *s; + + while ((s=(pgServer*)servers.GetNextObject()) != 0) + cbServer->Append(s->GetIdentifier(), (void*)s); + + cbServer->SetFocus(); + btnOK->Disable(); + return ShowModal(); +} + Added: trunk/pgadmin3/src/include/dlgSelectConnection.h =================================================================== --- trunk/pgadmin3/src/include/dlgSelectConnection.h 2005-09-18 16:47:02 UTC (rev 4450) +++ trunk/pgadmin3/src/include/dlgSelectConnection.h 2005-09-18 17:34:15 UTC (rev 4451) @@ -0,0 +1,40 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin III - PostgreSQL Tools +// RCS-ID: $Id: $ +// Copyright (C) 2002 - 2005, The pgAdmin Development Team +// This software is released under the Artistic Licence +// +// dlgSelectConnection.h - Connect to a database +// +////////////////////////////////////////////////////////////////////////// + +#ifndef DLGSELECTCONNECTION_H +#define DLGSELECTCONNECTION_H + +#include "dlgClasses.h" + +// Class declarations +class dlgSelectConnection : public DialogWithHelp +{ +public: + dlgSelectConnection(frmMain *form); + ~dlgSelectConnection(); + wxString GetHelpPage() const; + pgServer *GetServer() { return remoteServer; } + wxString GetDatabase(); + + int Go(); + +private: + void OnChangeServer(wxCommandEvent& ev); + void OnChangeDatabase(wxCommandEvent& ev); + void OnOK(wxCommandEvent& ev); + void OnCancel(wxCommandEvent& ev); + + pgServer *remoteServer; + + DECLARE_EVENT_TABLE() +}; + +#endif Added: trunk/pgadmin3/src/ui/dlgSelectConnection.xrc =================================================================== --- trunk/pgadmin3/src/ui/dlgSelectConnection.xrc 2005-09-18 16:47:02 UTC (rev 4450) +++ trunk/pgadmin3/src/ui/dlgSelectConnection.xrc 2005-09-18 17:34:15 UTC (rev 4451) @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<resource> + <object class="wxDialog" name="dlgSelectConnection"> + <title>Connect to Server</title> + <size>205,83d</size> + <style>wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxCAPTION|wxSYSTEM_MENU</style> + <object class="wxStaticText" name="stServer"> + + <label>Server</label> + + <pos>5,7d</pos> + </object> + <object class="wxComboBox" name="cbServer"> + + <content/> + + <pos>65,5d</pos> + + <size>135,12d</size> + + <style>wxCB_READONLY|wxCB_DROPDOWN</style> + </object> + <object class="wxStaticText" name="stDatabase"> + + <label>Database</label> + + <pos>5,22d</pos> + </object> + <object class="wxComboBox" name="cbDatabase"> + + <content/> + + <pos>65,20d</pos> + + <size>135,12d</size> + + <style>wxCB_READONLY|wxCB_DROPDOWN</style> + </object> + <object class="wxButton" name="wxID_HELP"> + + + + <label>&Help</label> + + + + <pos>2,65d</pos> + + + + <style></style> + </object> + <object class="wxButton" name="wxID_OK"> + + + + <label>&OK</label> + + + + <default>1</default> + + + + <pos>97,65d</pos> + + + + <style></style> + </object> + <object class="wxButton" name="wxID_CANCEL"> + + + + <label>&Cancel</label> + + + + <default>0</default> + + + + <pos>150,65d</pos> + </object> + </object> +</resource> \ No newline at end of file
В списке pgadmin-hackers по дате отправления:
Следующее
От: svn@pgadmin.orgДата:
Сообщение: SVN Commit by andreas: r4452 - in trunk/pgadmin3/src: dlg include