Package org.useware.kernel.gui.behaviour.common

Source Code of org.useware.kernel.gui.behaviour.common.ActivationProcedure

package org.useware.kernel.gui.behaviour.common;

import org.useware.kernel.gui.behaviour.InteractionCoordinator;
import org.useware.kernel.gui.behaviour.ModelDrivenCommand;
import org.useware.kernel.gui.behaviour.Procedure;
import org.useware.kernel.gui.behaviour.SystemEvent;
import org.useware.kernel.model.Dialog;
import org.useware.kernel.model.behaviour.Resource;
import org.useware.kernel.model.behaviour.ResourceType;
import org.useware.kernel.model.structure.QName;

/**
* Verifies activation constraints and activate a unit and it's corresponding scope.
*
* @author Heiko Braun
* @date 2/26/13
*/
public class ActivationProcedure extends Procedure {

    Resource<ResourceType> activation = new Resource<ResourceType>(CommonQNames.ACTIVATION_ID, ResourceType.System);

    public ActivationProcedure(final InteractionCoordinator coordinator) {
        super(CommonQNames.ACTIVATION_ID);
        this.coordinator = coordinator;


        setCommand(new ModelDrivenCommand() {
            @Override
            public void execute(Dialog dialog, Object data) {

                // activate target unit
                QName targetUnit = (QName)data;

                // 1.) verify activation constraints
                assert getRuntimeAPI().canBeActivated(targetUnit) : "Unit is not activatable: "+ targetUnit;

                // 2.) activate the scope of the unit
                coordinator.getDialogState().activateScope(targetUnit);

                // 3.) activate the unit itself
                SystemEvent activationEvent = new SystemEvent(CommonQNames.ACTIVATION_ID);
                activationEvent.setPayload(targetUnit);
                coordinator.fireEvent(activationEvent);

            }
        });

        // complement model
        setOutputs(activation);

    }



}
TOP

Related Classes of org.useware.kernel.gui.behaviour.common.ActivationProcedure

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.