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

at.spardat.xma.component.EmbeddableComponent Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2003, 2007 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
 *******************************************************************************/

/*
 * Created on 09.07.2003
 *
 *
 *
 */
package at.spardat.xma.component;

import org.eclipse.swt.widgets.Composite;

import at.spardat.xma.boot.component.IDialog;
import at.spardat.xma.page.DialogPage;
import at.spardat.xma.page.IEmbeddable;
import at.spardat.xma.page.PageClient;
import at.spardat.xma.session.XMASessionClient;

/**
 * This class servers a base class for client side components, which can be embedded into
 * a client side page. To be embeddable the component must define a main page via {@link #setMainPage(PageClient)}
 * which will be shown in place inside another page.
 *
 * @author s2877
 */
public abstract class EmbeddableComponent extends ComponentClient implements IEmbeddable {

    /** the page which will be shown */
    private PageClient mainPage;


    /**
     * Constructor of the Component. Creates the Display if necessary.
     * Registers this component with the session.
     *
     * @param session the XMASession this component belongs to
     * @param isStateless defines whether this component is stateless or not.
     */
    public EmbeddableComponent (XMASessionClient session, boolean isStateless) {
        super(session,isStateless);
    }

    /**
     * Sets the page which will be shown by the component.
     * @param page the page to show by the component.
     */
    public void setMainPage(PageClient page) {
        mainPage=page;
    }

    /** Gets the page which will be shown by the component.
     * @return the page shown by the component.
     */
    public PageClient getMainPage() {
        return mainPage;
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.page.IXMAControl#setDialog()
     */
    public void setDialog(IDialog dialog) {
        getMainPage().setDialog(dialog);
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.page.IXMAControl#getDialog()
     */
    public IDialog getDialog() {
        return getMainPage().getDialog();
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.page.IXMAControl#getComposite()
     */
    public Composite createComposite(Composite parent) {
        return getMainPage().createComposite(parent);
    }

    public Composite getComposite() {
        return getMainPage().getComposite();
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.page.IXMAControl#initGUI()
     */
    public void initGUI() {
        getMainPage().initGUI();
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.page.IXMAControl#enterBase()
     */
    public void enterBase() {
        try {
            enter();
        } catch (Exception exc) {
            ((DialogPage)getDialog()).showException(exc);
        }
        getMainPage().enterBase();
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.page.IXMAControl#stateChangedBase()
     */
    public void stateChangedBase() {
        //TODO stateChanged filtern?
        getMainPage().stateChangedBase();
    }

    /**
     * Delegates the call of {@link at.spardat.xma.page.PageClient#determineStateBase()} to the main page.
     */
    public void determineStateBase(){
        getMainPage().determineStateBase();
    }

    /**
     * Delegates the call of {@link at.spardat.xma.page.PageClient#stateChangedExtend()} to the main page.
     */
    public void stateChangedExtend(){
        getMainPage().stateChangedExtend();
    }

    /**
     * Delegates the call of {@link at.spardat.xma.page.PageClient#stateChangedBaseImpl()} to the main page.
     */
    public void stateChangedBaseImpl(){
        getMainPage().stateChangedBaseImpl();
    }
    
    public void initializePageEffectsBaseImpl () {
        getMainPage().initializePageEffectsBaseImpl();        
    }

    public void layoutStateChangedBaseImpl () {
        getMainPage().layoutStateChangedBaseImpl();        
    }

    public void applyPageEffectsBaseImpl () {
        getMainPage().applyPageEffectsBaseImpl();        
    }

    public void resetLayoutStateBaseImpl () {
        getMainPage().resetLayoutStateBaseImpl();        
    }           

    /* (non-Javadoc)
     * @see at.spardat.xma.page.IXMAControl#leaveBase()
     */
    public void leaveBase() {
        getMainPage().leaveBase();
        try {
            leave();
        } catch (Exception exc) {
            ((DialogPage)getDialog()).showException(exc);
        }
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.page.IXMAControl#removeWidgetsBase()
     */
    public void removeWidgetsBase() {
        getMainPage().removeWidgetsBase();
    }

    /**
     * Remove the embedded Component and all its PageModels. This causes the
     * corresponding server side models to be freed when the next serverEvent occurs.
     * It calls {@link PageClient#removeWidgetModels()} on the main page and all subpages.
     * The embedded Component will be disposed.
     */
    public void removeModel() {
        getMainPage().removeModel();
        dispose();
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.boot.component.IXMAControl#getContextString()
     */
    public String getContextString() {
        return getMainPage().getContextString();
    }

    /**
     * Enables/disables GUI-events on the mainpage and all its subpages.
     * @param enabled
     */
    public void setEventsEnabled(boolean enabled) {
        getMainPage().setEventsEnabled(enabled);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy