summaryrefslogtreecommitdiffstats
path: root/dbaccess/source/ui/dlg/adminpages.hxx
blob: 97b5058b6240822230c36939609c2db71e6f3ad6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
/*************************************************************************
 *
 *  $RCSfile: adminpages.hxx,v $
 *
 *  $Revision: 1.17 $
 *
 *  last change: $Author: fs $ $Date: 2001-01-04 11:21:45 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc..
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _DBAUI_ADMINPAGES_HXX_
#define _DBAUI_ADMINPAGES_HXX_

#ifndef _SFXTABDLG_HXX
#include <sfx2/tabdlg.hxx>
#endif
#ifndef _SV_FIXED_HXX
#include <vcl/fixed.hxx>
#endif
#ifndef _SV_LSTBOX_HXX
#include <vcl/lstbox.hxx>
#endif
#ifndef _SV_EDIT_HXX
#include <vcl/edit.hxx>
#endif
#ifndef _SV_BUTTON_HXX
#include <vcl/imagebtn.hxx>
#endif
#ifndef _SV_GROUP_HXX
#include <vcl/group.hxx>
#endif
#ifndef _SV_COMBOBOX_HXX
#include <vcl/combobox.hxx>
#endif
#ifndef _DBAUI_DSNTYPES_HXX_
#include "dsntypes.hxx"
#endif
#ifndef _DBAUI_CHARSETS_HXX_
#include "charsets.hxx"
#endif
#ifndef _DBAUI_CURLEDIT_HXX_
#include "curledit.hxx"
#endif
#ifndef _DBAUI_TABLETREE_HXX_
#include "tabletree.hxx"
#endif
#ifndef _DBAUI_COMMON_TYPES_HXX_
#include "commontypes.hxx"
#endif
#ifndef _UCBHELPER_CONTENT_HXX
#include <ucbhelper/content.hxx>
#endif

//.........................................................................
namespace dbaui
{
//.........................................................................

//=========================================================================
//= OGenericAdministrationPage
//=========================================================================
class OGenericAdministrationPage : public SfxTabPage
{
protected:
    Link        m_aModifiedHandler;     /// to be called if something on the page has been modified

public:
    OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet);

    /// set a handler which gets called every time something on the page has been modified
    void            SetModifiedHandler(const Link& _rHandler) { m_aModifiedHandler = _rHandler; }

protected:
    /// default implementation: call FillItemSet, call checkItems,
    virtual int DeactivatePage(SfxItemSet* pSet);
    /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
    virtual void Reset(const SfxItemSet& _rCoreAttrs);
    /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_True
    virtual void ActivatePage(const SfxItemSet& _rSet);

protected:
    void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call((void*)this); }

    /// called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_True
    virtual sal_Bool checkItems() { return sal_True; }

    /** called from within Reset and ActivatePage, use to initialize the controls with the items from the given set
        @param      _bSaveValue     if set to sal_True, the implementation should call SaveValue on all relevant controls
    */
    virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue) { }

    /// analyze the invalid and the readonly flag which may be present in the set
    void getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly);

protected:
    /** This link be used for controls where the tabpage does not need to take any special action when the control
        is modified. The implementation just calls callModifiedHdl.
    */
    DECL_LINK(OnControlModified, Control*);

    /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method>
    Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); }
};

//=========================================================================
//= OGeneralPage
//=========================================================================
/**
*/
class OGeneralPage : public OGenericAdministrationPage
{
    OGeneralPage(Window* pParent, const SfxItemSet& _rItems);

private:
    // dialog controls
    FixedText           m_aNameLabel;
    Edit                m_aName;
    GroupBox            m_aTypeBox;
    FixedText           m_aDatasourceTypeLabel;
    ListBox             m_aDatasourceType;
    FixedText           m_aConnectionLabel;
    OConnectionURLEdit  m_aConnection;
    PushButton          m_aBrowseConnection;
//  FixedText           m_aTimeoutLabel;
//  Edit                m_aTimeoutNumber;
//  ListBox             m_aTimeoutUnit;

    FixedText           m_aSpecialMessage;

    ODsnTypeCollection* m_pCollection;  /// the DSN type collection instance
    DECLARE_STL_MAP(DATASOURCE_TYPE, String, ::std::less< DATASOURCE_TYPE >, SelectionHistory);
    DATASOURCE_TYPE     m_eCurrentSelection;    /// currently selected type
    SelectionHistory    m_aSelectionHistory;    /// last selected ConnectURLs for all types

    Link                m_aTypeSelectHandler;   /// to be called if a new type is selected
    Link                m_aNameModifiedHandler; /// to be called whenever the name of the data source is changed by the user

    sal_Bool            m_bDisplayingInvalid : 1;   // the currently displayed data source is deleted

public:
    static SfxTabPage*  Create(Window* pParent, const SfxItemSet& _rAttrSet);

    /// set a handler which gets called every time the user selects a new type
    void            SetTypeSelectHandler(const Link& _rHandler) { m_aTypeSelectHandler = _rHandler; }
    /// get the currently selected datasource type
    DATASOURCE_TYPE GetSelectedType() const { return m_eCurrentSelection; }

    /// set a handler which gets called every time the user changes the data source name
    void            SetNameModifyHandler(const Link& _rHandler) { m_aNameModifiedHandler = _rHandler; }
    /// get the current name the user wants the data source to have
    String          GetCurrentName() const { return m_aName.GetText(); }

protected:
    // SfxTabPage overridables
    virtual BOOL FillItemSet(SfxItemSet& _rCoreAttrs);
    virtual void Reset(const SfxItemSet& _rCoreAttrs);

    virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
    virtual sal_Bool checkItems();

    virtual void GetFocus();

protected:
    void onTypeSelected(DATASOURCE_TYPE _eType);
    void initializeHistory();

    sal_Bool isBrowseable(DATASOURCE_TYPE _eType) const;
    StringBag getInstalledAdabasDBDirs(const String &_rPath,const ::ucb::ResultSetInclude& _reResultSetInclude);
    StringBag getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir);

    DECL_LINK(OnDatasourceTypeSelected, ListBox*);
    DECL_LINK(OnBrowseConnections, PushButton*);
    DECL_LINK(OnNameModified, Edit*);
};


//=========================================================================
//= OCommonBehaviourTabPage
//=========================================================================
#define     CBTP_NONE           0x0000
#define     CBTP_USE_UIDPWD     0x0001
#define     CBTP_USE_CHARSET    0x0002
#define     CBTP_USE_OPTIONS    0x0004

/** eases the implementation of tab pages handling user/password and/or character
    set and/or generic options input
    <BR>
    The controls to be used habe to be defined within the resource, as usual, but
    this class does all the handling necessary.
*/
class OCommonBehaviourTabPage : public OGenericAdministrationPage
{
protected:
    FixedText*          m_pUserNameLabel;
    Edit*               m_pUserName;
    FixedText*          m_pPasswordLabel;
    Edit*               m_pPassword;
    CheckBox*           m_pPasswordRequired;

    FixedText*          m_pOptionsLabel;
    Edit*               m_pOptions;

    FixedText*          m_pCharsetLabel;
    ListBox*            m_pCharset;

    OCharsetDisplay     m_aCharsets;

    USHORT              m_nControlFlags;

public:
    virtual BOOL        FillItemSet (SfxItemSet& _rCoreAttrs);
    virtual void        implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);

protected:
    OCommonBehaviourTabPage(Window* pParent, USHORT nResId, const SfxItemSet& _rCoreAttrs, USHORT nControlFlags);
        // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten
    virtual ~OCommonBehaviourTabPage();
};

//========================================================================
//= ODbaseDetailsPage
//========================================================================
class ODbaseDetailsPage : public OCommonBehaviourTabPage
{
public:
    static  SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );
    virtual BOOL        FillItemSet ( SfxItemSet& _rCoreAttrs );

    /// get the SfxPoolItem ids used by this tab page
    static sal_Int32* getDetailIds();

private:
    GroupBox            m_aFrame;
    CheckBox            m_aShowDeleted;
    PushButton          m_aIndexes;

    String              m_sDsn;

protected:
    ODbaseDetailsPage(Window* pParent, const SfxItemSet& _rCoreAttrs);
    ~ODbaseDetailsPage();

protected:
    virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);

private:
    DECL_LINK( OnButtonClicked, Button * );
};

//========================================================================
//= OJdbcDetailsPage
//========================================================================
class OJdbcDetailsPage : public OCommonBehaviourTabPage
{
public:
    static  SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );
    virtual BOOL        FillItemSet ( SfxItemSet& _rCoreAttrs );

    /// get the SfxPoolItem ids used by this tab page
    static sal_Int32* getDetailIds();

private:
    FixedText           m_aDriverLabel;
    Edit                m_aDriver;
    FixedText           m_aJdbcUrlLabel;
    OConnectionURLEdit  m_aJdbcUrl;
    FixedLine           m_aSeparator1;

    OJdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
    ~OJdbcDetailsPage();

    virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
};

//========================================================================
//= OAdoDetailsPage
//========================================================================
class OAdoDetailsPage : public OCommonBehaviourTabPage
{
public:
    static  SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );
    virtual BOOL        FillItemSet ( SfxItemSet& _rCoreAttrs );

    /// get the SfxPoolItem ids used by this tab page
    static sal_Int32* getDetailIds();

private:
    FixedText           m_aAdoUrlLabel;
    OConnectionURLEdit  m_aAdoUrl;

    OAdoDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
    ~OAdoDetailsPage();

    virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
};

//========================================================================
//= OOdbcDetailsPage
//========================================================================
class OOdbcDetailsPage : public OCommonBehaviourTabPage
{
public:
    static  SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );

    /// get the SfxPoolItem ids used by this tab page
    static sal_Int32* getDetailIds();

private:
    FixedLine           m_aSeparator1;

    OOdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
};

//========================================================================
//= OAdabasDetailsPage
//========================================================================
class OAdabasDetailsPage : public OCommonBehaviourTabPage
{
public:
    static  SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );

    /// get the SfxPoolItem ids used by this tab page
    static sal_Int32* getDetailIds();

private:
    FixedLine           m_aSeparator1;

    OAdabasDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
};

//========================================================================
//= OTextDetailsPage
//========================================================================
class OTextDetailsPage : public OCommonBehaviourTabPage
{
public:
    static  SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );
    virtual BOOL        FillItemSet ( SfxItemSet& _rCoreAttrs );

    /// get the SfxPoolItem ids used by this tab page
    static sal_Int32* getDetailIds();

private:
    CheckBox    m_aHeader;
    FixedText   m_aFieldSeparatorLabel;
    ComboBox    m_aFieldSeparator;
    FixedText   m_aTextSeparatorLabel;
    ComboBox    m_aTextSeparator;
    FixedText   m_aDecimalSeparatorLabel;
    ComboBox    m_aDecimalSeparator;
    FixedText   m_aThousandsSeparatorLabel;
    ComboBox    m_aThousandsSeparator;
    FixedLine   m_aSeparator1;
    FixedText   m_aExtensionLabel;
    ComboBox    m_aExtension;

    String      m_aFieldSeparatorList;
    String      m_aTextSeparatorList;

    OTextDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
    ~OTextDetailsPage();

private:
    String      GetSeparator( const ComboBox& rBox, const String& rList );
    void        SetSeparator( ComboBox& rBox, const String& rList, const String& rVal );

    virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
    virtual sal_Bool checkItems();
};

//========================================================================
//= OTableSubscriptionPage
//========================================================================
class ODbAdminDialog;
class OTableSubscriptionPage : public OGenericAdministrationPage
{
    friend class ODbAdminDialog;

private:
    GroupBox                m_aTables;
    RadioButton             m_aIncludeAll;
    RadioButton             m_aIncludeNone;
    RadioButton             m_aIncludeSelected;
    OTableTreeListBox       m_aTablesList;
    CheckBox                m_aSuppressVersionColumns;
    sal_Bool                m_bCheckedAll : 1;
    sal_Bool                m_bCatalogAtStart : 1;
    sal_Bool                m_bInitializingControls : 1;
    ::rtl::OUString         m_sCatalogSeparator;
    ODbAdminDialog*         m_pAdminDialog;     /** needed for translating an SfxItemSet into Sequence< PropertyValue >
                                                    (for building an XConnection)
                                                */

    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
                            m_xCurrentConnection;   /// valid as long as the page is active
    ::com::sun::star::uno::Sequence< ::rtl::OUString >
                            m_aLastDetailedSelection;
    RadioButton*            m_pLastCheckedButton;

public:
    static  SfxTabPage* Create( Window* _pParent, const SfxItemSet& _rAttrSet);
    virtual BOOL        FillItemSet(SfxItemSet& _rCoreAttrs);
    virtual void        ActivatePage(const SfxItemSet& _rSet);
    virtual int         DeactivatePage(SfxItemSet* _pSet);

    void setServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB)
        { m_aTablesList.setServiceFactory(_rxORB); }

protected:
    void SetAdminDialog(ODbAdminDialog* _pDialog) { m_pAdminDialog = _pDialog; }

private:
    OTableSubscriptionPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
    ~OTableSubscriptionPage();

    /** check the tables in <member>m_aTablesList</member> according to <arg>_rTables</arg>
    */
    void implCheckTables(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTables);

    /** return the current selection in <member>m_aTablesList</member>
    */
    ::com::sun::star::uno::Sequence< ::rtl::OUString > collectDetailedSelection() const;

    void CheckAll( BOOL bCheck=TRUE );
    DECL_LINK( OnRadioButtonClicked, Button* );

    virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
};

//.........................................................................
}   // namespace dbaui
//.........................................................................

#endif // _DBAUI_ADMINPAGES_HXX_

/*************************************************************************
 * history:
 *  $Log: not supported by cvs2svn $
 *  Revision 1.16  2000/12/07 14:15:42  oj
 *  #81131# check installed adabas dbs
 *
 *  Revision 1.15  2000/11/30 08:32:30  fs
 *  #80003# changed some sal_uInt16 to sal_Int32 (need some -1's)
 *
 *  Revision 1.14  2000/11/29 22:29:40  fs
 *  #80003# implementation of the character set map changed
 *
 *  Revision 1.13  2000/11/28 13:47:31  fs
 *  #80152# m_bDisplayingDeleted renamed in m_bDisplayingInvalid
 *
 *  Revision 1.12  2000/11/28 11:41:42  oj
 *  #80827# check dbroot if dbconfig failed
 *
 *  Revision 1.11  2000/11/22 15:44:05  oj
 *  #80269# remove property long names
 *
 *  Revision 1.10  2000/11/10 17:35:28  fs
 *  no parameter in checkItems anymore - did not make sense in the context it is called / some small bug fixes
 *
 *  Revision 1.9  2000/11/02 15:20:04  fs
 *  #79983# +isBrowseable / #79830# +checkItems
 *
 *  Revision 1.8  2000/10/30 15:22:44  fs
 *  no password fields anymore - don't want to have them in and _data source aministration_ dialog
 *
 *  Revision 1.7  2000/10/24 12:11:15  fs
 *  functionality added: browsing for system data sources (ODBC/Adabas/dbase/text)
 *
 *  Revision 1.6  2000/10/20 09:53:17  fs
 *  handling for the SuppresVersionColumns property of a data source
 *
 *  Revision 1.5  2000/10/13 16:03:34  fs
 *  Separator changed to string / getDetailIds
 *
 *  Revision 1.4  2000/10/12 16:20:42  fs
 *  new implementations ... still under construction
 *
 *  Revision 1.3  2000/10/11 11:31:03  fs
 *  new implementations - still under construction
 *
 *  Revision 1.2  2000/10/09 12:39:29  fs
 *  some (a lot of) new imlpementations - still under development
 *
 *  Revision 1.1  2000/10/05 10:04:22  fs
 *  initial checkin
 *
 *
 *  Revision 1.0 26.09.00 11:46:15  fs
 ************************************************************************/