~ubuntu-branches/debian/sid/pgadmin3/sid

« back to all changes in this revision

Viewing changes to pgadmin/dlg/dlgReassignDropOwned.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-07-30 12:27:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730122716-fddbh42on721bbs2
Tags: 1.10.0-1
* New upstream release.
* Adjusted watch file to match release candidates.
* Updated to Standards-Version 3.8.2:
  - Moved to Section: database.
  - Add DEB_BUILD_OPTIONS support for parallel building.
  - Move from findstring to filter suggestion for DEB_BUILD_OPTIONS parsing.
* pgagent got split into its own separate source package by upstream.
* Exclude Docs.vcproj from installation.
* Move doc-base.enus from pgadmin3 to pgadmin3-data package, the files are
  in there too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// pgAdmin III - PostgreSQL Tools
 
4
// RCS-ID:      $Id: dlgReassignDropOwned.cpp 7759 2009-03-26 21:24:39Z dpage $
 
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
 
6
// This software is released under the BSD Licence
 
7
//
 
8
// dlgReassignDropOwned.cpp - Reassign or drop owned objects
 
9
//
 
10
//////////////////////////////////////////////////////////////////////////
 
11
 
 
12
#include "pgAdmin3.h"
 
13
 
 
14
// wxWindows headers
 
15
#include <wx/wx.h>
 
16
 
 
17
// App headers
 
18
#include "pgAdmin3.h"
 
19
#include "utils/pgDefs.h"
 
20
#include "frm/frmMain.h"
 
21
#include "utils/misc.h"
 
22
#include "schema/pgRole.h"
 
23
#include "dlg/dlgReassignDropOwned.h"
 
24
 
 
25
 
 
26
// pointer to controls
 
27
#define rbReassignTo      CTRL_RADIOBUTTON("rbReassignTo")
 
28
#define rbDrop            CTRL_RADIOBUTTON("rbDrop")
 
29
#define cbRoles           CTRL_COMBOBOX("cbRoles")
 
30
#define cbDatabases       CTRL_COMBOBOX("cbDatabases")
 
31
 
 
32
BEGIN_EVENT_TABLE(dlgReassignDropOwned, pgDialog)
 
33
    EVT_RADIOBUTTON(XRCID("rbReassignTo"),    dlgReassignDropOwned::OnChange)
 
34
    EVT_RADIOBUTTON(XRCID("rbDrop"),          dlgReassignDropOwned::OnChange)
 
35
    EVT_BUTTON(wxID_OK,                       dlgReassignDropOwned::OnOK)
 
36
END_EVENT_TABLE()
 
37
 
 
38
 
 
39
dlgReassignDropOwned::dlgReassignDropOwned(frmMain *win, pgConn *conn,
 
40
  pgRole *role, wxString dbrestriction)
 
41
{
 
42
        wxString query;
 
43
 
 
44
        connection=conn;
 
45
        parent=win;
 
46
        
 
47
        wxWindowBase::SetFont(settings->GetSystemFont());
 
48
    LoadResource(win, wxT("dlgReassignDropOwned"));
 
49
    
 
50
    cbRoles->Clear();
 
51
    query = wxT("SELECT rolname FROM pg_roles WHERE rolname<>") + conn->qtDbString(role->GetName()) + wxT(" ORDER BY rolname");
 
52
    pgSetIterator roles(connection, query);
 
53
    while (roles.RowsLeft())
 
54
    {
 
55
        cbRoles->Append(roles.GetVal(wxT("rolname")));
 
56
    }
 
57
    cbRoles->SetSelection(0);
 
58
    cbRoles->Enable(cbRoles->GetStrings().Count() > 0);
 
59
        
 
60
    cbDatabases->Clear();
 
61
    query = wxT("SELECT DISTINCT datname FROM pg_database WHERE datallowconn");
 
62
    if (!dbrestriction.IsEmpty())
 
63
    {
 
64
        query += wxT(" AND datname NOT IN (") + dbrestriction + wxT(")");
 
65
    }
 
66
    query += wxT(" ORDER BY datname");
 
67
 
 
68
    pgSetIterator databases(connection, query);
 
69
    while (databases.RowsLeft())
 
70
    {
 
71
        cbDatabases->Append(databases.GetVal(wxT("datname")));
 
72
    }
 
73
    cbDatabases->SetSelection(0);
 
74
}
 
75
 
 
76
dlgReassignDropOwned::~dlgReassignDropOwned()
 
77
{
 
78
    SavePosition();
 
79
}
 
80
 
 
81
 
 
82
void dlgReassignDropOwned::OnOK(wxCommandEvent& ev)
 
83
{
 
84
    EndModal(wxID_OK);
 
85
}
 
86
 
 
87
 
 
88
void dlgReassignDropOwned::OnCancel(wxCommandEvent& ev)
 
89
{
 
90
    EndModal(wxID_CANCEL);
 
91
}
 
92
 
 
93
void dlgReassignDropOwned::OnChange(wxCommandEvent &ev)
 
94
{
 
95
    cbRoles->Enable(rbReassignTo->GetValue() && cbRoles->GetStrings().Count() > 0);
 
96
}
 
97
 
 
98
wxString dlgReassignDropOwned::GetDatabase()
 
99
{
 
100
        return cbDatabases->GetValue();
 
101
}
 
102
 
 
103
wxString dlgReassignDropOwned::GetRole()
 
104
{
 
105
        return cbRoles->GetValue();
 
106
}
 
107
 
 
108
bool dlgReassignDropOwned::IsReassign()
 
109
{
 
110
        return rbReassignTo->GetValue();
 
111
}