22#include <core_resource.hxx>
25#include <com/sun/star/container/XContainer.hpp>
26#include <com/sun/star/sdb/application/DatabaseObject.hpp>
27#include <com/sun/star/sdb/XQueriesSupplier.hpp>
28#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
29#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
30#include <com/sun/star/container/XNameAccess.hpp>
46TableObjectListFacade::~TableObjectListFacade()
65 ,m_rTableList( _rTableList )
70 virtual ~TableListFacade()
override;
73 virtual void updateTableObjectList(
bool _bAllowViews )
override;
74 virtual OUString getSelectedName( OUString& _out_rAliasName )
const override;
75 virtual bool isLeafSelected()
const override;
77 virtual void _elementInserted(
const css::container::ContainerEvent& _rEvent )
override;
78 virtual void _elementRemoved(
const css::container::ContainerEvent& _rEvent )
override;
79 virtual void _elementReplaced(
const css::container::ContainerEvent& _rEvent )
override;
84TableListFacade::~TableListFacade()
86 if ( m_pContainerListener.is() )
87 m_pContainerListener->dispose();
90OUString TableListFacade::getSelectedName( OUString& _out_rAliasName )
const
93 std::unique_ptr<weld::TreeIter> xEntry(rTableList.
make_iterator());
98 OUString aCatalog, aSchema, aTableName;
99 std::unique_ptr<weld::TreeIter> xSchema(rTableList.
make_iterator(xEntry.get()));
102 auto xAll = m_rTableList.getAllObjectsEntry();
103 if (!xAll || !xSchema->equal(*xAll))
105 std::unique_ptr<weld::TreeIter> xCatalog(rTableList.
make_iterator(xSchema.get()));
108 if (!xAll || !xCatalog->equal(*xAll))
109 aCatalog = rTableList.
get_text(*xCatalog, 0);
111 aSchema = rTableList.
get_text(*xSchema, 0);
114 aTableName = rTableList.
get_text(*xEntry, 0);
116 OUString aComposedName;
120 if ( aCatalog.isEmpty()
121 && !aSchema.isEmpty()
122 && xMeta->supportsCatalogsInDataManipulation()
123 && !xMeta->supportsSchemasInDataManipulation() )
129 aComposedName = ::dbtools::composeTableName(
130 xMeta, aCatalog, aSchema, aTableName,
false, ::dbtools::EComposeRule::InDataManipulation );
132 catch (
const Exception& )
137 _out_rAliasName = aTableName;
138 return aComposedName;
141void TableListFacade::_elementInserted(
const container::ContainerEvent& )
143 updateTableObjectList(m_bAllowViews);
146void TableListFacade::_elementRemoved(
const container::ContainerEvent& )
148 updateTableObjectList(m_bAllowViews);
151void TableListFacade::_elementReplaced(
const container::ContainerEvent& )
155void TableListFacade::updateTableObjectList(
bool _bAllowViews )
157 m_bAllowViews = _bAllowViews;
168 xTables = xTableSupp->getTables();
171 if ( !m_pContainerListener.is() )
174 if ( xContainer.is() )
175 m_pContainerListener = new ::comphelper::OContainerListenerAdapter(
this,xContainer);
177 sTables = xTables->getElementNames();
180 xViewSupp.set( xTableSupp, UNO_QUERY );
181 if ( xViewSupp.is() )
183 xViews = xViewSupp->getViews();
185 sViews = xViews->getElementNames();
191 const OUString* pTableBegin = sTables.getConstArray();
192 const OUString* pTableEnd = pTableBegin + sTables.getLength();
193 std::vector< OUString > aTables(pTableBegin,pTableEnd);
195 const OUString* pViewBegin = sViews.getConstArray();
196 const OUString* pViewEnd = pViewBegin + sViews.getLength();
198 for(;pViewBegin != pViewEnd;++pViewBegin)
199 aTables.erase(std::remove_if(aTables.begin(),aTables.end(),
200 [&aEqualFunctor, pViewBegin](
const OUString& lhs)
201 { return aEqualFunctor(lhs, *pViewBegin); } )
207 m_rTableList.UpdateTableList(
m_xConnection, sTables, sViews );
209 std::unique_ptr<weld::TreeIter> xEntry(rTableList.
make_iterator());
217 rTableList.
select(*xEntry);
219 catch(
const Exception& )
225bool TableListFacade::isLeafSelected()
const
228 std::unique_ptr<weld::TreeIter> xEntry(rTableList.
make_iterator());
229 const bool bEntry = rTableList.
get_selected(xEntry.get());
242 m_pContainerListener;
247 ,m_rQueryList( _rQueryList )
251 virtual ~QueryListFacade()
override;
254 virtual void updateTableObjectList(
bool _bAllowViews )
override;
255 virtual OUString getSelectedName( OUString& _out_rAliasName )
const override;
256 virtual bool isLeafSelected()
const override;
258 virtual void _elementInserted(
const css::container::ContainerEvent& _rEvent )
override;
259 virtual void _elementRemoved(
const css::container::ContainerEvent& _rEvent )
override;
260 virtual void _elementReplaced(
const css::container::ContainerEvent& _rEvent )
override;
265QueryListFacade::~QueryListFacade()
267 if ( m_pContainerListener.is() )
268 m_pContainerListener->dispose();
271void QueryListFacade::_elementInserted(
const container::ContainerEvent& _rEvent )
274 if ( _rEvent.Accessor >>=
sName )
277 m_rQueryList.append(
"",
sName, aQueryImage);
281void QueryListFacade::_elementRemoved(
const container::ContainerEvent& )
283 updateTableObjectList(
true);
286void QueryListFacade::_elementReplaced(
const container::ContainerEvent& )
290void QueryListFacade::updateTableObjectList(
bool )
292 m_rQueryList.clear();
299 if ( !m_pContainerListener.is() )
302 m_pContainerListener = new ::comphelper::OContainerListenerAdapter(
this,xContainer);
306 for (
auto const & name : aQueryNames )
307 m_rQueryList.append(
"", name, aQueryImage);
309 catch(
const Exception& )
315OUString QueryListFacade::getSelectedName( OUString& _out_rAliasName )
const
318 std::unique_ptr<weld::TreeIter> xEntry(m_rQueryList.make_iterator());
319 const bool bEntry = m_rQueryList.get_selected(xEntry.get());
321 sSelected = _out_rAliasName = m_rQueryList.get_text(*xEntry, 0);
325bool QueryListFacade::isLeafSelected()
const
327 std::unique_ptr<weld::TreeIter> xEntry(m_rQueryList.make_iterator());
328 const bool bEntry = m_rQueryList.get_selected(xEntry.get());
329 return bEntry && !m_rQueryList.iter_has_child(*xEntry);
334 : GenericDialogController(pParent,
"dbaccess/ui/tablesjoindialog.ui",
"TablesJoinDialog")
336 , m_xCaseTables(m_xBuilder->weld_radio_button(
"tables"))
337 , m_xCaseQueries(m_xBuilder->weld_radio_button(
"queries"))
339 , m_xTableList(new
OTableTreeListBox(m_xBuilder->weld_tree_view(
"tablelist"), false))
340 , m_xQueryList(m_xBuilder->weld_tree_view(
"querylist"))
341 , m_xAddButton(m_xBuilder->weld_button(
"add"))
342 , m_xCloseButton(m_xBuilder->weld_button(
"close"))
361 m_xQueryList->set_selection_mode(SelectionMode::Single);
407 TableListDoubleClickHdl(m_xTableList->GetWidget());
412 if ( impl_isAddAllowed() )
414 if ( m_xCurrentList->isLeafSelected() )
416 OUString sSelectedName, sAliasName;
417 sSelectedName = m_xCurrentList->getSelectedName( sAliasName );
419 m_rContext.addTableWindow( sSelectedName, sAliasName );
421 if ( !impl_isAddAllowed() )
429 m_xAddButton->set_sensitive( m_xCurrentList->isLeafSelected() );
439 if ( m_xCaseTables->get_active() )
442 impl_switchTo( Queries );
460 sTitle =
DBA_RES( STR_ADD_TABLE_OR_QUERY );
462 sTitle =
DBA_RES( STR_ADD_TABLES );
Reference< XExecutableDialog > m_xDialog
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual css::uno::Reference< css::sdbc::XConnection > getConnection() const =0
virtual void onWindowClosing()=0
virtual bool allowQueries() const =0
virtual bool allowAddition() const =0
virtual bool allowViews() const =0
static OUString getDialogTitleForContext(IAddTableDialogContext const &_rContext)
std::unique_ptr< weld::RadioButton > m_xCaseTables
std::unique_ptr< weld::RadioButton > m_xCaseQueries
std::unique_ptr< weld::Button > m_xCloseButton
IAddTableDialogContext & m_rContext
std::unique_ptr< weld::TreeView > m_xQueryList
std::unique_ptr< weld::Button > m_xAddButton
void impl_switchTo(ObjectList _eList)
virtual ~OAddTableDlg() override
OAddTableDlg(weld::Window *_pParent, IAddTableDialogContext &_rContext)
std::unique_ptr< OTableTreeListBox > m_xTableList
std::unique_ptr< TableObjectListFacade > m_xCurrentList
unifies the access to a list of table/query objects
std::shared_ptr< weld::Dialog > m_xDialog
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual bool get_selected(TreeIter *pIter) const=0
virtual void expand_row(const TreeIter &rIter)=0
void connect_row_activated(const Link< TreeView &, bool > &rLink)
virtual OUString get_text(int row, int col=-1) const=0
virtual void set_selection_mode(SelectionMode eMode)=0
void connect_changed(const Link< TreeView &, void > &rLink)
virtual bool get_iter_first(TreeIter &rIter) const=0
virtual int get_height_rows(int nRows) const=0
virtual void select(int pos)=0
virtual bool iter_parent(TreeIter &rIter) const=0
virtual bool iter_next(TreeIter &rIter) const=0
virtual bool iter_has_child(const TreeIter &rIter) const=0
#define DBG_UNHANDLED_EXCEPTION(...)
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
Reference< XConnection > m_xConnection
const Reference< XComponentContext > & m_rContext