summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-05-16 15:42:05 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-05-17 09:57:05 +0200
commit10bf9023791dae0a11c96e0e8fd05ccee3bc304f (patch)
tree528bc16bc666993c41394371cad4a577c12e2196 /cui
parent6b703887165a89b5a9003a3925985ec92292884e (diff)
weld SvxJavaParameterDlg
Change-Id: Ibcd19071aae42e07d9411d9c4ac4fbbb566aec45 Reviewed-on: https://gerrit.libreoffice.org/54441 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/options/optjava.cxx165
-rw-r--r--cui/source/options/optjava.hxx82
-rw-r--r--cui/uiconfig/ui/javastartparametersdialog.ui48
3 files changed, 153 insertions, 142 deletions
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index 36d33c6116f5..4d847ebaa9eb 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -111,7 +111,6 @@ public:
SvxJavaOptionsPage::SvxJavaOptionsPage( vcl::Window* pParent, const SfxItemSet& rSet )
: SfxTabPage(pParent, "OptAdvancedPage", "cui/ui/optadvancedpage.ui", &rSet)
- , m_pParamDlg(nullptr)
, m_pPathDlg(nullptr)
, m_aResetIdle("cui options SvxJavaOptionsPage Reset")
, xDialogListener(new ::svt::DialogClosedListener())
@@ -184,7 +183,7 @@ SvxJavaOptionsPage::~SvxJavaOptionsPage()
void SvxJavaOptionsPage::dispose()
{
m_pJavaList.disposeAndClear();
- m_pParamDlg.disposeAndClear();
+ m_xParamDlg.reset();
m_pPathDlg.disposeAndClear();
ClearJavaInfo();
#if HAVE_FEATURE_JAVA
@@ -265,27 +264,27 @@ IMPL_LINK_NOARG(SvxJavaOptionsPage, ParameterHdl_Impl, Button*, void)
{
#if HAVE_FEATURE_JAVA
std::vector< OUString > aParameterList;
- if ( !m_pParamDlg )
+ if (!m_xParamDlg)
{
- m_pParamDlg = VclPtr<SvxJavaParameterDlg>::Create( this );
+ m_xParamDlg.reset(new SvxJavaParameterDlg(GetFrameWeld()));
javaFrameworkError eErr = jfw_getVMParameters( &m_parParameters );
if ( JFW_E_NONE == eErr && !m_parParameters.empty() )
{
aParameterList = m_parParameters;
- m_pParamDlg->SetParameters( aParameterList );
+ m_xParamDlg->SetParameters( aParameterList );
}
}
else
{
- aParameterList = m_pParamDlg->GetParameters();
- m_pParamDlg->DisableButtons(); //disable add, edit and remove button when dialog is reopened
+ aParameterList = m_xParamDlg->GetParameters();
+ m_xParamDlg->DisableButtons(); //disable add, edit and remove button when dialog is reopened
}
- if ( m_pParamDlg->Execute() == RET_OK )
+ if (m_xParamDlg->execute() == RET_OK)
{
- if ( aParameterList != m_pParamDlg->GetParameters() )
+ if ( aParameterList != m_xParamDlg->GetParameters() )
{
- aParameterList = m_pParamDlg->GetParameters();
+ aParameterList = m_xParamDlg->GetParameters();
if ( jfw_isVMRunning() )
{
RequestRestart( svtools::RESTART_REASON_ASSIGNING_JAVAPARAMETERS );
@@ -293,7 +292,7 @@ IMPL_LINK_NOARG(SvxJavaOptionsPage, ParameterHdl_Impl, Button*, void)
}
}
else
- m_pParamDlg->SetParameters( aParameterList );
+ m_xParamDlg->SetParameters( aParameterList );
#else
(void) this; // Silence loplugin:staticmethods
#endif
@@ -596,9 +595,9 @@ bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
#if HAVE_FEATURE_JAVA
javaFrameworkError eErr = JFW_E_NONE;
- if ( m_pParamDlg )
+ if (m_xParamDlg)
{
- eErr = jfw_setVMParameters( m_pParamDlg->GetParameters() );
+ eErr = jfw_setVMParameters(m_xParamDlg->GetParameters());
SAL_WARN_IF(JFW_E_NONE != eErr, "cui.options", "SvxJavaOptionsPage::FillItemSet(): error in jfw_setVMParameters");
bModified = true;
}
@@ -698,101 +697,87 @@ void SvxJavaOptionsPage::FillUserData()
// class SvxJavaParameterDlg ---------------------------------------------
-SvxJavaParameterDlg::SvxJavaParameterDlg( vcl::Window* pParent ) :
-
- ModalDialog( pParent, "JavaStartParameters",
- "cui/ui/javastartparametersdialog.ui" )
+SvxJavaParameterDlg::SvxJavaParameterDlg(weld::Window* pParent)
+ : GenericDialogController(pParent, "cui/ui/javastartparametersdialog.ui",
+ "JavaStartParameters")
+ , m_xParameterEdit(m_xBuilder->weld_entry("parameterfield"))
+ , m_xAssignBtn(m_xBuilder->weld_button("assignbtn"))
+ , m_xAssignedList(m_xBuilder->weld_tree_view("assignlist"))
+ , m_xRemoveBtn(m_xBuilder->weld_button("removebtn"))
+ , m_xEditBtn(m_xBuilder->weld_button("editbtn"))
{
- get( m_pParameterEdit, "parameterfield");
- get( m_pAssignBtn, "assignbtn");
- get( m_pAssignedList, "assignlist");
- m_pAssignedList->SetDropDownLineCount(6);
- m_pAssignedList->set_width_request(m_pAssignedList->approximate_char_width() * 54);
- get( m_pRemoveBtn, "removebtn");
- get( m_pEditBtn, "editbtn");
-
- m_pParameterEdit->SetModifyHdl( LINK( this, SvxJavaParameterDlg, ModifyHdl_Impl ) );
- m_pAssignBtn->SetClickHdl( LINK( this, SvxJavaParameterDlg, AssignHdl_Impl ) );
- m_pRemoveBtn->SetClickHdl( LINK( this, SvxJavaParameterDlg, RemoveHdl_Impl ) );
- m_pEditBtn->SetClickHdl( LINK( this, SvxJavaParameterDlg, EditHdl_Impl ) );
- m_pAssignedList->SetSelectHdl( LINK( this, SvxJavaParameterDlg, SelectHdl_Impl ) );
- m_pAssignedList->SetDoubleClickHdl( LINK( this, SvxJavaParameterDlg, DblClickHdl_Impl ) );
-
- ModifyHdl_Impl( *m_pParameterEdit );
+ m_xAssignedList->set_size_request(m_xAssignedList->get_approximate_digit_width() * 54,
+ m_xAssignedList->get_height_rows(6));
+ m_xParameterEdit->connect_changed( LINK( this, SvxJavaParameterDlg, ModifyHdl_Impl ) );
+ m_xAssignBtn->connect_clicked( LINK( this, SvxJavaParameterDlg, AssignHdl_Impl ) );
+ m_xRemoveBtn->connect_clicked( LINK( this, SvxJavaParameterDlg, RemoveHdl_Impl ) );
+ m_xEditBtn->connect_clicked( LINK( this, SvxJavaParameterDlg, EditHdl_Impl ) );
+ m_xAssignedList->connect_changed( LINK( this, SvxJavaParameterDlg, SelectHdl_Impl ) );
+ m_xAssignedList->connect_row_activated( LINK( this, SvxJavaParameterDlg, DblClickHdl_Impl ) );
+
+ ModifyHdl_Impl(*m_xParameterEdit);
EnableEditButton();
EnableRemoveButton();
}
SvxJavaParameterDlg::~SvxJavaParameterDlg()
{
- disposeOnce();
}
-void SvxJavaParameterDlg::dispose()
+IMPL_LINK_NOARG(SvxJavaParameterDlg, ModifyHdl_Impl, weld::Entry&, void)
{
- m_pParameterEdit.clear();
- m_pAssignBtn.clear();
- m_pAssignedList.clear();
- m_pRemoveBtn.clear();
- m_pEditBtn.clear();
- ModalDialog::dispose();
+ OUString sParam = comphelper::string::strip(m_xParameterEdit->get_text(), ' ');
+ m_xAssignBtn->set_sensitive(!sParam.isEmpty());
}
-
-IMPL_LINK_NOARG(SvxJavaParameterDlg, ModifyHdl_Impl, Edit&, void)
+IMPL_LINK_NOARG(SvxJavaParameterDlg, AssignHdl_Impl, weld::Button&, void)
{
- OUString sParam = comphelper::string::strip(m_pParameterEdit->GetText(), ' ');
- m_pAssignBtn->Enable(!sParam.isEmpty());
-}
-
-
-IMPL_LINK_NOARG(SvxJavaParameterDlg, AssignHdl_Impl, Button*, void)
-{
- OUString sParam = comphelper::string::strip(m_pParameterEdit->GetText(), ' ');
+ OUString sParam = comphelper::string::strip(m_xParameterEdit->get_text(), ' ');
if (!sParam.isEmpty())
{
- sal_Int32 nPos = m_pAssignedList->GetEntryPos( sParam );
- if ( LISTBOX_ENTRY_NOTFOUND == nPos )
- nPos = m_pAssignedList->InsertEntry( sParam );
- m_pAssignedList->SelectEntryPos( nPos );
- m_pParameterEdit->SetText( OUString() );
- ModifyHdl_Impl( *m_pParameterEdit );
+ int nPos = m_xAssignedList->find_text(sParam);
+ if (nPos == -1)
+ {
+ m_xAssignedList->append_text(sParam);
+ m_xAssignedList->select(m_xAssignedList->n_children() - 1);
+ }
+ else
+ m_xAssignedList->select(nPos);
+ m_xParameterEdit->set_text(OUString());
+ ModifyHdl_Impl(*m_xParameterEdit);
EnableEditButton();
EnableRemoveButton();
}
}
-IMPL_LINK_NOARG(SvxJavaParameterDlg, EditHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxJavaParameterDlg, EditHdl_Impl, weld::Button&, void)
{
EditParameter();
}
-
-IMPL_LINK_NOARG(SvxJavaParameterDlg, SelectHdl_Impl, ListBox&, void)
+IMPL_LINK_NOARG(SvxJavaParameterDlg, SelectHdl_Impl, weld::TreeView&, void)
{
EnableEditButton();
EnableRemoveButton();
}
-
-IMPL_LINK_NOARG(SvxJavaParameterDlg, DblClickHdl_Impl, ListBox&, void)
+IMPL_LINK_NOARG(SvxJavaParameterDlg, DblClickHdl_Impl, weld::TreeView&, void)
{
EditParameter();
}
-
-IMPL_LINK_NOARG(SvxJavaParameterDlg, RemoveHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxJavaParameterDlg, RemoveHdl_Impl, weld::Button&, void)
{
- sal_Int32 nPos = m_pAssignedList->GetSelectedEntryPos();
- if ( nPos != LISTBOX_ENTRY_NOTFOUND )
+ int nPos = m_xAssignedList->get_selected_index();
+ if (nPos != -1)
{
- m_pAssignedList->RemoveEntry( nPos );
- sal_Int32 nCount = m_pAssignedList->GetEntryCount();
- if ( nCount )
+ m_xAssignedList->remove(nPos);
+ int nCount = m_xAssignedList->n_children();
+ if (nCount)
{
- if ( nPos >= nCount )
- nPos = ( nCount - 1 );
- m_pAssignedList->SelectEntryPos( nPos );
+ if (nPos >= nCount)
+ nPos = nCount - 1;
+ m_xAssignedList->select(nPos);
}
else
{
@@ -804,13 +789,13 @@ IMPL_LINK_NOARG(SvxJavaParameterDlg, RemoveHdl_Impl, Button*, void)
void SvxJavaParameterDlg::EditParameter()
{
- sal_Int32 nPos = m_pAssignedList->GetSelectedEntryPos();
- m_pParameterEdit->SetText( OUString() );
+ int nPos = m_xAssignedList->get_selected_index();
+ m_xParameterEdit->set_text(OUString());
- if ( nPos != LISTBOX_ENTRY_NOTFOUND )
+ if (nPos != -1)
{
- InputDialog aParamEditDlg(GetFrameWeld(), CuiResId(RID_SVXSTR_JAVA_START_PARAM));
- OUString editableClassPath = m_pAssignedList->GetSelectedEntry();
+ InputDialog aParamEditDlg(m_xDialog.get(), CuiResId(RID_SVXSTR_JAVA_START_PARAM));
+ OUString editableClassPath = m_xAssignedList->get_selected_text();
aParamEditDlg.SetEntryText(editableClassPath);
aParamEditDlg.HideHelpBtn();
@@ -820,31 +805,29 @@ void SvxJavaParameterDlg::EditParameter()
if ( !editedClassPath.isEmpty() && editableClassPath != editedClassPath )
{
- m_pAssignedList->RemoveEntry( nPos );
- m_pAssignedList->InsertEntry( editedClassPath, nPos );
- m_pAssignedList->SelectEntryPos( nPos );
+ m_xAssignedList->remove(nPos);
+ m_xAssignedList->insert_text(editedClassPath, nPos);
+ m_xAssignedList->select(nPos);
}
}
}
-short SvxJavaParameterDlg::Execute()
+short SvxJavaParameterDlg::execute()
{
- m_pParameterEdit->GrabFocus();
- m_pAssignedList->SetNoSelection();
- return ModalDialog::Execute();
+ m_xParameterEdit->grab_focus();
+ m_xAssignedList->select(-1);
+ return m_xDialog->run();
}
-
std::vector< OUString > SvxJavaParameterDlg::GetParameters() const
{
- sal_Int32 nCount = m_pAssignedList->GetEntryCount();
+ int nCount = m_xAssignedList->n_children();
std::vector< OUString > aParamList;
- for ( sal_Int32 i = 0; i < nCount; ++i )
- aParamList.push_back( m_pAssignedList->GetEntry(i) );
+ for (int i = 0; i < nCount; ++i)
+ aParamList.push_back(m_xAssignedList->get_text(i));
return aParamList;
}
-
void SvxJavaParameterDlg::DisableButtons()
{
DisableAssignButton();
@@ -854,10 +837,10 @@ void SvxJavaParameterDlg::DisableButtons()
void SvxJavaParameterDlg::SetParameters( std::vector< OUString > const & rParams )
{
- m_pAssignedList->Clear();
+ m_xAssignedList->clear();
for (auto const & sParam: rParams)
{
- m_pAssignedList->InsertEntry( sParam );
+ m_xAssignedList->append_text(sParam);
}
DisableEditButton();
DisableRemoveButton();
diff --git a/cui/source/options/optjava.hxx b/cui/source/options/optjava.hxx
index ebc6ed2be45b..96e2b89a58fc 100644
--- a/cui/source/options/optjava.hxx
+++ b/cui/source/options/optjava.hxx
@@ -63,7 +63,7 @@ private:
VclPtr<PushButton> m_pClassPathBtn;
VclPtr<PushButton> m_pExpertConfigBtn;
- VclPtr<SvxJavaParameterDlg> m_pParamDlg;
+ std::unique_ptr<SvxJavaParameterDlg> m_xParamDlg;
VclPtr<SvxJavaClassPathDlg> m_pPathDlg;
VclPtr<OfaTreeOptionsDialog> m_pParentDlg;
@@ -121,52 +121,52 @@ public:
// class SvxJavaParameterDlg ---------------------------------------------
-class SvxJavaParameterDlg : public ModalDialog
+class SvxJavaParameterDlg : public weld::GenericDialogController
{
private:
- VclPtr<Edit> m_pParameterEdit;
- VclPtr<PushButton> m_pAssignBtn;
-
- VclPtr<ListBox> m_pAssignedList;
- VclPtr<PushButton> m_pRemoveBtn;
-
- VclPtr<PushButton> m_pEditBtn;
-
- DECL_LINK(ModifyHdl_Impl, Edit&, void);
- DECL_LINK(AssignHdl_Impl, Button*, void);
- DECL_LINK(SelectHdl_Impl, ListBox&, void);
- DECL_LINK(DblClickHdl_Impl, ListBox&, void);
- DECL_LINK(RemoveHdl_Impl, Button*, void);
-
- DECL_LINK(EditHdl_Impl, Button*, void);
-
- void EnableRemoveButton()
- { m_pRemoveBtn->Enable(
- m_pAssignedList->GetSelectedEntryPos()
- != LISTBOX_ENTRY_NOTFOUND ); }
-
-
- void EnableEditButton()
- { m_pEditBtn->Enable(
- m_pAssignedList->GetSelectedEntryPos()
- != LISTBOX_ENTRY_NOTFOUND ); }
-
- void DisableAssignButton()
- { m_pAssignBtn->Disable(); }
-
- void DisableRemoveButton()
- { m_pRemoveBtn->Disable(); }
-
- void DisableEditButton()
- { m_pEditBtn->Disable(); }
-
+ std::unique_ptr<weld::Entry> m_xParameterEdit;
+ std::unique_ptr<weld::Button> m_xAssignBtn;
+ std::unique_ptr<weld::TreeView> m_xAssignedList;
+ std::unique_ptr<weld::Button> m_xRemoveBtn;
+ std::unique_ptr<weld::Button> m_xEditBtn;
+
+ DECL_LINK(ModifyHdl_Impl, weld::Entry&, void);
+ DECL_LINK(AssignHdl_Impl, weld::Button&, void);
+ DECL_LINK(SelectHdl_Impl, weld::TreeView&, void);
+ DECL_LINK(DblClickHdl_Impl, weld::TreeView&, void);
+ DECL_LINK(RemoveHdl_Impl, weld::Button&, void);
+ DECL_LINK(EditHdl_Impl, weld::Button&, void);
+
+ void EnableRemoveButton()
+ {
+ m_xRemoveBtn->set_sensitive(m_xAssignedList->get_selected_index() != -1);
+ }
+
+ void EnableEditButton()
+ {
+ m_xEditBtn->set_sensitive(m_xAssignedList->get_selected_index() != -1);
+ }
+
+ void DisableAssignButton()
+ {
+ m_xAssignBtn->set_sensitive(false);
+ }
+
+ void DisableRemoveButton()
+ {
+ m_xRemoveBtn->set_sensitive(false);
+ }
+
+ void DisableEditButton()
+ {
+ m_xEditBtn->set_sensitive(false);
+ }
public:
- explicit SvxJavaParameterDlg( vcl::Window* pParent );
+ explicit SvxJavaParameterDlg(weld::Window* pParent);
virtual ~SvxJavaParameterDlg() override;
- virtual void dispose() override;
- virtual short Execute() override;
+ short execute();
std::vector< OUString > GetParameters() const;
void SetParameters( std::vector< OUString > const & rParams );
diff --git a/cui/uiconfig/ui/javastartparametersdialog.ui b/cui/uiconfig/ui/javastartparametersdialog.ui
index 0d17a03a2e35..14bdff1a45b9 100644
--- a/cui/uiconfig/ui/javastartparametersdialog.ui
+++ b/cui/uiconfig/ui/javastartparametersdialog.ui
@@ -1,12 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="JavaStartParameters">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="javastartparametersdialog|JavaStartParameters">Java Start Parameters</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>
@@ -90,10 +104,10 @@
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="javastartparametersdialog|label4">Java start _parameter</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">parameterfield</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -115,10 +129,10 @@
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="javastartparametersdialog|label5">Assig_ned start parameters</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">assignlist:border</property>
+ <property name="mnemonic_widget">assignlist</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -126,21 +140,34 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="width_request">1</property>
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTreeView" id="assignlist:border">
+ <object class="GtkTreeView" id="assignlist">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
<child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection3"/>
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -154,8 +181,8 @@
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="javastartparametersdialog|label6">For example: -Dmyprop=c:\\program files\\java</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -182,6 +209,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
<object class="GtkButton" id="editbtn">
<property name="label" translatable="yes" context="javastartparametersdialog|editbtn">_Edit</property>