summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/ui
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-11-25 08:50:54 +0200
committerNoel Grandin <noel@peralex.com>2014-11-25 10:34:11 +0200
commit57a2f61e1b5c57ba78b07178dc37dc4b80005ab6 (patch)
treebaef43efee2909877d37ead61b38a3a6418d0f19 /wizards/com/sun/star/wizards/ui
parent74c6c6151cab078a6e31c66819c0609ef9637e6e (diff)
java,wizards: convert event listeners to inner classes
Change-Id: I8379bb8194b86a194c351c5e33e1765b8feb59d2
Diffstat (limited to 'wizards/com/sun/star/wizards/ui')
-rw-r--r--wizards/com/sun/star/wizards/ui/ButtonList.java31
-rw-r--r--wizards/com/sun/star/wizards/ui/ImageList.java19
-rw-r--r--wizards/com/sun/star/wizards/ui/PathSelection.java11
-rw-r--r--wizards/com/sun/star/wizards/ui/UnoDialog2.java29
-rw-r--r--wizards/com/sun/star/wizards/ui/WizardDialog.java56
5 files changed, 89 insertions, 57 deletions
diff --git a/wizards/com/sun/star/wizards/ui/ButtonList.java b/wizards/com/sun/star/wizards/ui/ButtonList.java
index 81069ec0079d..76d06fb18c31 100644
--- a/wizards/com/sun/star/wizards/ui/ButtonList.java
+++ b/wizards/com/sun/star/wizards/ui/ButtonList.java
@@ -17,6 +17,10 @@
*/
package com.sun.star.wizards.ui;
+import javax.swing.ListModel;
+import javax.swing.event.ListDataEvent;
+
+import com.sun.star.awt.ActionEvent;
import com.sun.star.awt.Size;
import com.sun.star.awt.XActionListener;
import com.sun.star.awt.XButton;
@@ -28,15 +32,12 @@ import com.sun.star.awt.XItemListener;
import com.sun.star.awt.XWindow;
import com.sun.star.lang.EventObject;
import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.HelpIds;
import com.sun.star.wizards.common.Helper;
import com.sun.star.wizards.common.IRenderer;
-import com.sun.star.wizards.common.PropertySetHelper;
import com.sun.star.wizards.common.PropertyNames;
-
-import javax.swing.ListModel;
-import javax.swing.event.ListDataEvent;
-
-import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.wizards.common.PropertySetHelper;
+import com.sun.star.wizards.ui.event.XActionListenerAdapter;
public class ButtonList implements XItemEventBroadcaster, XActionListener
{
@@ -149,7 +150,12 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
final Integer btnSize = Integer.valueOf(14);
// TODO: if list of strings not the same length of list object, office will die.
- btnBack = dialog.insertButton(m_aControlName + "_btnBack", "prevPage", this, pNames1, new Object[]
+ btnBack = dialog.insertButton(m_aControlName + "_btnBack", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ prevPage();
+ }
+ }, pNames1, new Object[]
{
btnSize,
HelpIds.getHelpIdString(helpURL++),
@@ -161,7 +167,12 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
btnSize
});
- btnNext = dialog.insertButton(m_aControlName + "_btnNext", "nextPage", this, pNames1, new Object[]
+ btnNext = dialog.insertButton(m_aControlName + "_btnNext", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ nextPage();
+ }
+ }, pNames1, new Object[]
{
btnSize,
HelpIds.getHelpIdString(helpURL++),
@@ -563,7 +574,7 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
showButtons = b;
}
- public void nextPage()
+ private void nextPage()
{
if (pageStart < getListModel().getSize() - rows * cols)
{
@@ -571,7 +582,7 @@ public class ButtonList implements XItemEventBroadcaster, XActionListener
}
}
- public void prevPage()
+ private void prevPage()
{
if (pageStart == 0)
{
diff --git a/wizards/com/sun/star/wizards/ui/ImageList.java b/wizards/com/sun/star/wizards/ui/ImageList.java
index e3139ff07830..163a3547f267 100644
--- a/wizards/com/sun/star/wizards/ui/ImageList.java
+++ b/wizards/com/sun/star/wizards/ui/ImageList.java
@@ -17,6 +17,7 @@
*/
package com.sun.star.wizards.ui;
+import com.sun.star.awt.ActionEvent;
import com.sun.star.awt.Key;
import com.sun.star.awt.KeyEvent;
import com.sun.star.awt.MouseEvent;
@@ -223,7 +224,12 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
{
final Integer btnSize = 14;
- btnBack = dialog.insertButton(name + "_btnBack", "prevPage", this, pNames1, new Object[]
+ btnBack = dialog.insertButton(name + "_btnBack", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ prevPage();
+ }
+ }, pNames1, new Object[]
{
btnSize,
HelpIds.getHelpIdString(helpURL++),
@@ -235,7 +241,12 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
btnSize
});
- btnNext = dialog.insertButton(name + "_btnNext", "nextPage", this, pNames1, new Object[]
+ btnNext = dialog.insertButton(name + "_btnNext", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ nextPage();
+ }
+ }, pNames1, new Object[]
{
btnSize,
HelpIds.getHelpIdString(helpURL++),
@@ -722,7 +733,7 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
showButtons = b;
}
- public void nextPage()
+ private void nextPage()
{
if (pageStart < getListModel().getSize() - rows * cols)
{
@@ -730,7 +741,7 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
}
}
- public void prevPage()
+ private void prevPage()
{
if (pageStart == 0)
{
diff --git a/wizards/com/sun/star/wizards/ui/PathSelection.java b/wizards/com/sun/star/wizards/ui/PathSelection.java
index d5dc74295e2f..207c97b44930 100644
--- a/wizards/com/sun/star/wizards/ui/PathSelection.java
+++ b/wizards/com/sun/star/wizards/ui/PathSelection.java
@@ -17,12 +17,14 @@
*/
package com.sun.star.wizards.ui;
+import com.sun.star.awt.ActionEvent;
import com.sun.star.awt.XTextComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.Exception;
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;
public class PathSelection
{
@@ -81,7 +83,12 @@ public class PathSelection
});
//CurUnoDialog.setControlProperty("txtSavePath", PropertyNames.READ_ONLY, Boolean.TRUE);
CurUnoDialog.setControlProperty("txtSavePath", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE);
- CurUnoDialog.insertButton("cmdSelectPath", "triggerPathPicker", this, new String[]
+ CurUnoDialog.insertButton("cmdSelectPath", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ triggerPathPicker();
+ }
+ }, new String[]
{
PropertyNames.PROPERTY_ENABLED, 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
}, new Object[]
@@ -114,7 +121,7 @@ public class PathSelection
}
}
- public void triggerPathPicker()
+ private void triggerPathPicker()
{
try
{
diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog2.java b/wizards/com/sun/star/wizards/ui/UnoDialog2.java
index 04cc3858265f..0226e0670911 100644
--- a/wizards/com/sun/star/wizards/ui/UnoDialog2.java
+++ b/wizards/com/sun/star/wizards/ui/UnoDialog2.java
@@ -17,20 +17,15 @@
*/
package com.sun.star.wizards.ui;
+import com.sun.star.awt.XActionListener;
import com.sun.star.awt.XButton;
import com.sun.star.awt.XCheckBox;
-import com.sun.star.awt.XComboBox;
import com.sun.star.awt.XControl;
-import com.sun.star.awt.XCurrencyField;
-import com.sun.star.awt.XDateField;
import com.sun.star.awt.XListBox;
-import com.sun.star.awt.XNumericField;
-import com.sun.star.awt.XPatternField;
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.XTimeField;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
@@ -56,27 +51,19 @@ public class UnoDialog2 extends UnoDialog
super(xmsf);
}
- public XButton insertButton(String sName, String actionPerformedMethodName, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ public XButton insertButton(String sName, XActionListener actionListener, String[] sPropNames, Object[] oPropValues)
{
-
XButton xButton = (XButton) insertControlModel2("com.sun.star.awt.UnoControlButtonModel", sName, sPropNames, oPropValues, XButton.class);
- if (actionPerformedMethodName != null)
+ if (actionListener != null)
{
- xButton.addActionListener(guiEventListener);
- guiEventListener.add(sName, EventNames.ACTION_PERFORMED, actionPerformedMethodName, eventTarget);
+ xButton.addActionListener(actionListener);
}
return xButton;
}
- public XButton insertButton(String sName, String actionPerformedMethodName, String[] sPropNames, Object[] oPropValues)
- {
- return insertButton(sName, actionPerformedMethodName, this, sPropNames, oPropValues);
- }
-
- public XButton insertImageButton(String sName, com.sun.star.awt.XActionListener actionPerformed, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ public XButton insertImageButton(String sName, com.sun.star.awt.XActionListener actionPerformed, String[] sPropNames, Object[] oPropValues)
{
-
XButton xButton = (XButton) insertControlModel2("com.sun.star.awt.UnoControlButtonModel", sName, sPropNames, oPropValues, XButton.class);
if (actionPerformed != null)
@@ -86,14 +73,8 @@ public class UnoDialog2 extends UnoDialog
return xButton;
}
- public XButton insertImageButton(String sName, com.sun.star.awt.XActionListener actionPerformed, String[] sPropNames, Object[] oPropValues)
- {
- return insertImageButton(sName, actionPerformed, this, sPropNames, oPropValues);
- }
-
public XCheckBox insertCheckBox(String sName, String itemChangedMethodName, Object eventTarget, String[] sPropNames, Object[] oPropValues)
{
-
XCheckBox xCheckBox = (XCheckBox) insertControlModel2("com.sun.star.awt.UnoControlCheckBoxModel", sName, sPropNames, oPropValues, XCheckBox.class);
if (itemChangedMethodName != null)
diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java
index d29e0264e8c9..3d80b095e931 100644
--- a/wizards/com/sun/star/wizards/ui/WizardDialog.java
+++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java
@@ -20,6 +20,7 @@ package com.sun.star.wizards.ui;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
+import com.sun.star.awt.ActionEvent;
import com.sun.star.awt.FontDescriptor;
import com.sun.star.awt.PushButtonType;
import com.sun.star.awt.XControl;
@@ -42,17 +43,13 @@ import com.sun.star.wizards.common.HelpIds;
import com.sun.star.wizards.common.Helper;
import com.sun.star.wizards.common.PropertyNames;
import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.ui.event.XActionListenerAdapter;
import com.sun.star.wizards.ui.event.XItemListenerAdapter;
import com.sun.star.wizards.ui.event.XWindowListenerAdapter;
public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeListener, XTerminateListener, XCompletion
{
- private static final String NEXT_ACTION_PERFORMED = "gotoNextAvailableStep";
- private static final String BACK_ACTION_PERFORMED = "gotoPreviousAvailableStep";
- private static final String FINISH_ACTION_PERFORMED = "finishWizard_1";
- private static final String CANCEL_ACTION_PERFORMED = "cancelWizard_1";
- private static final String HELP_ACTION_PERFORMED = "callHelp";
public VetoableChangeSupport vetos = new VetoableChangeSupport(this);
private static final int iButtonWidth = 50;
private int nNewStep = 1;
@@ -443,7 +440,12 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
};
Helper.setUnoPropertyValue(super.xDialogModel, PropertyNames.PROPERTY_HELPURL, HelpIds.getHelpIdString(hid));
- insertButton("btnWizardHelp", HELP_ACTION_PERFORMED, new String[]
+ insertButton("btnWizardHelp", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ callHelp();
+ }
+ }, new String[]
{
PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, "PushButtonType", PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
},
@@ -451,25 +453,45 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
{
true, IButtonHeight, oWizardResource.getResText(UIConsts.RID_COMMON + 15), Integer.valueOf(iHelpPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.HELP_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth
});
- insertButton("btnWizardBack", BACK_ACTION_PERFORMED, propNames,
+ insertButton("btnWizardBack", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ gotoPreviousAvailableStep();
+ }
+ }, propNames,
new Object[]
{
false, IButtonHeight, HelpIds.getHelpIdString(hid + 2), oWizardResource.getResText(UIConsts.RID_COMMON + 13), Integer.valueOf(iBackPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.STANDARD_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth
});
- insertButton("btnWizardNext", NEXT_ACTION_PERFORMED, propNames,
+ insertButton("btnWizardNext", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ gotoNextAvailableStep();
+ }
+ }, propNames,
new Object[]
{
true, IButtonHeight, HelpIds.getHelpIdString(hid + 3), oWizardResource.getResText(UIConsts.RID_COMMON + 14), Integer.valueOf(iNextPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.STANDARD_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth
});
- insertButton("btnWizardFinish", FINISH_ACTION_PERFORMED, propNames,
+ insertButton("btnWizardFinish", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ finishWizard_1();
+ }
+ }, propNames,
new Object[]
{
true, IButtonHeight, HelpIds.getHelpIdString(hid + 4), oWizardResource.getResText(UIConsts.RID_COMMON + 12), Integer.valueOf(iFinishPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.STANDARD_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth
});
- insertButton("btnWizardCancel", CANCEL_ACTION_PERFORMED, propNames,
+ insertButton("btnWizardCancel", new XActionListenerAdapter() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ cancelWizard_1();
+ }
+ }, propNames,
new Object[]
{
true, IButtonHeight, HelpIds.getHelpIdString(hid + 5), oWizardResource.getResText(UIConsts.RID_COMMON + 11), Integer.valueOf(iCancelPosX), Integer.valueOf(iBtnPosY), Short.valueOf((short) PushButtonType.STANDARD_value), ICurStep, Short.valueOf(curtabindex++), IButtonWidth
@@ -584,7 +606,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
}
}
- public synchronized void gotoPreviousAvailableStep()
+ private synchronized void gotoPreviousAvailableStep()
{
boolean bIsEnabled;
if (nNewStep > 1)
@@ -624,7 +646,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
return -1;
}
- public synchronized void gotoNextAvailableStep()
+ private synchronized void gotoNextAvailableStep()
{
nOldStep = nNewStep;
nNewStep = getNextAvailableStep();
@@ -639,7 +661,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
/**
* This function will call if the finish button is pressed on the UI.
*/
- public void finishWizard_1()
+ private void finishWizard_1()
{
enableFinishButton(false);
boolean success = false;
@@ -708,13 +730,13 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
public void cancelWizard()
{
- //can be overwritten by extending class
+ //can be overridden by extending class
xDialog.endExecute();
}
- public void callHelp()
+ protected void callHelp()
{
- //should be overwritten by extending class
+ //should be overridden by extending class
}
public void removeTerminateListener()
@@ -732,7 +754,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
* if this method was not called before,
* perform a cancel.
*/
- public void cancelWizard_1()
+ private void cancelWizard_1()
{
cancelWizard();
removeTerminateListener();