1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include "DBSetupConnectionPages.hxx"
23 #include "sqlmessage.hxx"
24 #include "dbu_dlg.hrc"
25 #include "dbu_resource.hrc"
26 #include <svl/itemset.hxx>
27 #include <svl/stritem.hxx>
28 #include <svl/eitem.hxx>
29 #include <svl/intitem.hxx>
30 #include "dsitems.hxx"
31 #include "dsnItem.hxx"
32 #include "dbaccess_helpid.hrc"
33 #include "localresaccess.hxx"
34 #include <vcl/msgbox.hxx>
35 #include <vcl/mnemonic.hxx>
36 #include <svl/cjkoptions.hxx>
38 #include <jvmaccess/virtualmachine.hxx>
40 #include <connectivity/CommonTools.hxx>
41 #include "DriverSettings.hxx"
42 #include "dbadmin.hxx"
43 #include <comphelper/types.hxx>
45 #include <com/sun/star/task/XInteractionHandler.hpp>
46 #include <com/sun/star/sdbc/XDriverAccess.hpp>
47 #include "dbustrings.hrc"
48 #include <svl/filenotation.hxx>
50 #include <unotools/localfilehelper.hxx>
51 #include <unotools/ucbhelper.hxx>
52 #include <ucbhelper/commandenvironment.hxx>
53 #include "finteraction.hxx"
54 #include <unotools/pathoptions.hxx>
55 #include <svtools/roadmapwizard.hxx>
56 #include "TextConnectionHelper.hxx"
57 #include <osl/diagnose.h>
61 using namespace ::com::sun::star
;
63 VclPtr
<OGenericAdministrationPage
> OTextConnectionPageSetup::CreateTextTabPage( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
65 return VclPtr
<OTextConnectionPageSetup
>::Create( pParent
, _rAttrSet
);
68 // OTextConnectionPageSetup
69 OTextConnectionPageSetup::OTextConnectionPageSetup( vcl::Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
70 :OConnectionTabPageSetup(pParent
, "DBWizTextPage", "dbaccess/ui/dbwiztextpage.ui", _rCoreAttrs
, STR_TEXT_HELPTEXT
, STR_TEXT_HEADERTEXT
, STR_TEXT_PATH_OR_FILE
)
73 m_pTextConnectionHelper
= VclPtr
<OTextConnectionHelper
>::Create( get
<VclVBox
>("TextPageContainer"), TC_EXTENSION
| TC_SEPARATORS
);
74 m_pTextConnectionHelper
->SetClickHandler(LINK( this, OTextConnectionPageSetup
, ImplGetExtensionHdl
) );
77 OTextConnectionPageSetup::~OTextConnectionPageSetup()
82 void OTextConnectionPageSetup::dispose()
84 m_pTextConnectionHelper
.disposeAndClear();
85 OConnectionTabPageSetup::dispose();
88 IMPL_LINK_NOARG_TYPED(OTextConnectionPageSetup
, ImplGetExtensionHdl
, OTextConnectionHelper
*, void)
90 SetRoadmapStateValue(!m_pTextConnectionHelper
->GetExtension().isEmpty() && OConnectionTabPageSetup::checkTestConnection());
94 bool OTextConnectionPageSetup::checkTestConnection()
96 bool bDoEnable
= OConnectionTabPageSetup::checkTestConnection();
97 bDoEnable
= !m_pTextConnectionHelper
->GetExtension().isEmpty() && bDoEnable
;
101 void OTextConnectionPageSetup::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
103 OConnectionTabPageSetup::fillControls(_rControlList
);
104 m_pTextConnectionHelper
->fillControls(_rControlList
);
106 void OTextConnectionPageSetup::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
108 OConnectionTabPageSetup::fillWindows(_rControlList
);
109 m_pTextConnectionHelper
->fillWindows(_rControlList
);
111 void OTextConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
113 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
114 bool bValid
, bReadonly
;
115 getFlags(_rSet
, bValid
, bReadonly
);
116 OConnectionTabPageSetup::implInitControls( _rSet
, _bSaveValue
);
117 m_pTextConnectionHelper
->implInitControls(_rSet
, bValid
);
120 bool OTextConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
122 bool bChangedSomething
= OConnectionTabPageSetup::FillItemSet(_rSet
);
123 bChangedSomething
= m_pTextConnectionHelper
->FillItemSet(*_rSet
, bChangedSomething
);
124 return bChangedSomething
;
127 bool OTextConnectionPageSetup::prepareLeave(){
128 return m_pTextConnectionHelper
->prepareLeave();
131 VclPtr
<OGenericAdministrationPage
> OLDAPConnectionPageSetup::CreateLDAPTabPage( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
133 return VclPtr
<OLDAPConnectionPageSetup
>::Create( pParent
, _rAttrSet
);
137 OLDAPConnectionPageSetup::OLDAPConnectionPageSetup( vcl::Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
138 :OGenericAdministrationPage(pParent
, "LDAPConnectionPage", "dbaccess/ui/ldapconnectionpage.ui",_rCoreAttrs
)
140 get(m_pFTHelpText
, "helpLabel");
141 get(m_pFTHostServer
, "hostNameLabel");
142 get(m_pETHostServer
, "hostNameEntry");
143 get(m_pFTBaseDN
, "baseDNLabel");
144 get(m_pETBaseDN
, "baseDNEntry");
145 get(m_pFTPortNumber
, "portNumLabel");
146 get(m_pNFPortNumber
, "portNumEntry");
147 m_pNFPortNumber
->SetUseThousandSep(false);
148 get(m_pFTDefaultPortNumber
, "portNumDefLabel");
149 get(m_pCBUseSSL
, "useSSLCheckbutton");
151 m_pETHostServer
->SetModifyHdl(getControlModifiedLink());
152 m_pETBaseDN
->SetModifyHdl(getControlModifiedLink());
153 m_pNFPortNumber
->SetModifyHdl(getControlModifiedLink());
154 m_pCBUseSSL
->SetToggleHdl(getControlModifiedLink());
155 SetRoadmapStateValue(false);
158 OLDAPConnectionPageSetup::~OLDAPConnectionPageSetup()
163 void OLDAPConnectionPageSetup::dispose()
165 m_pFTHelpText
.clear();
166 m_pFTHostServer
.clear();
167 m_pETHostServer
.clear();
170 m_pFTPortNumber
.clear();
171 m_pNFPortNumber
.clear();
172 m_pFTDefaultPortNumber
.clear();
174 OGenericAdministrationPage::dispose();
177 bool OLDAPConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
179 bool bChangedSomething
= false;
180 fillString(*_rSet
,m_pETBaseDN
,DSID_CONN_LDAP_BASEDN
, bChangedSomething
);
181 fillInt32(*_rSet
,m_pNFPortNumber
,DSID_CONN_LDAP_PORTNUMBER
,bChangedSomething
);
183 if ( m_pETHostServer
->IsValueChangedFromSaved() )
185 const DbuTypeCollectionItem
* pCollectionItem
= PTR_CAST(DbuTypeCollectionItem
, _rSet
->GetItem(DSID_TYPECOLLECTION
));
186 ::dbaccess::ODsnTypeCollection
* pCollection
= NULL
;
188 pCollection
= pCollectionItem
->getCollection();
189 OSL_ENSURE(pCollection
, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !");
192 OUString sUrl
= pCollection
->getPrefix( OUString("sdbc:address:ldap:"));
193 sUrl
+= m_pETHostServer
->GetText();
194 _rSet
->Put(SfxStringItem(DSID_CONNECTURL
, sUrl
));
195 bChangedSomething
= true;
199 fillBool(*_rSet
,m_pCBUseSSL
,DSID_CONN_LDAP_USESSL
,bChangedSomething
);
200 return bChangedSomething
;
202 void OLDAPConnectionPageSetup::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
204 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(m_pETHostServer
));
205 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(m_pETBaseDN
));
206 _rControlList
.push_back(new OSaveValueWrapper
<NumericField
>(m_pNFPortNumber
));
207 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(m_pCBUseSSL
));
209 void OLDAPConnectionPageSetup::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
211 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTHelpText
));
212 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTHostServer
));
213 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTBaseDN
));
214 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTPortNumber
));
215 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTDefaultPortNumber
));
217 void OLDAPConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
219 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
220 bool bValid
, bReadonly
;
221 getFlags(_rSet
, bValid
, bReadonly
);
223 SFX_ITEMSET_GET(_rSet
, pBaseDN
, SfxStringItem
, DSID_CONN_LDAP_BASEDN
, true);
224 SFX_ITEMSET_GET(_rSet
, pPortNumber
, SfxInt32Item
, DSID_CONN_LDAP_PORTNUMBER
, true);
228 m_pETBaseDN
->SetText(pBaseDN
->GetValue());
229 m_pNFPortNumber
->SetValue(pPortNumber
->GetValue());
231 OGenericAdministrationPage::implInitControls(_rSet
, _bSaveValue
);
235 IMPL_LINK(OLDAPConnectionPageSetup
, OnEditModified
, Edit
*, /*_pEdit*/)
237 bool bRoadmapState
= ((!m_pETHostServer
->GetText().isEmpty() ) && ( !m_pETBaseDN
->GetText().isEmpty() ) && (!m_pFTPortNumber
->GetText().isEmpty() ));
238 SetRoadmapStateValue(bRoadmapState
);
243 VclPtr
<OMySQLIntroPageSetup
> OMySQLIntroPageSetup::CreateMySQLIntroTabPage( vcl::Window
* _pParent
, const SfxItemSet
& _rAttrSet
)
245 return VclPtr
<OMySQLIntroPageSetup
>::Create( _pParent
, _rAttrSet
);
249 OMySQLIntroPageSetup::OMySQLIntroPageSetup( vcl::Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
250 :OGenericAdministrationPage(pParent
, "DBWizMysqlIntroPage", "dbaccess/ui/dbwizmysqlintropage.ui", _rCoreAttrs
)
252 get(m_pODBCDatabase
, "odbc");
253 get(m_pJDBCDatabase
, "jdbc");
254 get(m_pNATIVEDatabase
, "directly");
256 m_pODBCDatabase
->SetToggleHdl(LINK(this, OMySQLIntroPageSetup
, OnSetupModeSelected
));
257 m_pJDBCDatabase
->SetToggleHdl(LINK(this, OMySQLIntroPageSetup
, OnSetupModeSelected
));
258 m_pNATIVEDatabase
->SetToggleHdl(LINK(this, OMySQLIntroPageSetup
, OnSetupModeSelected
));
261 OMySQLIntroPageSetup::~OMySQLIntroPageSetup()
266 void OMySQLIntroPageSetup::dispose()
268 m_pODBCDatabase
.clear();
269 m_pJDBCDatabase
.clear();
270 m_pNATIVEDatabase
.clear();
271 OGenericAdministrationPage::dispose();
274 IMPL_LINK(OMySQLIntroPageSetup
, OnSetupModeSelected
, RadioButton
*, /*_pBox*/)
276 maClickHdl
.Call( this );
280 void OMySQLIntroPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool /*_bSaveValue*/)
282 // show the "Connect directly" option only if the driver is installed
283 const DbuTypeCollectionItem
* pCollectionItem
= PTR_CAST(DbuTypeCollectionItem
, _rSet
.GetItem(DSID_TYPECOLLECTION
));
284 bool bHasMySQLNative
= ( pCollectionItem
!= NULL
) && pCollectionItem
->getCollection()->hasDriver( "sdbc:mysqlc:" );
285 if ( bHasMySQLNative
)
286 m_pNATIVEDatabase
->Show();
288 // if any of the options is checked, then there's nothing to do
289 if ( m_pODBCDatabase
->IsChecked() || m_pJDBCDatabase
->IsChecked() || m_pNATIVEDatabase
->IsChecked() )
292 // prefer "native" or "JDBC"
293 if ( bHasMySQLNative
)
294 m_pNATIVEDatabase
->Check();
296 m_pJDBCDatabase
->Check();
299 void OMySQLIntroPageSetup::fillControls(::std::vector
< ISaveValueWrapper
* >& /*_rControlList*/)
303 void OMySQLIntroPageSetup::fillWindows(::std::vector
< ISaveValueWrapper
* >& /*_rControlList*/)
307 bool OMySQLIntroPageSetup::FillItemSet(SfxItemSet
* /*_rSet*/)
309 OSL_FAIL("Who called me?! Please ask oj for more information.");
313 OMySQLIntroPageSetup::ConnectionType
OMySQLIntroPageSetup::getMySQLMode()
315 if (m_pJDBCDatabase
->IsChecked())
317 else if (m_pNATIVEDatabase
->IsChecked())
323 // MySQLNativeSetupPage
324 MySQLNativeSetupPage::MySQLNativeSetupPage( vcl::Window
* _pParent
, const SfxItemSet
& _rCoreAttrs
)
325 :OGenericAdministrationPage( _pParent
, "DBWizMysqlNativePage", "dbaccess/ui/dbwizmysqlnativepage.ui", _rCoreAttrs
)
326 ,m_aMySQLSettings ( VclPtr
<MySQLNativeSettings
>::Create(*get
<VclVBox
>("MySQLSettingsContainer"), getControlModifiedLink()) )
328 get(m_pHelpText
, "helptext");
329 m_aMySQLSettings
->Show();
331 SetRoadmapStateValue(false);
334 MySQLNativeSetupPage::~MySQLNativeSetupPage()
339 void MySQLNativeSetupPage::dispose()
341 m_aMySQLSettings
.disposeAndClear();
343 OGenericAdministrationPage::dispose();
346 VclPtr
<OGenericAdministrationPage
> MySQLNativeSetupPage::Create( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
348 return VclPtr
<MySQLNativeSetupPage
>::Create( pParent
, _rAttrSet
);
351 void MySQLNativeSetupPage::fillControls( ::std::vector
< ISaveValueWrapper
* >& _rControlList
)
353 m_aMySQLSettings
->fillControls( _rControlList
);
356 void MySQLNativeSetupPage::fillWindows( ::std::vector
< ISaveValueWrapper
* >& _rControlList
)
358 _rControlList
.push_back( new ODisableWrapper
< FixedText
>( m_pHelpText
) );
359 m_aMySQLSettings
->fillWindows( _rControlList
);
362 bool MySQLNativeSetupPage::FillItemSet( SfxItemSet
* _rSet
)
364 return m_aMySQLSettings
->FillItemSet( _rSet
);
367 void MySQLNativeSetupPage::implInitControls( const SfxItemSet
& _rSet
, bool _bSaveValue
)
369 m_aMySQLSettings
->implInitControls( _rSet
);
371 OGenericAdministrationPage::implInitControls( _rSet
, _bSaveValue
);
376 Link
<> MySQLNativeSetupPage::getControlModifiedLink()
378 return LINK( this, MySQLNativeSetupPage
, OnModified
);
381 IMPL_LINK( MySQLNativeSetupPage
, OnModified
, Edit
*, _pEdit
)
383 SetRoadmapStateValue( m_aMySQLSettings
->canAdvance() );
385 return OGenericAdministrationPage::getControlModifiedLink().Call( _pEdit
);
388 // OMySQLJDBCConnectionPageSetup
389 OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( vcl::Window
* pParent
, const SfxItemSet
& _rCoreAttrs
,sal_uInt16 _nPortId
, sal_uInt16 _nDefaultPortResId
, sal_uInt16 _nHelpTextResId
, sal_uInt16 _nHeaderTextResId
, sal_uInt16 _nDriverClassId
)
390 :OGenericAdministrationPage(pParent
, "SpecialJDBCConnectionPage", "dbaccess/ui/specialjdbcconnectionpage.ui", _rCoreAttrs
)
393 get(m_pHeaderText
, "header");
394 get(m_pFTHelpText
, "helpLabel");
395 get(m_pFTDatabasename
, "dbNameLabel");
396 get(m_pETDatabasename
, "dbNameEntry");
397 get(m_pFTHostname
, "hostNameLabel");
398 get(m_pETHostname
, "hostNameEntry");
399 get(m_pFTPortNumber
, "portNumLabel");
400 get(m_pFTDefaultPortNumber
, "portNumDefLabel");
401 get(m_pNFPortNumber
, "portNumEntry");
402 m_pNFPortNumber
->SetUseThousandSep(false);
403 get(m_pFTDriverClass
, "jdbcDriverLabel");
404 get(m_pETDriverClass
, "jdbcDriverEntry");
405 get(m_pPBTestJavaDriver
, "testDriverButton");
407 m_pFTDriverClass
->SetText(OUString(ModuleRes(_nDriverClassId
)));
409 m_pFTDefaultPortNumber
->SetText(OUString(ModuleRes(_nDefaultPortResId
)));
410 OUString sHelpText
= OUString(ModuleRes(_nHelpTextResId
));
411 m_pFTHelpText
->SetText(sHelpText
);
412 //TODO this code snippet is redundant
413 m_pHeaderText
->SetText(ModuleRes(_nHeaderTextResId
));
415 m_pETDatabasename
->SetModifyHdl(getControlModifiedLink());
416 m_pETHostname
->SetModifyHdl(getControlModifiedLink());
417 m_pNFPortNumber
->SetModifyHdl(getControlModifiedLink());
419 m_pETDriverClass
->SetModifyHdl(LINK(this, OGeneralSpecialJDBCConnectionPageSetup
, OnEditModified
));
420 m_pPBTestJavaDriver
->SetClickHdl(LINK(this,OGeneralSpecialJDBCConnectionPageSetup
,OnTestJavaClickHdl
));
422 SFX_ITEMSET_GET(_rCoreAttrs
, pUrlItem
, SfxStringItem
, DSID_CONNECTURL
, true);
423 SFX_ITEMSET_GET(_rCoreAttrs
, pTypesItem
, DbuTypeCollectionItem
, DSID_TYPECOLLECTION
, true);
424 ::dbaccess::ODsnTypeCollection
* pTypeCollection
= pTypesItem
? pTypesItem
->getCollection() : NULL
;
425 if (pTypeCollection
&& pUrlItem
&& pUrlItem
->GetValue().getLength() )
427 m_sDefaultJdbcDriverName
= pTypeCollection
->getJavaDriverClass(pUrlItem
->GetValue());
430 SetRoadmapStateValue(false);
433 OGeneralSpecialJDBCConnectionPageSetup::~OGeneralSpecialJDBCConnectionPageSetup()
438 void OGeneralSpecialJDBCConnectionPageSetup::dispose()
440 m_pHeaderText
.clear();
441 m_pFTHelpText
.clear();
442 m_pFTDatabasename
.clear();
443 m_pETDatabasename
.clear();
444 m_pFTHostname
.clear();
445 m_pETHostname
.clear();
446 m_pFTPortNumber
.clear();
447 m_pFTDefaultPortNumber
.clear();
448 m_pNFPortNumber
.clear();
449 m_pFTDriverClass
.clear();
450 m_pETDriverClass
.clear();
451 m_pPBTestJavaDriver
.clear();
452 OGenericAdministrationPage::dispose();
455 VclPtr
<OGenericAdministrationPage
> OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
457 return VclPtr
<OGeneralSpecialJDBCConnectionPageSetup
>::Create( pParent
,
459 DSID_MYSQL_PORTNUMBER
,
461 STR_MYSQLJDBC_HELPTEXT
,
462 STR_MYSQLJDBC_HEADERTEXT
,
463 STR_MYSQL_DRIVERCLASSTEXT
);
466 VclPtr
<OGenericAdministrationPage
> OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
468 return VclPtr
<OGeneralSpecialJDBCConnectionPageSetup
>::Create( pParent
,
470 DSID_ORACLE_PORTNUMBER
,
473 STR_ORACLE_HEADERTEXT
,
474 STR_ORACLE_DRIVERCLASSTEXT
);
477 void OGeneralSpecialJDBCConnectionPageSetup::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
479 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(m_pETDatabasename
));
480 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(m_pETDriverClass
));
481 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(m_pETHostname
));
482 _rControlList
.push_back(new OSaveValueWrapper
<NumericField
>(m_pNFPortNumber
));
484 void OGeneralSpecialJDBCConnectionPageSetup::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
486 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTHelpText
));
487 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTDatabasename
));
488 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTHostname
));
489 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTPortNumber
));
490 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTDefaultPortNumber
));
491 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTDriverClass
));
494 bool OGeneralSpecialJDBCConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
496 bool bChangedSomething
= false;
497 fillString(*_rSet
,m_pETDriverClass
,DSID_JDBCDRIVERCLASS
,bChangedSomething
);
498 fillString(*_rSet
,m_pETHostname
,DSID_CONN_HOSTNAME
,bChangedSomething
);
499 fillString(*_rSet
,m_pETDatabasename
,DSID_DATABASENAME
,bChangedSomething
);
500 fillInt32(*_rSet
,m_pNFPortNumber
,m_nPortId
,bChangedSomething
);
501 return bChangedSomething
;
504 void OGeneralSpecialJDBCConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
506 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
507 bool bValid
, bReadonly
;
508 getFlags(_rSet
, bValid
, bReadonly
);
510 SFX_ITEMSET_GET(_rSet
, pDatabaseName
, SfxStringItem
, DSID_DATABASENAME
, true);
511 SFX_ITEMSET_GET(_rSet
, pDrvItem
, SfxStringItem
, DSID_JDBCDRIVERCLASS
, true);
512 SFX_ITEMSET_GET(_rSet
, pHostName
, SfxStringItem
, DSID_CONN_HOSTNAME
, true);
513 SFX_ITEMSET_GET(_rSet
, pPortNumber
, SfxInt32Item
, m_nPortId
, true);
517 m_pETDatabasename
->SetText(pDatabaseName
->GetValue());
518 m_pETDatabasename
->ClearModifyFlag();
520 m_pETDriverClass
->SetText(pDrvItem
->GetValue());
521 m_pETDriverClass
->ClearModifyFlag();
523 m_pETHostname
->SetText(pHostName
->GetValue());
524 m_pETHostname
->ClearModifyFlag();
526 m_pNFPortNumber
->SetValue(pPortNumber
->GetValue());
527 m_pNFPortNumber
->ClearModifyFlag();
529 OGenericAdministrationPage::implInitControls(_rSet
, _bSaveValue
);
531 // to get the correct value when saveValue was called by base class
532 if ( m_pETDriverClass
->GetText().trim().isEmpty() )
534 m_pETDriverClass
->SetText(m_sDefaultJdbcDriverName
);
535 m_pETDriverClass
->SetModifyFlag();
539 bool bRoadmapState
= ((!m_pETDatabasename
->GetText().isEmpty() ) && (!m_pETHostname
->GetText().isEmpty()) && (!m_pNFPortNumber
->GetText().isEmpty() ) && ( !m_pETDriverClass
->GetText().isEmpty() ));
540 SetRoadmapStateValue(bRoadmapState
);
543 IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup
, OnTestJavaClickHdl
, PushButton
*, /*_pButton*/)
545 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
547 bool bSuccess
= false;
548 #if HAVE_FEATURE_JAVA
551 if ( !m_pETDriverClass
->GetText().trim().isEmpty() )
553 // TODO change jvmaccess
554 ::rtl::Reference
< jvmaccess::VirtualMachine
> xJVM
= ::connectivity::getJavaVM( m_pAdminDialog
->getORB() );
555 m_pETDriverClass
->SetText(m_pETDriverClass
->GetText().trim()); // fdo#68341
556 bSuccess
= ::connectivity::existsJavaClassByName(xJVM
,m_pETDriverClass
->GetText());
559 catch(::com::sun::star::uno::Exception
&)
563 const sal_uInt16 nMessage
= bSuccess
? STR_JDBCDRIVER_SUCCESS
: STR_JDBCDRIVER_NO_SUCCESS
;
564 const OSQLMessageBox::MessageType mt
= bSuccess
? OSQLMessageBox::Info
: OSQLMessageBox::Error
;
565 ScopedVclPtrInstance
< OSQLMessageBox
> aMsg( this, OUString( ModuleRes( nMessage
) ), OUString(), WB_OK
| WB_DEF_OK
, mt
);
570 IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup
, OnEditModified
, Edit
*, _pEdit
)
572 if ( _pEdit
== m_pETDriverClass
)
573 m_pPBTestJavaDriver
->Enable( !m_pETDriverClass
->GetText().trim().isEmpty() );
574 bool bRoadmapState
= ((!m_pETDatabasename
->GetText().isEmpty() ) && ( !m_pETHostname
->GetText().isEmpty() ) && (!m_pNFPortNumber
->GetText().isEmpty() ) && ( !m_pETDriverClass
->GetText().trim().isEmpty() ));
575 SetRoadmapStateValue(bRoadmapState
);
580 VclPtr
<OGenericAdministrationPage
> OJDBCConnectionPageSetup::CreateJDBCTabPage( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
582 return VclPtr
<OJDBCConnectionPageSetup
>::Create( pParent
, _rAttrSet
);
585 // OMySQLJDBCConnectionPageSetup
586 OJDBCConnectionPageSetup::OJDBCConnectionPageSetup( vcl::Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
587 :OConnectionTabPageSetup(pParent
, "JDBCConnectionPage", "dbaccess/ui/jdbcconnectionpage.ui", _rCoreAttrs
,
588 STR_JDBC_HELPTEXT
, STR_JDBC_HEADERTEXT
, STR_COMMONURL
)
590 get(m_pFTDriverClass
, "jdbcLabel");
591 get(m_pETDriverClass
, "jdbcEntry");
592 get(m_pPBTestJavaDriver
, "jdbcButton");
593 m_pETDriverClass
->SetModifyHdl(LINK(this, OJDBCConnectionPageSetup
, OnEditModified
));
594 m_pPBTestJavaDriver
->SetClickHdl(LINK(this,OJDBCConnectionPageSetup
,OnTestJavaClickHdl
));
597 OJDBCConnectionPageSetup::~OJDBCConnectionPageSetup()
602 void OJDBCConnectionPageSetup::dispose()
604 m_pFTDriverClass
.clear();
605 m_pETDriverClass
.clear();
606 m_pPBTestJavaDriver
.clear();
607 OConnectionTabPageSetup::dispose();
610 void OJDBCConnectionPageSetup::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
612 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(m_pETDriverClass
));
615 void OJDBCConnectionPageSetup::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
617 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTDriverClass
));
620 bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
622 bool bChangedSomething
= OConnectionTabPageSetup::FillItemSet(_rSet
);
623 fillString(*_rSet
,m_pETDriverClass
,DSID_JDBCDRIVERCLASS
,bChangedSomething
);
624 return bChangedSomething
;
627 void OJDBCConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
629 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
630 bool bValid
, bReadonly
;
631 getFlags(_rSet
, bValid
, bReadonly
);
633 SFX_ITEMSET_GET(_rSet
, pDrvItem
, SfxStringItem
, DSID_JDBCDRIVERCLASS
, true);
637 if ( !pDrvItem
->GetValue().getLength() )
639 OUString sDefaultJdbcDriverName
= m_pCollection
->getJavaDriverClass(m_eType
);
640 if ( !sDefaultJdbcDriverName
.isEmpty() )
642 m_pETDriverClass
->SetText(sDefaultJdbcDriverName
);
643 m_pETDriverClass
->SetModifyFlag();
648 m_pETDriverClass
->SetText(pDrvItem
->GetValue());
649 m_pETDriverClass
->ClearModifyFlag();
652 bool bEnable
= pDrvItem
->GetValue().getLength() != 0;
653 m_pPBTestJavaDriver
->Enable(bEnable
);
654 OConnectionTabPageSetup::implInitControls(_rSet
, _bSaveValue
);
656 SetRoadmapStateValue(checkTestConnection());
659 bool OJDBCConnectionPageSetup::checkTestConnection()
661 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
662 bool bEnableTestConnection
= !m_pConnectionURL
->IsVisible() || !m_pConnectionURL
->GetTextNoPrefix().isEmpty();
663 bEnableTestConnection
= bEnableTestConnection
&& (!m_pETDriverClass
->GetText().isEmpty());
664 return bEnableTestConnection
;
667 IMPL_LINK(OJDBCConnectionPageSetup
, OnTestJavaClickHdl
, PushButton
*, /*_pButton*/)
669 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
670 bool bSuccess
= false;
671 #if HAVE_FEATURE_JAVA
674 if ( !m_pETDriverClass
->GetText().isEmpty() )
676 // TODO change jvmaccess
677 ::rtl::Reference
< jvmaccess::VirtualMachine
> xJVM
= ::connectivity::getJavaVM( m_pAdminDialog
->getORB() );
678 m_pETDriverClass
->SetText(m_pETDriverClass
->GetText().trim()); // fdo#68341
679 bSuccess
= xJVM
.is() && ::connectivity::existsJavaClassByName(xJVM
,m_pETDriverClass
->GetText());
682 catch(::com::sun::star::uno::Exception
&)
686 sal_uInt16 nMessage
= bSuccess
? STR_JDBCDRIVER_SUCCESS
: STR_JDBCDRIVER_NO_SUCCESS
;
687 ScopedVclPtrInstance
< OSQLMessageBox
> aMsg( this, OUString( ModuleRes( nMessage
) ), OUString() );
692 IMPL_LINK(OJDBCConnectionPageSetup
, OnEditModified
, Edit
*, _pEdit
)
694 if ( _pEdit
== m_pETDriverClass
)
695 m_pPBTestJavaDriver
->Enable( !m_pETDriverClass
->GetText().isEmpty() );
696 SetRoadmapStateValue(checkTestConnection());
697 // tell the listener we were modified
702 VclPtr
<OGenericAdministrationPage
> OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
704 return VclPtr
<OSpreadSheetConnectionPageSetup
>::Create( pParent
, _rAttrSet
);
708 OSpreadSheetConnectionPageSetup::OSpreadSheetConnectionPageSetup( vcl::Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
709 :OConnectionTabPageSetup(pParent
, "DBWizSpreadsheetPage", "dbaccess/ui/dbwizspreadsheetpage.ui", _rCoreAttrs
, STR_SPREADSHEET_HELPTEXT
, STR_SPREADSHEET_HEADERTEXT
, STR_SPREADSHEETPATH
)
711 get(m_pPasswordrequired
, "passwordrequired");
712 m_pPasswordrequired
->SetToggleHdl(getControlModifiedLink());
715 OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup()
720 void OSpreadSheetConnectionPageSetup::dispose()
722 m_pPasswordrequired
.clear();
723 OConnectionTabPageSetup::dispose();
726 void OSpreadSheetConnectionPageSetup::fillWindows(::std::vector
< ISaveValueWrapper
* >& /*_rControlList*/)
730 void OSpreadSheetConnectionPageSetup::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
732 OConnectionTabPageSetup::fillControls(_rControlList
);
733 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(m_pPasswordrequired
));
737 void OSpreadSheetConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
739 OConnectionTabPageSetup::implInitControls(_rSet
, _bSaveValue
);
742 bool OSpreadSheetConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
744 bool bChangedSomething
= OConnectionTabPageSetup::FillItemSet(_rSet
);
745 fillBool(*_rSet
,m_pPasswordrequired
,DSID_PASSWORDREQUIRED
,bChangedSomething
);
746 return bChangedSomething
;
749 VclPtr
<OGenericAdministrationPage
> OAuthentificationPageSetup::CreateAuthentificationTabPage( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
751 return VclPtr
<OAuthentificationPageSetup
>::Create( pParent
, _rAttrSet
);
755 OAuthentificationPageSetup::OAuthentificationPageSetup( vcl::Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
756 :OGenericAdministrationPage(pParent
, "AuthentificationPage", "dbaccess/ui/authentificationpage.ui", _rCoreAttrs
)
758 get(m_pFTHelpText
, "helptext");
759 get(m_pFTUserName
, "generalUserNameLabel");
760 get(m_pETUserName
, "generalUserNameEntry");
761 get(m_pCBPasswordRequired
, "passRequiredCheckbutton");
762 get(m_pPBTestConnection
, "testConnectionButton");
763 m_pETUserName
->SetModifyHdl(getControlModifiedLink());
764 m_pCBPasswordRequired
->SetClickHdl(getControlModifiedLink());
765 m_pPBTestConnection
->SetClickHdl(LINK(this,OGenericAdministrationPage
,OnTestConnectionClickHdl
));
767 LayoutHelper::fitSizeRightAligned( *m_pPBTestConnection
);
770 OAuthentificationPageSetup::~OAuthentificationPageSetup()
775 void OAuthentificationPageSetup::dispose()
777 m_pFTHelpText
.clear();
778 m_pFTUserName
.clear();
779 m_pETUserName
.clear();
780 m_pCBPasswordRequired
.clear();
781 m_pPBTestConnection
.clear();
782 OGenericAdministrationPage::dispose();
785 void OAuthentificationPageSetup::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
787 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTHelpText
));
788 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTUserName
));
789 _rControlList
.push_back(new ODisableWrapper
<PushButton
>(m_pPBTestConnection
));
792 void OAuthentificationPageSetup::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
794 _rControlList
.push_back(new OSaveValueWrapper
<Edit
>(m_pETUserName
));
795 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(m_pCBPasswordRequired
));
798 void OAuthentificationPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool /*_bSaveValue*/)
800 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
801 bool bValid
, bReadonly
;
802 getFlags(_rSet
, bValid
, bReadonly
);
803 SFX_ITEMSET_GET(_rSet
, pUidItem
, SfxStringItem
, DSID_USER
, true);
804 SFX_ITEMSET_GET(_rSet
, pAllowEmptyPwd
, SfxBoolItem
, DSID_PASSWORDREQUIRED
, true);
806 m_pETUserName
->SetText(pUidItem
->GetValue());
807 m_pCBPasswordRequired
->Check(pAllowEmptyPwd
->GetValue());
809 m_pETUserName
->ClearModifyFlag();
812 bool OAuthentificationPageSetup::FillItemSet( SfxItemSet
* _rSet
)
814 bool bChangedSomething
= false;
816 if (m_pETUserName
->IsValueChangedFromSaved())
818 _rSet
->Put(SfxStringItem(DSID_USER
, m_pETUserName
->GetText()));
819 _rSet
->Put(SfxStringItem(DSID_PASSWORD
, OUString()));
820 bChangedSomething
= true;
822 fillBool(*_rSet
,m_pCBPasswordRequired
,DSID_PASSWORDREQUIRED
,bChangedSomething
);
823 return bChangedSomething
;
826 VclPtr
<OGenericAdministrationPage
> OFinalDBPageSetup::CreateFinalDBTabPageSetup( vcl::Window
* pParent
, const SfxItemSet
& _rAttrSet
)
828 return VclPtr
<OFinalDBPageSetup
>::Create( pParent
, _rAttrSet
);
832 OFinalDBPageSetup::OFinalDBPageSetup(vcl::Window
* pParent
, const SfxItemSet
& _rCoreAttrs
)
833 : OGenericAdministrationPage(pParent
, "PageFinal",
834 "dbaccess/ui/finalpagewizard.ui", _rCoreAttrs
)
836 get(m_pFTFinalHeader
, "headerText");
837 get(m_pFTFinalHelpText
, "helpText");
838 get(m_pRBRegisterDataSource
, "yesregister");
839 get(m_pRBDontregisterDataSource
, "noregister");
840 get(m_pFTAdditionalSettings
, "additionalText");
841 get(m_pCBOpenAfterwards
, "openediting");
842 get(m_pCBStartTableWizard
, "usewizard");
843 get(m_pFTFinalText
, "finishText");
845 m_pCBOpenAfterwards
->SetClickHdl(LINK(this, OFinalDBPageSetup
, OnOpenSelected
));
846 m_pCBStartTableWizard
->SetClickHdl(getControlModifiedLink());
847 m_pRBRegisterDataSource
->SetState(true);
850 OFinalDBPageSetup::~OFinalDBPageSetup()
855 void OFinalDBPageSetup::dispose()
857 m_pFTFinalHeader
.clear();
858 m_pFTFinalHelpText
.clear();
859 m_pRBRegisterDataSource
.clear();
860 m_pRBDontregisterDataSource
.clear();
861 m_pFTAdditionalSettings
.clear();
862 m_pCBOpenAfterwards
.clear();
863 m_pCBStartTableWizard
.clear();
864 m_pFTFinalText
.clear();
865 OGenericAdministrationPage::dispose();
868 bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered()
870 return m_pRBRegisterDataSource
->IsChecked() && m_pRBRegisterDataSource
->IsEnabled();
873 bool OFinalDBPageSetup::IsDatabaseDocumentToBeOpened()
875 return m_pCBOpenAfterwards
->IsChecked() && m_pCBOpenAfterwards
->IsEnabled();
878 bool OFinalDBPageSetup::IsTableWizardToBeStarted()
880 return m_pCBStartTableWizard
->IsChecked() && m_pCBStartTableWizard
->IsEnabled();
883 void OFinalDBPageSetup::fillWindows(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
885 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTFinalHeader
));
886 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTFinalHelpText
));
887 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTAdditionalSettings
));
888 _rControlList
.push_back(new ODisableWrapper
<FixedText
>(m_pFTFinalText
));
891 void OFinalDBPageSetup::fillControls(::std::vector
< ISaveValueWrapper
* >& _rControlList
)
893 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(m_pCBOpenAfterwards
));
894 _rControlList
.push_back(new OSaveValueWrapper
<CheckBox
>(m_pCBStartTableWizard
));
895 _rControlList
.push_back(new OSaveValueWrapper
<RadioButton
>(m_pRBRegisterDataSource
));
896 _rControlList
.push_back(new OSaveValueWrapper
<RadioButton
>(m_pRBDontregisterDataSource
));
899 void OFinalDBPageSetup::implInitControls(const SfxItemSet
& /*_rSet*/, bool /*_bSaveValue*/)
901 m_pCBOpenAfterwards
->Check();
904 void OFinalDBPageSetup::enableTableWizardCheckBox( bool _bSupportsTableCreation
)
906 m_pCBStartTableWizard
->Enable(_bSupportsTableCreation
);
909 bool OFinalDBPageSetup::FillItemSet( SfxItemSet
* /*_rSet*/ )
914 IMPL_LINK(OFinalDBPageSetup
, OnOpenSelected
, CheckBox
*, _pBox
)
916 m_pCBStartTableWizard
->Enable( _pBox
->IsEnabled() && _pBox
->IsChecked() );
925 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */