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 vcl::Window* _pWindow ) = 0;
54 :
55 : protected:
56 0 : ~IAddTableDialogContext() {}
57 : };
58 :
59 : class OAddTableDlg : public ModelessDialog
60 : {
61 : VclPtr<RadioButton> m_pCaseTables;
62 : VclPtr<RadioButton> m_pCaseQueries;
63 :
64 : VclPtr<OTableTreeListBox> m_pTableList;
65 : VclPtr<SvTreeListBox> m_pQueryList;
66 : boost::scoped_ptr< TableObjectListFacade > m_xCurrentList;
67 :
68 : VclPtr<PushButton> m_pAddButton;
69 : VclPtr<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 : vcl::Window* _pParent,
82 : IAddTableDialogContext& _rContext );
83 : virtual ~OAddTableDlg();
84 : virtual void dispose() SAL_OVERRIDE;
85 :
86 : void DetermineAddTable() { m_pAddButton->Enable( impl_isAddAllowed() ); }
87 : void Update();
88 :
89 : static OUString getDialogTitleForContext(
90 : IAddTableDialogContext& _rContext );
91 :
92 : private:
93 : virtual bool Close() SAL_OVERRIDE;
94 :
95 : bool impl_isAddAllowed();
96 : void impl_addTable();
97 :
98 : enum ObjectList
99 : {
100 : Tables,
101 : Queries
102 : };
103 : void impl_switchTo( ObjectList _eList );
104 : };
105 : }
106 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_ADTABDLG_HXX
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|