All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ioc.commons.impl.gwt.client.globalflowcontroller.GwtGlobalFlowController Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package org.ioc.commons.impl.gwt.client.globalflowcontroller;

import org.ioc.commons.flowcontrol.actioncontroller.IsExternalAction;
import org.ioc.commons.flowcontrol.common.BindRegistration;
import org.ioc.commons.flowcontrol.eventbus.IsEvent;
import org.ioc.commons.flowcontrol.globalflowcontroller.GlobalFlowController;
import org.ioc.commons.flowcontrol.operationmanager.IsOperation;
import org.ioc.commons.ui.IsWidget;

import com.google.gwt.event.logical.shared.AttachEvent;
import com.google.gwt.user.client.ui.Widget;

/**
 * GWT implementation for {@link GlobalFlowController}
 * 
 * @author Jesús Lunar Pérez
 * 
 * @param 
 *            Event type
 * @param 
 *            Operation type
 * @param 
 *            External action type
 */
public class GwtGlobalFlowController, O extends Enum, A extends Enum>
		implements GlobalFlowController {

	protected final GwtGlobalEventBusImpl eventbus;
	protected final GwtGlobalOperationManagerImpl operationManager;
	protected final GwtGlobalActionControllerImpl actionController;

	public GwtGlobalFlowController(com.google.web.bindery.event.shared.EventBus eventBus) {
		this.eventbus = new GwtGlobalEventBusImpl(eventBus, this);
		this.operationManager = new GwtGlobalOperationManagerImpl(eventBus, this);
		this.actionController = new GwtGlobalActionControllerImpl(eventBus, this);
	}

	final public GlobalEventBus eventBus() {
		return this.eventbus;
	}

	final public GlobalOperationManager operationManager() {
		return this.operationManager;
	}

	final public GlobalActionController actionController() {
		return this.actionController;
	}

	static void unbindWhenDetach(final BindRegistration registration, IsWidget display) {
		Widget w = (Widget) display.asWidget();

		w.addAttachHandler(new AttachEvent.Handler() {

			@Override
			public void onAttachOrDetach(AttachEvent event) {
				if (!event.isAttached()) {
					registration.unbind();
				}
			}
		});
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy