Line data Source code
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 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_ADTABDLG_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_ADTABDLG_HXX
21 :
22 : #include <boost/scoped_ptr.hpp>
23 : #include <com/sun/star/sdbc/XConnection.hpp>
24 : #include <vcl/dialog.hxx>
25 : #include <vcl/button.hxx>
26 : #include <vcl/fixed.hxx>
27 : #include <vcl/lstbox.hxx>
28 : #include "tabletree.hxx"
29 :
30 : namespace dbaui
31 : {
32 : /** unifies the access to a list of table/query objects
33 : */
34 0 : class TableObjectListFacade
35 : {
36 : public:
37 : virtual void updateTableObjectList( bool _bAllowViews ) = 0;
38 : virtual OUString getSelectedName( OUString& _out_rAliasName ) const = 0;
39 : virtual bool isLeafSelected() const = 0;
40 :
41 : virtual ~TableObjectListFacade();
42 : };
43 :
44 0 : class IAddTableDialogContext
45 : {
46 : public:
47 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
48 : getConnection() const = 0;
49 : virtual bool allowViews() const = 0;
50 : virtual bool allowQueries() const = 0;
51 : virtual bool allowAddition() const = 0;
52 : virtual void addTableWindow( const OUString& _rQualifiedTableName, const OUString& _rAliasName ) = 0;
53 : virtual void onWindowClosing( const Window* _pWindow ) = 0;
54 :
55 : protected:
56 0 : ~IAddTableDialogContext() {}
57 : };
58 :
59 : class OAddTableDlg : public ModelessDialog
60 : {
61 : RadioButton* m_pCaseTables;
62 : RadioButton* m_pCaseQueries;
63 :
64 : OTableTreeListBox* m_pTableList;
65 : SvTreeListBox* m_pQueryList;
66 : boost::scoped_ptr< TableObjectListFacade > m_xCurrentList;
67 :
68 : PushButton* m_pAddButton;
69 : PushButton* m_pCloseButton;
70 :
71 : IAddTableDialogContext& m_rContext;
72 :
73 : DECL_LINK( AddClickHdl, Button* );
74 : DECL_LINK( CloseClickHdl, Button* );
75 : DECL_LINK( TableListDoubleClickHdl, void* );
76 : DECL_LINK( TableListSelectHdl, void* );
77 : DECL_LINK( OnTypeSelected, void* );
78 :
79 : public:
80 : OAddTableDlg(
81 : Window* _pParent,
82 : IAddTableDialogContext& _rContext );
83 : virtual ~OAddTableDlg();
84 :
85 : void DetermineAddTable() { m_pAddButton->Enable( impl_isAddAllowed() ); }
86 : void Update();
87 :
88 : static OUString getDialogTitleForContext(
89 : IAddTableDialogContext& _rContext );
90 :
91 : private:
92 : virtual bool Close() SAL_OVERRIDE;
93 :
94 : bool impl_isAddAllowed();
95 : void impl_addTable();
96 :
97 : enum ObjectList
98 : {
99 : Tables,
100 : Queries
101 : };
102 : void impl_switchTo( ObjectList _eList );
103 : };
104 : }
105 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_ADTABDLG_HXX
106 :
107 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|