<commit_before>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.ProcedureRuntimeAPI;
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;

/**
 * @author <NAME>
 * @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;

                // activate scope
                coordinator.getStatementScope().activateScope(targetUnit);
                //assert getRuntimeAPI().canBeActivated(targetUnit) : "Unit is not activatable: "+ targetUnit;

                if(!getRuntimeAPI().canBeActivated(targetUnit))
                    System.out.println("WARN: Unit is not activatable: "+ targetUnit);

                System.out.println("Activate: "+targetUnit);

                SystemEvent activationEvent = new SystemEvent(CommonQNames.ACTIVATION_ID);
                activationEvent.setPayload(targetUnit);

                coordinator.fireEvent(activationEvent);

            }<commit_msg>enforce activatable constraints<commit_after>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.ProcedureRuntimeAPI;
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;

/**
 * @author <NAME>
 * @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;

                // activate scope
                coordinator.getStatementScope().activateScope(targetUnit);
                assert getRuntimeAPI().canBeActivated(targetUnit) : "Unit is not activatable: "+ targetUnit;

                System.out.println("Activate: "+targetUnit);

                SystemEvent activationEvent = new SystemEvent(CommonQNames.ACTIVATION_ID);
                activationEvent.setPayload(targetUnit);

                coordinator.fireEvent(activationEvent);

            }
{'fraction_non_alphanumeric': 0.09461009174311927, 'fraction_numerical': 0.0028669724770642203, 'mean_word_length': 3.229090909090909, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2374265', 'n_tokens_mistral': 979, 'n_tokens_neox': 924, 'n_words': 157}