/**
* To execute an action immediately in the current thread.
*
* @param e
* the action to execute
*/
public void doActionNow(ActionEvent e) {
performAction(e);
}
public Set getAction(String actionName) {
Set set = new HashSet();
Set commandObjects = (Set) commands.get(actionName);
Iterator iter = commandObjects.iterator();
while (iter.hasNext()) {
try {
set.add(iter.next());
}
catch (Exception
err) {
log.error("", err);
}
}
return set;
}
public Command getAction(String actionName, Class actionClass) {
Set commandObjects = (Set) commands.get(actionName);
Iterator iter = commandObjects.iterator();
while (iter.hasNext()) {
try {
Command com = (Command) iter.next();
if (com.getClass().equals(actionClass)) {
return com;
}
}
catch (Exception
err) {
log.error("", err);
}
}
return null;
}
public Command getAction(String actionName, String className) {
Set commandObjects = (Set) commands.get(actionName);
Iterator iter = commandObjects.iterator();
while (iter.hasNext()) {
try {
Command com = (Command) iter.next();
if (com.getClass().getName().equals(className)) {
return com;
}
}
catch (Exception
err) {
log.error("", err);
}
}
return null;
}
/**
* Allows an ActionListener to receive notification of a command being
* executed prior to the actual execution of the command.
*
* @param action
* the Class of the command for which the listener will
* notifications for. Class must extend
* org.apache.jmeter.report.gui.action.Command.
* @param listener
* the ActionListener to receive the notifications
*/
/**
* Allows an ActionListener to receive notification of a command being
* executed prior to the actual execution of the command.
*
* @param action
* the Class of the command for which the listener will
* notifications for. Class must extend
* org.apache.jmeter.gui.action.Command.
* @param listener
* the ActionListener to receive the notifications
*/
public void addPreActionListener(Class action, ActionListener listener) {
if (action != null) {
HashSet set = (HashSet) preActionListeners.get(action.getName());
if (set == null) {
set = new HashSet();
}
set.add(listener);
preActionListeners.put(action.getName(), set);
}
}
/**
* Allows an ActionListener to be removed from receiving notifications of a
* command being executed prior to the actual execution of the command.
*
* @param action
* the Class of the command for which the listener will
* notifications for. Class must extend
* org.apache.jmeter.report.gui.action.Command.
* @param listener
* the ActionListener to receive the notifications
*/
/**
* Allows an ActionListener to be removed from receiving notifications of a
* command being executed prior to the actual execution of the command.
*
* @param action
* the Class of the command for which the listener will
* notifications for. Class must extend
* org.apache.jmeter.gui.action.Command.
* @param listener
* the ActionListener to receive the notifications
*/
public void removePreActionListener(Class action, ActionListener listener) {
if (action != null) {
HashSet set = (HashSet) preActionListeners.get(action.getName());
if (set != null) {
set.remove(listener);
preActionListeners.put(action.getName(), set);
}
}
}
/**
* Allows an ActionListener to receive notification of a command being
* executed after the command has executed.
*
* @param action
* the Class of the command for which the listener will
* notifications for. Class must extend
* org.apache.jmeter.report.gui.action.Command.
* @param listener
*/
/**
* Allows an ActionListener to receive notification of a command being
* executed after the command has executed.
*
* @param action
* the Class of the command for which the listener will
* notifications for. Class must extend
* org.apache.jmeter.gui.action.Command.
* @param listener
*/
public void addPostActionListener(Class action, ActionListener listener) {
if (action != null) {
HashSet set = (HashSet) postActionListeners.get(action.getName());
if (set == null) {
set = new HashSet();
}
set.add(listener);
postActionListeners.put(action.getName(), set);
}
}
/**
* Allows an ActionListener to be removed from receiving notifications of a
* command being executed after the command has executed.
*
* @param action
* the Class of the command for which the listener will
* notifications for. Class must extend
* org.apache.jmeter.report.gui.action.Command.
* @param listener
*/
/**
* Allows an ActionListener to be removed from receiving notifications of a
* command being executed after the command has executed.
*
* @param action
* the Class of the command for which the listener will
* notifications for. Class must extend
* org.apache.jmeter.gui.action.Command.
* @param listener
*/
public void removePostActionListener(Class action, ActionListener listener) {
if (action != null) {
HashSet set = (HashSet) postActionListeners.get(action.getName());
if (set != null) {
set.remove(listener);
postActionListeners.put(action.getName(), set);
}
}
}
protected void preActionPerformed(Class action, ActionEvent e) {
if (action != null) {
HashSet listenerSet = (HashSet) preActionListeners.get(action.getName());
if (listenerSet != null && listenerSet.size() > 0) {
Object[] listeners = listenerSet.toArray();
for (int i = 0; i < listeners.length; i++) {
((ActionListener) listeners[i]).actionPerformed(e);
}
}
}
}
protected void postActionPerformed(Class action, ActionEvent e) {
if (action != null) {
HashSet listenerSet = (HashSet) postActionListeners.get(action.getName());
if (listenerSet != null && listenerSet.size() > 0) {
Object[] listeners = listenerSet.toArray();
for (int i = 0; i < listeners.length; i++) {
((ActionListener) listeners[i]).actionPerformed(e);
}
}
}
}
|