Search in sources :

Example 1 with EventContext

use of com.codename1.rad.events.EventContext in project CodeRAD by shannah.

the class ActionNode method fireEvent.

/**
 * Fires an event with the given event context.
 * @param context The event context.
 * @return
 */
public ActionEvent fireEvent(EventContext context) {
    EventFactoryNode eventFactory = this.getEventFactory();
    EventContext contextCopy = context.copyWithNewAction(this);
    ActionEvent actionEvent = eventFactory.getValue().createEvent(contextCopy);
    fireActionListeners(actionEvent);
    if (actionEvent.isConsumed()) {
        fireAfterActionCallback(actionEvent);
        return actionEvent;
    }
    ActionSupport.dispatchEvent(actionEvent);
    fireAfterActionCallback(actionEvent);
    return actionEvent;
}
Also used : EventContext(com.codename1.rad.events.EventContext) ActionEvent(com.codename1.ui.events.ActionEvent)

Example 2 with EventContext

use of com.codename1.rad.events.EventContext in project CodeRAD by shannah.

the class ActionNode method fireEvent.

/**
 * Fires an event with the given entity, source, and extra data as the context.
 * @param entity
 * @param source
 * @param extraData
 * @return
 */
public ActionEvent fireEvent(Entity entity, Component source, Map extraData) {
    EventFactoryNode eventFactory = this.getEventFactory();
    if (eventFactory == null) {
        eventFactory = new EventFactoryNode(UI.getDefaultEventFactory());
    }
    EventContext eventContext = new EventContext();
    eventContext.setEntity(entity);
    eventContext.setAction(this);
    eventContext.setEventSource(source);
    if (extraData != null) {
        for (Object k : extraData.keySet()) {
            eventContext.putExtra(k, extraData.get(k));
        }
    }
    ActionEvent actionEvent = eventFactory.getValue().createEvent(eventContext);
    fireActionListeners(actionEvent);
    if (actionEvent.isConsumed()) {
        fireAfterActionCallback(actionEvent);
        return actionEvent;
    }
    ActionSupport.dispatchEvent(actionEvent);
    fireAfterActionCallback(actionEvent);
    return actionEvent;
}
Also used : EventContext(com.codename1.rad.events.EventContext) ActionEvent(com.codename1.ui.events.ActionEvent)

Aggregations

EventContext (com.codename1.rad.events.EventContext)2 ActionEvent (com.codename1.ui.events.ActionEvent)2