xref: /trunk/main/dbaccess/source/ui/inc/adtabdlg.hxx (revision 2e2212a7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef DBAUI_QYDLGTAB_HXX
24 #define DBAUI_QYDLGTAB_HXX
25 
26 #ifndef _DIALOG_HXX //autogen
27 #include <vcl/dialog.hxx>
28 #endif
29 
30 #ifndef _BUTTON_HXX //autogen
31 #include <vcl/button.hxx>
32 #endif
33 
34 #ifndef _FIXED_HXX //autogen
35 #include <vcl/fixed.hxx>
36 #endif
37 
38 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
39 #include <com/sun/star/sdbc/XConnection.hpp>
40 #endif
41 
42 #ifndef _LSTBOX_HXX //autogen
43 #include <vcl/lstbox.hxx>
44 #endif
45 #ifndef _SV_DIALOG_HXX
46 #include <vcl/dialog.hxx>
47 #endif
48 #ifndef _STRING_HXX //autogen
49 #include <tools/string.hxx>
50 #endif
51 
52 #ifndef _DBAUI_TABLETREE_HXX_
53 #include "tabletree.hxx"
54 #endif
55 
56 #include <memory>
57 
58 namespace dbaui
59 {
60 	//========================================================================
61     /** unifies the access to a list of table/query objects
62     */
63     class TableObjectListFacade
64     {
65     public:
66         virtual void    updateTableObjectList( bool _bAllowViews ) = 0;
67         virtual String  getSelectedName( String& _out_rAliasName ) const = 0;
68         virtual bool    isLeafSelected() const = 0;
69 
70         virtual ~TableObjectListFacade();
71     };
72 
73 	//========================================================================
74     class IAddTableDialogContext
75     {
76     public:
77         virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
78                         getConnection() const = 0;
79         virtual bool    allowViews() const = 0;
80         virtual bool    allowQueries() const = 0;
81         virtual bool    allowAddition() const = 0;
82         virtual void    addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ) = 0;
83         virtual void    onWindowClosing( const Window* _pWindow ) = 0;
84     };
85 
86 	//========================================================================
87 	class OAddTableDlg : public ModelessDialog
88 	{
89         RadioButton         m_aCaseTables;
90         RadioButton         m_aCaseQueries;
91 
92 		OTableTreeListBox	m_aTableList;
93         SvTreeListBox       m_aQueryList;
94         ::std::auto_ptr< TableObjectListFacade >
95                             m_pCurrentList;
96 
97 		PushButton			aAddButton;
98 		CancelButton		aCloseButton;
99 		HelpButton			aHelpButton;
100 
101         IAddTableDialogContext&
102                             m_rContext;
103 
104 		DECL_LINK( AddClickHdl, Button* );
105 		DECL_LINK( CloseClickHdl, Button* );
106 		DECL_LINK( TableListDoubleClickHdl, void* );
107 		DECL_LINK( TableListSelectHdl, void* );
108         DECL_LINK( OnTypeSelected, void* );
109 
110 	public:
111 		OAddTableDlg(
112             Window* _pParent,
113             IAddTableDialogContext& _rContext );
114 		virtual ~OAddTableDlg();
115 
DetermineAddTable()116 		void DetermineAddTable() { aAddButton.Enable( impl_isAddAllowed() ); }
117 		void Update();
118 
119         static  String  getDialogTitleForContext(
120             IAddTableDialogContext& _rContext );
121 
122     private:
123 		virtual sal_Bool Close();
124 
125 		bool impl_isAddAllowed();
126 		void impl_addTable();
127 
128         enum ObjectList
129         {
130             Tables,
131             Queries
132         };
133         void impl_switchTo( ObjectList _eList );
134 	};
135 }
136 #endif // DBAUI_QYDLGTAB_HXX
137