summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/control/tabletree.cxx
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-02-16 07:31:09 +0000
committerOliver Bolte <obo@openoffice.org>2009-02-16 07:31:09 +0000
commitb5345a6f8629478c9e543c494063bfec51ddbf74 (patch)
treec95338ebbc74ec5f2472a815b3d2f876134d81bb /dbaccess/source/ui/control/tabletree.cxx
parentcaa3bf5c34c08e5e93a03deb3064792139f030bb (diff)
CWS-TOOLING: integrate CWS mysql1
2009-01-29 13:25:23 +0100 fs r267126 : #i98559# 2009-01-29 10:29:23 +0100 fs r267100 : #i98559# 2009-01-29 09:56:20 +0100 fs r267098 : do not display empty schematas in the table list in the query designer 2009-01-29 09:40:28 +0100 fs r267097 : corrected acceptsURL 2009-01-28 11:17:42 +0100 fs r267042 : display empty catalogs/schemas, if indicated by the connection settings 2009-01-28 11:14:30 +0100 fs r267040 : +displayEmptyTableFolders 2009-01-28 11:03:28 +0100 fs r267036 : mysql:mysqlc, not mysql:mysql, for the native driver 2009-01-28 10:23:53 +0100 fs r267031 : select the first catalog/schema, if the guess for the current one did not match 2009-01-28 10:22:23 +0100 fs r267030 : select the first catalog/schema, if the guess for the current one did not match 2009-01-27 15:03:29 +0100 fs r266996 : #i10000# 2009-01-27 14:56:13 +0100 fs r266992 : #i20563# better (more dedicated) UI for the MySQL native driver's properties 2009-01-27 08:20:24 +0100 oj r266953 : enable sdbcx mysql driver for mysqlc 2009-01-27 08:20:09 +0100 oj r266952 : enable sdbcx mysql driver for mysqlc
Diffstat (limited to 'dbaccess/source/ui/control/tabletree.cxx')
-rw-r--r--dbaccess/source/ui/control/tabletree.cxx73
1 files changed, 63 insertions, 10 deletions
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
index 2f469a948b64..43a5728411ee 100644
--- a/dbaccess/source/ui/control/tabletree.cxx
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -97,6 +97,8 @@
#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif
+#include <connectivity/dbmetadata.hxx>
+
#include <algorithm>
//.........................................................................
@@ -126,6 +128,7 @@ OTableTreeListBox::OTableTreeListBox( Window* pParent, const Reference< XMultiSe
:OMarkableTreeListBox(pParent,_rxORB,nWinStyle)
,m_pImageProvider( new ImageProvider )
,m_bVirtualRoot(_bVirtualRoot)
+ ,m_bNoEmptyFolders( false )
{
implSetDefaultImages();
}
@@ -134,6 +137,7 @@ OTableTreeListBox::OTableTreeListBox( Window* pParent, const Reference< XMultiSe
:OMarkableTreeListBox(pParent,_rxORB,rResId)
,m_pImageProvider( new ImageProvider )
,m_bVirtualRoot(_bVirtualRoot)
+ ,m_bNoEmptyFolders( false )
{
implSetDefaultImages();
}
@@ -302,6 +306,26 @@ void OTableTreeListBox::UpdateTableList(
}
UpdateTableList( _rxConnection, aTables );
}
+
+//------------------------------------------------------------------------
+namespace
+{
+ ::std::vector< ::rtl::OUString > lcl_getMetaDataStrings_throw( const Reference< XResultSet >& _rxMetaDataResult, sal_Int32 _nColumnIndex )
+ {
+ ::std::vector< ::rtl::OUString > aStrings;
+ Reference< XRow > xRow( _rxMetaDataResult, UNO_QUERY_THROW );
+ while ( _rxMetaDataResult->next() )
+ aStrings.push_back( xRow->getString( _nColumnIndex ) );
+ return aStrings;
+ }
+
+ bool lcl_shouldDisplayEmptySchemasAndCatalogs( const Reference< XConnection >& _rxConnection )
+ {
+ ::dbtools::DatabaseMetaData aMetaData( _rxConnection );
+ return aMetaData.displayEmptyTableFolders();
+ }
+}
+
//------------------------------------------------------------------------
void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection, const TNames& _rTables )
{
@@ -349,6 +373,35 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn
sal_False
);
}
+
+ if ( !m_bNoEmptyFolders && lcl_shouldDisplayEmptySchemasAndCatalogs( _rxConnection ) )
+ {
+ sal_Bool bSupportsCatalogs = xMeta->supportsCatalogsInDataManipulation();
+ sal_Bool bSupportsSchemas = xMeta->supportsSchemasInDataManipulation();
+
+ if ( bSupportsCatalogs || bSupportsSchemas )
+ {
+ // we display empty catalogs if the DB supports catalogs, and they're noted at the beginning of a
+ // composed name. Otherwise, we display empty schematas. (also see the tree structure explained in
+ // implAddEntry)
+ bool bCatalogs = bSupportsCatalogs && xMeta->isCatalogAtStart();
+
+ ::std::vector< ::rtl::OUString > aFolderNames( lcl_getMetaDataStrings_throw(
+ bCatalogs ? xMeta->getCatalogs() : xMeta->getSchemas(), 1 ) );
+ sal_Int32 nFolderType = bCatalogs ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
+
+ SvLBoxEntry* pRootEntry = getAllObjectsEntry();
+ for ( ::std::vector< ::rtl::OUString >::const_iterator folder = aFolderNames.begin();
+ folder != aFolderNames.end();
+ ++folder
+ )
+ {
+ SvLBoxEntry* pFolder = GetEntryPosByName( *folder, pRootEntry );
+ if ( !pFolder )
+ pFolder = InsertEntry( *folder, pRootEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nFolderType ) );
+ }
+ }
+ }
}
catch ( const Exception& )
{
@@ -474,24 +527,24 @@ SvLBoxEntry* OTableTreeListBox::implAddEntry(
// +- catalog
// +- table
sal_Bool bCatalogAtStart = _rxMeta->isCatalogAtStart();
- ::rtl::OUString& nFirstName = bCatalogAtStart ? sCatalog : sSchema;
- sal_Int32 nFirstFolderType = bCatalogAtStart ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
- ::rtl::OUString& nSecondName = bCatalogAtStart ? sSchema : sCatalog;
- sal_Int32 nSecondFolderType = bCatalogAtStart ? DatabaseObjectContainer::SCHEMA : DatabaseObjectContainer::CATALOG;
+ const ::rtl::OUString& rFirstName = bCatalogAtStart ? sCatalog : sSchema;
+ const sal_Int32 nFirstFolderType = bCatalogAtStart ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
+ const ::rtl::OUString& rSecondName = bCatalogAtStart ? sSchema : sCatalog;
+ const sal_Int32 nSecondFolderType = bCatalogAtStart ? DatabaseObjectContainer::SCHEMA : DatabaseObjectContainer::CATALOG;
- if ( nFirstName.getLength() )
+ if ( rFirstName.getLength() )
{
- SvLBoxEntry* pFolder = GetEntryPosByName( nFirstName, pParentEntry );
+ SvLBoxEntry* pFolder = GetEntryPosByName( rFirstName, pParentEntry );
if ( !pFolder )
- pFolder = InsertEntry( nFirstName, pParentEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nFirstFolderType ) );
+ pFolder = InsertEntry( rFirstName, pParentEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nFirstFolderType ) );
pParentEntry = pFolder;
}
- if ( nSecondName.getLength() )
+ if ( rSecondName.getLength() )
{
- SvLBoxEntry* pFolder = GetEntryPosByName( nSecondName, pParentEntry );
+ SvLBoxEntry* pFolder = GetEntryPosByName( rSecondName, pParentEntry );
if ( !pFolder )
- pFolder = InsertEntry( nSecondName, pParentEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nSecondFolderType ) );
+ pFolder = InsertEntry( rSecondName, pParentEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nSecondFolderType ) );
pParentEntry = pFolder;
}