show views the correct way
This commit is contained in:
parent
543dd861ed
commit
f5d066f68f
2 changed files with 70 additions and 34 deletions
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: unodatbr.cxx,v $
|
||||
*
|
||||
* $Revision: 1.45 $
|
||||
* $Revision: 1.46 $
|
||||
*
|
||||
* last change: $Author: fs $ $Date: 2001-03-23 10:57:10 $
|
||||
* last change: $Author: oj $ $Date: 2001-03-29 07:09:53 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -1430,7 +1430,7 @@ void SbaTableQueryBrowser::initializeTreeModel()
|
|||
sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAccess, SvLBoxEntry* _pParent, const Image& _rImage)
|
||||
{
|
||||
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pParent->GetUserData());
|
||||
if(pData)
|
||||
if(pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables
|
||||
pData->xObject = _xNameAccess;
|
||||
|
||||
try
|
||||
|
@ -1439,7 +1439,8 @@ sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xName
|
|||
const ::rtl::OUString* pBegin = aNames.getConstArray();
|
||||
const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
|
||||
for (; pBegin != pEnd; ++pBegin)
|
||||
m_pTreeView->getListBox()->InsertEntry(*pBegin, _rImage, _rImage, _pParent, sal_False);
|
||||
if(!m_pTreeView->getListBox()->GetEntryPosByName(*pBegin,_pParent))
|
||||
m_pTreeView->getListBox()->InsertEntry(*pBegin, _rImage, _rImage, _pParent, sal_False);
|
||||
}
|
||||
catch(Exception&)
|
||||
{
|
||||
|
@ -1482,17 +1483,9 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent)
|
|||
if (xWarnings.is())
|
||||
xWarnings->clearWarnings();
|
||||
|
||||
Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY);
|
||||
if(xTabSup.is())
|
||||
{
|
||||
Image aImage(ModuleRes(TABLE_TREE_ICON));
|
||||
populateTree(xTabSup->getTables(),_pParent,aImage);
|
||||
Reference<XContainer> xCont(xTabSup->getTables(),UNO_QUERY);
|
||||
if(xCont.is())
|
||||
// add as listener to know when elements are inserted or removed
|
||||
xCont->addContainerListener(this);
|
||||
}
|
||||
|
||||
// first insert the views because the tables can also include
|
||||
// views but that time the bitmap is the wrong one
|
||||
// the nameaccess will be overwriten in populateTree
|
||||
Reference<XViewsSupplier> xViewSup(xConnection,UNO_QUERY);
|
||||
if(xViewSup.is())
|
||||
{
|
||||
|
@ -1504,6 +1497,17 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent)
|
|||
xCont->addContainerListener(this);
|
||||
}
|
||||
|
||||
Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY);
|
||||
if(xTabSup.is())
|
||||
{
|
||||
Image aImage(ModuleRes(TABLE_TREE_ICON));
|
||||
populateTree(xTabSup->getTables(),_pParent,aImage);
|
||||
Reference<XContainer> xCont(xTabSup->getTables(),UNO_QUERY);
|
||||
if(xCont.is())
|
||||
// add as listener to know when elements are inserted or removed
|
||||
xCont->addContainerListener(this);
|
||||
}
|
||||
|
||||
if (xWarnings.is())
|
||||
{
|
||||
SQLExceptionInfo aInfo(xWarnings->getWarnings());
|
||||
|
@ -2626,11 +2630,11 @@ sal_Bool SbaTableQueryBrowser::requestContextMenu( const CommandEvent& _rEvent )
|
|||
aPosition = _rEvent.GetMousePosPixel();
|
||||
// ensure that the entry which the user clicked at is selected
|
||||
pEntry = m_pTreeView->getListBox()->GetEntry(aPosition);
|
||||
if (!pEntry)
|
||||
// no context menu of no entry was hit ....
|
||||
return sal_False;
|
||||
|
||||
OSL_ENSURE(pEntry,"No current entry!");
|
||||
// if (!pEntry)
|
||||
// // no context menu of no entry was hit ....
|
||||
// return sal_False;
|
||||
//
|
||||
// OSL_ENSURE(pEntry,"No current entry!");
|
||||
if (pEntry && !m_pTreeView->getListBox()->IsSelected(pEntry))
|
||||
{
|
||||
pOldSelection = m_pTreeView->getListBox()->FirstSelected();
|
||||
|
@ -2652,11 +2656,15 @@ sal_Bool SbaTableQueryBrowser::requestContextMenu( const CommandEvent& _rEvent )
|
|||
// disable entries according to the currently selected entry
|
||||
|
||||
// does the datasource which the selected entry belongs to has an open connection ?
|
||||
SvLBoxEntry* pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(pEntry);
|
||||
DBTreeListModel::DBTreeListUserData* pDSData =
|
||||
pDSEntry
|
||||
? static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData())
|
||||
: NULL;
|
||||
SvLBoxEntry* pDSEntry = NULL;
|
||||
DBTreeListModel::DBTreeListUserData* pDSData = NULL;
|
||||
if(pEntry)
|
||||
{
|
||||
pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(pEntry);
|
||||
pDSData = pDSEntry
|
||||
? static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData())
|
||||
: NULL;
|
||||
}
|
||||
if (!pDSData || !pDSData->xObject.is())
|
||||
{ // no -> disable the connection-related menu entries
|
||||
aContextMenu.EnableItem(ID_TREE_CLOSE_CONN, sal_False);
|
||||
|
@ -2703,6 +2711,31 @@ sal_Bool SbaTableQueryBrowser::requestContextMenu( const CommandEvent& _rEvent )
|
|||
aContextMenu.EnableItem(ID_TREE_QUERY_DELETE, ET_QUERY == eType);
|
||||
aContextMenu.EnableItem(ID_TREE_QUERY_COPY, ET_QUERY == eType);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1.1 new table / edit relations - available if a table or a table container is selected
|
||||
aContextMenu.EnableItem(ID_TREE_TABLE_CREATE_DESIGN, FALSE);
|
||||
aContextMenu.EnableItem(ID_TREE_RELATION_DESIGN, FALSE);
|
||||
|
||||
// 1.2 pasting tables
|
||||
aContextMenu.EnableItem(ID_TREE_TABLE_PASTE, FALSE);
|
||||
|
||||
// 1.3 actions on existing tables
|
||||
aContextMenu.EnableItem(ID_TREE_TABLE_EDIT, FALSE);
|
||||
aContextMenu.EnableItem(ID_TREE_TABLE_DELETE, FALSE);
|
||||
aContextMenu.EnableItem(ID_TREE_TABLE_COPY, FALSE);
|
||||
|
||||
// 2. for queries
|
||||
|
||||
// 2.1 creating new queries
|
||||
aContextMenu.EnableItem(ID_TREE_QUERY_CREATE_DESIGN, FALSE);
|
||||
aContextMenu.EnableItem(ID_TREE_QUERY_CREATE_TEXT, FALSE);
|
||||
|
||||
// 2.2 actions on existing queries
|
||||
aContextMenu.EnableItem(ID_TREE_QUERY_EDIT, FALSE);
|
||||
aContextMenu.EnableItem(ID_TREE_QUERY_DELETE, FALSE);
|
||||
aContextMenu.EnableItem(ID_TREE_QUERY_COPY, FALSE);
|
||||
}
|
||||
|
||||
// rebuild conn not implemented yet
|
||||
aContextMenu.EnableItem(ID_TREE_REBUILD_CONN, sal_False);
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: tabletree.cxx,v $
|
||||
*
|
||||
* $Revision: 1.9 $
|
||||
* $Revision: 1.10 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2001-02-23 15:16:28 $
|
||||
* last change: $Author: oj $ $Date: 2001-03-29 07:09:53 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -392,17 +392,17 @@ void OTableTreeListBox::UpdateTableList(const Reference< XDatabaseMetaData >& _r
|
|||
SvLBoxEntry* pSchema = NULL;
|
||||
SvLBoxEntry* pParent = pAllObjects;
|
||||
|
||||
// loop through both sequences
|
||||
const ::rtl::OUString* pSwitchSequences = (pTables && pViews) ? pTables + _rTables.getLength() - 1 : NULL;
|
||||
// loop through both sequences first the vies and than the tables
|
||||
const ::rtl::OUString* pSwitchSequences = (pTables && pViews) ? pViews + _rViews.getLength() - 1 : NULL;
|
||||
|
||||
sal_Int32 nOverallLen = _rTables.getLength() + _rViews.getLength();
|
||||
const ::rtl::OUString* pCurrentTable = pTables ? pTables : pViews; // currently handled table or view name
|
||||
sal_Bool bIsView = pTables ? sal_False : sal_True; // pCurrentTable points to a view name ?
|
||||
const ::rtl::OUString* pCurrentTable = pViews ? pViews : pTables; // currently handled view or table name
|
||||
sal_Bool bIsView = pViews ? sal_True : sal_False; // pCurrentTable points to a view name ?
|
||||
for ( sal_Int32 i = 0;
|
||||
i < nOverallLen;
|
||||
++i // inc the counter
|
||||
, ( pSwitchSequences == pCurrentTable // did we reached the last table ?
|
||||
? bIsView = ((pCurrentTable = pViews) != NULL) // yes -> continue with the views, and set bIsView to sal_True
|
||||
? bIsView = !((pCurrentTable = pTables) != NULL) // yes -> continue with the views, and set bIsView to sal_True
|
||||
: ++pCurrentTable != NULL // no -> next table
|
||||
) // (!= NULL is to make this a boolean expression, so it should work under SUNPRO5, too)
|
||||
)
|
||||
|
@ -431,7 +431,8 @@ void OTableTreeListBox::UpdateTableList(const Reference< XDatabaseMetaData >& _r
|
|||
pParent = pSchema;
|
||||
}
|
||||
|
||||
InsertEntry(sName, aImage, aImage, pParent);
|
||||
if(!GetEntryPosByName(sName,pParent)) // only insert a table once
|
||||
InsertEntry(sName, aImage, aImage, pParent);
|
||||
}
|
||||
}
|
||||
catch(RuntimeException&)
|
||||
|
@ -439,7 +440,6 @@ void OTableTreeListBox::UpdateTableList(const Reference< XDatabaseMetaData >& _r
|
|||
DBG_ERROR("OTableTreeListBox::UpdateTableList : caught a RuntimeException!");
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
sal_Bool OTableTreeListBox::isWildcardChecked(SvLBoxEntry* _pEntry) const
|
||||
{
|
||||
|
@ -526,6 +526,9 @@ void OTableTreeListBox::InitEntry(SvLBoxEntry* _pEntry, const XubString& _rStrin
|
|||
/*************************************************************************
|
||||
* history:
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.9 2001/02/23 15:16:28 oj
|
||||
* use namespace
|
||||
*
|
||||
* Revision 1.8 2001/02/05 14:44:53 oj
|
||||
* new member for hiding first entry
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue