summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/browser
diff options
context:
space:
mode:
authorOcke Janssen <oj@openoffice.org>2001-09-25 12:28:23 +0000
committerOcke Janssen <oj@openoffice.org>2001-09-25 12:28:23 +0000
commitfe6066d957a51186f8578502e6651b55161d9b8f (patch)
tree0848d216d3739bdb287e1d8f77849599bac57627 /dbaccess/source/ui/browser
parent30099daceb5b67e169df1550dc8adf21c97333af (diff)
#91719# implementing the XRename handling
Diffstat (limited to 'dbaccess/source/ui/browser')
-rw-r--r--dbaccess/source/ui/browser/dbtreemodel.hxx9
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.cxx28
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.hxx8
-rw-r--r--dbaccess/source/ui/browser/dsbrowserDnD.cxx181
-rw-r--r--dbaccess/source/ui/browser/sbabrw.src11
-rw-r--r--dbaccess/source/ui/browser/sbagrid.src18
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx69
7 files changed, 239 insertions, 85 deletions
diff --git a/dbaccess/source/ui/browser/dbtreemodel.hxx b/dbaccess/source/ui/browser/dbtreemodel.hxx
index 0875fd848b31..ce3a4dc8f785 100644
--- a/dbaccess/source/ui/browser/dbtreemodel.hxx
+++ b/dbaccess/source/ui/browser/dbtreemodel.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbtreemodel.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: oj $ $Date: 2001-08-15 13:14:59 $
+ * last change: $Author: oj $ $Date: 2001-09-25 13:24:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -92,6 +92,11 @@ namespace com { namespace sun { namespace star { namespace lang { class XMultiSe
namespace dbaui
{
+ struct DBTreeEditedEntry
+ {
+ SvLBoxEntry* pEntry;
+ XubString aNewText;
+ };
//========================================================================
//= DBTreeListModel
//========================================================================
diff --git a/dbaccess/source/ui/browser/dbtreeview.cxx b/dbaccess/source/ui/browser/dbtreeview.cxx
index b0c900e2746b..cf40bb103e76 100644
--- a/dbaccess/source/ui/browser/dbtreeview.cxx
+++ b/dbaccess/source/ui/browser/dbtreeview.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbtreeview.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: fs $ $Date: 2001-09-06 12:40:39 $
+ * last change: $Author: oj $ $Date: 2001-09-25 13:24:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,7 +94,7 @@ DBTreeView::DBTreeView( Window* pParent, const Reference< XMultiServiceFactory >
m_pTreeListBox = new DBTreeListBox(this, _rxORB ,WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT);
m_pTreeListBox->EnableCheckButton(NULL);
m_pTreeListBox->SetDragDropMode( 0 );
- m_pTreeListBox->EnableInplaceEditing( sal_False );
+ m_pTreeListBox->EnableInplaceEditing( sal_True );
m_pTreeListBox->SetHelpId(HID_TLB_TREELISTBOX);
m_pTreeListBox->Show();
}
@@ -169,6 +169,26 @@ Link DBTreeView::getDeleteHandler() const
return m_pTreeListBox->getDeleteHandler();
}
// -----------------------------------------------------------------------------
+void DBTreeView::setEditingHandler(const Link& _rHdl)
+{
+ m_pTreeListBox->setEditingHandler(_rHdl);
+}
+// -----------------------------------------------------------------------------
+Link DBTreeView::getEditingHandler() const
+{
+ return m_pTreeListBox->getEditingHandler();
+}
+// -----------------------------------------------------------------------------
+void DBTreeView::setEditedHandler(const Link& _rHdl)
+{
+ m_pTreeListBox->setEditedHandler(_rHdl);
+}
+// -----------------------------------------------------------------------------
+Link DBTreeView::getEditedHandler() const
+{
+ return m_pTreeListBox->getEditedHandler();
+}
+// -----------------------------------------------------------------------------
void DBTreeView::Resize()
{
Window::Resize();
@@ -204,7 +224,7 @@ void DBTreeView::setSelectHdl(const Link& _rHdl)
long DBTreeView::PreNotify( NotifyEvent& rNEvt )
{
long nDone = 0L;
- if(rNEvt.GetType() == EVENT_GETFOCUS && m_pTreeListBox)
+ if(rNEvt.GetType() == EVENT_GETFOCUS && m_pTreeListBox && !m_pTreeListBox->HasChildPathFocus())
{
m_pTreeListBox->GrabFocus();
nDone = 1L;
diff --git a/dbaccess/source/ui/browser/dbtreeview.hxx b/dbaccess/source/ui/browser/dbtreeview.hxx
index af1979834f04..9ff1549f5efb 100644
--- a/dbaccess/source/ui/browser/dbtreeview.hxx
+++ b/dbaccess/source/ui/browser/dbtreeview.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dbtreeview.hxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: oj $ $Date: 2001-07-18 11:33:57 $
+ * last change: $Author: oj $ $Date: 2001-09-25 13:24:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -109,6 +109,10 @@ namespace dbaui
Link getPasteHandler() const;
void setDeleteHandler(const Link& _rHdl);
Link getDeleteHandler() const;
+ void setEditingHandler(const Link& _rHdl);
+ Link getEditingHandler() const;
+ void setEditedHandler(const Link& _rHdl);
+ Link getEditedHandler() const;
DBTreeListModel* getModel() const;
diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
index 19107812f01b..127446ff5f63 100644
--- a/dbaccess/source/ui/browser/dsbrowserDnD.cxx
+++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dsbrowserDnD.cxx,v $
*
- * $Revision: 1.28 $
+ * $Revision: 1.29 $
*
- * last change: $Author: oj $ $Date: 2001-09-20 12:56:17 $
+ * last change: $Author: oj $ $Date: 2001-09-25 13:24:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,6 +81,9 @@
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#endif
+#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
+#include <com/sun/star/sdbcx/XRename.hpp>
+#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
#endif
@@ -932,6 +935,117 @@ namespace dbaui
return 0;
}
// -----------------------------------------------------------------------------
+ IMPL_LINK(SbaTableQueryBrowser, OnEditingEntry, SvLBoxEntry*, _pEntry)
+ {
+ EntryType eType = getEntryType(_pEntry);
+ long nRet = 0;
+ switch(eType)
+ {
+ case etQuery:
+ case etView:
+ case etTable:
+ try
+ {
+ if(eType == etQuery || isConnectionWriteAble(_pEntry))
+ {
+ ensureObjectExists(_pEntry);
+ DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pEntry->GetUserData());
+ if(pData && pData->xObject.is())
+ {
+ Reference<XRename> xRename(pData->xObject,UNO_QUERY);
+ if(xRename.is())
+ {
+ ::rtl::OUString sName;
+ Reference<XPropertySet> xProp(pData->xObject,UNO_QUERY);
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
+ m_pTreeView->getListBox()->SetEntryText(_pEntry,sName);
+ nRet = 1;
+ }
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(0,"Exception catched!");
+ }
+ break;
+ default:
+ OSL_ENSURE(0,"Try to rename wrong entry!");
+ }
+ return nRet;
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK(SbaTableQueryBrowser, OnEditedEntry, DBTreeEditedEntry*, _aEntry)
+ {
+ EntryType eType = getEntryType(_aEntry->pEntry);
+ ::rtl::OUString sOldName;
+ long nRet = 0;
+ try
+ {
+ switch(eType)
+ {
+ case etView:
+ case etTable:
+ case etQuery:
+ if(etQuery == eType || isConnectionWriteAble(_aEntry->pEntry))
+ {
+ DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_aEntry->pEntry->GetUserData());
+ OSL_ENSURE(pData && pData->xObject.is(),"Error in editing!");
+ if(pData && pData->xObject.is())
+ {
+ ::rtl::OUString sName,sSchema,sCatalog;
+ ::rtl::OUString sNewName = _aEntry->aNewText;
+ Reference<XPropertySet> xProp(pData->xObject,UNO_QUERY);
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
+ Reference<XConnection> xConnection = getConnectionFromEntry(_aEntry->pEntry);
+ Reference<XDatabaseMetaData> xMeta = xConnection.is() ? xConnection->getMetaData() : Reference<XDatabaseMetaData>();
+ if(etQuery == eType)
+ sOldName = sName;
+ else
+ ::dbaui::composeTableName(xMeta,xProp,sOldName,sal_False);
+
+ if((etQuery == eType || (xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers())) ? sName != sNewName : !sNewName.equalsIgnoreAsciiCase(sName))
+ {
+ Reference<XRename> xRename(pData->xObject,UNO_QUERY);
+ OSL_ENSURE(xRename.is(),"No Xrename interface!");
+ if(xRename.is())
+ {
+ xRename->rename(sNewName);
+ nRet = 1;
+ if(etQuery != eType)
+ {// special handling for tables and views
+ xProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
+ xProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog;
+ ::dbtools::composeTableName(xMeta,sCatalog,sSchema,sNewName,sName,sal_False);
+ sOldName = sName;
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ catch(const SQLException& e)
+ {
+ showError(SQLExceptionInfo(e));
+ }
+ catch(const ElementExistException& e)
+ {
+ static ::rtl::OUString sStatus = ::rtl::OUString::createFromAscii("S1000");
+ String sMsg = String(ModuleRes(STR_OBJECT_ALREADY_EXISTS));
+ sMsg.SearchAndReplace('#',e.Message);
+ showError(SQLExceptionInfo(SQLException(sMsg, e.Context, sStatus, 0, Any())));
+ }
+ catch(const Exception& )
+ {
+ OSL_ENSURE(0,"Exception catched!");
+ }
+ _aEntry->aNewText = sOldName;
+
+ return nRet;
+ }
+ // -----------------------------------------------------------------------------
IMPL_LINK(SbaTableQueryBrowser, OnDeleteEntry, SvLBoxEntry*, _pEntry)
{
EntryType eType = getEntryType(_pEntry);
@@ -944,22 +1058,7 @@ namespace dbaui
case etTable:
{
// check if connection is readonly
- DBTreeListModel::DBTreeListUserData* pDSData = NULL;
- DBTreeListModel::DBTreeListUserData* pEntryData = NULL;
- SvLBoxEntry* pDSEntry = NULL;
- pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(_pEntry);
- pDSData = pDSEntry
- ? static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData())
- : NULL;
-
- sal_Bool bIsConnectionWriteAble = sal_False;
- if(pDSData && pDSData->xObject.is())
- {
- Reference<XConnection> xCon(pDSData->xObject,UNO_QUERY);
- if(xCon.is())
- bIsConnectionWriteAble = !xCon->getMetaData()->isReadOnly();
- }
- if(bIsConnectionWriteAble && (eType == etTable || eType == etView))
+ if(isConnectionWriteAble(_pEntry))
implDropTable(_pEntry);
}
break;
@@ -1014,22 +1113,7 @@ namespace dbaui
case etTableContainer:
{
// check if connection is readonly
- DBTreeListModel::DBTreeListUserData* pDSData = NULL;
- DBTreeListModel::DBTreeListUserData* pEntryData = NULL;
- SvLBoxEntry* pDSEntry = NULL;
- pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(_pEntry);
- pDSData = pDSEntry
- ? static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData())
- : NULL;
-
- sal_Bool bIsConnectionWriteAble = sal_False;
- if(pDSData && pDSData->xObject.is())
- {
- Reference<XConnection> xCon(pDSData->xObject,UNO_QUERY);
- if(xCon.is())
- bIsConnectionWriteAble = !xCon->getMetaData()->isReadOnly();
- }
- bAllowed = bIsConnectionWriteAble && ((eType == etTable || eType == etView || eType == etTableContainer) && isTableFormat());
+ bAllowed = isConnectionWriteAble(_pEntry) && isTableFormat();
}
break;
}
@@ -1071,6 +1155,32 @@ namespace dbaui
}
}
// -----------------------------------------------------------------------------
+ Reference<XConnection> SbaTableQueryBrowser::getConnectionFromEntry(SvLBoxEntry* _pEntry) const
+ {
+ DBTreeListModel::DBTreeListUserData* pDSData = NULL;
+ DBTreeListModel::DBTreeListUserData* pEntryData = NULL;
+ SvLBoxEntry* pDSEntry = NULL;
+ pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(_pEntry);
+ pDSData = pDSEntry
+ ? static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData())
+ : NULL;
+
+ sal_Bool bIsConnectionWriteAble = sal_False;
+ Reference<XConnection> xCon;
+ if(pDSData && pDSData->xObject.is())
+ xCon = Reference<XConnection>(pDSData->xObject,UNO_QUERY);
+ return xCon;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool SbaTableQueryBrowser::isConnectionWriteAble(SvLBoxEntry* _pEntry) const
+ {
+ // check if connection is readonly
+ sal_Bool bIsConnectionWriteAble = sal_False;
+ Reference<XConnection> xCon = getConnectionFromEntry(_pEntry);
+ if(xCon.is())
+ bIsConnectionWriteAble = !xCon->getMetaData()->isReadOnly();
+ return bIsConnectionWriteAble;
+ }
// .........................................................................
} // namespace dbaui
// .........................................................................
@@ -1078,6 +1188,9 @@ namespace dbaui
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.28 2001/09/20 12:56:17 oj
+ * #92232# fixes for BIGINT type and new property HELPTEXT
+ *
* Revision 1.27 2001/08/27 06:57:24 oj
* #90015# some speedup's
*
diff --git a/dbaccess/source/ui/browser/sbabrw.src b/dbaccess/source/ui/browser/sbabrw.src
index 7506de800baa..089d2b5dfa0a 100644
--- a/dbaccess/source/ui/browser/sbabrw.src
+++ b/dbaccess/source/ui/browser/sbabrw.src
@@ -2,9 +2,9 @@
*
* $RCSfile: sbabrw.src,v $
*
- * $Revision: 1.56 $
+ * $Revision: 1.57 $
*
- * last change: $Author: kz $ $Date: 2001-09-06 20:18:32 $
+ * last change: $Author: oj $ $Date: 2001-09-25 13:24:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,7 +68,9 @@
#include "browserids.hxx"
#endif
// #include <sfx2/sfx.hrc>
+#ifndef _GLOBLMN_HRC
#include <svx/globlmn.hrc>
+#endif
#ifndef DBAUI_TOOLBOX_HXX
#include "toolbox.hrc"
@@ -806,6 +808,7 @@ Menu MENU_BROWSER_QUERYCONTEXT
{
Separator = TRUE;
};
+ MenuItem { MID_RENAME_ENTRY };
MenuItem
{
MID_QUERY_DROP
@@ -881,6 +884,7 @@ Menu MENU_BROWSER_TABLECONTEXT
Separator = TRUE;
};
MenuItem { MID_DROP_TABLE };
+ MenuItem { MID_RENAME_ENTRY };
MenuItem
{
Identifier = ID_TREE_TABLE_COPY ;
@@ -980,7 +984,8 @@ Menu MENU_BROWSER_VIEWCONTEXT
{
Separator = TRUE;
};
- MenuItem { MID_DBAUI_DROP_VIEW };
+ MenuItem { MID_DBAUI_DROP_VIEW };
+ MenuItem { MID_RENAME_ENTRY };
MenuItem
{
Identifier = ID_TREE_VIEW_COPY ;
diff --git a/dbaccess/source/ui/browser/sbagrid.src b/dbaccess/source/ui/browser/sbagrid.src
index 67df74d832ee..6fa70dc09999 100644
--- a/dbaccess/source/ui/browser/sbagrid.src
+++ b/dbaccess/source/ui/browser/sbagrid.src
@@ -2,9 +2,9 @@
*
* $RCSfile: sbagrid.src,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: rt $ $Date: 2001-08-24 10:59:44 $
+ * last change: $Author: oj $ $Date: 2001-09-25 13:24:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -356,13 +356,9 @@ String STR_VIEW_TITLE
Text[ finnish ] = "Ansicht #";
};
-
-
-
-
-
-
-
-
-
+String STR_OBJECT_ALREADY_EXISTS
+{
+ Text = "Der Name # existiert bereits." ;
+ Text [ ENGLISH ] = "The name # already exists." ;
+};
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index ffc339ecdbe7..b8372e7a80a3 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unodatbr.cxx,v $
*
- * $Revision: 1.108 $
+ * $Revision: 1.109 $
*
- * last change: $Author: oj $ $Date: 2001-09-20 12:56:17 $
+ * last change: $Author: oj $ $Date: 2001-09-25 13:24:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -542,6 +542,8 @@ sal_Bool SbaTableQueryBrowser::Construct(Window* pParent)
m_pTreeView->setCopyHandler(LINK(this, SbaTableQueryBrowser, OnCopyEntry));
m_pTreeView->setPasteHandler(LINK(this, SbaTableQueryBrowser, OnPasteEntry));
m_pTreeView->setDeleteHandler(LINK(this, SbaTableQueryBrowser, OnDeleteEntry));
+ m_pTreeView->setEditingHandler(LINK(this, SbaTableQueryBrowser, OnEditingEntry));
+ m_pTreeView->setEditedHandler(LINK(this, SbaTableQueryBrowser, OnEditedEntry));
m_pTreeView->getListBox()->setControlActionListener(this);
m_pTreeView->SetHelpId(HID_CTL_TREEVIEW);
@@ -3268,32 +3270,7 @@ void SbaTableQueryBrowser::implCreateObject( SvLBoxEntry* _pApplyTo, sal_uInt16
if (pQueryTextItem)
sCurrentObject = static_cast<SvLBoxString*>(pQueryTextItem)->GetText();
- DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pApplyTo->GetUserData());
- if(!pData->xObject.is())
- {
- // the query has not been accessed before -> create it's user data
-
- Reference<XNameAccess> xNameAccess;
- if(ID_EDIT_TABLE == _nAction)
- {
- Reference<XTablesSupplier> xSup(xConnection,UNO_QUERY);
- if(xSup.is())
- xNameAccess = xSup->getTables();
- }
- else
- {
- Reference<XQueriesSupplier> xSup(xConnection,UNO_QUERY);
- if(xSup.is())
- xNameAccess = xSup->getQueries();
- }
-
- SvLBoxItem* pTextItem = _pApplyTo->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
- if (pTextItem)
- sCurrentObject = static_cast<SvLBoxString*>(pTextItem)->GetText();
-
- if(xNameAccess.is() && xNameAccess->hasByName(sCurrentObject)) // remember the table or query object
- xNameAccess->getByName(sCurrentObject) >>= pData->xObject;
- }
+ ensureObjectExists(_pApplyTo);
}
ODesignAccess* pDispatcher = NULL;
@@ -3398,7 +3375,11 @@ void SbaTableQueryBrowser::implRemoveQuery( SvLBoxEntry* _pApplyTo )
}
}
}
-
+// -----------------------------------------------------------------------------
+void SbaTableQueryBrowser::implRenameEntry( SvLBoxEntry* _pApplyTo )
+{
+ m_pTreeView->getListBox()->EditEntry(_pApplyTo);
+}
// -----------------------------------------------------------------------------
void SbaTableQueryBrowser::implDropTable( SvLBoxEntry* _pApplyTo )
{
@@ -3589,6 +3570,7 @@ sal_Bool SbaTableQueryBrowser::requestContextMenu( const CommandEvent& _rEvent )
// 1.3 actions on existing tables
aContextMenu.EnableItem(ID_EDIT_TABLE, etTable == eType && bIsConnectionWriteAble);
aContextMenu.EnableItem(ID_DROP_TABLE, etTable == eType && bIsConnectionWriteAble);
+ aContextMenu.EnableItem(ID_RENAME_ENTRY, etTable == eType && bIsConnectionWriteAble);
aContextMenu.EnableItem(ID_TREE_TABLE_COPY, etTable == eType);
// these have to be disabled if the connection is readonly
if(!bIsConnectionWriteAble)
@@ -3607,6 +3589,7 @@ sal_Bool SbaTableQueryBrowser::requestContextMenu( const CommandEvent& _rEvent )
// 2.3 actions on existing tables
aContextMenu.EnableItem(ID_DROP_VIEW, bIsConnectionWriteAble);
+ aContextMenu.EnableItem(ID_RENAME_ENTRY, bIsConnectionWriteAble);
aContextMenu.EnableItem(ID_TREE_VIEW_COPY, sal_True);
// these have to be disabled if the connection is readonly
@@ -3629,6 +3612,7 @@ sal_Bool SbaTableQueryBrowser::requestContextMenu( const CommandEvent& _rEvent )
aContextMenu.EnableItem(ID_EDIT_QUERY_DESIGN, etQuery == eType);
aContextMenu.EnableItem(ID_DROP_QUERY, etQuery == eType);
aContextMenu.EnableItem(ID_TREE_QUERY_COPY, etQuery == eType);
+ aContextMenu.EnableItem(ID_RENAME_ENTRY, etQuery == eType);
}
break;
@@ -3708,6 +3692,9 @@ sal_Bool SbaTableQueryBrowser::requestContextMenu( const CommandEvent& _rEvent )
case ID_DROP_VIEW:
implDropTable( pEntry );
break;
+ case ID_RENAME_ENTRY:
+ implRenameEntry(pEntry);
+ break;
case ID_TREE_QUERY_COPY:
{
@@ -3901,6 +3888,30 @@ sal_Bool SbaTableQueryBrowser::implGetQuerySignature( ::rtl::OUString& _rCommand
return sal_False;
}
+// -----------------------------------------------------------------------------
+void SbaTableQueryBrowser::ensureObjectExists(SvLBoxEntry* _pApplyTo)
+{
+ // get the name of the object
+ DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pApplyTo->GetUserData());
+ if(!pData->xObject.is())
+ {
+ // the object has not been accessed before -> create it's user data
+ SvLBoxEntry* pEntryParent = m_pTreeView->getListBox()->GetParent(_pApplyTo);
+ DBTreeListModel::DBTreeListUserData* pParentData = static_cast<DBTreeListModel::DBTreeListUserData*>(pEntryParent->GetUserData());
+ if(pParentData && pParentData->xObject.is())
+ {
+ Reference<XNameAccess> xNameAccess(pParentData->xObject,UNO_QUERY);
+
+ ::rtl::OUString sCurrentObject;
+ SvLBoxItem* pTextItem = _pApplyTo->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
+ if (pTextItem)
+ sCurrentObject = static_cast<SvLBoxString*>(pTextItem)->GetText();
+
+ if(xNameAccess.is() && xNameAccess->hasByName(sCurrentObject)) // remember the table or query object
+ xNameAccess->getByName(sCurrentObject) >>= pData->xObject;
+ }
+ }
+}
// .........................................................................
} // namespace dbaui