diff options
author | Noel Grandin <noel@peralex.com> | 2014-11-25 09:53:48 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-11-25 10:34:14 +0200 |
commit | 3d16e27d89298d4cf9efb46410c139fe1d46fa83 (patch) | |
tree | a6c63d9f4fa073d1da36c76b228e1839f9ec464e /wizards | |
parent | java,wizards: convert event listeners to inner classes (diff) | |
download | core-3d16e27d89298d4cf9efb46410c139fe1d46fa83.tar.gz core-3d16e27d89298d4cf9efb46410c139fe1d46fa83.zip |
java,wizards: convert event listeners to inner classes
Change-Id: Id6a6991704009b909e5108daf65c48722fa97447
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/com/sun/star/wizards/form/FormConfiguration.java | 14 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java | 25 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/ui/UnoDialog2.java | 13 |
3 files changed, 35 insertions, 17 deletions
diff --git a/wizards/com/sun/star/wizards/form/FormConfiguration.java b/wizards/com/sun/star/wizards/form/FormConfiguration.java index b0b052b524bf..0214a3251d9e 100644 --- a/wizards/com/sun/star/wizards/form/FormConfiguration.java +++ b/wizards/com/sun/star/wizards/form/FormConfiguration.java @@ -17,17 +17,19 @@ */ package com.sun.star.wizards.form; +import com.sun.star.awt.ItemEvent; import com.sun.star.awt.XCheckBox; import com.sun.star.awt.XFixedText; import com.sun.star.awt.XListBox; import com.sun.star.awt.XRadioButton; import com.sun.star.wizards.common.Helper; import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.RelationController; import com.sun.star.wizards.ui.CommandFieldSelection; import com.sun.star.wizards.ui.UIConsts; import com.sun.star.wizards.ui.UnoDialog; import com.sun.star.wizards.ui.WizardDialog; -import com.sun.star.wizards.db.RelationController; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; /** * To change the template for this generated type comment go to @@ -46,7 +48,6 @@ public class FormConfiguration XListBox lstRelations; String[] sreferencedTables; CommandFieldSelection CurSubFormFieldSelection; - String SSUBFORMMODE = "toggleSubFormMode"; String STOGGLESTEPS = "toggleSteps"; String SONEXISTINGRELATIONSELECTION = "onexistingRelationSelection"; boolean bsupportsRelations; @@ -64,7 +65,12 @@ public class FormConfiguration String sSubFormDescription = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 3); // CheckBox 'Add sub form' - chkcreateSubForm = CurUnoDialog.insertCheckBox("chkcreateSubForm", SSUBFORMMODE, this, + chkcreateSubForm = CurUnoDialog.insertCheckBox("chkcreateSubForm", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubFormMode(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH @@ -132,7 +138,7 @@ public class FormConfiguration return ((chkcreateSubForm.getState() == 1) && (optOnExistingRelation.getState())); } - public void toggleSubFormMode() + private void toggleSubFormMode() { boolean bdoEnable = (this.chkcreateSubForm.getState() == 1); Helper.setUnoPropertyValue(UnoDialog.getModel(optOnExistingRelation), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoEnable && bsupportsRelations)); diff --git a/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java index 7ec9e5b5fa7e..9cf40f1fd839 100644 --- a/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java +++ b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java @@ -17,6 +17,7 @@ */ package com.sun.star.wizards.table; +import com.sun.star.awt.ItemEvent; import com.sun.star.awt.XCheckBox; import com.sun.star.awt.XFixedText; import com.sun.star.awt.XListBox; @@ -33,6 +34,7 @@ import com.sun.star.wizards.ui.FieldSelection; import com.sun.star.wizards.ui.UIConsts; import com.sun.star.wizards.ui.UnoDialog; import com.sun.star.wizards.ui.XFieldSelectionListener; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; public class PrimaryKeyHandler implements XFieldSelectionListener { @@ -79,7 +81,12 @@ public class PrimaryKeyHandler implements XFieldSelectionListener 40, sExplanations, Boolean.TRUE, 91, 27, IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 233 }); - chkcreatePrimaryKey = CurUnoDialog.insertCheckBox("chkcreatePrimaryKey", SPRIMEKEYMODE, this, + chkcreatePrimaryKey = CurUnoDialog.insertCheckBox("chkcreatePrimaryKey", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH @@ -119,7 +126,12 @@ public class PrimaryKeyHandler implements XFieldSelectionListener UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SEVERAL", sUseSeveral, 106, 132, IPRIMEKEYSTEP, Short.valueOf(curtabindex++), 200 }); - chkApplyAutoValueAutomatic = CurUnoDialog.insertCheckBox("chkApplyAutoValueAutomatic", SPRIMEKEYMODE, this, + chkApplyAutoValueAutomatic = CurUnoDialog.insertCheckBox("chkApplyAutoValueAutomatic", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH @@ -167,7 +179,12 @@ public class PrimaryKeyHandler implements XFieldSelectionListener 80 }); - chkApplyAutoValueExisting = CurUnoDialog.insertCheckBox("chkApplyAutoValueExisting", SPRIMEKEYMODE, this, + chkApplyAutoValueExisting = CurUnoDialog.insertCheckBox("chkApplyAutoValueExisting", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + togglePrimeKeyFields(); + } + }, new String[] { PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH @@ -243,7 +260,7 @@ public class PrimaryKeyHandler implements XFieldSelectionListener return false; } - public void togglePrimeKeyFields() + private void togglePrimeKeyFields() { boolean bdoEnable = (this.chkcreatePrimaryKey.getState() == 1); Helper.setUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoEnable)); diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog2.java b/wizards/com/sun/star/wizards/ui/UnoDialog2.java index 0226e0670911..77f0fa36e6c5 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog2.java +++ b/wizards/com/sun/star/wizards/ui/UnoDialog2.java @@ -21,6 +21,7 @@ import com.sun.star.awt.XActionListener; import com.sun.star.awt.XButton; import com.sun.star.awt.XCheckBox; import com.sun.star.awt.XControl; +import com.sun.star.awt.XItemListener; import com.sun.star.awt.XListBox; import com.sun.star.awt.XProgressBar; import com.sun.star.awt.XRadioButton; @@ -73,23 +74,17 @@ public class UnoDialog2 extends UnoDialog return xButton; } - public XCheckBox insertCheckBox(String sName, String itemChangedMethodName, Object eventTarget, String[] sPropNames, Object[] oPropValues) + public XCheckBox insertCheckBox(String sName, XItemListener itemListener, String[] sPropNames, Object[] oPropValues) { XCheckBox xCheckBox = (XCheckBox) insertControlModel2("com.sun.star.awt.UnoControlCheckBoxModel", sName, sPropNames, oPropValues, XCheckBox.class); - if (itemChangedMethodName != null) + if (itemListener != null) { - xCheckBox.addItemListener(guiEventListener); - guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChangedMethodName, eventTarget); + xCheckBox.addItemListener(itemListener); } return xCheckBox; } - public XCheckBox insertCheckBox(String sName, String itemChangedMethodName, String[] sPropNames, Object[] oPropValues) - { - return insertCheckBox(sName, itemChangedMethodName, this, sPropNames, oPropValues); - } - public XListBox insertListBox(String sName, String actionPerformedMethodName, String itemChangedMethodName, Object eventTarget, String[] sPropNames, Object[] oPropValues) { XListBox xListBox = (XListBox) insertControlModel2("com.sun.star.awt.UnoControlListBoxModel", sName, sPropNames, oPropValues, XListBox.class); |