<commit_before>package org.jacpfx.rcp.context;

import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Node;
import org.jacpfx.api.message.Message;
import org.jacpfx.api.util.CustomSecurityManager;
import org.jacpfx.rcp.component.AStatelessCallbackComponent;
import org.jacpfx.rcp.component.CallbackComponent;
import org.jacpfx.rcp.component.FXComponent;
import org.jacpfx.rcp.componentLayout.FXComponentLayout;
import org.jacpfx.rcp.components.managedFragment.ManagedFragment;
import org.jacpfx.rcp.components.managedFragment.ManagedFragmentHandler;
import org.jacpfx.rcp.components.modalDialog.JACPModalDialog;
import org.jacpfx.rcp.message.ActionListenerImpl;
import org.jacpfx.rcp.message.MessageImpl;
import org.jacpfx.rcp.perspective.FXPerspective;
import org.jacpfx.rcp.util.AccessUtil;
import org.jacpfx.rcp.util.FXUtil;
import org.jacpfx.rcp.util.PerspectiveUtil;
import org.jacpfx.rcp.util.WorkerUtil;
import org.jacpfx.rcp.workbench.FXWorkbench;
import org.jacpfx.rcp.worker.AComponentWorker;
import org.jacpfx.rcp.worker.AEmbeddedComponentWorker;

import java.util.ResourceBundle;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * Created with IntelliJ IDEA.
 * User: <NAME>
 * Date: 24.06.13
 * Time: 21:36
 * JACP context object provides functionality to component context and basic features.
 */
public class JacpContextImpl implements Context {

    private final static CustomSecurityManager customSecurityManager =
            new CustomSecurityManager();
    private volatile BlockingQueue<Message<Event, Object>> globalMessageQueue;
    /**
     * will be set on init
     */
    private String id;
    private volatile String parentId;
    /**
     * will be set on init
     */
    private String name;
    private volatile String returnTarget;
    private volatile String targetLayout;
    private volatile String executionTarget = "";
    private volatile FXComponentLayout layout;
    private volatile ResourceBundle resourceBundle;
    private volatile AtomicBoolean active = new AtomicBoolean(false);

    public JacpContextImpl(final String id, final String name, final BlockingQueue<Message<Event, Object>> globalMessageQueue) {
        this.id = id;
        this.name = name;
        this.globalMessageQueue = globalMessageQueue;

    }

