Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Pgadmin Hackers > Re: Enabling SQ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 28 of 48 Topic 3654 of 4873
Post > Topic >>

Re: Enabling SQL text field in the SQL tab of object

by guillaume@[EMAIL PROTECTED] (Guillaume Lelarge) Jun 17, 2008 at 11:51 PM

This is a multi-part message in MIME format.
--------------050605040209010008090106
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Dave Page a écrit :
> On Tue, Jun 17, 2008 at 8:59 AM, Guillaume Lelarge
> <guillaume@[EMAIL PROTECTED]
> wrote:
> 
>>> That can be
>>> potentially dangerous if the user has another property dialogue for a
>>> sibling object open though (actually that's an issue now iirc - this
>>> would just make it far more likely to occur).
>>>
>> What kind of issue are you talking about? can you give me an example?
> 
> When you open a properties dialogue, it gets passed a pointer to the
> pgObject which it may use right up until it is closed. If you refresh
> part of the tree, you delete and recreate all the pgObjects under the
> node you refresh, so the dialogue can end up with a pointer to an
> object that's been deleted.
> 

OK, but this is already an issue.

Here is patch revision 2. It creates a new textfield for the second SQL 
query, and it takes care of the refresh of the tree. This patch seems to 
resolve all issues I could find (apart from the one above).

Comments?


-- 
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com

--------------050605040209010008090106
Content-Type: text/x-patch;
 name="enablingsqltextfield_v2.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="enablingsqltextfield_v2.patch"

Index: pgadmin/include/dlg/dlgProperty.h
===================================================================
--- pgadmin/include/dlg/dlgProperty.h	(revision 7376)
+++ pgadmin/include/dlg/dlgProperty.h	(working copy)
@[EMAIL PROTECTED]
 -60,6 +60,8 @[EMAIL PROTECTED]
     void EnableOK(bool enable);
 	virtual bool IsUpToDate() { return true; };
     void ShowObject();
+	
+	void FillSQLTextfield();
 
     void CheckValid(bool &enable, const bool condition, const wxString
&msg);
     static dlgProperty *CreateDlg(frmMain *frame, pgObject *node, bool
asNew, pgaFactory *factory=0);
@[EMAIL PROTECTED]
 -86,6 +88,7 @[EMAIL PROTECTED]
     void OnChange(wxCommandEvent &ev);
     void OnChangeOwner(wxCommandEvent &ev);
     void OnChangeStc(wxStyledTextEvent& event);
+    void OnChangeReadOnly(wxCommandEvent& event);
 
 protected:
     void AddUsers(ctlComboBoxFix *cb1, ctlComboBoxFix *cb2=0);
@[EMAIL PROTECTED]
 -97,7 +100,7 @[EMAIL PROTECTED]
     pgDatabase *database;
 
     frmMain *mainForm;
-    ctlSQLBox *sqlPane;
+    wxPanel *sqlPane;
 
     wxTextValidator numericValidator;
 
@[EMAIL PROTECTED]
 -105,6 +108,9 @[EMAIL PROTECTED]
     wxTextCtrl *txtName, *txtOid, *txtComment;
     ctlComboBox *cbOwner;
     ctlComboBox *cbClusterSet;
+    wxCheckBox *chkReadOnly;
+    ctlSQLBox *sqlTextField1;
+    ctlSQLBox *sqlTextField2;
 
     int width, height;
     wxTreeItemId item, owneritem;
Index: pgadmin/dlg/dlgProperty.cpp
===================================================================
--- pgadmin/dlg/dlgProperty.cpp	(revision 7376)
+++ pgadmin/dlg/dlgProperty.cpp	(working copy)
@[EMAIL PROTECTED]
 -59,8 +59,6 @[EMAIL PROTECTED]
 #include "schema/pgUser.h"
 
 
-
-
 class replClientData : public wxClientData
 {
 public:
@[EMAIL PROTECTED]
 -72,6 +70,9 @[EMAIL PROTECTED]
 };
 
 
+#define CTRLID_CHKSQLTEXTFIELD 1000
+
+
 BEGIN_EVENT_TABLE(dlgProperty, DialogWithHelp)
     EVT_NOTEBOOK_PAGE_CHANGED(XRCID("nbNotebook"), 
dlgProperty::OnPageSelect)  
 
@[EMAIL PROTECTED]
 -80,6 +81,8 @[EMAIL PROTECTED]
     EVT_COMBOBOX(XRCID("cbOwner"),                 
dlgProperty::OnChange)
     EVT_TEXT(XRCID("txtComment"),                  
dlgProperty::OnChange)
     
