Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <config_features.h>
21 :
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>
37 : #if HAVE_FEATURE_JAVA
38 : #include <jvmaccess/virtualmachine.hxx>
39 : #endif
40 : #include <connectivity/CommonTools.hxx>
41 : #include "DriverSettings.hxx"
42 : #include "dbadmin.hxx"
43 : #include <comphelper/types.hxx>
44 :
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>
49 :
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>
58 :
59 : namespace dbaui
60 : {
61 : using namespace ::com::sun::star;
62 :
63 0 : OGenericAdministrationPage* OTextConnectionPageSetup::CreateTextTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
64 : {
65 0 : return ( new OTextConnectionPageSetup( pParent, _rAttrSet ) );
66 : }
67 :
68 : // OTextConnectionPageSetup
69 0 : OTextConnectionPageSetup::OTextConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
70 0 : :OConnectionTabPageSetup(pParent, "DBWizTextPage", "dbaccess/ui/dbwiztextpage.ui", _rCoreAttrs, STR_TEXT_HELPTEXT, STR_TEXT_HEADERTEXT, STR_TEXT_PATH_OR_FILE)
71 : {
72 :
73 0 : m_pTextConnectionHelper = new OTextConnectionHelper( get<VclVBox>("TextPageContainer"), TC_EXTENSION | TC_SEPARATORS );
74 0 : m_pTextConnectionHelper->SetClickHandler(LINK( this, OTextConnectionPageSetup, ImplGetExtensionHdl ) );
75 0 : }
76 :
77 0 : OTextConnectionPageSetup::~OTextConnectionPageSetup()
78 : {
79 0 : DELETEZ(m_pTextConnectionHelper);
80 :
81 0 : }
82 :
83 0 : IMPL_LINK(OTextConnectionPageSetup, ImplGetExtensionHdl, OTextConnectionHelper*, /*_pTextConnectionHelper*/)
84 : {
85 0 : SetRoadmapStateValue(!m_pTextConnectionHelper->GetExtension().isEmpty() && OConnectionTabPageSetup::checkTestConnection());
86 0 : callModifiedHdl();
87 0 : return sal_True;
88 : }
89 :
90 0 : bool OTextConnectionPageSetup::checkTestConnection()
91 : {
92 0 : bool bDoEnable = OConnectionTabPageSetup::checkTestConnection();
93 0 : bDoEnable = !m_pTextConnectionHelper->GetExtension().isEmpty() && bDoEnable;
94 0 : return bDoEnable;
95 : }
96 :
97 0 : void OTextConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
98 : {
99 0 : OConnectionTabPageSetup::fillControls(_rControlList);
100 0 : m_pTextConnectionHelper->fillControls(_rControlList);
101 0 : }
102 0 : void OTextConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
103 : {
104 0 : OConnectionTabPageSetup::fillWindows(_rControlList);
105 0 : m_pTextConnectionHelper->fillWindows(_rControlList);
106 0 : }
107 0 : void OTextConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
108 : {
109 : // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
110 : bool bValid, bReadonly;
111 0 : getFlags(_rSet, bValid, bReadonly);
112 0 : OConnectionTabPageSetup::implInitControls( _rSet, _bSaveValue);
113 0 : m_pTextConnectionHelper->implInitControls(_rSet, bValid);
114 0 : }
115 :
116 0 : bool OTextConnectionPageSetup::FillItemSet( SfxItemSet* _rSet )
117 : {
118 0 : bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
119 0 : bChangedSomething = m_pTextConnectionHelper->FillItemSet(*_rSet, bChangedSomething);
120 0 : return bChangedSomething;
121 : }
122 :
123 0 : bool OTextConnectionPageSetup::prepareLeave(){
124 0 : return m_pTextConnectionHelper->prepareLeave();
125 : }
126 :
127 0 : OGenericAdministrationPage* OLDAPConnectionPageSetup::CreateLDAPTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
128 : {
129 0 : return ( new OLDAPConnectionPageSetup( pParent, _rAttrSet ) );
130 : }
131 :
132 : // OLDAPPageSetup
133 0 : OLDAPConnectionPageSetup::OLDAPConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
134 0 : :OGenericAdministrationPage(pParent, "LDAPConnectionPage", "dbaccess/ui/ldapconnectionpage.ui",_rCoreAttrs)
135 : {
136 0 : get(m_pFTHelpText, "helpLabel");
137 0 : get(m_pFTHostServer, "hostNameLabel");
138 0 : get(m_pETHostServer, "hostNameEntry");
139 0 : get(m_pFTBaseDN, "baseDNLabel");
140 0 : get(m_pETBaseDN, "baseDNEntry");
141 0 : get(m_pFTPortNumber, "portNumLabel");
142 0 : get(m_pNFPortNumber, "portNumEntry");
143 0 : m_pNFPortNumber->SetUseThousandSep(false);
144 0 : get(m_pFTDefaultPortNumber, "portNumDefLabel");
145 0 : get(m_pCBUseSSL, "useSSLCheckbutton");
146 :
147 0 : m_pETHostServer->SetModifyHdl(getControlModifiedLink());
148 0 : m_pETBaseDN->SetModifyHdl(getControlModifiedLink());
149 0 : m_pNFPortNumber->SetModifyHdl(getControlModifiedLink());
150 0 : m_pCBUseSSL->SetToggleHdl(getControlModifiedLink());
151 0 : SetRoadmapStateValue(false);
152 0 : }
153 :
154 0 : bool OLDAPConnectionPageSetup::FillItemSet( SfxItemSet* _rSet )
155 : {
156 0 : bool bChangedSomething = false;
157 0 : fillString(*_rSet,m_pETBaseDN,DSID_CONN_LDAP_BASEDN, bChangedSomething);
158 0 : fillInt32(*_rSet,m_pNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
159 :
160 0 : if ( m_pETHostServer->IsValueChangedFromSaved() )
161 : {
162 0 : const DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet->GetItem(DSID_TYPECOLLECTION));
163 0 : ::dbaccess::ODsnTypeCollection* pCollection = NULL;
164 0 : if (pCollectionItem)
165 0 : pCollection = pCollectionItem->getCollection();
166 : OSL_ENSURE(pCollection, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !");
167 0 : if (pCollection)
168 : {
169 0 : OUString sUrl = pCollection->getPrefix( OUString("sdbc:address:ldap:"));
170 0 : sUrl += m_pETHostServer->GetText();
171 0 : _rSet->Put(SfxStringItem(DSID_CONNECTURL, sUrl));
172 0 : bChangedSomething = true;
173 : }
174 : }
175 :
176 0 : fillBool(*_rSet,m_pCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething);
177 0 : return bChangedSomething;
178 : }
179 0 : void OLDAPConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
180 : {
181 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pETHostServer));
182 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pETBaseDN));
183 0 : _rControlList.push_back(new OSaveValueWrapper<NumericField>(m_pNFPortNumber));
184 0 : _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pCBUseSSL));
185 0 : }
186 0 : void OLDAPConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
187 : {
188 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTHelpText));
189 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTHostServer));
190 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTBaseDN));
191 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTPortNumber));
192 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTDefaultPortNumber));
193 0 : }
194 0 : void OLDAPConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
195 : {
196 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
197 : bool bValid, bReadonly;
198 0 : getFlags(_rSet, bValid, bReadonly);
199 :
200 0 : SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, true);
201 0 : SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, true);
202 :
203 0 : if ( bValid )
204 : {
205 0 : m_pETBaseDN->SetText(pBaseDN->GetValue());
206 0 : m_pNFPortNumber->SetValue(pPortNumber->GetValue());
207 : }
208 0 : OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
209 0 : callModifiedHdl();
210 0 : }
211 :
212 0 : IMPL_LINK(OLDAPConnectionPageSetup, OnEditModified, Edit*, /*_pEdit*/)
213 : {
214 0 : bool bRoadmapState = ((!m_pETHostServer->GetText().isEmpty() ) && ( !m_pETBaseDN->GetText().isEmpty() ) && (!m_pFTPortNumber->GetText().isEmpty() ));
215 0 : SetRoadmapStateValue(bRoadmapState);
216 0 : callModifiedHdl();
217 0 : return 0L;
218 : }
219 :
220 0 : OMySQLIntroPageSetup* OMySQLIntroPageSetup::CreateMySQLIntroTabPage( vcl::Window* _pParent, const SfxItemSet& _rAttrSet )
221 : {
222 0 : return ( new OMySQLIntroPageSetup( _pParent, _rAttrSet) );
223 : }
224 :
225 :
226 0 : OMySQLIntroPageSetup::OMySQLIntroPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
227 0 : :OGenericAdministrationPage(pParent, "DBWizMysqlIntroPage", "dbaccess/ui/dbwizmysqlintropage.ui", _rCoreAttrs)
228 : {
229 0 : get(m_pODBCDatabase, "odbc");
230 0 : get(m_pJDBCDatabase, "jdbc");
231 0 : get(m_pNATIVEDatabase, "directly");
232 :
233 0 : m_pODBCDatabase->SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
234 0 : m_pJDBCDatabase->SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
235 0 : m_pNATIVEDatabase->SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
236 0 : }
237 :
238 0 : IMPL_LINK(OMySQLIntroPageSetup, OnSetupModeSelected, RadioButton*, /*_pBox*/)
239 : {
240 0 : maClickHdl.Call( this );
241 0 : return long(true);
242 : }
243 :
244 0 : OMySQLIntroPageSetup::~OMySQLIntroPageSetup()
245 : {
246 :
247 0 : }
248 :
249 0 : void OMySQLIntroPageSetup::implInitControls(const SfxItemSet& _rSet, bool /*_bSaveValue*/)
250 : {
251 : // show the "Connect directly" option only if the driver is installed
252 0 : const DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION));
253 0 : bool bHasMySQLNative = ( pCollectionItem != NULL ) && pCollectionItem->getCollection()->hasDriver( "sdbc:mysqlc:" );
254 0 : if ( bHasMySQLNative )
255 0 : m_pNATIVEDatabase->Show();
256 :
257 : // if any of the options is checked, then there's nothing to do
258 0 : if ( m_pODBCDatabase->IsChecked() || m_pJDBCDatabase->IsChecked() || m_pNATIVEDatabase->IsChecked() )
259 0 : return;
260 :
261 : // prefer "native" or "JDBC"
262 0 : if ( bHasMySQLNative )
263 0 : m_pNATIVEDatabase->Check();
264 : else
265 0 : m_pJDBCDatabase->Check();
266 : }
267 :
268 0 : void OMySQLIntroPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
269 : {
270 0 : }
271 :
272 0 : void OMySQLIntroPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
273 : {
274 0 : }
275 :
276 0 : bool OMySQLIntroPageSetup::FillItemSet(SfxItemSet* /*_rSet*/)
277 : {
278 : OSL_FAIL("Who called me?! Please ask oj for more information.");
279 0 : return true;
280 : }
281 :
282 0 : OMySQLIntroPageSetup::ConnectionType OMySQLIntroPageSetup::getMySQLMode()
283 : {
284 0 : if (m_pJDBCDatabase->IsChecked())
285 0 : return VIA_JDBC;
286 0 : else if (m_pNATIVEDatabase->IsChecked())
287 0 : return VIA_NATIVE;
288 : else
289 0 : return VIA_ODBC;
290 : }
291 :
292 : // MySQLNativeSetupPage
293 0 : MySQLNativeSetupPage::MySQLNativeSetupPage( vcl::Window* _pParent, const SfxItemSet& _rCoreAttrs )
294 : :OGenericAdministrationPage( _pParent, "DBWizMysqlNativePage", "dbaccess/ui/dbwizmysqlnativepage.ui", _rCoreAttrs )
295 0 : ,m_aMySQLSettings ( *get<VclVBox>("MySQLSettingsContainer"), getControlModifiedLink() )
296 : {
297 0 : get(m_pHelpText, "helptext");
298 0 : m_aMySQLSettings.Show();
299 :
300 0 : SetRoadmapStateValue(false);
301 0 : }
302 :
303 0 : OGenericAdministrationPage* MySQLNativeSetupPage::Create( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
304 : {
305 0 : return new MySQLNativeSetupPage( pParent, _rAttrSet );
306 : }
307 :
308 0 : void MySQLNativeSetupPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList )
309 : {
310 0 : m_aMySQLSettings.fillControls( _rControlList );
311 0 : }
312 :
313 0 : void MySQLNativeSetupPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
314 : {
315 0 : _rControlList.push_back( new ODisableWrapper< FixedText >( m_pHelpText ) );
316 0 : m_aMySQLSettings.fillWindows( _rControlList );
317 0 : }
318 :
319 0 : bool MySQLNativeSetupPage::FillItemSet( SfxItemSet* _rSet )
320 : {
321 0 : return m_aMySQLSettings.FillItemSet( _rSet );
322 : }
323 :
324 0 : void MySQLNativeSetupPage::implInitControls( const SfxItemSet& _rSet, bool _bSaveValue )
325 : {
326 0 : m_aMySQLSettings.implInitControls( _rSet );
327 :
328 0 : OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue );
329 :
330 0 : OnModified( NULL );
331 0 : }
332 :
333 0 : Link MySQLNativeSetupPage::getControlModifiedLink()
334 : {
335 0 : return LINK( this, MySQLNativeSetupPage, OnModified );
336 : }
337 :
338 0 : IMPL_LINK( MySQLNativeSetupPage, OnModified, Edit*, _pEdit )
339 : {
340 0 : SetRoadmapStateValue( m_aMySQLSettings.canAdvance() );
341 :
342 0 : return OGenericAdministrationPage::getControlModifiedLink().Call( _pEdit );
343 : }
344 :
345 : // OMySQLJDBCConnectionPageSetup
346 0 : OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId, sal_uInt16 _nDefaultPortResId, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderTextResId, sal_uInt16 _nDriverClassId)
347 : :OGenericAdministrationPage(pParent, "SpecialJDBCConnectionPage", "dbaccess/ui/specialjdbcconnectionpage.ui", _rCoreAttrs)
348 0 : ,m_nPortId(_nPortId)
349 : {
350 0 : get(m_pHeaderText, "header");
351 0 : get(m_pFTHelpText, "helpLabel");
352 0 : get(m_pFTDatabasename, "dbNameLabel");
353 0 : get(m_pETDatabasename, "dbNameEntry");
354 0 : get(m_pFTHostname, "hostNameLabel");
355 0 : get(m_pETHostname, "hostNameEntry");
356 0 : get(m_pFTPortNumber, "portNumLabel");
357 0 : get(m_pFTDefaultPortNumber, "portNumDefLabel");
358 0 : get(m_pNFPortNumber, "portNumEntry");
359 0 : m_pNFPortNumber->SetUseThousandSep(false);
360 0 : get(m_pFTDriverClass, "jdbcDriverLabel");
361 0 : get(m_pETDriverClass, "jdbcDriverEntry");
362 0 : get(m_pPBTestJavaDriver, "testDriverButton");
363 :
364 0 : m_pFTDriverClass->SetText(OUString(ModuleRes(_nDriverClassId)));
365 :
366 0 : m_pFTDefaultPortNumber->SetText(OUString(ModuleRes(_nDefaultPortResId)));
367 0 : OUString sHelpText = OUString(ModuleRes(_nHelpTextResId));
368 0 : m_pFTHelpText->SetText(sHelpText);
369 : //TODO this code snippet is redundant
370 0 : m_pHeaderText->SetText(ModuleRes(_nHeaderTextResId));
371 :
372 0 : m_pETDatabasename->SetModifyHdl(getControlModifiedLink());
373 0 : m_pETHostname->SetModifyHdl(getControlModifiedLink());
374 0 : m_pNFPortNumber->SetModifyHdl(getControlModifiedLink());
375 :
376 0 : m_pETDriverClass->SetModifyHdl(LINK(this, OGeneralSpecialJDBCConnectionPageSetup, OnEditModified));
377 0 : m_pPBTestJavaDriver->SetClickHdl(LINK(this,OGeneralSpecialJDBCConnectionPageSetup,OnTestJavaClickHdl));
378 :
379 0 : SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, true);
380 0 : SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, true);
381 0 : ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
382 0 : if (pTypeCollection && pUrlItem && pUrlItem->GetValue().getLength() )
383 : {
384 0 : m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
385 : }
386 :
387 0 : SetRoadmapStateValue(false);
388 0 : }
389 :
390 0 : OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
391 : {
392 : return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent,
393 : _rAttrSet,
394 : DSID_MYSQL_PORTNUMBER ,
395 : STR_MYSQL_DEFAULT,
396 : STR_MYSQLJDBC_HELPTEXT,
397 : STR_MYSQLJDBC_HEADERTEXT,
398 0 : STR_MYSQL_DRIVERCLASSTEXT) );
399 : }
400 :
401 0 : OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
402 : {
403 : return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent,
404 : _rAttrSet,
405 : DSID_ORACLE_PORTNUMBER,
406 : STR_ORACLE_DEFAULT,
407 : STR_ORACLE_HELPTEXT,
408 : STR_ORACLE_HEADERTEXT,
409 0 : STR_ORACLE_DRIVERCLASSTEXT) );
410 : }
411 :
412 0 : void OGeneralSpecialJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
413 : {
414 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pETDatabasename));
415 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pETDriverClass));
416 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pETHostname));
417 0 : _rControlList.push_back(new OSaveValueWrapper<NumericField>(m_pNFPortNumber));
418 0 : }
419 0 : void OGeneralSpecialJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
420 : {
421 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTHelpText));
422 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTDatabasename));
423 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTHostname));
424 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTPortNumber));
425 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTDefaultPortNumber));
426 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTDriverClass));
427 0 : }
428 :
429 0 : bool OGeneralSpecialJDBCConnectionPageSetup::FillItemSet( SfxItemSet* _rSet )
430 : {
431 0 : bool bChangedSomething = false;
432 0 : fillString(*_rSet,m_pETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
433 0 : fillString(*_rSet,m_pETHostname,DSID_CONN_HOSTNAME,bChangedSomething);
434 0 : fillString(*_rSet,m_pETDatabasename,DSID_DATABASENAME,bChangedSomething);
435 0 : fillInt32(*_rSet,m_pNFPortNumber,m_nPortId,bChangedSomething );
436 0 : return bChangedSomething;
437 : }
438 :
439 0 : void OGeneralSpecialJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
440 : {
441 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
442 : bool bValid, bReadonly;
443 0 : getFlags(_rSet, bValid, bReadonly);
444 :
445 0 : SFX_ITEMSET_GET(_rSet, pDatabaseName, SfxStringItem, DSID_DATABASENAME, true);
446 0 : SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, true);
447 0 : SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, true);
448 0 : SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, true);
449 :
450 0 : if ( bValid )
451 : {
452 0 : m_pETDatabasename->SetText(pDatabaseName->GetValue());
453 0 : m_pETDatabasename->ClearModifyFlag();
454 :
455 0 : m_pETDriverClass->SetText(pDrvItem->GetValue());
456 0 : m_pETDriverClass->ClearModifyFlag();
457 :
458 0 : m_pETHostname->SetText(pHostName->GetValue());
459 0 : m_pETHostname->ClearModifyFlag();
460 :
461 0 : m_pNFPortNumber->SetValue(pPortNumber->GetValue());
462 0 : m_pNFPortNumber->ClearModifyFlag();
463 : }
464 0 : OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
465 :
466 : // to get the correct value when saveValue was called by base class
467 0 : if ( m_pETDriverClass->GetText().trim().isEmpty() )
468 : {
469 0 : m_pETDriverClass->SetText(m_sDefaultJdbcDriverName);
470 0 : m_pETDriverClass->SetModifyFlag();
471 : }
472 0 : callModifiedHdl();
473 :
474 0 : bool bRoadmapState = ((!m_pETDatabasename->GetText().isEmpty() ) && (!m_pETHostname->GetText().isEmpty()) && (!m_pNFPortNumber->GetText().isEmpty() ) && ( !m_pETDriverClass->GetText().isEmpty() ));
475 0 : SetRoadmapStateValue(bRoadmapState);
476 0 : }
477 :
478 0 : IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
479 : {
480 : OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
481 :
482 0 : bool bSuccess = false;
483 : #if HAVE_FEATURE_JAVA
484 : try
485 : {
486 0 : if ( !m_pETDriverClass->GetText().trim().isEmpty() )
487 : {
488 : // TODO change jvmaccess
489 0 : ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() );
490 0 : m_pETDriverClass->SetText(m_pETDriverClass->GetText().trim()); // fdo#68341
491 0 : bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_pETDriverClass->GetText());
492 : }
493 : }
494 0 : catch(::com::sun::star::uno::Exception&)
495 : {
496 : }
497 : #endif
498 0 : const sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
499 0 : const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error;
500 0 : OSQLMessageBox aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt );
501 0 : aMsg.Execute();
502 0 : return 0L;
503 : }
504 :
505 0 : IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit)
506 : {
507 0 : if ( _pEdit == m_pETDriverClass )
508 0 : m_pPBTestJavaDriver->Enable( !m_pETDriverClass->GetText().trim().isEmpty() );
509 0 : bool bRoadmapState = ((!m_pETDatabasename->GetText().isEmpty() ) && ( !m_pETHostname->GetText().isEmpty() ) && (!m_pNFPortNumber->GetText().isEmpty() ) && ( !m_pETDriverClass->GetText().trim().isEmpty() ));
510 0 : SetRoadmapStateValue(bRoadmapState);
511 0 : callModifiedHdl();
512 0 : return 0L;
513 : }
514 :
515 0 : OGenericAdministrationPage* OJDBCConnectionPageSetup::CreateJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
516 : {
517 0 : return ( new OJDBCConnectionPageSetup( pParent, _rAttrSet));
518 : }
519 :
520 : // OMySQLJDBCConnectionPageSetup
521 0 : OJDBCConnectionPageSetup::OJDBCConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs)
522 : :OConnectionTabPageSetup(pParent, "JDBCConnectionPage", "dbaccess/ui/jdbcconnectionpage.ui", _rCoreAttrs,
523 0 : STR_JDBC_HELPTEXT, STR_JDBC_HEADERTEXT, STR_COMMONURL)
524 : {
525 0 : get(m_pFTDriverClass, "jdbcLabel");
526 0 : get(m_pETDriverClass, "jdbcEntry");
527 0 : get(m_pPBTestJavaDriver, "jdbcButton");
528 0 : m_pETDriverClass->SetModifyHdl(LINK(this, OJDBCConnectionPageSetup, OnEditModified));
529 0 : m_pPBTestJavaDriver->SetClickHdl(LINK(this,OJDBCConnectionPageSetup,OnTestJavaClickHdl));
530 0 : }
531 :
532 0 : void OJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
533 : {
534 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pETDriverClass));
535 0 : }
536 :
537 0 : void OJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
538 : {
539 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTDriverClass));
540 0 : }
541 :
542 0 : bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet* _rSet )
543 : {
544 0 : bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
545 0 : fillString(*_rSet,m_pETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
546 0 : return bChangedSomething;
547 : }
548 :
549 0 : void OJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
550 : {
551 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
552 : bool bValid, bReadonly;
553 0 : getFlags(_rSet, bValid, bReadonly);
554 :
555 0 : SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, true);
556 :
557 0 : if ( bValid )
558 : {
559 0 : if ( !pDrvItem->GetValue().getLength() )
560 : {
561 0 : OUString sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType);
562 0 : if ( !sDefaultJdbcDriverName.isEmpty() )
563 : {
564 0 : m_pETDriverClass->SetText(sDefaultJdbcDriverName);
565 0 : m_pETDriverClass->SetModifyFlag();
566 0 : }
567 : }
568 : else
569 : {
570 0 : m_pETDriverClass->SetText(pDrvItem->GetValue());
571 0 : m_pETDriverClass->ClearModifyFlag();
572 : }
573 : }
574 0 : bool bEnable = pDrvItem->GetValue().getLength() != 0;
575 0 : m_pPBTestJavaDriver->Enable(bEnable);
576 0 : OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
577 :
578 0 : SetRoadmapStateValue(checkTestConnection());
579 0 : }
580 :
581 0 : bool OJDBCConnectionPageSetup::checkTestConnection()
582 : {
583 : OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
584 0 : bool bEnableTestConnection = !m_pConnectionURL->IsVisible() || !m_pConnectionURL->GetTextNoPrefix().isEmpty();
585 0 : bEnableTestConnection = bEnableTestConnection && (!m_pETDriverClass->GetText().isEmpty());
586 0 : return bEnableTestConnection;
587 : }
588 :
589 0 : IMPL_LINK(OJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
590 : {
591 : OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
592 0 : bool bSuccess = false;
593 : #if HAVE_FEATURE_JAVA
594 : try
595 : {
596 0 : if ( !m_pETDriverClass->GetText().isEmpty() )
597 : {
598 : // TODO change jvmaccess
599 0 : ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() );
600 0 : m_pETDriverClass->SetText(m_pETDriverClass->GetText().trim()); // fdo#68341
601 0 : bSuccess = xJVM.is() && ::connectivity::existsJavaClassByName(xJVM,m_pETDriverClass->GetText());
602 : }
603 : }
604 0 : catch(::com::sun::star::uno::Exception&)
605 : {
606 : }
607 : #endif
608 0 : sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
609 0 : OSQLMessageBox aMsg( this, OUString( ModuleRes( nMessage ) ), OUString() );
610 0 : aMsg.Execute();
611 0 : return 0L;
612 : }
613 :
614 0 : IMPL_LINK(OJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit)
615 : {
616 0 : if ( _pEdit == m_pETDriverClass )
617 0 : m_pPBTestJavaDriver->Enable( !m_pETDriverClass->GetText().isEmpty() );
618 0 : SetRoadmapStateValue(checkTestConnection());
619 : // tell the listener we were modified
620 0 : callModifiedHdl();
621 0 : return 0L;
622 : }
623 :
624 0 : OGenericAdministrationPage* OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
625 : {
626 0 : return ( new OSpreadSheetConnectionPageSetup( pParent, _rAttrSet ) );
627 : }
628 :
629 :
630 0 : OSpreadSheetConnectionPageSetup::OSpreadSheetConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
631 0 : :OConnectionTabPageSetup(pParent, "DBWizSpreadsheetPage", "dbaccess/ui/dbwizspreadsheetpage.ui", _rCoreAttrs, STR_SPREADSHEET_HELPTEXT, STR_SPREADSHEET_HEADERTEXT, STR_SPREADSHEETPATH)
632 : {
633 0 : get(m_pPasswordrequired, "passwordrequired");
634 0 : m_pPasswordrequired->SetToggleHdl(getControlModifiedLink());
635 0 : }
636 :
637 0 : OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup()
638 : {
639 :
640 0 : }
641 :
642 0 : void OSpreadSheetConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
643 : {
644 0 : }
645 :
646 0 : void OSpreadSheetConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
647 : {
648 0 : OConnectionTabPageSetup::fillControls(_rControlList);
649 0 : _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pPasswordrequired));
650 :
651 0 : }
652 :
653 0 : void OSpreadSheetConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
654 : {
655 0 : OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
656 0 : }
657 :
658 0 : bool OSpreadSheetConnectionPageSetup::FillItemSet( SfxItemSet* _rSet )
659 : {
660 0 : bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
661 0 : fillBool(*_rSet,m_pPasswordrequired,DSID_PASSWORDREQUIRED,bChangedSomething);
662 0 : return bChangedSomething;
663 : }
664 :
665 0 : OGenericAdministrationPage* OAuthentificationPageSetup::CreateAuthentificationTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet )
666 : {
667 0 : return ( new OAuthentificationPageSetup( pParent, _rAttrSet) );
668 : }
669 :
670 :
671 0 : OAuthentificationPageSetup::OAuthentificationPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
672 0 : :OGenericAdministrationPage(pParent, "AuthentificationPage", "dbaccess/ui/authentificationpage.ui", _rCoreAttrs )
673 : {
674 0 : get(m_pFTHelpText, "helptext");
675 0 : get(m_pFTUserName, "generalUserNameLabel");
676 0 : get(m_pETUserName, "generalUserNameEntry");
677 0 : get(m_pCBPasswordRequired, "passRequiredCheckbutton");
678 0 : get(m_pPBTestConnection, "testConnectionButton");
679 0 : m_pETUserName->SetModifyHdl(getControlModifiedLink());
680 0 : m_pCBPasswordRequired->SetClickHdl(getControlModifiedLink());
681 0 : m_pPBTestConnection->SetClickHdl(LINK(this,OGenericAdministrationPage,OnTestConnectionClickHdl));
682 :
683 0 : LayoutHelper::fitSizeRightAligned( *m_pPBTestConnection );
684 0 : }
685 :
686 0 : OAuthentificationPageSetup::~OAuthentificationPageSetup()
687 : {
688 :
689 0 : }
690 :
691 0 : void OAuthentificationPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
692 : {
693 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTHelpText));
694 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTUserName));
695 0 : _rControlList.push_back(new ODisableWrapper<PushButton>(m_pPBTestConnection));
696 0 : }
697 :
698 0 : void OAuthentificationPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
699 : {
700 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pETUserName));
701 0 : _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pCBPasswordRequired));
702 0 : }
703 :
704 0 : void OAuthentificationPageSetup::implInitControls(const SfxItemSet& _rSet, bool /*_bSaveValue*/)
705 : {
706 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
707 : bool bValid, bReadonly;
708 0 : getFlags(_rSet, bValid, bReadonly);
709 0 : SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, true);
710 0 : SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, true);
711 :
712 0 : m_pETUserName->SetText(pUidItem->GetValue());
713 0 : m_pCBPasswordRequired->Check(pAllowEmptyPwd->GetValue());
714 :
715 0 : m_pETUserName->ClearModifyFlag();
716 0 : }
717 :
718 0 : bool OAuthentificationPageSetup::FillItemSet( SfxItemSet* _rSet )
719 : {
720 0 : bool bChangedSomething = false;
721 :
722 0 : if (m_pETUserName->IsValueChangedFromSaved())
723 : {
724 0 : _rSet->Put(SfxStringItem(DSID_USER, m_pETUserName->GetText()));
725 0 : _rSet->Put(SfxStringItem(DSID_PASSWORD, OUString()));
726 0 : bChangedSomething = true;
727 : }
728 0 : fillBool(*_rSet,m_pCBPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
729 0 : return bChangedSomething;
730 : }
731 :
732 0 : OGenericAdministrationPage* OFinalDBPageSetup::CreateFinalDBTabPageSetup( vcl::Window* pParent, const SfxItemSet& _rAttrSet)
733 : {
734 0 : return ( new OFinalDBPageSetup( pParent, _rAttrSet) );
735 : }
736 :
737 :
738 0 : OFinalDBPageSetup::OFinalDBPageSetup(vcl::Window* pParent, const SfxItemSet& _rCoreAttrs)
739 : : OGenericAdministrationPage(pParent, "PageFinal",
740 0 : "dbaccess/ui/finalpagewizard.ui", _rCoreAttrs)
741 : {
742 0 : get(m_pFTFinalHeader, "headerText");
743 0 : get(m_pFTFinalHelpText, "helpText");
744 0 : get(m_pRBRegisterDataSource, "yesregister");
745 0 : get(m_pRBDontregisterDataSource, "noregister");
746 0 : get(m_pFTAdditionalSettings, "additionalText");
747 0 : get(m_pCBOpenAfterwards, "openediting");
748 0 : get(m_pCBStartTableWizard, "usewizard");
749 0 : get(m_pFTFinalText, "finishText");
750 :
751 0 : m_pCBOpenAfterwards->SetClickHdl(LINK(this, OFinalDBPageSetup, OnOpenSelected));
752 0 : m_pCBStartTableWizard->SetClickHdl(getControlModifiedLink());
753 0 : m_pRBRegisterDataSource->SetState(true);
754 0 : }
755 :
756 0 : OFinalDBPageSetup::~OFinalDBPageSetup()
757 : {
758 :
759 0 : }
760 :
761 0 : bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered()
762 : {
763 0 : return m_pRBRegisterDataSource->IsChecked() && m_pRBRegisterDataSource->IsEnabled();
764 : }
765 :
766 0 : bool OFinalDBPageSetup::IsDatabaseDocumentToBeOpened()
767 : {
768 0 : return m_pCBOpenAfterwards->IsChecked() && m_pCBOpenAfterwards->IsEnabled();
769 : }
770 :
771 0 : bool OFinalDBPageSetup::IsTableWizardToBeStarted()
772 : {
773 0 : return m_pCBStartTableWizard->IsChecked() && m_pCBStartTableWizard->IsEnabled();
774 : }
775 :
776 0 : void OFinalDBPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
777 : {
778 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTFinalHeader));
779 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTFinalHelpText));
780 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTAdditionalSettings));
781 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTFinalText));
782 0 : }
783 :
784 0 : void OFinalDBPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
785 : {
786 0 : _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pCBOpenAfterwards));
787 0 : _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pCBStartTableWizard));
788 0 : _rControlList.push_back(new OSaveValueWrapper<RadioButton>(m_pRBRegisterDataSource));
789 0 : _rControlList.push_back(new OSaveValueWrapper<RadioButton>(m_pRBDontregisterDataSource));
790 0 : }
791 :
792 0 : void OFinalDBPageSetup::implInitControls(const SfxItemSet& /*_rSet*/, bool /*_bSaveValue*/)
793 : {
794 0 : m_pCBOpenAfterwards->Check();
795 0 : }
796 :
797 0 : void OFinalDBPageSetup::enableTableWizardCheckBox( bool _bSupportsTableCreation)
798 : {
799 0 : m_pCBStartTableWizard->Enable(_bSupportsTableCreation);
800 0 : }
801 :
802 0 : bool OFinalDBPageSetup::FillItemSet( SfxItemSet* /*_rSet*/ )
803 : {
804 0 : return true;
805 : }
806 :
807 0 : IMPL_LINK(OFinalDBPageSetup, OnOpenSelected, CheckBox*, _pBox)
808 : {
809 0 : m_pCBStartTableWizard->Enable( _pBox->IsEnabled() && _pBox->IsChecked() );
810 0 : callModifiedHdl();
811 : // outta here
812 0 : return 0L;
813 : }
814 72 : }
815 :
816 : // namespace dbaui
817 :
818 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|