summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/ui
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-11-18 13:16:58 +0200
committerNoel Grandin <noelgrandin@gmail.com>2014-11-24 11:59:28 +0000
commit8b0aa5210a36c14bb9c3038870b83a6769dde601 (patch)
tree947b2929bae4d501dc6782888b61dda4f763afc0 /wizards/com/sun/star/wizards/ui
parent926744de7a9bb9375f41972f977bfa25fc837c15 (diff)
convert EventNames to an enum
Change-Id: I68496b47564f4c00c19a62f9f1bf38d3353598f7 Reviewed-on: https://gerrit.libreoffice.org/13095 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'wizards/com/sun/star/wizards/ui')
-rw-r--r--wizards/com/sun/star/wizards/ui/ImageList.java2
-rw-r--r--wizards/com/sun/star/wizards/ui/UnoDialog.java2
-rw-r--r--wizards/com/sun/star/wizards/ui/UnoDialog2.java34
-rw-r--r--wizards/com/sun/star/wizards/ui/WizardDialog.java4
-rw-r--r--wizards/com/sun/star/wizards/ui/event/CommonListener.java40
-rw-r--r--wizards/com/sun/star/wizards/ui/event/EventNames.java32
6 files changed, 64 insertions, 50 deletions
diff --git a/wizards/com/sun/star/wizards/ui/ImageList.java b/wizards/com/sun/star/wizards/ui/ImageList.java
index 9b3bfd3bcde0..3a0ec886ce35 100644
--- a/wizards/com/sun/star/wizards/ui/ImageList.java
+++ b/wizards/com/sun/star/wizards/ui/ImageList.java
@@ -337,7 +337,7 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
XWindow win = UnoRuntime.queryInterface(XWindow.class, image);
win.addMouseListener(uiEventListener);
win.addKeyListener(imageKeyListener);
- uiEventListener.add(imageName, EventNames.EVENT_MOUSE_PRESSED, METHOD_MOUSE_PRESSED);
+ uiEventListener.add(imageName, EventNames.MOUSE_PRESSED, METHOD_MOUSE_PRESSED);
return image;
}
diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.java b/wizards/com/sun/star/wizards/ui/UnoDialog.java
index 115f727eed3f..5b4eefee3221 100644
--- a/wizards/com/sun/star/wizards/ui/UnoDialog.java
+++ b/wizards/com/sun/star/wizards/ui/UnoDialog.java
@@ -34,7 +34,7 @@ import com.sun.star.wizards.ui.event.*;
import java.util.HashMap;
-public class UnoDialog implements EventNames
+public class UnoDialog
{
public XMultiServiceFactory xMSF;
diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog2.java b/wizards/com/sun/star/wizards/ui/UnoDialog2.java
index 02684744a83b..20a81c2bcada 100644
--- a/wizards/com/sun/star/wizards/ui/UnoDialog2.java
+++ b/wizards/com/sun/star/wizards/ui/UnoDialog2.java
@@ -17,7 +17,20 @@
*/
package com.sun.star.wizards.ui;
-import com.sun.star.awt.*;
+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;
@@ -25,6 +38,7 @@ 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.
@@ -50,7 +64,7 @@ public class UnoDialog2 extends UnoDialog
if (actionPerformed != null)
{
xButton.addActionListener(guiEventListener);
- guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget);
+ guiEventListener.add(sName, EventNames.ACTION_PERFORMED, actionPerformed, eventTarget);
}
return xButton;
}
@@ -85,7 +99,7 @@ public class UnoDialog2 extends UnoDialog
if (itemChanged != null)
{
xCheckBox.addItemListener(guiEventListener);
- guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget);
+ guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChanged, eventTarget);
}
return xCheckBox;
}
@@ -101,18 +115,18 @@ public class UnoDialog2 extends UnoDialog
if (actionPerformed != null)
{
xComboBox.addActionListener(guiEventListener);
- guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget);
+ guiEventListener.add(sName, EventNames.ACTION_PERFORMED, actionPerformed, eventTarget);
}
if (itemChanged != null)
{
xComboBox.addItemListener(guiEventListener);
- guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget);
+ guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChanged, eventTarget);
}
if (textChanged != null)
{
XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, xComboBox);
xTextComponent.addTextListener(guiEventListener);
- guiEventListener.add(sName, EVENT_TEXT_CHANGED, textChanged, eventTarget);
+ guiEventListener.add(sName, EventNames.TEXT_CHANGED, textChanged, eventTarget);
}
return xComboBox;
}
@@ -128,12 +142,12 @@ public class UnoDialog2 extends UnoDialog
if (actionPerformed != null)
{
xListBox.addActionListener(guiEventListener);
- guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget);
+ guiEventListener.add(sName, EventNames.ACTION_PERFORMED, actionPerformed, eventTarget);
}
if (itemChanged != null)
{
xListBox.addItemListener(guiEventListener);
- guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget);
+ guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChanged, eventTarget);
}
return xListBox;
}
@@ -149,7 +163,7 @@ public class UnoDialog2 extends UnoDialog
if (itemChanged != null)
{
xRadioButton.addItemListener(guiEventListener);
- guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget);
+ guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChanged, eventTarget);
}
return xRadioButton;
}
@@ -205,7 +219,7 @@ public class UnoDialog2 extends UnoDialog
if (sTextChanged != null)
{
xField.addTextListener(guiEventListener);
- guiEventListener.add(sName, EVENT_TEXT_CHANGED, sTextChanged, eventTarget);
+ guiEventListener.add(sName, EventNames.TEXT_CHANGED, sTextChanged, eventTarget);
}
return UnoRuntime.queryInterface(type, xField);
}
diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java
index 3b0136ccf4b7..662c98aeb15a 100644
--- a/wizards/com/sun/star/wizards/ui/WizardDialog.java
+++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java
@@ -242,7 +242,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
xIndexContRoadmap = UnoRuntime.queryInterface(XIndexContainer.class, oRoadmap);
MethodInvocation mi = new MethodInvocation("itemStateChanged", this, com.sun.star.awt.ItemEvent.class);
- guiEventListener.add("rdmNavi", EventNames.EVENT_ITEM_CHANGED, mi);
+ guiEventListener.add("rdmNavi", EventNames.ITEM_CHANGED, mi);
xRoadmapControl = this.xDlgContainer.getControl("rdmNavi");
xRoadmapBroadcaster = UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRoadmapControl);
xRoadmapBroadcaster.addItemListener(guiEventListener);
@@ -484,7 +484,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
MethodInvocation windowHidden = new MethodInvocation("windowHidden", this);
xWindow.addWindowListener(guiEventListener);
String dialogName = (String) Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_NAME);
- guiEventListener.add(dialogName, EVENT_ACTION_PERFORMED, windowHidden);
+ guiEventListener.add(dialogName, EventNames.ACTION_PERFORMED, windowHidden);
}
catch (java.lang.Exception jexception)
diff --git a/wizards/com/sun/star/wizards/ui/event/CommonListener.java b/wizards/com/sun/star/wizards/ui/event/CommonListener.java
index 7723e4bd8d7a..d75a24f17ffd 100644
--- a/wizards/com/sun/star/wizards/ui/event/CommonListener.java
+++ b/wizards/com/sun/star/wizards/ui/event/CommonListener.java
@@ -37,12 +37,12 @@ import com.sun.star.wizards.common.PropertyNames;
* <li>call the "add" method, to define a component-event-action mapping.</li>
* </ul>
*/
-public class CommonListener implements XActionListener, XItemListener, XTextListener, EventNames, XWindowListener, XMouseListener, XFocusListener, XKeyListener
+public class CommonListener implements XActionListener, XItemListener, XTextListener, XWindowListener, XMouseListener, XFocusListener, XKeyListener
{
private final HashMap<String,MethodInvocation> mHashtable = new HashMap<String,MethodInvocation>();
- public void add(String componentName, String eventName, String methodName, Object target)
+ public void add(String componentName, EventNames eventName, String methodName, Object target)
{
try
{
@@ -54,17 +54,17 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
}
}
- public void add(String componentName, String eventName, MethodInvocation mi)
+ public void add(String componentName, EventNames eventName, MethodInvocation mi)
{
mHashtable.put(componentName + eventName, mi);
}
- private MethodInvocation get(String componentName, String eventName)
+ private MethodInvocation get(String componentName, EventNames eventName)
{
return mHashtable.get(componentName + eventName);
}
- private Object invoke(String componentName, String eventName, Object param)
+ private Object invoke(String componentName, EventNames eventName, Object param)
{
try
{
@@ -121,7 +121,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
{
- invoke(getEventSourceName(actionEvent), EVENT_ACTION_PERFORMED, actionEvent);
+ invoke(getEventSourceName(actionEvent), EventNames.ACTION_PERFORMED, actionEvent);
}
public void disposing(com.sun.star.lang.EventObject eventObject)
@@ -133,7 +133,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void itemStateChanged(ItemEvent itemEvent)
{
- invoke(getEventSourceName(itemEvent), EVENT_ITEM_CHANGED, itemEvent);
+ invoke(getEventSourceName(itemEvent), EventNames.ITEM_CHANGED, itemEvent);
}
/**
@@ -141,7 +141,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void textChanged(TextEvent textEvent)
{
- invoke(getEventSourceName(textEvent), EVENT_TEXT_CHANGED, textEvent);
+ invoke(getEventSourceName(textEvent), EventNames.TEXT_CHANGED, textEvent);
}
/**
@@ -149,7 +149,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void windowResized(WindowEvent event)
{
- invoke(getEventSourceName(event), EVENT_WINDOW_RESIZED, event);
+ invoke(getEventSourceName(event), EventNames.WINDOW_RESIZED, event);
}
/**
@@ -157,7 +157,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void windowMoved(WindowEvent event)
{
- invoke(getEventSourceName(event), EVENT_WINDOW_MOVED, event);
+ invoke(getEventSourceName(event), EventNames.WINDOW_MOVED, event);
}
/**
@@ -165,7 +165,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void windowShown(EventObject event)
{
- invoke(getEventSourceName(event), EVENT_WINDOW_SHOWN, event);
+ invoke(getEventSourceName(event), EventNames.WINDOW_SHOWN, event);
}
/**
@@ -173,7 +173,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void windowHidden(EventObject event)
{
- invoke(getEventSourceName(event), EVENT_WINDOW_HIDDEN, event);
+ invoke(getEventSourceName(event), EventNames.WINDOW_HIDDEN, event);
}
/**
@@ -181,7 +181,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void mousePressed(MouseEvent event)
{
- invoke(getEventSourceName(event), EVENT_MOUSE_PRESSED, event);
+ invoke(getEventSourceName(event), EventNames.MOUSE_PRESSED, event);
}
/**
@@ -189,7 +189,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void mouseReleased(MouseEvent event)
{
- invoke(getEventSourceName(event), EVENT_KEY_RELEASED, event);
+ invoke(getEventSourceName(event), EventNames.KEY_RELEASED, event);
}
/**
@@ -197,7 +197,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void mouseEntered(MouseEvent event)
{
- invoke(getEventSourceName(event), EVENT_MOUSE_ENTERED, event);
+ invoke(getEventSourceName(event), EventNames.MOUSE_ENTERED, event);
}
/**
@@ -205,7 +205,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void mouseExited(MouseEvent event)
{
- invoke(getEventSourceName(event), EVENT_MOUSE_EXITED, event);
+ invoke(getEventSourceName(event), EventNames.MOUSE_EXITED, event);
}
/**
@@ -213,7 +213,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void focusGained(FocusEvent event)
{
- invoke(getEventSourceName(event), EVENT_FOCUS_GAINED, event);
+ invoke(getEventSourceName(event), EventNames.FOCUS_GAINED, event);
}
/**
@@ -221,7 +221,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void focusLost(FocusEvent event)
{
- invoke(getEventSourceName(event), EVENT_FOCUS_LOST, event);
+ invoke(getEventSourceName(event), EventNames.FOCUS_LOST, event);
}
/**
@@ -229,7 +229,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void keyPressed(KeyEvent event)
{
- invoke(getEventSourceName(event), EVENT_KEY_PRESSED, event);
+ invoke(getEventSourceName(event), EventNames.KEY_PRESSED, event);
}
/**
@@ -237,6 +237,6 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/
public void keyReleased(KeyEvent event)
{
- invoke(getEventSourceName(event), EVENT_KEY_RELEASED, event);
+ invoke(getEventSourceName(event), EventNames.KEY_RELEASED, event);
}
}
diff --git a/wizards/com/sun/star/wizards/ui/event/EventNames.java b/wizards/com/sun/star/wizards/ui/event/EventNames.java
index e49ee305dc9e..301e763c20cd 100644
--- a/wizards/com/sun/star/wizards/ui/event/EventNames.java
+++ b/wizards/com/sun/star/wizards/ui/event/EventNames.java
@@ -17,22 +17,22 @@
*/
package com.sun.star.wizards.ui.event;
-public interface EventNames
+public enum EventNames
{
//common listener events
- String EVENT_ACTION_PERFORMED = "APR";
- String EVENT_ITEM_CHANGED = "ICH";
- String EVENT_TEXT_CHANGED = "TCH"; //window events (XWindow)
- String EVENT_WINDOW_RESIZED = "WRE";
- String EVENT_WINDOW_MOVED = "WMO";
- String EVENT_WINDOW_SHOWN = "WSH";
- String EVENT_WINDOW_HIDDEN = "WHI"; //focus events (XWindow)
- String EVENT_FOCUS_GAINED = "FGA";
- String EVENT_FOCUS_LOST = "FLO"; //keyboard events
- String EVENT_KEY_PRESSED = "KPR";
- String EVENT_KEY_RELEASED = "KRE"; //mouse events
- String EVENT_MOUSE_PRESSED = "MPR";
- String EVENT_MOUSE_RELEASED = "MRE";
- String EVENT_MOUSE_ENTERED = "MEN";
- String EVENT_MOUSE_EXITED = "MEX"; //other events
+ ACTION_PERFORMED,
+ ITEM_CHANGED,
+ TEXT_CHANGED, //window events (XWindow)
+ WINDOW_RESIZED,
+ WINDOW_MOVED,
+ WINDOW_SHOWN,
+ WINDOW_HIDDEN, //focus events (XWindow)
+ FOCUS_GAINED,
+ FOCUS_LOST, //keyboard events
+ KEY_PRESSED,
+ KEY_RELEASED, //mouse events
+ MOUSE_PRESSED,
+ MOUSE_RELEASED,
+ MOUSE_ENTERED,
+ MOUSE_EXITED //other events
}