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

org.ioc.commons.impl.gwt.client.ui.ViewComposite Maven / Gradle / Ivy

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

import org.ioc.commons.flowcontrol.actioncontroller.IsExternalAction;
import org.ioc.commons.flowcontrol.eventbus.IsEvent;
import org.ioc.commons.flowcontrol.operationmanager.IsOperation;
import org.ioc.commons.ui.IsView;
import org.ioc.commons.ui.IsViewPresenter;

public class ViewComposite, O extends Enum, A extends Enum, P extends IsViewPresenter>
		extends DisplayComposite implements IsView {

	/**
	 * Determines if {@link #activate()} and {@link #deactivate()} methods will be
	 * automatically invoked when {@link #onLoad()} and {@link #onUnload()}
	 * methods are called. By default value is true.
	 */
	private boolean autoActivation = true;
	private boolean active;

	/**
	 * Default constructor. By default auto activation is true.
	 * 
	 * @see ViewComposite#autoActivation
	 */
	public ViewComposite() {
	}

	/**
	 * Constructor which set value of {@link #autoActivation}
	 * 
	 * @param autoActivation
	 * 
	 * @see ViewComposite#autoActivation
	 */
	public ViewComposite(boolean autoActivation) {
		this.autoActivation = autoActivation;
	}

	@Override
	protected void onLoad() {
		if (this.autoActivation) {
			this.active = this.isAttached();	
		}
		super.onLoad();
		if (this.autoActivation) {
			activate();
		}
	}

	/**
	 * This method should be manually called to indicate view is active when
	 * {@link #autoActivation} is false.
	 */
	@Override
	public void activate() {
		this.active = true;
		if (this.presenter != null) {
			this.presenter.onActive();
		}
	}

	@Override
	protected void onUnload() {
		super.onUnload();
		if (this.autoActivation) {
			deactivate();
		}
	}

	/**
	 * This method should be manually called to indicate view is not active when
	 * {@link #autoActivation} is false.
	 */
	@Override
	public void deactivate() {
		this.active = false;
		if (this.presenter != null) {
			this.presenter.onDeactive();
		}
	}

	@Override
	public boolean isActive() {
		return this.active;
	}

	public boolean isAutoActivation() {
		return autoActivation;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy