1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 #pragma once 20 21 #include <memory> 22 #include <com/sun/star/sdbc/XConnection.hpp> 23 #include <vcl/weld.hxx> 24 #include "tabletree.hxx" 25 26 namespace dbaui 27 { 28 /** unifies the access to a list of table/query objects 29 */ 30 class TableObjectListFacade 31 { 32 public: 33 virtual void updateTableObjectList( bool _bAllowViews ) = 0; 34 virtual OUString getSelectedName( OUString& _out_rAliasName ) const = 0; 35 virtual bool isLeafSelected() const = 0; 36 37 virtual ~TableObjectListFacade(); 38 }; 39 40 class IAddTableDialogContext 41 { 42 public: 43 virtual css::uno::Reference< css::sdbc::XConnection > 44 getConnection() const = 0; 45 virtual bool allowViews() const = 0; 46 virtual bool allowQueries() const = 0; 47 virtual bool allowAddition() const = 0; 48 virtual void addTableWindow( const OUString& _rQualifiedTableName, const OUString& _rAliasName ) = 0; 49 virtual void onWindowClosing() = 0; 50 51 protected: ~IAddTableDialogContext()52 ~IAddTableDialogContext() {} 53 }; 54 55 class OAddTableDlg : public weld::GenericDialogController 56 { 57 IAddTableDialogContext& m_rContext; 58 std::unique_ptr< TableObjectListFacade > m_xCurrentList; 59 60 std::unique_ptr<weld::RadioButton> m_xCaseTables; 61 std::unique_ptr<weld::RadioButton> m_xCaseQueries; 62 63 std::unique_ptr<OTableTreeListBox> m_xTableList; 64 std::unique_ptr<weld::TreeView> m_xQueryList; 65 66 std::unique_ptr<weld::Button> m_xAddButton; 67 std::unique_ptr<weld::Button> m_xCloseButton; 68 69 DECL_LINK( AddClickHdl, weld::Button&, void ); 70 DECL_LINK( CloseClickHdl, weld::Button&, void); 71 DECL_LINK( TableListDoubleClickHdl, weld::TreeView&, bool ); 72 DECL_LINK( TableListSelectHdl, weld::TreeView&, void ); 73 DECL_LINK( OnTypeSelected, weld::Toggleable&, void ); 74 75 public: 76 OAddTableDlg(weld::Window* _pParent, 77 IAddTableDialogContext& _rContext); 78 virtual ~OAddTableDlg() override; 79 80 void Update(); 81 void OnClose(); 82 83 static OUString getDialogTitleForContext( 84 IAddTableDialogContext const & _rContext ); 85 86 private: 87 bool impl_isAddAllowed(); 88 89 enum ObjectList 90 { 91 Tables, 92 Queries 93 }; 94 void impl_switchTo( ObjectList _eList ); 95 }; 96 } 97 98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 99