+    EVT_CHECKBOX(CTRLID_CHKSQLTEXTFIELD,           
dlgProperty::OnChangeReadOnly)
+    
     EVT_BUTTON(wxID_HELP,                           dlgProperty::OnHelp)
     EVT_BUTTON(wxID_OK,                             dlgProperty::OnOK)
     EVT_BUTTON(wxID_APPLY,                          dlgProperty::OnApply)
@[EMAIL PROTECTED]
 -90,6 +93,8 @[EMAIL PROTECTED]
 {
     readOnly=false;
     sqlPane=0;
+    sqlTextField1=0;
+    sqlTextField2=0;
     processing=false;
     mainForm=frame;
     database=0;
@[EMAIL PROTECTED]
 -311,7 +316,39 @[EMAIL PROTECTED]
 
 void dlgProperty::CreateAdditionalPages()
 {
-    sqlPane = new ctlSQLBox(nbNotebook, CTL_PROPSQL, wxDefaultPosition,
wxDefaultSize, wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY |
wxTE_RICH2);
+    int width, height;
+	
+	// get a few sizes and widths
+#ifdef __WIN32__
+    GetClientSize(&width, &height);
+#else
+	nbNotebook->GetClientSize(&width, &height);
+	height -= ConvertDialogToPixels(wxPoint(0, 20)).y;   // sizes of tabs
+#endif
+    wxPoint zeroPos=ConvertDialogToPixels(wxPoint(5, 5));
+    wxSize chkSize=ConvertDialogToPixels(wxSize(65,12));
+
+    // add a panel
+    sqlPane = new wxPanel(nbNotebook);
+
+    // add checkbox to the panel
+    chkReadOnly = new wxCheckBox(sqlPane, CTRLID_CHKSQLTEXTFIELD,
wxT("Read only"),
+      wxPoint(zeroPos.x, zeroPos.y), 
+      chkSize);
+    chkReadOnly->SetValue(true);
+
+    // add ctlSQLBox to the panel
+    sqlTextField1 = new ctlSQLBox(sqlPane, CTL_PROPSQL,
+      wxPoint(zeroPos.x, zeroPos.y + chkSize.GetHeight()), 
+      wxSize(width - 2 * zeroPos.x, (height - 3 * zeroPos.y) / 2),
+      wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_RICH2);
+	  
+    sqlTextField2 = new ctlSQLBox(sqlPane, CTL_PROPSQL,
+      wxPoint(zeroPos.x, zeroPos.y + chkSize.GetHeight() + (height - 3 *
zeroPos.y) / 2), 
+      wxSize(width - 2 * zeroPos.x, (height - 3 * zeroPos.y) / 2),
+      wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_RICH2);
+
+    // add panel to the notebook
     nbNotebook->AddPage(sqlPane, wxT("SQL"));
 }
 
@[EMAIL PROTECTED]
 -506,6 +543,54 @[EMAIL PROTECTED]
 }
 
 
