Tag: cws_src680_qiq User: fs Date: 06/05/17 04:45:32 Modified: /dba/dbaccess/source/ui/querydesign/ JoinController.cxx, JoinDesignView.cxx
Log: #i51143# AddTableDialog is now in the responsibility of the controller, not the view (allows late construction as needed) File Changes: Directory: /dba/dbaccess/source/ui/querydesign/ =============================================== File [changed]: JoinController.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/JoinController.cxx?r1=1.37.10.1&r2=1.37.10.2 Delta lines: +123 -20 ---------------------- --- JoinController.cxx 12 May 2006 11:14:06 -0000 1.37.10.1 +++ JoinController.cxx 17 May 2006 11:45:29 -0000 1.37.10.2 @@ -4,9 +4,9 @@ * * $RCSfile: JoinController.cxx,v $ * - * $Revision: 1.37.10.1 $ + * $Revision: 1.37.10.2 $ * - * last change: $Author: fs $ $Date: 2006/05/12 11:14:06 $ + * last change: $Author: fs $ $Date: 2006/05/17 11:45:29 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -156,13 +156,98 @@ using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::ui::dialogs; using namespace ::dbtools; -using namespace ::dbaui; using namespace ::comphelper; +// ............................................................................. +namespace dbaui +{ +// ............................................................................. + +// ============================================================================= +// = AddTableDialogContext +// ============================================================================= +class AddTableDialogContext : public IAddTableDialogContext +{ + OJoinController& m_rController; + +public: + AddTableDialogContext( OJoinController& _rController ) + :m_rController( _rController ) + { + } + + // IAddTableDialogContext + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > + getConnection() const; + virtual bool allowViews() const; + virtual bool allowQueries() const; + virtual bool allowAddition() const; + virtual void addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ); + virtual void onWindowClosing( const Window* _pWindow ); + +private: + OJoinTableView* getTableView() const; +}; + +// ----------------------------------------------------------------------------- +Reference< XConnection > AddTableDialogContext::getConnection() const +{ + return m_rController.getConnection(); +} + +// ----------------------------------------------------------------------------- +bool AddTableDialogContext::allowViews() const +{ + return m_rController.allowViews(); +} + +// ----------------------------------------------------------------------------- +bool AddTableDialogContext::allowQueries() const +{ + return m_rController.allowQueries(); +} + +// ----------------------------------------------------------------------------- +bool AddTableDialogContext::allowAddition() const +{ + return const_cast< OJoinController& >( m_rController ).getJoinView()->getTableView()->IsAddAllowed(); +} + +// ----------------------------------------------------------------------------- +void AddTableDialogContext::addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ) +{ + getTableView()->AddTabWin( _rQualifiedTableName, _rAliasName, TRUE ); +} + +// ----------------------------------------------------------------------------- +void AddTableDialogContext::onWindowClosing( const Window* _pWindow ) +{ + if ( !m_rController.getView() ) + return; + + ::dbaui::notifySystemWindow( + m_rController.getView(), const_cast< Window* >( _pWindow ), ::comphelper::mem_fun( &TaskPaneList::RemoveWindow ) ); + + m_rController.InvalidateFeature( ID_BROWSER_ADDTABLE ); + m_rController.getView()->GrabFocus(); +} + +// ----------------------------------------------------------------------------- +OJoinTableView* AddTableDialogContext::getTableView() const +{ + if ( m_rController.getJoinView() ) + return m_rController.getJoinView()->getTableView(); + return NULL; +} + +// ============================================================================= +// = OJoinController +// ============================================================================= + DBG_NAME(OJoinController); // ----------------------------------------------------------------------------- OJoinController::OJoinController(const Reference< XMultiServiceFactory >& _rM) : OJoinController_BASE(_rM) - ,m_pAddTabDlg(NULL) + ,m_pAddTableDialog( NULL ) { DBG_CTOR(OJoinController,NULL); } @@ -187,9 +272,13 @@ // ----------------------------------------------------------------------------- void OJoinController::disposing() { + { + ::std::auto_ptr< Window > pEnsureDelete( m_pAddTableDialog ); + m_pAddTableDialog = NULL; + } + OJoinController_BASE::disposing(); - m_pAddTabDlg = NULL; m_pView = NULL; { @@ -206,6 +295,14 @@ } } // ----------------------------------------------------------------------------- +void OJoinController::reconnect( sal_Bool _bUI ) +{ + OJoinController_BASE::reconnect( _bUI ); + if ( isConnected() && m_pAddTableDialog ) + m_pAddTableDialog->Update(); +} + +// ----------------------------------------------------------------------------- void OJoinController::setModified(sal_Bool _bModified) { OJoinController_BASE::setModified(_bModified); @@ -243,7 +340,7 @@ break; case ID_BROWSER_ADDTABLE: if (aReturn.bEnabled = getView() && const_cast< OJoinController* >( this )->getJoinView()->getTableView()->IsAddAllowed()) - aReturn.aState = ::cppu::bool2any(m_pAddTabDlg && m_pAddTabDlg->IsVisible()); + aReturn.aState = ::cppu::bool2any( m_pAddTableDialog && m_pAddTableDialog->IsVisible() ); else aReturn.aState = ::cppu::bool2any(sal_False); break; @@ -280,22 +377,25 @@ return; break; case ID_BROWSER_ADDTABLE: - if(!m_pAddTabDlg) - m_pAddTabDlg = getJoinView()->getAddTableDialog(); - if(m_pAddTabDlg->IsVisible()) + if ( !m_pAddTableDialog ) + { + m_pDialogContext.reset( new AddTableDialogContext( *this ) ); + m_pAddTableDialog = new OAddTableDlg( getView(), *m_pDialogContext ); + } + + if ( m_pAddTableDialog->IsVisible() ) { - // ::dbaui::notifySystemWindow(getView(),m_pAddTabDlg,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); - m_pAddTabDlg->Show(!m_pAddTabDlg->IsVisible()); - m_pView->GrabFocus(); + m_pAddTableDialog->Show( FALSE ); + getView()->GrabFocus(); } - else if(getJoinView()->getTableView()->IsAddAllowed()) + else { { - WaitObject aWaitCursor(getView()); - m_pAddTabDlg->Update(); + WaitObject aWaitCursor( getView() ); + m_pAddTableDialog->Update(); } - m_pAddTabDlg->Show(!m_pAddTabDlg->IsVisible()); - ::dbaui::notifySystemWindow(getView(),m_pAddTabDlg,::comphelper::mem_fun(&TaskPaneList::AddWindow)); + m_pAddTableDialog->Show( TRUE ); + ::dbaui::notifySystemWindow(getView(),m_pAddTableDialog,::comphelper::mem_fun(&TaskPaneList::AddWindow)); } break; default: @@ -490,3 +590,6 @@ } } +// ............................................................................. +} // namespace dbaui +// ............................................................................. File [changed]: JoinDesignView.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/JoinDesignView.cxx?r1=1.17.118.1&r2=1.17.118.2 Delta lines: +2 -78 -------------------- --- JoinDesignView.cxx 12 May 2006 11:11:02 -0000 1.17.118.1 +++ JoinDesignView.cxx 17 May 2006 11:45:29 -0000 1.17.118.2 @@ -4,9 +4,9 @@ * * $RCSfile: JoinDesignView.cxx,v $ * - * $Revision: 1.17.118.1 $ + * $Revision: 1.17.118.2 $ * - * last change: $Author: fs $ $Date: 2006/05/12 11:11:02 $ + * last change: $Author: fs $ $Date: 2006/05/17 11:45:29 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -109,74 +109,6 @@ { // ============================================================================= -// = AddTableDialogContext -// ============================================================================= -class AddTableDialogContext : public IAddTableDialogContext -{ - OJoinTableView& m_rView; - -public: - AddTableDialogContext( OJoinTableView& _rView ) - :m_rView( _rView ) - { - } - - // IAddTableDialogContext - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > - getConnection() const; - virtual bool allowViews() const; - virtual bool allowQueries() const; - virtual bool allowAddition() const; - virtual void addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ); - virtual void onWindowClosing( const Window* _pWindow ); -}; - -// ----------------------------------------------------------------------------- -Reference< XConnection > AddTableDialogContext::getConnection() const -{ - return m_rView.getDesignView()->getController()->getConnection(); -} - -// ----------------------------------------------------------------------------- -bool AddTableDialogContext::allowViews() const -{ - return m_rView.getDesignView()->getController()->allowViews(); -} - -// ----------------------------------------------------------------------------- -bool AddTableDialogContext::allowQueries() const -{ - return m_rView.getDesignView()->getController()->allowQueries(); -} - -// ----------------------------------------------------------------------------- -bool AddTableDialogContext::allowAddition() const -{ - return m_rView.IsAddAllowed(); -} - -// ----------------------------------------------------------------------------- -void AddTableDialogContext::addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ) -{ - m_rView.AddTabWin( _rQualifiedTableName, _rAliasName, TRUE ); -} - -// ----------------------------------------------------------------------------- -void AddTableDialogContext::onWindowClosing( const Window* _pWindow ) -{ - ::dbaui::notifySystemWindow( - m_rView.getDesignView(), const_cast< Window* >( _pWindow ), ::comphelper::mem_fun( &TaskPaneList::RemoveWindow ) ); - - if ( m_rView.getDesignView() && m_rView.getDesignView()->getController() ) - { - m_rView.getDesignView()->getController()->InvalidateFeature( ID_BROWSER_ADDTABLE ); - if ( m_rView.getDesignView()->getController()->getView() ) - m_rView.getDesignView()->getController()->getView()->GrabFocus(); - } -} - - -// ============================================================================= // = OJoinDesignView // ============================================================================= // ----------------------------------------------------------------------------- @@ -184,22 +116,16 @@ :ODataView(_pParent,_pController,_rFactory) ,m_pController(_pController) ,m_pTableView(NULL) - ,m_pAddTabDlg(NULL) - ,m_pDialogContext( NULL ) { m_pScrollWindow = new OScrollWindowHelper(this); } // ----------------------------------------------------------------------------- OJoinDesignView::~OJoinDesignView() { - if ( m_pController ) - m_pController->clearAddTableDialog(); ::std::auto_ptr<Window> aT3(m_pScrollWindow); m_pScrollWindow = NULL; ::std::auto_ptr<Window> aT2(m_pTableView); m_pTableView = NULL; - ::std::auto_ptr<Window> aT1(m_pAddTabDlg); - m_pAddTabDlg = NULL; } // ------------------------------------------------------------------------- void OJoinDesignView::Construct() @@ -208,8 +134,6 @@ m_pScrollWindow->Show(); m_pTableView->Show(); - m_pDialogContext.reset( new AddTableDialogContext( *m_pTableView ) ); - m_pAddTabDlg = new OAddTableDlg( m_pScrollWindow, *m_pDialogContext ); SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) ); ODataView::Construct(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
