xref: /aoo41x/main/dbaccess/source/ui/inc/adtabdlg.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_QYDLGTAB_HXX
28 #define DBAUI_QYDLGTAB_HXX
29 
30 #ifndef _DIALOG_HXX //autogen
31 #include <vcl/dialog.hxx>
32 #endif
33 
34 #ifndef _BUTTON_HXX //autogen
35 #include <vcl/button.hxx>
36 #endif
37 
38 #ifndef _FIXED_HXX //autogen
39 #include <vcl/fixed.hxx>
40 #endif
41 
42 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
43 #include <com/sun/star/sdbc/XConnection.hpp>
44 #endif
45 
46 #ifndef _LSTBOX_HXX //autogen
47 #include <vcl/lstbox.hxx>
48 #endif
49 #ifndef _SV_DIALOG_HXX
50 #include <vcl/dialog.hxx>
51 #endif
52 #ifndef _STRING_HXX //autogen
53 #include <tools/string.hxx>
54 #endif
55 
56 #ifndef _DBAUI_TABLETREE_HXX_
57 #include "tabletree.hxx"
58 #endif
59 
60 #include <memory>
61 
62 namespace dbaui
63 {
64 	//========================================================================
65     /** unifies the access to a list of table/query objects
66     */
67     class TableObjectListFacade
68     {
69     public:
70         virtual void    updateTableObjectList( bool _bAllowViews ) = 0;
71         virtual String  getSelectedName( String& _out_rAliasName ) const = 0;
72         virtual bool    isLeafSelected() const = 0;
73 
74         virtual ~TableObjectListFacade();
75     };
76 
77 	//========================================================================
78     class IAddTableDialogContext
79     {
80     public:
81         virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
82                         getConnection() const = 0;
83         virtual bool    allowViews() const = 0;
84         virtual bool    allowQueries() const = 0;
85         virtual bool    allowAddition() const = 0;
86         virtual void    addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ) = 0;
87         virtual void    onWindowClosing( const Window* _pWindow ) = 0;
88     };
89 
90 	//========================================================================
91 	class OAddTableDlg : public ModelessDialog
92 	{
93         RadioButton         m_aCaseTables;
94         RadioButton         m_aCaseQueries;
95 
96 		OTableTreeListBox	m_aTableList;
97         SvTreeListBox       m_aQueryList;
98         ::std::auto_ptr< TableObjectListFacade >
99                             m_pCurrentList;
100 
101 		PushButton			aAddButton;
102 		CancelButton		aCloseButton;
103 		HelpButton			aHelpButton;
104 
105         IAddTableDialogContext&
106                             m_rContext;
107 
108 		DECL_LINK( AddClickHdl, Button* );
109 		DECL_LINK( CloseClickHdl, Button* );
110 		DECL_LINK( TableListDoubleClickHdl, void* );
111 		DECL_LINK( TableListSelectHdl, void* );
112         DECL_LINK( OnTypeSelected, void* );
113 
114 	public:
115 		OAddTableDlg(
116             Window* _pParent,
117             IAddTableDialogContext& _rContext );
118 		virtual ~OAddTableDlg();
119 
120 		void DetermineAddTable() { aAddButton.Enable( impl_isAddAllowed() ); }
121 		void Update();
122 
123         static  String  getDialogTitleForContext(
124             IAddTableDialogContext& _rContext );
125 
126     private:
127 		virtual sal_Bool Close();
128 
129 		bool impl_isAddAllowed();
130 		void impl_addTable();
131 
132         enum ObjectList
133         {
134             Tables,
135             Queries
136         };
137         void impl_switchTo( ObjectList _eList );
138 	};
139 }
140 #endif // DBAUI_QYDLGTAB_HXX
141