diff options
author | Oliver Bolte <obo@openoffice.org> | 2006-07-10 14:40:03 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2006-07-10 14:40:03 +0000 |
commit | 6521f9ba3c241c62c3e107ab69d00d901814d70f (patch) | |
tree | 716d4ddd22e67a6ada2efb8f6269361bc64d0431 /dbaccess/source/ui/querydesign/JoinController.cxx | |
parent | 47a3cbc71f696a274e6b6dd002ae20b0a4f41881 (diff) |
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
Diffstat (limited to 'dbaccess/source/ui/querydesign/JoinController.cxx')
-rw-r--r-- | dbaccess/source/ui/querydesign/JoinController.cxx | 164 |
1 files changed, 139 insertions, 25 deletions
diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx index 9c12d45e7..dcc654456 100644 --- a/dbaccess/source/ui/querydesign/JoinController.cxx +++ b/dbaccess/source/ui/querydesign/JoinController.cxx @@ -4,9 +4,9 @@ * * $RCSfile: JoinController.cxx,v $ * - * $Revision: 1.38 $ + * $Revision: 1.39 $ * - * last change: $Author: hr $ $Date: 2006-06-20 03:25:26 $ + * last change: $Author: obo $ $Date: 2006-07-10 15:40:03 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -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::sdbc; 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,10 +275,14 @@ OJoinDesignView* OJoinController::getJoinView() // ----------------------------------------------------------------------------- void OJoinController::disposing() { + { + ::std::auto_ptr< Window > pEnsureDelete( m_pAddTableDialog ); + m_pAddTableDialog = NULL; + } + OJoinController_BASE::disposing(); - - m_pAddTabDlg = NULL; - m_pView = NULL; + + m_pView = NULL; { ::std::vector< OTableConnectionData*>::iterator aIter = m_vTableConnectionData.begin(); @@ -208,6 +298,14 @@ void OJoinController::disposing() } } // ----------------------------------------------------------------------------- +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 @@ FeatureState OJoinController::GetState(sal_uInt16 _nId) const 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 @@ void OJoinController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& 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 @@ void OJoinController::saveTableWindows(Sequence<PropertyValue>& _rViewProps) pViewIter->Value <<= aTables; } } -// ----------------------------------------------------------------------------- + +// ............................................................................. +} // namespace dbaui +// ............................................................................. |