Kaydet (Commit) c9e55e2b authored tarafından Caolán McNamara's avatar Caolán McNamara

weld OJDBCConnectionPageSetup

Change-Id: I8c194c8efa17079253c857e171af203c17d3aff3
Reviewed-on: https://gerrit.libreoffice.org/62323
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 08402a81
...@@ -563,21 +563,21 @@ using namespace ::com::sun::star; ...@@ -563,21 +563,21 @@ using namespace ::com::sun::star;
OGenericAdministrationPage::callModifiedHdl(); OGenericAdministrationPage::callModifiedHdl();
} }
VclPtr<OGenericAdministrationPage> OJDBCConnectionPageSetup::CreateJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet ) VclPtr<OGenericAdministrationPage> OJDBCConnectionPageSetup::CreateJDBCTabPage(TabPageParent pParent, const SfxItemSet& _rAttrSet)
{ {
return VclPtr<OJDBCConnectionPageSetup>::Create( pParent, _rAttrSet); return VclPtr<OJDBCConnectionPageSetup>::Create(pParent, _rAttrSet);
} }
// OMySQLJDBCConnectionPageSetup // OMySQLJDBCConnectionPageSetup
OJDBCConnectionPageSetup::OJDBCConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs) OJDBCConnectionPageSetup::OJDBCConnectionPageSetup(TabPageParent pParent, const SfxItemSet& rCoreAttrs)
:OConnectionTabPageSetup(pParent, "JDBCConnectionPage", "dbaccess/ui/jdbcconnectionpage.ui", _rCoreAttrs, : DBOConnectionTabPageSetup(pParent, "dbaccess/ui/jdbcconnectionpage.ui", "JDBCConnectionPage", rCoreAttrs,
STR_JDBC_HELPTEXT, STR_JDBC_HEADERTEXT, STR_COMMONURL) STR_JDBC_HELPTEXT, STR_JDBC_HEADERTEXT, STR_COMMONURL)
, m_xFTDriverClass(m_xBuilder->weld_label("jdbcLabel"))
, m_xETDriverClass(m_xBuilder->weld_entry("jdbcEntry"))
, m_xPBTestJavaDriver(m_xBuilder->weld_button("jdbcButton"))
{ {
get(m_pFTDriverClass, "jdbcLabel"); m_xETDriverClass->connect_changed(LINK(this, OJDBCConnectionPageSetup, OnEditModified));
get(m_pETDriverClass, "jdbcEntry"); m_xPBTestJavaDriver->connect_clicked(LINK(this,OJDBCConnectionPageSetup,OnTestJavaClickHdl));
get(m_pPBTestJavaDriver, "jdbcButton");
m_pETDriverClass->SetModifyHdl(LINK(this, OJDBCConnectionPageSetup, OnEditModified));
m_pPBTestJavaDriver->SetClickHdl(LINK(this,OJDBCConnectionPageSetup,OnTestJavaClickHdl));
} }
OJDBCConnectionPageSetup::~OJDBCConnectionPageSetup() OJDBCConnectionPageSetup::~OJDBCConnectionPageSetup()
...@@ -585,28 +585,20 @@ using namespace ::com::sun::star; ...@@ -585,28 +585,20 @@ using namespace ::com::sun::star;
disposeOnce(); disposeOnce();
} }
void OJDBCConnectionPageSetup::dispose()
{
m_pFTDriverClass.clear();
m_pETDriverClass.clear();
m_pPBTestJavaDriver.clear();
OConnectionTabPageSetup::dispose();
}
void OJDBCConnectionPageSetup::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) void OJDBCConnectionPageSetup::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
{ {
_rControlList.emplace_back(new OSaveValueWrapper<Edit>(m_pETDriverClass)); _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::Entry>(m_xETDriverClass.get()));
} }
void OJDBCConnectionPageSetup::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) void OJDBCConnectionPageSetup::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
{ {
_rControlList.emplace_back(new ODisableWrapper<FixedText>(m_pFTDriverClass)); _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xFTDriverClass.get()));
} }
bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet* _rSet ) bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet* _rSet )
{ {
bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet); bool bChangedSomething = DBOConnectionTabPageSetup::FillItemSet(_rSet);
fillString(*_rSet,m_pETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething); fillString(*_rSet,m_xETDriverClass.get(),DSID_JDBCDRIVERCLASS,bChangedSomething);
return bChangedSomething; return bChangedSomething;
} }
...@@ -625,19 +617,19 @@ using namespace ::com::sun::star; ...@@ -625,19 +617,19 @@ using namespace ::com::sun::star;
OUString sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType); OUString sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType);
if ( !sDefaultJdbcDriverName.isEmpty() ) if ( !sDefaultJdbcDriverName.isEmpty() )
{ {
m_pETDriverClass->SetText(sDefaultJdbcDriverName); m_xETDriverClass->set_text(sDefaultJdbcDriverName);
m_pETDriverClass->SetModifyFlag(); m_xETDriverClass->save_value();
} }
} }
else else
{ {
m_pETDriverClass->SetText(pDrvItem->GetValue()); m_xETDriverClass->set_text(pDrvItem->GetValue());
m_pETDriverClass->ClearModifyFlag(); m_xETDriverClass->save_value();
} }
} }
bool bEnable = pDrvItem->GetValue().getLength() != 0; bool bEnable = pDrvItem->GetValue().getLength() != 0;
m_pPBTestJavaDriver->Enable(bEnable); m_xPBTestJavaDriver->set_sensitive(bEnable);
OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue); DBOConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
SetRoadmapStateValue(checkTestConnection()); SetRoadmapStateValue(checkTestConnection());
} }
...@@ -645,24 +637,24 @@ using namespace ::com::sun::star; ...@@ -645,24 +637,24 @@ using namespace ::com::sun::star;
bool OJDBCConnectionPageSetup::checkTestConnection() bool OJDBCConnectionPageSetup::checkTestConnection()
{ {
OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
bool bEnableTestConnection = !m_pConnectionURL->IsVisible() || !m_pConnectionURL->GetTextNoPrefix().isEmpty(); bool bEnableTestConnection = !m_xConnectionURL->get_visible() || !m_xConnectionURL->GetTextNoPrefix().isEmpty();
bEnableTestConnection = bEnableTestConnection && (!m_pETDriverClass->GetText().isEmpty()); bEnableTestConnection = bEnableTestConnection && (!m_xETDriverClass->get_text().isEmpty());
return bEnableTestConnection; return bEnableTestConnection;
} }
IMPL_LINK_NOARG(OJDBCConnectionPageSetup, OnTestJavaClickHdl, Button*, void) IMPL_LINK_NOARG(OJDBCConnectionPageSetup, OnTestJavaClickHdl, weld::Button&, void)
{ {
OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
bool bSuccess = false; bool bSuccess = false;
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
try try
{ {
if ( !m_pETDriverClass->GetText().isEmpty() ) if ( !m_xETDriverClass->get_text().isEmpty() )
{ {
// TODO change jvmaccess // TODO change jvmaccess
::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() ); ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() );
m_pETDriverClass->SetText(m_pETDriverClass->GetText().trim()); // fdo#68341 m_xETDriverClass->set_text(m_xETDriverClass->get_text().trim()); // fdo#68341
bSuccess = xJVM.is() && ::connectivity::existsJavaClassByName(xJVM,m_pETDriverClass->GetText()); bSuccess = xJVM.is() && ::connectivity::existsJavaClassByName(xJVM,m_xETDriverClass->get_text());
} }
} }
catch(css::uno::Exception&) catch(css::uno::Exception&)
...@@ -675,10 +667,10 @@ using namespace ::com::sun::star; ...@@ -675,10 +667,10 @@ using namespace ::com::sun::star;
aMsg.run(); aMsg.run();
} }
IMPL_LINK(OJDBCConnectionPageSetup, OnEditModified, Edit&, _rEdit, void) IMPL_LINK(OJDBCConnectionPageSetup, OnEditModified, weld::Entry&, rEdit, void)
{ {
if ( &_rEdit == m_pETDriverClass ) if (&rEdit == m_xETDriverClass.get())
m_pPBTestJavaDriver->Enable( !m_pETDriverClass->GetText().isEmpty() ); m_xPBTestJavaDriver->set_sensitive(!m_xETDriverClass->get_text().isEmpty());
SetRoadmapStateValue(checkTestConnection()); SetRoadmapStateValue(checkTestConnection());
// tell the listener we were modified // tell the listener we were modified
callModifiedHdl(); callModifiedHdl();
......
...@@ -168,13 +168,12 @@ namespace dbaui ...@@ -168,13 +168,12 @@ namespace dbaui
}; };
// OJDBCConnectionPageSetup // OJDBCConnectionPageSetup
class OJDBCConnectionPageSetup final : public OConnectionTabPageSetup class OJDBCConnectionPageSetup final : public DBOConnectionTabPageSetup
{ {
public: public:
OJDBCConnectionPageSetup( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ); OJDBCConnectionPageSetup(TabPageParent pParent, const SfxItemSet& _rCoreAttrs);
virtual ~OJDBCConnectionPageSetup() override; virtual ~OJDBCConnectionPageSetup() override;
virtual void dispose() override; static VclPtr<OGenericAdministrationPage> CreateJDBCTabPage(TabPageParent pParent, const SfxItemSet& rAttrSet);
static VclPtr<OGenericAdministrationPage> CreateJDBCTabPage( vcl::Window* pParent, const SfxItemSet& _rAttrSet );
private: private:
virtual bool checkTestConnection() override; virtual bool checkTestConnection() override;
...@@ -184,14 +183,14 @@ namespace dbaui ...@@ -184,14 +183,14 @@ namespace dbaui
virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override; virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override; virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
DECL_LINK(OnTestJavaClickHdl, Button*, void); DECL_LINK(OnTestJavaClickHdl, weld::Button&, void);
DECL_LINK(OnEditModified, Edit&, void); DECL_LINK(OnEditModified, weld::Entry&, void);
VclPtr<FixedText> m_pFTDriverClass; std::unique_ptr<weld::Label> m_xFTDriverClass;
VclPtr<Edit> m_pETDriverClass; std::unique_ptr<weld::Entry> m_xETDriverClass;
VclPtr<PushButton> m_pPBTestJavaDriver; std::unique_ptr<weld::Button> m_xPBTestJavaDriver;
}; };
// OJDBCConnectionPageSetup // OMySQLIntroPageSetup
class OMySQLIntroPageSetup : public OGenericAdministrationPage class OMySQLIntroPageSetup : public OGenericAdministrationPage
{ {
public: public:
......
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<object class="GtkEntry" id="browseurl"> <object class="GtkEntry" id="browseurl">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activates_default">True</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.22.1 -->
<interface domain="dba"> <interface domain="dba">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkBox" id="JDBCConnectionPage"> <object class="GtkBox" id="JDBCConnectionPage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -32,10 +31,10 @@ ...@@ -32,10 +31,10 @@
<object class="GtkLabel" id="helptext"> <object class="GtkLabel" id="helptext">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="jdbcconnectionpage|helptext">Please enter the required information to connect to a JDBC database. Please contact your system administrator if you are unsure about the following settings.</property> <property name="label" translatable="yes" context="jdbcconnectionpage|helptext">Please enter the required information to connect to a JDBC database. Please contact your system administrator if you are unsure about the following settings.</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="max_width_chars">60</property> <property name="max_width_chars">60</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -63,17 +62,6 @@ ...@@ -63,17 +62,6 @@
<property name="top_attach">0</property> <property name="top_attach">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="dbulo-ConnectionURLEdit" id="browseurl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child> <child>
<object class="GtkButton" id="create"> <object class="GtkButton" id="create">
<property name="label" translatable="yes" context="jdbcconnectionpage|create">_Create New</property> <property name="label" translatable="yes" context="jdbcconnectionpage|create">_Create New</property>
...@@ -100,6 +88,37 @@ ...@@ -100,6 +88,37 @@
<property name="top_attach">1</property> <property name="top_attach">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkEntry" id="browseurl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="browselabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -141,6 +160,7 @@ ...@@ -141,6 +160,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="activates_default">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment