2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-17 06:07:32 +00:00
|
|
|
|
2001-02-05 08:15:20 +00:00
|
|
|
#include "adtabdlg.hxx"
|
2001-02-05 11:31:44 +00:00
|
|
|
#include "sqlmessage.hxx"
|
2001-02-05 08:15:20 +00:00
|
|
|
#include <tools/debug.hxx>
|
2006-07-10 14:25:35 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
#include <svtools/localresaccess.hxx>
|
2001-02-05 08:15:20 +00:00
|
|
|
#include "dbaccess_helpid.hrc"
|
2006-07-10 14:25:35 +00:00
|
|
|
#include "dbu_resource.hrc"
|
2002-08-19 07:01:32 +00:00
|
|
|
#include "dbu_dlg.hrc"
|
2001-02-05 08:15:20 +00:00
|
|
|
#include <sfx2/sfxsids.hrc>
|
|
|
|
#include "QueryTableView.hxx"
|
|
|
|
#include "QueryDesignView.hxx"
|
|
|
|
#include "querycontroller.hxx"
|
|
|
|
#include <connectivity/dbtools.hxx>
|
|
|
|
#include "browserids.hxx"
|
2006-07-10 14:25:35 +00:00
|
|
|
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
|
2001-02-05 08:15:20 +00:00
|
|
|
#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
2005-09-23 11:28:53 +00:00
|
|
|
#include "UITools.hxx"
|
2006-10-05 12:04:05 +00:00
|
|
|
#include "imageprovider.hxx"
|
2008-10-01 12:28:29 +00:00
|
|
|
#include <comphelper/containermultiplexer.hxx>
|
|
|
|
#include "cppuhelper/basemutex.hxx"
|
2002-07-16 08:53:18 +00:00
|
|
|
#include <algorithm>
|
2001-02-05 08:15:20 +00:00
|
|
|
|
|
|
|
// slot ids
|
|
|
|
using namespace dbaui;
|
2008-10-01 12:28:29 +00:00
|
|
|
using namespace ::com::sun::star;
|
2001-02-05 08:15:20 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::container;
|
2006-07-10 14:25:35 +00:00
|
|
|
using namespace ::com::sun::star::sdb;
|
2001-02-05 08:15:20 +00:00
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace dbtools;
|
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
TableObjectListFacade::~TableObjectListFacade()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-10-01 12:28:29 +00:00
|
|
|
class TableListFacade : public ::cppu::BaseMutex
|
|
|
|
, public TableObjectListFacade
|
|
|
|
, public ::comphelper::OContainerListener
|
2006-07-10 14:25:35 +00:00
|
|
|
{
|
|
|
|
OTableTreeListBox& m_rTableList;
|
|
|
|
Reference< XConnection > m_xConnection;
|
2008-10-01 12:28:29 +00:00
|
|
|
::rtl::Reference< comphelper::OContainerListenerAdapter>
|
|
|
|
m_pContainerListener;
|
|
|
|
bool m_bAllowViews;
|
2006-07-10 14:25:35 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
TableListFacade( OTableTreeListBox& _rTableList, const Reference< XConnection >& _rxConnection )
|
2008-10-01 12:28:29 +00:00
|
|
|
: ::comphelper::OContainerListener(m_aMutex)
|
|
|
|
,m_rTableList( _rTableList )
|
2006-07-10 14:25:35 +00:00
|
|
|
,m_xConnection( _rxConnection )
|
2008-10-01 12:28:29 +00:00
|
|
|
,m_bAllowViews(true)
|
2006-07-10 14:25:35 +00:00
|
|
|
{
|
|
|
|
}
|
2008-10-01 12:28:29 +00:00
|
|
|
virtual ~TableListFacade();
|
|
|
|
|
|
|
|
private:
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual void updateTableObjectList( bool _bAllowViews ) SAL_OVERRIDE;
|
|
|
|
virtual OUString getSelectedName( OUString& _out_rAliasName ) const SAL_OVERRIDE;
|
|
|
|
virtual bool isLeafSelected() const SAL_OVERRIDE;
|
2008-10-01 12:28:29 +00:00
|
|
|
// OContainerListener
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2006-07-10 14:25:35 +00:00
|
|
|
};
|
|
|
|
|
2008-10-01 12:28:29 +00:00
|
|
|
TableListFacade::~TableListFacade()
|
|
|
|
{
|
|
|
|
if ( m_pContainerListener.is() )
|
|
|
|
m_pContainerListener->dispose();
|
|
|
|
}
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString TableListFacade::getSelectedName( OUString& _out_rAliasName ) const
|
2006-07-10 14:25:35 +00:00
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = m_rTableList.FirstSelected();
|
2006-07-10 14:25:35 +00:00
|
|
|
if ( !pEntry )
|
2013-09-26 12:17:53 +02:00
|
|
|
return OUString();
|
2006-07-10 14:25:35 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aCatalog, aSchema, aTableName;
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pSchema = m_rTableList.GetParent(pEntry);
|
2006-07-10 14:25:35 +00:00
|
|
|
if(pSchema && pSchema != m_rTableList.getAllObjectsEntry())
|
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pCatalog = m_rTableList.GetParent(pSchema);
|
2006-07-10 14:25:35 +00:00
|
|
|
if(pCatalog && pCatalog != m_rTableList.getAllObjectsEntry())
|
|
|
|
aCatalog = m_rTableList.GetEntryText(pCatalog);
|
|
|
|
aSchema = m_rTableList.GetEntryText(pSchema);
|
|
|
|
}
|
|
|
|
aTableName = m_rTableList.GetEntryText(pEntry);
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aComposedName;
|
2006-07-10 14:25:35 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XDatabaseMetaData > xMeta( m_xConnection->getMetaData(), UNO_QUERY_THROW );
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( aCatalog.isEmpty()
|
|
|
|
&& !aSchema.isEmpty()
|
2006-07-10 14:25:35 +00:00
|
|
|
&& xMeta->supportsCatalogsInDataManipulation()
|
|
|
|
&& !xMeta->supportsSchemasInDataManipulation() )
|
|
|
|
{
|
|
|
|
aCatalog = aSchema;
|
2014-11-12 14:24:10 +05:30
|
|
|
aSchema.clear();
|
2006-07-10 14:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aComposedName = ::dbtools::composeTableName(
|
2014-03-31 16:46:08 +02:00
|
|
|
xMeta, aCatalog, aSchema, aTableName, false, ::dbtools::eInDataManipulation );
|
2006-07-10 14:25:35 +00:00
|
|
|
}
|
|
|
|
catch ( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
|
|
|
|
_out_rAliasName = aTableName;
|
|
|
|
return aComposedName;
|
|
|
|
}
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void TableListFacade::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2008-10-01 12:28:29 +00:00
|
|
|
{
|
|
|
|
updateTableObjectList(m_bAllowViews);
|
|
|
|
}
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void TableListFacade::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2008-10-01 12:28:29 +00:00
|
|
|
{
|
|
|
|
updateTableObjectList(m_bAllowViews);
|
|
|
|
}
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void TableListFacade::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2008-10-01 12:28:29 +00:00
|
|
|
{
|
|
|
|
}
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
void TableListFacade::updateTableObjectList( bool _bAllowViews )
|
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
m_bAllowViews = _bAllowViews;
|
2006-07-10 14:25:35 +00:00
|
|
|
m_rTableList.Clear();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XTablesSupplier > xTableSupp( m_xConnection, UNO_QUERY_THROW );
|
2008-10-01 12:28:29 +00:00
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
Reference< XViewsSupplier > xViewSupp;
|
|
|
|
Reference< XNameAccess > xTables, xViews;
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > sTables, sViews;
|
2006-07-10 14:25:35 +00:00
|
|
|
|
|
|
|
xTables = xTableSupp->getTables();
|
|
|
|
if ( xTables.is() )
|
2008-10-01 12:28:29 +00:00
|
|
|
{
|
|
|
|
if ( !m_pContainerListener.is() )
|
|
|
|
{
|
|
|
|
Reference< XContainer> xContainer(xTables,uno::UNO_QUERY);
|
|
|
|
if ( xContainer.is() )
|
|
|
|
m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
|
|
|
|
}
|
2006-07-10 14:25:35 +00:00
|
|
|
sTables = xTables->getElementNames();
|
2010-11-24 01:50:15 +00:00
|
|
|
}
|
2006-07-10 14:25:35 +00:00
|
|
|
|
|
|
|
xViewSupp.set( xTableSupp, UNO_QUERY );
|
|
|
|
if ( xViewSupp.is() )
|
|
|
|
{
|
|
|
|
xViews = xViewSupp->getViews();
|
|
|
|
if ( xViews.is() )
|
|
|
|
sViews = xViews->getElementNames();
|
|
|
|
}
|
|
|
|
|
|
|
|
// if no views are allowed remove the views also out the table name filter
|
|
|
|
if ( !_bAllowViews )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString* pTableBegin = sTables.getConstArray();
|
|
|
|
const OUString* pTableEnd = pTableBegin + sTables.getLength();
|
|
|
|
::std::vector< OUString > aTables(pTableBegin,pTableEnd);
|
2006-07-10 14:25:35 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString* pViewBegin = sViews.getConstArray();
|
|
|
|
const OUString* pViewEnd = pViewBegin + sViews.getLength();
|
2013-12-06 14:27:53 +01:00
|
|
|
::comphelper::UStringMixEqual aEqualFunctor;
|
2006-07-10 14:25:35 +00:00
|
|
|
for(;pViewBegin != pViewEnd;++pViewBegin)
|
|
|
|
aTables.erase(::std::remove_if(aTables.begin(),aTables.end(),::std::bind2nd(aEqualFunctor,*pViewBegin)),aTables.end());
|
2015-01-28 17:53:30 +01:00
|
|
|
sTables = Sequence< OUString>(aTables.data(), aTables.size());
|
2013-04-07 12:06:47 +02:00
|
|
|
sViews = Sequence< OUString>();
|
2006-07-10 14:25:35 +00:00
|
|
|
}
|
|
|
|
|
2006-10-05 12:04:05 +00:00
|
|
|
m_rTableList.UpdateTableList( m_xConnection, sTables, sViews );
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = m_rTableList.First();
|
2011-12-07 02:33:51 -08:00
|
|
|
while( pEntry && m_rTableList.GetModel()->HasChildren( pEntry ) )
|
2006-07-10 14:25:35 +00:00
|
|
|
{
|
|
|
|
m_rTableList.Expand( pEntry );
|
|
|
|
pEntry = m_rTableList.Next( pEntry );
|
|
|
|
}
|
|
|
|
if ( pEntry )
|
|
|
|
m_rTableList.Select(pEntry);
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TableListFacade::isLeafSelected() const
|
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = m_rTableList.FirstSelected();
|
2011-12-07 02:33:51 -08:00
|
|
|
return pEntry && !m_rTableList.GetModel()->HasChildren( pEntry );
|
2006-07-10 14:25:35 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 12:28:29 +00:00
|
|
|
class QueryListFacade : public ::cppu::BaseMutex
|
|
|
|
, public TableObjectListFacade
|
|
|
|
, public ::comphelper::OContainerListener
|
2006-07-10 14:25:35 +00:00
|
|
|
{
|
|
|
|
SvTreeListBox& m_rQueryList;
|
|
|
|
Reference< XConnection > m_xConnection;
|
2008-10-01 12:28:29 +00:00
|
|
|
::rtl::Reference< comphelper::OContainerListenerAdapter>
|
|
|
|
m_pContainerListener;
|
2006-07-10 14:25:35 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
QueryListFacade( SvTreeListBox& _rQueryList, const Reference< XConnection >& _rxConnection )
|
2008-10-01 12:28:29 +00:00
|
|
|
: ::comphelper::OContainerListener(m_aMutex)
|
|
|
|
,m_rQueryList( _rQueryList )
|
2006-07-10 14:25:35 +00:00
|
|
|
,m_xConnection( _rxConnection )
|
|
|
|
{
|
|
|
|
}
|
2008-10-01 12:28:29 +00:00
|
|
|
virtual ~QueryListFacade();
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2008-10-01 12:28:29 +00:00
|
|
|
private:
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual void updateTableObjectList( bool _bAllowViews ) SAL_OVERRIDE;
|
|
|
|
virtual OUString getSelectedName( OUString& _out_rAliasName ) const SAL_OVERRIDE;
|
|
|
|
virtual bool isLeafSelected() const SAL_OVERRIDE;
|
2008-10-01 12:28:29 +00:00
|
|
|
// OContainerListener
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2006-07-10 14:25:35 +00:00
|
|
|
};
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2008-10-01 12:28:29 +00:00
|
|
|
QueryListFacade::~QueryListFacade()
|
|
|
|
{
|
|
|
|
if ( m_pContainerListener.is() )
|
|
|
|
m_pContainerListener->dispose();
|
|
|
|
}
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void QueryListFacade::_elementInserted( const container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2008-10-01 12:28:29 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sName;
|
2008-10-01 12:28:29 +00:00
|
|
|
if ( _rEvent.Accessor >>= sName )
|
|
|
|
m_rQueryList.InsertEntry( sName );
|
|
|
|
}
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void QueryListFacade::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2008-10-01 12:28:29 +00:00
|
|
|
{
|
|
|
|
updateTableObjectList(true);
|
|
|
|
}
|
2012-08-10 20:50:33 +02:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void QueryListFacade::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
|
2008-10-01 12:28:29 +00:00
|
|
|
{
|
|
|
|
}
|
2006-07-10 14:25:35 +00:00
|
|
|
|
|
|
|
void QueryListFacade::updateTableObjectList( bool /*_bAllowViews*/ )
|
|
|
|
{
|
|
|
|
m_rQueryList.Clear();
|
|
|
|
try
|
|
|
|
{
|
2006-10-05 12:04:05 +00:00
|
|
|
ImageProvider aImageProvider( m_xConnection );
|
2015-04-24 15:29:31 +02:00
|
|
|
Image aQueryImage( ImageProvider::getDefaultImage( css::sdb::application::DatabaseObject::QUERY ) );
|
2006-10-05 12:04:05 +00:00
|
|
|
|
2010-11-09 21:00:04 -08:00
|
|
|
m_rQueryList.SetDefaultExpandedEntryBmp( aQueryImage );
|
|
|
|
m_rQueryList.SetDefaultCollapsedEntryBmp( aQueryImage );
|
2006-07-10 14:25:35 +00:00
|
|
|
|
|
|
|
Reference< XQueriesSupplier > xSuppQueries( m_xConnection, UNO_QUERY_THROW );
|
|
|
|
Reference< XNameAccess > xQueries( xSuppQueries->getQueries(), UNO_QUERY_THROW );
|
2008-10-01 12:28:29 +00:00
|
|
|
if ( !m_pContainerListener.is() )
|
|
|
|
{
|
|
|
|
Reference< XContainer> xContainer(xQueries,UNO_QUERY_THROW);
|
|
|
|
m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
|
|
|
|
}
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< OUString > aQueryNames = xQueries->getElementNames();
|
2006-07-10 14:25:35 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString* pQuery = aQueryNames.getConstArray();
|
|
|
|
const OUString* pQueryEnd = aQueryNames.getConstArray() + aQueryNames.getLength();
|
2006-07-10 14:25:35 +00:00
|
|
|
while ( pQuery != pQueryEnd )
|
|
|
|
m_rQueryList.InsertEntry( *pQuery++ );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString QueryListFacade::getSelectedName( OUString& _out_rAliasName ) const
|
2006-07-10 14:25:35 +00:00
|
|
|
{
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString sSelected;
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = m_rQueryList.FirstSelected();
|
2006-07-10 14:25:35 +00:00
|
|
|
if ( pEntry )
|
|
|
|
sSelected = _out_rAliasName = m_rQueryList.GetEntryText( pEntry );
|
|
|
|
return sSelected;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QueryListFacade::isLeafSelected() const
|
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = m_rQueryList.FirstSelected();
|
2011-12-07 02:33:51 -08:00
|
|
|
return pEntry && !m_rQueryList.GetModel()->HasChildren( pEntry );
|
2006-07-10 14:25:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
OAddTableDlg::OAddTableDlg( vcl::Window* pParent, IAddTableDialogContext& _rContext )
|
2014-02-10 15:28:03 +00:00
|
|
|
: ModelessDialog(pParent, "TablesJoinDialog", "dbaccess/ui/tablesjoindialog.ui")
|
|
|
|
, m_rContext(_rContext)
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2014-02-10 15:28:03 +00:00
|
|
|
get(m_pCaseTables, "tables");
|
|
|
|
get(m_pCaseQueries, "queries");
|
|
|
|
|
|
|
|
get(m_pTableList, "tablelist");
|
|
|
|
get(m_pQueryList, "querylist");
|
|
|
|
Size aSize(LogicToPixel(Size(106 , 122), MAP_APPFONT));
|
|
|
|
m_pTableList->set_height_request(aSize.Height());
|
|
|
|
m_pTableList->set_width_request(aSize.Width());
|
|
|
|
get(m_pQueryList, "querylist");
|
|
|
|
m_pQueryList->set_height_request(aSize.Height());
|
|
|
|
m_pQueryList->set_width_request(aSize.Width());
|
|
|
|
|
|
|
|
get(m_pAddButton, "add");
|
|
|
|
get(m_pCloseButton, "close");
|
|
|
|
|
|
|
|
m_pCaseTables->SetClickHdl( LINK( this, OAddTableDlg, OnTypeSelected ) );
|
|
|
|
m_pCaseQueries->SetClickHdl( LINK( this, OAddTableDlg, OnTypeSelected ) );
|
|
|
|
m_pAddButton->SetClickHdl( LINK( this, OAddTableDlg, AddClickHdl ) );
|
|
|
|
m_pCloseButton->SetClickHdl( LINK( this, OAddTableDlg, CloseClickHdl ) );
|
|
|
|
m_pTableList->SetDoubleClickHdl( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) );
|
|
|
|
m_pTableList->SetSelectHdl( LINK( this, OAddTableDlg, TableListSelectHdl ) );
|
|
|
|
m_pQueryList->SetDoubleClickHdl( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) );
|
|
|
|
m_pQueryList->SetSelectHdl( LINK( this, OAddTableDlg, TableListSelectHdl ) );
|
|
|
|
|
|
|
|
m_pTableList->EnableInplaceEditing( false );
|
|
|
|
m_pTableList->SetStyle(m_pTableList->GetStyle() | WB_BORDER | WB_HASLINES |WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HASLINESATROOT | WB_SORT | WB_HSCROLL );
|
|
|
|
m_pTableList->EnableCheckButton( NULL ); // do not show any buttons
|
|
|
|
m_pTableList->SetSelectionMode( SINGLE_SELECTION );
|
|
|
|
m_pTableList->notifyHiContrastChanged();
|
|
|
|
m_pTableList->suppressEmptyFolders();
|
|
|
|
|
|
|
|
m_pQueryList->EnableInplaceEditing( false );
|
|
|
|
m_pQueryList->SetSelectionMode( SINGLE_SELECTION );
|
2001-02-05 08:15:20 +00:00
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
if ( !m_rContext.allowQueries() )
|
|
|
|
{
|
2014-02-10 15:28:03 +00:00
|
|
|
m_pCaseTables->Hide();
|
|
|
|
m_pCaseQueries->Hide();
|
2006-07-10 14:25:35 +00:00
|
|
|
}
|
2001-02-05 08:15:20 +00:00
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
SetText( getDialogTitleForContext( m_rContext ) );
|
2001-02-05 08:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OAddTableDlg::~OAddTableDlg()
|
2015-01-16 15:29:28 +02:00
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-01-16 15:29:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OAddTableDlg::dispose()
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2006-07-10 14:25:35 +00:00
|
|
|
m_rContext.onWindowClosing( this );
|
2015-03-09 14:29:30 +02:00
|
|
|
m_pCaseTables.clear();
|
|
|
|
m_pCaseQueries.clear();
|
|
|
|
m_pTableList.clear();
|
|
|
|
m_pQueryList.clear();
|
|
|
|
m_pAddButton.clear();
|
|
|
|
m_pCloseButton.clear();
|
2015-01-16 15:29:28 +02:00
|
|
|
ModelessDialog::dispose();
|
2001-02-05 08:15:20 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
void OAddTableDlg::impl_switchTo( ObjectList _eList )
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2006-07-10 14:25:35 +00:00
|
|
|
switch ( _eList )
|
2001-08-24 05:40:35 +00:00
|
|
|
{
|
2006-07-10 14:25:35 +00:00
|
|
|
case Tables:
|
2014-02-21 12:53:51 +01:00
|
|
|
m_pTableList->Show( true ); m_pCaseTables->Check( true );
|
|
|
|
m_pQueryList->Show( false ); m_pCaseQueries->Check( false );
|
2014-02-10 15:28:03 +00:00
|
|
|
m_xCurrentList.reset( new TableListFacade( *m_pTableList, m_rContext.getConnection() ) );
|
|
|
|
m_pTableList->GrabFocus();
|
2006-07-10 14:25:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Queries:
|
2014-02-21 12:53:51 +01:00
|
|
|
m_pTableList->Show( false ); m_pCaseTables->Check( false );
|
|
|
|
m_pQueryList->Show( true ); m_pCaseQueries->Check( true );
|
2014-02-10 15:28:03 +00:00
|
|
|
m_xCurrentList.reset( new QueryListFacade( *m_pQueryList, m_rContext.getConnection() ) );
|
|
|
|
m_pQueryList->GrabFocus();
|
2006-07-10 14:25:35 +00:00
|
|
|
break;
|
2001-08-24 05:40:35 +00:00
|
|
|
}
|
2014-02-10 15:28:03 +00:00
|
|
|
m_xCurrentList->updateTableObjectList( m_rContext.allowViews() );
|
2006-07-10 14:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OAddTableDlg::Update()
|
|
|
|
{
|
2014-02-10 15:28:03 +00:00
|
|
|
if ( !m_xCurrentList.get() )
|
2006-07-10 14:25:35 +00:00
|
|
|
impl_switchTo( Tables );
|
|
|
|
else
|
2014-02-10 15:28:03 +00:00
|
|
|
m_xCurrentList->updateTableObjectList( m_rContext.allowViews() );
|
2001-02-05 08:15:20 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
void OAddTableDlg::impl_addTable()
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2014-02-10 15:28:03 +00:00
|
|
|
if ( m_xCurrentList->isLeafSelected() )
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString sSelectedName, sAliasName;
|
2014-02-10 15:28:03 +00:00
|
|
|
sSelectedName = m_xCurrentList->getSelectedName( sAliasName );
|
2001-02-05 08:15:20 +00:00
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
m_rContext.addTableWindow( sSelectedName, sAliasName );
|
2001-02-05 08:15:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-20 02:05:39 +00:00
|
|
|
IMPL_LINK( OAddTableDlg, AddClickHdl, Button*, /*pButton*/ )
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2002-02-11 12:02:08 +00:00
|
|
|
TableListDoubleClickHdl(NULL);
|
2001-02-05 08:15:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-10 11:24:40 +02:00
|
|
|
IMPL_LINK_NOARG( OAddTableDlg, TableListDoubleClickHdl )
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2006-07-10 14:25:35 +00:00
|
|
|
if ( impl_isAddAllowed() )
|
2006-12-01 16:30:50 +00:00
|
|
|
{
|
2006-07-10 14:25:35 +00:00
|
|
|
impl_addTable();
|
2006-12-01 16:30:50 +00:00
|
|
|
if ( !impl_isAddAllowed() )
|
|
|
|
Close();
|
|
|
|
return 1L; // handled
|
|
|
|
}
|
2001-02-05 08:15:20 +00:00
|
|
|
|
2006-12-01 16:30:50 +00:00
|
|
|
return 0L; // not handled
|
2001-02-05 08:15:20 +00:00
|
|
|
}
|
2006-07-10 14:25:35 +00:00
|
|
|
|
2015-05-10 11:24:40 +02:00
|
|
|
IMPL_LINK_NOARG( OAddTableDlg, TableListSelectHdl )
|
2002-12-03 11:28:03 +00:00
|
|
|
{
|
2014-02-10 15:28:03 +00:00
|
|
|
m_pAddButton->Enable( m_xCurrentList->isLeafSelected() );
|
2002-12-03 11:28:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-07-10 14:25:35 +00:00
|
|
|
|
2006-06-20 02:05:39 +00:00
|
|
|
IMPL_LINK( OAddTableDlg, CloseClickHdl, Button*, /*pButton*/ )
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
return int(Close());
|
2001-02-05 08:15:20 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 11:24:40 +02:00
|
|
|
IMPL_LINK_NOARG( OAddTableDlg, OnTypeSelected )
|
2006-07-10 14:25:35 +00:00
|
|
|
{
|
2014-02-10 15:28:03 +00:00
|
|
|
if ( m_pCaseTables->IsChecked() )
|
2006-07-10 14:25:35 +00:00
|
|
|
impl_switchTo( Tables );
|
|
|
|
else
|
|
|
|
impl_switchTo( Queries );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
bool OAddTableDlg::Close()
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2006-07-10 14:25:35 +00:00
|
|
|
m_rContext.onWindowClosing( this );
|
2001-02-05 08:15:20 +00:00
|
|
|
return ModelessDialog::Close();
|
|
|
|
}
|
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
bool OAddTableDlg::impl_isAddAllowed()
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2006-07-10 14:25:35 +00:00
|
|
|
return m_rContext.allowAddition();
|
2001-02-05 08:15:20 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString OAddTableDlg::getDialogTitleForContext( IAddTableDialogContext& _rContext )
|
2001-02-05 08:15:20 +00:00
|
|
|
{
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString sTitle;
|
2001-02-05 08:15:20 +00:00
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
if ( _rContext.allowQueries() )
|
2013-09-26 12:17:53 +02:00
|
|
|
sTitle = ModuleRes( STR_ADD_TABLE_OR_QUERY );
|
2006-07-10 14:25:35 +00:00
|
|
|
else
|
2013-09-26 12:17:53 +02:00
|
|
|
sTitle = ModuleRes( STR_ADD_TABLES );
|
2002-07-11 07:54:04 +00:00
|
|
|
|
2006-07-10 14:25:35 +00:00
|
|
|
return sTitle;
|
2001-02-05 08:15:20 +00:00
|
|
|
}
|
2006-07-10 14:25:35 +00:00
|
|
|
|
2010-10-12 15:59:03 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|