Validate the View dialogue properly [Ashesh Vashi]
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Wed, 8 Apr 2009 14:05:21 +0000 (14:05 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Wed, 8 Apr 2009 14:05:21 +0000 (14:05 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7804 a7884b65-44f6-0310-8a51-81a127f17b15

pgadmin/dlg/dlgView.cpp

index 599d3d30547bd161c78d62cd408895319646bf79..3a99ee4f884ea820147c405e98c2d7a91baf0a0b 100644 (file)
@@ -97,22 +97,21 @@ void dlgView::CheckChange()
     wxString name=GetName();
     if (name) 
     {
+        bool enable = true;
         if (view)
-             EnableOK(txtComment->GetValue() != view->GetComment()
-              || txtSqlBox->GetText() != oldDefinition
-              || cbOwner->GetValue() != view->GetOwner()
-              || name != view->GetName());
-         else
-            EnableOK(!txtComment->GetValue().IsEmpty()
-              || !txtSqlBox->GetText().IsEmpty()
-              || !cbOwner->GetValue().IsEmpty());
+            enable = txtComment->GetValue() != view->GetComment()
+                  || txtSqlBox->GetText().Trim(true).Trim(false) != oldDefinition.Trim(true).Trim(false)
+                  || cbOwner->GetValue() != view->GetOwner()
+                  || name != view->GetName();
+        enable &= !txtSqlBox->GetText().Trim(true).IsEmpty();
+        EnableOK(enable);
     }
     else
     {
         bool enable=true;
 
         CheckValid(enable, !name.IsEmpty(), _("Please specify name."));
-        CheckValid(enable, txtSqlBox->GetText().Length() > 14 , _("Please enter function definition."));
+        CheckValid(enable, txtSqlBox->GetText().Trim(true).Trim(false).Length() > 0 , _("Please enter function definition."));
 
         EnableOK(enable);
     }
@@ -123,7 +122,6 @@ wxString dlgView::GetSql()
 {
     wxString sql, name=GetName();
 
-
     if (view)
     {
         // edit mode
@@ -138,7 +136,7 @@ wxString dlgView::GetSql()
     if (!view || txtSqlBox->GetText() != oldDefinition)
     {
         sql += wxT("CREATE OR REPLACE VIEW ") + schema->GetQuotedPrefix() + qtIdent(name) + wxT(" AS\n")
-            + txtSqlBox->GetText()
+            + txtSqlBox->GetText().Trim(true).Trim(false)
             + wxT(";\n");
     }