+void dlgProperty::OnChangeReadOnly(wxCommandEvent &ev)
+{
+    size_t pos;
+    
+    sqlTextField1->SetReadOnly(chkReadOnly->GetValue());
+    sqlTextField2->SetReadOnly(chkReadOnly->GetValue());
+    for (pos = 0; pos < nbNotebook->GetPageCount() - 1; pos++)
+    {
+        nbNotebook->GetPage(pos)->Enable(chkReadOnly->GetValue());
+    }
+    
+    if (chkReadOnly->GetValue())
+    {
+		if (wxMessageBox(_("Are you sure you wish to cancel your edit?"),
_("SQL editor"), wxYES_NO) == wxNO)
+			return;		
+    }
+}
+
+
+void dlgProperty::FillSQLTextfield()
+{    
+    // create a function because this is a duplicated code
+    sqlTextField1->SetReadOnly(false);
+    sqlTextField2->SetReadOnly(false);
+    if (btnOK->IsEnabled())
+    {
+        wxString tmp;
+        if (cbClusterSet && cbClusterSet->GetSelection() > 0)
+        {
+            replClientData
*data=(replClientData*)cbClusterSet->GetClientData(cbClusterSet->GetSelection());
+            tmp.Printf(_("-- Execute replicated using cluster \"%s\", set
%ld\n"), data->cluster.c_str(), data->setId);
+        }
+        sqlTextField1->SetText(tmp + GetSql());
+		sqlTextField2->SetText(GetSql2());
+    }
+    else
+    {
+        if (GetObject())
+            sqlTextField1->SetText(_("-- nothing to change"));
+		else
+            sqlTextField1->SetText(_("-- definition incomplete"));
+		sqlTextField2->SetText(wxT(""));
+	}
+    sqlTextField1->SetReadOnly(true);
+    sqlTextField2->SetReadOnly(true);
+}
+
+
 bool dlgProperty::tryUpdate(wxTreeItemId collectionItem)
 {
     ctlTree *browser=mainForm->GetBrowser();
@[EMAIL PROTECTED]
 -608,7 +693,7 @[EMAIL PROTECTED]
             mainForm->GetSqlPane()->SetReadOnly(true);
         }
     }
-    else if (item)
+    else if (item && chkReadOnly->GetValue())
     {
         wxTreeItemId collectionItem=item;
 
@[EMAIL PROTECTED]
 -753,8 +838,18 @[EMAIL PROTECTED]
         return;
     }
 
-    wxString sql=GetSql();
-    wxString sql2=GetSql2();
+    wxString sql;
+    wxString sql2;
+    if (chkReadOnly->GetValue())
+    {
+        sql = GetSql();
+		sql2 = GetSql2();
+    }
+    else
+    {
+        sql = sqlTextField1->GetText();
+        sql2 = sqlTextField2->GetText();
+    }    
 
     if (!apply(sql, sql2))
     {
@[EMAIL PROTECTED]
 -768,27 +863,10 @[EMAIL PROTECTED]
 
 void dlgProperty::OnPageSelect(wxNotebookEvent& event)
 {
-    if (sqlPane && event.GetSelection() ==
(int)nbNotebook->GetPageCount()-1)
+    if (sqlTextField1 && chkReadOnly->GetValue() &&
+        event.GetSelection() == (int)nbNotebook->GetPageCount()-1)
     {
-        sqlPane->SetReadOnly(false);
-        if (btnOK->IsEnabled())
-        {
-            wxString tmp;
-            if (cbClusterSet && cbClusterSet->GetSelection() > 0)
-            {
-                replClientData
*data=(replClientData*)cbClusterSet->GetClientData(cbClusterSet->GetSelection());
-                tmp.Printf(_("-- Execute replicated using cluster \"%s\",
set %ld\n"), data->cluster.c_str(), data->setId);
-            }
-            sqlPane->SetText(tmp + GetSql() + GetSql2());
-        }
-        else
-        {
-            if (GetObject())
-                sqlPane->SetText(_("-- nothing to change"));
-            else
-                sqlPane->SetText(_("-- definition incomplete"));
-        }
-        sqlPane->SetReadOnly(true);
+		FillSQLTextfield();
     }
 }
 

--------------050605040209010008090106
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

--------------050605040209010008090106--
 




 48 Posts in Topic:
Enabling SQL text field in the SQL tab of object dialog
guillaume@[EMAIL PROTECTE  2007-07-31 10:35:53 
Re: Enabling SQL text field in the SQL tab of object
dpage@[EMAIL PROTECTED]   2007-07-31 11:35:11 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-14 16:01:29 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-06-14 21:09:07 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-14 22:33:10 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-16 21:58:19 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-06-18 09:53:03 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-20 01:48:55 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-20 14:09:14 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-07-01 12:52:22 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-07-09 12:40:56 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-26 19:44:53 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-28 08:29:16 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-28 09:56:50 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-07-09 11:54:42 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-07-09 13:31:13 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-28 08:13:23 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-28 09:23:08 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-06-16 21:12:58 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-06-16 21:11:42 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-16 22:34:33 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-06-16 21:40:51 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-17 00:07:04 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-06-20 13:36:26 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-06-17 08:45:27 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-17 09:59:19 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-06-17 09:02:07 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-06-17 23:51:30 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-07-09 08:41:16 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-07-09 10:18:25 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-07-01 16:17:49 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-07-05 12:32:39 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-07-09 01:07:37 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-26 20:54:45 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-26 23:50:14 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-27 10:10:54 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-28 01:15:51 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-30 21:59:05 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-30 23:10:32 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-27 11:03:00 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-30 18:52:58 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-28 09:12:14 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-30 18:28:56 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-30 20:48:41 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-30 20:50:33 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-30 22:28:05 
Re: Enabling SQL text field in the SQL tab of object dialog
dpage@[EMAIL PROTECTED]   2008-08-30 21:29:27 
Re: Enabling SQL text field in the SQL tab of object
guillaume@[EMAIL PROTECTE  2008-08-30 22:44:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 23:55:01 CST 2008.