User: obo Date: 2006/07/10 08:40:06 Modified: dba/dbaccess/source/ui/querydesign/JoinController.cxx
Log: INTEGRATION: CWS qiq (1.37.10); FILE MERGED 2006/06/27 12:51:35 fs 1.37.10.4: RESYNC: (1.37-1.38); FILE MERGED 2006/06/19 09:25:10 fs 1.37.10.3: #i51143# adjust the title of the .uno:AddTable command, depending on whether we are also allowed to add queries 2006/05/17 11:45:29 fs 1.37.10.2: #i51143# AddTableDialog is now in the responsibility of the controller, not the view (allows late construction as needed) 2006/05/12 11:14:06 fs 1.37.10.1: #i51143# m_bViewsAllowed now represented with method allowViews 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.38&r2=1.39 Delta lines: +139 -25 ---------------------- --- JoinController.cxx 20 Jun 2006 03:25:26 -0000 1.38 +++ JoinController.cxx 10 Jul 2006 15:40:03 -0000 1.39 @@ -144,6 +144,8 @@ #include "UITools.hxx" #endif +#include <boost/optional.hpp> + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; using namespace ::com::sun::star::beans; @@ -156,15 +158,99 @@ 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_bViewsAllowed(sal_True) + ,m_pAddTableDialog(NULL) { DBG_CTOR(OJoinController,NULL); } @@ -189,9 +275,13 @@ // ----------------------------------------------------------------------------- void OJoinController::disposing() { + { + ::std::auto_ptr< Window > pEnsureDelete( m_pAddTableDialog ); + m_pAddTableDialog = NULL; + } + OJoinController_BASE::disposing(); - m_pAddTabDlg = NULL; m_pView = NULL; { @@ -208,6 +298,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); @@ -238,22 +336,35 @@ switch (_nId) { case ID_BROWSER_EDITDOC: - aReturn.aState = ::cppu::bool2any(isEditable()); + aReturn.bChecked = isEditable(); break; case ID_BROWSER_SAVEDOC: aReturn.bEnabled = isConnected() && isModified(); 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()); - else - aReturn.aState = ::cppu::bool2any(sal_False); + aReturn.bEnabled = ( getView() != NULL ) + && const_cast< OJoinController* >( this )->getJoinView()->getTableView()->IsAddAllowed(); + aReturn.bChecked = aReturn.bEnabled && m_pAddTableDialog != NULL && m_pAddTableDialog->IsVisible() ; + aReturn.sTitle = OAddTableDlg::getDialogTitleForContext( impl_getDialogContext() ); break; + default: aReturn = OJoinController_BASE::GetState(_nId); } return aReturn; } + +// ----------------------------------------------------------------------------- +AddTableDialogContext& OJoinController::impl_getDialogContext() const +{ + if ( !m_pDialogContext.get() ) + { + OJoinController* pNonConstThis = const_cast< OJoinController* >( this ); + pNonConstThis->m_pDialogContext.reset( new AddTableDialogContext( *pNonConstThis ) ); + } + return *m_pDialogContext; +} + // ----------------------------------------------------------------------------- void OJoinController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs) { @@ -280,22 +391,22 @@ InvalidateAll(); return; case ID_BROWSER_ADDTABLE: - if(!m_pAddTabDlg) - m_pAddTabDlg = getJoinView()->getAddTableDialog(); - if(m_pAddTabDlg->IsVisible()) + if ( !m_pAddTableDialog ) + m_pAddTableDialog = new OAddTableDlg( getView(), impl_getDialogContext() ); + + 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: @@ -489,4 +600,7 @@ pViewIter->Value <<= aTables; } } -// ----------------------------------------------------------------------------- + +// ............................................................................. +} // namespace dbaui +// ............................................................................. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