    public JacpContextImpl(final BlockingQueue<Message<Event, Object>> globalMessageQueue) {
        this.globalMessageQueue = globalMessageQueue;

    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final EventHandler<Event> getEventHandler(
            final Object message) {
        final String callerClassName = customSecurityManager.getCallerClassName();
        if (AccessUtil.hasAccess(callerClassName, FXWorkbench.class))
            throw new IllegalStateException(" a FXWorkbench is no valid message target");
        return new ActionListenerImpl(new MessageImpl(this.parentId.concat(FXUtil.PATTERN_GLOBAL).concat(this.id), message),
                this.globalMessageQueue);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final EventHandler<Event> getEventHandler(
            final String targetId, final Object message) {
        return new ActionListenerImpl(new MessageImpl(this.parentId.concat(FXUtil.PATTERN_GLOBAL).concat(this.id), targetId, message, null),
                this.globalMessageQueue);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final void send(final String targetId, final Object message) {
        try {
            this.globalMessageQueue.put(new MessageImpl(this.parentId.concat(FXUtil.PATTERN_GLOBAL).concat(this.id), targetId, message, null));
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final void send(final Object message) {
        final String callerClassName = customSecurityManager.getCallerClassName();
        if (AccessUtil.hasAccess(callerClassName, FXWorkbench.class))
            throw new IllegalStateException(" a FXWorkbench is no valid message target");
        try {
            this.globalMessageQueue.put(new MessageImpl(this.parentId.concat(FXUtil.PATTERN_GLOBAL).concat(this.id), message));
        } catch (InterruptedException e) {<commit_msg>fixed issue with local messages in perspective<commit_after>package org.jacpfx.rcp.context;

import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Node;
import org.jacpfx.api.message.Message;
import org.jacpfx.api.util.CustomSecurityManager;
import org.jacpfx.rcp.component.AStatelessCallbackComponent;
import org.jacpfx.rcp.component.CallbackComponent;
import org.jacpfx.rcp.component.FXComponent;
import org.jacpfx.rcp.componentLayout.FXComponentLayout;
import org.jacpfx.rcp.components.managedFragment.ManagedFragment;
import org.jacpfx.rcp.components.managedFragment.ManagedFragmentHandler;
import org.jacpfx.rcp.components.modalDialog.JACPModalDialog;
import org.jacpfx.rcp.message.ActionListenerImpl;
import org.jacpfx.rcp.message.MessageImpl;
import org.jacpfx.rcp.perspective.FXPerspective;
import org.jacpfx.rcp.util.AccessUtil;
import org.jacpfx.rcp.util.FXUtil;
import org.jacpfx.rcp.util.PerspectiveUtil;
import org.jacpfx.rcp.util.WorkerUtil;
import org.jacpfx.rcp.workbench.FXWorkbench;
import org.jacpfx.rcp.worker.AComponentWorker;
import org.jacpfx.rcp.worker.AEmbeddedComponentWorker;

import java.util.ResourceBundle;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * Created with IntelliJ IDEA.
 * User: <NAME>
 * Date: 24.06.13
 * Time: 21:36
 * JACP context object provides functionality to component context and basic features.
 */
public class JacpContextImpl implements Context {

    private final static CustomSecurityManager customSecurityManager =
            new CustomSecurityManager();
    private volatile BlockingQueue<Message<Event, Object>> globalMessageQueue;
    /**
     * will be set on init
     */
    private String id;
    private volatile String parentId;
    /**
     * will be set on init
     */
    private String name;
    private volatile String returnTarget;
    private volatile String targetLayout;
    private volatile String executionTarget = "";
    private volatile FXComponentLayout layout;
    private volatile ResourceBundle resourceBundle;
    private volatile AtomicBoolean active = new AtomicBoolean(false);

    public JacpContextImpl(final String id, final String name, final BlockingQueue<Message<Event, Object>> globalMessageQueue) {
        this.id = id;
        this.name = name;
        this.globalMessageQueue = globalMessageQueue;

    }

    public JacpContextImpl(final BlockingQueue<Message<Event, Object>> globalMessageQueue) {
        this.globalMessageQueue = globalMessageQueue;

    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final EventHandler<Event> getEventHandler(
            final Object message) {
        final String callerClassName = customSecurityManager.getCallerClassName();
        if (AccessUtil.hasAccess(callerClassName, FXWorkbench.class))
            throw new IllegalStateException(" a FXWorkbench is no valid message target");
        return new ActionListenerImpl(new MessageImpl(this.parentId.concat(FXUtil.PATTERN_GLOBAL).concat(this.id), message),
                this.globalMessageQueue);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final EventHandler<Event> getEventHandler(
            final String targetId, final Object message) {
        return new ActionListenerImpl(new MessageImpl(this.parentId.concat(FXUtil.PATTERN_GLOBAL).concat(this.id), targetId, message, null),
                this.globalMessageQueue);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final void send(final String targetId, final Object message) {
        try {
            final String sourceId = this.parentId!=null?this.parentId.concat(FXUtil.PATTERN_GLOBAL).concat(this.id):this.id;
            this.globalMessageQueue.put(new MessageImpl(sourceId, targetId, message, null));
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final void send(final Object message) {
        final String callerClassName = customSecurityManager.getCallerClassName();
        if (AccessUtil.hasAccess(callerClassName, FXWorkbench.class))
            throw new IllegalStateException(" a FXWorkbench is no valid message target");
        try {
            final String fullyQualifiedId =this.parentId.concat(FXUtil.PATTERN_GLOBAL).concat(this.id);
            this.globalMessageQueue.put(new MessageImpl(fullyQualifiedId,this.id, message, null));

        } catch (InterruptedException e) {
{'fraction_non_alphanumeric': 0.09100913392758886, 'fraction_numerical': 0.0022009464069549906, 'mean_word_length': 3.6917914300464636, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '2654195', 'n_tokens_mistral': 2583, 'n_tokens_neox': 2497, 'n_words': 571}