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 :
20 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
22 :
23 : #include <vcl/dialog.hxx>
24 : #include <vcl/fixed.hxx>
25 : #include <vcl/lstbox.hxx>
26 : #include <vcl/button.hxx>
27 : #include <com/sun/star/container/XNameAccess.hpp>
28 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 : #include <com/sun/star/sdbc/XConnection.hpp>
30 : #include <com/sun/star/uno/Sequence.hxx>
31 : #include <com/sun/star/uno/XComponentContext.hpp>
32 : #include <vcl/toolbox.hxx>
33 : #include <svtools/treelistbox.hxx>
34 : #include <unotools/viewoptions.hxx>
35 : #include "indexes.hxx"
36 : #include <dbaccess/ToolBoxHelper.hxx>
37 :
38 : namespace dbaui
39 : {
40 :
41 : // DbaIndexList
42 0 : class DbaIndexList : public SvTreeListBox
43 : {
44 : protected:
45 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
46 : Link m_aSelectHdl;
47 : Link m_aEndEditHdl;
48 : bool m_bSuspendSelectHdl;
49 :
50 : public:
51 : DbaIndexList(vcl::Window* _pParent, WinBits nWinBits);
52 :
53 0 : void SetSelectHdl(const Link& _rHdl) { m_aSelectHdl = _rHdl; }
54 : Link GetSelectHdl() const { return m_aSelectHdl; }
55 :
56 0 : void SetEndEditHdl(const Link& _rHdl) { m_aEndEditHdl = _rHdl; }
57 : Link GetEndEditHdl() const { return m_aEndEditHdl; }
58 :
59 : virtual bool Select(SvTreeListEntry* pEntry, bool bSelect) SAL_OVERRIDE;
60 :
61 : void enableSelectHandler();
62 : void disableSelectHandler();
63 :
64 : void SelectNoHandlerCall( SvTreeListEntry* pEntry );
65 :
66 0 : inline void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection)
67 : {
68 0 : m_xConnection = _rxConnection;
69 0 : }
70 :
71 : protected:
72 : virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) SAL_OVERRIDE;
73 :
74 : private:
75 : using SvTreeListBox::Select;
76 : };
77 :
78 : // DbaIndexDialog
79 : class IndexFieldsControl;
80 : class OIndexCollection;
81 : class DbaIndexDialog : public ModalDialog,
82 : public OToolBoxHelper
83 : {
84 : protected:
85 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
86 : SvtViewOptions m_aGeometrySettings;
87 :
88 : ToolBox *m_pActions;
89 : DbaIndexList *m_pIndexList;
90 : FixedText *m_pIndexDetails;
91 : FixedText *m_pDescriptionLabel;
92 : FixedText *m_pDescription;
93 : CheckBox *m_pUnique;
94 : FixedText *m_pFieldsLabel;
95 : IndexFieldsControl *m_pFields;
96 : PushButton *m_pClose;
97 :
98 : OIndexCollection* m_pIndexes;
99 : SvTreeListEntry* m_pPreviousSelection;
100 : bool m_bEditAgain;
101 :
102 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
103 : m_xContext;
104 : public:
105 : DbaIndexDialog(
106 : vcl::Window* _pParent,
107 : const ::com::sun::star::uno::Sequence< OUString >& _rFieldNames,
108 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes,
109 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
110 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
111 : sal_Int32 _nMaxColumnsInIndex
112 : );
113 : virtual ~DbaIndexDialog();
114 :
115 : virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
116 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
117 :
118 : //TO-DO, remove when all other OToolBoxHelper are converted to .ui
119 : virtual void resizeControls(const Size&) SAL_OVERRIDE;
120 :
121 : /** will be called when the id of the image list needs to change
122 : @param _eBitmapSet
123 : <svtools/imgdef.hxx>
124 : */
125 : virtual void setImageList(sal_Int16 _eBitmapSet) SAL_OVERRIDE;
126 : protected:
127 : void fillIndexList();
128 : void updateToolbox();
129 : void updateControls(const SvTreeListEntry* _pEntry);
130 :
131 : protected:
132 : DECL_LINK( OnIndexSelected, DbaIndexList* );
133 : DECL_LINK( OnIndexAction, ToolBox* );
134 : DECL_LINK( OnEntryEdited, SvTreeListEntry* );
135 : DECL_LINK( OnModified, void* );
136 : DECL_LINK( OnCloseDialog, void* );
137 :
138 : DECL_LINK( OnEditIndexAgain, SvTreeListEntry* );
139 :
140 : private:
141 : sal_uInt16 mnNewCmdId;
142 : sal_uInt16 mnDropCmdId;
143 : sal_uInt16 mnRenameCmdId;
144 : sal_uInt16 mnSaveCmdId;
145 : sal_uInt16 mnResetCmdId;
146 :
147 : Image maScNewCmdImg;
148 : Image maScDropCmdImg;
149 : Image maScRenameCmdImg;
150 : Image maScSaveCmdImg;
151 : Image maScResetCmdImg;
152 : Image maLcNewCmdImg;
153 : Image maLcDropCmdImg;
154 : Image maLcRenameCmdImg;
155 : Image maLcSaveCmdImg;
156 : Image maLcResetCmdImg;
157 :
158 : void OnNewIndex();
159 : void OnDropIndex(bool _bConfirm = true);
160 : void OnRenameIndex();
161 : void OnSaveIndex();
162 : void OnResetIndex();
163 :
164 : bool implCommit(SvTreeListEntry* _pEntry);
165 : bool implSaveModified(bool _bPlausibility = true);
166 : bool implCommitPreviouslySelected();
167 :
168 : bool implDropIndex(SvTreeListEntry* _pEntry, bool _bRemoveFromCollection);
169 :
170 : bool implCheckPlausibility(const Indexes::const_iterator& _rPos);
171 :
172 : /** checks if the controls have to be replaced and moved.
173 : */
174 : void checkControls();
175 : };
176 :
177 : } // namespace dbaui
178 :
179 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
180 :
181 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|