xref: /trunk/main/dbaccess/source/ui/inc/indexdialog.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _DBAUI_INDEXDIALOG_HXX_
29*cdf0e10cSrcweir #define _DBAUI_INDEXDIALOG_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifndef _SV_DIALOG_HXX
32*cdf0e10cSrcweir #include <vcl/dialog.hxx>
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #ifndef _SV_FIXED_HXX
35*cdf0e10cSrcweir #include <vcl/fixed.hxx>
36*cdf0e10cSrcweir #endif
37*cdf0e10cSrcweir #ifndef _SV_LSTBOX_HXX
38*cdf0e10cSrcweir #include <vcl/lstbox.hxx>
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX
41*cdf0e10cSrcweir #include <vcl/button.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
44*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
45*cdf0e10cSrcweir #endif
46*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
47*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48*cdf0e10cSrcweir #endif
49*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
50*cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
51*cdf0e10cSrcweir #endif
52*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
53*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
54*cdf0e10cSrcweir #endif
55*cdf0e10cSrcweir #ifndef _SV_TOOLBOX_HXX
56*cdf0e10cSrcweir #include <vcl/toolbox.hxx>
57*cdf0e10cSrcweir #endif
58*cdf0e10cSrcweir #ifndef _SVTREEBOX_HXX
59*cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
60*cdf0e10cSrcweir #endif
61*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX
62*cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
63*cdf0e10cSrcweir #endif
64*cdf0e10cSrcweir #ifndef _DBAUI_INDEXES_HXX_
65*cdf0e10cSrcweir #include "indexes.hxx"
66*cdf0e10cSrcweir #endif
67*cdf0e10cSrcweir #ifndef DBAUI_TOOLBOXHELPER_HXX
68*cdf0e10cSrcweir #include "ToolBoxHelper.hxx"
69*cdf0e10cSrcweir #endif
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir //......................................................................
72*cdf0e10cSrcweir namespace dbaui
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir //......................................................................
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     //==================================================================
77*cdf0e10cSrcweir     //= DbaIndexList
78*cdf0e10cSrcweir     //==================================================================
79*cdf0e10cSrcweir     class DbaIndexList : public SvTreeListBox
80*cdf0e10cSrcweir     {
81*cdf0e10cSrcweir     protected:
82*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
83*cdf0e10cSrcweir         Link        m_aSelectHdl;
84*cdf0e10cSrcweir         Link        m_aEndEditHdl;
85*cdf0e10cSrcweir         sal_Bool    m_bSuspendSelectHdl;
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     public:
88*cdf0e10cSrcweir         DbaIndexList(Window* _pParent, const ResId& _rId);
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir         void SetSelectHdl(const Link& _rHdl) { m_aSelectHdl = _rHdl; }
91*cdf0e10cSrcweir         Link GetSelectHdl() const { return m_aSelectHdl; }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir         void SetEndEditHdl(const Link& _rHdl) { m_aEndEditHdl = _rHdl; }
94*cdf0e10cSrcweir         Link GetEndEditHdl() const { return m_aEndEditHdl; }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir         virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect );
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir         void enableSelectHandler();
99*cdf0e10cSrcweir         void disableSelectHandler();
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir         void SelectNoHandlerCall( SvLBoxEntry* pEntry );
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir         inline void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection)
104*cdf0e10cSrcweir         {
105*cdf0e10cSrcweir              m_xConnection = _rxConnection;
106*cdf0e10cSrcweir         }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     protected:
109*cdf0e10cSrcweir         virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     private:
112*cdf0e10cSrcweir         using SvTreeListBox::Select;
113*cdf0e10cSrcweir     };
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     //==================================================================
116*cdf0e10cSrcweir     //= DbaIndexDialog
117*cdf0e10cSrcweir     //==================================================================
118*cdf0e10cSrcweir     class IndexFieldsControl;
119*cdf0e10cSrcweir     class OIndexCollection;
120*cdf0e10cSrcweir     class DbaIndexDialog :  public ModalDialog,
121*cdf0e10cSrcweir                             public OToolBoxHelper
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir     protected:
124*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
125*cdf0e10cSrcweir         SvtViewOptions          m_aGeometrySettings;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir         ToolBox                 m_aActions;
128*cdf0e10cSrcweir         DbaIndexList            m_aIndexes;
129*cdf0e10cSrcweir         FixedLine               m_aIndexDetails;
130*cdf0e10cSrcweir         FixedText               m_aDescriptionLabel;
131*cdf0e10cSrcweir         FixedText               m_aDescription;
132*cdf0e10cSrcweir         CheckBox                m_aUnique;
133*cdf0e10cSrcweir         FixedText               m_aFieldsLabel;
134*cdf0e10cSrcweir         IndexFieldsControl*     m_pFields;
135*cdf0e10cSrcweir         PushButton              m_aClose;
136*cdf0e10cSrcweir         HelpButton              m_aHelp;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         OIndexCollection*       m_pIndexes;
139*cdf0e10cSrcweir         SvLBoxEntry*            m_pPreviousSelection;
140*cdf0e10cSrcweir         sal_Bool                m_bEditAgain;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
143*cdf0e10cSrcweir                                 m_xORB;
144*cdf0e10cSrcweir     public:
145*cdf0e10cSrcweir         DbaIndexDialog(
146*cdf0e10cSrcweir             Window* _pParent,
147*cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rFieldNames,
148*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes,
149*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
150*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
151*cdf0e10cSrcweir             sal_Int32 _nMaxColumnsInIndex
152*cdf0e10cSrcweir             );
153*cdf0e10cSrcweir         virtual ~DbaIndexDialog();
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir         virtual void StateChanged( StateChangedType nStateChange );
156*cdf0e10cSrcweir         virtual void DataChanged( const DataChangedEvent& rDCEvt );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         /** will be called whenthe id of the image list is needed.
159*cdf0e10cSrcweir             @param  _eBitmapSet
160*cdf0e10cSrcweir                 <svtools/imgdef.hxx>
161*cdf0e10cSrcweir             @param  _bHiContast
162*cdf0e10cSrcweir                 <TRUE/> when in high contrast mode.
163*cdf0e10cSrcweir         */
164*cdf0e10cSrcweir         virtual ImageList getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const;
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir         /** will be called when the controls need to be resized.
167*cdf0e10cSrcweir         */
168*cdf0e10cSrcweir         virtual void resizeControls(const Size& _rDiff);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     protected:
171*cdf0e10cSrcweir         void fillIndexList();
172*cdf0e10cSrcweir         void updateToolbox();
173*cdf0e10cSrcweir         void updateControls(const SvLBoxEntry* _pEntry);
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     protected:
176*cdf0e10cSrcweir         DECL_LINK( OnIndexSelected, DbaIndexList* );
177*cdf0e10cSrcweir         DECL_LINK( OnIndexAction, ToolBox* );
178*cdf0e10cSrcweir         DECL_LINK( OnEntryEdited, SvLBoxEntry* );
179*cdf0e10cSrcweir         DECL_LINK( OnModified, void* );
180*cdf0e10cSrcweir         DECL_LINK( OnCloseDialog, void* );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir         DECL_LINK( OnEditIndexAgain, SvLBoxEntry* );
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     private:
185*cdf0e10cSrcweir         void OnNewIndex();
186*cdf0e10cSrcweir         void OnDropIndex(sal_Bool _bConfirm = sal_True);
187*cdf0e10cSrcweir         void OnRenameIndex();
188*cdf0e10cSrcweir         void OnSaveIndex();
189*cdf0e10cSrcweir         void OnResetIndex();
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir         sal_Bool implCommit(SvLBoxEntry* _pEntry);
192*cdf0e10cSrcweir         sal_Bool implSaveModified(sal_Bool _bPlausibility = sal_True);
193*cdf0e10cSrcweir         sal_Bool implCommitPreviouslySelected();
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         sal_Bool implDropIndex(SvLBoxEntry* _pEntry, sal_Bool _bRemoveFromCollection);
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir         sal_Bool implCheckPlausibility(const ConstIndexesIterator& _rPos);
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir         /** checks if the controls have to be replaced and moved.
200*cdf0e10cSrcweir         */
201*cdf0e10cSrcweir         void checkControls();
202*cdf0e10cSrcweir     };
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir //......................................................................
205*cdf0e10cSrcweir }   // namespace dbaui
206*cdf0e10cSrcweir //......................................................................
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir #endif // _DBAUI_INDEXDIALOG_HXX_
209*cdf0e10cSrcweir 
210