diff options
author | akki95 <akshaydeepiitr@gmail.com> | 2016-02-09 03:37:37 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-02-12 09:43:10 +0000 |
commit | 3ae9eaa79353bc43d0a1dd32cbdb09236256a22b (patch) | |
tree | 9111b5b9945b27e773a6c891e01a43f1da6d29b6 | |
parent | 3d004858944b1ec69446941e65f317ee78da172e (diff) |
tdf#97425 - JVM start parameters should be editable.
Added new dialog to edit Java start Parameter.
Modified UI of JavaStartParameterDialog using Glade.
Renamed Assign Button to Add.
Added a function to edit.cxx vcl file to move cursor to last letter of GTKEntry.
Change-Id: Ia43e2c0fbced5674a84187de02a9bc9460141f2d
Reviewed-on: https://gerrit.libreoffice.org/22220
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r-- | cui/UIConfig_cui.mk | 1 | ||||
-rw-r--r-- | cui/source/options/optjava.cxx | 119 | ||||
-rw-r--r-- | cui/source/options/optjava.hxx | 26 | ||||
-rw-r--r-- | cui/uiconfig/ui/javastartparametersdialog.ui | 57 | ||||
-rw-r--r-- | cui/uiconfig/ui/javastartparameterseditdialog.ui | 107 | ||||
-rw-r--r-- | include/vcl/edit.hxx | 2 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 6 |
7 files changed, 282 insertions, 36 deletions
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk index b0f72cb6a9ea..697c701cdea1 100644 --- a/cui/UIConfig_cui.mk +++ b/cui/UIConfig_cui.mk @@ -90,6 +90,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\ cui/uiconfig/ui/insertrowcolumn \ cui/uiconfig/ui/javaclasspathdialog \ cui/uiconfig/ui/javastartparametersdialog \ + cui/uiconfig/ui/javastartparameterseditdialog \ cui/uiconfig/ui/linedialog \ cui/uiconfig/ui/linetabpage \ cui/uiconfig/ui/lineendstabpage \ diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx index 5568cdc89d8c..29a2c5faa286 100644 --- a/cui/source/options/optjava.cxx +++ b/cui/source/options/optjava.cxx @@ -311,7 +311,10 @@ IMPL_LINK_NOARG_TYPED(SvxJavaOptionsPage, ParameterHdl_Impl, Button*, void) } } else + { aParameterList = m_pParamDlg->GetParameters(); + m_pParamDlg->DisableButtons(); //disable add, edit and remove button when dialog is reopened + } if ( m_pParamDlg->Execute() == RET_OK ) { @@ -844,17 +847,7 @@ IMPL_LINK_NOARG_TYPED(SvxJavaParameterDlg, AssignHdl_Impl, Button*, void) IMPL_LINK_NOARG_TYPED(SvxJavaParameterDlg, EditHdl_Impl, Button*, void) { - sal_Int32 nPos = m_pAssignedList->GetSelectEntryPos(); - - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - { - OUString eVal = m_pAssignedList->GetSelectEntry(); - m_pAssignedList->RemoveEntry( nPos ); - m_pParameterEdit->SetText( eVal ); - } - DisableRemoveButton(); - DisableEditButton(); - EnableAssignButton(); + EditParameter(); } @@ -867,9 +860,7 @@ IMPL_LINK_NOARG_TYPED(SvxJavaParameterDlg, SelectHdl_Impl, ListBox&, void) IMPL_LINK_NOARG_TYPED(SvxJavaParameterDlg, DblClickHdl_Impl, ListBox&, void) { - sal_Int32 nPos = m_pAssignedList->GetSelectEntryPos(); - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - m_pParameterEdit->SetText( m_pAssignedList->GetEntry( nPos ) ); + EditParameter(); } @@ -886,10 +877,58 @@ IMPL_LINK_NOARG_TYPED(SvxJavaParameterDlg, RemoveHdl_Impl, Button*, void) nPos = ( nCount - 1 ); m_pAssignedList->SelectEntryPos( nPos ); } + else + { + DisableEditButton(); + } } EnableRemoveButton(); } +void SvxJavaParameterDlg::EditParameter() +{ + sal_Int32 nPos = m_pAssignedList->GetSelectEntryPos(); + m_pParameterEdit->SetText( OUString() ); + OUString editedClassPath; + + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + { + if ( !m_pParamEditDlg ) + { + m_pParamEditDlg = VclPtr<SvxJavaParameterEditDlg>::Create( this ); + editedClassPath = m_pAssignedList->GetSelectEntry(); + m_pParamEditDlg->SetParameter( editedClassPath ); + } + else{ + editedClassPath = m_pAssignedList->GetSelectEntry(); + m_pParamEditDlg->SetParameter( editedClassPath ); + } + } + else + { + if(m_pParamEditDlg) + { + editedClassPath = m_pParamEditDlg->GetParameter(); + } + } + + if ( m_pParamEditDlg->Execute() == RET_OK ) + { + if (!( editedClassPath == m_pParamEditDlg->GetParameter() ) ) + { + editedClassPath = m_pParamEditDlg->GetParameter(); + if( !editedClassPath.isEmpty() ){ + m_pAssignedList->RemoveEntry( nPos ); + m_pAssignedList->InsertEntry( editedClassPath, nPos ); + m_pAssignedList->SelectEntryPos( nPos ); + } + } + } + else + { + m_pParamEditDlg->SetParameter( editedClassPath ); + } +} short SvxJavaParameterDlg::Execute() { @@ -905,11 +944,18 @@ Sequence< OUString > SvxJavaParameterDlg::GetParameters() const Sequence< OUString > aParamList( nCount ); OUString* pArray = aParamList.getArray(); for ( sal_Int32 i = 0; i < nCount; ++i ) - pArray[i] = m_pAssignedList->GetEntry(i); + pArray[i] = OUString( m_pAssignedList->GetEntry(i) ); return aParamList; } +void SvxJavaParameterDlg::DisableButtons() +{ + DisableAssignButton(); + DisableEditButton(); + DisableRemoveButton(); +} + void SvxJavaParameterDlg::SetParameters( Sequence< OUString >& rParams ) { m_pAssignedList->Clear(); @@ -920,6 +966,49 @@ void SvxJavaParameterDlg::SetParameters( Sequence< OUString >& rParams ) OUString sParam = OUString( *pArray++ ); m_pAssignedList->InsertEntry( sParam ); } + DisableEditButton(); + DisableRemoveButton(); +} + +// class SvxJavaParameterEditDlg --------------------------------------------- + +SvxJavaParameterEditDlg::SvxJavaParameterEditDlg( vcl::Window* pParent ) : + + ModalDialog( pParent, "JavaStartParametersEdit", + "cui/ui/javastartparameterseditdialog.ui" ) +{ + get( m_pParameterEditField, "parametereditfield"); +} + +SvxJavaParameterEditDlg::~SvxJavaParameterEditDlg() +{ + disposeOnce(); +} + +void SvxJavaParameterEditDlg::dispose() +{ + m_pParameterEditField.clear(); + ModalDialog::dispose(); +} + + +short SvxJavaParameterEditDlg::Execute() +{ + m_pParameterEditField->GrabFocus(); + return ModalDialog::Execute(); +} + +OUString SvxJavaParameterEditDlg::GetParameter() const +{ + OUString sParamEdit = comphelper::string::strip(m_pParameterEditField->GetText(), ' '); + return sParamEdit; +} + + +void SvxJavaParameterEditDlg::SetParameter( OUString strParams ) +{ + m_pParameterEditField->SetText( strParams ); + m_pParameterEditField->SetCursorAtLast(); } // class SvxJavaClassPathDlg --------------------------------------------- diff --git a/cui/source/options/optjava.hxx b/cui/source/options/optjava.hxx index b887093011e5..049915969743 100644 --- a/cui/source/options/optjava.hxx +++ b/cui/source/options/optjava.hxx @@ -43,6 +43,7 @@ typedef void* JavaInfo; #endif class SvxJavaParameterDlg; +class SvxJavaParameterEditDlg; class SvxJavaClassPathDlg; class SvxJavaListBox; @@ -129,6 +130,8 @@ private: VclPtr<PushButton> m_pEditBtn; + VclPtr<SvxJavaParameterEditDlg> m_pParamEditDlg; + DECL_LINK_TYPED(ModifyHdl_Impl, Edit&, void); DECL_LINK_TYPED(AssignHdl_Impl, Button*, void); DECL_LINK_TYPED(SelectHdl_Impl, ListBox&, void); @@ -151,6 +154,9 @@ private: inline void EnableAssignButton() { m_pAssignBtn->Enable(); } + inline void DisableAssignButton() + { m_pAssignBtn->Disable(); } + inline void DisableRemoveButton() { m_pRemoveBtn->Disable(); } @@ -167,6 +173,26 @@ public: css::uno::Sequence< OUString > GetParameters() const; void SetParameters( css::uno::Sequence< OUString >& rParams ); + void DisableButtons(); + void EditParameter(); +}; + +// class SvxJavaParameterEditDlg --------------------------------------------- + +class SvxJavaParameterEditDlg : public ModalDialog +{ +private: + VclPtr<Edit> m_pParameterEditField; + +public: + explicit SvxJavaParameterEditDlg( vcl::Window* pParent ); + virtual ~SvxJavaParameterEditDlg(); + virtual void dispose() override; + + virtual short Execute() override; + + OUString GetParameter() const; + void SetParameter( OUString rParams ); }; // class SvxJavaClassPathDlg --------------------------------------------- diff --git a/cui/uiconfig/ui/javastartparametersdialog.ui b/cui/uiconfig/ui/javastartparametersdialog.ui index e1237ca77afb..bba3f96c4607 100644 --- a/cui/uiconfig/ui/javastartparametersdialog.ui +++ b/cui/uiconfig/ui/javastartparametersdialog.ui @@ -165,11 +165,13 @@ </child> <child> <object class="GtkButton" id="assignbtn"> - <property name="label" translatable="yes">_Assign</property> + <property name="label" translatable="yes">_Add</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_underline">True</property> + <property name="xalign">0.49000000953674316</property> + <property name="yalign">0.49000000953674316</property> </object> <packing> <property name="left_attach">1</property> @@ -177,13 +179,40 @@ </packing> </child> <child> - <object class="GtkButton" id="removebtn"> - <property name="label" translatable="yes">_Remove</property> + <object class="GtkBox" id="box2"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="valign">start</property> - <property name="use_underline">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkButton" id="editbtn"> + <property name="label" translatable="yes">_Edit</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="valign">start</property> + <property name="use_underline">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="removebtn"> + <property name="label" translatable="yes">_Remove</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="valign">start</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="left_attach">1</property> @@ -191,20 +220,6 @@ </packing> </child> <child> - <object class="GtkButton" id="editbtn"> - <property name="label" translatable="yes">_Edit</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="valign">start</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> <placeholder/> </child> <child> diff --git a/cui/uiconfig/ui/javastartparameterseditdialog.ui b/cui/uiconfig/ui/javastartparameterseditdialog.ui new file mode 100644 index 000000000000..73ebe23e5f69 --- /dev/null +++ b/cui/uiconfig/ui/javastartparameterseditdialog.ui @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.3 --> +<interface> + <requires lib="gtk+" version="3.0"/> + <object class="GtkDialog" id="JavaStartParametersEdit"> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <property name="title" translatable="yes">Edit Parameter</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="ok"> + <property name="label">gtk-ok</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">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="cancel"> + <property name="label">gtk-cancel</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">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkEntry" id="parametereditfield"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="0">ok</action-widget> + <action-widget response="0">cancel</action-widget> + </action-widgets> + </object> +</interface>
\ No newline at end of file diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx index ec947b672db0..30741d517d33 100644 --- a/include/vcl/edit.hxx +++ b/include/vcl/edit.hxx @@ -237,6 +237,8 @@ public: virtual void SetText( const OUString& rStr, const Selection& rNewSelection ); virtual OUString GetText() const override; + void SetCursorAtLast(); + void SetPlaceholderText( const OUString& rStr ); OUString GetPlaceholderText() const; diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 55acf9f1415a..7520cb416d0d 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2699,6 +2699,12 @@ OUString Edit::GetText() const return maText.toString(); } +void Edit::SetCursorAtLast(){ + OUString str = GetText(); + sal_Int32 len = str.getLength(); + ImplSetCursorPos( len, false ); +} + void Edit::SetPlaceholderText( const OUString& rStr ) { if ( mpSubEdit ) |