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

at.spardat.xma.mdl.NewModelEvent Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2003, 2009 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

package at.spardat.xma.mdl;

import java.io.IOException;

import at.spardat.xma.page.Page;
import at.spardat.xma.serializer.XmaInput;
import at.spardat.xma.serializer.XmaOutput;
import at.spardat.xma.serializer.XmaSerializable;

/**
 * Event class used to notify the dynamic registration of new widget models.
 * @author gub
 * @since 2.1.0
 * @see Page#addWModel(WModel)
*/
public abstract class NewModelEvent implements XmaSerializable {
	/** additional parameters send with the event */
	private NewModelEventParams params = new NewModelEventParams();

	/**
	 * Returns the type of the event. Every subclass of NewModelEvent must have a
	 * unique type value known by the used {@link NewModelEventFactory}.
	 */
    public abstract byte getType();

    /**
     * Creates the widget model corresponding to this event.
     * @param id a unique id identifying the created widget model within its page
     * @param page which will contain the new widget model
     * @return a newly created widget model
     */
	public abstract WModel createModel(short id,Page page);

    /*
     * Maps the information in this to out.
     */
	public void serialize(XmaOutput out) throws IOException {
		params.serialize(out);
    }

    /*
     * Reads the information from in and sets instance variable's
     * values in this.
     */
	public void deserialize(XmaInput in) throws IOException, ClassNotFoundException {
		params.deserialize(in);
    }

	/**
	 * Returns the additional parameters send with the event.
	 * @see Page#addWModel(WModel, NewModelEventParams)
	 */
	public NewModelEventParams getParams() {
		return params;
	}

	/**
	 * Sets the additional parameters to send with the event.
	 */
	public void setParams(NewModelEventParams params) {
		if(params!=null) this.params=params;
		else this.params.clear();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy