1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "detailpages.hxx"
31 #include "sqlmessage.hxx"
33 #include "advancedsettings.hxx"
34 #include "DbAdminImpl.hxx"
35 #include "dsitems.hxx"
36 #include "dbfindex.hxx"
37 #include "localresaccess.hxx"
38 #include "dsnItem.hxx"
40 #include "dbaccess_helpid.hrc"
41 #include "dbu_dlg.hrc"
42 #include "dbadmin.hrc"
44 #include <svl/itemset.hxx>
45 #include <svl/stritem.hxx>
46 #include <svl/eitem.hxx>
47 #include <svl/intitem.hxx>
48 #include <vcl/msgbox.hxx>
49 #include <vcl/mnemonic.hxx>
50 #include <svl/cjkoptions.hxx>
51 #include <jvmaccess/virtualmachine.hxx>
52 #include <connectivity/CommonTools.hxx>
53 #include "DriverSettings.hxx"
54 #include "dbadmin.hxx"
55 #include <comphelper/types.hxx>
56 #include "AutoControls.hrc"
58 //.........................................................................
61 //.........................................................................
63 using namespace ::com::sun::star::uno
;
64 using namespace ::com::sun::star::sdbc
;
65 using namespace ::com::sun::star::beans
;
66 using namespace ::com::sun::star::lang
;
67 using namespace ::com::sun::star::container
;
68 using namespace ::dbtools
;
70 //========================================================================
71 //= OCommonBehaviourTabPage
72 //========================================================================
73 DBG_NAME(OCommonBehaviourTabPage
)
74 //------------------------------------------------------------------------
75 OCommonBehaviourTabPage::OCommonBehaviourTabPage(Window
* pParent
, sal_uInt16 nResId
, const SfxItemSet
& _rCoreAttrs
,
76 sal_uInt32 nControlFlags
,bool _bFreeResource
)
78 :OGenericAdministrationPage(pParent
, ModuleRes(nResId
), _rCoreAttrs
)
79 ,m_pOptionsLabel(NULL
)
81 ,m_pDataConvertFixedLine(NULL
)
82 ,m_pCharsetLabel(NULL
)
84 ,m_pAutoFixedLine(NULL
)
85 ,m_pAutoRetrievingEnabled(NULL
)
86 ,m_pAutoIncrementLabel(NULL
)
87 ,m_pAutoIncrement(NULL
)
88 ,m_pAutoRetrievingLabel(NULL
)
89 ,m_pAutoRetrieving(NULL
)
90 ,m_nControlFlags(nControlFlags
)
92 DBG_CTOR(OCommonBehaviourTabPage
,NULL
);
94 if ((m_nControlFlags
& CBTP_USE_OPTIONS
) == CBTP_USE_OPTIONS
)
96 m_pOptionsLabel
= new FixedText(this, ModuleRes(FT_OPTIONS
));
97 m_pOptions
= new Edit(this, ModuleRes(ET_OPTIONS
));
98 m_pOptions
->SetModifyHdl(getControlModifiedLink());
101 if ((m_nControlFlags
& CBTP_USE_CHARSET
) == CBTP_USE_CHARSET
)
103 m_pDataConvertFixedLine
= new FixedLine(this, ModuleRes(FL_DATACONVERT
));
104 m_pCharsetLabel
= new FixedText(this, ModuleRes(FT_CHARSET
));
105 m_pCharset
= new CharSetListBox(this, ModuleRes(LB_CHARSET
));
106 m_pCharset
->SetSelectHdl(getControlModifiedLink());
109 Window
* pWindows
[] = { m_pAutoRetrievingEnabled
, m_pAutoFixedLine
,
110 m_pAutoIncrementLabel
, m_pAutoIncrement
,
111 m_pAutoRetrievingLabel
, m_pAutoRetrieving
};
113 sal_Int32 nCount
= sizeof(pWindows
) / sizeof(pWindows
[0]);
114 for (sal_Int32 i
=1; i
< nCount
; ++i
)
118 Window
* pPrev
= pWindows
[i
-1];
119 for (sal_Int32 j
= i
-1; pPrev
== NULL
&& j
>= 0 ; --j
)
124 pWindows
[i
]->SetZOrder(pPrev
, WINDOW_ZORDER_BEHIND
);
128 if ( _bFreeResource
)
132 // -----------------------------------------------------------------------
133 OCommonBehaviourTabPage::~OCommonBehaviourTabPage()
135 DELETEZ(m_pOptionsLabel
);
138 DELETEZ(m_pDataConvertFixedLine
);
139 DELETEZ(m_pCharsetLabel
);
142 DELETEZ(m_pAutoFixedLine
);
143 DELETEZ(m_pAutoIncrementLabel
);
144 DELETEZ(m_pAutoIncrement
);
146 DELETEZ(m_pAutoRetrievingEnabled
);
147 DELETEZ(m_pAutoRetrievingLabel
);
148 DELETEZ(m_pAutoRetrieving
);
150 DBG_DTOR(OCommonBehaviourTabPage
,NULL
);
153 // -----------------------------------------------------------------------
154 void OCommonBehaviourTabPage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
156 if ((m_nControlFlags
& CBTP_USE_OPTIONS
) == CBTP_USE_OPTIONS
)
158 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pOptionsLabel
));
161 if ((m_nControlFlags
& CBTP_USE_CHARSET
) == CBTP_USE_CHARSET
)
163 _rControlList
.push_back(new ODisableWrapper
<FixedLine
>(m_pDataConvertFixedLine
));
164 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pCharsetLabel
));
167 // -----------------------------------------------------------------------
168 void OCommonBehaviourTabPage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
170 if ((m_nControlFlags
& CBTP_USE_OPTIONS
) == CBTP_USE_OPTIONS
)
171 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(m_pOptions
));
173 if ((m_nControlFlags
& CBTP_USE_CHARSET
) == CBTP_USE_CHARSET
)
174 _rControlList
.push_back(new OSaveValueWrapper
<ListBox
>(m_pCharset
));
177 // -----------------------------------------------------------------------
178 void OCommonBehaviourTabPage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
180 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
181 sal_Bool bValid
, bReadonly
;
182 getFlags(_rSet
, bValid
, bReadonly
);
185 SFX_ITEMSET_GET(_rSet
, pOptionsItem
, SfxStringItem
, DSID_ADDITIONALOPTIONS
, sal_True
);
186 SFX_ITEMSET_GET(_rSet
, pCharsetItem
, SfxStringItem
, DSID_CHARSET
, sal_True
);
188 // forward the values to the controls
191 if ((m_nControlFlags
& CBTP_USE_OPTIONS
) == CBTP_USE_OPTIONS
)
193 m_pOptions
->SetText(pOptionsItem
->GetValue());
194 m_pOptions
->ClearModifyFlag();
197 if ((m_nControlFlags
& CBTP_USE_CHARSET
) == CBTP_USE_CHARSET
)
199 m_pCharset
->SelectEntryByIanaName( pCharsetItem
->GetValue() );
202 OGenericAdministrationPage::implInitControls(_rSet
, _bSaveValue
);
204 // -----------------------------------------------------------------------
205 sal_Bool
OCommonBehaviourTabPage::FillItemSet(SfxItemSet
& _rSet
)
207 sal_Bool bChangedSomething
= sal_False
;
209 if ((m_nControlFlags
& CBTP_USE_OPTIONS
) == CBTP_USE_OPTIONS
)
211 fillString(_rSet
,m_pOptions
,DSID_ADDITIONALOPTIONS
,bChangedSomething
);
214 if ((m_nControlFlags
& CBTP_USE_CHARSET
) == CBTP_USE_CHARSET
)
216 if ( m_pCharset
->StoreSelectedCharSet( _rSet
, DSID_CHARSET
) )
217 bChangedSomething
= sal_True
;
220 return bChangedSomething
;
223 //========================================================================
224 //= ODbaseDetailsPage
225 //========================================================================
226 DBG_NAME(ODbaseDetailsPage
)
227 //------------------------------------------------------------------------
228 ODbaseDetailsPage::ODbaseDetailsPage( Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
229 :OCommonBehaviourTabPage(pParent
, PAGE_DBASE
, _rCoreAttrs
, CBTP_USE_CHARSET
,false)
230 ,m_aShowDeleted (this, ModuleRes(CB_SHOWDELETEDROWS
))
231 ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1
) )
232 ,m_aFT_Message (this, ModuleRes( FT_SPECIAL_MESSAGE
) )
233 ,m_aIndexes (this, ModuleRes(PB_INDICIES
))
235 DBG_CTOR(ODbaseDetailsPage
,NULL
);
237 m_aIndexes
.SetClickHdl(LINK(this, ODbaseDetailsPage
, OnButtonClicked
));
238 m_aShowDeleted
.SetClickHdl(LINK(this, ODbaseDetailsPage
, OnButtonClicked
));
240 // correct the z-order which is mixed-up because the base class constructed some controls before we did
241 m_pCharset
->SetZOrder(&m_aShowDeleted
, WINDOW_ZORDER_BEFOR
);
246 // -----------------------------------------------------------------------
247 ODbaseDetailsPage::~ODbaseDetailsPage()
250 DBG_DTOR(ODbaseDetailsPage
,NULL
);
253 // -----------------------------------------------------------------------
254 SfxTabPage
* ODriversSettings::CreateDbase( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
256 return ( new ODbaseDetailsPage( pParent
, _rAttrSet
) );
259 // -----------------------------------------------------------------------
260 void ODbaseDetailsPage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
262 OCommonBehaviourTabPage::fillControls(_rControlList
);
263 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(&m_aShowDeleted
));
265 // -----------------------------------------------------------------------
266 void ODbaseDetailsPage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
268 OCommonBehaviourTabPage::fillWindows(_rControlList
);
269 _rControlList
.push_back(new ODisableWrapper
<FixedLine
>(&m_aFL_1
));
270 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aFT_Message
));
271 _rControlList
.push_back(new ODisableWrapper
<PushButton
>(&m_aIndexes
));
273 // -----------------------------------------------------------------------
274 void ODbaseDetailsPage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
276 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
277 sal_Bool bValid
, bReadonly
;
278 getFlags(_rSet
, bValid
, bReadonly
);
280 // get the DSN string (needed for the index dialog)
281 SFX_ITEMSET_GET(_rSet
, pUrlItem
, SfxStringItem
, DSID_CONNECTURL
, sal_True
);
282 SFX_ITEMSET_GET(_rSet
, pTypesItem
, DbuTypeCollectionItem
, DSID_TYPECOLLECTION
, sal_True
);
283 ::dbaccess::ODsnTypeCollection
* pTypeCollection
= pTypesItem
? pTypesItem
->getCollection() : NULL
;
284 if (pTypeCollection
&& pUrlItem
&& pUrlItem
->GetValue().Len())
285 m_sDsn
= pTypeCollection
->cutPrefix(pUrlItem
->GetValue());
287 // get the other relevant items
288 SFX_ITEMSET_GET(_rSet
, pDeletedItem
, SfxBoolItem
, DSID_SHOWDELETEDROWS
, sal_True
);
292 m_aShowDeleted
.Check( pDeletedItem
->GetValue() );
293 m_aFT_Message
.Show(m_aShowDeleted
.IsChecked());
296 OCommonBehaviourTabPage::implInitControls(_rSet
, _bSaveValue
);
299 // -----------------------------------------------------------------------
300 sal_Bool
ODbaseDetailsPage::FillItemSet( SfxItemSet
& _rSet
)
302 sal_Bool bChangedSomething
= OCommonBehaviourTabPage::FillItemSet(_rSet
);
304 fillBool(_rSet
,&m_aShowDeleted
,DSID_SHOWDELETEDROWS
,bChangedSomething
);
305 return bChangedSomething
;
308 //------------------------------------------------------------------------
309 IMPL_LINK( ODbaseDetailsPage
, OnButtonClicked
, Button
*, pButton
)
311 if (&m_aIndexes
== pButton
)
313 ODbaseIndexDialog
aIndexDialog(this, m_sDsn
);
314 aIndexDialog
.Execute();
318 m_aFT_Message
.Show(m_aShowDeleted
.IsChecked());
319 // it was one of the checkboxes -> we count as modified from now on
326 //========================================================================
328 //========================================================================
329 DBG_NAME(OAdoDetailsPage
)
330 // -----------------------------------------------------------------------
331 OAdoDetailsPage::OAdoDetailsPage( Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
332 :OCommonBehaviourTabPage(pParent
, PAGE_ADO
, _rCoreAttrs
, CBTP_USE_CHARSET
)
334 DBG_CTOR(OAdoDetailsPage
,NULL
);
338 // -----------------------------------------------------------------------
339 OAdoDetailsPage::~OAdoDetailsPage()
342 DBG_DTOR(OAdoDetailsPage
,NULL
);
344 // -----------------------------------------------------------------------
345 SfxTabPage
* ODriversSettings::CreateAdo( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
347 return ( new OAdoDetailsPage( pParent
, _rAttrSet
) );
350 // -----------------------------------------------------------------------
351 //========================================================================
353 //========================================================================
354 OOdbcDetailsPage::OOdbcDetailsPage( Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
355 :OCommonBehaviourTabPage(pParent
, PAGE_ODBC
, _rCoreAttrs
, CBTP_USE_CHARSET
| CBTP_USE_OPTIONS
,false)
356 ,m_aFL_1 (this, ModuleRes(FL_SEPARATOR1
))
357 ,m_aUseCatalog (this, ModuleRes(CB_USECATALOG
))
359 m_aUseCatalog
.SetToggleHdl(getControlModifiedLink());
362 Window
* pWindows
[] = { m_pCharsetLabel
, m_pCharset
363 ,m_pOptionsLabel
,m_pOptions
,&m_aUseCatalog
366 sal_Int32 nCount
= sizeof(pWindows
) / sizeof(pWindows
[0]);
367 for (sal_Int32 i
=1; i
< nCount
; ++i
)
368 pWindows
[i
]->SetZOrder(pWindows
[i
-1], WINDOW_ZORDER_BEHIND
);
371 // -----------------------------------------------------------------------
372 SfxTabPage
* ODriversSettings::CreateODBC( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
374 return ( new OOdbcDetailsPage( pParent
, _rAttrSet
) );
377 // -----------------------------------------------------------------------
378 sal_Bool
OOdbcDetailsPage::FillItemSet( SfxItemSet
& _rSet
)
380 sal_Bool bChangedSomething
= OCommonBehaviourTabPage::FillItemSet(_rSet
);
381 fillBool(_rSet
,&m_aUseCatalog
,DSID_USECATALOG
,bChangedSomething
);
382 return bChangedSomething
;
384 // -----------------------------------------------------------------------
385 void OOdbcDetailsPage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
387 OCommonBehaviourTabPage::fillControls(_rControlList
);
388 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(&m_aUseCatalog
));
390 // -----------------------------------------------------------------------
391 void OOdbcDetailsPage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
393 OCommonBehaviourTabPage::fillWindows(_rControlList
);
394 _rControlList
.push_back(new ODisableWrapper
<FixedLine
>(&m_aFL_1
));
396 // -----------------------------------------------------------------------
397 void OOdbcDetailsPage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
399 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
400 sal_Bool bValid
, bReadonly
;
401 getFlags(_rSet
, bValid
, bReadonly
);
403 SFX_ITEMSET_GET(_rSet
, pUseCatalogItem
, SfxBoolItem
, DSID_USECATALOG
, sal_True
);
406 m_aUseCatalog
.Check(pUseCatalogItem
->GetValue());
408 OCommonBehaviourTabPage::implInitControls(_rSet
, _bSaveValue
);
410 //========================================================================
412 //========================================================================
413 OUserDriverDetailsPage::OUserDriverDetailsPage( Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
414 :OCommonBehaviourTabPage(pParent
, PAGE_USERDRIVER
, _rCoreAttrs
,
415 CBTP_USE_CHARSET
| CBTP_USE_OPTIONS
,false)
416 ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME
))
417 ,m_aEDHostname (this, ModuleRes(ET_HOSTNAME
))
418 ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER
))
419 ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER
))
420 ,m_aUseCatalog (this, ModuleRes(CB_USECATALOG
))
422 m_aUseCatalog
.SetToggleHdl(getControlModifiedLink());
426 // -----------------------------------------------------------------------
427 SfxTabPage
* ODriversSettings::CreateUser( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
429 return ( new OUserDriverDetailsPage( pParent
, _rAttrSet
) );
432 // -----------------------------------------------------------------------
433 sal_Bool
OUserDriverDetailsPage::FillItemSet( SfxItemSet
& _rSet
)
435 sal_Bool bChangedSomething
= OCommonBehaviourTabPage::FillItemSet(_rSet
);
437 fillInt32(_rSet
,&m_aNFPortNumber
,DSID_CONN_PORTNUMBER
,bChangedSomething
);
438 fillString(_rSet
,&m_aEDHostname
,DSID_CONN_HOSTNAME
,bChangedSomething
);
439 fillBool(_rSet
,&m_aUseCatalog
,DSID_USECATALOG
,bChangedSomething
);
441 return bChangedSomething
;
443 // -----------------------------------------------------------------------
444 void OUserDriverDetailsPage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
446 OCommonBehaviourTabPage::fillControls(_rControlList
);
447 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(&m_aEDHostname
));
448 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(&m_aUseCatalog
));
449 _rControlList
.push_back(new OSaveValueWrapper
<NumericField
>(&m_aNFPortNumber
));
451 // -----------------------------------------------------------------------
452 void OUserDriverDetailsPage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
454 OCommonBehaviourTabPage::fillWindows(_rControlList
);
455 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aFTHostname
));
456 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aPortNumber
));
458 // -----------------------------------------------------------------------
459 void OUserDriverDetailsPage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
461 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
462 sal_Bool bValid
, bReadonly
;
463 getFlags(_rSet
, bValid
, bReadonly
);
465 SFX_ITEMSET_GET(_rSet
, pUseCatalogItem
, SfxBoolItem
, DSID_USECATALOG
, sal_True
);
466 SFX_ITEMSET_GET(_rSet
, pHostName
, SfxStringItem
, DSID_CONN_HOSTNAME
, sal_True
);
467 SFX_ITEMSET_GET(_rSet
, pPortNumber
, SfxInt32Item
, DSID_CONN_PORTNUMBER
, sal_True
);
471 m_aEDHostname
.SetText(pHostName
->GetValue());
472 m_aEDHostname
.ClearModifyFlag();
474 m_aNFPortNumber
.SetValue(pPortNumber
->GetValue());
475 m_aNFPortNumber
.ClearModifyFlag();
477 m_aUseCatalog
.Check(pUseCatalogItem
->GetValue());
480 OCommonBehaviourTabPage::implInitControls(_rSet
, _bSaveValue
);
482 //========================================================================
483 //= OMySQLODBCDetailsPage
484 //========================================================================
485 OMySQLODBCDetailsPage::OMySQLODBCDetailsPage( Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
486 :OCommonBehaviourTabPage(pParent
, PAGE_MYSQL_ODBC
, _rCoreAttrs
, CBTP_USE_CHARSET
)
490 // -----------------------------------------------------------------------
491 SfxTabPage
* ODriversSettings::CreateMySQLODBC( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
493 return ( new OMySQLODBCDetailsPage( pParent
, _rAttrSet
) );
496 //========================================================================
497 //= OMySQLJDBCDetailsPage
498 //========================================================================
499 OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage( Window
* pParent
,sal_uInt16 _nResId
, const SfxItemSet
& _rCoreAttrs
,sal_uInt16 _nPortId
)
500 :OCommonBehaviourTabPage(pParent
, _nResId
, _rCoreAttrs
, CBTP_USE_CHARSET
,false)
501 ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1
) )
502 ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME
))
503 ,m_aEDHostname (this, ModuleRes(ET_HOSTNAME
))
504 ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER
))
505 ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER
))
506 ,m_aFTSocket (this, ModuleRes(FT_SOCKET
))
507 ,m_aEDSocket (this, ModuleRes(ET_SOCKET
))
508 ,m_aFTDriverClass (this, ModuleRes(FT_JDBCDRIVERCLASS
))
509 ,m_aEDDriverClass (this, ModuleRes(ET_JDBCDRIVERCLASS
))
510 ,m_aTestJavaDriver (this, ModuleRes(PB_TESTDRIVERCLASS
))
514 SFX_ITEMSET_GET(_rCoreAttrs
, pUrlItem
, SfxStringItem
, DSID_CONNECTURL
, sal_True
);
515 SFX_ITEMSET_GET(_rCoreAttrs
, pTypesItem
, DbuTypeCollectionItem
, DSID_TYPECOLLECTION
, sal_True
);
516 ::dbaccess::ODsnTypeCollection
* pTypeCollection
= pTypesItem
? pTypesItem
->getCollection() : NULL
;
517 if (pTypeCollection
&& pUrlItem
&& pUrlItem
->GetValue().Len() )
519 m_sDefaultJdbcDriverName
= pTypeCollection
->getJavaDriverClass(pUrlItem
->GetValue());
521 if ( m_sDefaultJdbcDriverName
.Len() )
523 m_aEDDriverClass
.SetModifyHdl(getControlModifiedLink());
524 m_aEDDriverClass
.SetModifyHdl(LINK(this, OGeneralSpecialJDBCDetailsPage
, OnEditModified
));
525 m_aTestJavaDriver
.SetClickHdl(LINK(this,OGeneralSpecialJDBCDetailsPage
,OnTestJavaClickHdl
));
530 m_aFTDriverClass
.Show(sal_False
);
531 m_aEDDriverClass
.Show(sal_False
);
532 m_aTestJavaDriver
.Show(sal_False
);
535 m_aFTSocket
.Show(PAGE_MYSQL_JDBC
== _nResId
&& !m_bUseClass
);
536 m_aEDSocket
.Show(PAGE_MYSQL_JDBC
== _nResId
&& !m_bUseClass
);
538 m_aEDHostname
.SetModifyHdl(getControlModifiedLink());
539 m_aNFPortNumber
.SetModifyHdl(getControlModifiedLink());
540 m_aEDSocket
.SetModifyHdl(getControlModifiedLink());
542 Window
* pWindows
[] = { &m_aFTHostname
,&m_aEDHostname
,
543 &m_aPortNumber
,&m_aNFPortNumber
,&m_aFTSocket
,&m_aEDSocket
,
544 &m_aFTDriverClass
, &m_aEDDriverClass
,&m_aTestJavaDriver
,
545 m_pCharsetLabel
, m_pCharset
};
547 sal_Int32 nCount
= sizeof(pWindows
) / sizeof(pWindows
[0]);
548 for (sal_Int32 i
=1; i
< nCount
; ++i
)
549 pWindows
[i
]->SetZOrder(pWindows
[i
-1], WINDOW_ZORDER_BEHIND
);
554 // -----------------------------------------------------------------------
555 void OGeneralSpecialJDBCDetailsPage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
557 OCommonBehaviourTabPage::fillControls(_rControlList
);
559 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(&m_aEDDriverClass
));
560 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(&m_aEDHostname
));
561 _rControlList
.push_back(new OSaveValueWrapper
<NumericField
>(&m_aNFPortNumber
));
562 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(&m_aEDSocket
));
564 // -----------------------------------------------------------------------
565 void OGeneralSpecialJDBCDetailsPage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
567 OCommonBehaviourTabPage::fillWindows(_rControlList
);
568 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aFTHostname
));
569 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aPortNumber
));
570 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aFTSocket
));
572 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aFTDriverClass
));
573 _rControlList
.push_back(new ODisableWrapper
<FixedLine
>(&m_aFL_1
));
576 // -----------------------------------------------------------------------
577 sal_Bool
OGeneralSpecialJDBCDetailsPage::FillItemSet( SfxItemSet
& _rSet
)
579 sal_Bool bChangedSomething
= OCommonBehaviourTabPage::FillItemSet(_rSet
);
581 fillString(_rSet
,&m_aEDDriverClass
,DSID_JDBCDRIVERCLASS
,bChangedSomething
);
582 fillString(_rSet
,&m_aEDHostname
,DSID_CONN_HOSTNAME
,bChangedSomething
);
583 fillString(_rSet
,&m_aEDSocket
,DSID_CONN_SOCKET
,bChangedSomething
);
584 fillInt32(_rSet
,&m_aNFPortNumber
,m_nPortId
,bChangedSomething
);
586 return bChangedSomething
;
588 // -----------------------------------------------------------------------
589 void OGeneralSpecialJDBCDetailsPage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
591 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
592 sal_Bool bValid
, bReadonly
;
593 getFlags(_rSet
, bValid
, bReadonly
);
595 SFX_ITEMSET_GET(_rSet
, pDrvItem
, SfxStringItem
, DSID_JDBCDRIVERCLASS
, sal_True
);
596 SFX_ITEMSET_GET(_rSet
, pHostName
, SfxStringItem
, DSID_CONN_HOSTNAME
, sal_True
);
597 SFX_ITEMSET_GET(_rSet
, pPortNumber
, SfxInt32Item
, m_nPortId
, sal_True
);
598 SFX_ITEMSET_GET(_rSet
, pSocket
, SfxStringItem
, DSID_CONN_SOCKET
, sal_True
);
604 m_aEDDriverClass
.SetText(pDrvItem
->GetValue());
605 m_aEDDriverClass
.ClearModifyFlag();
608 m_aEDHostname
.SetText(pHostName
->GetValue());
609 m_aEDHostname
.ClearModifyFlag();
611 m_aNFPortNumber
.SetValue(pPortNumber
->GetValue());
612 m_aNFPortNumber
.ClearModifyFlag();
614 m_aEDSocket
.SetText(pSocket
->GetValue());
615 m_aEDSocket
.ClearModifyFlag();
618 OCommonBehaviourTabPage::implInitControls(_rSet
, _bSaveValue
);
620 // to get the correcxt value when saveValue was called by base class
621 if ( m_bUseClass
&& !m_aEDDriverClass
.GetText().Len() )
623 m_aEDDriverClass
.SetText(m_sDefaultJdbcDriverName
);
624 m_aEDDriverClass
.SetModifyFlag();
627 // -----------------------------------------------------------------------
628 IMPL_LINK(OGeneralSpecialJDBCDetailsPage
, OnTestJavaClickHdl
, PushButton
*, /*_pButton*/)
630 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
631 OSL_ENSURE(m_bUseClass
,"Who called me?");
633 sal_Bool bSuccess
= sal_False
;
636 if ( m_aEDDriverClass
.GetText().Len() )
638 // TODO chage jvmaccess
639 ::rtl::Reference
< jvmaccess::VirtualMachine
> xJVM
= ::connectivity::getJavaVM(m_pAdminDialog
->getORB());
640 bSuccess
= ::connectivity::existsJavaClassByName(xJVM
,m_aEDDriverClass
.GetText());
647 const sal_uInt16 nMessage
= bSuccess
? STR_JDBCDRIVER_SUCCESS
: STR_JDBCDRIVER_NO_SUCCESS
;
648 const OSQLMessageBox::MessageType mt
= bSuccess
? OSQLMessageBox::Info
: OSQLMessageBox::Error
;
649 OSQLMessageBox
aMsg( this, String( ModuleRes( nMessage
) ), String(), WB_OK
| WB_DEF_OK
, mt
);
653 // -----------------------------------------------------------------------
654 IMPL_LINK(OGeneralSpecialJDBCDetailsPage
, OnEditModified
, Edit
*, _pEdit
)
656 if ( m_bUseClass
&& _pEdit
== &m_aEDDriverClass
)
657 m_aTestJavaDriver
.Enable( m_aEDDriverClass
.GetText().Len() != 0 );
659 // tell the listener we were modified
664 //========================================================================
666 //========================================================================
667 MySQLNativePage::MySQLNativePage( Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
668 :OCommonBehaviourTabPage(pParent
, PAGE_MYSQL_NATIVE
, _rCoreAttrs
, CBTP_USE_CHARSET
, false )
669 ,m_aSeparator1 ( this, ModuleRes( FL_SEPARATOR1
) )
670 ,m_aMySQLSettings ( *this, getControlModifiedLink() )
671 ,m_aSeparator2 ( this, ModuleRes(FL_SEPARATOR2
))
672 ,m_aUserNameLabel ( this, ModuleRes(FT_USERNAME
))
673 ,m_aUserName ( this, ModuleRes(ET_USERNAME
))
674 ,m_aPasswordRequired ( this, ModuleRes(CB_PASSWORD_REQUIRED
))
676 m_aUserName
.SetModifyHdl(getControlModifiedLink());
678 Window
* pWindows
[] = { &m_aMySQLSettings
, &m_aSeparator2
, &m_aUserNameLabel
, &m_aUserName
,
679 &m_aPasswordRequired
, m_pCharsetLabel
, m_pCharset
};
680 sal_Int32 nCount
= sizeof(pWindows
) / sizeof(pWindows
[0]);
681 for (sal_Int32 i
=1; i
< nCount
; ++i
)
682 pWindows
[i
]->SetZOrder(pWindows
[i
-1], WINDOW_ZORDER_BEHIND
);
684 LayoutHelper::positionBelow( m_aSeparator1
, m_aMySQLSettings
, RelatedControls
, 3 );
685 m_aMySQLSettings
.Show();
690 // -----------------------------------------------------------------------
691 void MySQLNativePage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
693 OCommonBehaviourTabPage::fillControls( _rControlList
);
694 m_aMySQLSettings
.fillControls( _rControlList
);
696 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(&m_aUserName
));
697 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(&m_aPasswordRequired
));
699 // -----------------------------------------------------------------------
700 void MySQLNativePage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
702 OCommonBehaviourTabPage::fillWindows( _rControlList
);
703 m_aMySQLSettings
.fillWindows( _rControlList
);
705 _rControlList
.push_back(new ODisableWrapper
<FixedLine
>(&m_aSeparator1
));
706 _rControlList
.push_back(new ODisableWrapper
<FixedLine
>(&m_aSeparator2
));
707 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aUserNameLabel
));
710 // -----------------------------------------------------------------------
711 sal_Bool
MySQLNativePage::FillItemSet( SfxItemSet
& _rSet
)
713 sal_Bool bChangedSomething
= OCommonBehaviourTabPage::FillItemSet( _rSet
);
715 bChangedSomething
|= m_aMySQLSettings
.FillItemSet( _rSet
);
717 if ( m_aUserName
.GetText() != m_aUserName
.GetSavedValue() )
719 _rSet
.Put( SfxStringItem( DSID_USER
, m_aUserName
.GetText() ) );
720 _rSet
.Put( SfxStringItem( DSID_PASSWORD
, String()));
721 bChangedSomething
= sal_True
;
723 fillBool(_rSet
,&m_aPasswordRequired
,DSID_PASSWORDREQUIRED
,bChangedSomething
);
725 return bChangedSomething
;
727 // -----------------------------------------------------------------------
728 void MySQLNativePage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
730 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
731 sal_Bool bValid
, bReadonly
;
732 getFlags(_rSet
, bValid
, bReadonly
);
734 m_aMySQLSettings
.implInitControls( _rSet
);
736 SFX_ITEMSET_GET(_rSet
, pUidItem
, SfxStringItem
, DSID_USER
, sal_True
);
737 SFX_ITEMSET_GET(_rSet
, pAllowEmptyPwd
, SfxBoolItem
, DSID_PASSWORDREQUIRED
, sal_True
);
741 m_aUserName
.SetText(pUidItem
->GetValue());
742 m_aUserName
.ClearModifyFlag();
743 m_aPasswordRequired
.Check(pAllowEmptyPwd
->GetValue());
746 OCommonBehaviourTabPage::implInitControls(_rSet
, _bSaveValue
);
749 // -----------------------------------------------------------------------
750 SfxTabPage
* ODriversSettings::CreateMySQLJDBC( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
752 return ( new OGeneralSpecialJDBCDetailsPage( pParent
,PAGE_MYSQL_JDBC
, _rAttrSet
,DSID_MYSQL_PORTNUMBER
) );
754 // -----------------------------------------------------------------------
755 SfxTabPage
* ODriversSettings::CreateMySQLNATIVE( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
757 return ( new MySQLNativePage( pParent
, _rAttrSet
) );
760 // -----------------------------------------------------------------------
761 SfxTabPage
* ODriversSettings::CreateOracleJDBC( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
763 return ( new OGeneralSpecialJDBCDetailsPage( pParent
,PAGE_ORACLE_JDBC
, _rAttrSet
,DSID_ORACLE_PORTNUMBER
) );
766 //========================================================================
768 //========================================================================
769 OLDAPDetailsPage::OLDAPDetailsPage( Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
770 :OCommonBehaviourTabPage(pParent
, PAGE_LDAP
, _rCoreAttrs
,0,false)
771 ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1
) )
772 ,m_aBaseDN (this, ModuleRes(FT_BASEDN
))
773 ,m_aETBaseDN (this, ModuleRes(ET_BASEDN
))
774 ,m_aCBUseSSL (this, ModuleRes(CB_USESSL
))
775 ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER
))
776 ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER
))
777 ,m_aFTRowCount (this, ModuleRes(FT_LDAPROWCOUNT
))
778 ,m_aNFRowCount (this, ModuleRes(NF_LDAPROWCOUNT
))
780 m_aETBaseDN
.SetModifyHdl(getControlModifiedLink());
781 m_aCBUseSSL
.SetToggleHdl(getControlModifiedLink());
782 m_aNFPortNumber
.SetModifyHdl(getControlModifiedLink());
783 m_aNFRowCount
.SetModifyHdl(getControlModifiedLink());
785 m_aNFRowCount
.SetUseThousandSep(sal_False
);
788 m_aCBUseSSL
.SetClickHdl(LINK(this, OLDAPDetailsPage
,OnCheckBoxClick
));
792 // -----------------------------------------------------------------------
793 SfxTabPage
* ODriversSettings::CreateLDAP( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
795 return ( new OLDAPDetailsPage( pParent
, _rAttrSet
) );
798 // -----------------------------------------------------------------------
799 sal_Bool
OLDAPDetailsPage::FillItemSet( SfxItemSet
& _rSet
)
801 sal_Bool bChangedSomething
= OCommonBehaviourTabPage::FillItemSet(_rSet
);
803 fillString(_rSet
,&m_aETBaseDN
,DSID_CONN_LDAP_BASEDN
,bChangedSomething
);
804 fillInt32(_rSet
,&m_aNFPortNumber
,DSID_CONN_LDAP_PORTNUMBER
,bChangedSomething
);
805 fillInt32(_rSet
,&m_aNFRowCount
,DSID_CONN_LDAP_ROWCOUNT
,bChangedSomething
);
806 fillBool(_rSet
,&m_aCBUseSSL
,DSID_CONN_LDAP_USESSL
,bChangedSomething
);
807 return bChangedSomething
;
809 //------------------------------------------------------------------------
810 IMPL_LINK( OLDAPDetailsPage
, OnCheckBoxClick
, CheckBox
*, pCheckBox
)
813 if ( pCheckBox
== &m_aCBUseSSL
)
815 if ( m_aCBUseSSL
.IsChecked() )
817 m_iNormalPort
= static_cast<sal_Int32
>(m_aNFPortNumber
.GetValue());
818 m_aNFPortNumber
.SetValue(m_iSSLPort
);
822 m_iSSLPort
= static_cast<sal_Int32
>(m_aNFPortNumber
.GetValue());
823 m_aNFPortNumber
.SetValue(m_iNormalPort
);
829 // -----------------------------------------------------------------------
830 void OLDAPDetailsPage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
832 OCommonBehaviourTabPage::fillControls(_rControlList
);
833 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(&m_aETBaseDN
));
834 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(&m_aCBUseSSL
));
835 _rControlList
.push_back(new OSaveValueWrapper
<NumericField
>(&m_aNFPortNumber
));
836 _rControlList
.push_back(new OSaveValueWrapper
<NumericField
>(&m_aNFRowCount
));
838 // -----------------------------------------------------------------------
839 void OLDAPDetailsPage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
841 OCommonBehaviourTabPage::fillWindows(_rControlList
);
842 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aBaseDN
));
843 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aPortNumber
));
844 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(&m_aFTRowCount
));
845 _rControlList
.push_back(new ODisableWrapper
<FixedLine
>(&m_aFL_1
));
847 // -----------------------------------------------------------------------
848 void OLDAPDetailsPage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
850 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
851 sal_Bool bValid
, bReadonly
;
852 getFlags(_rSet
, bValid
, bReadonly
);
855 SFX_ITEMSET_GET(_rSet
, pBaseDN
, SfxStringItem
, DSID_CONN_LDAP_BASEDN
, sal_True
);
856 SFX_ITEMSET_GET(_rSet
, pUseSSL
, SfxBoolItem
, DSID_CONN_LDAP_USESSL
, sal_True
);
857 SFX_ITEMSET_GET(_rSet
, pPortNumber
, SfxInt32Item
, DSID_CONN_LDAP_PORTNUMBER
, sal_True
);
858 SFX_ITEMSET_GET(_rSet
, pRowCount
, SfxInt32Item
, DSID_CONN_LDAP_ROWCOUNT
, sal_True
);
862 m_aETBaseDN
.SetText(pBaseDN
->GetValue());
863 m_aNFPortNumber
.SetValue(pPortNumber
->GetValue());
864 m_aNFRowCount
.SetValue(pRowCount
->GetValue());
865 m_aCBUseSSL
.Check(pUseSSL
->GetValue());
868 OCommonBehaviourTabPage::implInitControls(_rSet
, _bSaveValue
);
872 //========================================================================
874 //========================================================================
875 DBG_NAME(OTextDetailsPage
)
876 //------------------------------------------------------------------------
877 OTextDetailsPage::OTextDetailsPage( Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
878 :OCommonBehaviourTabPage(pParent
, PAGE_TEXT
, _rCoreAttrs
, 0, false )
880 DBG_CTOR(OTextDetailsPage
,NULL
);
882 m_pTextConnectionHelper
= new OTextConnectionHelper( this, TC_EXTENSION
| TC_HEADER
| TC_SEPARATORS
| TC_CHARSET
);
886 // -----------------------------------------------------------------------
887 OTextDetailsPage::~OTextDetailsPage()
889 DELETEZ(m_pTextConnectionHelper
);
891 DBG_DTOR(OTextDetailsPage
,NULL
);
894 // -----------------------------------------------------------------------
895 SfxTabPage
* ODriversSettings::CreateText( Window
* pParent
, const SfxItemSet
& _rAttrSet
)
897 return ( new OTextDetailsPage( pParent
, _rAttrSet
) );
899 // -----------------------------------------------------------------------
900 void OTextDetailsPage::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
902 OCommonBehaviourTabPage::fillControls(_rControlList
);
903 m_pTextConnectionHelper
->fillControls(_rControlList
);
906 // -----------------------------------------------------------------------
907 void OTextDetailsPage::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
909 OCommonBehaviourTabPage::fillWindows(_rControlList
);
910 m_pTextConnectionHelper
->fillWindows(_rControlList
);
913 // -----------------------------------------------------------------------
914 void OTextDetailsPage::implInitControls(const SfxItemSet
& _rSet
, sal_Bool _bSaveValue
)
916 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
917 sal_Bool bValid
, bReadonly
;
918 getFlags(_rSet
, bValid
, bReadonly
);
920 m_pTextConnectionHelper
->implInitControls(_rSet
, bValid
);
921 OCommonBehaviourTabPage::implInitControls(_rSet
, _bSaveValue
);
924 // -----------------------------------------------------------------------
925 sal_Bool
OTextDetailsPage::FillItemSet( SfxItemSet
& rSet
)
927 sal_Bool bChangedSomething
= OCommonBehaviourTabPage::FillItemSet(rSet
);
928 bChangedSomething
= m_pTextConnectionHelper
->FillItemSet(rSet
, bChangedSomething
);
929 return bChangedSomething
;
932 // -----------------------------------------------------------------------
933 sal_Bool
OTextDetailsPage::prepareLeave()
935 return m_pTextConnectionHelper
->prepareLeave();
938 //------------------------------------------------------------------------
939 SfxTabPage
* ODriversSettings::CreateGeneratedValuesPage( Window
* _pParent
, const SfxItemSet
& _rAttrSet
)
941 return new GeneratedValuesPage( _pParent
, _rAttrSet
);
944 //------------------------------------------------------------------------
945 SfxTabPage
* ODriversSettings::CreateSpecialSettingsPage( Window
* _pParent
, const SfxItemSet
& _rAttrSet
)
947 ::rtl::OUString eType
= ODbDataSourceAdministrationHelper::getDatasourceType( _rAttrSet
);
948 DataSourceMetaData
aMetaData( eType
);
949 return new SpecialSettingsPage( _pParent
, _rAttrSet
, aMetaData
);
951 //.........................................................................
953 //.........................................................................
955 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */