weld ODbAdminDialog

Change-Id: I691ce67b55fb16d06d7266ebe671ac31e30c05d5
Reviewed-on: https://gerrit.libreoffice.org/62297
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2018-10-23 16:18:53 +01:00
parent 290b6e09f9
commit f62efe43a2
20 changed files with 95 additions and 125 deletions

View File

@@ -18,7 +18,6 @@
*/
#include "dbtreemodel.hxx"
#include <dbu_pageids.hxx>
namespace dbaui
{

View File

@@ -23,7 +23,6 @@
#include <connectivity/dbtools.hxx>
#include <UITools.hxx>
#include <core_resource.hxx>
#include <dbu_pageids.hxx>
#include <strings.hrc>
#include <com/sun/star/util/NumberFormatter.hpp>

View File

@@ -18,7 +18,6 @@
*/
#include <dbtreelistbox.hxx>
#include <dbu_pageids.hxx>
#include <browserids.hxx>
#include <listviewitems.hxx>
#include <callbacks.hxx>

View File

@@ -24,7 +24,6 @@
#include <sqlmessage.hxx>
#include <dbu_dlg.hxx>
#include <strings.hrc>
#include <dbu_pageids.hxx>
#include <svl/itemset.hxx>
#include <svl/stritem.hxx>
#include <svl/eitem.hxx>

View File

@@ -25,7 +25,6 @@
#include <dbu_dlg.hxx>
#include <strings.hrc>
#include <strings.hxx>
#include <dbu_pageids.hxx>
#include <svl/itemset.hxx>
#include <svl/stritem.hxx>
#include <svl/eitem.hxx>

View File

@@ -22,7 +22,6 @@
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
#include <core_resource.hxx>
#include <dbu_pageids.hxx>
#include <dbu_dlg.hxx>
#include <strings.hrc>
#include <sfx2/sfxsids.hrc>

View File

@@ -27,7 +27,6 @@
#include "DbAdminImpl.hxx"
#include "DriverSettings.hxx"
#include "optionalboolitem.hxx"
#include <dbu_pageids.hxx>
#include <dbu_dlg.hxx>
#include <svl/eitem.hxx>

View File

@@ -46,59 +46,47 @@ using namespace com::sun::star::beans;
using namespace com::sun::star::container;
// ODbAdminDialog
ODbAdminDialog::ODbAdminDialog(vcl::Window* _pParent
, SfxItemSet const * _pItems
, const Reference< XComponentContext >& _rxContext)
: SfxTabDialog(_pParent, "AdminDialog",
"dbaccess/ui/admindialog.ui", _pItems)
ODbAdminDialog::ODbAdminDialog(weld::Window* pParent,
SfxItemSet const * _pItems,
const Reference< XComponentContext >& _rxContext)
: SfxTabDialogController(pParent, "dbaccess/ui/admindialog.ui", "AdminDialog", _pItems)
, m_bUIEnabled(true)
, m_sMainPageID("advanced")
{
m_pImpl.reset(new ODbDataSourceAdministrationHelper(_rxContext,GetFrameWeld(), _pParent ? _pParent->GetFrameWeld() : nullptr, this));
m_pImpl.reset(new ODbDataSourceAdministrationHelper(_rxContext, m_xDialog.get(), pParent, this));
// add the initial tab page
m_nMainPageID = AddTabPage("advanced", OConnectionTabPage::Create, nullptr);
AddTabPage(m_sMainPageID, OConnectionTabPage::Create, nullptr);
// remove the reset button - it's meaning is much too ambiguous in this dialog
RemoveResetButton();
}
ODbAdminDialog::~ODbAdminDialog()
{
disposeOnce();
}
void ODbAdminDialog::dispose()
{
SetInputSet(nullptr);
DELETEZ(m_pExampleSet);
SfxTabDialog::dispose();
}
short ODbAdminDialog::Ok()
{
SfxTabDialog::Ok();
SfxTabDialogController::Ok();
m_bUIEnabled = false;
return ( AR_LEAVE_MODIFIED == implApplyChanges() ) ? RET_OK : RET_CANCEL;
// TODO : AR_ERROR is not handled correctly, we always close the dialog here
}
void ODbAdminDialog::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage)
void ODbAdminDialog::PageCreated(const OString& rId, SfxTabPage& _rPage)
{
// register ourself as modified listener
static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory( getORB() );
static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
vcl::Window *pWin = GetViewWindow();
if(pWin)
pWin->Invalidate();
SfxTabDialog::PageCreated(_nId, _rPage);
SfxTabDialogController::PageCreated(rId, _rPage);
}
void ODbAdminDialog::addDetailPage(sal_uInt16 _nPageId, const char* pTextId, CreateTabPage _pCreateFunc)
void ODbAdminDialog::addDetailPage(const OString& rPageId, const char* pTextId, CreateTabPage pCreateFunc)
{
AddTabPage(_nPageId, DBA_RES(pTextId), _pCreateFunc);
m_aCurrentDetailPages.push(_nPageId);
AddTabPage(rPageId, DBA_RES(pTextId), pCreateFunc, nullptr);
}
void ODbAdminDialog::impl_selectDataSource(const css::uno::Any& _aDataSourceName)
@@ -115,35 +103,35 @@ void ODbAdminDialog::impl_selectDataSource(const css::uno::Any& _aDataSourceName
switch ( eType )
{
case ::dbaccess::DST_DBASE:
addDetailPage(PAGE_DBASE, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateDbase);
addDetailPage("dbase", STR_PAGETITLE_ADVANCED, ODriversSettings::CreateDbase);
break;
case ::dbaccess::DST_ADO:
addDetailPage(PAGE_ADO, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdo);
addDetailPage("ado", STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdo);
break;
case ::dbaccess::DST_FLAT:
addDetailPage(PAGE_TEXT, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateText);
addDetailPage("text", STR_PAGETITLE_ADVANCED, ODriversSettings::CreateText);
break;
case ::dbaccess::DST_ODBC:
addDetailPage(PAGE_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateODBC);
addDetailPage("odbc", STR_PAGETITLE_ADVANCED, ODriversSettings::CreateODBC);
break;
case ::dbaccess::DST_MYSQL_ODBC:
addDetailPage(PAGE_MYSQL_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLODBC);
addDetailPage("mysqlodbc", STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLODBC);
break;
case ::dbaccess::DST_MYSQL_JDBC:
addDetailPage(PAGE_MYSQL_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLJDBC);
addDetailPage("mysqljdbc", STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLJDBC);
break;
case ::dbaccess::DST_ORACLE_JDBC:
addDetailPage(PAGE_ORACLE_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateOracleJDBC);
addDetailPage("oraclejdbc", STR_PAGETITLE_ADVANCED, ODriversSettings::CreateOracleJDBC);
break;
case ::dbaccess::DST_LDAP:
addDetailPage(PAGE_LDAP,STR_PAGETITLE_ADVANCED,ODriversSettings::CreateLDAP);
addDetailPage("ldap",STR_PAGETITLE_ADVANCED,ODriversSettings::CreateLDAP);
break;
case ::dbaccess::DST_USERDEFINE1: /// first user defined driver
case ::dbaccess::DST_USERDEFINE2:
@@ -157,8 +145,7 @@ void ODbAdminDialog::impl_selectDataSource(const css::uno::Any& _aDataSourceName
case ::dbaccess::DST_USERDEFINE10:
{
OUString aTitle(DBA_RES(STR_PAGETITLE_ADVANCED));
AddTabPage(PAGE_USERDRIVER, aTitle, ODriversSettings::CreateUser, 1);
m_aCurrentDetailPages.push(PAGE_USERDRIVER);
AddTabPage("user" + OString(static_cast<int>(eType)), aTitle, ODriversSettings::CreateUser, nullptr);
}
break;
default:
@@ -176,7 +163,7 @@ void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasou
// reset the pages
// prevent flicker
SetUpdateMode(false);
m_xDialog->freeze();
// remove all items which relate to indirect properties from the input set
// (without this, the following may happen: select an arbitrary data source where some indirect properties
@@ -190,33 +177,33 @@ void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasou
m_pImpl->translateProperties(_rxDatasource, *GetInputSetImpl());
// reset the example set
delete m_pExampleSet;
m_pExampleSet = new SfxItemSet(*GetInputSetImpl());
m_xExampleSet.reset(new SfxItemSet(*GetInputSetImpl()));
// special case: MySQL Native does not have the generic "advanced" page
const DbuTypeCollectionItem& rCollectionItem = dynamic_cast<const DbuTypeCollectionItem&>(*getOutputSet()->GetItem(DSID_TYPECOLLECTION));
::dbaccess::ODsnTypeCollection* pCollection = rCollectionItem.getCollection();
if ( pCollection->determineType(getDatasourceType( *m_pExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE )
if ( pCollection->determineType(getDatasourceType( *m_xExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE )
{
AddTabPage( PAGE_MYSQL_NATIVE, DBA_RES(STR_PAGETITLE_CONNECTION), ODriversSettings::CreateMySQLNATIVE );
OString sMySqlNative("mysqlnative");
AddTabPage(sMySqlNative, DBA_RES(STR_PAGETITLE_CONNECTION), ODriversSettings::CreateMySQLNATIVE, nullptr);
RemoveTabPage("advanced");
m_nMainPageID = PAGE_MYSQL_NATIVE;
m_sMainPageID = sMySqlNative;
}
ShowPage( m_nMainPageID );
SfxTabPage* pConnectionPage = GetTabPage( m_nMainPageID );
SetCurPageId(m_sMainPageID);
SfxTabPage* pConnectionPage = GetTabPage(m_sMainPageID);
if ( pConnectionPage )
pConnectionPage->Reset(GetInputSetImpl());
// if this is NULL, the page has not been created yet, which means we're called before the
// dialog was displayed (probably from inside the ctor)
SetUpdateMode(true);
m_xDialog->thaw();
}
void ODbAdminDialog::setTitle(const OUString& _sTitle)
void ODbAdminDialog::setTitle(const OUString& rTitle)
{
SetText(_sTitle);
m_xDialog->set_title(rTitle);
}
void ODbAdminDialog::enableConfirmSettings( bool ) {}
@@ -233,15 +220,9 @@ ODbAdminDialog::ApplyResult ODbAdminDialog::implApplyChanges()
return AR_KEEP;
}
if ( !m_pImpl->saveChanges(*m_pExampleSet) )
if ( !m_pImpl->saveChanges(*m_xExampleSet) )
return AR_KEEP;
if ( m_bUIEnabled )
ShowPage(GetCurPageId());
// This does the usual ActivatePage, so the pages can save their current status.
// This way, next time they're asked what has changed since now and here, they really
// can compare with the status they have _now_ (not the one they had before this apply call).
return AR_LEAVE_MODIFIED;
}
@@ -257,7 +238,7 @@ const SfxItemSet* ODbAdminDialog::getOutputSet() const
SfxItemSet* ODbAdminDialog::getWriteOutputSet()
{
return m_pExampleSet;
return m_xExampleSet.get();
}
std::pair< Reference<XConnection>,bool> ODbAdminDialog::createConnection()

View File

@@ -19,7 +19,6 @@
#include <textconnectionsettings.hxx>
#include "TextConnectionHelper.hxx"
#include <dbu_pageids.hxx>
#include <dsitems.hxx>
#include <stringconstants.hxx>

View File

@@ -44,26 +44,21 @@ namespace dbaui
class ODbDataSourceAdministrationHelper;
/** tab dialog for administrating the office wide registered data sources
*/
class ODbAdminDialog final : public SfxTabDialog , public IItemSetHelper, public IDatabaseSettingsDialog
class ODbAdminDialog final : public SfxTabDialogController, public IItemSetHelper, public IDatabaseSettingsDialog
{
private:
std::stack< sal_Int32 > m_aCurrentDetailPages; // ids of all currently enabled (type-dependent) detail pages
std::unique_ptr<ODbDataSourceAdministrationHelper> m_pImpl;
bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/>
sal_uInt16 m_nMainPageID;
OString m_sMainPageID;
public:
/** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
after the dialog has been destroyed
*/
ODbAdminDialog(vcl::Window* pParent,
SfxItemSet const * _pItems,
const css::uno::Reference< css::uno::XComponentContext >& _rxORB
);
ODbAdminDialog(weld::Window* pParent, SfxItemSet const * _pItems,
const css::uno::Reference< css::uno::XComponentContext >& _rxORB);
virtual ~ODbAdminDialog() override;
virtual void dispose() override;
/** create and return an item set for use with the dialog.
@param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case
@@ -95,9 +90,9 @@ public:
private:
// adds a new detail page and remove all the old ones
void addDetailPage(sal_uInt16 _nPageId, const char* pTextId, CreateTabPage pCreateFunc);
void addDetailPage(const OString& rPageId, const char* pTextId, CreateTabPage pCreateFunc);
virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage) override;
virtual void PageCreated(const OString& rId, SfxTabPage& _rPage) override;
virtual short Ok() override;
/// select a datasource with a given name, adjust the item set accordingly, and everything like that ..

View File

@@ -19,8 +19,6 @@
#ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_DBU_DLG_HRC
#define INCLUDED_DBACCESS_SOURCE_UI_INC_DBU_DLG_HRC
#include "dbu_pageids.hxx"
#define PAGE_X 281
#define PAGE_Y 215
#define WIZARD_PAGE_X 225

View File

@@ -1,38 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_DBU_RESOURCE_HRC
#define INCLUDED_DBACCESS_SOURCE_UI_INC_DBU_RESOURCE_HRC
// tab pages
#define PAGE_DBASE 1001
#define PAGE_ODBC 1003
#define PAGE_TEXT 1004
#define PAGE_ADO 1007
#define PAGE_LDAP 1015
#define PAGE_MYSQL_ODBC 1017
#define PAGE_USERDRIVER 1019
#define PAGE_MYSQL_JDBC 1020
#define PAGE_MYSQL_NATIVE 1024
#define PAGE_ORACLE_JDBC 1027
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -37,7 +37,6 @@
#include <TokenWriter.hxx>
#include <UITools.hxx>
#include <dbaccess/dataview.hxx>
#include <dbu_pageids.hxx>
#include <unotools/ucbhelper.hxx>
#include <tools/urlobj.hxx>
#include <tools/diagnose_ex.h>

View File

@@ -22,7 +22,6 @@
#include <callbacks.hxx>
#include <core_resource.hxx>
#include <stringconstants.hxx>
#include <dbu_pageids.hxx>
#include <dlgsave.hxx>
#include <dbtreelistbox.hxx>
#include <defaultobjectnamecheck.hxx>

View File

@@ -18,7 +18,6 @@
*/
#include <imageprovider.hxx>
#include <dbu_pageids.hxx>
#include <stringconstants.hxx>
#include <bitmaps.hlst>

View File

@@ -23,7 +23,6 @@
#include <strings.hrc>
#include <query.hrc>
#include <dbu_reghelper.hxx>
#include <dbu_pageids.hxx>
#include <stringconstants.hxx>
#include <defaultobjectnamecheck.hxx>
#include <dlgsave.hxx>

View File

@@ -94,13 +94,13 @@ Reference<XPropertySetInfo> SAL_CALL ODataSourcePropertyDialog::getPropertySetI
svt::OGenericUnoDialog::Dialog ODataSourcePropertyDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
{
VclPtrInstance<ODbAdminDialog> pDialog(VCLUnoHelper::GetWindow(rParent), m_pDatasourceItems.get(), m_aContext);
std::unique_ptr<ODbAdminDialog> xDialog(new ODbAdminDialog(Application::GetFrameWeld(rParent), m_pDatasourceItems.get(), m_aContext));
// the initial selection
if ( m_aInitialSelection.hasValue() )
pDialog->selectDataSource(m_aInitialSelection);
xDialog->selectDataSource(m_aInitialSelection);
return svt::OGenericUnoDialog::Dialog(pDialog);
return svt::OGenericUnoDialog::Dialog(std::move(xDialog));
}
} // namespace dbaui

View File

@@ -19,7 +19,6 @@
#include <memory>
#include <dbu_reghelper.hxx>
#include <dbu_pageids.hxx>
#include <strings.hrc>
#include <strings.hxx>
#include <stringconstants.hxx>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="dba">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="AdminDialog">
@@ -7,7 +7,13 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="admindialog|AdminDialog">Database Properties</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -17,6 +23,20 @@
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="reset">
<property name="label">gtk-revert-to-saved</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
@@ -30,7 +50,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
<child>
@@ -44,7 +64,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
@@ -58,7 +78,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
<property name="secondary">True</property>
</packing>
</child>
@@ -73,7 +93,7 @@
<child>
<object class="GtkNotebook" id="tabcontrol">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="scrollable">True</property>
@@ -85,6 +105,30 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="tab">
@@ -108,6 +152,7 @@
</object>
</child>
<action-widgets>
<action-widget response="0">reset</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>

View File

@@ -8,6 +8,8 @@
<property name="title" translatable="yes" context="advancedsettingsdialog|AdvancedSettingsDialog">Advanced Settings</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>