summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-11-24 15:31:11 +0200
committerNoel Grandin <noel@peralex.com>2014-11-25 10:34:09 +0200
commit74c6c6151cab078a6e31c66819c0609ef9637e6e (patch)
tree9935ec4392d2dc9e55b4dbfe43feb2a22fd5455b
parentbc2b4210d279793e5b08e13d3a1536e74daee321 (diff)
java,wizards: convert some listeners to more normal inner classes
Change-Id: Iee0b9e3409f5789a1ca17eb10b100a457dfbdea3
-rw-r--r--wizards/com/sun/star/wizards/ui/ImageList.java26
-rw-r--r--wizards/com/sun/star/wizards/ui/WizardDialog.java91
-rw-r--r--wizards/com/sun/star/wizards/ui/event/CommonListener.java19
-rw-r--r--wizards/com/sun/star/wizards/ui/event/XItemListenerAdapter.java32
-rw-r--r--wizards/com/sun/star/wizards/ui/event/XMouseListenerAdapter.java39
-rw-r--r--wizards/com/sun/star/wizards/ui/event/XWindowListenerAdapter.java41
6 files changed, 171 insertions, 77 deletions
diff --git a/wizards/com/sun/star/wizards/ui/ImageList.java b/wizards/com/sun/star/wizards/ui/ImageList.java
index 342f264c8e54..e3139ff07830 100644
--- a/wizards/com/sun/star/wizards/ui/ImageList.java
+++ b/wizards/com/sun/star/wizards/ui/ImageList.java
@@ -305,7 +305,7 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
private Short m_tabIndex;
private XControl createImage(UnoDialog2 dialog, int _row, int _col)
- {
+ {
String imageName = name + "_image" + (_row * cols + _col);
XControl image = dialog.insertImage(imageName,
IMAGE_PROPS,
@@ -325,9 +325,18 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
});
XWindow win = UnoRuntime.queryInterface(XWindow.class, image);
- win.addMouseListener(uiEventListener);
+ win.addMouseListener(new XMouseListenerAdapter() {
+ public void mousePressed(MouseEvent event) {
+ int image = getImageFromEvent(event);
+ int index = getIndexFor(image);
+ if (index < listModel.getSize())
+ {
+ focus(image);
+ setSelected(index);
+ }
+ }
+ });
win.addKeyListener(imageKeyListener);
- uiEventListener.add(imageName, EventNames.MOUSE_PRESSED, "mousePressed", this, Object.class);
return image;
}
@@ -759,17 +768,6 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
}
- public void mousePressed(Object event)
- {
- int image = getImageFromEvent(event);
- int index = getIndexFor(image);
- if (index < listModel.getSize())
- {
- focus(image);
- setSelected(index);
- }
- }
-
public Object[] getSelectedObjects()
{
return new Object[]
diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java
index dd64b9272de6..d29e0264e8c9 100644
--- a/wizards/com/sun/star/wizards/ui/WizardDialog.java
+++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java
@@ -17,26 +17,33 @@
*/
package com.sun.star.wizards.ui;
-import java.beans.*;
-
-import com.sun.star.wizards.ui.event.EventNames;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.awt.*;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.XInterface;
-import com.sun.star.lang.EventObject;
-import com.sun.star.lang.XSingleServiceFactory;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.wizards.common.Desktop;
-import com.sun.star.wizards.common.Helper;
-import com.sun.star.wizards.common.Resource;
+import java.beans.VetoableChangeListener;
+import java.beans.VetoableChangeSupport;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.awt.PushButtonType;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XItemEventBroadcaster;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XIndexContainer;
-import com.sun.star.frame.XTerminateListener;
import com.sun.star.frame.TerminationVetoException;
+import com.sun.star.frame.XTerminateListener;
+import com.sun.star.lang.EventObject;
import com.sun.star.lang.IllegalArgumentException;
-import com.sun.star.beans.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.wizards.common.Desktop;
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.XItemListenerAdapter;
+import com.sun.star.wizards.ui.event.XWindowListenerAdapter;
public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeListener, XTerminateListener, XCompletion
{
@@ -52,7 +59,6 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
private int nOldStep = 1;
private int nMaxStep = 1;
protected XItemListener RoadmapItemListener;
- protected XControl xRoadmapControl;
XItemEventBroadcaster xRoadmapBroadcaster;
String[] sRMItemLabels;
private Object oRoadmap;
@@ -139,23 +145,6 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
nNewStep = nOldStep;
}
- public void itemStateChanged(com.sun.star.awt.ItemEvent itemEvent)
- {
- try
- {
- nNewStep = itemEvent.ItemId;
- nOldStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP));
- if (nNewStep != nOldStep)
- {
- switchToStep();
- }
- }
- catch (com.sun.star.lang.IllegalArgumentException exception)
- {
- exception.printStackTrace(System.err);
- }
- }
-
public void setRoadmapInteractive(boolean _bInteractive)
{
Helper.setUnoPropertyValue(oRoadmap, "Activated", Boolean.valueOf(_bInteractive));
@@ -240,10 +229,25 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
xSSFRoadmap = UnoRuntime.queryInterface(XSingleServiceFactory.class, oRoadmap);
xIndexContRoadmap = UnoRuntime.queryInterface(XIndexContainer.class, oRoadmap);
- guiEventListener.add("rdmNavi", EventNames.ITEM_CHANGED, "itemStateChanged", this, com.sun.star.awt.ItemEvent.class);
- xRoadmapControl = this.xDlgContainer.getControl("rdmNavi");
+ XControl xRoadmapControl = this.xDlgContainer.getControl("rdmNavi");
xRoadmapBroadcaster = UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRoadmapControl);
- xRoadmapBroadcaster.addItemListener(guiEventListener);
+ xRoadmapBroadcaster.addItemListener(new XItemListenerAdapter() {
+ public void itemStateChanged(com.sun.star.awt.ItemEvent itemEvent) {
+ try
+ {
+ nNewStep = itemEvent.ItemId;
+ nOldStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP));
+ if (nNewStep != nOldStep)
+ {
+ switchToStep();
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException exception)
+ {
+ exception.printStackTrace(System.err);
+ }
+ }
+ });
Helper.setUnoPropertyValue(oRoadmap, "Text", oWizardResource.getResText(UIConsts.RID_COMMON + 16));
}
@@ -475,10 +479,12 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
// add a window listener, to know
// if the user used "escape" key to
// close the dialog.
- xWindow.addWindowListener(guiEventListener);
- String dialogName = (String) Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_NAME);
- guiEventListener.add(dialogName, EventNames.ACTION_PERFORMED, "windowHidden", this);
-
+ xWindow.addWindowListener(new XWindowListenerAdapter() {
+ @Override
+ public void windowHidden(EventObject event) {
+ cancelWizard_1();
+ }
+ });
}
catch (java.lang.Exception jexception)
{
@@ -732,11 +738,6 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
removeTerminateListener();
}
- public void windowHidden()
- {
- cancelWizard_1();
- }
-
public void notifyTermination(EventObject arg0)
{
cancelWizard_1();
diff --git a/wizards/com/sun/star/wizards/ui/event/CommonListener.java b/wizards/com/sun/star/wizards/ui/event/CommonListener.java
index ddc7c2992785..477ae3dd99eb 100644
--- a/wizards/com/sun/star/wizards/ui/event/CommonListener.java
+++ b/wizards/com/sun/star/wizards/ui/event/CommonListener.java
@@ -46,7 +46,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
{
try
{
- add(componentName, eventName, new MethodInvocation(methodName, target));
+ mHashtable.put(componentName + eventName, new MethodInvocation(methodName, target));
}
catch (Exception ex)
{
@@ -54,23 +54,6 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
}
}
- public void add(String componentName, EventNames eventName, String methodName, Object target, Class<?> paramClass)
- {
- try
- {
- add(componentName, eventName, new MethodInvocation(methodName, target, paramClass));
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- private void add(String componentName, EventNames eventName, MethodInvocation mi)
- {
- mHashtable.put(componentName + eventName, mi);
- }
-
private void invoke(String componentName, EventNames eventName, Object param)
{
try
diff --git a/wizards/com/sun/star/wizards/ui/event/XItemListenerAdapter.java b/wizards/com/sun/star/wizards/ui/event/XItemListenerAdapter.java
new file mode 100644
index 000000000000..160ecdb4fd2f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/XItemListenerAdapter.java
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package com.sun.star.wizards.ui.event;
+
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.lang.EventObject;
+
+public class XItemListenerAdapter implements XItemListener {
+
+ public void disposing(EventObject event) {
+ }
+
+ public void itemStateChanged(ItemEvent event) {
+ }
+
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/XMouseListenerAdapter.java b/wizards/com/sun/star/wizards/ui/event/XMouseListenerAdapter.java
new file mode 100644
index 000000000000..8d89c4a263e4
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/XMouseListenerAdapter.java
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package com.sun.star.wizards.ui.event;
+
+import com.sun.star.awt.MouseEvent;
+import com.sun.star.awt.XMouseListener;
+
+public class XMouseListenerAdapter implements XMouseListener {
+
+ public void disposing(com.sun.star.lang.EventObject event) {
+ }
+
+ public void mouseEntered(MouseEvent event) {
+ }
+
+ public void mouseExited(MouseEvent event) {
+ }
+
+ public void mousePressed(MouseEvent event) {
+ }
+
+ public void mouseReleased(MouseEvent event) {
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/XWindowListenerAdapter.java b/wizards/com/sun/star/wizards/ui/event/XWindowListenerAdapter.java
new file mode 100644
index 000000000000..118569ab16e1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/XWindowListenerAdapter.java
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package com.sun.star.wizards.ui.event;
+
+import com.sun.star.awt.WindowEvent;
+import com.sun.star.awt.XWindowListener;
+import com.sun.star.lang.EventObject;
+
+public class XWindowListenerAdapter implements XWindowListener {
+
+ public void disposing(EventObject event) {
+ }
+
+ public void windowHidden(EventObject event) {
+ }
+
+ public void windowMoved(WindowEvent event) {
+ }
+
+ public void windowResized(WindowEvent event) {
+ }
+
+ public void windowShown(EventObject event) {
+ }
+
+}