[PATCH] Disable database wizard's next-button if needed

Mathias Hasselmann (via Code Review) gerrit at gerrit.libreoffice.org
Thu Mar 21 01:23:06 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2889

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/89/2889/1

Disable database wizard's next-button if needed

This disables the database wizard's next-button if the current page cannot
advance yet. This is needed to prevent the wizard from crashing if next gets
pushed when no datasource type is selected yet.

Note that this patch is far from being complete: I am pretty sure that some
of the other datasource pages also could use a custom canAdvance() method.
I'll look at them when transforming the other pages to the UI builder format.

Change-Id: I7f9fc42e534aebf10f4db62e5ae095d04f9be3c7
---
M dbaccess/source/ui/dlg/dbwizsetup.cxx
M dbaccess/source/ui/dlg/generalpage.cxx
M dbaccess/source/ui/dlg/generalpage.hxx
3 files changed, 25 insertions(+), 4 deletions(-)



diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 5db7e5f..b0fe79d 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -375,7 +375,7 @@
         OSL_FAIL( "ODbTypeWizDialogSetup::activateDatabasePath: unknown creation mode!" );
     }
 
-    enableButtons( WZB_NEXT, m_pGeneralPage->GetDatabaseCreationMode() != OGeneralPageWizard::eOpenExisting );
+    enableButtons( WZB_NEXT, m_pGeneralPage->canAdvance() );
         // TODO: this should go into the base class. Point is, we activate a path whose *last*
         // step is also the current one. The base class should automatically disable
         // the Next button in such a case. However, not for this patch ...
@@ -597,9 +597,11 @@
         pPage->SetServiceFactory( m_pImpl->getORB() );
         pPage->SetAdminDialog(this, this);
 
-        defaultButton( _nState == PAGE_DBSETUPWIZARD_FINAL ? WZB_FINISH : WZB_NEXT );
-        enableButtons( WZB_FINISH, _nState == PAGE_DBSETUPWIZARD_FINAL );
-        enableButtons( WZB_NEXT, _nState == PAGE_DBSETUPWIZARD_FINAL ? sal_False : sal_True);
+        const bool bEnableFinish = _nState == PAGE_DBSETUPWIZARD_FINAL;
+        const bool bEnableNext = !bEnableNext && pPage->canAdvance();
+        defaultButton( bEnableFinish ? WZB_FINISH : WZB_NEXT);
+        enableButtons( WZB_FINISH, bEnableFinish );
+        enableButtons( WZB_NEXT, bEnableNext );
         pPage->Show();
     }
     return pPage;
@@ -670,6 +672,7 @@
     switch(_nState)
     {
         case PAGE_DBSETUPWIZARD_INTRO:
+            enableButtons( WZB_NEXT, m_pGeneralPage->canAdvance() );
             m_sOldURL = m_sURL;
             break;
         case PAGE_DBSETUPWIZARD_FINAL:
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx
index 5117f2e..adca33c 100644
--- a/dbaccess/source/ui/dlg/generalpage.cxx
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -634,6 +634,22 @@
         return 0L;
     }
 
+    // -----------------------------------------------------------------------
+    bool OGeneralPageWizard::canAdvance() const
+    {
+        switch ( GetDatabaseCreationMode() )
+        {
+        case eConnectExternal:
+            return !GetSelectedType().isEmpty();
+        case eOpenExisting:
+            return false;
+        case eCreateNew:
+            break;
+        }
+
+        return true;
+    }
+
 //.........................................................................
 }   // namespace dbaui
 //.........................................................................
diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx
index a10e5ff..264b9bf 100644
--- a/dbaccess/source/ui/dlg/generalpage.hxx
+++ b/dbaccess/source/ui/dlg/generalpage.hxx
@@ -172,6 +172,8 @@
         void                    SetChooseDocumentHandler( const Link& _rHandler) { m_aChooseDocumentHandler = _rHandler; }
         DocumentDescriptor      GetSelectedDocument() const;
 
+        virtual bool            canAdvance() const;
+
     protected:
         virtual sal_Bool FillItemSet( SfxItemSet& _rCoreAttrs );
 

-- 
To view, visit https://gerrit.libreoffice.org/2889
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f9fc42e534aebf10f4db62e5ae095d04f9be3c7
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Mathias Hasselmann <mathias at openismus.com>



More information about the LibreOffice mailing list