Kaydet (Commit) 8b0aa521 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

convert EventNames to an enum

Change-Id: I68496b47564f4c00c19a62f9f1bf38d3353598f7
Reviewed-on: https://gerrit.libreoffice.org/13095Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 926744de
...@@ -337,7 +337,7 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener ...@@ -337,7 +337,7 @@ public class ImageList implements XItemEventBroadcaster, ListDataListener
XWindow win = UnoRuntime.queryInterface(XWindow.class, image); XWindow win = UnoRuntime.queryInterface(XWindow.class, image);
win.addMouseListener(uiEventListener); win.addMouseListener(uiEventListener);
win.addKeyListener(imageKeyListener); win.addKeyListener(imageKeyListener);
uiEventListener.add(imageName, EventNames.EVENT_MOUSE_PRESSED, METHOD_MOUSE_PRESSED); uiEventListener.add(imageName, EventNames.MOUSE_PRESSED, METHOD_MOUSE_PRESSED);
return image; return image;
} }
......
...@@ -34,7 +34,7 @@ import com.sun.star.wizards.ui.event.*; ...@@ -34,7 +34,7 @@ import com.sun.star.wizards.ui.event.*;
import java.util.HashMap; import java.util.HashMap;
public class UnoDialog implements EventNames public class UnoDialog
{ {
public XMultiServiceFactory xMSF; public XMultiServiceFactory xMSF;
......
...@@ -17,7 +17,20 @@ ...@@ -17,7 +17,20 @@
*/ */
package com.sun.star.wizards.ui; 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.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
...@@ -25,6 +38,7 @@ import com.sun.star.wizards.common.Desktop; ...@@ -25,6 +38,7 @@ import com.sun.star.wizards.common.Desktop;
import com.sun.star.wizards.common.Helper; import com.sun.star.wizards.common.Helper;
import com.sun.star.wizards.common.PropertyNames; import com.sun.star.wizards.common.PropertyNames;
import com.sun.star.wizards.common.SystemDialog; 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. * This class contains convenience methods for inserting components to a dialog.
...@@ -50,7 +64,7 @@ public class UnoDialog2 extends UnoDialog ...@@ -50,7 +64,7 @@ public class UnoDialog2 extends UnoDialog
if (actionPerformed != null) if (actionPerformed != null)
{ {
xButton.addActionListener(guiEventListener); xButton.addActionListener(guiEventListener);
guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget); guiEventListener.add(sName, EventNames.ACTION_PERFORMED, actionPerformed, eventTarget);
} }
return xButton; return xButton;
} }
...@@ -85,7 +99,7 @@ public class UnoDialog2 extends UnoDialog ...@@ -85,7 +99,7 @@ public class UnoDialog2 extends UnoDialog
if (itemChanged != null) if (itemChanged != null)
{ {
xCheckBox.addItemListener(guiEventListener); xCheckBox.addItemListener(guiEventListener);
guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget); guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChanged, eventTarget);
} }
return xCheckBox; return xCheckBox;
} }
...@@ -101,18 +115,18 @@ public class UnoDialog2 extends UnoDialog ...@@ -101,18 +115,18 @@ public class UnoDialog2 extends UnoDialog
if (actionPerformed != null) if (actionPerformed != null)
{ {
xComboBox.addActionListener(guiEventListener); xComboBox.addActionListener(guiEventListener);
guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget); guiEventListener.add(sName, EventNames.ACTION_PERFORMED, actionPerformed, eventTarget);
} }
if (itemChanged != null) if (itemChanged != null)
{ {
xComboBox.addItemListener(guiEventListener); xComboBox.addItemListener(guiEventListener);
guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget); guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChanged, eventTarget);
} }
if (textChanged != null) if (textChanged != null)
{ {
XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, xComboBox); XTextComponent xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, xComboBox);
xTextComponent.addTextListener(guiEventListener); xTextComponent.addTextListener(guiEventListener);
guiEventListener.add(sName, EVENT_TEXT_CHANGED, textChanged, eventTarget); guiEventListener.add(sName, EventNames.TEXT_CHANGED, textChanged, eventTarget);
} }
return xComboBox; return xComboBox;
} }
...@@ -128,12 +142,12 @@ public class UnoDialog2 extends UnoDialog ...@@ -128,12 +142,12 @@ public class UnoDialog2 extends UnoDialog
if (actionPerformed != null) if (actionPerformed != null)
{ {
xListBox.addActionListener(guiEventListener); xListBox.addActionListener(guiEventListener);
guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget); guiEventListener.add(sName, EventNames.ACTION_PERFORMED, actionPerformed, eventTarget);
} }
if (itemChanged != null) if (itemChanged != null)
{ {
xListBox.addItemListener(guiEventListener); xListBox.addItemListener(guiEventListener);
guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget); guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChanged, eventTarget);
} }
return xListBox; return xListBox;
} }
...@@ -149,7 +163,7 @@ public class UnoDialog2 extends UnoDialog ...@@ -149,7 +163,7 @@ public class UnoDialog2 extends UnoDialog
if (itemChanged != null) if (itemChanged != null)
{ {
xRadioButton.addItemListener(guiEventListener); xRadioButton.addItemListener(guiEventListener);
guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget); guiEventListener.add(sName, EventNames.ITEM_CHANGED, itemChanged, eventTarget);
} }
return xRadioButton; return xRadioButton;
} }
...@@ -205,7 +219,7 @@ public class UnoDialog2 extends UnoDialog ...@@ -205,7 +219,7 @@ public class UnoDialog2 extends UnoDialog
if (sTextChanged != null) if (sTextChanged != null)
{ {
xField.addTextListener(guiEventListener); xField.addTextListener(guiEventListener);
guiEventListener.add(sName, EVENT_TEXT_CHANGED, sTextChanged, eventTarget); guiEventListener.add(sName, EventNames.TEXT_CHANGED, sTextChanged, eventTarget);
} }
return UnoRuntime.queryInterface(type, xField); return UnoRuntime.queryInterface(type, xField);
} }
......
...@@ -242,7 +242,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL ...@@ -242,7 +242,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
xIndexContRoadmap = UnoRuntime.queryInterface(XIndexContainer.class, oRoadmap); xIndexContRoadmap = UnoRuntime.queryInterface(XIndexContainer.class, oRoadmap);
MethodInvocation mi = new MethodInvocation("itemStateChanged", this, com.sun.star.awt.ItemEvent.class); 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"); xRoadmapControl = this.xDlgContainer.getControl("rdmNavi");
xRoadmapBroadcaster = UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRoadmapControl); xRoadmapBroadcaster = UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRoadmapControl);
xRoadmapBroadcaster.addItemListener(guiEventListener); xRoadmapBroadcaster.addItemListener(guiEventListener);
...@@ -484,7 +484,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL ...@@ -484,7 +484,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
MethodInvocation windowHidden = new MethodInvocation("windowHidden", this); MethodInvocation windowHidden = new MethodInvocation("windowHidden", this);
xWindow.addWindowListener(guiEventListener); xWindow.addWindowListener(guiEventListener);
String dialogName = (String) Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_NAME); 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) catch (java.lang.Exception jexception)
......
...@@ -37,12 +37,12 @@ import com.sun.star.wizards.common.PropertyNames; ...@@ -37,12 +37,12 @@ import com.sun.star.wizards.common.PropertyNames;
* <li>call the "add" method, to define a component-event-action mapping.</li> * <li>call the "add" method, to define a component-event-action mapping.</li>
* </ul> * </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>(); 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 try
{ {
...@@ -54,17 +54,17 @@ public class CommonListener implements XActionListener, XItemListener, XTextList ...@@ -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); mHashtable.put(componentName + eventName, mi);
} }
private MethodInvocation get(String componentName, String eventName) private MethodInvocation get(String componentName, EventNames eventName)
{ {
return mHashtable.get(componentName + 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 try
{ {
...@@ -121,7 +121,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList ...@@ -121,7 +121,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) 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) public void disposing(com.sun.star.lang.EventObject eventObject)
...@@ -133,7 +133,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList ...@@ -133,7 +133,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void itemStateChanged(ItemEvent itemEvent) 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 ...@@ -141,7 +141,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void textChanged(TextEvent textEvent) 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 ...@@ -149,7 +149,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void windowResized(WindowEvent event) 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 ...@@ -157,7 +157,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void windowMoved(WindowEvent event) 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 ...@@ -165,7 +165,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void windowShown(EventObject event) 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 ...@@ -173,7 +173,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void windowHidden(EventObject event) 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 ...@@ -181,7 +181,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void mousePressed(MouseEvent event) 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 ...@@ -189,7 +189,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void mouseReleased(MouseEvent event) 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 ...@@ -197,7 +197,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void mouseEntered(MouseEvent event) 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 ...@@ -205,7 +205,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void mouseExited(MouseEvent event) 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 ...@@ -213,7 +213,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void focusGained(FocusEvent event) 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 ...@@ -221,7 +221,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void focusLost(FocusEvent event) 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 ...@@ -229,7 +229,7 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void keyPressed(KeyEvent event) 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 ...@@ -237,6 +237,6 @@ public class CommonListener implements XActionListener, XItemListener, XTextList
*/ */
public void keyReleased(KeyEvent event) public void keyReleased(KeyEvent event)
{ {
invoke(getEventSourceName(event), EVENT_KEY_RELEASED, event); invoke(getEventSourceName(event), EventNames.KEY_RELEASED, event);
} }
} }
...@@ -17,22 +17,22 @@ ...@@ -17,22 +17,22 @@
*/ */
package com.sun.star.wizards.ui.event; package com.sun.star.wizards.ui.event;
public interface EventNames public enum EventNames
{ {
//common listener events //common listener events
String EVENT_ACTION_PERFORMED = "APR"; ACTION_PERFORMED,
String EVENT_ITEM_CHANGED = "ICH"; ITEM_CHANGED,
String EVENT_TEXT_CHANGED = "TCH"; //window events (XWindow) TEXT_CHANGED, //window events (XWindow)
String EVENT_WINDOW_RESIZED = "WRE"; WINDOW_RESIZED,
String EVENT_WINDOW_MOVED = "WMO"; WINDOW_MOVED,
String EVENT_WINDOW_SHOWN = "WSH"; WINDOW_SHOWN,
String EVENT_WINDOW_HIDDEN = "WHI"; //focus events (XWindow) WINDOW_HIDDEN, //focus events (XWindow)
String EVENT_FOCUS_GAINED = "FGA"; FOCUS_GAINED,
String EVENT_FOCUS_LOST = "FLO"; //keyboard events FOCUS_LOST, //keyboard events
String EVENT_KEY_PRESSED = "KPR"; KEY_PRESSED,
String EVENT_KEY_RELEASED = "KRE"; //mouse events KEY_RELEASED, //mouse events
String EVENT_MOUSE_PRESSED = "MPR"; MOUSE_PRESSED,
String EVENT_MOUSE_RELEASED = "MRE"; MOUSE_RELEASED,
String EVENT_MOUSE_ENTERED = "MEN"; MOUSE_ENTERED,
String EVENT_MOUSE_EXITED = "MEX"; //other events MOUSE_EXITED //other events
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment