diff options
author | Noel Grandin <noel@peralex.com> | 2014-11-25 10:22:47 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-11-25 10:34:22 +0200 |
commit | 207f6c7ee15742005b2b37f26a3e2de5cb010421 (patch) | |
tree | 145e27b6524b1c7a62c33b939f74f08932a3f93c /wizards | |
parent | 40f7f1cf749d788b328bd132ed4bbeb1a19ee90b (diff) |
java,wizards: convert event listeners to inner classes
Change-Id: I3c30d3865302741c7fbdc811e32686a921b6a4df
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/com/sun/star/wizards/form/Finalizer.java | 11 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/query/Finalizer.java | 11 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/report/ReportFinalizer.java | 24 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/table/FieldFormatter.java | 13 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/table/Finalizer.java | 12 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/ui/PathSelection.java | 12 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/ui/UnoDialog.java | 1 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/ui/UnoDialog2.java | 13 |
8 files changed, 68 insertions, 29 deletions
diff --git a/wizards/com/sun/star/wizards/form/Finalizer.java b/wizards/com/sun/star/wizards/form/Finalizer.java index b9806b58ecdc..ee994b4dfddd 100644 --- a/wizards/com/sun/star/wizards/form/Finalizer.java +++ b/wizards/com/sun/star/wizards/form/Finalizer.java @@ -17,11 +17,13 @@ */ package com.sun.star.wizards.form; +import com.sun.star.awt.TextEvent; import com.sun.star.awt.XRadioButton; import com.sun.star.awt.XTextComponent; import com.sun.star.wizards.common.Desktop; import com.sun.star.wizards.common.PropertyNames; import com.sun.star.wizards.ui.*; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; /** * @@ -56,7 +58,12 @@ public class Finalizer { UIConsts.INTEGERS[8], slblFormName, 97, 25, UIConsts.INTEGERS[8], Short.valueOf(curtabindex++), 111 }); - txtFormName = CurUnoDialog.insertTextField("txtFormName", "toggleFinishButton", this, + txtFormName = CurUnoDialog.insertTextField("txtFormName", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent event) { + toggleFinishButton(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH @@ -106,7 +113,7 @@ public class Finalizer } } - public void toggleFinishButton() + private void toggleFinishButton() { CurUnoDialog.enableFinishButton(txtFormName.getText().length() > 0); } diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java index 6cf03b67f251..8efe9abf76ed 100644 --- a/wizards/com/sun/star/wizards/query/Finalizer.java +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -17,6 +17,7 @@ */ package com.sun.star.wizards.query; +import com.sun.star.awt.TextEvent; import com.sun.star.awt.XRadioButton; import com.sun.star.awt.XTextComponent; import com.sun.star.lang.IllegalArgumentException; @@ -28,6 +29,7 @@ import com.sun.star.wizards.common.Helper; import com.sun.star.wizards.common.PropertyNames; import com.sun.star.wizards.ui.UIConsts; import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; import java.util.logging.Level; import java.util.logging.Logger; @@ -66,7 +68,12 @@ public class Finalizer { 8, reslblQueryTitle, 95, 27, Integer.valueOf(QueryWizard.SOSUMMARY_PAGE), Short.valueOf(curtabindex++), 52 }); - m_aTxtTitle = m_queryWizard.insertTextField("txtQueryTitle", "changeTitle", this, new String[] + m_aTxtTitle = m_queryWizard.insertTextField("txtQueryTitle", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent event) { + changeTitle(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH }, @@ -119,7 +126,7 @@ public class Finalizer }); } - public void changeTitle() + private void changeTitle() { final String TitleName = m_aTxtTitle.getText(); m_queryWizard.enableFinishButton( TitleName.length() > 0 ); diff --git a/wizards/com/sun/star/wizards/report/ReportFinalizer.java b/wizards/com/sun/star/wizards/report/ReportFinalizer.java index af3843af2d82..af5ea07deaed 100644 --- a/wizards/com/sun/star/wizards/report/ReportFinalizer.java +++ b/wizards/com/sun/star/wizards/report/ReportFinalizer.java @@ -16,15 +16,21 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ package com.sun.star.wizards.report; -import com.sun.star.uno.Exception; -import com.sun.star.wizards.common.*; -import com.sun.star.wizards.ui.*; -import com.sun.star.wizards.ui.event.XItemListenerAdapter; import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.TextEvent; import com.sun.star.awt.VclWindowPeerAttribute; import com.sun.star.awt.XTextComponent; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Exception; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; import com.sun.star.wizards.db.RecordParser; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.WizardDialog; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; public class ReportFinalizer { @@ -33,7 +39,6 @@ public class ReportFinalizer XTextComponent xTitleTextBox; XTextComponent[] xSaveTextBox = new XTextComponent[2]; Object chkTemplate; - String CHANGEREPORTTITLE_FUNCNAME = "changeReportTitle"; String TemplatePath; String StoreName; boolean bfinalaskbeforeOverwrite; @@ -70,7 +75,12 @@ public class ReportFinalizer 8, sReportTitle, 95, 27, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 68 }); - xTitleTextBox = CurUnoDialog.insertTextField("txtTitle", CHANGEREPORTTITLE_FUNCNAME, this, + xTitleTextBox = CurUnoDialog.insertTextField("txtTitle", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent arg0) { + changeReportTitle(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH @@ -211,7 +221,7 @@ public class ReportFinalizer return StorePath; } - public void changeReportTitle() + private void changeReportTitle() { final String TitleName = xTitleTextBox.getText(); CurReportDocument.liveupdate_updateReportTitle(TitleName); diff --git a/wizards/com/sun/star/wizards/table/FieldFormatter.java b/wizards/com/sun/star/wizards/table/FieldFormatter.java index cad742573cd4..a9a41cadbe08 100644 --- a/wizards/com/sun/star/wizards/table/FieldFormatter.java +++ b/wizards/com/sun/star/wizards/table/FieldFormatter.java @@ -20,6 +20,7 @@ package com.sun.star.wizards.table; import com.sun.star.awt.ActionEvent; import com.sun.star.awt.FontDescriptor; import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.TextEvent; import com.sun.star.awt.XButton; import com.sun.star.awt.XItemListener; import com.sun.star.awt.XListBox; @@ -35,6 +36,7 @@ import com.sun.star.wizards.db.TableDescriptor; import com.sun.star.wizards.ui.UIConsts; import com.sun.star.wizards.ui.UnoDialog; import com.sun.star.wizards.ui.event.XActionListenerAdapter; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; public class FieldFormatter implements XItemListener { @@ -49,10 +51,6 @@ public class FieldFormatter implements XItemListener XButton btnShiftUp; XButton btnShiftDown; short curtabindex; - String TOGGLEBUTTONS = "toggleButtons"; - String ADDFIELDNAME = "addFieldName"; - String REMOVEFIELDNAME = "removeFieldName"; - String MODIFYFIELDNAME = "modifyFieldName"; String[] fieldnames; String suntitled; Integer IFieldFormatStep; @@ -183,7 +181,12 @@ public class FieldFormatter implements XItemListener UIConsts.INTEGERS[8], sFieldName, 158, 39, IFieldFormatStep, Short.valueOf(curtabindex++), 94 }); - txtfieldname = CurUnoDialog.insertTextField("txtfieldname", MODIFYFIELDNAME, this, + txtfieldname = CurUnoDialog.insertTextField("txtfieldname", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent event) { + modifyFieldName(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH diff --git a/wizards/com/sun/star/wizards/table/Finalizer.java b/wizards/com/sun/star/wizards/table/Finalizer.java index 5d081ec329b0..f4cb9d46e23e 100644 --- a/wizards/com/sun/star/wizards/table/Finalizer.java +++ b/wizards/com/sun/star/wizards/table/Finalizer.java @@ -17,6 +17,7 @@ */ package com.sun.star.wizards.table; +import com.sun.star.awt.TextEvent; import com.sun.star.awt.XListBox; import com.sun.star.awt.XRadioButton; import com.sun.star.awt.XTextComponent; @@ -26,6 +27,7 @@ import com.sun.star.wizards.common.JavaTools; import com.sun.star.wizards.common.PropertyNames; import com.sun.star.wizards.db.TableDescriptor; import com.sun.star.wizards.ui.*; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; public class Finalizer { @@ -39,7 +41,6 @@ public class Finalizer XListBox xCatalogListBox; XListBox xSchemaListBox; TableDescriptor curtabledescriptor; - public String SETCOMPLETIONFLAG = "setCompletionFlag"; public static int WORKWITHTABLEMODE = 0; public static int MODIFYTABLEMODE = 1; public static int STARTFORMWIZARDMODE = 2; @@ -76,7 +77,12 @@ public class Finalizer { UIConsts.INTEGERS[8], slblTableName, 97, 25, IFINALSTEP, 220 }); - txtTableName = CurUnoDialog.insertTextField("txtTableName", SETCOMPLETIONFLAG, this, + txtTableName = CurUnoDialog.insertTextField("txtTableName", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent event) { + setCompletionFlag(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH @@ -344,7 +350,7 @@ public class Finalizer return (txtTableName.getText().length() > 0); } - public void setCompletionFlag() + private void setCompletionFlag() { CurUnoDialog.setcompleted(TableWizard.SOFINALPAGE, iscompleted()); } diff --git a/wizards/com/sun/star/wizards/ui/PathSelection.java b/wizards/com/sun/star/wizards/ui/PathSelection.java index 207c97b44930..7fa09c5d6269 100644 --- a/wizards/com/sun/star/wizards/ui/PathSelection.java +++ b/wizards/com/sun/star/wizards/ui/PathSelection.java @@ -18,6 +18,7 @@ package com.sun.star.wizards.ui; import com.sun.star.awt.ActionEvent; +import com.sun.star.awt.TextEvent; import com.sun.star.awt.XTextComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.Exception; @@ -25,6 +26,7 @@ import com.sun.star.wizards.common.FileAccess; import com.sun.star.wizards.common.PropertyNames; import com.sun.star.wizards.common.SystemDialog; import com.sun.star.wizards.ui.event.XActionListenerAdapter; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; public class PathSelection { @@ -74,7 +76,13 @@ public class PathSelection Boolean.valueOf(Enabled), 8, LabelText, Integer.valueOf(XPos), Integer.valueOf(YPos), Integer.valueOf(DialogStep), Short.valueOf(CurTabIndex), Integer.valueOf(Width) }); - xSaveTextBox = CurUnoDialog.insertTextField("txtSavePath", "callXPathSelectionListener", this, new String[] + xSaveTextBox = CurUnoDialog.insertTextField("txtSavePath", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent arg0) { + callXPathSelectionListener(); + } + }, + new String[] { PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH }, new Object[] @@ -174,7 +182,7 @@ public class PathSelection } } - public void callXPathSelectionListener() + private void callXPathSelectionListener() { if (xAction != null) { diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.java b/wizards/com/sun/star/wizards/ui/UnoDialog.java index 5b4eefee3221..07266709f4f8 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog.java +++ b/wizards/com/sun/star/wizards/ui/UnoDialog.java @@ -55,7 +55,6 @@ public class UnoDialog public Resource m_oResource; public XWindowPeer xWindowPeer = null; private PeerConfig m_oPeerConfig; - protected final CommonListener guiEventListener = new CommonListener(); public UnoDialog(XMultiServiceFactory xMSF) { diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog2.java b/wizards/com/sun/star/wizards/ui/UnoDialog2.java index 0c912779b2be..f91fbf93a151 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog2.java +++ b/wizards/com/sun/star/wizards/ui/UnoDialog2.java @@ -27,6 +27,7 @@ import com.sun.star.awt.XProgressBar; import com.sun.star.awt.XRadioButton; import com.sun.star.awt.XScrollBar; import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XTextListener; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XInterface; @@ -34,7 +35,6 @@ import com.sun.star.wizards.common.Desktop; import com.sun.star.wizards.common.Helper; import com.sun.star.wizards.common.PropertyNames; import com.sun.star.wizards.common.SystemDialog; -import com.sun.star.wizards.ui.event.EventNames; /** * This class contains convenience methods for inserting components to a dialog. @@ -115,9 +115,9 @@ public class UnoDialog2 extends UnoDialog return UnoRuntime.queryInterface(XControl.class, oTitledBox); } - public XTextComponent insertTextField(String sName, String sTextChangedMethodName, Object eventTarget, String[] sPropNames, Object[] oPropValues) + public XTextComponent insertTextField(String sName, XTextListener textListener, String[] sPropNames, Object[] oPropValues) { - return (XTextComponent) insertEditField(sName, sTextChangedMethodName, eventTarget, "com.sun.star.awt.UnoControlEditModel", sPropNames, oPropValues, XTextComponent.class); + return (XTextComponent) insertEditField(sName, textListener, "com.sun.star.awt.UnoControlEditModel", sPropNames, oPropValues, XTextComponent.class); } public XControl insertImage(String sName, String[] sPropNames, Object[] oPropValues) @@ -144,13 +144,12 @@ public class UnoDialog2 extends UnoDialog * This method is used for creating Edit, Currency, Date, Formatted, Pattern, File * and Time edit components. */ - private Object insertEditField(String sName, String sTextChangedMethodName, Object eventTarget, String sModelClass, String[] sPropNames, Object[] oPropValues, Class<? extends XInterface> type) + private Object insertEditField(String sName, XTextListener textListener, String sModelClass, String[] sPropNames, Object[] oPropValues, Class<? extends XInterface> type) { XTextComponent xField = (XTextComponent) insertControlModel2(sModelClass, sName, sPropNames, oPropValues, XTextComponent.class); - if (sTextChangedMethodName != null) + if (textListener != null) { - xField.addTextListener(guiEventListener); - guiEventListener.add(sName, EventNames.TEXT_CHANGED, sTextChangedMethodName, eventTarget); + xField.addTextListener(textListener); } return UnoRuntime.queryInterface(type, xField); } |