[
  {
    "path": "Documentation/JBT.tex",
    "content": "\\documentclass[a4paper,10pt]{article}\n\\usepackage[utf8x]{inputenc}\n\\usepackage{graphicx}\n\\usepackage{minted}\n\n%opening\n\\title{\\textit{Java Behaviour Trees}, a Java Framework for Creating and Running Behaviour Trees}\n\\author{Ricardo Juan Palma Dur\\'an}\n\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\n\nBehaviour Trees (BTs) have gained popularity over the past few years as a tool for defining the behaviour of video games' characters. However, to the best of our knowledge, currently there is no open Java implementation of BTs. Here we present \\textit{Java Behaviour Trees} (JBT), a GNU framework in Java for defining and running BTs.\n\n\\end{abstract}\n\n\\section{Introduction}\n\nWe assume that the reader is familiar with the concept of BT. Here we are not going to explain all the details about what a BT is or how it conceptually works. Some authors have spent a lot of effort doing so, so we will just refer the reader to \\cite{Millington09} for an introduction.\n\nThe model we have implemented is a hybrid one, since it combines ideas from several sources. The basic underlying model is that of \\cite{Millington09}, including all the task that the authors propose as well as the concept of context and libraries of behaviour trees. However, we have also added \\textit{guards} to our implementation. Guards act like conditions that in some scenarios are checked in order to decide whether a task is run or not. \n\nWe have also taken some ideas from \\cite{AIGameDev}, specially that of having trees whose nodes are ticked only when necessary so that CPU time does not get wasted.\n\n\\subsection{Model overview description}\n\nIn this section we describe the JBT architecture as well as the main features that BTs have.\n\n\\subsubsection{Model driven by ticks}\n\nJBT implements a BT model driven by ticks. A BT must be evaluated through ticks, so every game cycle an external caller \\textit{ticks} the tree in order for the tree to update its status. A tick is just a way of giving the tree some CPU time to update their status; in particular, ticks are used to give the nodes of the tree some time to evaluate whether they have finished or not, and consequently make the tree evolve.\n\nThe simplest approach to BTs driven by ticks is that of ticking the root node and then letting each node recursively tick its children according to its semantics. However, this is a very inefficient process, since in general the major part of the nodes of the tree are just waiting for their children to finish. Therefore, they should not receive ticks, since unless their children are done they will do nothing useful when receiving the tick. Therefore, in general only very few nodes should be ticked at a game cycle, and as a result JBT implements a model in which there is a list of \\textit{tickable} nodes. Only the nodes in the list can be ticked.\n\n\\subsubsection{Model independent from execution}\n\nWhen running a BT, there should be a clear distinction between the tree that is being run (the model) and how it is actually being run (the execution). For each particular behaviour, we distinguish between the \\textit{Model BT} that defines it and how it is being run. The \\textit{how} is what the \\textit{BT Executor} does. Basically, for every entity in the game that wants to run a behaviour (Model BT), there is a BT Executor. The BT Executor takes the Model BT and processes it (without modifying it), simulating the behaviour that is represented by the Model BT. This choice implies that, apart from the Model BT, there is another type of tree, the \\textit{Execution BT}. When an entity wants to execute a behaviour, the BT Executor takes the Model BT and creates an Execution BT to execute the behaviour. The BT Executor along with the Execution BT know how to run the behaviour that the Model BT represents.\n\n\\subsubsection{Architecture}\n\nFigure \\ref{fig:Overview} shows an overview of the proposed architecture for BTs. There is a Model BT that represents a particular behaviour. Also, there is a BT Executor for every entity that wants to run the Model BT. Each BT Executor makes use of the Model BT and builds an Execution BT that actually runs the behaviour conceptualized by the Model BT. An external Game AI ticks the BT Executors, in order for them to update the trees that they are running.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=\\textwidth]{./Images/Overview.pdf}\n \\caption{Overview of the BT architecture}\n \\label{fig:Overview}\n\\end{figure}\n\n\\section{Lists of nodes}\n\nAt all times, the BT Executor receives ticks from an external Game AI. As a consequence, the BT Executor makes the tree it contains evolve.\n\nNot all the nodes of the tree should receive ticks. In general, the evolution of the tree depends on a very small set of nodes, which, in general, is mainly composed of leaves of the tree. In general, intermediate nodes, such as sequences or selectors, should do nothing unless they are notified by their children after finishing. As a consequence, it is obvious that only a few nodes should receive ticks. The rest should be somehow \\textit{asleep}, waiting for some events to take place in order to be awakened.\n\nWe have implemented an architecture where, for each BT being run, there is a list of \\textit{tickable nodes} (\\textit{Tickable Nodes List} from now on). Whenever the external Game AI ticks the BT Executor, the BT Executor will only tick the nodes in the Tickable Nodes List. This list is modified through out the execution of the tree, so nodes enter and leave the list depending on whether they are useful with respect to the evolution of the tree or not.\n\nAlso, at all times the BT Executor knows which nodes are open (or active). A node is active if it belongs to a path from the root node to an active leaf node. Therefore, open nodes represent those that are actively involved in the current execution of the tree. They may not be tickable nodes, but the fact that they belong to a path from the root to an active leaf node means that they may receive ticks soon.\n\nThis list is called the \\textit{Open Nodes List}.\n\n\\section{Model BT, guards and context}\n\nA Model BT is a BT that conceptually represents a behaviour. A Model BT does not have running capabilities, that is, it is just a way of defining a behaviour. An external interpreter, the BT Executor, uses the Model BT as a base to run the behaviour it embodies. A Model BT is shared by all the entities that want to run such a behaviour. By following this model, there is only one tree even though it is being actually run by several entities.\n\nThe main functionality of a Model BT is very simple. The base class for a node (also called \\textit{task}) is mainly as follows:\n\n\\begin{minted}{java}\npublic abstract class ModelTask{\n  /* The list of children of the task. */\n  private List<ModelTask> children;\n\n  /* The guard of the task, which may be null. */\n  private ModelTask guard;\n\n  public ModelTask(ModelTask guard, ModelTask... children){\n    this.children = new Vector<ModelTask>();\n    for(int i=0;i<children.lenght;i++){\n      this.children.add(children[i]);\n    }\n    this.guard = guard;\n  }\n\n  public List<ModelTask> getChildren(){\n    return this.children;\n  }\n\n  public ModelTask getGuard(){\n    return this.guard;\n  }\n\n  ...\n}\n\\end{minted}\n\nThat is, a task is just a container of other tasks, with no running capabilities. A task's children can be accessed, as well as its guard. In this model, a behaviour tree is equivalent to a ModelTask object, that is, a ModelTask can be interpreted as the behaviour tree whose root is the ModelTask itself. There can be as many ModelTask subclasses as supported by the underlying BT model being implemented, but none of them should define running methods.\n\nA guard is represented by an ModelTask object. Initially, we defined guards as objects implementing the \\textit{IGuard} interface:\n\n\\begin{minted}{java}\npublic interface IGuard{\n  /* Evaluates the guard within a context. */\n  public boolean evaluate(IContext);\n}\n\\end{minted}\n\nThat is, a guard was just an entity capable of being evaluated within a context, issuing a boolean value as a result. However, a more general approach is that of considering a ModelTask to be a guard. By doing so, \\textit{conditions} (ModelTasks that evaluate certain attributes of the world) can be used as guards. What is more, any behaviour tree can be used as a guard. As long as the behaviour tree succeeds, the guard evaluation is interpreted as \\textit{true}; if the behaviour tree fails, the guard evaluation is interpreted as \\textit{false}.\n\nIn general, guards will be implemented by single ModelTask nodes. For instance, if a guard has to check if the current player has enough resources to build a particular type of unit, then a subclass of ModelTask may represent such condition. This conditions may be used, not only as a guard, but also as a condition node along the tree.\n\nThe main advantage of this method is that of reusability, since predefined tasks can also be used as guards.\n\nA context is defined by the \\textit{IContext} interface:\n\n\\begin{minted}{java}\npublic interface IContext{\n  /* Sets the value of a variable. */\n  public void setVariable(String name, Object value);\n\n  /* Gets the value of a variable (null if not found). */\n  public Object getVariable(String name);\n\n  ...\n}\n\\end{minted}\n\nWe will extend this interface further in following sections. However, the previous two methods define the core of what a context should be in a behaviour tree: an large repository of variables that can be modified an accessed by tasks.\n\n\\section{Execution BT and BT Executor}\\label{Sub:ExecutionBTAndBTExecutor}\n\nAn Execution BT is a BT capable of running a particular BT Model. The idea behind this whole architecture is that, for each ModelTask, there must be another task knowing how to run it. For instance, there could be an ExecutionSequenceTask knowing how a ModelSequenceTask behaves, or an ExecutionParallelTask knowing how to run a ModelParallelTask. \n\n\\textit{ExecutionTask} is the base class for all the tasks with the ability to run. An ExecutionTask has a reference to the ModelTask it represents, so it knows what the structure of the conceptual tree is like. An ExecutionTask also has a reference to the BT Executor in charge of it.\n\nThe BT Executor contains the Tickable Nodes List and the Open Nodes List. Both lists store ExecutionTasks.\n\nInitially, the BT Executor receives the Model BT it should execute. It then creates an ExecutionTask for the root node of the tree, and \\textit{spawns} it. When an ExecutionTask is spawned, it recursively spawns its children according to the semantics of the particular task. The idea is that, when \\textit{spawn()} is called, the path(s) containing all the tasks from the root to the active leaf nodes must be created and stored. When a task is spawned, it has to decide whether it enters the list of tickable nodes or not. Also, when a task is spawned, it is inserted into the \\textit{Open Nodes List}.\n\nFrom then on, the BT Executor just ticks the list of tickables nodes it contains. At every tick, the tickable nodes analyse their current situation to check whether they have or have not finished. For an intermediate node, this decision in general depends on whether its children have finished or not. For leaf nodes, this decision usually depends on an external process that has to be checked for termination.\n\nWhen a task (intermediate or not) has finished, it should notify its parent. In general, parent (intermediate) nodes will not usually be tickables; therefore, they will not be in the Tickable Nodes List, and as a result, the only way for them to notice that they have to be updated is by being explicitly told so. Thus, when a tickable finishes, a TaskEvent is fired. Parents register as TaskEventListeners of their children (at spawning time), so whenever a child is done, the parent will immediately realize and will be able to act as a consequence. By following this pattern, only very few tasks must stay in the Tickable Nodes List: in general, only leaf nodes will receive ticks. When they are done, they will automatically fire a TaskEvent. Parents, on the other hand, will usually register as TaskEventListeners of their children, so they will receive such events and will be able to have a chance to react to the termination of their children. If the parent finishes as a consequence of the child's termination, then the parent will fire a TaskEvent to notify its parent too, and so on.\n\nThe BT Executor has a very simple interface:\n\n\\begin{minted}{java}\npublic class BTExecutor{\n  /* The Model BT being run. */\n  private ModelTask modelBT;\n\n  /* The list of tickable nodes. */\n  private List<ExecutionTask> tickableList;\n\n  /* The list of open nodes. */\n  private List<ExecutionTask> openList;\n\n  /* Updates the tree being run. */\n  public void tick();\n\n  /* Terminates the execution of the tree. */\n  public void terminate();\n\n  /* Returns the status of the tree being run. */\n  public Status getStatus();\n\n  ...\n} \n\\end{minted}\n\nAn ExecutionTask mainly contains a reference to the ModelTask it is running, the BTExecutor and the context (IContext), as follows:\n\n\\begin{minted}{java}\npublic abstract ExecutionTask implements ITaskListener{\n  /* Reference to the corresponding ModelTask. */\n  private ModelTask modelTask;\n\n  /* The BTExecutor that is running this ExecutionTask. */\n  private BTExecutor executor;\n\n  /* The context of the task. */\n  private IContext context;\n\n  /* List of all the listeners of this task. */\n  private List<ITaskListener> listeners;\n\n  /* Current status of the task. */\n  private Status currentStatus;\n\n  /* Spawns the task and its children. */\n  public final void spawn(IContext context){...};\n\n  /* Ticks the task. */\n  public final void tick(){...}\n \n  /* Terminates the task. */\n  public final void terminate(){...}\n\n  /* Returns the current status of the task. */\n  public Status getCurrentStatus(){\n    return this.currentStatus;\n  }\n\n  /* \n   * Adds a task listener to this task. The\n   * task listener will be notified when an important\n   * change in the status of this task occurs.\n   */\n  public void addTaskListener(ITaskListener listener){\n    if(listener != null){\n      this.listener.add(listener);\n    }\n  }\n\n  /* Called to fire the TaskEvent on all the listeners. */\n  private void fireTaskEvent(Status s){\n    for(ITaskListener t:this.listeners){\n      t.taskFinished(new TaskEvent(s));\n    }  \n  }\n\n  ...\n}\n\\end{minted}\n\nAn ExecutionTask has three main methods, \\textit{spawn()}, \\textit{tick()} and \\textit{terminate()}. These three methods define the main functionality of an ExecutionTask. They have a base definition that cannot be overriden by subclasses, and their internal implementation relies upon three abstract methods, \\textit{internalSpawn()}, \\textit{internalTick()} and \\textit{internalTerminate()} respectively. Subclasses define their specific behaviour by implementing these abstract methods.\n\nAs stated before, the standard behaviour of all ExecutionTask is implemented in the \\textit{spawn()}, \\textit{tick()} and \\textit{terminate()} methods. Their definition is as follows:\n\n\\begin{minted}{java}\n/* Spawn. */\npublic final void spawn(IContext context){\n  /*\n   * Store the context.\n   */\n  this.context = context;\n\n  /* Set the current status of the task to Status.RUNNING. */\n  this.status = Status.RUNNING;\n\n  /*\n   * Request to be inserted into the list of open tasks.\n   */\n  this.executor.requestInsertionIntoOpenList(this);\n  \n  /*\n   * Carry out the actual spawn.\n   */\n  internalSpawn();\n}\n\n/* Tick. */\npublic final Status tick(){\n  Status newStatus = internalTick();\n\n  this.currentStatus = newStatus;\n\n  if(this.currentStatus != RUNNING){\n    this.executor.requestRemovalFromTickableList(this);\n    this.executor.requestRemovalFromOpenList(this);\n\n    fireTaskEvent(newStatus);\n  } \n\n  return newStatus;\n}\n\n\\end{minted}\n\nWith respect to the \\textit{terminate()} method, see section \\ref{Sub:TerminatingTasks} for further explanation. As we can see, the main purpose of \\textit{spawn()} is to store the context (so that in is accessible later on, when the task actually needs it) and request that the task be inserted into the list of open nodes. Finally, it calls \\textit{internalSpawn()}, where the task will carry out the spawning process according to its semantics (for instance, a parallel task would spawn all of its children, while a selector would spawn just one child). This method is in charge of the following:\n\n\\begin{itemize}\n  \\item It decides whether it should enter the Tickable Nodes List or not\\footnote{See Section \\ref{Sub:ManagingLists} for further explanation.}. For instance, an ExecutionSequenceTask should not enter the list, because the fact that it evolves or not depends on the termination of its children (therefore, only its children should enter the list). However, low level actions or tasks such as DynamicPriorotyList should. It is very important to note that if the spawning process of a task fails, it should enter the Tickable Nodes List in order for it to notify its parent at the next AI cycle. A DynamicPriorityList, for instance, may fail in case no valid guard is found, in which case it should be ticked at the next AI cycle so as to notify its parent.\n\n  \\item According to the semantics of the node, it recursively spawns none, one or several of its children. For instance, an ExecutionSequenceTask should spawn the very first node of its list of children. An ExecutionParallelTask should spawn all of its children. On the contrary, a low level task (leaf node) cannot spawn any child since it has none.\n\n  \\item In case of a low level task, \\textit{internalSpawn()} should start the execution of the process associated to the node. Keep in mind that low level tasks may perform long processes that require several ticks in order to complete. It is in this method that those processes start (maybe in independent threads). It should be noted, however, that many processes may be \\textit{instantaneous}, so they may complete even within the \\textit{internalSpawn()} method. Nevertheless, in these cases the tree should not evolve, reason why the termination notification to its parent should be carried out in the \\textit{tick()} method, in the next AI cycle. If \\textit{internalSpawn()} were allowed to notify parents when the node terminated, then a single call to \\textit{spawn()} may take too long to complete due to the uninterrupted evolution of the tree, which is something that has to be avoided.\n\\end{itemize}\n\nOn the other hand, \\textit{tick()} calls the \\textit{internalTick()} method, where the task will carry out the actual ticking process. Then, if the task has finished after calling it, a TaskEvent will be fired to notify all the listeners that are registered with the task, and it requests to be removed from the Tickable Nodes List and the Open Nodes List. It is by this mechanism that parents are notified about their children termination, and can act accordingly.\n\n\\textit{internalTick()} is the method that actually performs the tick. In general, this method will analyse the current status of the children of the task (\\textit{ExecutionTask.getStatus()}), and will evolve accordingly. For instance, when an ExecutionSequenceTask receives a TaskEvent from its currently active child, its \\textit{tick()} method gets called, and the following is done (in \\textit{internalTick()}):\n\n\\begin{itemize}\n\\item If the child has succeeded, the ExecutionSequenceTask will spawn the next child in case there is one, and will return RUNNING. In case it is the last child, it will return SUCCESS.\n\\item If the child has failed, the ExecutionSequenceTask will also fail, returning FAILURE.\n\\end{itemize}\n\nThe ITaskListener interface represents an interface for listening to events fired when there are important changes in the status of a task.\n\n\\begin{minted}{java}\npublic interface ITaskListener{\n  /* \n   * Called whenever there is a change in\n   * the status of a task. \n   */\n  public void statusChanged(TaskEvent e);\n}\n\\end{minted}\n\nIn general, the method \\textit{statusChanged()} will just call \\textit{tick()} on the node itself. By doing so, the node will be able to advance, either by spawning other children or by firing a TaskEvent to its parent to make it go on too.\n\n\n\\section{Creating ExecutionTasks from ModelTasks}\n\nExecutionTasks must be created for ModelTasks. In order to make this process easier, it can be delegated to ModelTasks. When an ExecutionTask needs to create the ExecutionTask of one of its children, it can ask the corresponding ModelTask to do so. Therefore, ModelTasks define a new method,\n\n\\begin{minted}{java}\n/* \n * Creates an ExecutionTask that is able to run \n * this ModelTask. \"executor\" is the BTExecutor \n * managing the ExecutionTask that will be created.\n */\npublic abstract ExecutionTask createExecutor(BTExecutor executor);\n\\end{minted}\n\nThis method should return an ExecutionTask capable of running the corresponding ModelTask. Keep in mind that the returned ExecutionTask must have a reference to the ModelTask that created it. For instance, in case of a ModelSequenceTask, it should do something like:\n\n\\begin{minted}{java}\npublic ExecutionTask createExecutor(BTExecutor executor){\n  return new ExecutionSequenceTask(this, executor);\n}\n\\end{minted}\n\nBy following this pattern, it would be ModelTasks that would be in charge of creating ExecutionTasks through \\textit{createExecutor()}.\n\n\n\\section{Managing the Tickable Nodes List and the Open Nodes List}\\label{Sub:ManagingLists}\n\nWhen tasks are being ticked, there may be a problem accessing the Tickable Nodes List. The algorithm followed by the BTExecutor is pretty simple:\n\n\\begin{minted}{java}\npublic class BTExecutor{\n  ...\n\n  public void tick(){\n    if(this.firstTimeCalled){\n      ExecutionTask root = this.modelBT.createExecutor();\n      root.spawn();\n      this.firstTimeCalled = false;\n    }\n    else{\n      for(ExecutionTask t:this.tickableList){\n\tt.tick();\n      }\n    }\n\n    ...\n  }\n\n  ...\n}\n\\end{minted}\n\nThat is, it just ticks all the nodes in the Tickable Nodes List. However, while the list is being ticked, some nodes may need to leave the list, so the iteration through its elements may be left in an inconsistent state. Therefore, when a node wants to enter or leave the list, it does not \\textit{immediately} do it. Instead, it \\textit{requests} to be inserted or removed. When the BTExecutor has ticked all the nodes, it processes these requests, so the code above should finally be something like:\n\n\\begin{minted}{java}\npublic class BTExecutor{\n  ...\n \n  public void tick(){\n    if(this.firstTimeCalled){\n      ExecutionTask root = this.modelBT.createExecutor();\n      root.spawn();\n      this.firstTimeCalled = false;\n    }\n    else{\n      for(ExecutionTask t:this.tickableList){\n\tt.tick();\n      }\n    }\n    \n    processRemovalsAndInsertions();\n  }\n  \n  ...\n}\n\\end{minted}\n\nIn order to prevent the Open Nodes List from failing the same way, insertions and removals from it are also requested and delayed instead of being immediately carried out. \n\n\\section{Terminating tasks}\\label{Sub:TerminatingTasks}\n\nIn certain cases, tasks must be abruptly terminated. This happens, for instance, when a parallel task realizes that one of its children has failed. In such a case, it has to immediately stop the other children. Another example is when a whole tree needs to be terminated, because it just does not make sense to run it any more. As we can see, there are several scenarios in which it is necessary to have the ability to stop individual tasks or branches of a tree. This is the purpose of the method \\textit{terminate()}, first introduced in the section \\ref{Sub:ExecutionBTAndBTExecutor}.\n\nAs a consequence of these requirements, BTExecutor and ExecutionTask need to be extended, so both include a \\textit{terminate()} method. In the case of the BTExecutor, its implementation is trivial: it will just terminate the tree that it is running. However, the \\textit{terminate()} method in the ExecutionTask class is more complicated. Since the termination process of an ExecutionTask varies according to the specific type, it is an final method whose implementation relies on the abstract \\textit{internalTerminate()} method, which carries out the actual termination process.\n\nWhat \\textit{terminate()} does is to request that the task be removed from both the list of tickable and open nodes, sets the status of the task to \\textit{terminated}, and finally calls \\textit{internalTerminate()}. For non-leaf tasks, \\textit{internalTerminate()} usually calls \\textit{terminate()} on their active children, in a recursive manner. For leaf tasks, it will stop and free all the processes and resources belonging to the task.\n\nThe problem about terminating tasks is that they must not leave the list of tickable nodes until the next game AI cycle (that is, until \\textit{BTExecutor.tick()}) is called again. This is due to the fact that the list of tickable nodes may be being ticked just when a task is terminated. If the terminated task(s) were removed from the list, then it would be left in an inconsistent state and the BTExecutor would have problems ticking all of its tasks. It is for this reason that when a task is requested to terminate itself, the task does not immediately remove itself from the Tickable Nodes List, but requests it. Now, the problem is that the BTExecutor could tick tasks that have been terminated, since they are not removed from the Tickable Nodes List until the current AI cycle finishes.In order to prevent from any problem, the \\textit{ExecutionTask.tick()} method is modified so that, if the task has been terminated, it does nothing.\n\n\\begin{minted}{java}\npublic abstract ExecutionTask implements ITaskListener{\n  ...\n  public Status tick(){\n    if(!this.terminated){\n      Status newStatus = internalTick();\n\n      this.currentStatus = newStatus;\n\n      if(this.currentStatus != RUNNING){\n\trequestRemovalFromTickableList(this);\n\trequestRemovalFromOpenList(this);\n\n\tfireTaskEvent(newStatus);\n      } \n\n      return newStatus;\n    }\n    else{\n      return Status.TERMINATED;\n    }\n  }\n  ...\n\\end{minted}\n\nThe \\textit{ExecutionTask.terminate()} method is mainly implemented like this:\n\n\\begin{minted}{java}\npublic abstract ExecutionTask implements ITaskListener{\n  ...\n  public void terminate(){\n      if(!this.terminated){\n\trequestRemovalFromOpenList();\n\trequestRemovalFromTickableList();\n\tthis.terminated = true;\n\tthis.currentStatus = Status.TERMINATED;\n\tinternalTerminate();\n      }\n  }\n  ...\n}\n\\end{minted}\n\nThat is, the \\textit{terminate()} method requests to remove the task from both the Open Nodes List and the Tickable Nodes List. Also, it activates a flag to indicate that the task has been terminated. Finally, it calls the abstract method \\textit{ExecutionTask.internalTerminate()} which will actually terminate the task.\n\n\\textbf{It must be noted that the termination process must be carefully handled}. When a task is terminated, it immediately becomes totally unresponsive, so ticking it will have no effect; also, at the next game AI cycle, it will be removed from the list of tickable nodes. As a result, its parent will never be notified about its child termination -it will not receive a TaskEvent-, and it will never be able to evolve. \n\nTherefore, when a task is terminated, its parent should enter the list of tickable nodes so that at the next game AI cycle it can receive ticks and realizes that its child has finished (been terminated). This is for example what the ExecutionInterrupter does when it is interrupted: it terminates its child and then requests to be inserted into the list of tickable nodes. Even though it may not be necessary to always insert the parent task into the list of tickable nodes, it should be kept in mind that terminating tasks is a very delicate process that must be properly handled.\n\n\\section{General process}\n\nSo far we have described a general architecture to model and run behaviour trees. Despite the fact that there are still many details to be taken care of, we can give an overview of the whole process of managing a behaviour tree:\n\n\\begin{itemize}\n\n\\item A Model BT is created. The Model BT represents the behaviour that must be run, but it cannot be executed by itself. The tree would be implemented by a ModelTask.\n\n\\item A BTExecutor is created. The BTExecutor will contain a reference to the ModelTask that must be run.\n\n\\item From then on, \\textit{BTExecutor.tick()} is called in order to run the tree. At every game cycle, \\textit{tick()} is called. The external caller should not worry about anything else; it will be the BTExecutor that will handle the execution of the BT.\n\n\\begin{itemize}\n\n\\item The very first time \\textit{tick()} is called, the BTExecutor takes the root node of the Model BT, and creates the corresponding ExecutionTask node, which is spawned. This is done by calling \\textit{ModelTask.createExecutor()}, and then calling \\textit{ExecutionTask.spawn()} on the returned ExecutionTask.\n\n\\item From then on, every time \\textit{BTExecutor.tick()} is called, the BTExecutor will just tick the nodes in the Tickable Nodes List. \n\n\\end{itemize}\n\n\\item Whenever a task finishes, it fires an event to inform its parent. The parent will then either report success or failure (depending on whether the child failed or succeeded) or spawn a new child. If the parent also finishes, it will fire a new event to its parent, in a recursive manner.\n\n\\end{itemize}\n\n\\section{Actions and conditions (leaf nodes)}\n\nActions and conditions, that is, leaf nodes in the BT, must be somehow specified. At design level, the BT is designed including all the low level actions and conditions that the tree is supposed to run, but in an abstract manner. \n\nOn the implementation side, however, there must be an ExecutionTask that knows how to run each leaf node. Since these tasks are outside the framework, a way of defining their behaviour must be provided. The framework provides two abstract classes, \\textit{ModelAction} and \\textit{ModelCondition}, so every low level action and condition must subclass them, \n\n\\begin{minted}{java}\npublic abstract class ModelAction extends ModelTask{\n  ...\n}\n\\end{minted}\n\n\\begin{minted}{java}\npublic abstract class ModelCondition extends ModelTask{\n  ...\n}\n\\end{minted}\n\nFor instance, a low level action \\textit{MoveTo} would be defined like this:\n\n\\begin{minted}{java}\npublic class MoveTo extends ModelAction{\n  ...\n}\n\\end{minted}\n\nModelTasks and ModelConditions also define a \\textit{createExecutor()} method that must return the corresponding ExecutionTask to run the action or condition. The designer should define the \\textit{internalSpawn()}, \\textit{internalTick()} and \\textit{internalTerminate()} methods for these ExecutionTasks. For instance, lets suppose that the designer has created a BT with a low level action called \\textit{MoveTo}. Such action would be represented by two classes:\n\n\\begin{minted}{java}\npublic class ModelMoveTo extends ModelAction{\n  ...\n\n  public ExecutionTask createExecutor(BTExecutor executor){\n    return new ExecutionMoveTo(this, executor);\n  }\n}\n\\end{minted}\n\n\\begin{minted}{java}\npublic class ExecutionMoveTo extends ExecutionAction{\n  ...\n\n  public void internalSpawn(){\n    /* TODO: designer should implement this method! */\n  }\n\n  public Status internalTick(){\n    /* TODO: designer should implement this method! */\n    return Status.SUCCESS;\n  }\n\n  public void internalTerminate(){\n    /* TODO: designer should implement this method! */\n  }\n}\n\\end{minted}\n\nSo the designer should only implement the \\textit{internalSpawn()}, \\textit{internalTick()} and \\textit{internalTerminate()} methods. In the case of the MoveTo action, \\textit{internalSpawn()} would send the unit the move order through the game engine. \\textit{internalTick()} would check whether the unit has arrived at its destination. If so, it would return \\textit{Status.SUCCESS}; otherwise, it would return \\textit{Status.RUNNING}.\n\n\\section{Evaluation order}\n\nThe problem with having a Tickable Nodes List is that the order in which nodes are ticked does not necessarily correspond to that of an ideal BT. Suppose for example that we have a BT with a DynamicPriorotyList (DPL) task, and some of its children are currently running. Suppose an scenario in which, if the active child is ticked, it finishes successfully, but at the same time, if the DPL is ticked, it realizes there is a child with higher priority that must be run.\n\nIdeally, the DPL is ticked first, so it terminates the currently active child and spawns the child with higher priority. However, if in the Tickable Nodes List the currently active child is placed before the DPL node, it will receive a tick first. In the presented scenario, the child would finish with success, the DPL would be informed, and as a result, it would terminate without spawning the child with higher priority. Moreover, the child task would succeeds while in the ideal BT it would not.\n\nThis problem can be fixed by forcing an order in the Tickable Nodes List. In particular, if parent nodes always precede their children at ticking time, then this problem is fixed, since by doing so the ideal evaluation order of a BT is emulated.\n\n\\section{Subtree Lookup and IContext}\\label{sec:SubtreeLookupAndIContext}\n\nOne of the most important features of behaviour trees is that of reusability. In the context of behaviour trees it is very important to notice the way that parent tasks interact with their children: parents do not care about what their children are; in JBT, on the conceptual side, this can be seen in the fact that ModelTasks always have other ModelTasks as children, and it is through its interface that they interact, no matter the particular subtype. On the execution side, ExecutionTasks always have other ExecutionTasks as their children, and it is also through its interface that they interact, no matter the particular subtype.\n\nA behaviour tree is represented by its root ModelTask (with its corresponding ExecutionTask). As a consequence, a behaviour tree task interacts with a single child task just the same way it interacts with a complete behaviour tree (that is, with the root of the tree). This property is specially important with respect to reusability: the designer labels trees with a name, and then at some point in whatever tree he is building, decides to reuse a particular tree -identifier by its name-. By following this philosophy, the effort of creating trees decreases dramatically.\n\nThe ability to reuse trees by name is implemented by the Subtree Lookup task. The ModelSubtreeLookup task receives, as an input argument in its constructor, the name of the subtree that it has to emulate. When it gets spawned, it will emulate the behaviour of the tree it is expected to emulate.\n\nThe ExecutionTask that is able to run a ModelSubtreeLookup is the ExecutionSubtreeLookup class. This class, however, faces a problem when it tries to emulate the tree whose name was initially given: even though it knows the name that identifies the tree to emulate, it does not know where to find such tree (that is, it does not know where the root ModelTask of such tree is). Thus, there must be a mechanism through which the ExecutionSubtreeLookup can find the tree it is expected to emulate. This mechanism is implemented via the IContext interface. The IContext interface\nis extended with a new method:\n\n\\begin{minted}{java}\n/* Returns a behavior tree by name. */ \npublic ModelTask getBT(String name);\n\\end{minted}\n\nGiven the name of the tree to retrieve, \\textit{getBT()} returns the root of such tree. Note that users of the IContext interface do not care about where the trees it provides come from; it only cares about retrieving trees by name, which is exactly that the IContext interface exposes.\n\n\\section{Behaviour trees libraries}\n\nBehaviour trees are identified by names that somehow summarize what they do. Take for example a character that is expected to behave aggressively. Such character could use a behaviour tree with name ``AggressiveBehaviour''.\n\nIn general, behaviour trees are identified by name, so there must be a way of retrieving behaviour trees given a name. This is what a behaviour tree library represents: a repository of trees that can be accessed.\n\nIn JBT, a behaviour trees library is represented by the \\textit{IBTLibrary} interface. The IBTLibrary interface defines a single method that returns a tree with a given name. It is defined as follows:\n\n\\begin{minted}{java}\npublic interface IBTLibrary extends \n\t  Iterable<Pair<String, ModelTask>> {\n  /* Returns a behaviour tree given its name. */\n  public ModelTask getBT(String name);\n}\n\\end{minted}\n\nOne important detail about the IBTLibrary is that it implements the \\textit{Iterable} interface. By doing so, it allows its users to retrieve all the trees it contains. In particular, for each tree, it retrieves both the tree itself (the root ModelTask of the tree) and its name (as a String).\n\n\\section{Persistent tasks}\n\nSome tasks in BTs are persistent in the sense that, after finishing, if they are spawned again, they remember past information. Take for example the Limit task. A Limit task allows to run its child node only a certain number of times (for example, 5). After being spawned, it has to remember how many times it has been run so far, so that, once the threshold is exceeded, it fails.\n\nIn the simple model of BT there is no problem about it, because nodes are objects that exist from the beginning to the end, so they can remember whatever information they want. However, in the model we propose, nodes (ExecutionTask objects) are destroyed once they finish (they leave the Tickable Nodes List and whatever other lists they may be in), so a new mechanism must be implemented for keeping past information.\n\nWe propose to use the BTExecutor with that purpose. For instance, if a Limit task needs to know that it has been run 3 times so far, just before being destroyed it may write into the BTExecutor that number (3). The next time it is spawned, it may read, from the BTExecutor, that information. \n\nAll the persistent information of a task is saved into a \\textit{ITaskState} object. The ITaskState interface represents a collection of variables that can be accessed:\n\n\\begin{minted}{java}\npublic interface ITaskState {\n  /* Returns the value of a state variable by its name. */\n  public Object getStateVariable(String name);\n} \n\\end{minted}\n\nWhen the tasks needs to store its state for future use, it will have to create an ITaskState object containing all the information it wishes to keep. On the other hand, when the task needs to restore its previous state, it will receive an ITaskState object from which it will have to retrieve the needed information. We will see this in a moment, but first we have to address an important problem: who is in charge of storing the ITaskState objects of the tasks of a tree? Moreover, by what mechanism can we unambiguously assign an ITaskState to a node of the tree, so that the proper ITaskState object is delivered to the proper ExecutionTask? Both questions are in fact related.\n\nAn effective mechanism to assign ITaskState objects to tasks is by using the position of the task in the tree. Each ExecutionTask in the tree has got a position that is constant all over the execution of the tree, no matter how the tree evolves. Thanks to this we can assign ITaskState objects to positions in the tree; since a position in the tree corresponds to one, and only one ExecutionTask, such ITaskState will be that of the ExecutionTask pointed by the position.\n\nThe first question is a tricky one. Initially it could be thought that the context may be used; however, the fact that one context can also be used by guards (which are actually behaviour trees run each one by its own BTExecutor), makes it impossible to do so, because it could lead to clashes between positions of the main tree and those of the guards.\n\nOnce the context has been discarded, the only alternative left is the BTExecutor. The BTExecutor suffices for this task, since, among other things, it is shared by all the nodes of the tree except for those of guards' trees, thus avoiding position clashes.\n\nAs a result, the BTExecutor class is extended to support the storage of ITaskState objects:\n\n\\begin{minted}{java}\n/* \n * Sets the state of the task placed at a particular \n * position in the tree. \n */\npublic boolean setTaskState(Position taskPosition, \n\tITaskState state);\n\n/* \n * Retrieves the state of the task placed at a particular \n * position in the tree. \n */\npublic ITaskState getTaskState(Position taskPosition);\n\n/* \n * Clears the state of the task placed at a particular \n * position in the tree. \n */\npublic boolean clearTaskState(Position taskPosition);\n\\end{minted}\n\nIn order to facilitate the persistence of tasks to the designer, we can modify both the \\textit{spawn()} and \\textit{tick()} method so that they automatize this process. \n\n\\begin{minted}{java}\npublic final void spawn(IContext context){\n  /*\n   * Store the context.\n   */\n  this.context = context;\n\n  /* Set the current status of the task to Status.RUNNING. */\n  this.status = Status.RUNNING;\n\n  /*\n   * Request to be inserted into the list of open tasks.\n   */\n  this.executor.requestInsertionIntoOpenList(this);\n  \n  /* Restore the previous state. */\n  ITaskState previousState = this.executor.getTaskState();\n  restoreState(previousState);\n\n  /*\n   * Carry out the actual spawn.\n   */\n  internalSpawn();\n}\n\\end{minted}\n\nWhere it must be noted the new \\textit{restoreState(ITaskState)} method. This is an abstract method that must be implemented by subclasses, and its purpose is to restore the state of an ExecutionTask given the set of persistent information (ITaskState object) that was previously issued by the task. For the major part of tasks, this method will do nothing, so it will have an empty implementation. However, for tasks such as Limit, it will retrieve past information from the ITaskState object to properly restore the task. If the ITaskState object is null, it means that there is no past information, so the method should do nothing. For instance, the very first time that a Limit task is spawned it cannot retrieve past information, so \\textit{restoreState()} should do nothing.\n\nThe \\textit{tick()} method should also be modified to automatically store into the BTExecutor the persistent state information that \\textit{restoreStatus()} needs to restore the task:\n\n\\begin{minted}{java}\n/* Tick. */\npublic Status tick(){\n  if(!this.terminated){\n    Status newStatus = internalTick();\n\n    this.currentStatus = newStatus;\n\n    if(this.currentStatus != RUNNING){\n      ITaskState taskState = storeState();\n      this.executor.setTaskState(getPosition(), taskState);\n      requestRemovalFromTickableList(this);\n      requestRemovalFromOpenList(this);\n\n      fireTaskEvent(newStatus);\n    }  \n\n    return newStatus;\n  }\n  else{\n    return Status.TERMINATED;\n  }\n}\n\\end{minted}\n\nAlso here must be noted the new abstract method \\textit{storeState()}. This method is implemented by each subclass, and it returns an ITaskState object containing all the information that must be made persistent for future use. This method must issue an ITaskState object compatible with the \\textit{restoreState()} method, so that the ITaskState objects that the former issues can be understood by the latter. If no persistent information had to be stored for the task, null should be returned.\n\nThe \\textit{terminate()} method is also extended with a call to the \\textit{storeTerminationState()}, which is a method equivalent to \\textit{storeState()} but that is called only when the task is terminated.\n\nIn short, \\textit{storeState()} creates an ITaskState object that contains all the persistent information that the task may want to use in the future. That information is read by the \\textit{restoreState()} method.\n\n\\section{Native tasks}\\label{sec:NativeTasks}\n\nJBT offers a wide range of tasks that can be used to build behaviour trees. JBT basically implements the BT model described in \\cite{Millington09}, but extended with guards.\n\nJBT supports the following tasks:\n\n\\begin{itemize}\n  \\item Composite tasks: tasks with one or more children, whose execution depends on the execution of their children. The task's children are ordered.\n  \\begin{itemize}\n    \\item Sequence: task that sequentially executes all its children in order. If one fails, the Sequence task fails. If all succeeds, the Sequence task succeeds.\n    \\item Selector: task that sequentially executes all its children in order. If one succeeds, the Selector task succeeds. If all fail, the Selector task fails.\n    \\item Parallel: task that concurrently executes all its children. A Parallel task does have a \\textit{parallel policy}. If the parallel task's policy is \\textit{sequence}, the parallel fails if one child fails; if all succeed, then the parallel succeed. If the parallel task's policy is \\textit{selector}, the parallel fails if all its children fail. If one succeeds, then the parallel also succeeds.\n    \\item Random Selector: task that executes all its children in a random order. If one fails, the Sequence task fails. If all succeeds, the Sequence task succeeds.\n    \\item Random Sequence: task that sequentially executes all its children in random order. If one succeeds, the Selector task succeeds. If all fail, the Selector task fails.\n    \\item Dynamic Priority List: task that executes the child with the highest priority whose guard is evaluated to true. At every AI cycle, the children's guards are re-evaluated, so if the guard of the running child is evaluated to false, it is terminated, and the child with the highest priority starts running. The Dynamic Priority List task finishes when no guard is evaluated to true (thus failing) or when its active child finishes (returning the active child's termination status).\n    \\item Static Priority List: task that executes the child with the highest priority whose guard is evaluated to true. Unlike the Dynamic Priority List, the Static Priority List does not keep evaluating its children's guards once a child is spawned. The Static Priority List task finishes when no guard is evaluated to true (thus failing) or when its active child finishes (returning the active child's termination status).\n  \\end{itemize}\n  \\item Decorator tasks: tasks with one child whose purpose is to alter the way other tasks behave.\n  \\begin{itemize}\n    \\item Interrupter: task that controls the termination of its child task. An Interrupter simply lets its child task run normally. If the child returns a result, the Interrupter will return it. However, the Interrupter can be asked to terminate the child task and return an specified status when done so.\n    \\item Inverter: task used to invert the status code returned by its child. When the decorated task finishes, its status code gets inverted.\n    \\item Limit: task that limits the number of times a task can be executed. This decorator is used when a task (the child of the decorator) must be run a maximum number of times. When the maximum number of times is exceeded, the decorator will fail forever on.\n    \\item Repeat: task that runs its child task forever. When its child task finishes, it runs it once more.\n    \\item Until Fail: task that runs its child as long as it does not fail. When the child task fails, Until Fail succeeds.\n    \\item Hierarchical Context Manager: task that creates a new context for its child. The context that it creates is a Hierarchical Context.\n    \\item Safe Output Context Manager: task that creates a new context for its child. The context that it creates is a Safe Output Context.\n    \\item Safe Context Manager: task that creates a new context for its child. The context that it creates is a Safe Context.\n  \\end{itemize}\n  \\item Leaf tasks: tasks with no children.\n  \\begin{itemize}\n    \\item Wait: task that keeps running for a period of time, and then succeeds. The user can specify for how long the Wait task should be running.\n    \\item Subtree Lookup: the Subtree Lookup described in section \\ref{sec:SubtreeLookupAndIContext}.\n    \\item Perform Interruption: task that interrupts an Interrupter task.\n    \\item Variable Renamer: task that renames a variable in the context.\n    \\item Success: task that immediately succeeds.\n    \\item Failure: task that immediately fails.\n    \\item Action: generic action that is executed in the game engine.\n    \\item Condition: generic condition that is executed in the game engine.\n  \\end{itemize}\n\\end{itemize}\n\n\\section{Automatic behaviour trees generation}\n\nSo far, JBT offers the main classes for building and executing behaviour trees. The user needs to construct a ModelTask object representing the tree that he wants to run, and then create a BTExecutor to run it.\n\nThis philosophy of creating behaviour trees, however, lacks of reusability, and can be very time consuming. \n\nFirst of all, the user must explicitly create the Java structure of all the behaviour trees, which can be very time consuming for very complex ones. It would be nice for the user to be able to define behaviour trees in a standard XML format that then may be directly translated into the corresponding JBT Java classes. By doing so, the user should not have to deal directly with the JBT Java classes, and as a result it would be much easier for him to define behaviour trees.\n\nOn the other hand, the user must create and implement all the classes that represent low level actions and conditions. These are classes that extend the \\textit{ModelAction}, \\textit{ExecutionAction}, \\textit{ModelCondition} and \\textit{ExecutionCondition} classes. To ease this task, the user may define actions and conditions in a standard XML format so that they may be directly translated into the corresponding JBT Java classes. However, since the way a low level action and condition works is not known by JBT, the programmer would still be in charge of defining their abstract methods so that JBT could run them as expected.\n\nJBT offers two tools that do these two tasks.\n\n\\subsection{Low level actions and conditions generation}\n\nJBT lets the user define, in a XML format, the set of actions and conditions that will be used to generate the skeleton of the corresponding JBT Java classes.\n\nThe XML format that JBT understand is an extension of that of Make Me Play Me (MMPM) domain files\\footnote{MMPM does support several action parameter types; our extension just adds the type \"OBJECT\", which represents a generic Java Object.}. A MMPM domain file contains a set of actions, sensors, goals and entities. As far as JBT is concerned, it only needs the set of actions and sensors. For each action in the domain file, JBT is able to generate the corresponding ModelAction and ExecutionAction classes. Also, for each boolean sensor in the domain file, JBT is able to generate the corresponding ModelCondition and ExecutionCondition classes.\n\nThe generated ModelAction and ModelCondition classes are complete, so they do not need to be modified. However, the ExecutionAction and ExecutionCondition generated classes contain a set of abstract method that must be implemented according to the semantics of the respective actions and conditions, so that they do what they are expected to do.\n\nIn particular, the abstract methods that must be implemented are:\n\n\\begin{minted}{java}\nprotected void internalSpawn();\nprotected Status internalTick();\nprotected void internaTerminate();\nprotected void restoreState(ITaskState state);\nprotected ITaskState storeState();\nprotected ITaskState storeTerminationState(); \n\\end{minted}\n\nMMPM domain files also let the designer specify input parameters for actions and sensors. These are parameters that actions and sensors are supposed to use when running. The generated JBT ExecutionAction and ExecutionCondition classes include \\textit{getter} methods for such input parameters. As a result, the programmer will be able to access the value of the input parameters in the abstract methods he has to implement, by using the getter methods. The value for the input parameters are either retrieved from the execution context(IContext) or directly provided at construction time, but these details are hidden from the programmer that implements the action or condition (he should just use the getter methods to retrieve whatever input parameters may be needed).\n\nThe class \\textit{ActionsAndConditionsGenerator.java} implements the program that performs this generation process.\n\n\\subsection{Behaviour trees libraries generation}\n\nJBT lets the user define behaviour trees in a standard XML format. Once he has defined several trees in different files, JBT can parse these files and produce a behaviour tree library class (class implementing the IBTLibrary interface) that the programmer can use to retrieve the corresponding behaviour trees and run them.\n\nThe class \\textit{BTLibraryGenerator.java} implements the program the performs this generation process. \n\n\\subsubsection{Behaviour tree XML format}\n\nIn this section we explain the format the user must follow to define behaviour trees in XML files.\n\nA behaviour tree has a root tag, $<Tree>$, within which all the tree is defined. The $<Tree>$ element has only one child, which is the root node of the tree.\n\n\\begin{minted}{xml}\n<Tree>\n  <Node>\n  ...\n  </Node>\n</Tree>\n\\end{minted}\n\nA $<Node>$ has three attributes, an \"id\", a \"name\" and a \"type\". \"id\" and \"type\" are mandatory for all nodes. \"name\", however, is not. There cannot be two nodes with the same \"id\" in the same tree\\footnote{This is not totally true. Guards are an exception. Keep reading for a further explanation.}. The root node of the tree has type \"Root\". For instance:\n\n\\begin{minted}{xml}\n<Tree>\n  <Node id=\"Node_0\" name=\"MyRoot\" type=\"Root\">\n  ...\n  </Node>\n</Tree>\n\\end{minted}\n\nA $<Node>$ has three types of child element. One of them is the $<Children>$ element, which stores the list of children of the node. $<Children>$ just contains a sequence of $<Node>$ elements. For instance:\n\n\\begin{minted}{xml}\n<Tree>\n  <Node id=\"Node_0\" name=\"MyRoot\" type=\"Root\">\n    <Children>\n      <Node>\n      ...\n      </Node>\n      <Node>\n      ...\n      </Node>\n      ...\n    </Children>\n  </Node>\n</Tree>\n\\end{minted}\n\nLeaf tasks of the tree do not have any child task, so $<Children>$ is not use there.\n\nThe second type of child of $<Node>$ is the $<Paramenters>$ element. $<Paramenters>$ just stores the list of parameters of the task, as well as their value. Each parameter \"name\" and its value is stored in a $<Paramenter>$ element. For instance, this is the set of parameters of a particular task:\n\n\\begin{minted}{xml}\n<Parameters>\n  <Parameter name=\"preFailureTime\" fromcontext=\"false\">34</Parameter>\n  <Parameter name=\"failureTime\" fromcontext=\"false\">434</Parameter>\n  <Parameter name=\"target\" fromcontext=\"false\">HydraliskID</Parameter>\n</Parameters>\n\\end{minted}\n\nWhere we can see three parameters, \"preFailureTime\", \"failureTime\" and \"target\" and their corresponding values, \"34\", \"434\" and \"HydraliskID\". \n\nA $<Parameter>$ element also has an attribute, \"fromcontext\", that can be either \"true\" or \"false\". If \"false\", the value of the parameter is read directly from the $<Parameter>$ element. If \"true\", the value in the $<Parameter>$ element represents the location, in the context, where the value of the parameter can be found.\n\nFor instance, a parameter like this:\n\n\\begin{minted}{xml}\n<Parameter name=\"preFailureTime\" fromcontext=\"false\">34</Parameter>\n\\end{minted}\n\nmeans that the value of the parameter \"preFailureTime\" is 34, while this:\n\n\\begin{minted}{xml}\n<Parameter name=\"preFailureTime\" fromcontext=\"true\">\npreFailureTimeLocation</Parameter>\n\\end{minted}\n\nmeans that the value of the parameter \"preFailureTime\" can be found in the context, in the place referenced by the string \"preFailureTimeLocation\".\n\nAmong other things, the \"fromcontext\" attribute determines the way that the getter methods of the automatically generated low level actions and conditions behave. If \"true\", the getter method will retrieve the parameter from the context (\\textit{IContext}). Otherwise, its value will be known in advance, so it will be easily retrieved.\n\nThe $<Parameters>$ child of $<Node>$ is optional, depending on whether the respective task does or does not have parameters. For instance, a Sequence node does not have parameters, but a Wait node does.\n\nThe third type of child of $<Node>$ is the $<Guard>$ element. A $<Guard>$ only contains one $<Node>$ element, which represents the guard. A $<Node>$ may have no guard, in which case the $<Guard>$ element is not used. \n\nWith respect to guards, there is an important detail about their identifiers that must be noted. In general, there cannot be two different nodes with the same ID in the same tree. However, guards are an exception. Guards are actually considered independent trees, so the ID of a guard's node can match the ID of a node of the tree that contains the guard. For instance, if a tree $A$ has a node with ID $ID\\_1$, a node of a guard of an $A$'s node may have $ID\\_1$ as ID, and there would be no conflict at all, since $A$ and any of $A$'s guards are considered to be independent trees.\n\nThis somehow restricts the way that nodes can interact with each other. For instance, if a node in $A$ refers to a node with ID $ID\\_23$, the node with $ID\\_23$ must be placed in $A$ and not in any of the guards that the nodes of $A$ may have. The Perform Interruption is a good example of this, since it has a parameter that stores the ID of the node that it has to interrupt. This restriction may be fixed in the future.\n\nThere are several standard types of node that are used when building a behaviour tree (one for each native task supported by JBT -see section \\ref{sec:NativeTasks}-). These nodes have a fixed syntax and well established semantics. They are:\n\n\\begin{itemize}\n \n\\item Sequence:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Sequence\".\n  \\item It does not have parameters.\n  \\item It does have children.\n  \\end{itemize}\n\n\\item Selector:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Selector\".\n  \\item It does not have parameters.\n  \\item It does have children.\n  \\end{itemize}\n\n\\item Random Sequence:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"RandomSequence\".\n  \\item It does not have parameters.\n  \\item It does have children.\n  \\end{itemize}\n\n\\item Random Selector:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"RandomSelector\".\n  \\item It does not have parameters.\n  \\item It does have children.\n  \\end{itemize}\n\n\\item Parallel:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Parallel\".\n  \\item It does have one parameter, named \"policy\", whose value may be either \"selector\" or \"sequence\". Its value cannot be retrieved from the context. For instance:\n    \\begin{minted}{xml}\n    <Node id=\"Node_XXX\" type=\"Parallel\">\n      <Parameters>\n        <Parameter name=\"policy\" fromcontext=\"false\">\n        selector</Parameter>\n      </Parameters>\n      <Children>\n      ...\n      </Children>\n    </Node>\n    \\end{minted}\n  \\item It does have children.\n  \\end{itemize}\n\n\\item Dynamic Priority List:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"DynamicPriorityList\".\n  \\item It does not have parameters.\n  \\item It does have children.\n  \\end{itemize}\n  \n\\item Static Priority List:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"StaticPriorityList\".\n  \\item It does not have parameters.\n  \\item It does have children.\n  \\end{itemize}\n\n\\item Hierarchical Context Manager:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"HierarchicalContextManager\".\n  \\item It does not have parameters.\n  \\item It does have one child.\n  \\end{itemize}\n\n\\item Safe Output Context Manager:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"SafeOutputContextManager\".\n  \\item It does not have parameters.\n  \\item It does have one child.\n  \\end{itemize}\n\n\\item Safe Context Manager:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"SafeContextManager\".\n  \\item It does not have parameters.\n  \\item It does have one child.\n  \\end{itemize}\n\n\\item Interrupter:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Interrupter\".\n  \\item It does not have parameters.\n  \\item It does have one child.\n  \\end{itemize}\n\n\\item Inverter:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Inverter\".\n  \\item It does not have parameters.\n  \\item It does have one child.\n  \\end{itemize}\n\n\\item Limit:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Limit\".\n  \\item It does have one parameter, named \"runs\", whose value can be any integer greater than 0. Its value cannot be retrieved from the context:\n    \\begin{minted}{xml}\n    <Node id=\"Node_XXX\" type=\"Limit\">\n      <Parameters>\n        <Parameter name=\"runs\" fromcontext=\"false\">12</Parameter>\n      </Parameters>\n      <Children>\n      ...\n      </Children>\n    </Node>\n    \\end{minted}\n  \\item It does have one child.\n  \\end{itemize}\n\n\\item Repeat:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Repeat\".\n  \\item It does not have parameters.\n  \\item It does have one child.\n  \\end{itemize}\n\n\\item Until Fail:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"UntilFail\".\n  \\item It does not have parameters.\n  \\item It does have one child.\n  \\end{itemize}\n\n\\item Perform Interruption:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"PerformInterruption\".\n  \\item It does have two parameters:\n    \\begin{itemize}\n      \\item One is named \"expectedresult\", and its value can be either \"success\" or \"failure\". Its value cannot be retrieved from the context.\n      \\item The other one's name is \"nodeid\", and its value must be the identifier of a node in the tree. Its value cannot be retrieved from the context.\n      \\begin{minted}{xml}\n    <Node id=\"Node_XXX\" type=\"PerformInterruption\">\n      <Parameters>\n        <Parameter name=\"expectedresult\" fromcontext=\"false\">\n        failure</Parameter>\n        <Parameter name=\"nodeid\" fromcontext=\"false\">\n        NODE_YYY</Parameter>\n      </Parameters>\n    </Node>\n      \\end{minted}\n    \\end{itemize}\n  \\item It does not have any children.\n  \\end{itemize}\n\n\\item Subtree Lookup:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"SubtreeLookup\".\n  \\item It does have one parameter, named \"subtreename\", whose value is any string. Its value cannot be retrieved from the context:\n   \\begin{minted}{xml}\n      <Node id=\"Node_XXX\" type=\"SubtreeLookup\">\n        <Parameters>\n          <Parameter name=\"subtreename\" fromcontext=\"false\">\n          MoveTo</Parameter>\n        </Parameters>\n        <Children>\n          ...\n        </Children>\n      </Node>\n    \\end{minted}\n  \\item It does not have any children.\n  \\end{itemize}\n\n\\item Wait:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Wait\".\n  \\item It does have one parameter, named \"duration\", whose value must be an integer greater or equal than 0. Its value cannot be retrieved from the context:\n    \\begin{minted}{xml}\n      <Node id=\"Node_XXX\" type=\"Wait\">\n        <Parameters>\n          <Parameter name=\"duration\" fromcontext=\"false\">\n          1500</Parameter>\n        </Parameters>\n      </Node>\n    \\end{minted}\n  \\item It does not have any children.\n  \\end{itemize}\n\n\\item Variable Renamer:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"VariableRenamer\".\n  \\item It does have two parameters:\n    \\begin{itemize}\n      \\item One is named \"variableName\", whose value must be a string. Its value cannot be retrieved from the context.\n      \\item The other one's name is \"newVariableName\", and its value is a string. Its value cannot be retrieved from the context.\n      \\begin{minted}{xml}\n    <Node id=\"Node_XXX\" type=\"VariableRenamer\">\n      <Parameters>\n        <Parameter name=\"variableName\" fromcontext=\"false\">\n        VariableToRename</Parameter>\n        <Parameter name=\"newVariableName\" fromcontext=\"false\">\n        NewName</Parameter>\n      </Parameters>\n    </Node>\n      \\end{minted}\n    \\end{itemize}\n  \\item It does not have any children.\n  \\end{itemize}\n\n\\item Success:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Success\".\n  \\item It does not have parameters.\n  \\item It does not have any children.\n  \\end{itemize}\n\n\\item Failure:\n\n  \\begin{itemize}\n  \\item \"type\" attribute has value \"Failure\".\n  \\item It does not have parameters.\n  \\item It does not have any children.\n  \\end{itemize}\n\n\\end{itemize}\n\nWith respect to low level actions and conditions, they are represented by $<Node>$ elements whose \"type\" attribute is \"Action\" and \"Condition\" respectively, and whose parameter \"name\" specifies the concrete type of action and condition.\n\n\\subsection{JBT Editor}\n\nEven though JBT is able to parse behaviour trees in the XML format defined above and generate the corresponding Java classes that can be run, for the user it is still a complicated task to define complex behaviour trees in such a format.\n\nJBT provides the \\textit{JBT Editor} (see a screenshot in figure \\ref{fig:JBTEditor}), a program that can be used to define behaviour trees through a graphical user interface in a very user-friendly way. These behaviour trees can be then exported into the XML format defined above, so that they can be parsed by JBT to create the corresponding behaviour trees libraries. By using the JBT Editor, the user does not have to deal with XML files directly; also, it checks the correctness of the trees, so whatever trees are stored into XML files, they are correct and can be parsed by JBT with no problems. JBT also lets the user load MMPM domain files and use its actions and conditions in the trees the user creates, as well as specify values for their input parameters and check their correctness.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=\\textwidth]{./Images/JBTEditor.png}\n % JBTEditor.png: 1365x730 pixel, 72dpi, 48.15x25.75 cm, bb=\n \\caption{JBT Editor}\n \\label{fig:JBTEditor}\n\\end{figure}\n\n\\bibliographystyle{plain}\n\\bibliography{JBTBib}\n\n\\end{document}\n"
  },
  {
    "path": "Documentation/JBTBib.bib",
    "content": "@Book{Millington09,\n  author =\t {Ian Millington and John Funge},\n  title = \t {Artificial Intelligence for Games},\n  publisher = \t {Morgan Kaufmann},\n  year = \t {2009},\n  edition =      {Second}\n}\n\n@misc{AIGameDev,\n\tauthor = {Alex J. Champandard},\n\ttitle = {http://aigamedev.com}\n}\n\n"
  },
  {
    "path": "JBTCore/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<classpath>\r\n\t<classpathentry kind=\"src\" path=\"src\"/>\r\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\r\n\t<classpathentry kind=\"lib\" path=\"libs/jdom.jar\" sourcepath=\"libs/jdomsrc.zip\"/>\r\n\t<classpathentry kind=\"lib\" path=\"libs/jargs.jar\"/>\r\n\t<classpathentry kind=\"lib\" path=\"libs/sourceformatter.jar\"/>\r\n\t<classpathentry kind=\"lib\" path=\"libs/mmpm.jar\"/>\r\n\t<classpathentry kind=\"output\" path=\"bin\"/>\r\n</classpath>\r\n"
  },
  {
    "path": "JBTCore/.gitignore",
    "content": "/bin\n"
  },
  {
    "path": "JBTCore/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>JBT</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "JBTCore/src/jbt/exception/IllegalReturnStatusException.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.exception;\n\nimport jbt.execution.core.ExecutionTask;\n\n/**\n * Exception thrown when {@link ExecutionTask#internalTick()} returns a Status\n * that is not allowed.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class IllegalReturnStatusException extends TickException {\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tpublic IllegalReturnStatusException(){\n\t\tsuper();\n\t}\n\t\n\tpublic IllegalReturnStatusException(String msg){\n\t\tsuper(msg);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/exception/NotTickableException.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.exception;\n\n/**\n * Exception thrown when a task that cannot be ticked is ticked.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class NotTickableException extends TickException {\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tpublic NotTickableException(){\n\t\tsuper();\n\t}\n\t\n\tpublic NotTickableException(String msg){\n\t\tsuper(msg);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/exception/SpawnException.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.exception;\n\n/**\n * Exception thrown when a task that cannot be spawned is spawned.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class SpawnException extends RuntimeException {\n\tprivate static final long serialVersionUID = 1L;\n\n\tpublic SpawnException() {\n\t\tsuper();\n\t}\n\n\tpublic SpawnException(String msg) {\n\t\tsuper(msg);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/exception/TickException.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.exception;\n\n/**\n * Exception thrown when there is an error in the ticking process of a task.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class TickException extends RuntimeException {\n\tprivate static final long serialVersionUID = 1L;\n\n\tpublic TickException() {\n\t\tsuper();\n\t}\n\n\tpublic TickException(String msg) {\n\t\tsuper(msg);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/context/BasicContext.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.context;\n\nimport java.util.Hashtable;\nimport java.util.Map;\n\nimport jbt.execution.core.IBTLibrary;\nimport jbt.execution.core.IContext;\nimport jbt.model.core.ModelTask;\n\n/**\n * Basic implementation of the IContext interface. This class uses a Hashtable\n * to store the set of variables.\n * <p>\n * Also, since a context must contain a set of behaviour trees, this class\n * defines some methods to add behaviour trees to the context.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BasicContext implements IContext {\n\t/**\n\t * The set of variables that the context consists of.\n\t */\n\tprivate Map<String, Object> variables;\n\t/**\n\t * The BT library that is internally used to manage all the trees of the\n\t * context.\n\t */\n\tprivate GenericBTLibrary library;\n\n\t/**\n\t * Default constructor. Constructs an empty BasicContext.\n\t */\n\tpublic BasicContext() {\n\t\tthis.variables = new Hashtable<String, Object>();\n\t\tthis.library = new GenericBTLibrary();\n\t}\n\n\t/**\n\t * \n\t * @see es.ucm.bt.core.IContext#getVariable(java.lang.String)\n\t */\n\tpublic Object getVariable(String name) {\n\t\treturn this.variables.get(name);\n\t}\n\n\t/**\n\t * \n\t * @see es.ucm.bt.core.IContext#setVariable(java.lang.String,\n\t *      java.lang.Object)\n\t */\n\tpublic boolean setVariable(String name, Object value) {\n\t\tif (value == null) {\n\t\t\treturn this.variables.remove(name) == null ? false : true;\n\t\t}\n\t\treturn this.variables.put(name, value) == null ? false : true;\n\t}\n\n\t/**\n\t * \n\t * @see es.ucm.bt.core.IContext#clear()\n\t */\n\tpublic void clear() {\n\t\tthis.variables.clear();\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.IContext#clearVariable(java.lang.String)\n\t */\n\tpublic boolean clearVariable(String name) {\n\t\treturn this.variables.remove(name) == null ? false : true;\n\t}\n\n\t/**\n\t * Adds all the behaviour trees in <code>library</code> to the set of\n\t * behaviour trees stored in the context. If there is already a tree with\n\t * the same name as that of one of the trees in <code>library</code>, it is\n\t * overwritten.\n\t * \n\t * @param library\n\t *            the library containing all the behaviour trees to add to this\n\t *            context.\n\t * @return true if a previously stored behaviour tree has been overwritten,\n\t *         and false otherwise.\n\t */\n\tpublic boolean addBTLibrary(IBTLibrary library) {\n\t\treturn this.library.addBTLibrary(library);\n\t}\n\n\t/**\n\t * Adds the behaviour tree <code>tree</code> to the set of behaviour trees\n\t * stored in the context. If there is already a tree with the name\n\t * <code>name</code>, then it is overwritten by <code>tree</code>.\n\t * \n\t * @param name\n\t *            the name that will identify the tree <code>tree</code> in the\n\t *            context.\n\t * @param tree\n\t *            the tree to insert.\n\t * @return true if there was already a tree with name <code>name</code>, and\n\t *         false otherwise.\n\t */\n\tpublic boolean addBT(String name, ModelTask tree) {\n\t\treturn this.library.addBT(name, tree);\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.IContext#getBT(java.lang.String)\n\t */\n\tpublic ModelTask getBT(String name) {\n\t\treturn this.library.getBT(name);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/context/GenericBTLibrary.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.context;\n\nimport java.util.Hashtable;\nimport java.util.Iterator;\nimport java.util.Map.Entry;\n\nimport jbt.execution.core.IBTLibrary;\nimport jbt.model.core.ModelTask;\nimport jbt.util.Pair;\n\n/**\n * Simple implementation of the {@link IBTLibrary} interface, which internally\n * uses a Hashtable to map tree names to actual trees. This class also defines\n * methods for adding behaviour trees to the library itself.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class GenericBTLibrary implements IBTLibrary {\n\t/**\n\t * The hashtable that stores all the trees of the library.\n\t */\n\tprivate Hashtable<String, ModelTask> trees;\n\n\t/**\n\t * Constructs a GenericBTLibrary containing no trees.\n\t */\n\tpublic GenericBTLibrary() {\n\t\tthis.trees = new Hashtable<String, ModelTask>();\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.IBTLibrary#getBT(java.lang.String)\n\t */\n\tpublic ModelTask getBT(String name) {\n\t\treturn this.trees.get(name);\n\t}\n\n\t/**\n\t * Returns a read-only iterator through the behaviour trees of the library.\n\t * While this iterator is being used, the library cannot be modified.\n\t * Otherwise, the results are undefined. Note that both trees and their\n\t * names can be accessed through this iterator.\n\t * \n\t * @see java.lang.Iterable#iterator()\n\t */\n\tpublic Iterator<Pair<String, ModelTask>> iterator() {\n\t\treturn new GenericBTLibraryIterator();\n\t}\n\n\t/**\n\t * Adds all the behaviour trees in <code>library</code> to the set of\n\t * behaviour trees stored in this library. If there is already a tree with\n\t * the same name as that of one of the trees in <code>library</code>, it is\n\t * overwritten.\n\t * \n\t * @param library\n\t *            the library containing all the behaviour trees to add to this\n\t *            library.\n\t * @return true if a previously stored behaviour tree has been overwritten,\n\t *         and false otherwise.\n\t */\n\tpublic boolean addBTLibrary(IBTLibrary library) {\n\t\tboolean overwritten = false;\n\n\t\tfor (Pair<String, ModelTask> tree : library) {\n\t\t\tif (this.trees.put(tree.getFirst(), tree.getSecond()) != null) {\n\t\t\t\toverwritten = true;\n\t\t\t}\n\t\t}\n\n\t\treturn overwritten;\n\t}\n\n\t/**\n\t * Adds the behaviour tree <code>tree</code> to the set of behaviour trees\n\t * stored in this library. If there is already a tree with the name\n\t * <code>name</code>, then it is overwritten by <code>tree</code>.\n\t * \n\t * @param name\n\t *            the name that will identify the tree <code>tree</code> in the\n\t *            library.\n\t * @param tree\n\t *            the tree to insert.\n\t * @return true if there was already a tree with name <code>name</code>, and\n\t *         false otherwise.\n\t */\n\tpublic boolean addBT(String name, ModelTask tree) {\n\t\tif (this.trees.put(name, tree) != null) {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Implementation of the iterator that GenericBTLibrary uses. This is a\n\t * read-only iterator (removal is not supported), and it internally uses an\n\t * iterator through the entry set of the hashtable.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class GenericBTLibraryIterator implements Iterator<Pair<String, ModelTask>> {\n\t\tprivate Iterator<Entry<String, ModelTask>> internalIterator;\n\n\t\tpublic GenericBTLibraryIterator() {\n\t\t\tthis.internalIterator = trees.entrySet().iterator();\n\t\t}\n\n\t\tpublic boolean hasNext() {\n\t\t\treturn this.internalIterator.hasNext();\n\t\t}\n\n\t\tpublic Pair<String, ModelTask> next() {\n\t\t\tEntry<String, ModelTask> next = this.internalIterator.next();\n\t\t\treturn new Pair<String, ModelTask>(next.getKey(), next.getValue());\n\t\t}\n\n\t\tpublic void remove() {\n\t\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\t\"This iterator cannot be used to remove elements\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/context/HierarchicalContext.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.context;\n\nimport jbt.execution.core.IContext;\n\n/**\n * A HierarchicalContext is a context that stores a parent IContext to fall back\n * to when it cannot find a particular variable in its own set of variables.\n * This class just redefines the method {@link #getVariable(String)} so that if\n * the variable name cannot be found, its value is retrieved from the parent\n * context.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class HierarchicalContext extends BasicContext {\n\t/**\n\t * The parent context. When a variable cannot be retrieved from the current\n\t * context, it will be looked up in the parent context.\n\t */\n\tprivate IContext parent;\n\n\t/**\n\t * Default constructor. Builds an empty HierarchicalContext, with no parent\n\t * context.\n\t */\n\tpublic HierarchicalContext() {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Sets the parent context of this HierarchicalContext. May be null, in\n\t * which case no parent context will be used.\n\t * \n\t * @param parent\n\t *            the parent context, which may be null.\n\t */\n\tpublic void setParent(IContext parent) {\n\t\tthis.parent = parent;\n\t}\n\n\t/**\n\t * Returns the value of a variable whose name is <code>name</code>. If a\n\t * variable with such a name cannot be found in the current context, and\n\t * there is a parent context set, the variable will be looked up in the\n\t * parent context, and its value returned. If it cannot be found in the\n\t * parent context (or in any other parent contexts through recursion), null\n\t * is returned.\n\t * \n\t * @see es.ucm.bt.context.BasicContext#getVariable(java.lang.String)\n\t */\n\tpublic Object getVariable(String name) {\n\t\tObject result;\n\n\t\tresult = super.getVariable(name);\n\n\t\tif (result == null) {\n\t\t\tif (this.parent != null) {\n\t\t\t\tresult = this.parent.getVariable(name);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/context/SafeContext.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.context;\n\nimport java.util.HashSet;\nimport java.util.Hashtable;\nimport java.util.Map;\nimport java.util.Set;\n\nimport jbt.execution.core.IContext;\nimport jbt.model.core.ModelTask;\n\n/**\n * The SafeContext represents a context that can be used to safely controls\n * modifications in another context (the <i>input context</i>).\n * <p>\n * A SafeContext contains an IContext (the <i>input context</i>). Initially, all\n * variables are read form the input context. However, when a variable is set or\n * cleared, its value is not modified in the input context, but it is locally\n * modified instead. From then on, the variable will be locally read instead of\n * reading if from the input context. Thus, the input context is never modified.\n * <p>\n * SafeContext can be used to situations in which an entity should use another\n * context (the input context) in read-only mode. If such entity uses a\n * SafeContext, it will not modify the input context, but on the other hand will\n * interact with the SafeContext in just the same way it would with the input\n * context.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class SafeContext implements IContext {\n\t/**\n\t * The original input context which the SafeOutputContext is based on.\n\t */\n\tprivate IContext inputContext;\n\t/**\n\t * Flag that tells whether the SafeOutputContext has been cleared.\n\t */\n\tprivate boolean cleared;\n\t/**\n\t * The set of local variables managed by the SafeOutputContext.\n\t */\n\tprivate Map<String, Object> localVariables;\n\t/**\n\t * Set containing the names of those variables whose value has been set or\n\t * cleared by the SafeOutputContext.\n\t */\n\tprivate Set<String> localModifiedVariables;\n\n\t/**\n\t * Constructs a SafeContext whose input context is <code>inputContext</code>\n\t * .\n\t * \n\t * @param inputContext\n\t *            the input context.\n\t */\n\tpublic SafeContext(IContext inputContext) {\n\t\tthis.inputContext = inputContext;\n\t\tthis.localVariables = new Hashtable<String, Object>();\n\t\tthis.cleared = false;\n\t\tthis.localModifiedVariables = new HashSet<String>();\n\t}\n\n\t/**\n\t * Retrieves the value of a variable.If the variable has not been modified\n\t * by the SafeContext, its value is retrieved from the input context.\n\t * However, if the variable has been modified (either cleared or set), the\n\t * value will be retrieved from the SafeContext.\n\t * \n\t * @param name\n\t *            the name of the variable to retrieve.\n\t * \n\t * @return the value of a variable whose name is <code>name</code>, or null\n\t *         if it does not exist.\n\t * \n\t * @see jbt.execution.core.IContext#getVariable(java.lang.String)\n\t */\n\tpublic Object getVariable(String name) {\n\t\tif (this.localModifiedVariables.contains(name) || this.cleared) {\n\t\t\treturn this.localVariables.get(name);\n\t\t} else {\n\t\t\tObject variable = this.localVariables.get(name);\n\t\t\tif (variable != null) {\n\t\t\t\treturn variable;\n\t\t\t} else {\n\t\t\t\treturn this.inputContext.getVariable(name);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Sets the value of a variable. Its value is not written into the input\n\t * context. Instead, its value is stored into a local variable managed by\n\t * the SafeContext.\n\t * \n\t * @param name\n\t *            the name of the variable.\n\t * @param value\n\t *            the value for the variable.\n\t * @return true if a variable with the same name already existed, and false\n\t *         otherwise.\n\t * \n\t * @see jbt.execution.core.IContext#setVariable(java.lang.String,\n\t *      java.lang.Object)\n\t */\n\tpublic boolean setVariable(String name, Object value) {\n\t\tif (!this.localModifiedVariables.contains(name)) {\n\t\t\tthis.localModifiedVariables.add(name);\n\t\t}\n\t\tif (value == null) {\n\t\t\treturn this.localVariables.remove(name) == null ? false : true;\n\t\t}\n\t\treturn this.localVariables.put(name, value) == null ? false : true;\n\t}\n\n\t/**\n\t * Clears the context. Variables are not removed from the input context, but\n\t * from the set of local variables managed by the SafeContext.\n\t * \n\t * @see jbt.execution.core.IContext#clear()\n\t */\n\tpublic void clear() {\n\t\tthis.localVariables.clear();\n\t\tthis.cleared = true;\n\t}\n\n\t/**\n\t * Clears a variable of the context. If it not removed from the input\n\t * context, but from the set of local variables managed by the SafeContext.\n\t * \n\t * @param name\n\t *            the name of the variable to clear.\n\t * @return true if a variable was actually cleared, and false in case it did\n\t *         not exist.\n\t * \n\t * @see jbt.execution.core.IContext#clearVariable(java.lang.String)\n\t */\n\tpublic boolean clearVariable(String name) {\n\t\tif (!this.localModifiedVariables.contains(name)) {\n\t\t\tthis.localModifiedVariables.add(name);\n\t\t}\n\t\treturn this.localVariables.remove(name) == null ? false : true;\n\t}\n\n\t/**\n\t * Returns the behaviour tree of a particular name, or null in case it\n\t * cannot be found. The behaviour tree is extracted from the input context\n\t * passed at construction time.\n\t * \n\t * @param the\n\t *            name of the behaviour tree to retrieve.\n\t * @return the behaviour tree, or null if it cannot be found.\n\t * \n\t * @see jbt.execution.core.IContext#getBT(java.lang.String)\n\t */\n\tpublic ModelTask getBT(String name) {\n\t\treturn this.inputContext.getBT(name);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/context/SafeOutputContext.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.context;\n\nimport java.util.HashSet;\nimport java.util.Hashtable;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\n\nimport jbt.execution.core.IContext;\nimport jbt.model.core.ModelTask;\n\n/**\n * The SafeOutputContext represents a context that can be used to safely\n * controls modifications in another context (the <i>input context</i>).\n * <p>\n * A SafeOutputContext contains an IContext (the <i>input context</i>), and a\n * list of <i>output variables</i>. These are the variables that can be written\n * into the input context. The rest of variables are stored locally in the\n * SafeOutputContext.\n * <p>\n * Thus, when the SafeOutputContext sets the value of a variable, it will\n * normally set its value in a local variable. However, if the variable is one\n * of the list of output variables, the value will be set in the input context.\n * <p>\n * When retrieving variables, a variable in the list of output variables will\n * always be retrieved from the input context. A variable that is not in the\n * list of output variables will also be retrieved from the input context;\n * however, when such variable is modified (either its value is changed or\n * cleared), the value will be retrieved from the SafeOutputContext (that is,\n * from the moment a variable that is not in the list of output variables is\n * modified, it is managed locally).\n * <p>\n * With respect to clearing variables, output variables are always cleared in\n * the input context. However, since only output variables can be modified in\n * the input context, any other variable will be cleared in the\n * SafeOutputContext.\n * <p>\n * The SafeOutputContext can be used in situations where an entity must use a\n * context (the input context) in a soft-read-only mode. By using the\n * SafeOutputContext, such entity will only be able to modify the output\n * variables in the input context. On the other hand, it will interact with the\n * SafeOutputContext in just the same way it would with the input context.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class SafeOutputContext implements IContext {\n\t/**\n\t * The original input context which the SafeOutputContext is based on.\n\t */\n\tprivate IContext inputContext;\n\t/**\n\t * The list of output variables. These variables can be written into the\n\t * {@link #inputContext}, unlike the rest, that are stored in\n\t * {@link #localVariables}.\n\t */\n\tprivate List<String> outputVariables;\n\t/**\n\t * Set containing the names of those non-output variables whose value has\n\t * been set or cleared by the SafeOutputContext.\n\t */\n\tprivate Set<String> localModifiedVariables;\n\t/**\n\t * Flag that tells whether the SafeOutputContext has been cleared.\n\t */\n\tprivate boolean cleared;\n\t/**\n\t * The set of local variables managed by the SafeOutputContext.\n\t */\n\tprivate Map<String, Object> localVariables;\n\n\t/**\n\t * Constructs a SafeOutputContext whose input context is\n\t * <code>inputContext</code> and whose list of output variables is\n\t * <code>outputVariables</code>.\n\t * \n\t * @param inputContext\n\t *            the input context.\n\t * @param outputVariables\n\t *            the list of output variables.\n\t */\n\tpublic SafeOutputContext(IContext inputContext, List<String> outputVariables) {\n\t\tthis.inputContext = inputContext;\n\t\tthis.outputVariables = outputVariables;\n\t\tthis.localVariables = new Hashtable<String, Object>();\n\t\tthis.localModifiedVariables = new HashSet<String>();\n\t\tthis.cleared = false;\n\t}\n\n\t/**\n\t * Retrieves the value of a variable. If it is an output variable, its value\n\t * is retrieved from the input context. Otherwise, if the variable has not\n\t * been modified by the SafeOutputContext, its value is also retrieved from\n\t * the input context. However, if the variable has been modified (either\n\t * cleared or set), the value will be retrieved from the SafeOutputContext.\n\t * \n\t * @param name\n\t *            the name of the variable to retrieve.\n\t * \n\t * @return the value of a variable whose name is <code>name</code>, or null\n\t *         if it does not exist.\n\t * \n\t * @see jbt.execution.core.IContext#getVariable(java.lang.String)\n\t */\n\tpublic Object getVariable(String name) {\n\t\tif (this.outputVariables.contains(name)) {\n\t\t\treturn this.inputContext.getVariable(name);\n\t\t} else {\n\t\t\tif (this.localModifiedVariables.contains(name) || this.cleared) {\n\t\t\t\treturn this.localVariables.get(name);\n\t\t\t} else {\n\t\t\t\tObject variable = this.localVariables.get(name);\n\t\t\t\tif (variable != null) {\n\t\t\t\t\treturn variable;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.inputContext.getVariable(name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Sets the value of a variable. If it is an output variable, its value is\n\t * written into the input context. Otherwise, its value will be stored into\n\t * a local variable managed by the SafeOutputContext.\n\t * \n\t * @param name\n\t *            the name of the variable.\n\t * @param value\n\t *            the value for the variable.\n\t * @return true if a variable with the same name already existed, and false\n\t *         otherwise.\n\t * \n\t * @see jbt.execution.core.IContext#setVariable(java.lang.String,\n\t *      java.lang.Object)\n\t */\n\tpublic boolean setVariable(String name, Object value) {\n\t\tif (this.outputVariables.contains(name)) {\n\t\t\treturn this.inputContext.setVariable(name, value);\n\t\t} else {\n\t\t\tif (!this.localModifiedVariables.contains(name)) {\n\t\t\t\tthis.localModifiedVariables.add(name);\n\t\t\t}\n\t\t\tif (value == null) {\n\t\t\t\treturn this.localVariables.remove(name) == null ? false : true;\n\t\t\t}\n\t\t\treturn this.localVariables.put(name, value) == null ? false : true;\n\t\t}\n\t}\n\n\t/**\n\t * Clears the context. Output variables are cleared in the input context.\n\t * The rest are removed from the set of local variables managed by the\n\t * SafeOutputContext.\n\t * \n\t * @see jbt.execution.core.IContext#clear()\n\t */\n\tpublic void clear() {\n\t\tthis.localVariables.clear();\n\t\tfor (String outputVariable : this.outputVariables) {\n\t\t\tthis.inputContext.clearVariable(outputVariable);\n\t\t}\n\t\tthis.cleared = true;\n\t}\n\n\t/**\n\t * Clears a variable of the context. If it is an output variable, the value\n\t * is cleared in the input context. Otherwise, the variable is removed from\n\t * the set of local variables managed by the SafeOutputContext.\n\t * \n\t * @param name\n\t *            the name of the variable to clear.\n\t * @return true if a variable was actually cleared, and false in case it did\n\t *         not exist.\n\t * \n\t * @see jbt.execution.core.IContext#clearVariable(java.lang.String)\n\t */\n\tpublic boolean clearVariable(String name) {\n\t\tif (this.outputVariables.contains(name)) {\n\t\t\treturn this.inputContext.clearVariable(name);\n\t\t} else {\n\t\t\tif (!this.localModifiedVariables.contains(name)) {\n\t\t\t\tthis.localModifiedVariables.add(name);\n\t\t\t}\n\t\t\treturn this.localVariables.remove(name) == null ? false : true;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the behaviour tree of a particular name, or null in case it\n\t * cannot be found. The behaviour tree is extracted from the input context\n\t * passed at construction time.\n\t * \n\t * @param the\n\t *            name of the behaviour tree to retrieve.\n\t * @return the behaviour tree, or null if it cannot be found.\n\t * \n\t * @see jbt.execution.core.IContext#getBT(java.lang.String)\n\t */\n\tpublic ModelTask getBT(String name) {\n\t\treturn this.inputContext.getBT(name);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/BTExecutor.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport java.util.Hashtable;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\n\nimport jbt.execution.context.BasicContext;\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.execution.task.decorator.ExecutionInterrupter;\nimport jbt.model.core.ModelTask;\nimport jbt.model.core.ModelTask.Position;\nimport jbt.model.task.decorator.ModelInterrupter;\n\n/**\n * BTExecutor is the implementation of the IBTExecutor interface.\n * <p>\n * BTs are conceptually modeled by a hierarchy of interconnected ModelTask objects. A BT is\n * represented by the root of the tree, which is a single ModelTask object.\n * <p>\n * Therefore, in order to run a BT, a BTExecutor only needs the root task of the tree (a ModelTask\n * object), and the context (IContext) that will be used by the tree. Keep in mind that a BT is\n * executed within a context that contains information about the game that leaf tasks (actions and\n * conditions) and guards (ModelTask) may need in order to run.\n * <p>\n * The internal implementation of the BTExecutor is based on using, for each ModelTask of the BT, an\n * ExecutionTask obtained by calling the {@link ModelTask#createExecutor(BTExecutor, ExecutionTask)}\n * method. The most important feature of the BTExecutor, however, is that it uses a list of\n * <i>tickable</i> nodes. When {@link #tick()} is called, not all the nodes of the tree are ticked,\n * but only those that are currently relevant to the execution of the tree. By doing so, running the\n * tree is a much more efficient process, since only the nodes that can make the tree evolve receive\n * CPU time.\n * <p>\n * The BTExecutor is also in charge of storing the permanent state of tasks (see {@link ITaskState}\n * and {@link ExecutionTask#storeState()}). For each BT there is only one BTExecutor that actually\n * runs it. Therefore, the BTExecutor can be used as the repository for storing the state of the\n * tasks of the tree.\n * \n * @see ModelTask\n * @see ExecutionTask\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTExecutor implements IBTExecutor {\n\t/** The root task of the BT this executor is running. */\n\tprivate ModelTask modelBT;\n\t/** The ExecutionTask associated to the root ModelTask. */\n\tprivate ExecutionTask executionBT;\n\t/** List of tickable tasks. */\n\tprivate List<ExecutionTask> tickableTasks;\n\t/** List of open tasks. */\n\tprivate List<ExecutionTask> openTasks;\n\t/** The context that will be passed to the root task. */\n\tprivate IContext context;\n\t/**\n\t * Boolean telling whether this BTExecutor has been ticked ( {@link #tick()} ) before.\n\t */\n\tprivate boolean firstTimeTicked = true;\n\t/**\n\t * List of the tasks that must be inserted into the list of tickable nodes.\n\t */\n\tprivate List<ExecutionTask> currentTickableInsertions;\n\t/**\n\t * List of the tasks that must be removed from the list of tickable nodes.\n\t */\n\t/*\n\t * TODO: improve the way requests for insertions and removals are handled. Currently simple\n\t * Lists are used to manage them, but in case there were many requests, this process would not\n\t * be very efficient.\n\t */\n\tprivate List<ExecutionTask> currentTickableRemovals;\n\t/**\n\t * List of the tasks that must be inserted into the list of open nodes.\n\t */\n\tprivate List<ExecutionTask> currentOpenInsertions;\n\t/**\n\t * List of the tasks that must be removed from the list of open nodes.\n\t */\n\tprivate List<ExecutionTask> currentOpenRemovals;\n\t/**\n\t * List of all the ExecutionInterrupter currently active in the behaviour tree. They are indexed\n\t * by their ModelInterrupter in the conceptual tree.\n\t * <p>\n\t * This list is used by ExecutionPerformInterruption, which must have a way of knowing what\n\t * ExecutionInterrupter it is interrupting.\n\t */\n\tprivate Map<ModelInterrupter, ExecutionInterrupter> interrupters;\n\t/**\n\t * States of the tasks of the tree that is being run by this BTExecutor. States are indexed by\n\t * Position. These are the positions of the ExecutionTask in the execution tree. These positions\n\t * are unique (they do not necessarily match the position of the corresponding ModelTask), so\n\t * each node in the execution tree can be unambiguously referenced by such position. Note that\n\t * this Map does not store the states of the nodes of the guards of the tree that is being run.\n\t */\n\tprivate Map<Position, ITaskState> tasksStates;\n\n\t/**\n\t * Creates a BTExecutor that handles the execution of a behaviour tree. The behaviour tree is\n\t * represented by a ModelTask (the root of the tree).\n\t * <p>\n\t * A context for the tree must be provided. This context is passed to the root of the tree, and,\n\t * in general, it will be shared by all the nodes in the tree (it will be passed down the\n\t * hierarchy of the tree). Note however that, depending on the semantics of the tree itself,\n\t * some nodes may not use this context.\n\t * \n\t * @param modelBT\n\t *            the root of the behaviour tree to run.\n\t * @param context\n\t *            the initial context for the tree.\n\t */\n\tpublic BTExecutor(ModelTask modelBT, IContext context) {\n\t\tif (modelBT == null) {\n\t\t\tthrow new IllegalArgumentException(\"The input ModelTask cannot be null\");\n\t\t}\n\n\t\tif (context == null) {\n\t\t\tthrow new IllegalArgumentException(\"The input IContext cannot be null\");\n\t\t}\n\n\t\tthis.modelBT = modelBT;\n\t\tthis.modelBT.computePositions();\n\t\tthis.context = context;\n\t\tthis.tickableTasks = new LinkedList<ExecutionTask>();\n\t\tthis.openTasks = new LinkedList<ExecutionTask>();\n\t\tthis.currentOpenInsertions = new LinkedList<ExecutionTask>();\n\t\tthis.currentOpenRemovals = new LinkedList<ExecutionTask>();\n\t\tthis.currentTickableInsertions = new LinkedList<ExecutionTask>();\n\t\tthis.currentTickableRemovals = new LinkedList<ExecutionTask>();\n\t\tthis.interrupters = new Hashtable<ModelInterrupter, ExecutionInterrupter>();\n\t\tthis.tasksStates = new Hashtable<ModelTask.Position, ITaskState>();\n\t}\n\n\t/**\n\t * Creates a BTExecutor that handles the execution of a behaviour tree. The behaviour tree is\n\t * represented by a ModelTask (the root of the tree).\n\t * <p>\n\t * A new empty context for the tree is created. This context is passed to the root of the tree,\n\t * and, in general, it will be shared by all the nodes in the tree (it will be passed down the\n\t * hierarchy of the tree). Note however that, depending on the semantics of the tree itself,\n\t * some nodes may not use the context context.\n\t * \n\t * @param modelBT\n\t *            the root of the behaviour tree to run.\n\t */\n\tpublic BTExecutor(ModelTask modelBT) {\n\t\tif (modelBT == null) {\n\t\t\tthrow new IllegalArgumentException(\"The input ModelTask cannot be null\");\n\t\t}\n\n\t\tthis.modelBT = modelBT;\n\t\tthis.modelBT.computePositions();\n\t\tthis.context = new BasicContext();\n\t\tthis.tickableTasks = new LinkedList<ExecutionTask>();\n\t\tthis.openTasks = new LinkedList<ExecutionTask>();\n\t\tthis.currentOpenInsertions = new LinkedList<ExecutionTask>();\n\t\tthis.currentOpenRemovals = new LinkedList<ExecutionTask>();\n\t\tthis.currentTickableInsertions = new LinkedList<ExecutionTask>();\n\t\tthis.currentTickableRemovals = new LinkedList<ExecutionTask>();\n\t\tthis.interrupters = new Hashtable<ModelInterrupter, ExecutionInterrupter>();\n\t\tthis.tasksStates = new Hashtable<ModelTask.Position, ITaskState>();\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.IBTExecutor#tick()\n\t */\n\tpublic void tick() {\n\t\t/*\n\t\t * The ticking algorithm works as follows:\n\t\t * \n\t\t * If it is the very first time that this method is called, an ExecutionTask is created from\n\t\t * the root ModelTask (that is, the root of the behaviour tree that this BTExecutor is going\n\t\t * to run). Then, that task is spawned.\n\t\t * \n\t\t * From then on, tick() will just call tick() on all the ExecutionTasks in the list of\n\t\t * tickable tasks.\n\t\t * \n\t\t * It is important to note that insertions and removals from the list of tickable and open\n\t\t * tasks are processed at the very beginning and at the very end of this method, but not\n\t\t * while it is ticking the current list of tickable tasks.\n\t\t */\n\t\tStatus currentStatus = this.getStatus();\n\n\t\t/* We only tick if the tree has not finished yet or if it has not started running. */\n\t\tif (currentStatus == Status.RUNNING || currentStatus == Status.UNINITIALIZED) {\n\t\t\tprocessInsertionsAndRemovals();\n\n\t\t\tif (this.firstTimeTicked) {\n\t\t\t\tthis.executionBT = this.modelBT.createExecutor(this, null);\n\t\t\t\tthis.executionBT.spawn(this.context);\n\t\t\t\tthis.firstTimeTicked = false;\n\t\t\t} else {\n\t\t\t\tfor (ExecutionTask t : tickableTasks) {\n\t\t\t\t\tt.tick();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tprocessInsertionsAndRemovals();\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.IBTExecutor#terminate()\n\t */\n\tpublic void terminate() {\n\t\tif (this.executionBT != null) {\n\t\t\tthis.executionBT.terminate();\n\t\t}\n\t}\n\n\t/**\n\t * Returns the ExecutionInterrupter that is currently active and registered in the BTExecutor (\n\t * {@link #registerInterrupter(ExecutionInterrupter)}) whose associated ModelInterrupter is\n\t * <code>modelInterrupter</code>. Returns null if there is no such an ExecutionInterrupter.\n\t * \n\t * @param modelInterrupter\n\t *            the ModelInterrupter associated to the ExecutionInterrupter to retrieve.\n\t * @return the ExecutionInterrupter whose associated ModelInterrupter is\n\t *         <code>modelInterrupter</code>.\n\t */\n\tpublic ExecutionInterrupter getExecutionInterrupter(ModelInterrupter modelInterrupter) {\n\t\treturn this.interrupters.get(modelInterrupter);\n\t}\n\n\t/**\n\t * Registers an ExecutionInterrupter with this BTExecutor.\n\t * \n\t * @param interrupter\n\t *            the ExecutionInterrupter to register.\n\t */\n\tpublic void registerInterrupter(ExecutionInterrupter interrupter) {\n\t\tthis.interrupters.put((ModelInterrupter) interrupter.getModelTask(), interrupter);\n\t}\n\n\t/**\n\t * Unregisters an ExecutionInterrupter from this BTExecutor.\n\t * \n\t * @param interrupter\n\t *            the ExecutionInterrupter to unregister.\n\t */\n\tpublic void unregisterInterrupter(ExecutionInterrupter interrupter) {\n\t\tthis.interrupters.remove(interrupter.getModelTask());\n\t}\n\n\t/**\n\t * Enum defining the relevant lists that the BTExecutor handles.\n\t * \n\t * <ul>\n\t * <li> {@link #OPEN}: the list of open (active) nodes.\n\t * <li> {@link #TICKABLE}: the list of tickable nodes, that is, those that receive ticks every\n\t * time {@link BTExecutor#tick()} is called.\n\t * </ul>\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static enum BTExecutorList {\n\t\t/** Enum for the list of open nodes. */\n\t\tOPEN, /** Enum for the list of tickable nodes. */\n\t\tTICKABLE\n\t};\n\n\t/**\n\t * Method used to request the BTExecutor to insert an ExecutionTask into one of the list that it\n\t * handles. The insertion is not performed right away, but delayed until:\n\t * \n\t * <ul>\n\t * <li>Either the current game AI cycle (call to {@link #tick()}) finishes. This happens if the\n\t * insertion is requested in the middle of an AI cycle, that is, if <code>tick()</code> is still\n\t * running.\n\t * <li>Or the next AI cycle starts. This happens if the insertion is requested when the\n\t * BTExecutor is not ticking the underlying BT. In this case, the next time <code>tick()</code>\n\t * is called, the insertion will be processed just before the BT is actually ticked.\n\t * </ul>\n\t * \n\t * @param listType\n\t *            the type of the list that the task will be inserted into.\n\t * @param t\n\t *            the task that wants to be inserted into the list of type <code>listType</code>.\n\t */\n\tpublic void requestInsertionIntoList(BTExecutorList listType, ExecutionTask t) {\n\t\tif (listType == BTExecutorList.OPEN) {\n\t\t\tif (!this.currentOpenInsertions.contains(t)) {\n\t\t\t\tthis.currentOpenInsertions.add(t);\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this.currentTickableInsertions.contains(t)) {\n\t\t\t\tthis.currentTickableInsertions.add(t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Method used to request the BTExecutor to remove an ExecutionTask from one of the list that\n\t * the BTExecutor handles. The removal is not performed right away, but delayed until:\n\t * \n\t * <ul>\n\t * <li>Either the current game AI cycle (call to {@link #tick()}) finishes. This happens if the\n\t * removal is requested in the middle of an AI cycle, that is, if <code>tick()</code> is still\n\t * running.\n\t * <li>Or the next AI cycle starts. This happens if the removal is requested when the BTExecutor\n\t * is not ticking the underlying BT. In this case, the next time <code>tick()</code> is called,\n\t * the removal will be processed just before the BT is actually ticked.\n\t * </ul>\n\t * \n\t * @param listType\n\t *            the type of the list from which the task will be removed.\n\t * @param t\n\t *            the task that wants to be removed from the list of type <code>listType</code>.\n\t */\n\tpublic void requestRemovalFromList(BTExecutorList listType, ExecutionTask t) {\n\t\tif (listType == BTExecutorList.OPEN) {\n\t\t\tif (!this.currentOpenRemovals.contains(t)) {\n\t\t\t\tthis.currentOpenRemovals.add(t);\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this.currentTickableRemovals.contains(t)) {\n\t\t\t\tthis.currentTickableRemovals.add(t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Cancels a previous request of insertion into one of the lists that the BTExecutor handles. If\n\t * no such insertion request was made, this method does nothing.\n\t * \n\t * @param listType\n\t *            the list from which the insertion request will be canceled.\n\t * @param t\n\t *            the task whose insertion will be canceled.\n\t */\n\tpublic void cancelInsertionRequest(BTExecutorList listType, ExecutionTask t) {\n\t\tif (listType == BTExecutorList.OPEN) {\n\t\t\tthis.currentOpenInsertions.remove(t);\n\t\t} else {\n\t\t\tthis.currentTickableInsertions.remove(t);\n\t\t}\n\t}\n\n\t/**\n\t * Cancels a previous request of removal from one of the lists that the BTExecutor handles. If\n\t * no such removal request was made, this method does nothing.\n\t * \n\t * @param listType\n\t *            the list from which the removal request will be canceled.\n\t * @param t\n\t *            the task whose removal will be canceled.\n\t */\n\tpublic void cancelRemovalRequest(BTExecutorList listType, ExecutionTask t) {\n\t\tif (listType == BTExecutorList.OPEN) {\n\t\t\tthis.currentOpenRemovals.remove(t);\n\t\t} else {\n\t\t\tthis.currentTickableRemovals.remove(t);\n\t\t}\n\t}\n\n\t/**\n\t * Method that processes the insertions and removals into and from the lists of tickable and\n\t * open nodes that have been previously requested via the <code>requestXXX</code> methods.\n\t * <p>\n\t * After calling this method, all pending removals and insertions are processed, so no new\n\t * insertion and removal will be carried out unless new ones are requested.\n\t */\n\tprivate void processInsertionsAndRemovals() {\n\t\t/*\n\t\t * Process insertions and removals.\n\t\t */\n\t\tfor (ExecutionTask t : this.currentTickableInsertions) {\n\t\t\tthis.tickableTasks.add(t);\n\t\t}\n\t\tfor (ExecutionTask t : this.currentTickableRemovals) {\n\t\t\tthis.tickableTasks.remove(t);\n\t\t}\n\t\tfor (ExecutionTask t : this.currentOpenInsertions) {\n\t\t\tthis.openTasks.add(t);\n\t\t}\n\t\tfor (ExecutionTask t : this.currentOpenRemovals) {\n\t\t\tthis.openTasks.remove(t);\n\t\t}\n\t\t/*\n\t\t * Clear the lists of tasks to insert and remove.\n\t\t */\n\t\tthis.currentOpenInsertions.clear();\n\t\tthis.currentOpenRemovals.clear();\n\t\tthis.currentTickableInsertions.clear();\n\t\tthis.currentTickableRemovals.clear();\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.IBTExecutor#getBehaviourTree()\n\t */\n\tpublic ModelTask getBehaviourTree() {\n\t\treturn this.modelBT;\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.IBTExecutor#getStatus()\n\t */\n\tpublic Status getStatus() {\n\t\tif (this.executionBT == null) {\n\t\t\treturn Status.UNINITIALIZED;\n\t\t} else {\n\t\t\treturn this.executionBT.getStatus();\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.IBTExecutor#getRootContext()\n\t */\n\tpublic IContext getRootContext() {\n\t\treturn this.context;\n\t}\n\n\t/**\n\t * Sets the permanent state of a given task. The task is identified by the position it occupies\n\t * in the execution behaviour tree, which unambiguously identifies it.\n\t * \n\t * @param taskPosition\n\t *            the position of the task whose state must be stored.\n\t * @param state\n\t *            the state of the task, or null if it should be cleared.\n\t * @return true if there was a previous state for this task in the BTExecutor, or false\n\t *         otherwise.\n\t */\n\tpublic boolean setTaskState(Position taskPosition, ITaskState state) {\n\t\tif (state == null) {\n\t\t\treturn this.tasksStates.remove(taskPosition) == null ? false : true;\n\t\t}\n\t\treturn this.tasksStates.put(taskPosition, state) == null ? false : true;\n\t}\n\n\t/**\n\t * Returns the permanent state of a task. The task is identified by the position it occupies in\n\t * the execution behaviour tree, which unambiguously identifies it.\n\t * \n\t * @param taskPosition\n\t *            the position of the task whose state must be retrieved.\n\t * @return the state of the task, or null if there is no state stored in the BTExecutor for the\n\t *         task.\n\t */\n\tpublic ITaskState getTaskState(Position taskPosition) {\n\t\treturn this.tasksStates.get(taskPosition);\n\t}\n\n\t/**\n\t * Copies the set of all tasks' states stored in <code>executor</code> into this BTExecutor.\n\t * <p>\n\t * <b>After calling this method, the set of all tasks' states is shared by both BTExecutor\n\t * objects (<code>executor</code> and <code>this</code>), so if one modifies it, the other will\n\t * notice the change.</b>\n\t */\n\tpublic void copyTasksStates(BTExecutor executor) {\n\t\tthis.tasksStates = executor.tasksStates;\n\t}\n\n\t/**\n\t * Clears the permanent state of a task. The task is identified by the position it occupies in\n\t * the execution behaviour tree, which unambiguously identifies it.\n\t * \n\t * @param taskPosition\n\t *            the position of the task whose state must be cleared.\n\t * @return true if the BTExecutor contained the state of the task before calling this method, or\n\t *         false otherwise.\n\t */\n\tpublic boolean clearTaskState(Position taskPosition) {\n\t\treturn this.tasksStates.remove(taskPosition) == null ? false : true;\n\t}\n\n\t/**\n\t * \n\t * @see java.lang.Object#toString()\n\t */\n\tpublic String toString() {\n\t\treturn \"[Root: \" + this.modelBT.getClass().getSimpleName() + \", Status: \"\n\t\t\t\t+ this.getStatus() + \"]\";\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/BTExecutorFactory.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport jbt.model.core.ModelTask;\n\n/**\n * The BTExecutorFactory implements the simple factory pattern, and allows\n * clients of the framework to create instances of {@link IBTExecutor} objects\n * that will run specific behaviour trees.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTExecutorFactory {\n\t/**\n\t * Creates an IBTExecutor that is able to run a specific behaviour tree. The\n\t * input context is also specified.\n\t * \n\t * @param treeToRun\n\t *            the behaviour tree that the returned IBTExecutor will run,\n\t * @param context\n\t *            the input context to be used by the behaviour tree.\n\t * @return an IBTExecutor to run the tree <code>treeToRun</code>.\n\t */\n\tpublic static IBTExecutor createBTExecutor(ModelTask treeToRun,\n\t\t\tIContext context) {\n\t\treturn new BTExecutor(treeToRun, context);\n\t}\n\n\t/**\n\t * Creates an IBTExecutor that is able to run a specific behaviour tree. A\n\t * new empty context is created for the tree.\n\t * \n\t * @param treeToRun\n\t *            the behaviour tree that the returned IBTExecutor will run,\n\t * @return an IBTExecutor to run the tree <code>treeToRun</code>.\n\t */\n\tpublic static IBTExecutor createBTExecutor(ModelTask treeToRun) {\n\t\treturn new BTExecutor(treeToRun);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/BTLibraryFactory.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport java.util.Iterator;\nimport java.util.List;\n\nimport jbt.execution.context.GenericBTLibrary;\nimport jbt.model.core.ModelTask;\n\n/**\n * The BTLibraryFactory implements the simple factory pattern, and allows\n * clients of the framework to create instances of {@link IBTLibrary} composed\n * of behaviour trees.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTLibraryFactory {\n\t/**\n\t * Creates a BT library that contains all the BTs contained in the libraries\n\t * of <code>libraries</code>. If several trees are referenced by the same\n\t * name, only the last one (according to its order in the input libraries)\n\t * will remain.\n\t * \n\t * @param libraries\n\t *            the list with all the libraries whose BTs will contain the\n\t *            returned BT library.\n\t * @return a BT library that contains all the BTs contained in the libraries\n\t *         of <code>libraries</code>.\n\t */\n\tpublic static IBTLibrary createBTLibrary(List<IBTLibrary> libraries) {\n\t\tGenericBTLibrary result = new GenericBTLibrary();\n\n\t\tfor (IBTLibrary library : libraries) {\n\t\t\tresult.addBTLibrary(library);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates a BT library that contains all the behaviour trees in\n\t * <code>behaviourTrees</code>. The name of the trees are specified in\n\t * <code>names</code>, so, for instance, the i-th element in\n\t * <code>names</code> represents the name of the i-th tree in\n\t * <code>behaviourTrees</code>. If several trees are referenced by the same\n\t * name, only the last one (according to its order in the input lists) will\n\t * remain.\n\t * \n\t * @param behaviourTrees\n\t *            the list with the trees that the BT library will contain.\n\t * @param names\n\t *            the list with the names of the trees.\n\t * @return a BT library that contains all the behaviour trees in the list\n\t *         <code>behaviourTrees</code>.\n\t */\n\tpublic static IBTLibrary createBTLibrary(List<ModelTask> behaviourTrees, List<String> names) {\n\t\tGenericBTLibrary result = new GenericBTLibrary();\n\n\t\tIterator<ModelTask> treesIterator = behaviourTrees.iterator();\n\t\tIterator<String> namesIterator = names.iterator();\n\n\t\twhile (treesIterator.hasNext()) {\n\t\t\tresult.addBT(namesIterator.next(), treesIterator.next());\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/ContextFactory.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport java.util.Iterator;\nimport java.util.List;\n\nimport jbt.execution.context.BasicContext;\nimport jbt.model.core.ModelTask;\n\n/**\n * The ContextFactory implements the simple factory pattern, and allows clients\n * of the framework to create instances of {@link IContext} objects that can be\n * used when running behaviour trees.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ContextFactory {\n\t/**\n\t * Creates a new empty context (with no variables) that contains all the\n\t * behaviour trees specified in <code>library</code>.\n\t * \n\t * @param library\n\t *            the set of behaviour trees that the returned IContext will\n\t *            contain.\n\t * @return a new empty context that contains all the behaviour trees\n\t *         specified in <code>library</code>.\n\t */\n\tpublic static IContext createContext(IBTLibrary library) {\n\t\tBasicContext result = new BasicContext();\n\t\tresult.addBTLibrary(library);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates a new empty context (with no variables) that contains all the\n\t * behaviour trees in the libraries <code>libraries</code>.\n\t * \n\t * @param libraries\n\t *            the list of libraries whose behaviour trees this context will\n\t *            contain.\n\t * @return a new empty context that contains all the behaviour trees in the\n\t *         libraries <code>libraries</code>.\n\t */\n\tpublic static IContext createContext(List<IBTLibrary> libraries) {\n\t\tBasicContext result = new BasicContext();\n\n\t\tfor (IBTLibrary library : libraries) {\n\t\t\tresult.addBTLibrary(library);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates a new empty context (with no variables in it) that contains all\n\t * the behaviour trees in <code>behaviourTrees</code>. The name of the trees\n\t * are specified in <code>names</code>, so, for instance, the i-th element\n\t * in <code>names</code> represents the name of the i-th tree in\n\t * <code>behaviourTrees</code>.\n\t * \n\t * @param behaviourTrees\n\t *            the list with the trees that the context will contain.\n\t * @param names\n\t *            the list with the names of the trees.\n\t * @return a new empty context that contains all the behaviour trees in the\n\t *         list <code>behaviourTrees</code>.\n\t */\n\tpublic static IContext createContext(List<ModelTask> behaviourTrees, List<String> names) {\n\t\tBasicContext result = new BasicContext();\n\n\t\tIterator<ModelTask> treesIterator = behaviourTrees.iterator();\n\t\tIterator<String> namesIterator = names.iterator();\n\n\t\twhile (treesIterator.hasNext()) {\n\t\t\tresult.addBT(namesIterator.next(), treesIterator.next());\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates a new empty context (with no variables in it).\n\t * \n\t * @return a new empty context.\n\t */\n\tpublic static IContext createContext() {\n\t\treturn new BasicContext();\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/ExecutionTask.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport jbt.exception.IllegalReturnStatusException;\nimport jbt.exception.NotTickableException;\nimport jbt.exception.SpawnException;\nimport jbt.exception.TickException;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.event.ITaskListener;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.core.ModelTask.Position;\n\n/**\n * A behaviour tree is conceptually modeled by the ModelTask class. A ModelTask,\n * however, does not know how to run, since it is just a conceptual abstraction.\n * <p>\n * The ExecutionTask represents a tasks that knows how to run a particular\n * ModelTask. For each type of ModelTask, such as ModelSequence or\n * ModelParallel, there is an ExecutionTask that knows how to run it (e.g.,\n * ExecutionSequence and ExecutionParallel).\n * <p>\n * ExecutionTask works together with the BTExecutor class to run its\n * corresponding ModelTask (an ExecutionTask does have a managing BTExecutor).\n * An ExecutionTask defines several methods for the different stages it goes\n * through.\n * <ul>\n * <li>{@link #spawn(IContext)} is initially called when the task needs to\n * create the hierarchical structure of ExecutionTask objects that, as a whole,\n * are able to run the parent ExecutionTask.\n * <li>{@link #tick()} is used from then on, in order to give the ExecutionTask\n * some time to think and evolve according to its semantics.\n * <li>{@link #terminate()} is used when the task needs to be abruptly\n * terminated.\n * </ul>\n * \n * The three methods above depend on the implementation that each subclass makes\n * of the {@link #internalSpawn()}, {@link #internalTick()} and\n * {@link #internalTerminate()} methods respectively. These three protected\n * abstract methods are in charge of carrying out the actual spawning, ticking\n * and termination processes. It has to be noted that it is very important the\n * way that the ExecutionTask class interacts with other ExecutionTask classes\n * as well as with the BTExecutor. With respect to the BTExecutor, the\n * ExecutionTask asks to be inserted and removed from both the lists of open and\n * tickable nodes of the BTExecutor. Subclasses only have to worry about\n * requesting to be inserted into the list of tickable nodes. Other types of\n * insertions and removals are automatically handled by the ExecutionTask class.\n * \n * @see ModelTask\n * @see BTExecutor\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ExecutionTask implements ITaskListener {\n\t/** The ModelTask this ExecutionTask is running. */\n\tprivate ModelTask modelTask;\n\t/** The BTExecutor that is managing this ExecutionTask. */\n\tprivate BTExecutor executor;\n\t/** The context of the task. */\n\tprivate IContext context;\n\t/**\n\t * List of all the listeners that are listening to TaskEvent from this task.\n\t */\n\tprivate List<ITaskListener> listeners;\n\t/** Current status of the task. */\n\tprivate Status status;\n\t/** Flag telling whether the task can be spawned or not. */\n\tprivate boolean spawnable;\n\t/** Flag indicating whether the task can ticked or not. */\n\tprivate boolean tickable;\n\t/** Flag indicating whether the task has been terminated or not. */\n\tprivate boolean terminated;\n\t/** The parent ExecutionTask. null if this is the root of the tree. */\n\tprivate ExecutionTask parent;\n\t/**\n\t * The position that the task occupies in the execution tree. Note that this\n\t * position does not necessarily match that of the underlying ModelTask.\n\t * This position is computed from the parent ExecutionTask when the\n\t * ExecutionTask is created.\n\t */\n\tprivate Position position;\n\n\t/**\n\t * Enum defining the possible states of an ExecutionTask. Throughout its\n\t * execution, an ExecutionTask may be in several states:\n\t * \n\t * <ul>\n\t * <li> {@link #FAILURE}: means the task has failed, that is, it could not\n\t * complete successfully.\n\t * <li> {@link #SUCCESS}: means the task has completed successfully.\n\t * <li> {@link #RUNNING}: means the task is still running.\n\t * <li> {@link #TERMINATED}: means the task has been abruptly terminated. It\n\t * is conceptually similar to {@link #FAILURE}, so whenever a task has been\n\t * terminated, it is also considered to have failed.\n\t * <li> {@link #UNINITIALIZED}: means the task has not been spawned yet, that\n\t * is, it has not started executing.\n\t * </ul>\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static enum Status {\n\t\t/** Status code meaning the task has failed. */\n\t\tFAILURE, /** Status code meaning the task has succeeded. */\n\t\tSUCCESS, /** Status code meaning the task is still running. */\n\t\tRUNNING, /**\n\t\t * Status code meaning the task has been abruptly terminated.\n\t\t * It is conceptually similar to {@link #FAILURE}, so whenever a task\n\t\t * has been terminated, it is also considered to have failed.\n\t\t */\n\t\tTERMINATED,\n\t\t/**\n\t\t * Status code meaning the task has not been spawned yet, that is, it\n\t\t * has not started executing.\n\t\t */\n\t\tUNINITIALIZED,\n\t}\n\n\t/**\n\t * Constructs an ExecutionTask with an associated ModelTask and a\n\t * BTExecutor. The ModelTask represents the conceptual task that the\n\t * ExecutionTask is running, and the BTExecutor is that in charge of the\n\t * ExecutionTask. Also, the parent of the ExecutionTask must be provided.\n\t * \n\t * @param modelTask\n\t *            the ModelTask this ExecutionTask will run.\n\t * @param executor\n\t *            the BTExecutor managing this task.\n\t * @param parent\n\t *            the parent ExecutionTask, or null in case this is the root of\n\t *            the tree.\n\t */\n\tpublic ExecutionTask(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tthis.modelTask = modelTask;\n\t\tthis.executor = executor;\n\t\tthis.listeners = new LinkedList<ITaskListener>();\n\t\tthis.spawnable = true;\n\t\tthis.tickable = false;\n\t\tthis.terminated = false;\n\t\tthis.status = Status.UNINITIALIZED;\n\t\tthis.parent = parent;\n\n\t\t/* Compute the position of this node. */\n\t\tif (parent == null) {\n\t\t\tthis.position = new Position();\n\t\t} else {\n\t\t\tthis.position = new Position(parent.position);\n\t\t\tint nextMove = getMove();\n\t\t\tthis.position.addMove(nextMove);\n\t\t}\n\t}\n\n\t/**\n\t * This method is called the very first time the task has to be executed.\n\t * <p>\n\t * This method is in charge of creating all the structure down the hierarchy\n\t * of the BT that is needed to actually run the task. This process will\n\t * probably include creating and spawning, in a recursive manner, some of\n\t * the children of this task.\n\t * <p>\n\t * <code>spawn()</code> is not an abstract method. In reality, the actual\n\t * spawning process is not carried out by <code>spawn()</code> itself, but\n\t * by the abstract {@link #internalSpawn()} method. What\n\t * <code>spawn()</code> does is to just restore the previous state of the\n\t * task (if any), and then call <code>internalSpawn()</code>.\n\t * <code>internalSpawn()</code> has a different implementation for every\n\t * subclass of ExecutionTask, since it is that method the one that in fact\n\t * carries out the spawning process. <b>Thus, subclasses must define the\n\t * abstract <code>internalSpawn()</code> method</b>.\n\t * <p>\n\t * This method also stores the execution context (<code>context</code>) to\n\t * be used by the task, which will be accessible through\n\t * {@link #getContext()} after calling this method.\n\t * \n\t * @param context\n\t *            the context that the task will use.\n\t */\n\tpublic final void spawn(IContext context) throws SpawnException {\n\t\t/* If the task cannot be spawned, throw an exception. */\n\t\tif (!this.spawnable) {\n\t\t\tthrow new SpawnException(\"The task cannot be spawned. It has already been spawned.\");\n\t\t}\n\n\t\t/*\n\t\t * Store the context.\n\t\t */\n\t\tthis.context = context;\n\n\t\tthis.spawnable = false;\n\t\tthis.tickable = true;\n\n\t\t/* Set the current status of the task to Status.RUNNING. */\n\t\tthis.status = Status.RUNNING;\n\n\t\t/*\n\t\t * Request to be inserted into the list of open tasks.\n\t\t */\n\t\tthis.executor.requestInsertionIntoList(BTExecutorList.OPEN, this);\n\n\t\t/*\n\t\t * Restore the past state of the task in case it has any.\n\t\t */\n\t\tITaskState previousState = this.executor.getTaskState(getPosition());\n\t\trestoreState(previousState);\n\n\t\t/*\n\t\t * Carry out the actual spawn.\n\t\t */\n\t\tinternalSpawn();\n\t}\n\n\t/**\n\t * This is the method that carries out the actual spawning process of the\n\t * ExecutionTask. Sublclasses must define it, since the spawning process\n\t * varies depending on the type of the task.\n\t * <p>\n\t * <code>internalSpawn()</code> is called from the {@link #spawn(IContext)}\n\t * method. When <code>internalSpawn()</code> is called, the context of the\n\t * task is already accessible through {@link #getContext()}, so it can be\n\t * used by the task.\n\t * <p>\n\t * <code>internalSpawn()</code> is the method that creates all the structure\n\t * of interconnected tasks (ExecutionTask) that are necessary to run this\n\t * task. Each subclass is spawned in a different way. For instance, when a\n\t * sequence task is spawned, it has to spawn its first child, but when a\n\t * parallel task is spawned, it has to spawn all of its children.\n\t * <p>\n\t * An ExecutionTask contains a reference to a ModelTask which is trying to\n\t * run. When <code>internalSpawn()</code> is called, it has to create,\n\t * according to the semantics of the task, new ExecutionTask objects for the\n\t * children of the ModelTask.\n\t * <p>\n\t * For instance, let us suppose that there is a ModelSequence class\n\t * subclassing ModelTask. The ExecutionTask associated to ModelSequence is\n\t * ExecutionSequence. An ExecutionSequence has a reference to the\n\t * ModelSequence it is running. When ExecutionSequence is spawned, it has to\n\t * create, <i>according to the semantics of the task, new ExecutionTask\n\t * objects for the children of the ModelTask</i>. In this case it means that\n\t * the first child of the sequence should also be spawned (in a recursive\n\t * manner). Therefore, what the ExecutioSequence has to is to take the first\n\t * child of the ModelSequence (let us call it <i>child</i>), which will be a\n\t * ModelTask. Then, it will have to create the appropriate ExecutionTask for\n\t * <i>child</i>, by calling <i>child.createExecutor()</i>. Finally, it will\n\t * have to call the <code>spawn()</code> method recursively on the\n\t * ExecutionTask returned by <i>child.createExecutor()</i>. Other tasks\n\t * would behave differently. For instance, when an ExecutionParallel\n\t * (associated to a ModelParallel) is spawned, it has to create an\n\t * ExecutionTask for all of the children of its ModelParallel, and\n\t * recursively spawn every single one of them.\n\t * <p>\n\t * Leaf tasks (also known as <i>low level task</i>, since they usually -but\n\t * not always- perform a game-dependent process), such as actions and\n\t * conditions, are spawned in a different way. They do not recursively spawn\n\t * any child, since they have none. When a leaf task is spawned, it should\n\t * start the execution of the process associated to the node. Keep in mind\n\t * that low level tasks may perform long processes that require several\n\t * ticks in order to complete. It is in this method that those processes\n\t * start (maybe in independent threads).\n\t * <p>\n\t * It should be noted, however, that many processes may be instantaneous, so\n\t * they may complete even within the <code>internalSpawn()</code> method.\n\t * Nevertheless, in these cases the BT should not evolve, reason why the\n\t * termination notification to its parent is carried out in the\n\t * <code>tick()</code> method, probably in the next AI cycle. If\n\t * <code>spawn()</code> were allowed to notify parents when the task\n\t * terminates, then a single call to <code>spawn()</code> may take too long\n\t * to complete due to the uninterrupted evolution of the tree, which is\n\t * something that has to be avoided.\n\t * <p>\n\t * An important part of the spawning process is to decide if the\n\t * ExecutionTask will enter the list of tickable nodes of the BTExecutor.\n\t * Only tasks that request to be inserted into that list are ticked at every\n\t * game AI cycle (when {@link BTExecutor#tick()} is called). In order to\n\t * request it, the task has to call\n\t * {@link #requestInsertionIntoTickableList()}. In general, all leaf tasks\n\t * should be ticked every cycle, since the progress of parent tasks depends\n\t * on the termination of their children. However, non-leaf tasks may also\n\t * need ticking. For instance, the dynamic priority list task needs to\n\t * constantly receive ticks, since it has to check its children's guards all\n\t * the time -the dynamic priority list can evolve not only because of the\n\t * termination of the currently active child, but also because of the\n\t * reevaluation of guards-. In general, if the only way of making a task\n\t * evolve is through the notification of termination from one or several of\n\t * its children, then the task should not be in the list of tickable nodes.\n\t * On the other hand, if a task can evolve because of factors other than the\n\t * termination of one or several of its children, then it should request to\n\t * be inserted into the list of tickable nodes.\n\t */\n\tprotected abstract void internalSpawn();\n\n\t/**\n\t * After spawning an ExecutionTask, <code>tick()</code> has to be called in\n\t * order to update it and keep track of its status.\n\t * <p>\n\t * This method is in charge of updating this ExecutionTask according to its\n\t * semantics. This process may include spawning none, one, or several of its\n\t * children depending on their termination status. It may also have to\n\t * terminate some of its children.\n\t * <p>\n\t * <code>tick()</code> is not an abstract method. In reality, the actual\n\t * ticking process is not carried out by <code>tick()</code> itself, but by\n\t * the abstract {@link #internalTick()} method. <b>Thus, subclasses must\n\t * define the abstract <code>internalSpawn()</code> method</b>.\n\t * <p>\n\t * What <code>tick()</code> does is to call <code>internalTick()</code> to\n\t * carry out the actual ticking process. Then, <code>tick()</code> checks\n\t * if, after the tick, the task has finished (that is, it checks if the\n\t * status returned by <code>internalTick()</code> is {@link Status#FAILURE}\n\t * or {@link Status#SUCCESS}). If so, <code>tick()</code> fires a TaskEvent\n\t * to the parent of this ExecutionTask, so the parent does whatever it has\n\t * to do after the termination of its child, and also requests to be removed\n\t * from both the lists of tickable and open nodes of the BTExecutor (because\n\t * this task will not be ticked again unless it is spawned again). Also, if\n\t * the ExecutionTask has finished, <code>tick()</code> stores the current\n\t * state of the task just in case it is spawned again in the future.\n\t * <p>\n\t * <b>It should be noted that when a task has been terminated (\n\t * {@link #terminate()}), <code>tick()</code> does nothing</b>, and it just\n\t * returns {@link Status#TERMINATED} (it does not even fire a TaskEvent).\n\t * \n\t * @return the status of the task after being ticked.\n\t */\n\tpublic final Status tick() throws TickException {\n\t\t/* If the task cannot be ticked, throw an exception. */\n\t\tif (!this.tickable) {\n\t\t\tthrow new NotTickableException(\"The task cannot be ticked. It must be spawned first.\");\n\t\t}\n\n\t\t/* If the task has been terminated, do nothing. */\n\t\tif (!this.terminated) {\n\t\t\t/* Otherwise, perform the actual tick by calling \"internalTick()\". */\n\t\t\tStatus newStatus = this.internalTick();\n\n\t\t\t/* Check if the value that is returned by \"internalTick()\" is valid. */\n\t\t\tif (!validInternalTickStatus(newStatus)) {\n\t\t\t\tthrow new IllegalReturnStatusException(newStatus.toString()\n\t\t\t\t\t\t+ \" cannot be returned by ExecutionTask.internalTick()\");\n\t\t\t}\n\n\t\t\tthis.status = newStatus;\n\n\t\t\t/*\n\t\t\t * If the task has finished (either successfully or in failure), a\n\t\t\t * TaskEvent has to be fired in order to notify its parent about the\n\t\t\t * termination. Before firing the event, the current state of the\n\t\t\t * task has to be stored into the BTExecutor, just in case it needs\n\t\t\t * to be restored in the future. The task also requests to be\n\t\t\t * removed from both the list of tickable and open nodes.\n\t\t\t * \n\t\t\t * Otherwise the task has not finished, so nothing in particular is\n\t\t\t * done.\n\t\t\t */\n\t\t\tif (newStatus != Status.RUNNING) {\n\t\t\t\tITaskState taskState = storeState();\n\t\t\t\tthis.executor.setTaskState(getPosition(), taskState);\n\t\t\t\tthis.executor.requestRemovalFromList(BTExecutorList.TICKABLE, this);\n\t\t\t\tthis.executor.requestRemovalFromList(BTExecutorList.OPEN, this);\n\n\t\t\t\tfireTaskEvent(newStatus);\n\t\t\t}\n\n\t\t\treturn newStatus;\n\t\t} else {\n\t\t\treturn Status.TERMINATED;\n\t\t}\n\t}\n\n\t/**\n\t * <code>internalTick()</code> is the method that actually carries out the\n\t * ticking process of an ExecutionTask. Subclasses must define it, since the\n\t * ticking process varies depending on the type of the task.\n\t * <p>\n\t * <code>internalTick()</code> is called from the {@link #tick()} method.\n\t * When it is called, it must assume that the task has already been spawned\n\t * ({@link #spawn(IContext)}) and that the context of the task is already\n\t * accessible through {@link #getContext()}.\n\t * <p>\n\t * <code>internalTick()</code> is the method that is used to update an\n\t * ExecutionTask. Behaviour trees are driven by ticks, which means that they\n\t * only evolve when they are ticked (otherwise put, behaviour trees are\n\t * given CPU time only when they are ticked). <code>internalTick()</code> is\n\t * the method that implements the ticking process of the task. Therefore,\n\t * when it is called, and according to the semantics of the task, it will\n\t * have to do some processes to make the task go on. This processes may\n\t * include spawning other children or even terminating currently running\n\t * children.\n\t * <p>\n\t * For instance, let us suppose that there is a ModelSequence class\n\t * subclassing ModelTask. The ExecutionTask associated to ModelSequence is\n\t * ExecutionSequence. An ExecutionSequence has a reference to the\n\t * ModelSequence it is running. When ExecutionSequence is ticked, it has to\n\t * update the task <i>according to the semantics of the task</i>. In this\n\t * case it means that it has to analyze the current status of the current\n\t * active child (through {@link #getStatus()}). If the child is still\n\t * running, the ticking process just does nothing, since the sequence cannot\n\t * go on unless the current child finishes. Nevertheless, if the child has\n\t * successfully finished, the ExecutionSequence will have to spawn the next\n\t * task of the sequence. In order to do so, the ExecutionSequence will\n\t * access it through its ModelSequence. A new ExecutionTask will be created\n\t * for the next child of the ModelSequence (via the\n\t * <code>ModelTask.createExecutor()</code>) method, and then it will be\n\t * spawned (in this case, <code>internalTick()</code> will return\n\t * {@link Status#RUNNING}). However, if the child has not finished\n\t * successfully, the sequence has to be aborted, so the ticking process will\n\t * just return the failure status code {@link Status#FAILURE} (from the\n\t * outside, the <code>tick()</code> method will catch this termination code\n\t * and, as a result, it will fire a TaskEvent to notify the parent of the\n\t * ExecutionSequence).\n\t * <p>\n\t * The ticking process of the ExecutionParallel task is very different. When\n\t * <code>internalTick()</code> is called, the ExecutionParallel has to check\n\t * the current status of all of its children. If one of them has failed,\n\t * then all the children must be terminated, and the failure code\n\t * {@link Status#FAILURE} must be returned. If all of its children have\n\t * successfully finished, then the ExecutionParallel will just return\n\t * {@link Status#SUCCESS}. Otherwise, it will return {@link Status#RUNNING}.\n\t * <p>\n\t * Leaf tasks (<i>low level task</i>), such as actions and conditions, are\n\t * ticked in a different way. They do not have to analyze the termination\n\t * status of any child, since they have none. When a leaf task is ticked, it\n\t * should check the termination status of the process associated to the\n\t * task, and return a termination status accordingly. <b>It should be noted\n\t * that when a task has been terminated ( {@link #terminate()}),\n\t * <code>tick()</code> does nothing</b>.\n\t * <p>\n\t * It should be noted that when a task has been terminated (\n\t * {@link #terminate()}), <code>tick()</code> does nothing. In particular,\n\t * <code>tick()</code> will not call <code>internalTick()</code>.\n\t * <b>Therefore, it can be assumed that if <code>internalTick()</code> is\n\t * called, then this task has not been terminated</b>, so the implementation\n\t * of this method should not even consider other cases.\n\t * <p>\n\t * An important aspect of this method is that, even though it returns an\n\t * Status object, only certain return values are allowed. In particular,\n\t * only {@link Status#SUCCESS}, {@link Status#FAILURE} and\n\t * {@link Status#RUNNING} can be returned.\n\t * \n\t * @return the status of the task after being ticked.\n\t */\n\tprotected abstract Status internalTick();\n\n\t/**\n\t * This method stores the persistent state of an ExecutionTask. Some tasks\n\t * need to keep some information throughout the execution of the tree.\n\t * <p>\n\t * Some tasks in BTs are persistent in the sense that, after finishing, if\n\t * they are spawned again, they remember past information. Take for example\n\t * the \"limit\" task. A \"limit\" task allows to run its child node only a\n\t * certain number of times (for example, 5). After being spawned, it has to\n\t * remember how many times it has been run so far, so that, once the\n\t * threshold is exceeded, it fails.\n\t * <p>\n\t * The problem here is that tasks are destroyed when they leave the list of\n\t * tickable tasks. Thus, if the task needs to be used again, a new instance\n\t * for the task must be created, which, of course, will not remember past\n\t * information since it is a new object. This method is used for storing\n\t * information that needs to be used in the future when the task gets\n\t * created again. In particular, this method is called in the\n\t * {@link #tick()} function just after noticing that the task has finished\n\t * (when <code>internalTick()</code> returns a termination status). By doing\n\t * so, the task stores its state as soon as possible just in case it needs\n\t * to be spawned immediately afterwards.\n\t * <p>\n\t * This method must return the information it needs to remember in a a\n\t * {@link ITaskState} object, which must be comprehensible by the\n\t * {@link #restoreState(ITaskState)}, that is, it is\n\t * <code>restoreState()</code> that knows how to restore the state of the\n\t * task by reading the information that <code>storeState()</code> returns.\n\t * <p>\n\t * This method is called when the task finishes, so its implementation\n\t * should take into account that it will be called only when\n\t * {@link #internalTick()} returns a Status different from\n\t * {@link Status#RUNNING}.\n\t * <p>\n\t * This method may return null if the task does not need to store any state\n\t * information for future use.\n\t * \n\t * @return an ITaskState object with the persistent state information of the\n\t *         task, for future use. The returned ITaskState must be readable by\n\t *         <code>restoreState()</code>.\n\t */\n\tprotected abstract ITaskState storeState();\n\n\t/**\n\t * This method follows the same semantics as {@link #storeState()}. However,\n\t * it is called when the task is terminated ( {@link #terminate()} ). When a\n\t * task is abruptly terminated, it may want to store some state information\n\t * for future use. It is in this method where such information should be\n\t * returned.\n\t * \n\t * @return an ITaskState object with the persistent state information of the\n\t *         task, for future use. The returned ITaskState must be readable by\n\t *         <code>restoreState()</code>.\n\t */\n\tprotected abstract ITaskState storeTerminationState();\n\n\t/**\n\t * This method restores the persistent state of an ExecutionTask from an\n\t * {@link ITaskState} object. Some tasks need to keep some information\n\t * throughout the execution of the tree.\n\t * <p>\n\t * Some tasks in BTs are persistent in the sense that, after finishing, if\n\t * they are spawned again, they remember past information. Take for example\n\t * the \"limit\" task. A \"limit\" task allows to run its child node only a\n\t * certain number of times (for example, 5). After being spawned, it has to\n\t * remember how many times it has been run so far, so that, once the\n\t * threshold is exceeded, it fails.\n\t * <p>\n\t * The problem here is that tasks are destroyed when they leave the list of\n\t * tickable tasks. Thus, if the task needs to be used again, a new instance\n\t * for the task must be created, which, of course, will not remember past\n\t * information since it is a new object. This method is used for retrieving\n\t * from the ITaskState object past information that has previously returned\n\t * by either the {@link #storeState()} or the\n\t * {@link #storeTerminationState()} method. In particular, this method is\n\t * called in the {@link #spawn(IContext)} method, just before\n\t * {@link #internalSpawn()} gets called. By doing so, the task that is\n\t * created is able to restore past information needed to work. Since this\n\t * method is called before the task is spawned (that is, before\n\t * <code>internalSpawn()</code> is called), it must be assumed that the task\n\t * always keeps its past state.\n\t * <p>\n\t * This method reads the information that either <code>storeState()</code>\n\t * or <code>storeTerminationState()</code> has previously returned..\n\t * Therefore, it must follow the same format as that of both methods. It the\n\t * input ITaskState is null, it means that there is no past information to\n\t * retrieve, so the task should be left unchanged.\n\t * <p>\n\t * This method may be left empty if the task does not need to restore any\n\t * past state.\n\t * \n\t * @param state\n\t *            an ITaskState object containing past state information that\n\t *            should be retrieved, or null in case there is no past\n\t *            information to remember.\n\t */\n\tprotected abstract void restoreState(ITaskState state);\n\n\t/**\n\t * Returns the context of the task.\n\t * \n\t * @return the context of the task.\n\t */\n\tpublic IContext getContext() {\n\t\treturn this.context;\n\t}\n\n\t/**\n\t * Adds a task listener to this task. When there is a relevant change in the\n\t * status of this task, the listener will be notified by calling its\n\t * {@link ITaskListener#statusChanged(TaskEvent)} method.\n\t * \n\t * @param listener\n\t *            the listener to add.\n\t */\n\tpublic void addTaskListener(ITaskListener listener) {\n\t\tthis.listeners.add(listener);\n\t}\n\n\t/**\n\t * Removes a listener from this task.\n\t * \n\t * @param listener\n\t *            the task listener to remove.\n\t */\n\tpublic void removeTaskListener(ITaskListener listener) {\n\t\tthis.listeners.remove(listener);\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.event.ITaskListener#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic abstract void statusChanged(TaskEvent e);\n\n\t/**\n\t * Returns the current status of the task.\n\t * \n\t * @return the current status of the task.\n\t */\n\tpublic Status getStatus() {\n\t\treturn this.status;\n\t}\n\n\t/**\n\t * Returns the BTExecutor of this ExecutionTask.\n\t * \n\t * @return the BTExecutor of this ExecutionTask.\n\t */\n\tpublic BTExecutor getExecutor() {\n\t\treturn this.executor;\n\t}\n\n\t/**\n\t * Returns the ModelTask associated to this ExecutionTask.\n\t * \n\t * @return the ModelTask associated to this ExecutionTask.\n\t */\n\tpublic ModelTask getModelTask() {\n\t\treturn this.modelTask;\n\t}\n\n\t/**\n\t * Returns the position of the ExecutionTask in the execution tree. Note\n\t * that such position is not necessarily that of the underlying ModelTask.\n\t * \n\t * @return the position of the ExecutionTask in the execution tree.\n\t */\n\tpublic Position getPosition() {\n\t\treturn this.position;\n\t}\n\n\t/**\n\t * Returns true if the task has been spawned, and false otherwise.\n\t * \n\t * @return true if the task has been spawned, and false otherwise.\n\t */\n\tpublic boolean getSpawned() {\n\t\treturn this.spawnable == false;\n\t}\n\n\t/**\n\t * Returns true if the task has been terminated, and false otherwise.\n\t * \n\t * @return true if the task has been terminated, and false otherwise.\n\t */\n\tpublic boolean getTerminated() {\n\t\treturn this.terminated;\n\t}\n\n\t/**\n\t * Terminates the execution of this task and all the tasks below it.\n\t * <p>\n\t * When this method is called, the task is marked as terminated. From then\n\t * on, ticking the task will have no effect, and its status will be\n\t * {@link Status#TERMINATED}. Also, when terminating the task, it requests\n\t * to be removed from both the list of tickable and open nodes of the\n\t * BTExecutor. It also stores the task state after being terminated, by\n\t * calling {@link #storeTerminationState()}.\n\t * <p>\n\t * Finally, this method calls the abstract method\n\t * {@link #internalTerminate()}. <code>internalTerminate()</code> is the\n\t * method that actually terminates the execution of the task and all the\n\t * tasks below it, usually by calling <code>terminate()</code> on the active\n\t * children and by stopping any process associated to the task. <b>\n\t * <code>internalTerminate()</code> must be defined for each subclass, since\n\t * their termination processes differ from one another</b>.\n\t * <p>\n\t * This method cannot be called if the task has not been spawned yet (an\n\t * exception is thrown in that case). However, it is valid terminating a\n\t * task that has already been terminated, in which case nothing happens.\n\t */\n\tpublic final void terminate() {\n\t\tif (!this.tickable) {\n\t\t\tthrow new RuntimeException(\"Cannot terminate a task that has not been spawned yet.\");\n\t\t}\n\t\tif (!this.terminated) {\n\t\t\tthis.terminated = true;\n\t\t\tthis.status = Status.TERMINATED;\n\t\t\tthis.executor.requestRemovalFromList(BTExecutorList.TICKABLE, this);\n\t\t\tthis.executor.requestRemovalFromList(BTExecutorList.OPEN, this);\n\t\t\tITaskState taskState = this.storeTerminationState();\n\t\t\tthis.executor.setTaskState(getPosition(), taskState);\n\t\t\tthis.internalTerminate();\n\t\t}\n\t}\n\n\t/**\n\t * This method is called form {@link #terminate()}, and it is the one that\n\t * actually terminates the ExecutionTask as well as all the tasks below it.\n\t * <p>\n\t * <code>internalTerminate()</code> has to stop all the processes associated\n\t * to the ExecutionTask. For non-leaf tasks, this usually means that it has\n\t * to terminate all its active children (by recursively calling\n\t * <code>terminate()</code> on them). For leaf tasks, this means that it has\n\t * to terminate the processes associated to them, so that they stop doing\n\t * things.\n\t * <p>\n\t * For instance, an ExecutionParallel task has to call\n\t * <code>terminate</code> on all of its alive (still running) children. An\n\t * ExecutionSequence has to call <code>terminate()</code> on its current\n\t * alive child. A leaf task that, say, is carrying out some process in an\n\t * independent execution thread, should stop the thread.\n\t * <p>\n\t * This method can be called only once, and only once the task has already\n\t * been spawned, so the implementation does not have to even consider what\n\t * happens in other cases.\n\t */\n\tprotected abstract void internalTerminate();\n\n\t/**\n\t * Fires a TaskEvent in all the listeners of this task. The TaskEvent will\n\t * inform about an important change in the status of the task.\n\t * \n\t * @param newStatus\n\t *            the new status of the task.\n\t */\n\tprivate void fireTaskEvent(Status newStatus) {\n\t\tfor (ITaskListener l : this.listeners) {\n\t\t\tl.statusChanged(new TaskEvent(this, newStatus, this.getStatus()));\n\t\t}\n\t}\n\n\t/**\n\t * Returns the index that the ModelTask associated to this ExecutionTask\n\t * occupies in the list of children of its parent's children. Returns 0 if\n\t * the this ExecutionTask's ModelTask cannot be found.\n\t * <p>\n\t * The fact that the 0-case is contemplated is due to the existence of the\n\t * Subtree Lookup operator. The ModelSubtreeLookup does not have any\n\t * children, because it is a leaf node. However, the ExecutionSubtreeLookup\n\t * does have one child, which is the root of the tree that it is going to\n\t * emulate. As a result, the root of the tree emulated by the Subtree Lookup\n\t * cannot find itself as a child of its parent (the parent is the\n\t * ExecutionSubtreeLookup); as a workaround, we can return 0, since it is\n\t * the 0-th child of the ExecutionSubtreeLookup.\n\t */\n\tprivate int getMove() {\n\t\tList<ModelTask> parentsChildren = this.parent.getModelTask().getChildren();\n\t\tIterator<ModelTask> iterator = parentsChildren.iterator();\n\t\tModelTask thisModelTask = this.getModelTask();\n\n\t\tfor (int i = 0; i < parentsChildren.size(); i++) {\n\t\t\tif (iterator.next() == thisModelTask) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\t/**\n\t * Checks if a Status returned by {@link #internalTick()} is valid or not.\n\t * <code>internalTick()</code> can only return {@link Status#SUCCESS},\n\t * {@link Status#FAILURE} and {@link Status#RUNNING}.\n\t * \n\t * @param status\n\t *            the status to check.\n\t * @return true if <code>status</code> can be returned by\n\t *         <code>internalTick()</code>, and false otherwise.\n\t */\n\tprivate static boolean validInternalTickStatus(Status status) {\n\t\tif (status == Status.TERMINATED || status == Status.UNINITIALIZED) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * \n\t * @see java.lang.Object#toString()\n\t */\n\tpublic String toString() {\n\t\treturn \"[\" + this.getClass().getSimpleName() + \", Status: \" + this.status.toString() + \"]\";\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/IBTExecutor.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.model.core.ModelTask;\n\n/**\n * A behaviour tree executor (entity that is able to run a behaviour tree) must\n * implement this interface.\n * <p>\n * This is the part of the behaviour trees execution interface that is exposed\n * to clients. The execution process of behaviour trees is driven by ticks,\n * which means that they only perform calculations when they are ticked. At\n * every tick, they are given a little amount of time to think and evolve as\n * expected. If a behaviour tree is not ticked, then it does not go on.\n * <p>\n * An IBTExecutor defines two main methods, one for ticking the behaviour tree\n * it is running, and another one for terminating the tree.\n * <p>\n * Behaviour trees are represented by the ModelTask class.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic interface IBTExecutor {\n\t/**\n\t * This method gives the underlying BT a little amount of time to run.\n\t * <p>\n\t * Initially, a IBTExecutor is created to run a particular BT (ModelTask).\n\t * From then on, the <code>tick()</code> method is called to make the tree\n\t * evolve.\n\t * <p>\n\t * Usually the AI of a game is driven by ticks, which means that\n\t * periodically the AI is given some time to update its state (it checks the\n\t * current game state and performs some actions). BTs follow this pattern,\n\t * so whenever they are ticked, they are given a little amount of time to\n\t * think and behave as expected. If BTs are not ticked, they do not consume\n\t * CPU time and they not evolve.\n\t * <p>\n\t * By calling this method, the underlying BT will be ticked, so it will\n\t * think and evolve accordingly.\n\t * <p>\n\t * Note that ticking a tree that has already finished should have no effect\n\t * on the tree.\n\t */\n\tpublic void tick();\n\n\t/**\n\t * Terminates the execution of the behaviour tree. This method can be called\n\t * even if the tree has not started running yet or if it has already been\n\t * terminated.\n\t */\n\tpublic void terminate();\n\n\t/**\n\t * Returns the behaviour tree that this IBTExecutor is running. The\n\t * behaviour tree is represented by its root, which is a single ModelTask\n\t * object.\n\t * \n\t * @return the behaviour tree that this IBTExecutor is running.\n\t */\n\tpublic ModelTask getBehaviourTree();\n\n\t/**\n\t * Returns the execution status of the behaviour tree. It is the status of\n\t * the root of the tree.\n\t * \n\t * @return the execution status of the behaviour tree. It is the status of\n\t *         the root of the tree.\n\t */\n\tpublic Status getStatus();\n\n\t/**\n\t * Returns the context that was associated to the root node of the behaviour\n\t * tree, and which is being used to run it.\n\t * \n\t * @return the context that was associated to the root node of the behaviour\n\t *         tree, and which is being used to run it.\n\t */\n\tpublic IContext getRootContext();\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/IBTLibrary.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport jbt.model.core.ModelTask;\nimport jbt.util.Pair;\n\n/**\n * Common interface for all behaviour tree libraries. A behaviour tree library\n * is just a repository from which behaviour trees can be retrieved by name.\n * <p>\n * This is an <i>iterable</i> interface (it extends {@link Iterable}) so that\n * all the behaviour trees of the library can be easily accessed.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic interface IBTLibrary extends Iterable<Pair<String, ModelTask>> {\n\t/**\n\t * Returns the behaviour tree whose name is <code>name</code>. This method\n\t * returns the root task of the tree.\n\t * \n\t * @param name\n\t *            the name of the tree to retrieve.\n\t * @return the behaviour tree whose name is <code>name</code>, or null in\n\t *         case it does not exist.\n\t */\n\tpublic ModelTask getBT(String name);\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/IContext.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport jbt.model.core.ModelTask;\n\n/**\n * Interface defining the context of a behavior tree task. The context of a task\n * is a set of variables, each one consisting of a name and a value. This\n * interface defines some methods for manipulating such variables.\n * <p>\n * A context also contains a set of behaviour trees that can be accessed by\n * tasks using the context. Reusability is very important for behaviour trees.\n * In general, a behaviour tree will be made of some tasks of its own as well as\n * references to other behaviour trees. When tasks need to retrieve references\n * to other behaviour trees, it will be the context that will provide with them.\n * Thus, the context defines a method for retrieving behaviour trees by name.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic interface IContext {\n\t/**\n\t * Returns the value of a variable whose name is <code>name</code>, or null\n\t * if it is not found.\n\t * \n\t * @param name\n\t *            the name of the variable to retrieve.\n\t * \n\t * @return the value of a variable whose name is <code>name</code>, or null\n\t *         if it does not exist.\n\t */\n\tpublic Object getVariable(String name);\n\n\t/**\n\t * Sets the value of a variable. If the variable already existed, its value\n\t * is overwritten. <code>value</code> may be null in order to clear the\n\t * value of the variable.\n\t * \n\t * @param name\n\t *            the name of the variable.\n\t * @param value\n\t *            the value for the variable.\n\t * @return true if a variable with the same name already existed, and false\n\t *         otherwise.\n\t */\n\tpublic boolean setVariable(String name, Object value);\n\n\t/**\n\t * Clears the set of all the variables of the context.\n\t */\n\tpublic void clear();\n\n\t/**\n\t * Clears the value of a variable. This is equivalent to calling\n\t * {@link #setVariable(String, Object)} with a value of null for the second\n\t * argument.\n\t * \n\t * @param name\n\t *            the name of a variable.\n\t * @return true if the variable existed, and false otherwise.\n\t */\n\tpublic boolean clearVariable(String name);\n\n\t/**\n\t * Returns the behaviour tree whose name is <code>name</code>, or null in\n\t * case it does not exist it the context.\n\t * \n\t * @param name\n\t *            the name of the tree to retrieve.\n\t * @return the root of the behaviour tree whose name is <code>name</code>,\n\t *         or null in case it does not exist in the context.\n\t */\n\tpublic ModelTask getBT(String name);\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/ITaskState.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\n/**\n * The ITaskState interface represents the persistent state of a task in a\n * behaviour tree. This state is represented as a set of variables with name and\n * value.\n * <p>\n * Some tasks in BTs are persistent in the sense that, after finishing, if they\n * are spawned again, they remember past information. Take for example the\n * \"limit\" task. A \"limit\" task allows to run its child node only a certain\n * number of times (for example, 5). After being spawned, it has to remember how\n * many times it has been run so far, so that, once the threshold is exceeded,\n * it fails.\n * <p>\n * This interface represents the common functionality for classes that represent\n * the persistent state of a task. It just defines a method for retrieving the\n * value of a variable of the task's state. They way the task's state is\n * populated is not defined.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic interface ITaskState {\n\t/**\n\t * Returns the value of a variable whose name is <code>name</code>, or null\n\t * if it is not found.\n\t * \n\t * @param name\n\t *            the name of the variable to retrieve.\n\t * \n\t * @return the value of a variable whose name is <code>name</code>, or null\n\t *         if it does not exist.\n\t */\n\tpublic Object getStateVariable(String name);\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/TaskState.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport java.util.Hashtable;\nimport java.util.Map;\n\n/**\n * Default implementation of the {@link ITaskState} interface. It provides\n * methods for modifying the set of variables stored by the TaskState.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class TaskState implements ITaskState {\n\t/** The set of variables. */\n\tprivate Map<String, Object> variables;\n\n\t/**\n\t * Constructs an empty TaskState.\n\t */\n\tpublic TaskState() {\n\t\tthis.variables = new Hashtable<String, Object>();\n\t}\n\n\t/**\n\t * \n\t * @see jbt.execution.core.ITaskState#getStateVariable(java.lang.String)\n\t */\n\tpublic Object getStateVariable(String name) {\n\t\treturn this.variables.get(name);\n\t}\n\n\t/**\n\t * Sets the value of a variable. If the value is null, the variable is\n\t * cleared.\n\t * \n\t * @param name\n\t *            the name of the variable.\n\t * @param value\n\t *            the value of the variable.\n\t * @return true if there was a variable with name <code>name</code> before\n\t *         calling this method (it is therefore been overwritten), and false\n\t *         otherwise.\n\t */\n\tpublic boolean setStateVariable(String name, Object value) {\n\t\tif (value == null) {\n\t\t\treturn this.variables.remove(name) == null ? false : true;\n\t\t}\n\t\treturn this.variables.put(name, value) == null ? false : true;\n\t}\n\n\t/**\n\t * Clears all the variables of the TaskState.\n\t */\n\tpublic void clear() {\n\t\tthis.variables.clear();\n\t}\n\n\t/**\n\t * Clears the value of a variable.\n\t * \n\t * @param name\n\t *            the name of the variable.\n\t * @return true if the variable existed before calling this method, and\n\t *         false otherwise.\n\t */\n\tpublic boolean clearStateVariable(String name) {\n\t\treturn this.variables.remove(name) == null ? false : true;\n\t}\n\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/TaskStateFactory.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core;\n\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Map.Entry;\n\nimport jbt.util.Pair;\n\n/**\n * The TaskStateFactory implements the simple factory pattern, and allows\n * clients of the framework to create instances of {@link ITaskState} objects.\n * The methods provided by this factory allows the client to specify the set of\n * variables that the task state will contain.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class TaskStateFactory {\n\t/**\n\t * Creates an ITaskState that contains the set of variables specified by\n\t * <code>variables</code>. Each variable is a Pair whose first element is\n\t * the variable's name and the second element is its value.\n\t * \n\t * @param variables\n\t *            the list of variables that the ITaskState will contain.\n\t * @return an ITaskState that contains the set of variables in\n\t *         <code>variables</code>.\n\t */\n\tpublic static ITaskState createTaskState(List<Pair<String, Object>> variables) {\n\t\tTaskState taskState = new TaskState();\n\n\t\tfor (Pair<String, Object> variable : variables) {\n\t\t\ttaskState.setStateVariable(variable.getFirst(), variable.getSecond());\n\t\t}\n\n\t\treturn taskState;\n\t}\n\n\t/**\n\t * Creates an ITaskState that contains the set of variables specified by\n\t * <code>variables</code>. Variables are stored in a Map whose keys are\n\t * variables' names and whose values are the values of the variables.\n\t * \n\t * @param variables\n\t *            the list of variables that the ITaskState will contain.\n\t * @return an ITaskState that contains the set of variables in\n\t *         <code>variables</code>.\n\t */\n\tpublic static ITaskState createTaskState(Map<String, Object> variables) {\n\t\tTaskState taskState = new TaskState();\n\n\t\tfor (Entry<String, Object> variable : variables.entrySet()) {\n\t\t\ttaskState.setStateVariable(variable.getKey(), variable.getValue());\n\t\t}\n\n\t\treturn taskState;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/event/ITaskListener.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core.event;\n\nimport jbt.execution.core.ExecutionTask;\n\n/**\n * Interface for an entity that is able to receive events from tasks (\n * {@link ExecutionTask}) whose status has changed in a relevant way.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic interface ITaskListener {\n\t/**\n\t * Method called when an important change in the status of a task has taken\n\t * place.\n\t * \n\t * @param e\n\t *            the TaskEvent with all the information about the change in the\n\t *            status of the task.\n\t */\n\tpublic void statusChanged(TaskEvent e);\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/core/event/TaskEvent.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.core.event;\n\nimport java.util.EventObject;\n\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ExecutionTask.Status;\n\n/**\n * A TaskEvent is an event that is generated by tasks ({@link ExecutionTask}) to\n * signal that a relevant change in the status of a task has taken place.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class TaskEvent extends EventObject {\n\tprivate static final long serialVersionUID = 1L;\n\n\t/** The new status of the task. */\n\tprivate Status newStatus;\n\t/** The previous status of the task. */\n\tprivate Status previousStatus;\n\n\t/**\n\t * Creates a TaskEvent with a particular ExcutionTask as source of the\n\t * event. The source (<code>source</code>) is the task whose status has\n\t * changed, and <code>newStatus</code> is the new status of the task.\n\t * \n\t * @param source\n\t *            the task whose status has changed.\n\t * @param newStatus\n\t *            the new status of the task.\n\t */\n\tpublic TaskEvent(ExecutionTask source, Status newStatus, Status previousStatus) {\n\t\tsuper(source);\n\t\tthis.newStatus = newStatus;\n\t\tthis.previousStatus = previousStatus;\n\t}\n\n\t/**\n\t * Returns the new status associated to the task.\n\t * \n\t * @return the new status associated to the task.\n\t */\n\tpublic Status getNewStatus() {\n\t\treturn this.newStatus;\n\t}\n\n\t/**\n\t * Returns the previous status associated to the task.\n\t * \n\t * @return the previous status associated to the task.\n\t */\n\tpublic Status getPreviousStatus() {\n\t\treturn this.previousStatus;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/composite/ExecutionComposite.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.composite;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.composite.ModelComposite;\n\n/**\n * Base class for all the ExecutionTask subclasses that are able to run\n * composite tasks (that is, classes that inherit from ModelComposite).\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ExecutionComposite extends ExecutionTask {\n\t/**\n\t * Creates an ExecutionComposite that is able to run a particular\n\t * ModelComposite task.\n\t * \n\t * @param modelTask\n\t *            the ModelComposite task to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionComposite.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionComposite(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelComposite)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelComposite.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/composite/ExecutionDynamicPriorityList.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.composite;\n\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.IBTExecutor;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.composite.ModelDynamicPriorityList;\nimport jbt.util.Pair;\n\n/**\n * ExecutionDynamicPriorityList is the ExecutionTask that knows how to run a\n * ModelDynamicPriorityList.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionDynamicPriorityList extends ExecutionComposite {\n\t/** List of the children (ModelTask) of this task. */\n\tprivate List<ModelTask> children;\n\t/** Flag telling if the spawning process has failed. */\n\tprivate boolean spawnFailed;\n\t/** Flag that tells if there is a spawned child. */\n\tprivate boolean stillNotSpawned;\n\t/** Index of the currently active child. */\n\tprivate int activeChildIndex;\n\t/** Currently active child. */\n\tprivate ExecutionTask activeChild;\n\t/**\n\t * List containing the IBTExecutors in charge of running the guards. The i-th element of this\n\t * list manages the guard of the i-th child ( {@link #children}). Note that if a guard is null,\n\t * its corresponding IBTExecutor is also null.\n\t */\n\tprivate List<BTExecutor> guardsExecutors;\n\t/**\n\t * This List contains the current evaluation status of all the guards. If a guard is null, its\n\t * corresponding status is {@link Status#SUCCESS} (null guards are evaluated to true).\n\t */\n\tprivate List<Status> guardsResults;\n\t/**\n\t * Index of the current most relevant guard. All the guards before it have finished in failure.\n\t * This represents the guard such that, if its status changes to success, then it would be the\n\t * one selected by the dynamic priority list.\n\t */\n\tprivate int indexMostRelevantGuard = 0;\n\n\t/**\n\t * Creates an ExecutionDynamicPriorityList that is able to run a ModelDynamicPriorityList task\n\t * and that is managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelDynamicPriorityList that this ExecutionDynamicPriorityList is going to\n\t *            run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this ExecutionDynamicPriorityList.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionDynamicPriorityList(ModelTask modelTask, BTExecutor executor,\n\t\t\tExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelDynamicPriorityList)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelDynamicPriorityList.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the first child with active guard. It also requests to be inserted into the list of\n\t * tickable nodes of the BTExecutor, since this task has to check its children's guards all the\n\t * time. If there is no active guard, the spawning process is considered to have failed, so\n\t * {@link #internalTick()} will return {@link Status#FAILURE}. If some guards are still running\n\t * the spawning process is not considered to have started yet.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\t/*\n\t\t * The dynamic priority list has to be inserted into the list of tickable nodes because it\n\t\t * has to check its children's guards all the time.\n\t\t */\n\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\n\t\tthis.children = this.getModelTask().getChildren();\n\n\t\t/* Initialize guard executors. */\n\t\tthis.guardsExecutors = new Vector<BTExecutor>();\n\t\tthis.guardsResults = new Vector<Status>();\n\t\tfor (ModelTask child : this.children) {\n\t\t\tif (child.getGuard() != null) {\n\t\t\t\tthis.guardsExecutors.add(new BTExecutor(child.getGuard(), this.getContext()));\n\t\t\t\tthis.guardsResults.add(Status.RUNNING);\n\t\t\t} else {\n\t\t\t\tthis.guardsExecutors.add(null);\n\t\t\t\tthis.guardsResults.add(Status.SUCCESS);\n\t\t\t}\n\t\t}\n\n\t\t/* Evaluate guards. */\n\t\tresetGuardsEvaluation();\n\t\tPair<Status, Integer> activeGuard = evaluateGuards();\n\n\t\t/* If all guards have failed, the spawning process has also failed. */\n\t\tif (activeGuard.getFirst() == Status.FAILURE) {\n\t\t\tthis.spawnFailed = true;\n\t\t} else if (activeGuard.getFirst() == Status.RUNNING) {\n\t\t\t/*\n\t\t\t * If not all the guards have been evaluated yet, the spawning process is not considered\n\t\t\t * to have started.\n\t\t\t */\n\t\t\tthis.stillNotSpawned = true;\n\t\t} else {\n\t\t\t/*\n\t\t\t * If all the guards have been evaluated and one succeeded, spawn the corresponding\n\t\t\t * child.\n\t\t\t */\n\t\t\tthis.spawnFailed = false;\n\t\t\tthis.stillNotSpawned = false;\n\t\t\tthis.activeChildIndex = activeGuard.getSecond();\n\t\t\tthis.activeChild = this.children.get(this.activeChildIndex).createExecutor(\n\t\t\t\t\tthis.getExecutor(), this);\n\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\tthis.activeChild.spawn(this.getContext());\n\n\t\t\t/* Reset the guards evaluators. */\n\t\t\tresetGuardsEvaluation();\n\t\t}\n\t}\n\n\t/**\n\t * Just terminates the currently active child (if there is one).\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\t/*\n\t\t * This null check is necessary. Keep in mind that the dynamic priority list may not have an\n\t\t * active child, since the spawning process may have failed or not started yet. In such a\n\t\t * case, if it is terminated, \"this.activeChild\" will be null.\n\t\t */\n\t\tif (this.activeChild != null) {\n\t\t\tthis.activeChild.terminate();\n\t\t}\n\n\t\t/* Terminate the guards executors. */\n\t\tfor (IBTExecutor guardExecutor : this.guardsExecutors) {\n\t\t\tif (guardExecutor != null) {\n\t\t\t\tguardExecutor.terminate();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if there is an active guard with a priority higher than that of the active child. If\n\t * there is such a task, it terminates the active child and spawns the child of the guard with\n\t * higher priority, and {@link Status#RUNNING} is returned. If there is no such task, then the\n\t * status of the active child is returned.\n\t * <p>\n\t * If the spawning process failed, this method just returns {@link Status#FAILURE}. If the\n\t * spawning process has not finished yet, this method keeps evaluating the guards, and returns\n\t * {@link Status#RUNNING}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\t/* If the spawning process failed, return failure. */\n\t\tif (this.spawnFailed) {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\n\t\t/* Evaluate guards. */\n\t\tPair<Status, Integer> activeGuard = evaluateGuards();\n\n\t\t/*\n\t\t * If no child has been spawned yet (not all the guards had completed yet in the\n\t\t * internalSpawn() method)...\n\t\t */\n\t\tif (this.stillNotSpawned) {\n\t\t\t/* If all the guards have failed, return failure. */\n\t\t\tif (activeGuard.getFirst() == Status.FAILURE) {\n\t\t\t\treturn Status.FAILURE;\n\t\t\t} else if (activeGuard.getFirst() == Status.RUNNING) {\n\t\t\t\t/*\n\t\t\t\t * If not all the guards have finished, do no nothing (return RUNNING).\n\t\t\t\t */\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t * If all the guards have been evaluated and one succeeded, spawn the child.\n\t\t\t\t */\n\t\t\t\tthis.spawnFailed = false;\n\t\t\t\tthis.stillNotSpawned = false;\n\t\t\t\tthis.activeChildIndex = activeGuard.getSecond();\n\t\t\t\tthis.activeChild = this.children.get(this.activeChildIndex).createExecutor(\n\t\t\t\t\t\tthis.getExecutor(), this);\n\t\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\t\tthis.activeChild.spawn(this.getContext());\n\n\t\t\t\t/* Reset the guards evaluators. */\n\t\t\t\tresetGuardsEvaluation();\n\t\t\t}\n\n\t\t\treturn Status.RUNNING;\n\t\t}\n\n\t\t/* If this point has been reached, there must be an active child. */\n\t\tif (activeGuard.getFirst() == Status.FAILURE) {\n\t\t\t/* If all the guards have failed, return failure. */\n\t\t\treturn Status.FAILURE;\n\t\t} else if (activeGuard.getFirst() == Status.RUNNING) {\n\t\t\t/*\n\t\t\t * If the guards are being evaluated, return the status of the active child.\n\t\t\t */\n\t\t\treturn this.activeChild.getStatus();\n\t\t} else {\n\t\t\tif (activeGuard.getSecond() != this.activeChildIndex) {\n\t\t\t\t/*\n\t\t\t\t * If the child with the highest priority guard has changed, terminate the currently\n\t\t\t\t * active child.\n\t\t\t\t */\n\t\t\t\tthis.activeChild.terminate();\n\t\t\t\tthis.activeChildIndex = activeGuard.getSecond();\n\n\t\t\t\t/*\n\t\t\t\t * Spawn the new child.\n\t\t\t\t */\n\t\t\t\tthis.activeChild = this.children.get(this.activeChildIndex).createExecutor(\n\t\t\t\t\t\tthis.getExecutor(), this);\n\t\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\t\tthis.activeChild.spawn(this.getContext());\n\n\t\t\t\tresetGuardsEvaluation();\n\t\t\t\treturn Status.RUNNING;\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t * If the child with the highest priority guard has not changed, return the status\n\t\t\t\t * of the active child.\n\t\t\t\t */\n\t\t\t\tresetGuardsEvaluation();\n\t\t\t\treturn this.activeChild.getStatus();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {\n\t}\n\n\t/**\n\t * Just calls {@link #tick()} to make the task evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Resets the evaluation of all the guards. This method leaves all the guard executors (\n\t * {@link #guardsExecutors}) ready to start again the evaluation of the guards. It internally\n\t * terminates the IBTExecutor of each guard, creates a new one, and then ticks it.\n\t */\n\tprivate void resetGuardsEvaluation() {\n\t\tfor (int i = 0; i < this.guardsExecutors.size(); i++) {\n\t\t\tBTExecutor guardExecutor = this.guardsExecutors.get(i);\n\n\t\t\tif (guardExecutor != null) {\n\t\t\t\tguardExecutor.terminate();\n\t\t\t\tthis.guardsResults.set(i, Status.RUNNING);\n\t\t\t\tBTExecutor newExecutor = new BTExecutor(guardExecutor.getBehaviourTree(),\n\t\t\t\t\t\tthis.getContext());\n\t\t\t\tnewExecutor.copyTasksStates(guardExecutor);\n\t\t\t\tnewExecutor.tick();\n\t\t\t\tthis.guardsExecutors.set(i, newExecutor);\n\t\t\t}\n\t\t}\n\n\t\tthis.indexMostRelevantGuard = 0;\n\t}\n\n\t/**\n\t * Evaluate all the guards that have not finished yet, that is, those whose result in\n\t * {@link #guardsResults} is {@link Status#RUNNING}, by ticking them.\n\t * <p>\n\t * If all the guards have finished in failure, this method returns a Pair whose first element is\n\t * {@link Status#FAILURE}. If guards' evaluation has not completed yet, the first element of the\n\t * Pair contains {@link Status#RUNNING}. If all the guards have been evaluated and at least one\n\t * has succeeded, the first element of the Pair is {@link Status#SUCCESS}, and the second one is\n\t * the index, over the list of guards ({@link #guardsExecutors}) , of the first guard (that with\n\t * the highest priority) that has succeeded.\n\t * \n\t */\n\tprivate Pair<Status, Integer> evaluateGuards() {\n\t\t/*\n\t\t * Tick all the guards that are still running. If one changes its status to SUCCESS and it\n\t\t * matches the guard associated to \"indexMostRelevantGuard\", then the guards' evaluation is\n\t\t * over and that is the selected guard.\n\t\t */\n\t\tfor (int i = 0; i < this.guardsExecutors.size(); i++) {\n\t\t\tIBTExecutor guardExecutor = this.guardsExecutors.get(i);\n\n\t\t\tif (guardExecutor != null) {\n\t\t\t\tif (this.guardsResults.get(i) == Status.RUNNING) {\n\t\t\t\t\tlongTick(guardExecutor);\n\n\t\t\t\t\tthis.guardsResults.set(i, guardExecutor.getStatus());\n\n\t\t\t\t\tif (guardExecutor.getStatus() != Status.RUNNING) {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * If the guard has finished, we check if it matches the\n\t\t\t\t\t\t * \"most relevant guard\".\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (i == this.indexMostRelevantGuard) {\n\t\t\t\t\t\t\tif (guardExecutor.getStatus() == Status.SUCCESS) {\n\t\t\t\t\t\t\t\treturn new Pair<Status, Integer>(Status.SUCCESS, i);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t\t * If the guard failed, we have to find the next\n\t\t\t\t\t\t\t\t * \"most relevant guard\" and update \"indexMostRelevantGuard\"\n\t\t\t\t\t\t\t\t * accordingly. For that we check the status of the following\n\t\t\t\t\t\t\t\t * guards. If we find a successful guard before any running guard,\n\t\t\t\t\t\t\t\t * then the guards' evaluation is over, and that is the selected\n\t\t\t\t\t\t\t\t * guard. If we find a running guard before, then that's the new\n\t\t\t\t\t\t\t\t * \"most relevant guard\". Otherwise, the evaluation has failed, and\n\t\t\t\t\t\t\t\t * there is no successful guard.\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\tboolean oneRunning = false;\n\n\t\t\t\t\t\t\t\tfor (int k = this.indexMostRelevantGuard + 1; k < this.guardsExecutors\n\t\t\t\t\t\t\t\t\t\t.size(); k++) {\n\t\t\t\t\t\t\t\t\tif (this.guardsExecutors.get(k) != null) {\n\t\t\t\t\t\t\t\t\t\tStatus currentResult = this.guardsExecutors.get(k)\n\t\t\t\t\t\t\t\t\t\t\t\t.getStatus();\n\t\t\t\t\t\t\t\t\t\tif (currentResult == Status.RUNNING) {\n\t\t\t\t\t\t\t\t\t\t\tthis.indexMostRelevantGuard = k;\n\t\t\t\t\t\t\t\t\t\t\toneRunning = true;\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t} else if (currentResult == Status.SUCCESS) {\n\t\t\t\t\t\t\t\t\t\t\treturn new Pair<Status, Integer>(Status.SUCCESS, k);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\treturn new Pair<Status, Integer>(Status.SUCCESS, k);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (!oneRunning) {\n\t\t\t\t\t\t\t\t\treturn new Pair<Status, Integer>(Status.FAILURE, -1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/* Remember, null guard means successful evaluation. */\n\t\t\t\tif (i == this.indexMostRelevantGuard) {\n\t\t\t\t\treturn new Pair<Status, Integer>(Status.SUCCESS, i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn new Pair<Status, Integer>(Status.RUNNING, -1);\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * This method ticks <code>executor</code> {@value #NUM_TICKS_LONG_TICK} times. If the executor\n\t * finishes earlier, it is not ticked anymore, and the ticking process stops.\n\t * \n\t * @param executor\n\t *            the IBTExecutor that is ticked.\n\t */\n\tprivate void longTick(IBTExecutor executor) {\n\t\tif (executor.getStatus() == Status.RUNNING || executor.getStatus() == Status.UNINITIALIZED) {\n\t\t\tint counter = 0;\n\t\t\tdo {\n\t\t\t\texecutor.tick();\n\t\t\t\tcounter++;\n\t\t\t} while (executor.getStatus() == Status.RUNNING && counter < NUM_TICKS_LONG_TICK);\n\t\t}\n\t}\n\n\t/** Number of ticks performed in each long tick ({@link #longTick(IBTExecutor)}). */\n\tprivate static final int NUM_TICKS_LONG_TICK = 20;\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/composite/ExecutionParallel.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.composite;\n\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.composite.ModelParallel;\nimport jbt.model.task.composite.ModelParallel.ParallelPolicy;\n\n/**\n * ExecutionParallel is the ExecutionTask that knows how to run a ModelParallel\n * task.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionParallel extends ExecutionComposite {\n\t/** Policy of the parallel task. */\n\tprivate ParallelPolicy policy;\n\t/** List of the ModelTask children of this task. */\n\tprivate List<ModelTask> modelChildren;\n\t/** List of the ExecutionTask children of this task. */\n\tprivate List<ExecutionTask> executionChildren;\n\n\t/**\n\t * Creates an ExecutionParallel that is able to run a ModelParallel task and\n\t * that is managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelParallel that this ExecutionParallel is going to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this ExecutionParallel.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionParallel(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelParallel)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelParallel.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\n\t\tthis.policy = ((ModelParallel) modelTask).getPolicy();\n\t\tthis.modelChildren = modelTask.getChildren();\n\t\tthis.executionChildren = new LinkedList<ExecutionTask>();\n\t}\n\n\t/**\n\t * Spawns every single child of the task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tif (this.policy == ParallelPolicy.SEQUENCE_POLICY) {\n\t\t\tsequencePolicySpawn();\n\t\t}\n\t\telse {\n\t\t\tselectorPolicySpawn();\n\t\t}\n\t}\n\n\t/**\n\t * Terminates all of its children.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tif (this.policy == ParallelPolicy.SEQUENCE_POLICY) {\n\t\t\tsequencePolicyTerminate();\n\t\t}\n\t\telse {\n\t\t\tselectorPolicyTerminate();\n\t\t}\n\n\t}\n\n\t/**\n\t * Ticks this ExecutionParallel. This process varies depending on the\n\t * policy. that is being followed. See {@link ModelParallel} for more\n\t * information.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tif (this.policy == ParallelPolicy.SEQUENCE_POLICY) {\n\t\t\treturn sequencePolicyTick();\n\t\t}\n\t\telse {\n\t\t\treturn selectorPolicyTick();\n\t\t}\n\t}\n\n\t/**\n\t * Carries out the spawning process when the policy is\n\t * {@link ParallelPolicy#SEQUENCE_POLICY}.\n\t */\n\tprivate void sequencePolicySpawn() {\n\t\t/* First, create an ExecutionTask for all of the childre. */\n\t\tfor (ModelTask t : this.modelChildren) {\n\t\t\tthis.executionChildren.add(t.createExecutor(this.getExecutor(), this));\n\t\t}\n\n\t\t/* Then, spawn them all. */\n\t\tfor (ExecutionTask t : this.executionChildren) {\n\t\t\tt.addTaskListener(this);\n\t\t\tt.spawn(this.getContext());\n\t\t}\n\t}\n\n\t/**\n\t * Carries out the spawning process when the policy is\n\t * {@link ParallelPolicy#SELECTOR_POLICY}.\n\t */\n\tprivate void selectorPolicySpawn() {\n\t\tsequencePolicySpawn();\n\t}\n\n\t/**\n\t * Carries out the termination process when the policy is\n\t * {@link ParallelPolicy#SEQUENCE_POLICY}.\n\t */\n\tprivate void sequencePolicyTerminate() {\n\t\t/* Just terminate all of its children. */\n\t\tfor (ExecutionTask t : this.executionChildren) {\n\t\t\tt.terminate();\n\t\t}\n\t}\n\n\t/**\n\t * Carries out the termination process when the policy is\n\t * {@link ParallelPolicy#SELECTOR_POLICY}.\n\t */\n\tprivate void selectorPolicyTerminate() {\n\t\tsequencePolicyTerminate();\n\t}\n\n\t/**\n\t * Carries out the ticking process when the policy is\n\t * {@link ParallelPolicy#SEQUENCE_POLICY}.\n\t * \n\t * @return the task status after the tick.\n\t */\n\tprivate Status sequencePolicyTick() {\n\t\t/*\n\t\t * If one child has failed, then return Status.FAILURE. Otherwise, if\n\t\t * there is at least one child still running, return Status.RUNNING.\n\t\t * Otherwise, return Status.SUCCESS.\n\t\t */\n\t\tboolean oneRunning = false;\n\n\t\tfor (ExecutionTask t : this.executionChildren) {\n\t\t\tStatus currentStatus = t.getStatus();\n\t\t\tif (currentStatus == Status.RUNNING) {\n\t\t\t\toneRunning = true;\n\t\t\t}\n\t\t\telse if (currentStatus == Status.FAILURE || currentStatus == Status.TERMINATED) {\n\t\t\t\tsequencePolicyTerminate();\n\t\t\t\treturn Status.FAILURE;\n\t\t\t}\n\t\t}\n\n\t\tif (!oneRunning) {\n\t\t\treturn Status.SUCCESS;\n\t\t}\n\t\telse {\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t}\n\n\t/**\n\t * Carries out the ticking process when the policy is\n\t * {@link ParallelPolicy#SELECTOR_POLICY}.\n\t * \n\t * @return the task status after the tick.\n\t */\n\tprivate Status selectorPolicyTick() {\n\t\t/*\n\t\t * If one child has succeeded, then return Status.SUCCESS. Otherwise, if\n\t\t * there is at least one child still running, return Status.RUNNING.\n\t\t * Otherwise, return Status.FAILURE.\n\t\t */\n\t\tboolean oneRunning = false;\n\n\t\tfor (ExecutionTask t : this.executionChildren) {\n\t\t\tStatus currentStatus = t.getStatus();\n\t\t\tif (currentStatus == Status.SUCCESS) {\n\t\t\t\tsequencePolicyTerminate();\n\t\t\t\treturn Status.SUCCESS;\n\t\t\t}\n\t\t\telse if (currentStatus == Status.RUNNING) {\n\t\t\t\toneRunning = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!oneRunning) {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\t\telse {\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the ExecutionParallel task evolve\n\t * according to the status of its children.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\t/*\n\t\t * TODO: the TaskEvent could be used to improve the efficiency of this\n\t\t * method, since we only have to analyse the status of the task that\n\t\t * fired the event, not the status of all the tasks (which is what\n\t\t * tick() does).\n\t\t */\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/composite/ExecutionRandomSelector.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.composite;\n\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.composite.ModelRandomSelector;\n\n/**\n * ExecutionRandomSelector is the ExecutionTask that knows how to run a\n * ModelRandomSelector.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionRandomSelector extends ExecutionComposite {\n\t/**\n\t * Currently active child.\n\t */\n\tprivate ExecutionTask activeChild;\n\t/**\n\t * The currently active child of the selector. This integer is an index over\n\t * the elements of {@link #order}.\n\t */\n\tprivate int activeChildIndex;\n\t/**\n\t * The list of children of this task.\n\t */\n\tprivate List<ModelTask> children;\n\t/**\n\t * List storing a sequence of integers with the order in which the children\n\t * of this task must be evaluated. This list is computed when the task is\n\t * spawned.\n\t */\n\tprivate List<Integer> order;\n\n\t/**\n\t * Constructs an ExecutionRandomSelector to run a specific\n\t * ModelRandomSelector.\n\t * \n\t * @param modelTask\n\t *            the ModelRandomSelector to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionRandomSelector.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionRandomSelector(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelRandomSelector)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelRandomSelector.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the first task (randomly selected).\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.children = this.getModelTask().getChildren();\n\t\t/*\n\t\t * First we initialize the list with the order in which the list of\n\t\t * children will be evaluated.\n\t\t */\n\t\tthis.order = new Vector<Integer>();\n\t\tfor (int i = 0; i < this.children.size(); i++) {\n\t\t\tthis.order.add(i);\n\t\t}\n\t\tCollections.shuffle(this.order);\n\n\t\t/*\n\t\t * Then we spawn the first child.\n\t\t */\n\t\tthis.activeChildIndex = 0;\n\t\tthis.activeChild = this.children.get(this.order.get(this.activeChildIndex)).createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.activeChild.addTaskListener(this);\n\t\tthis.activeChild.spawn(this.getContext());\n\t}\n\n\t/**\n\t * Just terminates the currently active child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tthis.activeChild.terminate();\n\t}\n\n\t/**\n\t * Checks the status of the currently active child. If it is running,\n\t * {@link Status#RUNNING} is returned. If it has successfully finished, it\n\t * returns {@link Status#SUCCESS}. If it has failed, it tries to spawn the\n\t * next child (returning {@link Status#RUNNING}). If it was the last child,\n\t * returns {@link Status#FAILURE}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tStatus childStatus = this.activeChild.getStatus();\n\n\t\tif (childStatus == Status.RUNNING) {\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t\telse if (childStatus == Status.SUCCESS) {\n\t\t\treturn Status.SUCCESS;\n\t\t}\n\t\telse {\n\t\t\t/* If it was the last child of the list, return failure. */\n\t\t\tif (this.activeChildIndex == this.children.size() - 1) {\n\t\t\t\treturn Status.FAILURE;\n\t\t\t}\n\n\t\t\tthis.activeChildIndex++;\n\t\t\tthis.activeChild = this.children.get(this.order.get(this.activeChildIndex))\n\t\t\t\t\t.createExecutor(this.getExecutor(), this);\n\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\tthis.activeChild.spawn(this.getContext());\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the task evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/composite/ExecutionRandomSequence.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.composite;\n\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.composite.ModelRandomSequence;\n\n/**\n * ExecutionRandomSequence is the ExecutionTask that knows how to run a\n * ModelRandomSequence.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionRandomSequence extends ExecutionComposite {\n\t/**\n\t * Currently active child.\n\t */\n\tprivate ExecutionTask activeChild;\n\t/**\n\t * The currently active child of the sequence. This integer is an index over\n\t * the elements of {@link #order}.\n\t */\n\tprivate int activeChildIndex;\n\t/**\n\t * The list of children of this task.\n\t */\n\tprivate List<ModelTask> children;\n\t/**\n\t * List storing a sequence of integers with the order in which the children\n\t * of this task must be evaluated. This list is computed when the task is\n\t * spawned.\n\t */\n\tprivate List<Integer> order;\n\n\t/**\n\t * Constructs an ExecutionRandomSequence to run a specific\n\t * ModelRandomSequence.\n\t * \n\t * @param modelTask\n\t *            the ModelRandomSequence to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionRandomSequence.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionRandomSequence(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelRandomSequence)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelRandomSequence.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the first task (randomly selected).\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.children = this.getModelTask().getChildren();\n\t\t/*\n\t\t * First we initialize the list with the order in which the list of\n\t\t * children will be evaluated.\n\t\t */\n\t\tthis.order = new Vector<Integer>();\n\t\tfor (int i = 0; i < this.children.size(); i++) {\n\t\t\tthis.order.add(i);\n\t\t}\n\t\tCollections.shuffle(this.order);\n\n\t\t/*\n\t\t * Then we spawn the first child.\n\t\t */\n\t\tthis.activeChildIndex = 0;\n\t\tthis.activeChild = this.children.get(this.order.get(this.activeChildIndex)).createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.activeChild.addTaskListener(this);\n\t\tthis.activeChild.spawn(this.getContext());\n\t}\n\n\t/**\n\t * Just terminates the currently active child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tthis.activeChild.terminate();\n\t}\n\n\t/**\n\t * Checks the status of the currently active child. If it is running,\n\t * {@link Status#RUNNING} is returned. If it has finished in failure,\n\t * {@link Status#FAILURE} is returned. If it has finished successfully, it\n\t * tries to spawn the next child (and returns {@link Status#RUNNING}). If it\n\t * was the last child of the sequence, returns {@link Status#SUCCESS}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tStatus childStatus = this.activeChild.getStatus();\n\n\t\tif (childStatus == Status.RUNNING) {\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t\telse if (childStatus == Status.SUCCESS) {\n\t\t\t/* If it was the last child of the sequence, returns success. */\n\t\t\tif (this.activeChildIndex == this.children.size() - 1) {\n\t\t\t\treturn Status.SUCCESS;\n\t\t\t}\n\n\t\t\tthis.activeChildIndex++;\n\t\t\tthis.activeChild = this.children.get(this.order.get(this.activeChildIndex))\n\t\t\t\t\t.createExecutor(this.getExecutor(), this);\n\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\tthis.activeChild.spawn(this.getContext());\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t\telse {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the task evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/composite/ExecutionSelector.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.composite;\n\nimport java.util.List;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.composite.ModelSelector;\n\n/**\n * ExecutionSelector is the ExecutionTask that is able to run a ModelSelector\n * task.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionSelector extends ExecutionComposite {\n\t/** Index of the active child. */\n\tprivate int activeChildIndex;\n\t/** The currently active child. */\n\tprivate ExecutionTask activeChild;\n\t/** List of the ModelTask children of the selector. */\n\tprivate List<ModelTask> children;\n\n\t/**\n\t * Creates an ExecutionSelector that is able to run a ModelSelector task and\n\t * that is managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelSelector that this ExecutionSelector is going to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this ExecutionSelector.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionSelector(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelSelector)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelSelector.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the first child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.activeChildIndex = 0;\n\t\tthis.children = this.getModelTask().getChildren();\n\t\tthis.activeChild = this.children.get(this.activeChildIndex).createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.activeChild.addTaskListener(this);\n\t\tthis.activeChild.spawn(this.getContext());\n\t}\n\n\t/**\n\t * Terminates the current active child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tthis.activeChild.terminate();\n\t}\n\n\t/**\n\t * Checks if the currently active child has finished. It it has not, it\n\t * returns {@link Status#RUNNING}. If it has finished successfully, it\n\t * returns {@link Status#SUCCESS}. If it has finished in failure, then:\n\t * <ul>\n\t * <li>If it was the last child of the selector, returns\n\t * {@link Status#FAILURE}.\n\t * <li>Otherwise, it spawns the next child of the selector and returns\n\t * {@link Status#RUNNING}.\n\t * </ul>\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tStatus childStatus = this.activeChild.getStatus();\n\n\t\tif (childStatus == Status.RUNNING) {\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t\telse if (childStatus == Status.SUCCESS) {\n\t\t\treturn Status.SUCCESS;\n\t\t}\n\t\telse {\n\t\t\t/*\n\t\t\t * If the current child has failed, and it was the last one, return\n\t\t\t * failure.\n\t\t\t */\n\t\t\tif (this.activeChildIndex == this.children.size() - 1) {\n\t\t\t\treturn Status.FAILURE;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t/*\n\t\t\t\t * Otherwise, if it was not the last child, spawn the next\n\t\t\t\t * child.\n\t\t\t\t */\n\t\t\t\tthis.activeChildIndex++;\n\t\t\t\tthis.activeChild = this.children.get(this.activeChildIndex).createExecutor(\n\t\t\t\t\t\tthis.getExecutor(), this);\n\t\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\t\tthis.activeChild.spawn(this.getContext());\n\t\t\t\treturn Status.RUNNING;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the ExecutionSelector evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/composite/ExecutionSequence.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.composite;\n\nimport java.util.List;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.composite.ModelSequence;\n\n/**\n * ExecutionSequence is the ExecutionTask that knows how to run a ModelSequence\n * task.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionSequence extends ExecutionTask {\n\t/** Index of the active child. */\n\tprivate int activeChildIndex;\n\t/** The currently active child. */\n\tprivate ExecutionTask activeChild;\n\t/** List of the ModelTask children of the sequence. */\n\tprivate List<ModelTask> children;\n\n\t/**\n\t * Creates an ExecutionSequence that is able to run a ModelSequence task and\n\t * that is managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelSequence that this ExecutionSequence is going to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this ExecutionSequence.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionSequence(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelSequence)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelSequence.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the first child of the sequence.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\t/*\n\t\t * Spawn the first child of the sequence.\n\t\t */\n\t\tthis.activeChildIndex = 0;\n\t\tthis.children = this.getModelTask().getChildren();\n\t\tthis.activeChild = this.children.get(0).createExecutor(this.getExecutor(), this);\n\t\tthis.activeChild.addTaskListener(this);\n\t\tthis.activeChild.spawn(this.getContext());\n\t}\n\n\t/**\n\t * Terminates the currently active child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\t/* Just terminate the active child. */\n\t\tthis.activeChild.terminate();\n\t}\n\n\t/**\n\t * Checks if the currently active child has finished. If it has not\n\t * finished, returns {@link Status#SUCCESS}. If it has finished in failure,\n\t * returns {@link Status#FAILURE}. If it has finished successfully, it\n\t * checks if there is any remaining child. If so, it spawns it. Otherwise,\n\t * returns {@link Status#SUCCESS}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tStatus childStatus = this.activeChild.getStatus();\n\t\tif (childStatus == Status.RUNNING) {\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t\telse if (childStatus == Status.FAILURE || childStatus == Status.TERMINATED) {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\t\telse {\n\t\t\tif (this.activeChildIndex == this.children.size() - 1) {\n\t\t\t\t/*\n\t\t\t\t * If this was the last child, return success.\n\t\t\t\t */\n\t\t\t\treturn Status.SUCCESS;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t/*\n\t\t\t\t * If the current child has finished successfully, but it is not\n\t\t\t\t * the last one, spawn the next child.\n\t\t\t\t */\n\t\t\t\tthis.activeChildIndex++;\n\t\t\t\tthis.activeChild = this.children.get(this.activeChildIndex).createExecutor(\n\t\t\t\t\t\tthis.getExecutor(), this);\n\t\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\t\tthis.activeChild.spawn(this.getContext());\n\t\t\t\treturn Status.RUNNING;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to check if the ExecutionSequence can evolve\n\t * due to the change in the state of the task that was listening to.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/composite/ExecutionStaticPriorityList.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.composite;\n\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.IBTExecutor;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.composite.ModelStaticPriorityList;\nimport jbt.util.Pair;\n\n/**\n * ExecutionStaticPriorityList is the ExecutionTask that knows how to run a\n * ModelStaticPriorityList.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionStaticPriorityList extends ExecutionComposite {\n\t/** List of the children (ModelTask) of this task. */\n\tprivate List<ModelTask> children;\n\t/** Flag telling if the spawning process has failed. */\n\tprivate boolean spawnFailed;\n\t/** Flag that tells if there is a spawned child. */\n\tprivate boolean stillNotSpawned;\n\t/** Index of the currently active child. */\n\tprivate int activeChildIndex;\n\t/** Currently active child. */\n\tprivate ExecutionTask activeChild;\n\t/**\n\t * List containing the IBTExecutors in charge of running the guards. The\n\t * i-th element of this list manages the guard of the i-th child (\n\t * {@link #children}). Note that if a guard is null, its corresponding\n\t * IBTExecutor is also null.\n\t */\n\tprivate List<BTExecutor> guardsExecutors;\n\t/**\n\t * This List contains the current evaluation status of all the guards. If a\n\t * guard is null, its corresponding status is {@link Status#SUCCESS} (null\n\t * guards are evaluated to true).\n\t */\n\tprivate List<Status> guardsResults;\n\n\t/**\n\t * Creates an ExecutionStaticPriorityList that is able to run a\n\t * ModelStaticPriorityList task and that is managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelStaticPriorityList that this\n\t *            ExecutionStaticPriorityList is going to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this\n\t *            ExecutionStaticPriorityList.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionStaticPriorityList(ModelTask modelTask, BTExecutor executor,\n\t\t\tExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelStaticPriorityList)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelStaticPriorityList.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the first child with active guard. If there is no active guard,\n\t * the spawning process is considered to have failed, so\n\t * {@link #internalTick()} will return {@link Status#FAILURE}. If some\n\t * guards are still running the spawning process is not considered to have\n\t * started yet.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.children = this.getModelTask().getChildren();\n\n\t\t/* Initialize guard executors. */\n\t\tthis.guardsExecutors = new Vector<BTExecutor>();\n\t\tthis.guardsResults = new Vector<Status>();\n\t\tfor (ModelTask child : this.children) {\n\t\t\tif (child.getGuard() != null) {\n\t\t\t\tthis.guardsExecutors.add(new BTExecutor(child.getGuard(), this.getContext()));\n\t\t\t\tthis.guardsResults.add(Status.RUNNING);\n\t\t\t} else {\n\t\t\t\tthis.guardsExecutors.add(null);\n\t\t\t\tthis.guardsResults.add(Status.SUCCESS);\n\t\t\t}\n\t\t}\n\n\t\t/* Evaluate guards. */\n\t\tresetGuardsEvaluation();\n\t\tPair<Status, Integer> activeGuard = evaluateGuards();\n\n\t\t/*\n\t\t * Flag that tells if the static priority list must be inserted into the\n\t\t * list of tickable nodes.\n\t\t */\n\t\tboolean insertIntoTickableNodesList = false;\n\n\t\t/*\n\t\t * If all the guards have failed, the spawning process has also failed.\n\t\t * In such a case, the task must be inserted into the list of tickable\n\t\t * nodes.\n\t\t */\n\t\tif (activeGuard.getFirst() == Status.FAILURE) {\n\t\t\tthis.spawnFailed = true;\n\t\t\tinsertIntoTickableNodesList = true;\n\t\t} else if (activeGuard.getFirst() == Status.RUNNING) {\n\t\t\t/*\n\t\t\t * If not all the guards have been evaluated yet, the spawning\n\t\t\t * process is not considered to have started. In such a case, the\n\t\t\t * task must be inserted into the list of tickable nodes.\n\t\t\t */\n\t\t\tthis.stillNotSpawned = true;\n\t\t\tinsertIntoTickableNodesList = true;\n\t\t} else {\n\t\t\t/*\n\t\t\t * If all the guards have been evaluated and one succeeded, spawn\n\t\t\t * the corresponding child.\n\t\t\t */\n\t\t\tthis.spawnFailed = false;\n\t\t\tthis.stillNotSpawned = false;\n\t\t\tthis.activeChildIndex = activeGuard.getSecond();\n\t\t\tthis.activeChild = this.children.get(this.activeChildIndex).createExecutor(\n\t\t\t\t\tthis.getExecutor(), this);\n\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\tthis.activeChild.spawn(this.getContext());\n\t\t}\n\n\t\t/* Insert into the list of tickable nodes if required. */\n\t\tif (insertIntoTickableNodesList) {\n\t\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t\t}\n\t}\n\n\t/**\n\t * If the spawning process has not finished yet (because there are some\n\t * guards running), then this method keeps evaluating the guards, and\n\t * returns {@link Status#RUNNING}. Whenever there is an active child\n\t * (because the spawning process has finished), its status is returned.\n\t * <p>\n\t * If the spawning process failed, this method just returns\n\t * {@link Status#FAILURE}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\t/* If the spawning process failed, return failure. */\n\t\tif (this.spawnFailed) {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\n\t\t/*\n\t\t * If no child has been spawned yet (not all the guards had completed in\n\t\t * the internalSpawn() method)...\n\t\t */\n\t\tif (this.stillNotSpawned) {\n\t\t\t/* Evaluate guards. */\n\t\t\tPair<Status, Integer> activeGuard = evaluateGuards();\n\n\t\t\t/* If all the guards have failed, return failure. */\n\t\t\tif (activeGuard.getFirst() == Status.FAILURE) {\n\t\t\t\treturn Status.FAILURE;\n\t\t\t} else if (activeGuard.getFirst() == Status.RUNNING) {\n\t\t\t\t/*\n\t\t\t\t * If not all the guards have finished, do no nothing (return\n\t\t\t\t * RUNNING).\n\t\t\t\t */\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t * If all the guards have been evaluated and one succeeded,\n\t\t\t\t * spawn the child. In this case, the static priority list\n\t\t\t\t * must be removed from the list of tickable nodes.\n\t\t\t\t */\n\t\t\t\tthis.spawnFailed = false;\n\t\t\t\tthis.stillNotSpawned = false;\n\t\t\t\tthis.activeChildIndex = activeGuard.getSecond();\n\t\t\t\tthis.activeChild = this.children.get(this.activeChildIndex).createExecutor(\n\t\t\t\t\t\tthis.getExecutor(), this);\n\t\t\t\tthis.activeChild.addTaskListener(this);\n\t\t\t\tthis.activeChild.spawn(this.getContext());\n\t\t\t\t\n\t\t\t\tthis.getExecutor().requestRemovalFromList(BTExecutorList.TICKABLE, this);\n\t\t\t}\n\n\t\t\treturn Status.RUNNING;\n\t\t}\n\n\t\t/* If this point has been reached, there must be an active child. */\n\t\treturn this.activeChild.getStatus();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(jbt.execution.core.ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {\n\t}\n\n\t/**\n\t * Just ticks this task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Just terminates the currently active child (if there is one).\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\t/*\n\t\t * This null check is necessary. Keep in mind that the static priority\n\t\t * list may not have an active child, since the spawning process may\n\t\t * have failed or not started yet. In such a case, if it is terminated,\n\t\t * \"this.activeChild\" will be null.\n\t\t */\n\t\tif (this.activeChild != null) {\n\t\t\tthis.activeChild.terminate();\n\t\t}\n\n\t\t/* Terminate the guards executors. */\n\t\tfor (IBTExecutor guardExecutor : this.guardsExecutors) {\n\t\t\tif (guardExecutor != null) {\n\t\t\t\tguardExecutor.terminate();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Resets the evaluation of all the guards. This method leaves all the guard\n\t * executors ({@link #guardsExecutors}) ready to start again the evaluation\n\t * of the guards. It internally terminates the IBTExecutor of each guard,\n\t * creates a new one, and then ticks it.\n\t */\n\tprivate void resetGuardsEvaluation() {\n\t\tfor (int i = 0; i < this.guardsExecutors.size(); i++) {\n\t\t\tBTExecutor guardExecutor = this.guardsExecutors.get(i);\n\n\t\t\tif (guardExecutor != null) {\n\t\t\t\tguardExecutor.terminate();\n\t\t\t\tthis.guardsResults.set(i, Status.RUNNING);\n\t\t\t\tBTExecutor newExecutor = new BTExecutor(guardExecutor.getBehaviourTree(),\n\t\t\t\t\t\tthis.getContext());\n\t\t\t\tnewExecutor.copyTasksStates(guardExecutor);\n\t\t\t\tnewExecutor.tick();\n\t\t\t\tthis.guardsExecutors.set(i, newExecutor);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Evaluate all the guards that have not finished yet, that is, those whose\n\t * result in {@link #guardsResults} is {@link Status#RUNNING}, by ticking\n\t * them.\n\t * <p>\n\t * If all the guards have finished in failure, this method returns a Pair\n\t * whose first element is {@link Status#FAILURE}. If there is at least one\n\t * guard still being evaluated, the first element of the Pair contains\n\t * {@link Status#RUNNING}. If all the guards have been evaluated and at\n\t * least one has succeeded, the first element of the Pair is\n\t * {@link Status#SUCCESS}, and the second one is the index, over the list of\n\t * guards ({@link #guardsExecutors}) , of the first guard (that with the\n\t * highest priority) that has succeeded.\n\t * \n\t */\n\tprivate Pair<Status, Integer> evaluateGuards() {\n\t\tboolean oneRunning = false;\n\n\t\t/* First, evaluate all the guards that have not finished yet. */\n\t\tfor (int i = 0; i < this.guardsExecutors.size(); i++) {\n\t\t\tIBTExecutor guardExecutor = this.guardsExecutors.get(i);\n\t\t\tif (guardExecutor != null) {\n\t\t\t\tif (this.guardsResults.get(i) == Status.RUNNING) {\n\t\t\t\t\tguardExecutor.tick();\n\t\t\t\t\tthis.guardsResults.set(i, guardExecutor.getStatus());\n\t\t\t\t\tif (this.guardsResults.get(i) == Status.RUNNING) {\n\t\t\t\t\t\toneRunning = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/* If there is at least one still running... */\n\t\tif (oneRunning) {\n\t\t\treturn new Pair<Status, Integer>(Status.RUNNING, -1);\n\t\t}\n\n\t\t/* If all of them have finished we check which one succeeded first. */\n\t\tfor (int i = 0; i < this.guardsResults.size(); i++) {\n\t\t\tif (this.guardsResults.get(i) == Status.SUCCESS) {\n\t\t\t\treturn new Pair<Status, Integer>(Status.SUCCESS, i);\n\t\t\t}\n\t\t}\n\n\t\t/* Otherwise, the evaluation has failed. */\n\t\treturn new Pair<Status, Integer>(Status.FAILURE, -1);\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionDecorator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelDecorator;\n\n/**\n * Base class for all the ExecutionTask subclasses that are able to run\n * decorator tasks (that is, classes that inherit from ModelDecorator).\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ExecutionDecorator extends ExecutionTask {\n\t/**\n\t * Creates an ExecutionDecorator that is able to run a particular\n\t * ModelDecorator task.\n\t * \n\t * @param modelTask\n\t *            the ModelDecorator task to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionDecorator.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionDecorator(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelDecorator)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelDecorator.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionHierarchicalContextManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport jbt.execution.context.HierarchicalContext;\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelHierarchicalContextManager;\nimport jbt.model.task.decorator.ModelDecorator;\n\n/**\n * ExecutionHierarchicalContextManager is the ExecutionTask that knows how to run a\n * ModelHierarchicalContextManager.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionHierarchicalContextManager extends ExecutionDecorator {\n\t/** The child task. */\n\tprivate ExecutionTask child;\n\n\t/**\n\t * Constructs an ExecutionHierarchicalContextManager that knows how to run a\n\t * ModelHierarchicalContextManager.\n\t * \n\t * @param modelTask\n\t *            the ModelHierarchicalContextManager to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionHierarchicalContextManager.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionHierarchicalContextManager(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelHierarchicalContextManager)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelHierarchicalContextManager.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the child task. This method creates a new HierarchicalContext,\n\t * sets its parent to the context of the ExecutionHierarchicalContextManager, and spawns\n\t * the child task using this HierarchicalContext.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tHierarchicalContext newContext = new HierarchicalContext();\n\t\tnewContext.setParent(this.getContext());\n\t\tthis.child = ((ModelDecorator) this.getModelTask()).getChild().createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.child.addTaskListener(this);\n\t\tthis.child.spawn(newContext);\n\t}\n\n\t/**\n\t * Just terminates the child task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tthis.child.terminate();\n\t}\n\n\t/**\n\t * Returns the current status of the child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\treturn this.child.getStatus();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the tass evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionInterrupter.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelInterrupter;\n\n/**\n * ExecutionInterrupter is the ExecutionTask that knows how to run a\n * ModelInterrupter. In order to interrupt the ExecutionInterrupter,\n * {@link #interrupt(Status)} must be called.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionInterrupter extends ExecutionDecorator {\n\t/**\n\t * Flag that tells if the ExecutionInterrupter has already been interrupted.\n\t */\n\tprivate boolean interrupted;\n\t/**\n\t * Status code that this ExecutionInterrupter should return in case it is\n\t * interrupted.\n\t */\n\tprivate Status statusSet;\n\t/**\n\t * The child ExecutionTask of this ExecutionInterrupter.\n\t */\n\tprivate ExecutionTask executionChild;\n\n\t/**\n\t * Creates an ExecutionInterrupter that is able to run a ModelInterrupter\n\t * task and that is managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelInterrupter that this ExecutionInterrupter is going\n\t *            to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this ExecutionInterrupter.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionInterrupter(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelInterrupter)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelInterrupter.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t\tthis.interrupted = false;\n\t}\n\n\t/**\n\t * Spawns its child and registers itself into the list of interrupters of\n\t * the BTExecutor.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.executionChild = ((ModelInterrupter) this.getModelTask()).getChild().createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.executionChild.addTaskListener(this);\n\t\t/*\n\t\t * Register the ExecutionInterrupter so that\n\t\t * ExecutionPerformInterruption can find it.\n\t\t */\n\t\tthis.getExecutor().registerInterrupter(this);\n\t\tthis.executionChild.spawn(this.getContext());\n\t}\n\n\t/**\n\t * Terminates the child task and unregister itself from the list of\n\t * interrupters of the BTExecutor.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\t/*\n\t\t * Unregister the ExecutionInterrupter so that it is no longer available\n\t\t * to ExecutionPerformInterruption.\n\t\t */\n\t\tthis.getExecutor().unregisterInterrupter(this);\n\t\t/*\n\t\t * It is important to cancel any request for insertion that this task\n\t\t * has. If the task has been interrupted, it will have requested to be\n\t\t * inserted into the list of tickable nodes. However, if it is then\n\t\t * terminated, we do not want it to be inserted into the list of\n\t\t * tickable nodes, so the request made in \"interrupt()\" must be\n\t\t * cancelled.\n\t\t */\n\t\tif (this.interrupted) {\n\t\t\tthis.getExecutor().cancelInsertionRequest(BTExecutorList.TICKABLE, this);\n\t\t}\n\n\t\tthis.executionChild.terminate();\n\t}\n\n\t/**\n\t * If the ExecutionInterrupter has been interrupted, returns the status that\n\t * was passed to the {@link #interrupt(Status)} method. Otherwise, returns\n\t * the current status of the child task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tif (this.interrupted) {\n\t\t\t/*\n\t\t\t * Unregister the ExecutionInterrupter so that it is no longer\n\t\t\t * available to ExecutionPerformInterruption.\n\t\t\t */\n\t\t\tthis.getExecutor().unregisterInterrupter(this);\n\t\t\treturn this.statusSet;\n\t\t}\n\t\telse {\n\t\t\tStatus childStatus = this.executionChild.getStatus();\n\t\t\tif (childStatus != Status.RUNNING) {\n\t\t\t\t/*\n\t\t\t\t * If the child has finished, unregister the\n\t\t\t\t * ExecutionInterrupter so that it is no longer available to\n\t\t\t\t * ExecutionPerformInterruption.\n\t\t\t\t */\n\t\t\t\tthis.getExecutor().unregisterInterrupter(this);\n\t\t\t}\n\t\t\treturn childStatus;\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the ExecutionInterrupter evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Interrupts the ExecutionInterrupter. This method causes the\n\t * ExecutionInterrupter to terminate its child and set the status that will\n\t * be returned to <code>status</code>. Also, it requests to be inserted into\n\t * the list of tickable nodes, since the terminated child will no longer\n\t * react to ticks after being terminated.\n\t * <p>\n\t * A task that have not been spawned cannot be interrupted. It should be\n\t * noted that if the task has already been terminated, this method does\n\t * nothing. Also, if the task has already been interrupted, this method does\n\t * nothing too.\n\t * \n\t * @param status\n\t *            the status that the ExecutionInterrupter will return.\n\t */\n\tpublic void interrupt(Status status) {\n\t\tif (!this.interrupted) {\n\t\t\t/*\n\t\t\t * If the task has not been spawned, throw an exception.\n\t\t\t */\n\t\t\tif (!this.getSpawned()) {\n\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\"Cannot interrupt an ExecutionInterrupter that has not been spawned\");\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Also it is important to note that that if the task has been\n\t\t\t * terminated it cannot be interrupted, since by doing so the task\n\t\t\t * would insert itself into the list of tickable nodes (see below),\n\t\t\t * which should not be done since the task has been terminated.\n\t\t\t */\n\t\t\tif (!this.getTerminated()) {\n\t\t\t\tif (status != Status.FAILURE && status != Status.SUCCESS) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\t\"The specified status is not valid. Must be either Status.FAILURE or Status.SUCCESS\");\n\t\t\t\t}\n\n\t\t\t\t/* Terminate the child. */\n\t\t\t\tthis.executionChild.terminate();\n\n\t\t\t\t/*\n\t\t\t\t * It is very important for the ExecutionInterrupter to be\n\t\t\t\t * inserted into the list of tickable nodes. If not, after being\n\t\t\t\t * interrupted, it will not inform its parent about the\n\t\t\t\t * termination of its child. Keep in mind that after terminating\n\t\t\t\t * its child, the child will not react to ticks (actually it\n\t\t\t\t * will leave the list of tickable nodes in the next AI cycle),\n\t\t\t\t * so it has to be the interrupter itself that informs its\n\t\t\t\t * parent about termination.\n\t\t\t\t */\n\t\t\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t\t\t\tthis.interrupted = true;\n\t\t\t\tthis.statusSet = status;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionInverter.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelInverter;\n\n/**\n * ExecutionInverter is the ExecutionTask that knows how to run a ModelInverter.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionInverter extends ExecutionDecorator {\n\t/** The child. */\n\tprivate ExecutionTask child;\n\n\t/**\n\t * Creates an ExecutionInverter that is able to run a ModelInverter task and\n\t * that is managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelInverter that this ExecutionInverter is going to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this ExecutionInverter.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionInverter(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelInverter)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelInverter.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the only child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\t/* Just spawn the only child. */\n\t\tthis.child = ((ModelInverter) this.getModelTask()).getChild().createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.child.addTaskListener(this);\n\t\tthis.child.spawn(this.getContext());\n\t}\n\n\t/**\n\t * Terminates the only child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\t/* Just terminates the only child. */\n\t\tthis.child.terminate();\n\t}\n\n\t/**\n\t * Checks if the only child has already finished. If so, it inverts its\n\t * status code. Otherwise, it returns {@link Status#RUNNING}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\t/* Just inverts the status code. */\n\t\tStatus childStatus = this.child.getStatus();\n\t\tif (childStatus == Status.RUNNING) {\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t\telse if (childStatus == Status.FAILURE || childStatus == Status.TERMINATED) {\n\t\t\treturn Status.SUCCESS;\n\t\t}\n\t\telse {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} so that the ExecutionInverter can evolve\n\t * according to the termination of its child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionLimit.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.TaskStateFactory;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelLimit;\nimport jbt.util.Pair;\n\n/**\n * ExecutionLimit is the ExecutionTask that knows how to run a ModelLimit.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionLimit extends ExecutionDecorator {\n\t/** Maximum number of times that the child task can be executed. */\n\tprivate int maxNumTimes;\n\t/**\n\t * Number of times that the child task has been run so far. Initially, its\n\t * value is restored from the context.\n\t */\n\tprivate int numRunsSoFar;\n\t/**\n\t * The child of this decorator.\n\t */\n\tprivate ExecutionTask child;\n\n\t/**\n\t * Name of the variable that is stored in the context and that represents\n\t * the number of times that the decorator has been run so far.\n\t */\n\tprotected String STATE_VARIABLE_NAME = \"RunsSoFar\";\n\n\t/**\n\t * Creates an ExecutionLimit that knows how to run a ModelLimit.\n\t * \n\t * @param modelTask\n\t *            the ModelLimit to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionLimit.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionLimit(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelLimit)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelLimit.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\n\t\tthis.maxNumTimes = ((ModelLimit) this.getModelTask()).getMaxNumTimes();\n\t\tthis.numRunsSoFar = 0;\n\t}\n\n\t/**\n\t * Spawns the child task if it has not been run more than the maximum\n\t * allowed number of times. Otherwise, it requests to be inserted into the\n\t * list of tickable nodes, since the child is not spawned.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tif (this.numRunsSoFar < this.maxNumTimes) {\n\t\t\tthis.numRunsSoFar++;\n\t\t\tthis.child = ((ModelLimit) this.getModelTask()).getChild().createExecutor(\n\t\t\t\t\tthis.getExecutor(), this);\n\t\t\tthis.child.addTaskListener(this);\n\t\t\tthis.child.spawn(this.getContext());\n\t\t}\n\t\telse {\n\t\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t\t}\n\t}\n\n\t/**\n\t * Terminates the child task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tif (this.child != null) {\n\t\t\tthis.child.terminate();\n\t\t}\n\t}\n\n\t/**\n\t * Returns the status of the child task, or {@link Status#FAILURE} in case\n\t * it could not be spawned.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tif (this.child != null) {\n\t\t\treturn this.child.getStatus();\n\t\t}\n\t\telse {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\t}\n\n\t/**\n\t * Restore from the ITaskState the number of times that the child task of\n\t * this decorator has been run so far. It is read from the variable whose\n\t * name is {@link #STATE_VARIABLE_NAME}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {\n\t\ttry {\n\t\t\tthis.numRunsSoFar = (Integer) state.getStateVariable(STATE_VARIABLE_NAME);\n\t\t}\n\t\tcatch (Exception e) {}\n\t}\n\n\t/**\n\t * Just calls {@link #tick()} to make this task evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Returns an ITaskState witht a variable with name\n\t * {@link #STATE_VARIABLE_NAME} , and whose value is the number of times\n\t * that the child task of this decorator has been run so far.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\tList<Pair<String,Object>> variables=new Vector<Pair<String,Object>>();\n\t\tvariables.add(new Pair<String,Object>(STATE_VARIABLE_NAME, this.numRunsSoFar));\n\t\treturn TaskStateFactory.createTaskState(variables);\n\t}\n\n\t/**\n\t * Returns an ITaskState witht a variable with name\n\t * {@link #STATE_VARIABLE_NAME} , and whose value is the number of times\n\t * that the child task of this decorator has been run so far.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\tList<Pair<String,Object>> variables=new Vector<Pair<String,Object>>();\n\t\tvariables.add(new Pair<String,Object>(STATE_VARIABLE_NAME, this.numRunsSoFar));\n\t\treturn TaskStateFactory.createTaskState(variables);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionRepeat.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelDecorator;\nimport jbt.model.task.decorator.ModelRepeat;\n\n/**\n * ExecutionRepeat is the ExecutionTask that knows how to run a ModelForever.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionRepeat extends ExecutionDecorator {\n\t/** The child task. */\n\tprivate ExecutionTask child;\n\n\t/**\n\t * Constructs an ExecutionRepeat that knows how to run a ModelForever.\n\t * \n\t * @param modelTask\n\t *            the ModelForever to run.\n\t * @param executor\n\t *            the BTExecutor that will manager this ExecutionRepeat.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionRepeat(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelRepeat)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelRepeat.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Just spawns its child task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.child = ((ModelRepeat) this.getModelTask()).getChild().createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.child.addTaskListener(this);\n\t\tthis.child.spawn(this.getContext());\n\t}\n\n\t/**\n\t * Terminates the child task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tthis.child.terminate();\n\t}\n\n\t/**\n\t * If the child task has finished, it spawns it again. Always returns\n\t * {@link Status#RUNNING}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tStatus childStatus = this.child.getStatus();\n\n\t\t/*\n\t\t * If the child has finished, spawn it again\n\t\t */\n\t\tif (childStatus != Status.RUNNING) {\n\t\t\tthis.child = ((ModelDecorator) this.getModelTask()).getChild().createExecutor(\n\t\t\t\t\tthis.getExecutor(), this);\n\t\t\tthis.child.addTaskListener(this);\n\t\t\tthis.child.spawn(this.getContext());\n\t\t}\n\n\t\treturn Status.RUNNING;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the task evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionSafeContextManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport jbt.execution.context.SafeContext;\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelDecorator;\nimport jbt.model.task.decorator.ModelSafeContextManager;\n\n/**\n * ExecutionSafeContextManager is the ExecutionTask that knows how to run a\n * ModelSafeContextManager.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionSafeContextManager extends ExecutionDecorator {\n\t/** The child task. */\n\tprivate ExecutionTask child;\n\n\t/**\n\t * Constructs an ExecutionSafeContextManager that knows how to run a\n\t * ModelSafeContextManager.\n\t * \n\t * @param modelTask\n\t *            the ModelSafeContextManager to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this\n\t *            ExecutionSafeContextManager.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionSafeContextManager(ModelTask modelTask, BTExecutor executor,\n\t\t\tExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelSafeContextManager)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelSafeContextManager.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the child task. This method creates a new SafeContext, and spawns\n\t * the child task using this SafeContext. The input context of the\n\t * SafeContext is that of this ExecutionSafeContextManager task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tSafeContext newContext = new SafeContext(this.getContext());\n\t\tthis.child = ((ModelDecorator) this.getModelTask()).getChild().createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.child.addTaskListener(this);\n\t\tthis.child.spawn(newContext);\n\t}\n\n\t/**\n\t * Just terminates the child task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tthis.child.terminate();\n\t}\n\n\t/**\n\t * Returns the current status of the child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\treturn this.child.getStatus();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {\n\t}\n\n\t/**\n\t * Just calls {@link #tick()} to make the tass evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionSafeOutputContextManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport jbt.execution.context.SafeOutputContext;\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelDecorator;\nimport jbt.model.task.decorator.ModelSafeOutputContextManager;\n\n/**\n * ExecutionSafeOutputContextManager is the ExecutionTask that knows how to run\n * a ModelSafeOutputContextManager.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionSafeOutputContextManager extends ExecutionDecorator {\n\t/** The child task. */\n\tprivate ExecutionTask child;\n\n\t/**\n\t * Constructs an ExecutionSafeOutputContextManager that knows how to run a\n\t * ModelSafeOutputContextManager.\n\t * \n\t * @param modelTask\n\t *            the ModelSafeOutputContextManager to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this\n\t *            ExecutionSafeOutputContextManager.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionSafeOutputContextManager(ModelTask modelTask, BTExecutor executor,\n\t\t\tExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelSafeOutputContextManager)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelSafeOutputContextManager.class.getCanonicalName()\n\t\t\t\t\t+ \" but it inherits from \" + modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the child task. This method creates a new SafeOutputContext, and\n\t * spawns the child task using this SafeContext. The input context of the\n\t * SafeOutputContext is that of this ExecutionSafeOutputContextManager task.\n\t * The list of output variables of the SafeOutputContext is retrieved from\n\t * the ModelSafeOutputContextManager associated to this task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tSafeOutputContext newContext = new SafeOutputContext(this.getContext(),\n\t\t\t\t((ModelSafeOutputContextManager) this.getModelTask()).getOutputVariables());\n\t\tthis.child = ((ModelDecorator) this.getModelTask()).getChild().createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.child.addTaskListener(this);\n\t\tthis.child.spawn(newContext);\n\t}\n\n\t/**\n\t * Just terminates the child task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tthis.child.terminate();\n\t}\n\n\t/**\n\t * Returns the current status of the child.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\treturn this.child.getStatus();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {\n\t}\n\n\t/**\n\t * Just calls {@link #tick()} to make the tass evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionSucceeder.java",
    "content": "/*\r\n * Copyright (C) 2012 Ricardo Juan Palma Durán\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\npackage jbt.execution.task.decorator;\r\n\r\nimport jbt.execution.core.BTExecutor;\r\nimport jbt.execution.core.ExecutionTask;\r\nimport jbt.execution.core.ITaskState;\r\nimport jbt.execution.core.event.TaskEvent;\r\nimport jbt.model.core.ModelTask;\r\nimport jbt.model.task.decorator.ModelSucceeder;\r\n\r\n/**\r\n * ExecutionSucceeder is the ExecutionTask that knows how to run a ModelSucceeder.\r\n * \r\n * @author Ricardo Juan Palma Durán\r\n * \r\n */\r\npublic class ExecutionSucceeder extends ExecutionDecorator {\r\n\t/** The child that is being decorated. */\r\n\tprivate ExecutionTask child;\r\n\r\n\t/**\r\n\t * Creates an ExecutionSucceeder that knows how to run a ModelSucceeder.\r\n\t * \r\n\t * @param modelTask\r\n\t *            the ModelSucceeder to run.\r\n\t * @param executor\r\n\t *            the BTExecutor that will manage this ExecutionSucceeder.\r\n\t * @param parent\r\n\t *            the parent ExecutionTask of this task.\r\n\t */\r\n\tpublic ExecutionSucceeder(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\r\n\t\tsuper(modelTask, executor, parent);\r\n\t\tif (!(modelTask instanceof ModelSucceeder)) {\r\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\r\n\t\t\t\t\t+ ModelSucceeder.class.getCanonicalName() + \" but it inherits from \"\r\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Just spawns its child.\r\n\t * \r\n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\r\n\t */\r\n\tprotected void internalSpawn() {\r\n\t\tthis.child = ((ModelSucceeder) this.getModelTask()).getChild().createExecutor(\r\n\t\t\t\tthis.getExecutor(), this);\r\n\r\n\t\tthis.child.addTaskListener(this);\r\n\t\tthis.child.spawn(this.getContext());\r\n\t}\r\n\r\n\t/**\r\n\t * Just ticks its child.\r\n\t * \r\n\t * @see jbt.execution.core.ExecutionTask#internalTick()\r\n\t */\r\n\tprotected Status internalTick() {\r\n\t\tStatus childStatus = this.child.getStatus();\r\n\r\n\t\tif (childStatus == Status.RUNNING) {\r\n\t\t\treturn Status.RUNNING;\r\n\t\t}\r\n\r\n\t\treturn Status.SUCCESS;\r\n\t}\r\n\r\n\t/**\r\n\t * Does nothing.\r\n\t * \r\n\t * @see jbt.execution.core.ExecutionTask#storeState()\r\n\t */\r\n\tprotected ITaskState storeState() {\r\n\t\treturn null;\r\n\t}\r\n\r\n\t/**\r\n\t * Does nothing.\r\n\t * \r\n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\r\n\t */\r\n\tprotected ITaskState storeTerminationState() {\r\n\t\treturn null;\r\n\t}\r\n\r\n\t/**\r\n\t * Does nothing.\r\n\t * \r\n\t * @see jbt.execution.core.ExecutionTask#restoreState(jbt.execution.core.ITaskState)\r\n\t */\r\n\tprotected void restoreState(ITaskState state) {\r\n\t}\r\n\r\n\t/**\r\n\t * Just ticks the task.\r\n\t * \r\n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\r\n\t */\r\n\tpublic void statusChanged(TaskEvent e) {\r\n\t\tthis.tick();\r\n\t}\r\n\r\n\t/**\r\n\t * Does nothing.\r\n\t * \r\n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\r\n\t */\r\n\tprotected void internalTerminate() {\r\n\t\tthis.child.terminate();\r\n\t}\r\n}\r\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/decorator/ExecutionUntilFail.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelDecorator;\nimport jbt.model.task.decorator.ModelUntilFail;\n\n/**\n * ExecutionUntilFail is the ExecutionTask that knows how to run a\n * ModelUntilFail.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionUntilFail extends ExecutionDecorator {\n\t/** The task that is being decorated. */\n\tprivate ExecutionTask child;\n\n\t/**\n\t * Constructs and ExecutionUntilFail that knows how to run a ModelUntilFail.\n\t * \n\t * @param modelTask\n\t *            the ModelUntilFail that this ExecutionUntilFail will run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionUntilFail.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionUntilFail(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelUntilFail)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelUntilFail.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Spawns the child task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.child = ((ModelDecorator) this.getModelTask()).getChild().createExecutor(\n\t\t\t\tthis.getExecutor(), this);\n\t\tthis.child.addTaskListener(this);\n\t\tthis.child.spawn(this.getContext());\n\t}\n\n\t/**\n\t * Just terminates the child of this task.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tthis.child.terminate();\n\t}\n\n\t/**\n\t * If the child has finished in failure or been terminated, return\n\t * {@link Status#SUCCESS}. Otherwise, {@link Status#RUNNING} is returned. If\n\t * the child has finished successfully, it is spawned again.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tStatus childStatus = this.child.getStatus();\n\n\t\t/*\n\t\t * If the child has finished in failure or been terminated, return\n\t\t * success.\n\t\t */\n\t\tif (childStatus == Status.FAILURE || childStatus == Status.TERMINATED) {\n\t\t\treturn Status.SUCCESS;\n\t\t}\n\t\telse {\n\t\t\t/* If the child has finished successfully, spawn it again. */\n\t\t\tif (childStatus == Status.SUCCESS) {\n\t\t\t\tthis.child = ((ModelDecorator) this.getModelTask()).getChild().createExecutor(\n\t\t\t\t\t\tthis.getExecutor(), this);\n\t\t\t\tthis.child.addTaskListener(this);\n\t\t\t\tthis.child.spawn(this.getContext());\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * In case the child has not finished in failure, return\n\t\t\t * Status.RUNNING.\n\t\t\t */\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the task evolve.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/ExecutionFailure.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelFailure;\n\n/**\n * An ExecutionFailure is the ExecutionTask that knows how to run a\n * ModelFailure.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionFailure extends ExecutionLeaf {\n\t/**\n\t * Constructs an ExecutionFailure that knows how to run a ModelFailure.\n\t * \n\t * @param modelTask\n\t *            the ModelFailure to run.\n\t * @param executor\n\t *            the BTExecutor managing this ExecutionFailure.\n\t * @param parent\n\t *            the parent ExecutionTask.\n\t */\n\tpublic ExecutionFailure(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelFailure)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelFailure.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t}\n\n\t/**\n\t * Returns {@link Status#FAILURE}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\treturn Status.FAILURE;\n\t}\n\n\t/**\n\t * Returns null.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns null.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(jbt.execution.core.ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/ExecutionLeaf.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelLeaf;\n\n/**\n * Base class for all the ExecutionTask classes that are able to run leaf tasks,\n * that is, classes that inherit from ModelLeaf.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ExecutionLeaf extends ExecutionTask {\n\t/**\n\t * Constructs an ExecutionLeaf to run a specific ModelLeaf.\n\t * \n\t * @param modelTask\n\t *            the ModelLeaf to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionLeaf.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionLeaf(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelLeaf)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelLeaf.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing by default, since a leaf task has no children.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/ExecutionPerformInterruption.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.task.decorator.ExecutionInterrupter;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelPerformInterruption;\n\n/**\n * ExecutionPerformInterruption is the ExecutionTask that knows how to run a\n * ModelPerformInterrupter.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionPerformInterruption extends ExecutionLeaf {\n\t/**\n\t * Creates an ExecutionPerformInterruption that is able to run a\n\t * ModelPerformInterruption task and that is managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelPerformInterruption that this\n\t *            ExecutionPerformInterruption is going to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this\n\t *            ExecutionPerformInterruption.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionPerformInterruption(ModelTask modelTask, BTExecutor executor,\n\t\t\tExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelPerformInterruption)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelPerformInterruption.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Calls {@link ExecutionInterrupter#interrupt(Status)} on the\n\t * ExecutionInterrupter associated to this ExecutionPerformInterruption.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t\t/*\n\t\t * First, retrieve the ExecutionInterrupter that is going to be\n\t\t * interrupted.\n\t\t */\n\t\tExecutionInterrupter interrupter = this.getExecutor().getExecutionInterrupter(\n\t\t\t\t((ModelPerformInterruption) this.getModelTask()).getInterrupter());\n\n\t\t/* If we could find the ExecutionInterrupter, interrupt it. */\n\t\tif (interrupter != null) {\n\t\t\tinterrupter.interrupt(((ModelPerformInterruption) this.getModelTask())\n\t\t\t\t\t.getDesiredResult());\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {}\n\n\t/**\n\t * Returns {@link Status#SUCCESS}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\treturn Status.SUCCESS;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/ExecutionSubtreeLookup.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.event.TaskEvent;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelSubtreeLookup;\n\n/**\n * ExecutionSubtreeLookup is the ExecutionTask that knows how to run a\n * ModelExecutionSubtreeLookup.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionSubtreeLookup extends ExecutionLeaf {\n\t/**\n\t * Behaviour tree that is retrieved from the context and that is going to be\n\t * run.\n\t */\n\tprivate ModelTask treeToRun;\n\t/**\n\t * The tree that is actually being run (constructed from {@link #treeToRun}\n\t * ).\n\t */\n\tprivate ExecutionTask executionTree;\n\t/** Flag that tells if the tree could be retrieved from the context. */\n\tprivate boolean treeRetrieved;\n\n\t/**\n\t * Constructs an ExecutionSubtreeLookup that knows how to run a\n\t * ModelSubtreeLookup.\n\t * \n\t * @param modelTask\n\t *            the ModelSubtreeLookup to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionSubtreeLookup.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionSubtreeLookup(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelSubtreeLookup)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelSubtreeLookup.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * This method first retrieve from the context the tree (ModelTask) that is\n\t * going to be emulated by this task. Then, it creates its corresponding\n\t * executor and finally spawns it. If the tree cannot be found in the\n\t * context, does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\t/* Retrieve the tree to run from the context. */\n\t\tthis.treeToRun = this.getContext().getBT(\n\t\t\t\t((ModelSubtreeLookup) this.getModelTask()).getTreeName());\n\n\t\tif (this.treeToRun == null) {\n\t\t\tthis.treeRetrieved = false;\n\t\t\t/*\n\t\t\t * Must request to be inserted into the list of tickable nodes,\n\t\t\t * since no tree has been retrieved and as a result it must be the\n\t\t\t * task the one continuin the work.\n\t\t\t */\n\t\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t\t\tSystem.err.println(\"Could not retrieve tree \"\n\t\t\t\t\t+ ((ModelSubtreeLookup) this.getModelTask()).getTreeName()\n\t\t\t\t\t+ \" from the context. Check if the context has been properly initialized.\");\n\t\t}\n\t\telse {\n\t\t\tthis.treeRetrieved = true;\n\t\t\t/* Compute positions for the retrieved tree. */\n\t\t\tthis.treeToRun.computePositions();\n\n\t\t\tthis.executionTree = this.treeToRun.createExecutor(this.getExecutor(), this);\n\t\t\tthis.executionTree.addTaskListener(this);\n\t\t\tthis.executionTree.spawn(this.getContext());\n\t\t}\n\t}\n\n\t/**\n\t * Just terminates the tree that it is emulating, or does nothing if the\n\t * tree could not be retrieved.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t\tif (this.treeRetrieved) {\n\t\t\tthis.executionTree.terminate();\n\t\t}\n\t}\n\n\t/**\n\t * Returns the status of the tree it is running, or null if the tree could\n\t * not be retrieved.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tif (this.treeRetrieved) {\n\t\t\treturn this.executionTree.getStatus();\n\t\t}\n\t\telse {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Just calls {@link #tick()} to make the task evolve.\n\t * \n\t * @see jbt.execution.task.leaf.ExecutionLeaf#statusChanged(jbt.execution.core.event.TaskEvent)\n\t */\n\tpublic void statusChanged(TaskEvent e) {\n\t\tthis.tick();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/ExecutionSuccess.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelSuccess;\n\n/**\n * An ExecutionSuccess is the ExecutionTask that knows how to run a\n * ModelSuccess.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionSuccess extends ExecutionLeaf {\n\t/**\n\t * Constructs an ExecutionSuccess that knows how to run a ModelSuccess.\n\t * \n\t * @param modelTask\n\t *            the ModelSuccess to run.\n\t * @param executor\n\t *            the BTExecutor managing this ExecutionSuccess.\n\t * @param parent\n\t *            the parent ExecutionTask.\n\t */\n\tpublic ExecutionSuccess(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelSuccess)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelSuccess.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t}\n\n\t/**\n\t * Returns {@link Status#SUCCESS}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\treturn Status.SUCCESS;\n\t}\n\n\t/**\n\t * Returns null.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns null.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(jbt.execution.core.ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/ExecutionVariableRenamer.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelVariableRenamer;\n\n/**\n * EsecutionVariableRenamer is the ExecutionTask that knows how to run a\n * {@link ModelVariableRenamer}.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionVariableRenamer extends ExecutionLeaf {\n\t/** The name of the variable that must be renamed. */\n\tprivate String variableName;\n\t/** The new name for the variable that must be renamed. */\n\tprivate String newVariableName;\n\n\t/**\n\t * Constructs an ExecutionVariableRenamer that knows how to run a\n\t * ModelVariableRenamer.\n\t * \n\t * @param modelTask\n\t *            the ModelVariableRenamer to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this\n\t *            ExecutionVariableRenamer.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionVariableRenamer(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelVariableRenamer)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelVariableRenamer.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\n\t\tthis.variableName = ((ModelVariableRenamer) modelTask).getVariableName();\n\t\tthis.newVariableName = ((ModelVariableRenamer) modelTask).getNewVariableName();\n\t}\n\n\t/**\n\t * Renames the variable in the context.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t    this.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t\tObject variable = this.getContext().getVariable(this.variableName);\n\t\tthis.getContext().clearVariable(this.variableName);\n\t\tthis.getContext().setVariable(this.newVariableName, variable);\n\t}\n\n\t/**\n\t * Returns {@link Status#SUCCESS}.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\treturn Status.SUCCESS;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(jbt.execution.core.ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/ExecutionWait.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.ITaskState;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelWait;\n\n/**\n * ExecutionWait is the ExecutionTask that knows how to run a ModelWait task.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ExecutionWait extends ExecutionLeaf {\n\t/** Duration of the wait task. */\n\tprivate long duration;\n\t/**\n\t * Starting time, measured in nanoseconds. Note that this value is obtained\n\t * by {@link System#nanoTime()}, so it is not related to any notion of\n\t * system or wall-clock time. Therefore, it can only be used to measure time\n\t * intervals.\n\t */\n\tprivate long startTime;\n\n\t/**\n\t * Creates an ExecutionWait that is able to run a ModelWait task and that is\n\t * managed by a BTExecutor.\n\t * \n\t * @param modelTask\n\t *            the ModelWait that this ExecutionWait is going to run.\n\t * @param executor\n\t *            the BTExecutor in charge of running this ExecutionWait.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionWait(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelWait)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelWait.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\n\t\tthis.duration = ((ModelWait) modelTask).getDuration();\n\t}\n\n\t/**\n\t * Starts measuring the time interval.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalSpawn()\n\t */\n\tprotected void internalSpawn() {\n\t\tthis.getExecutor().requestInsertionIntoList(BTExecutorList.TICKABLE, this);\n\t\tthis.startTime = System.nanoTime();\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTerminate()\n\t */\n\tprotected void internalTerminate() {}\n\n\t/**\n\t * Returns Status.SUCCESS or Status.RUNNING depending on whether the task\n\t * has waited long enough or not.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#internalTick()\n\t */\n\tprotected Status internalTick() {\n\t\tlong estimatedTime = System.nanoTime() - this.startTime;\n\n\t\tif ((estimatedTime / 1000000.0) >= this.duration) {\n\t\t\treturn Status.SUCCESS;\n\t\t}\n\t\telse {\n\t\t\treturn Status.RUNNING;\n\t\t}\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#restoreState(ITaskState)\n\t */\n\tprotected void restoreState(ITaskState state) {\n\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeState()\n\t */\n\tprotected ITaskState storeState() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Does nothing.\n\t * \n\t * @see jbt.execution.core.ExecutionTask#storeTerminationState()\n\t */\n\tprotected ITaskState storeTerminationState() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/action/ExecutionAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf.action;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.ExecutionLeaf;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.action.ModelAction;\n\n/**\n * ExecutionAction is the base class of all of the class that are able to run\n * actions in the game (that is, subclasses of ModelAction).\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ExecutionAction extends ExecutionLeaf {\n\t/**\n\t * Constructs an ExecutionAction that knows how to run a ModelAction.\n\t * \n\t * @param modelTask\n\t *            the ModelAction to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionAction.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionAction(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelAction)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelAction.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/execution/task/leaf/condition/ExecutionCondition.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.execution.task.leaf.condition;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.ExecutionLeaf;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.condition.ModelCondition;\n\n/**\n * ExecutionCondition is the base class of all of the class that are able to run\n * conditions in the game (that is, subclasses of ModelCondition).\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ExecutionCondition extends ExecutionLeaf {\n\t/**\n\t * Constructs an ExecutionCondition that knows how to run a ModelCondition.\n\t * \n\t * @param modelTask\n\t *            the ModelCondition to run.\n\t * @param executor\n\t *            the BTExecutor that will manage this ExecutionCondition.\n\t * @param parent\n\t *            the parent ExecutionTask of this task.\n\t */\n\tpublic ExecutionCondition(ModelTask modelTask, BTExecutor executor, ExecutionTask parent) {\n\t\tsuper(modelTask, executor, parent);\n\t\tif (!(modelTask instanceof ModelCondition)) {\n\t\t\tthrow new IllegalArgumentException(\"The ModelTask must subclass \"\n\t\t\t\t\t+ ModelCondition.class.getCanonicalName() + \" but it inherits from \"\n\t\t\t\t\t+ modelTask.getClass().getCanonicalName());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/core/ModelTask.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.core;\n\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\n\n/**\n * ModelTask is a class that models a node (task) of a behaviour tree in an\n * conceptual way. A ModelTask does not have execution capabilities, since it\n * only purpose is to serve as a way of modeling a behaviour tree conceptually.\n * <p>\n * ModelTask is an abstract class, and it just acts as a container of other\n * child tasks, with maybe a guard.\n * <p>\n * As stated above, a ModelTask cannot be run. The idea behind this model is\n * that an external interpreter should be in charge of running the behaviour\n * tree (ModelTask) instead of the task itself. By doing so, there is a clear\n * separation between both the conceptual and execution model, thus allowing to\n * have a unique model shared by many interpreters (which, in other words, means\n * that a single behaviour tree can be run by many entities at the same time).\n * <p>\n * The interpreter that is used to run a behaviour tree -that is, a ModelTask\n * and all the tasks below it- is the BTExecutor class. The BTExecutor class is\n * used to run a ModelTask. A BTExecutor runs a behaviour tree by ticks. This\n * means that the tree is given some time to think and evolve only at certain\n * moments (ticks), and is doing nothing otherwise.\n * <p>\n * Every ModelTask is able to issue an ExecutionTask capable of running it (\n * {@link #createExecutor(BTExecutor, ExecutionTask)}). Actually, the BTExecutor\n * uses ExecutionTask objects in order to run the conceptual behaviour tree. An\n * ExecutionTask is just another type of task that knows how to run its\n * corresponding ModelTask (by interacting with other tasks as well as with the\n * BTExecutor). For instance, a ModelSequence, which represents a sequence task\n * in a behaviour tree, has got an ExecutionTask that knows how to run it, the\n * ExecutionSequence. The <code>createExecutor()</code> method of ModelSequence\n * just returns an instance of ExecutionSequence. Therefore, the\n * <code>createExecutor()</code> method should just return an ExecutionTask that\n * knows how to run the ModelTask.\n * \n * @see ExecutionTask\n * @see BTExecutor\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ModelTask {\n\t/** List of the children of the ModelTask. */\n\tprivate List<ModelTask> children;\n\t/** The position of the ModelTask in the behaviour tree. */\n\tprivate Position position;\n\t/**\n\t * The guard of the ModelTask. It may be null, in which case it will always\n\t * be evaluated to true.\n\t */\n\tprivate ModelTask guard;\n\n\t/**\n\t * The position of a ModelTask in a behaviour tree. It contains the sequence\n\t * of moves that must be performed to go from the root to the node itself.\n\t * Each of the moves of the sequence represents what child of the current\n\t * node must be selected. For instance, if the position represents the\n\t * sequence of moves {1,4,0}, the node that it points to is the first child\n\t * (0) of the fifth child (4) of the second child (1) of the root. En empty\n\t * list of moves represents the root.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static class Position {\n\t\t/**\n\t\t * The list of moves that this position represents.\n\t\t */\n\t\tprivate List<Integer> moves;\n\n\t\t/**\n\t\t * Constructs an Position that contains the moves specified in its\n\t\t * constructor, in the same order. If no move is specified, the Position\n\t\t * will represent an empty sequence of moves.\n\t\t */\n\t\tpublic Position(Integer... moves) {\n\t\t\tthis.moves = new LinkedList<Integer>();\n\n\t\t\tfor (Integer i : moves) {\n\t\t\t\tthis.moves.add(i);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Constructs a Position from a sequence of moves represented as a List.\n\t\t * \n\t\t * @param moves\n\t\t *            the sequence of moves that this Position will represent.\n\t\t */\n\t\tpublic Position(List<Integer> moves) {\n\t\t\tif (moves == null) {\n\t\t\t\tthrow new RuntimeException(\"The list of moves cannot be null\");\n\t\t\t}\n\n\t\t\tthis.moves = new LinkedList<Integer>();\n\t\t\tfor (Integer i : moves) {\n\t\t\t\tthis.moves.add(i);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Constructs a copy of the Position <code>pos</code>.\n\t\t * \n\t\t * @param pos\n\t\t *            the Position that is copied.\n\t\t */\n\t\tpublic Position(Position pos) {\n\t\t\tthis.moves = new LinkedList<Integer>();\n\t\t\tfor (Integer i : pos.moves) {\n\t\t\t\tthis.moves.add(i);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Returns the sequence of moves that this Position represents.\n\t\t * \n\t\t * @return the sequence of moves that this Position represents.\n\t\t */\n\t\tpublic List<Integer> getMoves() {\n\t\t\treturn new LinkedList<Integer>(this.moves);\n\t\t}\n\n\t\t/**\n\t\t * Adds a move to this Position. The move is inserted as the last one of\n\t\t * the sequence.\n\t\t * \n\t\t * @param move\n\t\t *            the move to add.\n\t\t * @return this Position.\n\t\t */\n\t\tpublic Position addMove(Integer move) {\n\t\t\tthis.moves.add(move);\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Adds a list of moves to this Position. The moves are inserted in the\n\t\t * order specified in the <code>moves</code> list.\n\t\t * \n\t\t * @param moves\n\t\t *            the list of moves to add.\n\t\t * @return this Position.\n\t\t */\n\t\tpublic Position addMoves(List<Integer> moves) {\n\t\t\tfor (Integer i : moves) {\n\t\t\t\tthis.moves.add(i);\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Adds the moves of a Position to this Position.\n\t\t * \n\t\t * @param position\n\t\t *            the position whose moves are going to be added to this\n\t\t *            one.\n\t\t * @return this Position.\n\t\t */\n\t\tpublic Position addMoves(Position position) {\n\t\t\taddMoves(position.getMoves());\n\t\t\treturn this;\n\t\t}\n\n\t\t// /**\n\t\t// * Compares this Position object to another one. Let <i>A</i> and\n\t\t// * <i>B</i> be two Position objects. If <i>A</i> is at a higher\n\t\t// level\n\t\t// in\n\t\t// * the tree, then <i>A</i> is less than <i>B</i>. If <i>A</i> is at\n\t\t// a\n\t\t// * lower lever in the tree, then <i>A</i> is greater than <i>B</i>.\n\t\t// If\n\t\t// * <i>A</i> is at the same level in the tree as that of <i>B</i>,\n\t\t// then:\n\t\t// * <ul>\n\t\t// * <li>If <i>A</i> is at the left of <i>B</i>, then <i>A</i> is less\n\t\t// * than <i>B</i>.\n\t\t// * <li>If <i>A</i> represents the same sequence of moves as that of\n\t\t// * <i>B</i>, then <i>A</i> equals <i>B</i>.\n\t\t// * <li>Otherwise, <i>A</i> is greater than <i>B</i>.\n\t\t// * </ul>\n\t\t// *\n\t\t// * @see java.lang.Comparable#compareTo(java.lang.Object)\n\t\t// */\n\t\t// public int compareTo(Position o) {\n\t\t// if (this.moves.size() > o.moves.size()) {\n\t\t// return 1;\n\t\t// } else if (this.moves.size() < o.moves.size()) {\n\t\t// return -1;\n\t\t// } else {\n\t\t// Iterator<Integer> thisIt = this.moves.iterator();\n\t\t// Iterator<Integer> otherIt = o.moves.iterator();\n\t\t//\n\t\t// while (thisIt.hasNext()) {\n\t\t// Integer thisElem = thisIt.next();\n\t\t// Integer otherElem = otherIt.next();\n\t\t//\n\t\t// if (thisElem < otherElem) {\n\t\t// return -1;\n\t\t// } else if (thisElem > otherElem) {\n\t\t// return 1;\n\t\t// }\n\t\t// }\n\t\t//\n\t\t// return 0;\n\t\t// }\n\t\t// }\n\n\t\t/**\n\t\t * \n\t\t * @see java.lang.Object#toString()\n\t\t */\n\t\tpublic String toString() {\n\t\t\tString result = new String();\n\t\t\tif (this.moves.size() != 0) {\n\t\t\t\tfor (Integer i : this.moves) {\n\t\t\t\t\tresult += i + \" \";\n\t\t\t\t}\n\t\t\t\treturn \"[\" + result.substring(0, result.length() - 1) + \"]\";\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn \"[]\";\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Returns true if <code>o</code> is a Position object that contains the\n\t\t * same sequence of moves as that of this. Returns false otherwise.\n\t\t * \n\t\t * @see java.lang.Object#equals(java.lang.Object)\n\t\t */\n\t\tpublic boolean equals(Object o) {\n\t\t\tif (this == o) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!(o instanceof Position)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tPosition oPosition = (Position) o;\n\n\t\t\tList<Integer> thisMoves = this.getMoves();\n\t\t\tList<Integer> oMoves = oPosition.getMoves();\n\n\t\t\tif (oMoves.size() != thisMoves.size()) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tIterator<Integer> thisIt = thisMoves.iterator();\n\t\t\tIterator<Integer> oIt = oMoves.iterator();\n\n\t\t\twhile (thisIt.hasNext()) {\n\t\t\t\tInteger thisElem = thisIt.next();\n\t\t\t\tInteger oElem = oIt.next();\n\n\t\t\t\tif (!thisElem.equals(oElem)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\t/**\n\t\t * \n\t\t * @see java.lang.Object#hashCode()\n\t\t */\n\t\tpublic int hashCode() {\n\t\t\treturn this.moves.hashCode();\n\t\t}\n\t}\n\n\t/**\n\t * Creates a new ModelTask with a guard and several children. The guard may\n\t * be null, in which case it is always evaluated to true. The task may also\n\t * have no children.\n\t * \n\t * @param guard\n\t *            the guard, which may be null.\n\t * @param children\n\t *            the list of children.\n\t */\n\tpublic ModelTask(ModelTask guard, ModelTask... children) {\n\t\tthis.guard = guard;\n\t\tthis.children = new Vector<ModelTask>();\n\n\t\tfor (ModelTask t : children) {\n\t\t\tthis.children.add(t);\n\t\t}\n\n\t\tthis.position = new Position();\n\t}\n\n\t/**\n\t * Returns the list of children of this task, or an empty list if it has no\n\t * children. It should be noted that the children of a task are ordered, and\n\t * the order influences the way the task runs, reason why a List is\n\t * returned. Note that the returned list is the underlying list of children\n\t * used by the task, so it should be used carefully (in general, it should\n\t * never be modified).\n\t * \n\t * @return the list of children of this task.\n\t */\n\tpublic List<ModelTask> getChildren() {\n\t\treturn this.children;\n\t}\n\n\t/**\n\t * Returns the guard of the task, which may be null.\n\t * \n\t * @return the guard of the task, which may be null.\n\t */\n\tpublic ModelTask getGuard() {\n\t\treturn this.guard;\n\t}\n\n\t/**\n\t * Creates a suitable ExecutionTask that will be able to run this ModelTask\n\t * through the management of a BTExecutor.\n\t * \n\t * @param executor\n\t *            the BTExecutor that will manage the returned ExecutionTask.\n\t * @param parent\n\t *            the parent ExecutionTask for the returned ExecutionTask.\n\t * \n\t * @return an ExecutionTask that is able to run this ModelTask.\n\t */\n\tpublic abstract ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent);\n\n\t/**\n\t * Returns the position that this task occupies in the behaviour tree. If it\n\t * has not been computed yet (see {@link #computePositions()}), it returns a\n\t * Position object with both x and y equal to -1.\n\t * \n\t * @return the position that this task occupies in the behaviour tree.\n\t */\n\tpublic Position getPosition() {\n\t\treturn this.position;\n\t}\n\n\t/**\n\t * This method computes the positions of all the tasks of the behaviour tree\n\t * whose root is this node. After calling this method, the positions of all\n\t * the tasks below this one will be available and accessible through\n\t * {@link #getPosition()}.\n\t * <p>\n\t * It is important to note that, when calling this method, this task is\n\t * considered to be the root of the behaviour tree, so its position will be\n\t * set to an empty sequence of moves, with no offset, and the positions of\n\t * the tasks below it will be computed from it.\n\t */\n\tpublic void computePositions() {\n\t\t/* Assume this node is the root of the tree. */\n\t\tthis.position = new Position(new LinkedList<Integer>());\n\n\t\t/*\n\t\t * Set the position of all of the children of this task and recursively\n\t\t * compute the position of the rest of the tasks.\n\t\t */\n\t\tfor (int i = 0; i < this.children.size(); i++) {\n\t\t\tModelTask currentChild = this.children.get(i);\n\t\t\tPosition currentChildPos = new Position(this.position);\n\t\t\tcurrentChildPos.addMove(i);\n\t\t\tcurrentChild.position = currentChildPos;\n\t\t\trecursiveComputePositions(currentChild);\n\t\t}\n\t}\n\n\t/**\n\t * This function searches for a ModelTask according to a particular\n\t * Position.\n\t * <p>\n\t * Conceptually, a Position represents a sequence of moves. This method just\n\t * applies all moves in <code>moves</code> starting from this ModelTask, and\n\t * returns the reached ModelTask, or null in case it does not exist.\n\t * \n\t * @param moves\n\t *            the sequence of moves that must be performed to retrieve the\n\t *            ModelTask.\n\t * @return the ModelTask obtained by moving down the tree according to the\n\t *         sequence of moves <code>moves</code>, or null in case no\n\t *         ModelTask could be found.\n\t */\n\tpublic ModelTask findNode(Position moves) {\n\t\tList<Integer> m = moves.getMoves();\n\n\t\tModelTask currentTask = this;\n\n\t\tfor (Integer currentMove : m) {\n\t\t\tList<ModelTask> children = currentTask.getChildren();\n\n\t\t\tif (currentMove >= children.size()) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tcurrentTask = children.get(currentMove);\n\t\t}\n\n\t\treturn currentTask;\n\t}\n\n\t/**\n\t * This method sets the positions of all tasks below <code>t</code> in the\n\t * tree.\n\t * \n\t * @param t\n\t *            the task whose descendants will be computed their positions.\n\t */\n\tprivate void recursiveComputePositions(ModelTask t) {\n\t\t/*\n\t\t * Set the position of all of the children of this task and recursively\n\t\t * compute the position of the rest of the tasks.\n\t\t */\n\t\tfor (int i = 0; i < t.children.size(); i++) {\n\t\t\tModelTask currentChild = t.children.get(i);\n\t\t\tPosition currentChildPos = new Position(t.getPosition());\n\t\t\tcurrentChildPos.addMove(i);\n\t\t\tcurrentChild.position = currentChildPos;\n\t\t\trecursiveComputePositions(currentChild);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/composite/ModelComposite.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.composite;\n\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelComposite task is a task with several children, whose evaluation\n * depends on the evaluation of its children.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ModelComposite extends ModelTask {\n\t/**\n\t * Constructor.\n\t * <p>\n\t * Constructs a ModelComposite with some children. A ModelComposite must\n\t * have at least one child.\n\t * \n\t * @param guard\n\t *            the guard of the ModelComposite.\n\t * @param children\n\t *            the list of children. Must have at least one element.\n\t */\n\tpublic ModelComposite(ModelTask guard, ModelTask... children) {\n\t\tsuper(guard, children);\n\t\tif (children.length == 0) {\n\t\t\tthrow new IllegalArgumentException(\"The list of children cannot be empty\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/composite/ModelDynamicPriorityList.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.composite;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.composite.ExecutionDynamicPriorityList;\nimport jbt.model.core.ModelTask;\n\n/**\n * This class represents a task with one or more children, only one being\n * evaluated.\n * <p>\n * A ModelDynamicPriorityList has a current active child, which is the task that\n * is being evaluated. The very first time the ModelDynamicPriorityList is\n * spawned, the active child is set to the left most task whose guard is\n * evaluated to true. However, the current active task may change when the task\n * is ticked, according to the guards of the other tasks: if there is a task to\n * the left of the current active task whose guard is true, the latter is\n * terminated, and the new current active task is set to the former. In case\n * there are several tasks to the left of the current active task whose guards\n * are evaluated to true, the current active task will be the left most one.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelDynamicPriorityList extends ModelComposite {\n\t/**\n\t * Creates a ModelDynamicPriorityList task with a guard, and a list of\n\t * children to run. A ModelDynamicPriorityList must have at least one child.\n\t * \n\t * @param guard\n\t *            the guard, which may be null.\n\t * @param children\n\t *            the list of children. Must have at least one element.\n\t */\n\tpublic ModelDynamicPriorityList(ModelTask guard, ModelTask... children) {\n\t\tsuper(guard, children);\n\t}\n\n\t/**\n\t * Returns an ExecutionDynamicPriorityList that is able to run this\n\t * ModelDynamicPriorityList.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionDynamicPriorityList(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/composite/ModelParallel.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.composite;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.composite.ExecutionParallel;\nimport jbt.model.core.ModelTask;\n\n/**\n * ModelParallel is a task that runs all its children simultaneously. A\n * ModelParallel is constantly checking the evolution of its children.\n * <p>\n * The parallel task has a policy that defines the way it behaves. There are to\n * policies for parallel:\n * <ul>\n * <li>{@link ParallelPolicy#SEQUENCE_POLICY}: meaning the parallel behaves like\n * a sequence task, that is, it fails as soon as one of its children fail, and\n * it only succeed if all of its children succeed. Otherwise it is running.\n * <li>{@link ParallelPolicy#SELECTOR_POLICY}: meaning the parallel behaves like\n * a selector task, that is, if succeeds as soon as one of its children succeed,\n * and it only fails of all of its children fail. Otherwise it is running.\n * </ul>\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelParallel extends ModelComposite {\n\t/** Policy of this ModelParallel task. */\n\tprivate ParallelPolicy policy;\n\n\t/**\n\t * Enum defining the different policies for a parallel task (ModelParallel):\n\t * <ul>\n\t * <li>{@link ParallelPolicy#SEQUENCE_POLICY}: means the parallel behaves\n\t * like a sequence task, that is, it fails as soon as one of its children\n\t * fail, and it only succeed if all of its children succeed. Otherwise it is\n\t * running.\n\t * <li>{@link ParallelPolicy#SELECTOR_POLICY}: means the parallel behaves\n\t * like a selector task, that is, if succeeds as soon as one of its children\n\t * succeed, and it only fails of all of its children fail. Otherwise it is\n\t * running.\n\t * </ul>\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static enum ParallelPolicy {\n\t\t/**\n\t\t * Policy meaning that the parallel behaves like a sequence task, that\n\t\t * is, it fails as soon as one of its children fail, and it only succeed\n\t\t * if all of its children succeed.\n\t\t */\n\t\tSEQUENCE_POLICY,\n\t\t/**\n\t\t * Policy meaning the parallel behaves like a selector task, that is, if\n\t\t * succeeds as soon as one of its children succeed, and it only fails of\n\t\t * all of its children fail.\n\t\t */\n\t\tSELECTOR_POLICY\n\t}\n\n\t/**\n\t * Creates a ModelParallel task with a guard, a policy and a list of\n\t * children to run. A ModelParallel must have at least one child.\n\t * \n\t * @param guard\n\t *            the guard, which may be null.\n\t * @param policy\n\t *            the policy for the ModelParallel.\n\t * @param children\n\t *            the list of children. Must have at least one element.\n\t */\n\tpublic ModelParallel(ModelTask guard, ParallelPolicy policy, ModelTask... children) {\n\t\tsuper(guard, children);\n\t\tthis.policy = policy;\n\t}\n\n\t/**\n\t * Returns the policy of this ModelParallel.\n\t * \n\t * @return the policy of this ModelParallel.\n\t */\n\tpublic ParallelPolicy getPolicy() {\n\t\treturn this.policy;\n\t}\n\n\t/**\n\t * Returns an ExecutionParallel that can run this ModelParallel.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionParallel(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/composite/ModelRandomSelector.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.composite;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.composite.ExecutionRandomSelector;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelRandomSelector is a task that behaves just like a ModelSelector, but\n * which walk through its children in a random order. Instead of evaluating its\n * children from left to right, this task evaluate them in a random order.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelRandomSelector extends ModelComposite {\n\t/**\n\t * Creates a ModelRandomSelector with a guard and several children. The list\n\t * of children cannot be empty.\n\t * \n\t * @param guard\n\t *            the guard of the ModelRandomSelector, which may be null.\n\t * @param children\n\t *            the list of children, which cannot be empty.\n\t */\n\tpublic ModelRandomSelector(ModelTask guard, ModelTask... children) {\n\t\tsuper(guard, children);\n\t}\n\n\t/**\n\t * Returns an ExecutionRandomSelector that knows how to run this\n\t * ModelRandomSelector.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionRandomSelector(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/composite/ModelRandomSequence.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.composite;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.composite.ExecutionRandomSequence;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelRandomSequence is a task that behaves just like a ModelSequence, but\n * which walk through its children in a random order. Instead of evaluating its\n * children from left to right, this task evaluate them in a random order.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelRandomSequence extends ModelComposite {\n\t/**\n\t * Creates a ModelRandomSequence with a guard and several children. The list\n\t * of children cannot be empty.\n\t * \n\t * @param guard\n\t *            the guard of the ModelRandomSequence, which may be null.\n\t * @param children\n\t *            the list of children, which cannot be empty.\n\t */\n\tpublic ModelRandomSequence(ModelTask guard, ModelTask... children) {\n\t\tsuper(guard, children);\n\t}\n\n\t/**\n\t * Returns an ExecutionRandomSequence that knows how to run this\n\t * ModelRandomSequence.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionRandomSequence(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/composite/ModelSelector.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.composite;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.composite.ExecutionSelector;\nimport jbt.model.core.ModelTask;\n\n/**\n * This class represents a task with one or more children, which are run\n * sequentially.\n * <p>\n * A selector tries to run all its children sequentially. Therefore, there is an\n * active child task. However, when the current active task fails, the selector\n * does not fail, but goes on to the next child task, which is evaluated. A\n * selector succeeds if one of the tasks succeeds, and fails if all the child\n * tasks fail.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelSelector extends ModelComposite {\n\t/**\n\t * Constructor.\n\t * <p>\n\t * Constructs a ModelSelector with some children. A ModelSelector must have\n\t * at least one child.\n\t * \n\t * @param guard\n\t *            the guard of the ModelSelector, which may be null.\n\t * @param children\n\t *            the list of children. Must have at least one element.\n\t */\n\tpublic ModelSelector(ModelTask guard, ModelTask... children) {\n\t\tsuper(guard, children);\n\t}\n\n\t/**\n\t * Returns an ExecutionSelector that is able to run this ModelSelector.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionSelector(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/composite/ModelSequence.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.composite;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.composite.ExecutionSequence;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModeSequence is a task with one or more children which are evaluated\n * sequentially.\n * <p>\n * A ModeSequence has an active child, which is the child task currently being\n * evaluated. If the execution of the current child finishes successfully, the\n * next child of the sequence is spawned and evaluated. However, if the\n * execution of the currently active child ends in failure, the whole\n * ModeSequence also fails.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelSequence extends ModelComposite {\n\t/**\n\t * Constructor.\n\t * <p>\n\t * Constructs a ModeSequence with some children. A ModeSequence must have at\n\t * least one child.\n\t * \n\t * @param guard\n\t *            the guard of the ModeSequence, which may be null.\n\t * @param children\n\t *            the list of children. Must have at least one element.\n\t */\n\tpublic ModelSequence(ModelTask guard, ModelTask... children) {\n\t\tsuper(guard, children);\n\t}\n\n\t/**\n\t * Returns an ExecutionSequence that can run this ModelSequence.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionSequence(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/composite/ModelStaticPriorityList.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.composite;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.composite.ExecutionStaticPriorityList;\nimport jbt.model.core.ModelTask;\n\n/**\n * This class represents a task with one or more children, only one being\n * evaluated.\n * <p>\n * A ModelStaticPriorityList has a current active child, which is the task that\n * is being evaluated. The very first time the ModelStaticPriorityList is\n * spawned, the active child is set to the left most task whose guard is\n * evaluated to true. From then on, that child will run as normal, and the\n * ModelStaticPriorityList will finish as soon as its child finishes.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelStaticPriorityList extends ModelComposite {\n\t/**\n\t * Creates a ModelStaticPriorityList task with a guard, and a list of\n\t * children to run. A ModelStaticPriorityList must have at least one child.\n\t * \n\t * @param guard\n\t *            the guard, which may be null.\n\t * @param children\n\t *            the list of children. Must have at least one element.\n\t */\n\tpublic ModelStaticPriorityList(ModelTask guard, ModelTask... children) {\n\t\tsuper(guard, children);\n\t}\n\n\t/**\n\t * Returns an ExecutionStaticPriorityList that is able to run this\n\t * ModelStaticPriorityList.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionStaticPriorityList(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelDecorator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport jbt.model.core.ModelTask;\n\n/**\n * This class represents a decorator of a task. A decorator is a task with only\n * one child, whose behavior it modifies. A decorator is used in situations in\n * which we want to execute a particular task but in a little different way.\n * <p>\n * Typical examples of decorators are:\n * \n * <ul>\n * <li>Filters: they decide whether the child task can continue running or not.\n * Some examples of filters are:\n * <ul>\n * <li>Limit filter: which limits the number of times a task can execute.\n * <li>Until fail filter: which repeats a task until it fails.\n * </ul>\n * <li>Inverter: inverts the status code of a task.\n * <li>Semaphore guard: they are associated to resources. If the resource is\n * currently being used by another task, the new task cannot start running, so\n * it fails.\n * </ul>\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ModelDecorator extends ModelTask {\n\t/**\n\t * Constructor.\n\t * <p>\n\t * Constructs a ModelDecorator with one child.\n\t * \n\t * @param guard\n\t *            the guard of the ModelDecorator. which may be null.\n\t * @param child\n\t *            the child of the ModelDecorator.\n\t */\n\tpublic ModelDecorator(ModelTask guard, ModelTask child) {\n\t\tsuper(guard, child);\n\t}\n\n\t/**\n\t * Returns the child of this decorator.\n\t * \n\t * @return the child of this decorator.\n\t */\n\tpublic ModelTask getChild() {\n\t\treturn this.getChildren().get(0);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelHierarchicalContextManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.decorator.ExecutionHierarchicalContextManager;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelHierarchicalContextManager is a decorator that creates a new context for its child\n * task. The context that it creates is a {@link HierarchicalContext}. The\n * parent context of the HierarchicalContext is the context of the\n * ModelHierarchicalContextManager, so if the child task does not find a variable in its\n * context, the context of the ModelHierarchicalContextManager will be used instead.\n * <p>\n * The spawning and updating of the child task are carried out as usual.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelHierarchicalContextManager extends ModelDecorator {\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelHierarchicalContextManager, which may be null.\n\t * @param child\n\t *            the child of the ModelHierarchicalContextManager.\n\t */\n\tpublic ModelHierarchicalContextManager(ModelTask guard, ModelTask child) {\n\t\tsuper(guard, child);\n\t}\n\n\t/**\n\t * Returns an ExecutionContextManager that knows how to run this\n\t * ModelHierarchicalContextManager.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionHierarchicalContextManager(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelInterrupter.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.decorator.ExecutionInterrupter;\nimport jbt.model.core.ModelTask;\n\n/**\n * An ModelInterrupter is a decorator that controls the termination of a child\n * task. An ModelInterrupter simply lets its child task run normally. If the\n * child returns a result, the ModelInterrupter will return it. However, the\n * ModelInterrupter can be asked to terminate the child task and return an\n * specified status when done so.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelInterrupter extends ModelDecorator {\n\t/**\n\t * Constructor.\n\t * <p>\n\t * Constructs a ModelInterrupter with one child.\n\t * \n\t * @param guard\n\t *            the guard of the ModelInterrupter, which may be null.\n\t * @param child\n\t *            the child of the ModelInterrupter.\n\t */\n\tpublic ModelInterrupter(ModelTask guard, ModelTask child) {\n\t\tsuper(guard, child);\n\t}\n\n\t/**\n\t * Returns an ExecutionInterrupter that is able to run this\n\t * ModelInterrupter.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionInterrupter(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelInverter.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.decorator.ExecutionInverter;\nimport jbt.model.core.ModelTask;\n\n/**\n * ModelInverter is a decorator used to invert the status code returned by its\n * child.\n * <p>\n * When the decorated task finishes, its status code gets inverted according to:\n * \n * <ul>\n * <li><code>Status.SUCCESS</code> -> <code>Status.FAILURE</code>.\n * <li><code>Status.FAILURE</code> -> <code>Status.SUCCESS</code>.\n * <li><code>Status.TERMINATED</code> -> <code>Status.SUCCESS</code>.\n * </ul>\n * \n * If the child task has not finished yet, the ModelInverter returns\n * <code>Status.RUNNING</code> (that is, <code>Status.RUNNING</code> is not\n * inverted).\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelInverter extends ModelDecorator {\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelInverter, which may be null.\n\t * @param child\n\t *            the child task to invert.\n\t */\n\tpublic ModelInverter(ModelTask guard, ModelTask child) {\n\t\tsuper(guard, child);\n\t}\n\n\t/**\n\t * Returns an ExecutionInverter that is able to run this ModelInverter.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionInverter(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelLimit.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.decorator.ExecutionLimit;\nimport jbt.model.core.ModelTask;\n\n/**\n * Limit is a decorator that limits the number of times a task can be executed.\n * This decorator is used when a task (the child of the decorator) must be run a\n * maximum number of times. When the maximum number of times is exceeded, the\n * decorator will fail forever on.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelLimit extends ModelDecorator {\n\t/** Maximum number of times that the decorated task can be run. */\n\tprivate int maxNumTimes;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelLimit, which may be null.\n\t * @param maxNumTimes\n\t *            the maximum number of times that <code>child</code> will be\n\t *            run.\n\t * @param child\n\t *            the child of this task.\n\t */\n\tpublic ModelLimit(ModelTask guard, int maxNumTimes, ModelTask child) {\n\t\tsuper(guard, child);\n\t\tthis.maxNumTimes = maxNumTimes;\n\t}\n\n\t/**\n\t * Returns an ExecutionLimit that knows how to run this ModelLimit.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionLimit(this, executor, parent);\n\t}\n\n\t/**\n\t * Returns the maximum number of times that the decorated task can be run.\n\t * \n\t * @return the maximum number of times that the decorated task can be run.\n\t */\n\tpublic int getMaxNumTimes() {\n\t\treturn this.maxNumTimes;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelRepeat.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.execution.task.decorator.ExecutionRepeat;\nimport jbt.model.core.ModelTask;\n\n/**\n * ModelRepeat represents a decorator that runs its child task forever. When its\n * child task finishes, it runs it once more. This decorator always return\n * {@link Status#RUNNING}.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelRepeat extends ModelDecorator {\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelRepeat, which may be null.\n\t * @param child\n\t *            the child that will be run forever.\n\t */\n\tpublic ModelRepeat(ModelTask guard, ModelTask child) {\n\t\tsuper(guard, child);\n\t}\n\n\t/**\n\t * Returns an ExecutionForever that knows how to run this ModelRepeat.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionRepeat(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelSafeContextManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport jbt.execution.context.SafeContext;\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.decorator.ExecutionSafeContextManager;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelSafeContextManager is a decorator that creates a new context for its\n * child task. The context that it creates is a {@link SafeContext}, and the\n * input context that the SafeContext receives is the context of the\n * ModelSafeContextManager.\n * <p>\n * The spawning and updating of the child task are carried out as usual.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelSafeContextManager extends ModelDecorator {\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelSafeContextManager, which may be null.\n\t * @param child\n\t *            the child of the ModelSafeContextManager.\n\t */\n\tpublic ModelSafeContextManager(ModelTask guard, ModelTask child) {\n\t\tsuper(guard, child);\n\t}\n\n\t/**\n\t * Returns an ExecutionSafeContextManager that knows how to run this\n\t * ModelSafeContextManager.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionSafeContextManager(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelSafeOutputContextManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport java.util.List;\n\nimport jbt.execution.context.SafeOutputContext;\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.decorator.ExecutionSafeOutputContextManager;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelSafeOutputContextManager is a decorator that creates a new context for\n * its child task. The context that it creates is a {@link SafeOutputContext},\n * and the input context that the SafeOutputContext receives is that of the\n * ModelSafeOutputContextManager.\n * <p>\n * The spawning and updating of the child task are carried out as usual.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelSafeOutputContextManager extends ModelDecorator {\n\t/**\n\t * The list of output variables of the SafeOutputContext.\n\t */\n\tprivate List<String> outputVariables;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelSafeOutputContextManager, which may be\n\t *            null.\n\t * @param child\n\t *            the child of the ModelSafeOutputContextManager.\n\t * @param outputVariables\n\t *            the list of output variables of the SafeOutputContext that is\n\t *            created.\n\t */\n\tpublic ModelSafeOutputContextManager(ModelTask guard, List<String> outputVariables,\n\t\t\tModelTask child) {\n\t\tsuper(guard, child);\n\t\tthis.outputVariables = outputVariables;\n\t}\n\n\t/**\n\t * Returns an ExecutionSafeOutputContextManager that knows how to run this\n\t * ModelSafeOutputContextManager.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionSafeOutputContextManager(this, executor, parent);\n\t}\n\n\t/**\n\t * Returns a list with the set of output variables of the SafeOutputContext.\n\t * The list cannot be modified.\n\t * \n\t * @return a list with the set of output variables of the SafeOutputContext.\n\t */\n\tpublic List<String> getOutputVariables() {\n\t\treturn this.outputVariables;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelSucceeder.java",
    "content": "/*\r\n * Copyright (C) 2012 Ricardo Juan Palma Durán\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\npackage jbt.model.task.decorator;\r\n\r\nimport jbt.execution.core.BTExecutor;\r\nimport jbt.execution.core.ExecutionTask;\r\nimport jbt.execution.task.decorator.ExecutionSucceeder;\r\nimport jbt.model.core.ModelTask;\r\n\r\n/**\r\n * A ModelSucceeder is a decorator that makes its child succeeds no matter it it actually fails.\r\n * \r\n * @author Ricardo Juan Palma Durán\r\n * \r\n */\r\npublic class ModelSucceeder extends ModelDecorator {\r\n\t/**\r\n\t * Constructor.\r\n\t * \r\n\t * @param guard\r\n\t *            the guard of the ModelSucceeder, which may be null.\r\n\t * @param child\r\n\t *            the child task.\r\n\t */\r\n\tpublic ModelSucceeder(ModelTask guard, ModelTask child) {\r\n\t\tsuper(guard, child);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an ExecutionSucceeder that is able to run this ModelSucceeder.\r\n\t * \r\n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\r\n\t *      ExecutionTask)\r\n\t */\r\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\r\n\t\treturn new ExecutionSucceeder(this, executor, parent);\r\n\t}\r\n}\r\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/decorator/ModelUntilFail.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.decorator;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.decorator.ExecutionUntilFail;\nimport jbt.model.core.ModelTask;\n\n/**\n * The ModelUntilFail class represents a decorator used to run a task as long as\n * it does not fail.\n * <p>\n * ModelUntilFail just keeps executing its child task as long as it does not\n * fail. When the child task fails, ModelUntilFail returns\n * {@link Status#SUCCESS}. Otherwise it returns {@link Status#RUNNING}.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelUntilFail extends ModelDecorator {\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelUntilFail, which may be null.\n\t * @param child\n\t *            the task that will be run until it fails.\n\t */\n\tpublic ModelUntilFail(ModelTask guard, ModelTask child) {\n\t\tsuper(guard, child);\n\t}\n\n\t/**\n\t * Returns an ExecutionUntilFail that knows how to run this ModelUntilFail.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionUntilFail(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/ModelFailure.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.ExecutionFailure;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelFailure represents a task that always fails.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelFailure extends ModelLeaf {\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelFailure, which may be null.\n\t */\n\tpublic ModelFailure(ModelTask guard) {\n\t\tsuper(guard);\n\t}\n\n\t/**\n\t * Returns an {@link ExecutionFailure} that knows how to run this\n\t * ModelFailure.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      jbt.execution.core.ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionFailure(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/ModelLeaf.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf;\n\nimport jbt.model.core.ModelTask;\n\n/**\n * Base class for all the tasks that have no children.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ModelLeaf extends ModelTask {\n\t/**\n\t * Constructs a ModelLeaf with a guard.\n\t * \n\t * @param guard\n\t *            the guard, which may be null.\n\t */\n\tpublic ModelLeaf(ModelTask guard) {\n\t\tsuper(guard);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/ModelPerformInterruption.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.execution.task.leaf.ExecutionPerformInterruption;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.decorator.ModelInterrupter;\n\n/**\n * A ModelPerformInterruption is a task that interacts with a ModelInterrupter\n * decorator, interrupting it when it (the ModelPerformInterruption) is spawned.\n * A ModelPerformInterruption always succeeds when it is spawned. When the\n * ModelInterrupter gets interrupted, the status code it returns is also set by\n * the ModelPerformInterruption.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelPerformInterruption extends ModelLeaf {\n\t/**\n\t * The ModelInterrupter that this ModelPerformInterruption is going to\n\t * interrupt.\n\t */\n\tprivate ModelInterrupter interrupter;\n\t/**\n\t * The status code that the ModelInterrupter should return in case it is\n\t * interrupted.\n\t */\n\tprivate Status desiredResult;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelPerformInterruption, which may be null.\n\t * @param interrupter\n\t *            the ModelInterrupter that this ModelPerformInterruption will\n\t *            interrupt. May be null.\n\t * @param desiredResult\n\t *            the result that the ModelInterrupter should return in case it\n\t *            is interrupted.\n\t */\n\tpublic ModelPerformInterruption(ModelTask guard, ModelInterrupter interrupter,\n\t\t\tStatus desiredResult) {\n\t\tsuper(guard);\n\t\tthis.interrupter = interrupter;\n\t\tthis.desiredResult = desiredResult;\n\t}\n\n\t/**\n\t * Returns an ExecutionPerformInterruption that is able to run this\n\t * ModelPerformInterruption.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionPerformInterruption(this, executor, parent);\n\t}\n\n\t/**\n\t * Sets the interrupter that this PerformInterruption is going to interrupt.\n\t * \n\t * @param interrupter\n\t *            the ModelInterrupter that this PerformInterruption is going to\n\t *            interrupt. May be null.\n\t */\n\tpublic void setInterrupter(ModelInterrupter interrupter) {\n\t\tthis.interrupter = interrupter;\n\t}\n\n\t/**\n\t * Returns the ModelInterrupter that this PerformInterruption is going to\n\t * interrupt, or null if not set.\n\t * \n\t * @return the ModelInterrupter that this PerformInterruption is going to\n\t *         interrupt, or null if not set.\n\t */\n\tpublic ModelInterrupter getInterrupter() {\n\t\treturn this.interrupter;\n\t}\n\n\t/**\n\t * Returns the result that the ModelInterrupter should return in case it is\n\t * interrupted.\n\t * \n\t * @return e result that the ModelInterrupter should return in case it is\n\t *         interrupted.\n\t */\n\tpublic Status getDesiredResult() {\n\t\treturn this.desiredResult;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/ModelSubtreeLookup.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.ExecutionSubtreeLookup;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelSubtreeLookup is a leaf node that emulates the behaviour of another\n * behaviour tree.\n * <p>\n * One of the key features of behaviour trees is that they can be reused in many\n * places. This reusability is implemented through the ModelSubreeLookup task.\n * When a tree <i>A</i> must be reused within another tree <i>B</i>, this task\n * is used to retrieve <i>A</i> and use it within <i>B</i>. Trees are indexed by\n * names, so this task needs the name of the tree that it will emulate.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelSubtreeLookup extends ModelLeaf {\n\t/** The name of the tree that this task is going to emulate. */\n\tprivate String treeName;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the task, which may be null.\n\t * @param treeName\n\t *            the name of the tree that this task is going to emulate.\n\t */\n\tpublic ModelSubtreeLookup(ModelTask guard, String treeName) {\n\t\tsuper(guard);\n\t\tthis.treeName = treeName;\n\t}\n\n\t/**\n\t * Returns an ExecutionSubtreeLookup that is able to run this\n\t * ModelSubtreeLookup.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionSubtreeLookup(this, executor, parent);\n\t}\n\n\t/**\n\t * Returns the name of the tree that this task is going to emulate.\n\t * \n\t * @return the name of the tree that this task is going to emulate.\n\t */\n\tpublic String getTreeName() {\n\t\treturn this.treeName;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/ModelSuccess.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.ExecutionSuccess;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelSuccess represents a task that always succeeds.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelSuccess extends ModelLeaf {\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the ModelSuccess, which may be null.\n\t */\n\tpublic ModelSuccess(ModelTask guard) {\n\t\tsuper(guard);\n\t}\n\n\t/**\n\t * Returns an {@link ExecutionSuccess} that knows how to run this\n\t * ModelSuccess.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      jbt.execution.core.ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionSuccess(this, executor, parent);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/ModelVariableRenamer.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.ExecutionVariableRenamer;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelVariableRenamer is a task that renames a variable of the context. This\n * task just takes one variable of the context and changes its name.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelVariableRenamer extends ModelLeaf {\n\t/** The name of the variable that must be renamed. */\n\tprivate String variableName;\n\t/** The new name for the variable that must be renamed. */\n\tprivate String newVariableName;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param guard\n\t *            the guard of the task, which may be null.\n\t * @param variableName\n\t *            the name of the variable to rename.\n\t * @param newVariableName\n\t *            the new name for the variable.\n\t */\n\tpublic ModelVariableRenamer(ModelTask guard, String variableName, String newVariableName) {\n\t\tsuper(guard);\n\t\tthis.variableName = variableName;\n\t\tthis.newVariableName = newVariableName;\n\t}\n\n\t/**\n\t * Returns a new {@link ExecutionVariableRenamer} that knows how to run this\n\t * ModelVariableRenamer.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      jbt.execution.core.ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionVariableRenamer(this, executor, parent);\n\t}\n\n\t/**\n\t * Returns the name of the variable to rename.\n\t * \n\t * @return the name of the variable to rename.\n\t */\n\tpublic String getVariableName() {\n\t\treturn this.variableName;\n\t}\n\n\t/**\n\t * Returns the new name for the variable that must be renamed.\n\t * \n\t * @return the new name for the variable that must be renamed.\n\t */\n\tpublic String getNewVariableName() {\n\t\treturn this.newVariableName;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/ModelWait.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.ExecutionWait;\nimport jbt.model.core.ModelTask;\n\n/**\n * A ModelWait task is a task that keeps running for a period of time, and then\n * succeeds. The user can specify for how long the ModelWait task should be\n * running. For that period of time, the task will be evaluated to\n * Status.RUNNING. Then, the task will return Status.SUCCESS.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelWait extends ModelLeaf {\n\t/**\n\t * Duration, measured in milliseconds, of the period of time the task will\n\t * be running.\n\t */\n\tprivate long duration;\n\n\t/**\n\t * Constructor. Constructs a ModelWait task that will keep running for\n\t * <code>duration</code> milliseconds.\n\t * \n\t * @param guard\n\t *            the guard of the ModelWait task, which may be null.\n\t * @param duration\n\t *            the ModelWait of the Wait task, in milliseconds.\n\t */\n\tpublic ModelWait(ModelTask guard, long duration) {\n\t\tsuper(guard);\n\t\tthis.duration = duration;\n\t}\n\n\t/**\n\t * Returns an ExecutionWait that can run this ModelWait.\n\t * \n\t * @see jbt.model.core.ModelTask#createExecutor(jbt.execution.core.BTExecutor,\n\t *      ExecutionTask)\n\t */\n\tpublic ExecutionTask createExecutor(BTExecutor executor, ExecutionTask parent) {\n\t\treturn new ExecutionWait(this, executor, parent);\n\t}\n\n\t/**\n\t * Returns the duration of this ModelWait task.\n\t * \n\t * @return the duration of this ModelWait task.\n\t */\n\tpublic long getDuration() {\n\t\treturn this.duration;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/action/ModelAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf.action;\n\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelLeaf;\n\n/**\n * Class representing an abstract basic action to be executed in the game. An\n * action is a task with no children (that is, it is a leaf in the behavior\n * tree) and with no connection to any other task in the tree.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ModelAction extends ModelLeaf {\n\t/**\n\t * Constructs the ModelAction.\n\t * \n\t * @param guard\n\t *            the guard of the ModelAction, which may be null.\n\t */\n\tpublic ModelAction(ModelTask guard) {\n\t\tsuper(guard);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/model/task/leaf/condition/ModelCondition.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.model.task.leaf.condition;\n\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.ModelLeaf;\n\n/**\n * Class representing an abstract condition to be tested within the game.\n * Conditions are tasks with no children (that is, they are leaves in the\n * behavior tree) and with no connection to any other task in the tree.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic abstract class ModelCondition extends ModelLeaf {\n\t/**\n\t * Constructs a ModelCondition.\n\t * \n\t * @param guard\n\t *            the guard of the ModelCondition, which may be null.\n\t */\n\tpublic ModelCondition(ModelTask guard) {\n\t\tsuper(guard);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/ActionsAndConditionsGenerator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator;\n\nimport gatech.mmpm.ActionParameterType;\nimport gatech.mmpm.tools.parseddomain.ParseException;\nimport gatech.mmpm.tools.parseddomain.ParsedAction;\nimport gatech.mmpm.tools.parseddomain.ParsedDomain;\nimport gatech.mmpm.tools.parseddomain.ParsedMethod;\n\nimport jargs.gnu.CmdLineParser;\n\nimport java.io.BufferedWriter;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileWriter;\nimport java.io.IOException;\nimport java.text.DateFormat;\nimport java.text.SimpleDateFormat;\nimport java.util.Date;\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport jbt.execution.task.leaf.action.ExecutionAction;\nimport jbt.model.task.leaf.action.ModelAction;\nimport jbt.model.task.leaf.condition.ModelCondition;\nimport jbt.tools.btlibrarygenerator.lowlevelgenerator.ActionsGenerator;\nimport jbt.tools.btlibrarygenerator.lowlevelgenerator.ConditionsGenerator;\nimport jbt.tools.btlibrarygenerator.util.Util;\n\nimport org.jdom.Document;\nimport org.jdom.Element;\nimport org.jdom.input.SAXBuilder;\n\n/**\n * ActionsAndConditionsGenerator is an application that generates the skeleton\n * for low level actions and conditions specified in one or several MMPM domain\n * files.\n * <p>\n * For every MMPM action, two classes are created: one extending\n * {@link ModelAction}, which conceptually represents the action, and another\n * one extending {@link ExecutionAction}, which represents how the action\n * actually works -whose abstract methods must be completed in order for the\n * action to perform any task at all-.\n * <p>\n * Also, for every MMPM boolean sensor, two classes are created: one extending\n * {@link ModelCondition}, which conceptually represents the condition (sensor),\n * and another one extending {@link ExecutionCondition}, which represents how\n * the condition actually works -whose abstract methods must be completed in\n * order for the condition to perform any task at all-.\n * <p>\n * Created execution classes define getter methods for each MMPM parameter.\n * <p>\n * The syntax of this program is as follows:\n * \n * <pre>\n * ActionsAndConditionsGenerator -c configurationFile [-r relativePath] [-o]\n * </pre>\n * \n * Where <i>configurationFile</i> is an XML file that contains all the\n * information required to run this application. The syntax of such a file is:\n * \n * <pre>\n * &lt;Configuration&gt;\n * \t\n *  &lt;DomainFile&gt;MMPMDomainFile1&lt;/DomainFile&gt;\n *  &lt;DomainFile&gt;MMPMDomainFile2&lt;/DomainFile&gt;\n *  ...\n *  &lt;DomainFile&gt;MMPMDomainFileN&lt;/DomainFile&gt;\n *  \n *  &lt;ModelActionsPackage&gt;Name of the package for generated model action classes&lt;/ModelActionsPackage&gt;\n *  \n *  &lt;ModelConditionsPackage&gt;Name of the package for generated model condition classes&lt;/ModelConditionsPackage&gt;\n *  \n *  &lt;ModelActionsOutputDirectory&gt;Name of the directory where model actions are created&lt;/ModelActionsOutputDirectory&gt;\n *  \n *  &lt;ModelConditionsOutputDirectory&gt;Name of the directory where model conditions are created&lt;/ModelConditionsOutputDirectory&gt;\n *  \n *  &lt;ExecutionActionsPackage&gt;Name of the package for generated execution action classes&lt;/ExecutionActionsPackage&gt;\n *  \n *  &lt;ExecutionConditionsPackage&gt;Name of the package for generated execution condition classes&lt;/ExecutionConditionsPackage&gt;\n *  \n *  &lt;ExecutionActionsOutputDirectory&gt;Name of the directory where execution actions are created&lt;/ExecutionActionsOutputDirectory&gt;\n *  \n *  &lt;ExecutionConditionsOutputDirectory&gt;Name of the directory where execution conditions are created&lt;/ExecutionConditionsOutputDirectory&gt;\n *  \n * &lt;/Configuration&gt;\n * </pre>\n * \n * The order in which the elements are specified is not relevant. If the input\n * files do contain only actions, parameters related to conditions may not be\n * specified, and vice versa.\n * <p>\n * The -r option is used to add a path to the beginning of the files listed in\n * the configuration file; as a result, each file is considered to be placed at\n * the path specified in the -r option. The -r option may not be specified, in\n * which case the files are considered to be at the current execution directory.\n * <p>\n * The -o option (standing for <i>overwrite</i>) is either is specified or not.\n * If it is not specified, generated output files will not overwrite any\n * existing file in the file system, and as a result, the corresponding class\n * file will not be produced in case there is a file with the same name in the\n * file system. If the option -o is specified, then generated output files will\n * overwrite any file in the file system whose name matches.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ActionsAndConditionsGenerator {\n\t/** Tag of the XML configuration file. */\n\tprivate static final String CONFIGURATION_TAG = \"Configuration\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String DOMAIN_FILE_TAG = \"DomainFile\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String MODEL_ACTIONS_PACKAGE_TAG = \"ModelActionsPackage\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String MODEL_CONDITIONS_PACKAGE_TAG = \"ModelConditionsPackage\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String MODEL_ACTIONS_OUTPUT_DIRECTORY_TAG = \"ModelActionsOutputDirectory\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String MODEL_CONDITIONS_OUTPUT_DIRECTORY_TAG = \"ModelConditionsOutputDirectory\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String EXECUTION_ACTIONS_PACKAGE_TAG = \"ExecutionActionsPackage\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String EXECUTION_CONDITIONS_PACKAGE_TAG = \"ExecutionConditionsPackage\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String EXECUTION_ACTIONS_OUTPUT_DIRECTORY_TAG = \"ExecutionActionsOutputDirectory\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String EXECUTION_CONDITIONS_OUTPUT_DIRECTORY_TAG = \"ExecutionConditionsOutputDirectory\";\n\n\tpublic static void main(String[] args) {\n\t\t/* Parse command line arguments. */\n\t\tCmdLineParser parser = new CmdLineParser();\n\t\tCmdLineParser.Option configurationFileOption = parser.addStringOption('c', \"config\");\n\t\tCmdLineParser.Option relativePathOption = parser.addStringOption('r', \"relativepath\");\n\t\tCmdLineParser.Option overwriteOption = parser.addBooleanOption('o', \"overwrite\");\n\n\t\ttry {\n\t\t\tparser.parse(args);\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tprintUsage();\n\t\t\tSystem.exit(1);\n\t\t}\n\n\t\ttry {\n\t\t\t/* Relative path read from the command line. */\n\t\t\tString relativePath = (String) parser.getOptionValue(relativePathOption);\n\n\t\t\tif (relativePath == null) {\n\t\t\t\trelativePath = \"\";\n\t\t\t}\n\t\t\telse {\n\t\t\t\trelativePath = Util.addDirectorySeparator(relativePath);\n\t\t\t}\n\n\t\t\t/* Overwrite option. */\n\t\t\tBoolean overwrite = (Boolean) parser.getOptionValue(overwriteOption, Boolean.FALSE);\n\n\t\t\t/* Open the configuration file and read file names. */\n\t\t\tString configurationFileName;\n\n\t\t\tconfigurationFileName = (String) parser.getOptionValue(configurationFileOption);\n\n\t\t\tif (configurationFileName == null) {\n\t\t\t\tprintUsage();\n\t\t\t\tSystem.exit(1);\n\t\t\t}\n\n\t\t\tFileInputStream file = new FileInputStream(configurationFileName);\n\n\t\t\tSAXBuilder confFileBuilder = new SAXBuilder();\n\t\t\tDocument confFileDoc = confFileBuilder.build(file);\n\t\t\tfile.close();\n\n\t\t\tList<String> fileNames = new LinkedList<String>();\n\t\t\tElement root = confFileDoc.getRootElement();\n\t\t\tList<Element> childrenElements = root.getChildren(DOMAIN_FILE_TAG);\n\n\t\t\tfor (Element e : childrenElements) {\n\t\t\t\tfileNames.add(e.getText());\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * First, we process all MMPM domain files and extract a global list\n\t\t\t * of actions and conditions.\n\t\t\t */\n\t\t\tList<ParsedAction> actions = new LinkedList<ParsedAction>();\n\t\t\tList<ParsedMethod> conditions = new LinkedList<ParsedMethod>();\n\n\t\t\tfor (String currentFileName : fileNames) {\n\t\t\t\ttry {\n\t\t\t\t\tcurrentFileName = relativePath + currentFileName;\n\n\t\t\t\t\tSystem.out.println(\"Reading and parsing \" + currentFileName + \"...\");\n\t\t\t\t\tFileInputStream currentFile = new FileInputStream(currentFileName);\n\n\t\t\t\t\tSAXBuilder mmpmFileBuilder = new SAXBuilder();\n\t\t\t\t\tDocument mmpmDoc = mmpmFileBuilder.build(currentFile);\n\t\t\t\t\tcurrentFile.close();\n\t\t\t\t\tParsedDomain domain = new ParsedDomain();\n\n\t\t\t\t\tdomain.init(mmpmDoc.getRootElement(), null);\n\n\t\t\t\t\tactions.addAll(domain.getActionSet().getAction());\n\t\t\t\t\tfor (ParsedMethod method : domain.getSensorSet().getMethods()) {\n\t\t\t\t\t\tif (method.getReturnedType() == ActionParameterType.BOOLEAN) {\n\t\t\t\t\t\t\tconditions.add(method);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (IOException e) {\n\t\t\t\t\tSystem.out.println(\"Could not open file: \" + currentFileName + \": \"\n\t\t\t\t\t\t\t+ e.getMessage());\n\t\t\t\t}\n\t\t\t\tcatch (ParseException e) {\n\t\t\t\t\tSystem.out.println(\"There were errors while parsing the MMPM domain file \"\n\t\t\t\t\t\t\t+ currentFileName + \": \" + e.getMessage());\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* Now create all the action classes. */\n\t\t\tif (actions.size() != 0) {\n\t\t\t\ttry {\n\t\t\t\t\t/*\n\t\t\t\t\t * Get output directories and packages from the XML\n\t\t\t\t\t * configuration file.\n\t\t\t\t\t */\n\t\t\t\t\tString modelActionsPackage = root.getChildText(MODEL_ACTIONS_PACKAGE_TAG);\n\t\t\t\t\tString modelActionsOutputDirectory = relativePath\n\t\t\t\t\t\t\t+ root.getChildText(MODEL_ACTIONS_OUTPUT_DIRECTORY_TAG);\n\n\t\t\t\t\t/* If directory ends in separator, remove it. */\n\t\t\t\t\tmodelActionsOutputDirectory = Util\n\t\t\t\t\t\t\t.removeDirectorySeparator(modelActionsOutputDirectory);\n\n\t\t\t\t\tString executionActionsPackage = root\n\t\t\t\t\t\t\t.getChildText(EXECUTION_ACTIONS_PACKAGE_TAG);\n\t\t\t\t\tString executionActionsOutputDirectory = relativePath\n\t\t\t\t\t\t\t+ root.getChildText(EXECUTION_ACTIONS_OUTPUT_DIRECTORY_TAG);\n\n\t\t\t\t\t/* If directory ends in separator, remove it. */\n\t\t\t\t\texecutionActionsOutputDirectory = Util\n\t\t\t\t\t\t\t.removeDirectorySeparator(executionActionsOutputDirectory);\n\n\t\t\t\t\tFile modelActionsDirectory = new File(modelActionsOutputDirectory);\n\n\t\t\t\t\t/* Create output directories. */\n\t\t\t\t\tif (!modelActionsDirectory.isDirectory()) {\n\t\t\t\t\t\tSystem.out.println(\"Creating output directory: \"\n\t\t\t\t\t\t\t\t+ modelActionsOutputDirectory + \"...\");\n\t\t\t\t\t\tmodelActionsDirectory.mkdirs();\n\t\t\t\t\t}\n\n\t\t\t\t\tFile executionActionsDirectory = new File(executionActionsOutputDirectory);\n\n\t\t\t\t\tif (!executionActionsDirectory.isDirectory()) {\n\t\t\t\t\t\tSystem.out.println(\"Creating output directory: \"\n\t\t\t\t\t\t\t\t+ executionActionsOutputDirectory + \"...\");\n\t\t\t\t\t\texecutionActionsDirectory.mkdirs();\n\t\t\t\t\t}\n\n\t\t\t\t\t/* Create action classes. */\n\t\t\t\t\tActionsGenerator actionGenerator = new ActionsGenerator();\n\n\t\t\t\t\tfor (ParsedAction currentAction : actions) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t/* Create model action. */\n\t\t\t\t\t\t\tString modelOutputFileName = modelActionsOutputDirectory\n\t\t\t\t\t\t\t\t\t+ File.separator + currentAction.getName() + \".java\";\n\n\t\t\t\t\t\t\tboolean skipModelAction = false;\n\n\t\t\t\t\t\t\tif (Util.fileExists(modelOutputFileName)) {\n\t\t\t\t\t\t\t\tSystem.out.print(modelOutputFileName + \" already exists. \");\n\n\t\t\t\t\t\t\t\tif (overwrite) {\n\t\t\t\t\t\t\t\t\tSystem.out.println(\"It will be overwritten.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tSystem.out.println(modelOutputFileName\n\t\t\t\t\t\t\t\t\t\t\t+ \" will not be generated.\");\n\t\t\t\t\t\t\t\t\tskipModelAction = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!skipModelAction) {\n\t\t\t\t\t\t\t\tSystem.out.println(\"Creating model action class: \"\n\t\t\t\t\t\t\t\t\t\t+ modelOutputFileName + \"...\");\n\t\t\t\t\t\t\t\tString modelActionFileContent = new String();\n\t\t\t\t\t\t\t\tmodelActionFileContent += getModelClassesFileHeader();\n\t\t\t\t\t\t\t\tmodelActionFileContent += \"package \" + modelActionsPackage\n\t\t\t\t\t\t\t\t\t\t+ \";\\n\\n\";\n\n\t\t\t\t\t\t\t\tmodelActionFileContent += actionGenerator.getModelActionClass(\n\t\t\t\t\t\t\t\t\t\tcurrentAction, executionActionsPackage);\n\n\t\t\t\t\t\t\t\tBufferedWriter modelOutputFile = new BufferedWriter(new FileWriter(\n\t\t\t\t\t\t\t\t\t\tmodelOutputFileName));\n\n\t\t\t\t\t\t\t\tmodelOutputFile.write(Util.format(modelActionFileContent));\n\t\t\t\t\t\t\t\tmodelOutputFile.close();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t/* Create execution action. */\n\t\t\t\t\t\t\tString executionOutputFileName = executionActionsOutputDirectory\n\t\t\t\t\t\t\t\t\t+ File.separator + currentAction.getName() + \".java\";\n\n\t\t\t\t\t\t\tboolean skipExecutionAction = false;\n\n\t\t\t\t\t\t\tif (Util.fileExists(executionOutputFileName)) {\n\t\t\t\t\t\t\t\tSystem.out.print(executionOutputFileName + \" already exists. \");\n\n\t\t\t\t\t\t\t\tif (overwrite) {\n\t\t\t\t\t\t\t\t\tSystem.out.println(\"It will be overwritten.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tSystem.out.println(executionOutputFileName\n\t\t\t\t\t\t\t\t\t\t\t+ \" will not be generated.\");\n\t\t\t\t\t\t\t\t\tskipExecutionAction = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!skipExecutionAction) {\n\t\t\t\t\t\t\t\tSystem.out.println(\"Creating execution action class: \"\n\t\t\t\t\t\t\t\t\t\t+ executionOutputFileName + \"...\");\n\t\t\t\t\t\t\t\tBufferedWriter executionOutputFile = new BufferedWriter(\n\t\t\t\t\t\t\t\t\t\tnew FileWriter(executionOutputFileName));\n\t\t\t\t\t\t\t\tString executionActionFileContent = new String();\n\n\t\t\t\t\t\t\t\texecutionActionFileContent += getExecutionClassesFileHeader();\n\n\t\t\t\t\t\t\t\texecutionActionFileContent += \"package \" + executionActionsPackage\n\t\t\t\t\t\t\t\t\t\t+ \";\\n\\n\";\n\n\t\t\t\t\t\t\t\texecutionActionFileContent += actionGenerator\n\t\t\t\t\t\t\t\t\t\t.getExecutionActionClass(currentAction, modelActionsPackage);\n\n\t\t\t\t\t\t\t\texecutionOutputFile.write(Util.format(executionActionFileContent));\n\t\t\t\t\t\t\t\texecutionOutputFile.close();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (IOException e) {\n\t\t\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t\t\t.println(\"There were errors while creating classes for the MMPM action \"\n\t\t\t\t\t\t\t\t\t\t\t+ currentAction.getName() + \": \" + e.getMessage());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t.println(\"There was an unexpected error while creating actions. Actions generation aborted\");\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* Now create all the condition classes. */\n\t\t\tif (conditions.size() != 0) {\n\t\t\t\ttry {\n\t\t\t\t\t/*\n\t\t\t\t\t * Get output directories and packages from the XML\n\t\t\t\t\t * configuration file.\n\t\t\t\t\t */\n\t\t\t\t\tString modelConditionsPackage = root.getChildText(MODEL_CONDITIONS_PACKAGE_TAG);\n\t\t\t\t\tString modelConditionsOutputDirectory = relativePath\n\t\t\t\t\t\t\t+ root.getChildText(MODEL_CONDITIONS_OUTPUT_DIRECTORY_TAG);\n\n\t\t\t\t\t/* If directory ends in separator, remove it. */\n\t\t\t\t\tmodelConditionsOutputDirectory = Util\n\t\t\t\t\t\t\t.removeDirectorySeparator(modelConditionsOutputDirectory);\n\n\t\t\t\t\tString executionConditionsPackage = root\n\t\t\t\t\t\t\t.getChildText(EXECUTION_CONDITIONS_PACKAGE_TAG);\n\t\t\t\t\tString executionConditionsOutputDirectory = relativePath\n\t\t\t\t\t\t\t+ root.getChildText(EXECUTION_CONDITIONS_OUTPUT_DIRECTORY_TAG);\n\n\t\t\t\t\t/* Create ouput directories. */\n\t\t\t\t\tFile modelConditionsDirectory = new File(modelConditionsOutputDirectory);\n\n\t\t\t\t\tif (!modelConditionsDirectory.isDirectory()) {\n\t\t\t\t\t\tSystem.out.println(\"Creating output directory: \"\n\t\t\t\t\t\t\t\t+ modelConditionsOutputDirectory + \"...\");\n\t\t\t\t\t\tmodelConditionsDirectory.mkdirs();\n\t\t\t\t\t}\n\n\t\t\t\t\tFile executionConditionsDirectory = new File(executionConditionsOutputDirectory);\n\n\t\t\t\t\tif (!executionConditionsDirectory.isDirectory()) {\n\t\t\t\t\t\tSystem.out.println(\"Creating output directory: \"\n\t\t\t\t\t\t\t\t+ executionConditionsOutputDirectory + \"...\");\n\t\t\t\t\t\texecutionConditionsDirectory.mkdirs();\n\t\t\t\t\t}\n\n\t\t\t\t\t/* Create condition classes. */\n\t\t\t\t\tConditionsGenerator conditionGenerator = new ConditionsGenerator();\n\n\t\t\t\t\tfor (ParsedMethod currentCondition : conditions) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t/* Create model condition. */\n\t\t\t\t\t\t\tString modelOutputFileName = modelConditionsOutputDirectory\n\t\t\t\t\t\t\t\t\t+ File.separator + currentCondition.getName() + \".java\";\n\n\t\t\t\t\t\t\tboolean skipModelCondition = false;\n\n\t\t\t\t\t\t\tif (Util.fileExists(modelOutputFileName)) {\n\t\t\t\t\t\t\t\tSystem.out.print(modelOutputFileName + \" already exists. \");\n\n\t\t\t\t\t\t\t\tif (overwrite) {\n\t\t\t\t\t\t\t\t\tSystem.out.println(\"It will be overwritten.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tSystem.out.println(modelOutputFileName\n\t\t\t\t\t\t\t\t\t\t\t+ \" will not be generated.\");\n\t\t\t\t\t\t\t\t\tskipModelCondition = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!skipModelCondition) {\n\t\t\t\t\t\t\t\tSystem.out.println(\"Creating model condition class: \"\n\t\t\t\t\t\t\t\t\t\t+ modelOutputFileName + \"...\");\n\t\t\t\t\t\t\t\tBufferedWriter modelOutputFile = new BufferedWriter(new FileWriter(\n\t\t\t\t\t\t\t\t\t\tmodelOutputFileName));\n\n\t\t\t\t\t\t\t\tString modelConditionFileContent = new String();\n\n\t\t\t\t\t\t\t\tmodelConditionFileContent += getModelClassesFileHeader();\n\n\t\t\t\t\t\t\t\tmodelConditionFileContent += \"package \" + modelConditionsPackage\n\t\t\t\t\t\t\t\t\t\t+ \";\\n\\n\";\n\n\t\t\t\t\t\t\t\tmodelConditionFileContent += conditionGenerator\n\t\t\t\t\t\t\t\t\t\t.getModelConditionClass(currentCondition,\n\t\t\t\t\t\t\t\t\t\t\t\texecutionConditionsPackage);\n\n\t\t\t\t\t\t\t\tmodelOutputFile.write(Util.format(modelConditionFileContent));\n\t\t\t\t\t\t\t\tmodelOutputFile.close();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t/* Create execution condition. */\n\n\t\t\t\t\t\t\tboolean skipExecutionCondition = false;\n\n\t\t\t\t\t\t\tString executionOutputFileName = executionConditionsOutputDirectory\n\t\t\t\t\t\t\t\t\t+ File.separator + currentCondition.getName() + \".java\";\n\n\t\t\t\t\t\t\tif (Util.fileExists(executionOutputFileName)) {\n\t\t\t\t\t\t\t\tSystem.out.print(executionOutputFileName + \" already exists. \");\n\n\t\t\t\t\t\t\t\tif (overwrite) {\n\t\t\t\t\t\t\t\t\tSystem.out.println(\"It will be overwritten.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tSystem.out.println(executionOutputFileName\n\t\t\t\t\t\t\t\t\t\t\t+ \" will not be generated.\");\n\t\t\t\t\t\t\t\t\tskipExecutionCondition = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!skipExecutionCondition) {\n\t\t\t\t\t\t\t\tSystem.out.println(\"Creating execution condition class: \"\n\t\t\t\t\t\t\t\t\t\t+ executionOutputFileName + \"...\");\n\t\t\t\t\t\t\t\tString executionConditionFileContent = new String();\n\n\t\t\t\t\t\t\t\texecutionConditionFileContent += getExecutionClassesFileHeader();\n\n\t\t\t\t\t\t\t\texecutionConditionFileContent += \"package \"\n\t\t\t\t\t\t\t\t\t\t+ executionConditionsPackage + \";\\n\\n\";\n\n\t\t\t\t\t\t\t\texecutionConditionFileContent += conditionGenerator\n\t\t\t\t\t\t\t\t\t\t.getExecutionConditionClass(currentCondition,\n\t\t\t\t\t\t\t\t\t\t\t\tmodelConditionsPackage);\n\n\t\t\t\t\t\t\t\tBufferedWriter executionOutputFile = new BufferedWriter(\n\t\t\t\t\t\t\t\t\t\tnew FileWriter(executionOutputFileName));\n\n\t\t\t\t\t\t\t\texecutionOutputFile.write(Util\n\t\t\t\t\t\t\t\t\t\t.format(executionConditionFileContent));\n\t\t\t\t\t\t\t\texecutionOutputFile.close();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (IOException e) {\n\t\t\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t\t\t.println(\"There were errors while creating classes for the MMPM sensor \"\n\t\t\t\t\t\t\t\t\t\t\t+ currentCondition.getName() + \": \" + e.getMessage());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t.println(\"There was an unexpected error while creating conditions. Conditions generation aborted\");\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.println(\"Finished successfully\");\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tSystem.out.println(\"An error occurred while creating actions and conditions classes\");\n\t\t\te.printStackTrace();\n\t\t\tSystem.exit(1);\n\t\t}\n\t}\n\n\t/**\n\t * Prints the usage syntax of the application.\n\t */\n\tprivate static void printUsage() {\n\t\tSystem.out.println(\"Syntax error. Usage: \\n\");\n\t\tSystem.out\n\t\t\t\t.println(\"ActionsAndConditionsGenerator -c configurationFile [-r relativePath] [-o]\\n\");\n\t\tSystem.out.println(\"-\\\"configurationFile\\\" is the configuration file that includes all\");\n\t\tSystem.out.println(\"the information required to run the actions and conditions generator.\");\n\t\tSystem.out\n\t\t\t\t.println(\"-\\\"r\\\" is the root path (directory) of all the files specified within the \");\n\t\tSystem.out.println(\"configuration file. This is an optional option. If not specified, \");\n\t\tSystem.out.println(\"if will be considered to be the current execution directory.\");\n\t\tSystem.out\n\t\t\t\t.println(\"-\\\"o\\\" is an optional option. If not specified, generated output files will not\");\n\t\tSystem.out\n\t\t\t\t.println(\"overwrite files in the file system. As a result, if there are files in the file\");\n\t\tSystem.out\n\t\t\t\t.println(\"system with the same name as those generated by the application, they will not\");\n\t\tSystem.out.println(\"be overwritten. Otherwise, it will overwrite any existing file.\");\n\t}\n\n\t/**\n\t * Returns the file header for model actions and conditions.\n\t */\n\tprivate static String getModelClassesFileHeader() {\n\t\tString result = new String();\n\n\t\tDateFormat dateFormat = new SimpleDateFormat(\"MM/dd/yyyy HH:mm:ss\");\n\t\tDate date = new Date();\n\t\tString currentDate = dateFormat.format(date);\n\n\t\tresult += \"// ******************************************************* \\n\";\n\t\tresult += \"//                   MACHINE GENERATED CODE                \\n\";\n\t\tresult += \"//                       DO NOT MODIFY                     \\n\";\n\t\tresult += \"//                                                         \\n\";\n\t\tresult += \"// Generated on \" + currentDate + \"\\n\";\n\t\tresult += \"// ******************************************************* \\n\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns the file header for execution actions and conditions.\n\t */\n\tprivate static String getExecutionClassesFileHeader() {\n\t\tString result = new String();\n\n\t\tDateFormat dateFormat = new SimpleDateFormat(\"MM/dd/yyyy HH:mm:ss\");\n\t\tDate date = new Date();\n\t\tString currentDate = dateFormat.format(date);\n\n\t\tresult += \"// ******************************************************* \\n\";\n\t\tresult += \"//                   MACHINE GENERATED CODE                \\n\";\n\t\tresult += \"//                MUST BE CAREFULLY COMPLETED              \\n\";\n\t\tresult += \"//                                                         \\n\";\n\t\tresult += \"//           ABSTRACT METHODS MUST BE IMPLEMENTED          \\n\";\n\t\tresult += \"//                                                         \\n\";\n\t\tresult += \"// Generated on \" + currentDate + \"\\n\";\n\t\tresult += \"// ******************************************************* \\n\";\n\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/BTLibraryGenerator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator;\n\nimport gatech.mmpm.ActionParameterType;\nimport gatech.mmpm.tools.parseddomain.ParsedAction;\nimport gatech.mmpm.tools.parseddomain.ParsedDomain;\nimport gatech.mmpm.tools.parseddomain.ParsedMethod;\n\nimport java.io.BufferedWriter;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileWriter;\nimport java.text.DateFormat;\nimport java.text.SimpleDateFormat;\nimport java.util.Date;\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport org.jdom.Document;\nimport org.jdom.Element;\nimport org.jdom.input.SAXBuilder;\n\nimport jargs.gnu.CmdLineParser;\nimport jbt.execution.core.IBTLibrary;\nimport jbt.tools.btlibrarygenerator.util.Util;\n\n/**\n * BTLibraryGenerator is an application that generates a behaviour tree\n * libraries (classes implementing {@link IBTLibrary}) from:\n * <ul>\n * <li>A set of behaviour trees specified in XML files.\n * <li>The MMPM definition of the low level actions and conditions that are used\n * in the trees.\n * </ul>\n * <p>\n * The syntax of this program is as follows:\n * \n * <pre>\n * BTLibraryGenerator -c configurationFile [-r relativePath] [-o]\n * </pre>\n * \n * Where <i>configurationFile</i> is an XML file that contains all the\n * information required to run this application. The syntax of such a file is:\n * \n * <pre>\n * &lt;Configuration&gt;\n * \n *  &lt;BTLibrary&gt;\n * \n *    &lt;BTFile&gt;BTFile1&lt;/BTFile&gt;\n *    &lt;BTFile&gt;BTFile2&lt;/BTFile&gt;\n *    ...\n *    &lt;BTFile&gt;BTFileN&lt;/BTFile&gt;\t\n * \n *    &lt;DomainFile&gt;MMPMDomainFile1&lt;/DomainFile&gt;\n *    &lt;DomainFile&gt;MMPMDomainFile2&lt;/DomainFile&gt;\n *    ...\n *    &lt;DomainFile&gt;MMPMDomainFileN&lt;/DomainFile&gt;\n *  \n *    &lt;ModelActionsPackage&gt;Name of the package where model action classes are placed&lt;/ModelActionsPackage&gt;\n *  \n *    &lt;ModelConditionsPackage&gt;Name of the package where model condition classes are placed&lt;/ModelConditionsPackage&gt;\n *  \n *    &lt;LibraryClassName&gt;Name of the class that is going to be created&lt;/LibraryClassName&gt;\n *  \n *    &lt;LibraryPackage&gt;Name of the package for the generated BT library&lt;/LibraryPackage&gt;\n * \t\n *    &lt;LibraryOutputDirectory&gt;Name of the directory where the generated library is going to be stored&lt;/LibraryOutputDirectory&gt;\n *  \n *    &lt;/BTLibrary&gt;\n *  \n *  &lt;BTLibrary&gt;\n *  ...\n *  &lt;/BTLibrary&gt;\n *  \n *  ...\n * &lt;/Configuration&gt;\n * </pre>\n * \n * <p>\n * The order in which the elements are specified is not relevant.\n * <p>\n * In the file the user can define several BT libraries, each one within the\n * <i>BTLibrary</i> element. For each BT library defined in a <i>BTLibrary</i>\n * element, the program will produce an output file (class implementing the\n * <code>IBTLibrary</code> interface) for the library.\n * <p>\n * The -r option is used to add a path to the beginning of the files listed in\n * the configuration file; as a result, each file is considered to be placed at\n * the path specified in the -r option. The -r option may not be specified, in\n * which case the files are considered to be at the current execution directory.\n * <p>\n * The -o option (standing for <i>overwrite</i>) is either is specified or not.\n * If it is not specified, the generated output files will not overwrite any\n * existing file in the file system, and as a result, a behaviour tree library\n * may not be produced in case there is a file with the same name in the file\n * system. If the option -o is specified, then generated output files will\n * overwrite any file in the file system whose name matches.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTLibraryGenerator {\n\t/** Tag of the XML configuration file. */\n\tprivate static final String CONFIGURATION_TAG = \"Configuration\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String BT_LIBRARY = \"BTLibrary\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String BT_FILE_TAG = \"BTFile\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String DOMAIN_FILE_TAG = \"DomainFile\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String LIBRARY_CLASS_NAME_TAG = \"LibraryClassName\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String LIBRARY_OUTPUT_DIRECTORY_TAG = \"LibraryOutputDirectory\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String LIBRARY_PACKAGE_TAG = \"LibraryPackage\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String MODEL_ACTIONS_PACKAGE_TAG = \"ModelActionsPackage\";\n\t/** Tag of the XML configuration file. */\n\tprivate static final String MODEL_CONDITIONS_PACKAGE_TAG = \"ModelConditionsPackage\";\n\n\tpublic static void main(String[] args) {\n\t\t/* Parse command line arguments. */\n\t\tCmdLineParser parser = new CmdLineParser();\n\t\tCmdLineParser.Option configurationFileOption = parser.addStringOption('c', \"config\");\n\t\tCmdLineParser.Option relativePathOption = parser.addStringOption('r', \"relativepath\");\n\t\tCmdLineParser.Option overwriteOption = parser.addBooleanOption('o', \"overwrite\");\n\n\t\ttry {\n\t\t\tparser.parse(args);\n\t\t} catch (Exception e) {\n\t\t\tprintUsage();\n\t\t\tSystem.exit(1);\n\t\t}\n\n\t\ttry {\n\t\t\t/* Read relative path from command line. */\n\t\t\tString relativePath = (String) parser.getOptionValue(relativePathOption);\n\n\t\t\tif (relativePath == null) {\n\t\t\t\trelativePath = \"\";\n\t\t\t} else {\n\t\t\t\trelativePath = Util.addDirectorySeparator(relativePath);\n\t\t\t}\n\n\t\t\t/* Overwrite option. */\n\t\t\tBoolean overwrite = (Boolean) parser.getOptionValue(overwriteOption, Boolean.FALSE);\n\n\t\t\t/*\n\t\t\t * Open the configuration file and read behaviour trees file names.\n\t\t\t */\n\t\t\tString configurationFileName;\n\n\t\t\tconfigurationFileName = (String) parser.getOptionValue(configurationFileOption);\n\n\t\t\tif (configurationFileName == null) {\n\t\t\t\tprintUsage();\n\t\t\t\tSystem.exit(1);\n\t\t\t}\n\n\t\t\tFileInputStream file = new FileInputStream(configurationFileName);\n\n\t\t\tSAXBuilder confFileBuilder = new SAXBuilder();\n\t\t\tDocument confFileDoc = confFileBuilder.build(file);\n\t\t\tfile.close();\n\n\t\t\t/*\n\t\t\t * Parse and create all the libraries specified in the configuration\n\t\t\t * file.\n\t\t\t */\n\t\t\tElement root = confFileDoc.getRootElement();\n\t\t\tList<Element> btLibrariesDescription = root.getChildren(BT_LIBRARY);\n\n\t\t\tfor (Element currentBTLibrary : btLibrariesDescription) {\n\t\t\t\ttry {\n\t\t\t\t\t/*\n\t\t\t\t\t * Read library class name, packages and output directory\n\t\t\t\t\t * from the configuration file.\n\t\t\t\t\t */\n\t\t\t\t\tSystem.out.print(\"Creating next BT library \");\n\n\t\t\t\t\tString libraryClassName = currentBTLibrary.getChildText(LIBRARY_CLASS_NAME_TAG);\n\n\t\t\t\t\tif (libraryClassName == null) {\n\t\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t\t.println(\"There were errors while parsing the configuration file: a name for the BT library class must be specified\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tSystem.out.println(\"\\\"\" + libraryClassName + \"\\\"...\");\n\n\t\t\t\t\tString libraryDirectory = relativePath\n\t\t\t\t\t\t\t+ currentBTLibrary.getChildText(LIBRARY_OUTPUT_DIRECTORY_TAG);\n\n\t\t\t\t\tlibraryDirectory = Util.removeDirectorySeparator(libraryDirectory);\n\n\t\t\t\t\tString libraryPackage = currentBTLibrary.getChildText(LIBRARY_PACKAGE_TAG);\n\n\t\t\t\t\tif (libraryPackage == null) {\n\t\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t\t.println(\"There were errors while parsing the configuration file: a name for the BT library Java package must be specified\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tString modelActionsPackage = currentBTLibrary\n\t\t\t\t\t\t\t.getChildText(MODEL_ACTIONS_PACKAGE_TAG);\n\n\t\t\t\t\tif (modelActionsPackage == null) {\n\t\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t\t.println(\"There were errors while parsing the configuration file: the name of the model low level actions Java package must be specified\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tString modelConditionsPackage = currentBTLibrary\n\t\t\t\t\t\t\t.getChildText(MODEL_CONDITIONS_PACKAGE_TAG);\n\n\t\t\t\t\tif (modelConditionsPackage == null) {\n\t\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t\t.println(\"There were errors while parsing the configuration file: the name of the model low level conditions Java package must be specified\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t/* Read the names of the files that contain the BTs. */\n\t\t\t\t\tList<String> btFileNames = new LinkedList<String>();\n\n\t\t\t\t\tList<Element> childrenElements = currentBTLibrary.getChildren(BT_FILE_TAG);\n\n\t\t\t\t\tfor (Element e : childrenElements) {\n\t\t\t\t\t\tbtFileNames.add(relativePath + e.getText());\n\t\t\t\t\t}\n\n\t\t\t\t\t/*\n\t\t\t\t\t * Now read all the domain actions and conditions (boolean\n\t\t\t\t\t * conditions) stored in domain files.\n\t\t\t\t\t */\n\t\t\t\t\tList<ParsedAction> actions = new LinkedList<ParsedAction>();\n\t\t\t\t\tList<ParsedMethod> conditions = new LinkedList<ParsedMethod>();\n\t\t\t\t\tList<String> domainFileNames = new LinkedList<String>();\n\n\t\t\t\t\tchildrenElements = currentBTLibrary.getChildren(DOMAIN_FILE_TAG);\n\n\t\t\t\t\tfor (Element e : childrenElements) {\n\t\t\t\t\t\tdomainFileNames.add(e.getText());\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (String domainFile : domainFileNames) {\n\t\t\t\t\t\t/* Get the parsed domain of the current file. */\n\t\t\t\t\t\tdomainFile = relativePath + domainFile;\n\t\t\t\t\t\tSystem.out.println(\"Reading and parsing \" + domainFile + \"...\");\n\t\t\t\t\t\tFileInputStream currentFile = new FileInputStream(domainFile);\n\n\t\t\t\t\t\tSAXBuilder mmpmFileBuilder = new SAXBuilder();\n\t\t\t\t\t\tDocument mmpmDoc = mmpmFileBuilder.build(currentFile);\n\t\t\t\t\t\tcurrentFile.close();\n\t\t\t\t\t\tParsedDomain domain = new ParsedDomain();\n\t\t\t\t\t\tdomain.init(mmpmDoc.getRootElement(), null);\n\t\t\t\t\t\tactions.addAll(domain.getActionSet().getAction());\n\t\t\t\t\t\tList<ParsedMethod> booleanSensors = new LinkedList<ParsedMethod>();\n\t\t\t\t\t\tfor (ParsedMethod sensor : domain.getSensorSet().getMethods()) {\n\t\t\t\t\t\t\tif (sensor.getReturnedType() == ActionParameterType.BOOLEAN) {\n\t\t\t\t\t\t\t\tbooleanSensors.add(sensor);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconditions.addAll(booleanSensors);\n\t\t\t\t\t}\n\n\t\t\t\t\t/* Now generate the library. */\n\t\t\t\t\tString outputFileName = libraryDirectory + File.separator + libraryClassName\n\t\t\t\t\t\t\t+ \".java\";\n\n\t\t\t\t\tif (Util.fileExists(outputFileName)) {\n\t\t\t\t\t\tSystem.out.print(outputFileName + \" already exists. \");\n\n\t\t\t\t\t\tif (overwrite) {\n\t\t\t\t\t\t\tSystem.out.println(\"It will be overwritten.\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tSystem.out.println(\"The behaviour tree library will not be generated.\");\n\t\t\t\t\t\t\tSystem.out.println(\"Finished\");\n\t\t\t\t\t\t\tSystem.exit(0);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tSystem.out.println(\"Creating library \" + outputFileName + \"...\");\n\t\t\t\t\tString outputFileContent = new String();\n\n\t\t\t\t\toutputFileContent += getClassFileHeader();\n\n\t\t\t\t\toutputFileContent += \"package \" + libraryPackage + \";\\n\\n\";\n\t\t\t\t\tjbt.tools.btlibrarygenerator.librarygenerator.BTLibraryGenerator generator = new jbt.tools.btlibrarygenerator.librarygenerator.BTLibraryGenerator();\n\t\t\t\t\toutputFileContent += generator.getBTLibraryDeclaration(libraryClassName,\n\t\t\t\t\t\t\tmodelActionsPackage, modelConditionsPackage, actions, conditions,\n\t\t\t\t\t\t\tbtFileNames);\n\n\t\t\t\t\t/* And create the output file for it. */\n\t\t\t\t\tFile libraryOutputDirectory = new File(libraryDirectory);\n\n\t\t\t\t\tif (!libraryOutputDirectory.isDirectory()) {\n\t\t\t\t\t\tlibraryOutputDirectory.mkdirs();\n\t\t\t\t\t}\n\n\t\t\t\t\tBufferedWriter outputFile = new BufferedWriter(new FileWriter(outputFileName));\n\n\t\t\t\t\toutputFile.write(Util.format(outputFileContent));\n\n\t\t\t\t\toutputFile.close();\n\n\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t.println(\"\\\"\" + libraryClassName + \"\\\"\" + \" was successfully created\");\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tSystem.out\n\t\t\t\t\t\t\t.println(\"There was an unexpected error while creating the current BT library. Skipped to next\");\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tSystem.out\n\t\t\t\t\t.println(\"There was an unrecoverable error while creating the BT libraries. Program aborted\");\n\t\t\te.printStackTrace();\n\t\t\tSystem.exit(1);\n\t\t}\n\t}\n\n\t/**\n\t * Prints the usage syntax of the application.\n\t */\n\tprivate static void printUsage() {\n\t\tSystem.out.println(\"Syntax error. Usage: \\n\");\n\t\tSystem.out.println(\"BTLibraryGenerator -c configurationFile [-r relativePath] [-o]\");\n\t\tSystem.out.println(\"-\\\"configurationFile\\\" is the configuration file that includes all\");\n\t\tSystem.out.println(\"the information required to run the behaviour tree library generator.\");\n\t\tSystem.out\n\t\t\t\t.println(\"-\\\"r\\\" is the root path (directory) of all the files specified within the \");\n\t\tSystem.out.println(\"configuration file. This is an optional option. If not specified, \");\n\t\tSystem.out.println(\"if will be considered to be the current execution directory.\");\n\t\tSystem.out\n\t\t\t\t.println(\"-\\\"o\\\" is an optional option. If not specified, the generated output files will not\");\n\t\tSystem.out\n\t\t\t\t.println(\"overwrite files in the file system, and as a result, a behaviour tree library\");\n\t\tSystem.out\n\t\t\t\t.println(\"may not be produced in case there is a file with the same name in the file system\");\n\t\tSystem.out.println(\"system. Otherwise, it will overwrite any existing file.\");\n\t}\n\n\t/**\n\t * Returns the file header for the BT library.\n\t */\n\tprivate static String getClassFileHeader() {\n\t\tString result = new String();\n\n\t\tDateFormat dateFormat = new SimpleDateFormat(\"MM/dd/yyyy HH:mm:ss\");\n\t\tDate date = new Date();\n\t\tString currentDate = dateFormat.format(date);\n\n\t\tresult += \"// ******************************************************* \\n\";\n\t\tresult += \"//                   MACHINE GENERATED CODE                \\n\";\n\t\tresult += \"//                       DO NOT MODIFY                     \\n\";\n\t\tresult += \"//                                                         \\n\";\n\t\tresult += \"// Generated on \" + currentDate + \"\\n\";\n\t\tresult += \"// ******************************************************* \\n\";\n\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/librarygenerator/BTLibraryGenerationException.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator.librarygenerator;\n\n/**\n * Exception thrown when there is an error creating an IBTLibrary.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTLibraryGenerationException extends Exception {\n\tprivate static final long serialVersionUID = 1L;\n\n\tpublic BTLibraryGenerationException(String message) {\n\t\tsuper(message);\n\t}\n\n\tpublic BTLibraryGenerationException(String message, Throwable cause) {\n\t\tsuper(message, cause);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/librarygenerator/BTLibraryGenerator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator.librarygenerator;\n\nimport gatech.mmpm.tools.parseddomain.ParsedAction;\nimport gatech.mmpm.tools.parseddomain.ParsedMethod;\n\nimport java.io.FileInputStream;\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.NoSuchElementException;\n\nimport org.jdom.Document;\nimport org.jdom.Element;\nimport org.jdom.input.SAXBuilder;\n\nimport jbt.execution.core.IBTLibrary;\nimport jbt.model.core.ModelTask;\nimport jbt.tools.btlibrarygenerator.modelbtgenerator.ModelBTGenerator;\nimport jbt.util.Pair;\n\n/**\n * BTLibraryGenerator is used for generating String expressions representing the\n * declaration of a Java class that implements the {@link IBTLibrary} interface,\n * which also includes a list of behaviour trees that can be accessed.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTLibraryGenerator {\n\t/**\n\t * The name of the class of the elements through which the iterator of\n\t * IBTLibrary iterates.\n\t */\n\tprivate static final String ITERABLE_ELEMENTS_CLASS_NAME = Pair.class.getCanonicalName() + \"<\"\n\t\t\t+ String.class.getCanonicalName() + \", \" + ModelTask.class.getCanonicalName() + \">\";\n\n\t/**\n\t * The name of the class of the iterator of the IBTLibrary.\n\t */\n\tprivate static final String ITERATOR_CLASS_NAME = Iterator.class.getCanonicalName() + \"<\"\n\t\t\t+ ITERABLE_ELEMENTS_CLASS_NAME + \">\";\n\n\t/** Attribute \"name\" of the BT XML file. */\n\tprivate static final String NAME_ATTR = \"name\";\n\n\t/**\n\t * This method creates an String representing an expression that declares a\n\t * class that implements the {@link IBTLibrary} interface and contains all\n\t * the behaviour trees in the files specified in <code>treeFileNames</code>.\n\t * The created library will have <code>libraryClassName</code> as name.\n\t * <p>\n\t * In order to generate the expression for the library, some additional\n\t * information must be provided:\n\t * <ul>\n\t * <li><code>actionsPackageName</code> is the name of the Java package that\n\t * contains all the low level actions that are used in the tree.\n\t * <li><code>conditionsPackageName</code> is the name of the Java package\n\t * that contains all the low level conditions that are used in the tree.\n\t * <li><code>actionsDefinition</code> is a list containing the MMPM\n\t * definition of all the low level actions that are used in the tree.\n\t * <li><code>conditionsDefinition</code> is a list containing the MMPM\n\t * definition of all the low level conditions that are used in the tree.\n\t * </ul>\n\t * \n\t * @param libraryClassName\n\t *            name of the class that will be generated.\n\t * @param actionsPackageName\n\t *            name of the Java package that contains all the low level\n\t *            actions that are used in the tree.\n\t * @param conditionsPackageName\n\t *            name of the Java package that contains all the low level\n\t *            conditions that are used in the tree.\n\t * @param actionsDefinition\n\t *            list containing the MMPM definition of all the low level\n\t *            actions that are used in the tree.\n\t * @param conditionsDefinition\n\t *            list containing the MMPM definition of all the low level\n\t *            conditions that are used in the tree.\n\t * @param treeFileNames\n\t *            names of the files that contain all the behaviour trees that\n\t *            the generated library will contain.\n\t * @return a String as described above.\n\t * @throws BTLibraryGenerationException\n\t *             if there is an error creating the library.\n\t */\n\tpublic String getBTLibraryDeclaration(String libraryClassName, String actionsPackageName,\n\t\t\tString conditionsPackageName, List<ParsedAction> actionsDefinition,\n\t\t\tList<ParsedMethod> conditionsDefinition, List<String> treeFileNames)\n\t\t\tthrows BTLibraryGenerationException {\n\n\t\ttry {\n\t\t\tString result = new String();\n\n\t\t\tresult += \"/** BT library that includes the trees read from the following files:\\n<ul>\";\n\n\t\t\tfor (String file : treeFileNames) {\n\t\t\t\tresult += \"<li>\" + file + \"</li>\\n\";\n\t\t\t}\n\n\t\t\tresult += \"</ul>*/\";\n\n\t\t\t/* Class header. */\n\t\t\tresult += \"public class \" + libraryClassName + \" implements \"\n\t\t\t\t\t+ IBTLibrary.class.getCanonicalName() + \"{\\n\";\n\n\t\t\t/*\n\t\t\t * Node declare all the behaviour trees as static variables. First,\n\t\t\t * we declare them. Then we will generate appropriate expressions\n\t\t\t * for them.\n\t\t\t */\n\t\t\tList<String> treeNames = new LinkedList<String>();\n\n\t\t\tfor (String fileName : treeFileNames) {\n\t\t\t\tString treeName = getTreeName(fileName);\n\t\t\t\ttreeNames.add(treeName);\n\t\t\t\tresult += \"/**Tree generated from file \" + fileName + \".*/\";\n\t\t\t\tresult += \"private static \" + ModelTask.class.getCanonicalName() + \" \" + treeName\n\t\t\t\t\t\t+ \";\\n\";\n\t\t\t}\n\n\t\t\tresult += \"\\n\";\n\n\t\t\tresult += \"/*Static initialization of all the trees.*/\\n\";\n\n\t\t\tresult += \"static{\\n\";\n\n\t\t\t/* Now we generate expressions for each behaviour tree. */\n\t\t\tModelBTGenerator generator = new ModelBTGenerator();\n\n\t\t\tIterator<String> fileNamesIt = treeFileNames.iterator();\n\t\t\tIterator<String> treeNamesIt = treeNames.iterator();\n\n\t\t\twhile (fileNamesIt.hasNext()) {\n\t\t\t\tString treeVariableName = treeNamesIt.next();\n\t\t\t\tString fileName = fileNamesIt.next();\n\n\t\t\t\tString modelBTDeclaration = generator.getModelBTDeclaration(treeVariableName,\n\t\t\t\t\t\tfileName, actionsPackageName, conditionsPackageName, actionsDefinition,\n\t\t\t\t\t\tconditionsDefinition, false);\n\n\t\t\t\tresult += modelBTDeclaration + \"\\n\\n\";\n\t\t\t}\n\n\t\t\tresult += \"}\\n\\n\";\n\n\t\t\t/* Adding the getBT() method of the IBTLibrary interface. */\n\t\t\tresult += getGetBTMethod(treeNames) + \"\\n\\n\";\n\n\t\t\t/*\n\t\t\t * Adding the iterator() method if the Iterable interface (which is\n\t\t\t * implemented by IBTLibrary).\n\t\t\t */\n\t\t\tresult += getIteratorMethod(treeNames) + \"\\n\\n\";\n\n\t\t\t/*\n\t\t\t * Creates an internal iterator class that knows how to iterate\n\t\t\t * through the trees of the created library.\n\t\t\t */\n\t\t\tresult += getLibraryIterator(treeNames) + \"\\n\";\n\n\t\t\tresult += \"}\\n\";\n\n\t\t\treturn result;\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new BTLibraryGenerationException(\"Could not generate the BT library: \"\n\t\t\t\t\t+ e.getMessage(), e);\n\t\t}\n\t}\n\n\t/**\n\t * Given the name of a file storing a behaviour tree in XML format (the\n\t * format of <i>BT Editor</i>), this method returns the name of the tree\n\t * (which is extracted from the <i>Root</i> node of the XML file).\n\t * \n\t */\n\tprivate String getTreeName(String treeFileName) throws Exception {\n\t\tFileInputStream file = new FileInputStream(treeFileName);\n\n\t\tSAXBuilder builder = new SAXBuilder();\n\n\t\tDocument doc = builder.build(file);\n\t\tElement documentRoot = doc.getRootElement();\n\n\t\tElement treeRoot = (Element) documentRoot.getChildren().get(0);\n\n\t\tString result = treeRoot.getAttributeValue(NAME_ATTR);\n\n\t\tfile.close();\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates the {@link IBTLibrary#getBT(String)} method for the BT library.\n\t * <code>treeNames</code> is the list of names of the trees in the library.\n\t */\n\tprivate String getGetBTMethod(List<String> treeNames) {\n\t\tString result = new String();\n\n\t\tresult += \"/**Returns a  behaviour tree by its name, or null in case it cannot be found. \"\n\t\t\t\t+ \"It must be noted that the trees that are retrieved belong to the class, not to the instance (that is, the trees are static members of the class), \"\n\t\t\t\t+ \"so they are shared among all the instances of this class.*/\";\n\n\t\tresult += \"public \" + ModelTask.class.getCanonicalName() + \" getBT(\"\n\t\t\t\t+ String.class.getCanonicalName() + \" name){\\n\";\n\n\t\tfor (String treeName : treeNames) {\n\t\t\tresult += \"if(name.equals(\" + \"\\\"\" + treeName + \"\\\")){\\n\";\n\t\t\tresult += \"return \" + treeName + \";\\n\";\n\t\t\tresult += \"}\\n\";\n\t\t}\n\n\t\tresult += \"return null;\\n\";\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates an expression for the {@link Iterable#iterator()} method of the\n\t * IBTLibrary that is created. <code>treeNames</code> is the names of the\n\t * trees that the library contains. The function will just return an\n\t * instance of the private class BTLibraryIterator (see\n\t * {@link #getLibraryIterator(List)}). Note that the <code>remove()</code>\n\t * operation is not supported by this iterator.\n\t */\n\tprivate String getIteratorMethod(List<String> treeNames) {\n\t\tString result = new String();\n\n\t\tresult += \"/**Returns an Iterator that is able to iterate through all the elements in the library.\\n \"\n\t\t\t\t+ \"It must be noted that the iterator does not support the \\\"remove()\\\" operation.\\n\";\n\n\t\tresult += \"It must be noted that the trees that are retrieved belong to the class, \"\n\t\t\t\t+ \"not to the instance (that is, the trees are static members of the class), so \"\n\t\t\t\t+ \"they are shared among all the instances of this class.*/\";\n\n\t\tresult += \"public \" + ITERATOR_CLASS_NAME + \" iterator(){\\n\";\n\n\t\tresult += \"return new BTLibraryIterator();\\n\";\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Declares a class called BTLibraryIterator, which implements the\n\t * {@link Iterator} interface, and that is able to iterate through the trees\n\t * of the library. <code>treeNames</code> contains the names of the trees in\n\t * the library. Note that the <code>remove()</code> operation is not\n\t * supported by this iterator.\n\t */\n\tprivate String getLibraryIterator(List<String> treeNames) {\n\t\tString result = new String();\n\n\t\tresult += \"private class BTLibraryIterator implements \" + ITERATOR_CLASS_NAME + \"{\\n\";\n\n\t\tresult += \"static final long numTrees = \" + treeNames.size() + \";\\n\";\n\n\t\tresult += \"long currentTree = 0;\\n\\n\";\n\n\t\tresult += \"public boolean hasNext(){\\n\";\n\n\t\tresult += \"return this.currentTree < numTrees;\\n\";\n\n\t\tresult += \"}\\n\\n\";\n\n\t\tresult += \"public \" + ITERABLE_ELEMENTS_CLASS_NAME + \" next(){\\n\";\n\n\t\tresult += \"this.currentTree++;\\n\\n\";\n\n\t\tfor (int i = 0; i < treeNames.size(); i++) {\n\t\t\tString treeName = treeNames.get(i);\n\n\t\t\tresult += \"if((this.currentTree - 1) == \" + i + \"){\\n\";\n\n\t\t\tresult += \"return new \" + ITERABLE_ELEMENTS_CLASS_NAME + \"(\\\"\" + treeName + \"\\\", \"\n\t\t\t\t\t+ treeName + \")\" + \";\\n\";\n\n\t\t\tresult += \"}\\n\\n\";\n\t\t}\n\n\t\tresult += \"throw new \" + NoSuchElementException.class.getCanonicalName() + \"();\\n\";\n\n\t\tresult += \"}\\n\\n\";\n\n\t\tresult += \"public void remove(){\\n\";\n\n\t\tresult += \"throw new \" + UnsupportedOperationException.class.getCanonicalName() + \"();\\n\";\n\n\t\tresult += \"}\\n\";\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/lowlevelgenerator/ActionsGenerator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator.lowlevelgenerator;\n\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.action.ExecutionAction;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.action.ModelAction;\nimport jbt.tools.btlibrarygenerator.util.Util;\nimport jbt.util.Pair;\nimport gatech.mmpm.tools.parseddomain.ParsedAction;\nimport gatech.mmpm.tools.parseddomain.ParsedActionParameter;\n\n/**\n * Class used for generating Java-BT expressions for MMPM actions (represented\n * as {@link ParsedAction} objects).\n * <p>\n * Given a ParsedAction, this class can be used for generating a\n * {@link ModelAction} or an {@link ExecutionAction} for such an action. In\n * reality, this class does not produce instances of ModelAction and\n * ExecutionAction, but String representations of the Java implementation of\n * those classes.\n * \n * @see ConditionsGenerator\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ActionsGenerator {\n\t/**\n\t * This method is used for creating a String representation of the\n\t * definition of a Java class for <code>action</code>.\n\t * <p>\n\t * The output class extends {@link ModelAction}, and it is the conceptual\n\t * representation of <code>action</code>.\n\t * <p>\n\t * The generated class contains two private fields for each parameter of\n\t * <code>action</code>. Given a parameter with name <code>pName</code>, two\n\t * class variables are created in the output class:\n\t * <ul>\n\t * <li> <code>pName</code>. The type of this variable will be a Java type\n\t * compatible with that of the MMPM definition of <code>pName</code> in\n\t * <code>action</code> (according to\n\t * {@link Util#fromMMPMParameterType(gatech.mmpm.ActionParameterType)}).\n\t * This variable represents the value of the parameter in case a value has\n\t * been specified when constructing an instance of the output class.\n\t * <li> <code>pNameLoc</code>. This is a String representing where the\n\t * variable <code>pName</code> can be located in the context. In case a\n\t * value is not specified for the variable, the task's context must be\n\t * searched for a variable whose name is <code>pNameLoc</code>.\n\t * </ul>\n\t * \n\t * The\n\t * {@link ModelTask#createExecutor(jbt.execution.core.BTExecutor, ExecutionTask)}\n\t * method of the output class returns an instance of the corresponding\n\t * {@link ExecutionAction}. This method assumes that the corresponding\n\t * ExecutionTask's name is <code>action</code>'s name too, and that the\n\t * class is located in the Java package\n\t * <code>executionActionPackageName</code>. The corresponding\n\t * ExecutionAction receives in its constructor all the private class\n\t * variables of the output class, in the same order as they are declared in\n\t * the output class. In a similar way,\n\t * {@link #getExecutionActionClass(ParsedAction)} can be used to construct a\n\t * String expression for <code>action</code>.\n\t * <p>\n\t * The first argument of the constructor of the output class is the guard.\n\t * The rest of them are values for each private class variable of the output\n\t * class, in the same order as they are declared.\n\t * \n\t * @param action\n\t *            the action whose representation as a ModelAction is going to\n\t *            be created.\n\t * @param executionActionPackageName\n\t *            the name of the package that contains the ExecutionAction\n\t *            associated to <code>action</code>. It must not be empty, and\n\t *            it has to be of the form <i>level1.level2. ... .levelN</i>.\n\t * @return a String representation of <code>action</code> as a ModelAction\n\t *         class.\n\t */\n\tpublic String getModelActionClass(ParsedAction action, String executionActionPackageName) {\n\t\tString result = new String();\n\n\t\t/* First element is the type, and the second element is the value. */\n\t\tList<Pair<Class, String>> params = new LinkedList<Pair<Class, String>>();\n\n\t\t/* Extract all the parameters. */\n\t\tfor (ParsedActionParameter parameter : action.getParameters()) {\n\t\t\tparams.add(new Pair<Class, String>(Util.fromMMPMParameterType(parameter.getType()),\n\t\t\t\t\tparameter.getName()));\n\t\t}\n\n\t\tresult += \"/** ModelAction class created from MMPM action \" + action.getName() + \". */\";\n\n\t\t/* Action class header. */\n\t\tresult += getModelActionClassHeader(action) + \"\\n\";\n\n\t\t/* Class variables. */\n\t\tresult += CommonCodeGenerationUtilities.getClassVariables(params) + \"\\n\\n\";\n\n\t\t/* Constructor. */\n\t\tresult += CommonCodeGenerationUtilities.getModelConstructor(action.getName(), params)\n\t\t\t\t+ \"\\n\\n\";\n\n\t\t/* \"createExecutor()\" method. */\n\t\tresult += CommonCodeGenerationUtilities.getCreateExecutorMethod(action.getName(),\n\t\t\t\texecutionActionPackageName, params) + \"\\n\";\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * This method is used for creating a String representation of the\n\t * definition of a Java class for <code>action</code>.\n\t * <p>\n\t * The output class extends {@link ExecutionAction}, and it defines how\n\t * <code>action</code> actually works.\n\t * <p>\n\t * The generated class contains two private fields for each parameter of\n\t * <code>action</code>. Given a parameter with name <code>pName</code>, two\n\t * class variables are created in the output class:\n\t * <ul>\n\t * <li> <code>pName</code>. The type of this variable will be a Java type\n\t * compatible with that of the MMPM definition of <code>pName</code> in\n\t * <code>action</code> (according to\n\t * {@link Util#fromMMPMParameterType(gatech.mmpm.ActionParameterType)}).\n\t * This variable represents the value of the parameter in case a value has\n\t * been specified when constructing an instance of the output class.\n\t * <li> <code>pNameLoc</code>. This is a String representing where the\n\t * variable <code>pName</code> can be located in the context. In case a\n\t * value is not specified for the variable, the task's context must be\n\t * searched for a variable whose name is <code>pNameLoc</code>.\n\t * </ul>\n\t * <p>\n\t * For all of <code>action</code>'s parameters, a <i>getter</i> method is\n\t * constructed. Given a parameter with name <code>pName</code>, a getter\n\t * named <code>getPName()</code> is constructed. If at construction time a\n\t * value was specified for <code>pName</code>, then <code>getPName()</code>\n\t * returns such a value. Otherwise, <code>getPName()</code> will search for\n\t * a variable of name <code>pNameLoc</code> in the context, and will return\n\t * its value.\n\t * <p>\n\t * This method also constructs an empty skeleton for all abstract methods of\n\t * ExecutionAction. The getter methods can be used in the implementation of\n\t * those abstract methods in order to retrieve the action's parameters.\n\t * <p>\n\t * The first argument of the constructor of the output class is its\n\t * corresponding ModelAction. The second one is its corresponding\n\t * BTExecutor. The rest of them are values for each private class variable\n\t * of the output class, in the same order as they are declared.\n\t * \n\t * @param action\n\t *            the action whose representation as an ExecutionAction is going\n\t *            to be created.\n\t * @return a String representation of <code>action</code> as an\n\t *         ExecutionAction class.\n\t */\n\tpublic String getExecutionActionClass(ParsedAction action, String modelActionPackageName) {\n\t\tString result = new String();\n\n\t\t/* First element is the type, and the second element is the value. */\n\t\tList<Pair<Class, String>> params = new LinkedList<Pair<Class, String>>();\n\n\t\tfor (ParsedActionParameter parameter : action.getParameters()) {\n\t\t\tparams.add(new Pair<Class, String>(Util.fromMMPMParameterType(parameter.getType()),\n\t\t\t\t\tparameter.getName()));\n\t\t}\n\n\t\tresult += \"/** ExecutionAction class created from MMPM action \" + action.getName() + \". */\";\n\n\t\t/* Action class header. */\n\t\tresult += getExecutionActionClassHeader(action) + \"\\n\";\n\n\t\t/* Class variables. */\n\t\tresult += CommonCodeGenerationUtilities.getClassVariables(params) + \"\\n\\n\";\n\n\t\t/* Constructor. */\n\t\tresult += CommonCodeGenerationUtilities.getExecutionConstructor(action.getName(),\n\t\t\t\tmodelActionPackageName, params) + \"\\n\\n\";\n\n\t\t/* Getters. */\n\t\tresult += CommonCodeGenerationUtilities.getGetters(params) + \"\\n\\n\";\n\n\t\t/* Abstract methods. */\n\t\tresult += CommonCodeGenerationUtilities.getAbstractMethods();\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\tprivate String getModelActionClassHeader(ParsedAction action) {\n\t\treturn \"public class \" + action.getName() + \" extends \"\n\t\t\t\t+ ModelAction.class.getCanonicalName() + \"{\";\n\t}\n\n\tprivate String getExecutionActionClassHeader(ParsedAction action) {\n\t\treturn \"public class \" + action.getName() + \" extends \"\n\t\t\t\t+ ExecutionAction.class.getCanonicalName() + \"{\";\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/lowlevelgenerator/CommonCodeGenerationUtilities.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator.lowlevelgenerator;\n\nimport java.util.List;\n\nimport jbt.execution.core.BTExecutor;\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.core.BTExecutor.BTExecutorList;\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.execution.core.ITaskState;\nimport jbt.execution.task.leaf.action.ExecutionAction;\nimport jbt.execution.task.leaf.condition.ExecutionCondition;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.action.ModelAction;\nimport jbt.model.task.leaf.condition.ModelCondition;\nimport jbt.util.Pair;\n\n/**\n * Some helper functions used for easily generating String representations of {@link ModelAction}s,\n * {@link ModelCondition}s, {@link ExecutionAction}s and {@link ExecutionCondition}s from MMPM\n * actions and sensors.\n * <p>\n * {@link ActionsGenerator} and {@link ConditionsGenerator} share most of their functionality, so\n * this class just gathers all of the common parts when they are generating classes.\n * \n * @see ActionsGenerator\n * @see ConditionsGenerator\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class CommonCodeGenerationUtilities {\n\t/** Message for a \"to do\". */\n\tstatic final String TODO_MESSAGE = \"/* TODO: this method's implementation must be completed. */\";\n\t/**\n\t * Suffix that is placed at the end of the class's variables to represent the variable that will\n\t * store the location in the context of the original variable.\n\t */\n\tstatic final String PARAM_LOCATION_SUFFIX = \"Loc\";\n\n\t/**\n\t * Given a list of class \"parameters\", this method returns a String representation of the\n\t * declaration of those parameters as private members of a class.\n\t * <p>\n\t * <code>params</code> contains all the parameters. Each Pair represents a parameter, being the\n\t * first element its class and the second element its name.\n\t * <p>\n\t * The returned representation is tabulated one unit.\n\t * \n\t * @param params\n\t *            the set of parameters from which a String representation is created.\n\t * @return a String representation of the declaration of the parameters in <code>params</code>.\n\t */\n\tstatic String getClassVariables(List<Pair<Class, String>> params) {\n\t\tString result = new String();\n\n\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\tresult += \"/**Value of the parameter \\\"\" + currentParam.getSecond()\n\t\t\t\t\t+ \"\\\" in case its value is specified at construction time. null otherwise.*/\";\n\t\t\tresult += \"private \" + currentParam.getFirst().getCanonicalName() + \" \"\n\t\t\t\t\t+ currentParam.getSecond() + \";\" + \"\\n\";\n\t\t\tresult += \"/**Location, in the context, of the parameter \\\"\"\n\t\t\t\t\t+ currentParam.getSecond()\n\t\t\t\t\t+ \"\\\" in case its value is not specified at construction time. null otherwise.*/\";\n\t\t\tresult += \"private \" + String.class.getCanonicalName() + \" \" + currentParam.getSecond()\n\t\t\t\t\t+ PARAM_LOCATION_SUFFIX + \";\" + \"\\n\";\n\t\t}\n\n\t\tif (params.size() != 0) {\n\t\t\tresult = result.substring(0, result.length() - 1);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates a String expression for the constructor of a ModelAction or ModelCondition. The name\n\t * of the class is <code>modelClassName</code>, and <code>params</code> is a list of parameters\n\t * (the first element of each pair is the class of the parameter and the second element is its\n\t * name).\n\t * <p>\n\t * For each parameter of name <code>pName</code> in <code>params</code>, the constructor will\n\t * receive two parameters, one of name <code>pName</code>, whose type is that specified in the\n\t * list of parameters, and another one of name <code>pNameLoc</code>, whose type is String, and\n\t * which represents the place in the context where <code>pName</code> must be looked for in case\n\t * a value is not specified for it.\n\t * <p>\n\t * The constructor assigns the value of every input argument to its corresponding class\n\t * variable.\n\t * \n\t * @param modelClassName\n\t *            the name of the ModelAction or ModelCondition class whose constructor is going to\n\t *            be created.\n\t * @param params\n\t *            the list of parameters to be used when building the constructor.\n\t * @return a String expression for the constructor, as described above.\n\t */\n\tstatic String getModelConstructor(String modelClassName, List<Pair<Class, String>> params) {\n\t\tString result = new String();\n\n\t\tresult += \"/** Constructor. Constructs an instance of \" + modelClassName + \".\\n\";\n\n\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\tresult += \"@param \" + currentParam.getSecond() + \" value of the parameter \\\"\"\n\t\t\t\t\t+ currentParam.getSecond()\n\t\t\t\t\t+ \"\\\", or null in case it should be read from the context. If null, <code>\"\n\t\t\t\t\t+ currentParam.getSecond() + PARAM_LOCATION_SUFFIX\n\t\t\t\t\t+ \"</code> cannot be null.\\n\";\n\n\t\t\tresult += \"@param \"\n\t\t\t\t\t+ currentParam.getSecond()\n\t\t\t\t\t+ PARAM_LOCATION_SUFFIX\n\t\t\t\t\t+ \" in case <code>\"\n\t\t\t\t\t+ currentParam.getSecond()\n\t\t\t\t\t+ \"</code> is null, this variable represents the place in the context where the parameter's value will be retrieved from.\\n\";\n\t\t}\n\n\t\tresult += \"*/\";\n\n\t\tresult += \"public \" + modelClassName + \"(\";\n\n\t\tString stringParams = new String();\n\n\t\tstringParams += ModelTask.class.getCanonicalName() + \" guard, \";\n\n\t\tif (params.size() != 0) {\n\t\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\t\tstringParams += currentParam.getFirst().getCanonicalName() + \" \"\n\t\t\t\t\t\t+ currentParam.getSecond() + \", \";\n\t\t\t\tstringParams += String.class.getCanonicalName() + \" \" + currentParam.getSecond()\n\t\t\t\t\t\t+ PARAM_LOCATION_SUFFIX + \", \";\n\t\t\t}\n\t\t}\n\n\t\tstringParams = stringParams.substring(0, stringParams.length() - 2);\n\n\t\tresult += stringParams + \"){\\n\";\n\n\t\tresult += \"super(guard);\\n\";\n\n\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\tresult += \"this.\" + currentParam.getSecond() + \" = \" + currentParam.getSecond() + \";\\n\";\n\t\t\tresult += \"this.\" + currentParam.getSecond() + PARAM_LOCATION_SUFFIX + \" = \"\n\t\t\t\t\t+ currentParam.getSecond() + PARAM_LOCATION_SUFFIX + \";\\n\";\n\t\t}\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates a String expression for the constructor of a ExecutionAction or ExecutionCondition.\n\t * The name of the class is <code>executionClassName</code>, and <code>params</code> is a list\n\t * of parameters (the first element of each pair is the class of the parameter and the second\n\t * element is its name).\n\t * <p>\n\t * For each parameter of name <code>pName</code> in <code>params</code>, the constructor will\n\t * receive two parameters, one of name <code>pName</code>, whose type is that specified in the\n\t * list of parameters, and another one of name <code>pNameLoc</code>, whose type is String, and\n\t * which represents the place in the context where <code>pName</code> must be looked for in case\n\t * a value is not specified for it.\n\t * <p>\n\t * The constructor assigns the value of every input argument to its corresponding class\n\t * variable.\n\t * <p>\n\t * <code>modelClassPackageName</code> is the name of the package that contains the corresponding\n\t * model class (the name of the corresponding model class is assumed to be\n\t * <code>executionClassName</code>.\n\t * \n\t * @param executionClassName\n\t *            the name of the ModelAction or ModelCondition class whose constructor is going to\n\t *            be created.\n\t * @param params\n\t *            the list of parameters to be used when building the constructor.\n\t * @param modelClassPackageName\n\t *            the name of the package that contains the corresponding model class.\n\t * @return a String expression for the constructor, as described above.\n\t */\n\tstatic String getExecutionConstructor(String executionClassName, String modelClassPackageName,\n\t\t\tList<Pair<Class, String>> params) {\n\t\tString result = new String();\n\n\t\tresult += \"/** Constructor. Constructs an instance of \" + executionClassName\n\t\t\t\t+ \" that is able to run a \" + modelClassPackageName + \".\" + executionClassName\n\t\t\t\t+ \".\\n\";\n\n\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\tresult += \"@param \" + currentParam.getSecond() + \" value of the parameter \\\"\"\n\t\t\t\t\t+ currentParam.getSecond()\n\t\t\t\t\t+ \"\\\", or null in case it should be read from the context. If null, <code>\"\n\t\t\t\t\t+ currentParam.getSecond() + PARAM_LOCATION_SUFFIX + \"<code> cannot be null.\\n\";\n\n\t\t\tresult += \"@param \"\n\t\t\t\t\t+ currentParam.getSecond()\n\t\t\t\t\t+ PARAM_LOCATION_SUFFIX\n\t\t\t\t\t+ \" in case <code>\"\n\t\t\t\t\t+ currentParam.getSecond()\n\t\t\t\t\t+ \"</code> is null, this variable represents the place in the context where the parameter's value will be retrieved from.\\n\";\n\t\t}\n\n\t\tresult += \"*/\";\n\n\t\tresult += \"public \" + executionClassName + \"(\";\n\n\t\tString stringParams = new String();\n\n\t\tstringParams += modelClassPackageName + \".\" + executionClassName + \" modelTask, \"\n\t\t\t\t+ BTExecutor.class.getCanonicalName() + \" executor, \"\n\t\t\t\t+ ExecutionTask.class.getCanonicalName() + \" parent, \";\n\n\t\tif (params.size() != 0) {\n\t\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\t\tstringParams += currentParam.getFirst().getCanonicalName() + \" \"\n\t\t\t\t\t\t+ currentParam.getSecond() + \", \";\n\t\t\t\tstringParams += String.class.getCanonicalName() + \" \" + currentParam.getSecond()\n\t\t\t\t\t\t+ PARAM_LOCATION_SUFFIX + \", \";\n\t\t\t}\n\t\t}\n\n\t\tstringParams = stringParams.substring(0, stringParams.length() - 2);\n\n\t\tresult += stringParams + \"){\\n\";\n\n\t\tresult += \"super(modelTask, executor, parent);\\n\\n\";\n\n\t\tif (params.size() != 0) {\n\t\t\tresult += \"\\n\\n\";\n\t\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\t\tresult += \"this.\" + currentParam.getSecond() + \" = \" + currentParam.getSecond()\n\t\t\t\t\t\t+ \";\\n\";\n\t\t\t\tresult += \"this.\" + currentParam.getSecond() + PARAM_LOCATION_SUFFIX + \" = \"\n\t\t\t\t\t\t+ currentParam.getSecond() + PARAM_LOCATION_SUFFIX + \";\\n\";\n\t\t\t}\n\t\t}\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * This method creates a String representing the definition of the\n\t * {@link ModelTask#createExecutor(BTExecutor, ExecutionTask)} method of a class.\n\t * <p>\n\t * The method will return an instance of an ExecutionTask whose name is\n\t * <code>executionClassName</code> and placed in the package\n\t * <code>executionActionPackageName</code>.\n\t * <p>\n\t * <code>params</code> represents the list of parameters that the ExecutionTask will receive in\n\t * its constructor. The first argument that is passed to the ExecutionTask's constructor is\n\t * <code>this</code>; the second argument is <code>executor</code> (<code>executor</code>\n\t * represents the {@link BTExecutor} that is passed to the <code>createExecutor()</code> method.\n\t * The rest of the parameters that are passed to the constructor are those in\n\t * <code>params</code>. Each Pair in <code>params</code> represents a parameter, being the first\n\t * element its class and the second element its name. For each parameter in <code>params</code>,\n\t * the constructor receives two parameters, the parameter itself (for instance\n\t * <code>pName</code>) , and the location of the parameter in the context (<code>pNameLoc</code>\n\t * ).\n\t * \n\t * @param executionClassName\n\t *            the name of the ExecutionTask that the method will return.\n\t * @param params\n\t *            the list of parameters that the ExecutionTask <code>executionClassName</code> will\n\t *            receive in its constructor, apart from <code>this</code> and <code>executor</code>\n\t *            .\n\t * @param executionClassPackageName\n\t *            the name of the Java package that contains the class\n\t *            <code>executionClassName</code>.\n\t * @return a String representation for the <code>createExecutor()</code> method as described\n\t *         above.\n\t */\n\tstatic String getCreateExecutorMethod(String executionClassName,\n\t\t\tString executionClassPackageName, List<Pair<Class, String>> params) {\n\t\t/*\n\t\t * TODO: this method could be improved, since only the names of the parameters are required.\n\t\t */\n\t\tString result = new String();\n\n\t\tresult += \"/** Returns a \" + executionClassPackageName + \".\" + executionClassName\n\t\t\t\t+ \" task that is able to run this task. */\";\n\n\t\tresult += \"public \" + ExecutionTask.class.getCanonicalName() + \" createExecutor(\"\n\t\t\t\t+ BTExecutor.class.getCanonicalName() + \" executor, \"\n\t\t\t\t+ ExecutionTask.class.getCanonicalName() + \" parent\" + \"){\\n\";\n\n\t\tString returnStatement = \"return new \" + executionClassPackageName + \".\"\n\t\t\t\t+ executionClassName + \"(\";\n\n\t\treturnStatement += \"this, executor, parent, \";\n\n\t\tif (params.size() != 0) {\n\t\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\t\treturnStatement += \"this.\" + currentParam.getSecond() + \", \";\n\t\t\t\treturnStatement += \"this.\" + currentParam.getSecond() + PARAM_LOCATION_SUFFIX\n\t\t\t\t\t\t+ \", \";\n\t\t\t}\n\t\t}\n\n\t\treturnStatement = returnStatement.substring(0, returnStatement.length() - 2);\n\n\t\treturnStatement += \");\\n\";\n\n\t\tresult += returnStatement;\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Given a list of parameters, this method creates an expression declaring a public getter\n\t * method for each parameter. These getters must be used by a class extending\n\t * {@link ExecutionTask}, since the implementation of such getters make use of the context of\n\t * the task.\n\t * <p>\n\t * <code>params</code> contains all the parameters. Each Pair represents a parameter, being the\n\t * first element its class and the second element its name.\n\t * <p>\n\t * Given a parameter of name <code>pName</code>, the getter function has as a name\n\t * <code>getPName()</code>. If the variable to get is not null, the getter method returns the\n\t * variable. Otherwise, it searches for the variable in the context by using the class private\n\t * variable <code>getPNameLoc</code>.\n\t * \n\t * @param params\n\t *            the set of parameters from which getters are going to be obtained.\n\t * @return a String representation of all the getters for the parameters in <code>params</code.\n\t */\n\tstatic String getGetters(List<Pair<Class, String>> params) {\n\t\tString result = new String();\n\n\t\tfor (Pair<Class, String> currentParam : params) {\n\t\t\tString currentGetter = getGetter(currentParam);\n\t\t\tresult += currentGetter + \"\\n\\n\";\n\t\t}\n\n\t\tif (params.size() != 0) {\n\t\t\tresult = result.substring(0, result.length() - 2);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Given a parameter, this method returns a getter method for it. This getter must be used by a\n\t * class extending {@link ExecutionTask}, since the implementation of such getter make use of\n\t * the context of the task.\n\t * <p>\n\t * <code>param</code> represents the parameter, being the first element its class and the second\n\t * element its name.\n\t * <p>\n\t * Given a parameter of name <code>pName</code>, the getter function has as a name\n\t * <code>getPName()</code>. If the variable to get is not null, the getter method returns the\n\t * variable. Otherwise, it searches for the variable in the context by using the class private\n\t * variable <code>getPNameLoc</code>.\n\t * \n\t * @param param\n\t *            the parameter from which the getter method is obtained.\n\t * @return a String representation for the parameter <code>param</code>.\n\t */\n\tstatic String getGetter(Pair<Class, String> param) {\n\t\tString result = new String();\n\n\t\tresult += \"/** Returns the value of the parameter \\\"\"\n\t\t\t\t+ param.getSecond()\n\t\t\t\t+ \"\\\", or null in case it has not been specified or it cannot be found in the context. */\";\n\n\t\tresult += \"public \" + param.getFirst().getCanonicalName() + \" get\"\n\t\t\t\t+ Character.toUpperCase(param.getSecond().charAt(0))\n\t\t\t\t+ param.getSecond().substring(1) + \"(){\\n\";\n\t\tresult += \"if(this.\" + param.getSecond() + \" != null){\\n\";\n\t\tresult += \"return this.\" + param.getSecond() + \";\\n\";\n\t\tresult += \"}\\n\";\n\t\tresult += \"else{\\n\";\n\t\tresult += \"return (\" + param.getFirst().getCanonicalName() + \")\"\n\t\t\t\t+ \"this.getContext().getVariable(\" + \"this.\" + param.getSecond()\n\t\t\t\t+ PARAM_LOCATION_SUFFIX + \");\\n\";\n\t\tresult += \"}\\n\";\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns a String representation of the declaration of the abstract methods of the\n\t * {@link ExecutionTask} class. The String is tabulated one unit.\n\t * \n\t * @return a String representation of the declaration of the abstract methods of the\n\t *         {@link ExecutionTask} class.\n\t */\n\tstatic String getAbstractMethods() {\n\t\tString result = new String();\n\n\t\tresult += \"protected void internalSpawn(){\\n\";\n\t\tresult += \"/* Do not remove this first line unless you know what it does and you need not do it. */\\n\";\n\t\tresult += \"this.getExecutor().requestInsertionIntoList(\"\n\t\t\t\t+ BTExecutorList.class.getCanonicalName() + \".\"\n\t\t\t\t+ BTExecutorList.TICKABLE.toString() + \",this);\\n\";\n\t\tresult += TODO_MESSAGE + \"\\n\";\n\t\tresult += \"System.out.println(this.getClass().getCanonicalName() +\" + \"\\\" spawned\\\");\";\n\t\tresult += \"}\\n\\n\";\n\n\t\tresult += \"protected \" + Status.class.getCanonicalName() + \" internalTick(){\\n\";\n\t\tresult += \"/* TODO: this method's implementation must be completed. This function should only return Status.SUCCESS, Status.FAILURE or Status.RUNNING. No other values are allowed. */\"\n\t\t\t\t+ \"\\n\";\n\t\tresult += \"return \" + Status.class.getCanonicalName() + \".\" + Status.SUCCESS.toString()\n\t\t\t\t+ \";\\n\";\n\t\tresult += \"}\\n\\n\";\n\n\t\tresult += \"protected void internalTerminate(){\\n\";\n\t\tresult += TODO_MESSAGE + \"\\n\";\n\t\tresult += \"}\\n\\n\";\n\n\t\tresult += \"protected void restoreState(\" + ITaskState.class.getCanonicalName()\n\t\t\t\t+ \" state){\\n\";\n\t\tresult += TODO_MESSAGE + \"\\n\";\n\t\tresult += \"}\\n\\n\";\n\n\t\tresult += \"protected \" + ITaskState.class.getCanonicalName() + \" storeState(){\\n\";\n\t\tresult += TODO_MESSAGE + \"\\n\";\n\t\tresult += \"return null;\";\n\t\tresult += \"}\\n\";\n\n\t\tresult += \"protected \" + ITaskState.class.getCanonicalName()\n\t\t\t\t+ \" storeTerminationState(){\\n\";\n\t\tresult += TODO_MESSAGE + \"\\n\";\n\t\tresult += \"return null;\";\n\t\tresult += \"}\\n\";\n\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/lowlevelgenerator/ConditionsGenerator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator.lowlevelgenerator;\n\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport jbt.execution.core.ExecutionTask;\nimport jbt.execution.task.leaf.condition.ExecutionCondition;\nimport jbt.model.core.ModelTask;\nimport jbt.model.task.leaf.condition.ModelCondition;\nimport jbt.tools.btlibrarygenerator.util.Util;\nimport jbt.util.Pair;\nimport gatech.mmpm.tools.parseddomain.ParsedActionParameter;\nimport gatech.mmpm.tools.parseddomain.ParsedMethod;\n\n/**\n * Class used for generating Java-BT expressions for MMPM sensors (represented\n * as {@link ParsedMethod} objects).\n * <p>\n * Given a ParsedMethod, this class can be used for generating a\n * {@link ModelCondition} or an {@link ExecutionCondition} for such a sensor. In\n * reality, this class does not produce instances of ModelCondition and\n * ExecutionCondition, but String representations of the Java implementation of\n * those classes.\n * \n * @see ActionsGenerator\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ConditionsGenerator {\n\t/**\n\t * This method is used for creating a String representation of the\n\t * definition of a Java class for <code>condition</code>.\n\t * <p>\n\t * The output class extends {@link ModelCondition}, and it is the conceptual\n\t * representation of <code>condition</code>.\n\t * <p>\n\t * The generated class contains two private fields for each parameter of\n\t * <code>condition</code>. Given a parameter with name <code>pName</code>,\n\t * two class variables are created in the output class:\n\t * <ul>\n\t * <li> <code>pName</code>. The type of this variable will be a Java type\n\t * compatible with that of the MMPM definition of <code>pName</code> in\n\t * <code>condition</code> (according to\n\t * {@link Util#fromMMPMParameterType(gatech.mmpm.ActionParameterType)}).\n\t * This variable represents the value of the parameter in case a value has\n\t * been specified when constructing an instance of the output class.\n\t * <li> <code>pNameLoc</code>. This is a String representing where the\n\t * variable <code>pName</code> can be located in the context. In case a\n\t * value is not specified for the variable, the task's context must be\n\t * searched for a variable whose name is <code>pNameLoc</code>.\n\t * </ul>\n\t * \n\t * The\n\t * {@link ModelTask#createExecutor(jbt.execution.core.BTExecutor, ExecutionTask)}\n\t * method of the output class returns an instance of the corresponding\n\t * {@link ExecutionCondition}. This method assumes that the corresponding\n\t * ExecutionCondition's name is <code>condition</code>'s name too, and that\n\t * the class is located in the Java package\n\t * <code>executionConditionPackageName</code>. The corresponding\n\t * ExecutionCondition receives in its constructor all the private class\n\t * variables of the output class, in the same order as they are declared in\n\t * the output class. In a similar way,\n\t * {@link #getExecutionConditionClass(ParsedMethod)} can be used to\n\t * construct a String expression for <code>condition</code>.\n\t * <p>\n\t * The first argument of the constructor of the output class is the guard.\n\t * The rest of them are values for each private class variable of the output\n\t * class, in the same order as they are declared.\n\t * \n\t * @param condition\n\t *            the condition whose representation as a ModelCondition is\n\t *            going to be created.\n\t * @param executionConditionPackageName\n\t *            the name of the package that contains the ExecutionCondition\n\t *            associated to <code>condition</code>. It must not be empty,\n\t *            and it has to be of the form <i>level1.level2. ...\n\t *            .levelN</i>.\n\t * @return a String representation of <code>condition</code> as a\n\t *         ModelCondition class.\n\t */\n\tpublic String getModelConditionClass(ParsedMethod condition,\n\t\t\tString executionConditionPackageName) {\n\t\tString result = new String();\n\n\t\t/* First element is the type, and the second element is the value. */\n\t\tList<Pair<Class, String>> params = new LinkedList<Pair<Class, String>>();\n\n\t\tfor (ParsedActionParameter parameter : condition.getParameters()) {\n\t\t\tparams.add(new Pair<Class, String>(Util.fromMMPMParameterType(parameter.getType()),\n\t\t\t\t\tparameter.getName()));\n\t\t}\n\n\t\tresult += \"/** ModelCondition class created from MMPM condition \" + condition.getName()\n\t\t\t\t+ \". */\";\n\n\t\t/* Class header. */\n\t\tresult += getModelConditionClassHeader(condition) + \"\\n\";\n\n\t\t/* Class variables. */\n\t\tresult += CommonCodeGenerationUtilities.getClassVariables(params) + \"\\n\\n\";\n\n\t\t/* Constructor. */\n\t\tresult += CommonCodeGenerationUtilities.getModelConstructor(condition.getName(), params)\n\t\t\t\t+ \"\\n\\n\";\n\n\t\t/* \"createExecutor()\" method. */\n\t\tresult += CommonCodeGenerationUtilities.getCreateExecutorMethod(condition.getName(),\n\t\t\t\texecutionConditionPackageName, params) + \"\\n\";\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * This method is used for creating a String representation of the\n\t * definition of a Java class for <code>condition</code>.\n\t * <p>\n\t * The output class extends {@link ExecutionCondition}, and it defines how\n\t * <code>condition</code> actually works.\n\t * <p>\n\t * The generated class contains two private fields for each parameter of\n\t * <code>condition</code>. Given a parameter with name <code>pName</code>,\n\t * two class variables are created in the output class:\n\t * <ul>\n\t * <li> <code>pName</code>. The type of this variable will be a Java type\n\t * compatible with that of the MMPM definition of <code>pName</code> in\n\t * <code>condition</code> (according to\n\t * {@link Util#fromMMPMParameterType(gatech.mmpm.ActionParameterType)}).\n\t * This variable represents the value of the parameter in case a value has\n\t * been specified when constructing an instance of the output class.\n\t * <li> <code>pNameLoc</code>. This is a String representing where the\n\t * variable <code>pName</code> can be located in the context. In case a\n\t * value is not specified for the variable, the task's context must be\n\t * searched for a variable whose name is <code>pNameLoc</code>.\n\t * </ul>\n\t * <p>\n\t * For all of <code>condition</code>'s parameters, a <i>getter</i> method is\n\t * constructed. Given a parameter with name <code>pName</code>, a getter\n\t * named <code>getPName()</code> is constructed. If at construction time a\n\t * value was specified for <code>pName</code>, then <code>getPName()</code>\n\t * returns such a value. Otherwise, <code>getPName()</code> will search for\n\t * a variable of name <code>pNameLoc</code> in the context, and will return\n\t * its value.\n\t * <p>\n\t * This method also constructs an empty skeleton for all abstract methods of\n\t * ExecutionCondition. The getter methods can be used in the implementation\n\t * of those abstract methods in order to retrieve the condition's\n\t * parameters.\n\t * <p>\n\t * The first argument of the constructor of the output class is its\n\t * corresponding ModelContion. The second one is its corresponding\n\t * BTExecutor. The rest of them are values for each private class variable\n\t * of the output class, in the same order as they are declared.\n\t * \n\t * @param condition\n\t *            the condition whose representation as an ExecutionCondition is\n\t *            going to be created.\n\t * @return a String representation of <code>action</code> as an\n\t *         ExecutionCondition class.\n\t */\n\tpublic String getExecutionConditionClass(ParsedMethod condition,\n\t\t\tString modelConditionPackageName) {\n\t\tString result = new String();\n\n\t\t/* First element is the type, and the second element is the value. */\n\t\tList<Pair<Class, String>> params = new LinkedList<Pair<Class, String>>();\n\n\t\tfor (ParsedActionParameter parameter : condition.getParameters()) {\n\t\t\tparams.add(new Pair<Class, String>(Util.fromMMPMParameterType(parameter.getType()),\n\t\t\t\t\tparameter.getName()));\n\t\t}\n\n\t\tresult += \"/** ExecutionCondition class created from MMPM condition \" + condition.getName()\n\t\t\t\t+ \". */\";\n\n\t\t/* Class header. */\n\t\tresult += getExecutionConditionClassHeader(condition) + \"\\n\";\n\n\t\t/* Class variables. */\n\t\tresult += CommonCodeGenerationUtilities.getClassVariables(params) + \"\\n\\n\";\n\n\t\t/* Constructor. */\n\t\tresult += CommonCodeGenerationUtilities.getExecutionConstructor(condition.getName(),\n\t\t\t\tmodelConditionPackageName, params) + \"\\n\\n\";\n\n\t\t/* Getters. */\n\t\tresult += CommonCodeGenerationUtilities.getGetters(params) + \"\\n\\n\";\n\n\t\t/* Abstract methods. */\n\t\tresult += CommonCodeGenerationUtilities.getAbstractMethods();\n\n\t\tresult += \"}\";\n\n\t\treturn result;\n\t}\n\n\tprivate String getModelConditionClassHeader(ParsedMethod condition) {\n\t\treturn \"public class \" + condition.getName() + \" extends \"\n\t\t\t\t+ ModelCondition.class.getCanonicalName() + \"{\";\n\t}\n\n\tprivate String getExecutionConditionClassHeader(ParsedMethod condition) {\n\t\treturn \"public class \" + condition.getName() + \" extends \"\n\t\t\t\t+ ExecutionCondition.class.getCanonicalName() + \"{\";\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/modelbtgenerator/ModelBTGenerationException.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator.modelbtgenerator;\n\n/**\n * Exception that is thrown when there is any error when generating an\n * expression for a model BT.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelBTGenerationException extends Exception {\n\tprivate static final long serialVersionUID = 1L;\n\n\tpublic ModelBTGenerationException(String message) {\n\t\tsuper(message);\n\t}\n\n\tpublic ModelBTGenerationException(String message, Throwable cause) {\n\t\tsuper(message, cause);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/modelbtgenerator/ModelBTGenerator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator.modelbtgenerator;\n\nimport gatech.mmpm.ActionParameterType;\nimport gatech.mmpm.tools.parseddomain.ParsedAction;\nimport gatech.mmpm.tools.parseddomain.ParsedActionParameter;\nimport gatech.mmpm.tools.parseddomain.ParsedMethod;\n\nimport java.io.FileInputStream;\nimport java.util.Arrays;\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nimport jbt.execution.core.ExecutionTask.Status;\nimport jbt.model.core.ModelTask;\nimport jbt.model.core.ModelTask.Position;\nimport jbt.model.task.composite.ModelDynamicPriorityList;\nimport jbt.model.task.composite.ModelParallel;\nimport jbt.model.task.composite.ModelRandomSelector;\nimport jbt.model.task.composite.ModelRandomSequence;\nimport jbt.model.task.composite.ModelSelector;\nimport jbt.model.task.composite.ModelSequence;\nimport jbt.model.task.composite.ModelParallel.ParallelPolicy;\nimport jbt.model.task.composite.ModelStaticPriorityList;\nimport jbt.model.task.decorator.ModelHierarchicalContextManager;\nimport jbt.model.task.decorator.ModelInterrupter;\nimport jbt.model.task.decorator.ModelInverter;\nimport jbt.model.task.decorator.ModelLimit;\nimport jbt.model.task.decorator.ModelRepeat;\nimport jbt.model.task.decorator.ModelSafeContextManager;\nimport jbt.model.task.decorator.ModelSafeOutputContextManager;\nimport jbt.model.task.decorator.ModelSucceeder;\nimport jbt.model.task.decorator.ModelUntilFail;\nimport jbt.model.task.leaf.ModelFailure;\nimport jbt.model.task.leaf.ModelPerformInterruption;\nimport jbt.model.task.leaf.ModelSubtreeLookup;\nimport jbt.model.task.leaf.ModelSuccess;\nimport jbt.model.task.leaf.ModelVariableRenamer;\nimport jbt.model.task.leaf.ModelWait;\nimport jbt.model.task.leaf.action.ModelAction;\nimport jbt.model.task.leaf.condition.ModelCondition;\nimport jbt.tools.btlibrarygenerator.lowlevelgenerator.ActionsGenerator;\nimport jbt.tools.btlibrarygenerator.lowlevelgenerator.ConditionsGenerator;\nimport jbt.tools.btlibrarygenerator.util.Util;\n\nimport org.jdom.Document;\nimport org.jdom.Element;\nimport org.jdom.input.SAXBuilder;\n\n/**\n * This class is used for generating Java expressions for behaviour trees specified in an XML\n * format.\n * <p>\n * The XML format is that of <i>BT Editor</i>. The expression that is generated from the XML\n * behaviour tree is just a composition of {@link ModelTask} objects that represent the behaviour\n * tree in the XML file. An example of such an expression is:\n * \n * <pre>\n * new ModelSequence(null, new ModelSelector(null, new Condition1ModelCondition(null),\n * \t\tnew Action1ModelAction(null)), new ModelParallel(null, ParallelPolicy.SEQUENCE_POLICY,\n * \t\tnew Action2ModelAction(null), new Action3ModelAction(null)))\n * </pre>\n * \n * Where <code>Condition1ModelCondition</code>, <code>Action1ModelAction</code>,\n * <code>Action2ModelAction</code> and <code>Action1Mode3Action</code> are user-defined conditions\n * and actions.\n * <p>\n * The expression also assigns each ModelPerformInterruption task its corresponding ModelInterrupter\n * task. Thus, the expression that is obtained is a fully functional behaviour tree (ModelTask).\n * \n * @see ActionsGenerator\n * @see ConditionsGenerator\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ModelBTGenerator {\n\t/** Representation of the Tree tag of the XML file. */\n\tprivate static String TAG_TREE = \"Tree\";\n\t/** Representation of the Node tag of the XML file. */\n\tprivate static String TAG_NODE = \"Node\";\n\n\t/** Representation of the Children tag of the XML file. */\n\tprivate static String TAG_CHILDREN = \"Children\";\n\t/** Representation of the Parameters tag of the XML file. */\n\tprivate static String TAG_PARAMETERS = \"Parameters\";\n\t/** Representation of the Parameter tag of the XML file. */\n\tprivate static String TAG_PARAMETER = \"Parameter\";\n\t/** Representation of the Guard tag of the XML file. */\n\tprivate static String TAG_GUARD = \"Guard\";\n\n\t/** Representation of the \"type\" attribute of the XML file. */\n\tprivate static String ATTR_TYPE = \"type\";\n\t/** Representation of the \"name\" attribute of the XML file. */\n\tprivate static String ATTR_NAME = \"name\";\n\t/** Representation of the \"runs\" attribute of the XML file. */\n\tprivate static String ATTR_RUNS = \"runs\";\n\t/** Representation of the \"duration\" attribute of the XML file. */\n\tprivate static String ATTR_DURATION = \"duration\";\n\t/** Representation of the \"policy\" attribute of the XML file. */\n\tprivate static String ATTR_POLICY = \"policy\";\n\t/** Representation of the \"from context\" attribute of the XML file. */\n\tprivate static String ATTR_FROM_CONTEXT = \"fromcontext\";\n\t/** Representation of the \"id\" attribute of the XML file. */\n\tprivate static String ATTR_ID = \"id\";\n\t/** Representation of the \"listOfVariables\" attribute of the XML file. */\n\tprivate static String ATTR_LIST_OF_VARIABLES = \"listOfVariables\";\n\n\t/** Representation of the Root value of the XML file. */\n\tprivate static String VAL_ROOT = \"Root\";\n\t/** Representation of the Selector value of the XML file. */\n\tprivate static String VAL_SELECTOR = \"Selector\";\n\t/** Representation of the Sequence value of the XML file. */\n\tprivate static String VAL_SEQUENCE = \"Sequence\";\n\t/** Representation of the Parallel value of the XML file. */\n\tprivate static String VAL_PARALLEL = \"Parallel\";\n\t/** Representation of the Action value of the XML file. */\n\tprivate static String VAL_ACTION = \"Action\";\n\t/** Representation of the Condition value of the XML file. */\n\tprivate static String VAL_CONDITION = \"Condition\";\n\t/** Representation of the Random sequence value of the XML file. */\n\tprivate static String VAL_RANDOM_SEQUENCE = \"RandomSequence\";\n\t/** Representation of the Random selector value of the XML file. */\n\tprivate static String VAL_RANDOM_SELECTOR = \"RandomSelector\";\n\t/** Representation of the Interrupter value of the XML file. */\n\tprivate static String VAL_INTERRUPTER = \"Interrupter\";\n\t/** Representation of the Inverter value of the XML file. */\n\tprivate static String VAL_INVERTER = \"Inverter\";\n\t/** Representation of the Limit value of the XML file. */\n\tprivate static String VAL_LIMIT = \"Limit\";\n\t/** Representation of the Perform interruption value of the XML file. */\n\tprivate static String VAL_PERFORM_INTERRUPTION = \"PerformInterruption\";\n\t/** Representation of the Repeat value of the XML file. */\n\tprivate static String VAL_REPEAT = \"Repeat\";\n\t/** Representation of the Until fail value of the XML file. */\n\tprivate static String VAL_UNTIL_FAIL = \"UntilFail\";\n\t/** Representation of the Wait value of the XML file. */\n\tprivate static String VAL_WAIT = \"Wait\";\n\t/** Representation of the Subtree lookup value of the XML file. */\n\tprivate static String VAL_SUBTREE_LOOKUP = \"SubtreeLookup\";\n\t/** Representation of the Dynamic priority list value of the XML file. */\n\tprivate static String VAL_DYNAMIC_PRIORITY_LIST = \"DynamicPriorityList\";\n\t/** Representation of the Static priority list value of the XML file. */\n\tprivate static String VAL_STATIC_PRIORITY_LIST = \"StaticPriorityList\";\n\t/**\n\t * Representation of the Hierarchical context manager value of the XML file.\n\t */\n\tprivate static String VAL_HIERARCHICAL_CONTEXT_MANAGER = \"HierarchicalContextManager\";\n\t/** Representation of the Safe context manager value of the XML file. */\n\tprivate static String VAL_SAFE_CONTEXT_MANAGER = \"SafeContextManager\";\n\t/** Representation of the Safe output context manager value of the XML file. */\n\tprivate static String VAL_SAFE_OUTPUT_CONTEXT_MANAGER = \"SafeOutputContextManager\";\n\t/** Representation of the Variable renamer value of the XML file. */\n\tprivate static String VAL_VARIABLE_RENAMER = \"VariableRenamer\";\n\t/** Representation of the Success value of the XML file. */\n\tprivate static String VAL_SUCCESS = \"Success\";\n\t/** Representation of the Succeeder value of the XML file. */\n\tprivate static String VAL_SUCCEEDER = \"Succeeder\";\n\t/** Representation of the Success value of the XML file. */\n\tprivate static String VAL_FAILURE = \"Failure\";\n\t/** Representation of the Sequence parallel policy value of the XML file. */\n\tprivate static String VAL_SEQUENCE_POLICY = \"sequence\";\n\t/** Representation of the Selector parallel policy value of the XML file. */\n\tprivate static String VAL_SELECTOR_POLICY = \"selector\";\n\t/** Representation of the Success status value of the XML file. */\n\tprivate static String VAL_SUCCESS_STATUS = \"success\";\n\t/** Representation of the Failure status value of the XML file. */\n\tprivate static String VAL_FAILURE_STATUS = \"failure\";\n\t/** Representation of the Variable name value of the XML file. */\n\tprivate static String VAL_VARIABLE_NAME = \"variableName\";\n\t/** Representation of the New variable name value of the XML file. */\n\tprivate static String VAL_NEW_VARIABLE_NAME = \"newVariableName\";\n\n\t/**\n\t * Representation of the Node ID value of the Perform Interruption task of the XML file.\n\t */\n\tprivate static String VAL_NODE_ID = \"nodeID\";\n\t/**\n\t * Representation of the Expected result value of the Perform Interruption task of the XML file.\n\t */\n\tprivate static String VAL_EXPECTED_RESULT = \"expectedResult\";\n\n\t/** Name of the java class that represents a selector node of the tree. */\n\tprivate static String CLASS_SELECTOR = ModelSelector.class.getCanonicalName();\n\t/** Name of the java class that represents a sequence node of the tree. */\n\tprivate static String CLASS_SEQUENCE = ModelSequence.class.getCanonicalName();\n\t/** Name of the java class that represents a parallel node of the tree. */\n\tprivate static String CLASS_PARALLEL = ModelParallel.class.getCanonicalName();\n\t/** Name of the java class that represents an action node of the tree. */\n\tprivate static String CLASS_ACTION = ModelAction.class.getCanonicalName();\n\t/** Name of the java class that represents a condition node of the tree. */\n\tprivate static String CLASS_CONDITION = ModelCondition.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents a random sequence node of the tree.\n\t */\n\tprivate static String CLASS_RANDOM_SEQUENCE = ModelRandomSequence.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents a random selector node of the tree.\n\t */\n\tprivate static String CLASS_RANDOM_SELECTOR = ModelRandomSelector.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents an interrupter node of the tree.\n\t */\n\tprivate static String CLASS_INTERRUPTER = ModelInterrupter.class.getCanonicalName();\n\t/** Name of the java class that represents an inverter node of the tree. */\n\tprivate static String CLASS_INVERTER = ModelInverter.class.getCanonicalName();\n\t/** Name of the java class that represents a limit node of the tree. */\n\tprivate static String CLASS_LIMIT = ModelLimit.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents a perform interruption node of the tree.\n\t */\n\tprivate static String CLASS_PERFORM_INTERRUPTION = ModelPerformInterruption.class\n\t\t\t.getCanonicalName();\n\t/** Name of the java class that represents a repeat node of the tree. */\n\tprivate static String CLASS_REPEAT = ModelRepeat.class.getCanonicalName();\n\t/** Name of the java class that represents an until fail node of the tree. */\n\tprivate static String CLASS_UNTIL_FAIL = ModelUntilFail.class.getCanonicalName();\n\t/** Name of the java class that represents a wait node of the tree. */\n\tprivate static String CLASS_WAIT = ModelWait.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents a subtree lookup node of the tree.\n\t */\n\tprivate static String CLASS_SUBTREE_LOOKUP = ModelSubtreeLookup.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents a dynamic priority list node of the tree.\n\t */\n\tprivate static String CLASS_DYNAMIC_PRIORITY_LIST = ModelDynamicPriorityList.class\n\t\t\t.getCanonicalName();\n\t/**\n\t * Name of the java class that represents a static priority list node of the tree.\n\t */\n\tprivate static String CLASS_STATIC_PRIORITY_LIST = ModelStaticPriorityList.class\n\t\t\t.getCanonicalName();\n\n\t/**\n\t * Name of the java class that represents a hierarchical context manager node of the tree.\n\t */\n\tprivate static String CLASS_HIERARCHICAL_CONTEXT_MANAGER = ModelHierarchicalContextManager.class\n\t\t\t.getCanonicalName();\n\n\t/**\n\t * Name of the java class that represents a safe context manager node of the tree.\n\t */\n\tprivate static String CLASS_SAFE_CONTEXT_MANAGER = ModelSafeContextManager.class\n\t\t\t.getCanonicalName();\n\n\t/**\n\t * Name of the java class that represents a safe output context manager node of the tree.\n\t */\n\tprivate static String CLASS_SAFE_OUTPUT_CONTEXT_MANAGER = ModelSafeOutputContextManager.class\n\t\t\t.getCanonicalName();\n\n\t/**\n\t * Name of the java class that represents the parallel node possible policies.\n\t */\n\tprivate static String CLASS_PARALLEL_POLICY = ParallelPolicy.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents the variable renamer task.\n\t */\n\tprivate static String CLASS_VARIABLE_RENAMER = ModelVariableRenamer.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents the success task.\n\t */\n\tprivate static String CLASS_SUCCESS = ModelSuccess.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents the failure task.\n\t */\n\tprivate static String CLASS_FAILURE = ModelFailure.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents the succeeder task.\n\t */\n\tprivate static String CLASS_SUCCEEDER = ModelSucceeder.class.getCanonicalName();\n\t/**\n\t * Name of the java class that represents a task status.\n\t */\n\tprivate static String CLASS_STATUS = Status.class.getCanonicalName();\n\n\t/**\n\t * Pattern for verifying list of variables values. This is used, for instance, for checking the\n\t * correctness of the list of variables of the SafeOutputContextManager node.\n\t */\n\tprivate static final Pattern pattern = Pattern.compile(\"(( )*\\\"[a-zA-Z_0-9\\\\s]+\\\"( )*)+\");\n\n\t/**\n\t * List that stores which interrupters are associated to which perform interruption nodes.\n\t */\n\tprivate List<InterrupterMatch> interruptersMatchings;\n\t/**\n\t * The root element of the tree in the BT XML file. This is not the Tree tag, but the root Node\n\t * tag.\n\t */\n\tprivate Element root;\n\t/**\n\t * The name of the package that contains the low level actions of the BT whose expression is\n\t * going to be built.\n\t */\n\tprivate String actionsPackage;\n\t/**\n\t * The name of the package that contains the low level conditions of the BT whose expression is\n\t * going to be built.\n\t */\n\tprivate String conditionsPackage;\n\t/**\n\t * The MMPM definition of the low level actions used when building the BT.\n\t */\n\tprivate List<ParsedAction> actionsDefinition;\n\t/**\n\t * The MMPM definition of the low level conditions used when building the BT.\n\t */\n\tprivate List<ParsedMethod> conditionsDefinition;\n\t/**\n\t * The name of the file that contains the tree.\n\t */\n\tprivate String treeFileName;\n\n\t/**\n\t * This method creates a String representing the declaration of a BT ( {@link ModelTask}\n\t * variable) read from a BT XML file in the format of <i>BT Editor</i>.\n\t * <p>\n\t * This method reads the XML file <code>treeFileName</code> and creates a ModelTask variable of\n\t * name <code>treeVariableName</code> that represents the BT in the file.\n\t * <p>\n\t * In order to generate the expression for the tree, some additional information must be\n\t * provided:\n\t * <ul>\n\t * <li><code>actionsPackage</code> is the name of the Java package that contains all the low\n\t * level actions that are used in the tree.\n\t * <li><code>conditionsPackage</code> is the name of the Java package that contains all the low\n\t * level conditions that are used in the tree.\n\t * <li><code>actionsDefinition</code> is a list containing the MMPM definition of all the low\n\t * level actions that are used in the tree.\n\t * <li><code>conditionsDefinition</code> is a list containing the MMPM definition of all the low\n\t * level conditions that are used in the tree.\n\t * <li><code>declareTree</code> is a flag that indicates whether the tree returned expression\n\t * should also declare the variable <code>treeVariableName</code> or assume that it already\n\t * exists. If true, it will be declared.\n\t * </ul>\n\t * \n\t * @param treeVariableName\n\t *            name of the variable that will store the tree.\n\t * @param treeFileName\n\t *            XML file that contains the BT.\n\t * @param actionsPackage\n\t *            name of the Java package that contains all the low level actions that are used in\n\t *            the tree.\n\t * @param conditionsPackage\n\t *            name of the Java package that contains all the low level conditions that are used\n\t *            in the tree.\n\t * @param actionsDefinition\n\t *            list containing the MMPM definition of all the low level actions that are used in\n\t *            the tree.\n\t * @param conditionsDefinition\n\t *            list containing the MMPM definition of all the low level conditions that are used\n\t *            in the tree.\n\t * @param declareTree\n\t *            flag that indicates whether the tree returned expression should also declare the\n\t *            variable <code>treeVariableName</code> or assume that it already exists. If true,\n\t *            it will be declared.\n\t * @return a String representing a expression that assigns to the variable\n\t *         <code>treeVariableName</code> a ModelTask representing the behaviour tree in\n\t *         <code>treeFileName</code>, as explained above.\n\t * @throws ModelBTGenerationException\n\t *             if there is any error when creating the expression for the behaviour tree.\n\t */\n\tpublic String getModelBTDeclaration(String treeVariableName, String treeFileName,\n\t\t\tString actionsPackage, String conditionsPackage, List<ParsedAction> actionsDefinition,\n\t\t\tList<ParsedMethod> conditionsDefinition, boolean declareTree)\n\t\t\tthrows ModelBTGenerationException {\n\t\ttry {\n\t\t\tthis.treeFileName = treeFileName;\n\t\t\tFileInputStream file = new FileInputStream(treeFileName);\n\t\t\tBTFileParseResult result = parseBTFile(file, actionsPackage, conditionsPackage,\n\t\t\t\t\tactionsDefinition, conditionsDefinition);\n\t\t\tfile.close();\n\t\t\treturn completeModelBTDeclaration(treeVariableName, result, declareTree);\n\t\t} catch (Exception e) {\n\t\t\tthrow new ModelBTGenerationException(\n\t\t\t\t\t\"Could not generate an expresion for the behaviour tree: \" + e.getMessage(), e);\n\t\t}\n\t}\n\n\t/**\n\t * This method parses a BT XML file in the format of <i>BT Editor</i> and mainly generates a\n\t * \"new\" expression that is able to build the tree in the file.\n\t * <p>\n\t * This function returns a {@link BTFileParseResult} object that contains:\n\t * <ul>\n\t * <li>A \"new\" expression (as a String) that is able to construct the tree specified in the\n\t * file.\n\t * <li>A list of all the matches between interrupters and perform interruption tasks in the\n\t * tree.\n\t * </ul>\n\t * \n\t * It must be noted that the \"new\" expression is somehow incomplete, since interrupters are not\n\t * assigned to perform interruptions. That is why the list of match is given. By using it, the\n\t * external caller should take care of creating another expression that links each perform\n\t * interruption with its corresponding interrupter task.\n\t * \n\t * @param file\n\t *            the XML file that contains the behaviour tree.\n\t * @param actionsPackage\n\t *            name of the Java package that contains all the low level actions that are used in\n\t *            the tree.\n\t * @param conditionsPackage\n\t *            name of the Java package that contains all the low level conditions that are used\n\t *            in the tree.\n\t * @param actionsDefinition\n\t *            list containing the MMPM definition of all the low level actions that are used in\n\t *            the tree.\n\t * @param conditionsDefinition\n\t *            list containing the MMPM definition of all the low level conditions that are used\n\t *            in the tree.\n\t * @return a BTFileParseResult as described above.\n\t */\n\tprivate BTFileParseResult parseBTFile(FileInputStream file, String actionsPackage,\n\t\t\tString conditionsPackage, List<ParsedAction> actionsDefinition,\n\t\t\tList<ParsedMethod> conditionsDefinition) {\n\n\t\tthis.actionsDefinition = actionsDefinition;\n\t\tthis.conditionsDefinition = conditionsDefinition;\n\t\tthis.actionsPackage = actionsPackage;\n\t\tthis.conditionsPackage = conditionsPackage;\n\n\t\tSAXBuilder builder = new SAXBuilder();\n\n\t\tStringBuffer result = new StringBuffer();\n\n\t\ttry {\n\t\t\tDocument doc = builder.build(file);\n\t\t\tElement documentRoot = doc.getRootElement();\n\n\t\t\tthis.root = (Element) ((Element) (((Element) documentRoot.getChildren().get(0))\n\t\t\t\t\t.getChildren().get(0))).getChildren().get(0);\n\n\t\t\tthis.interruptersMatchings = new LinkedList<InterrupterMatch>();\n\n\t\t\tprocessElement(new LinkedList<Position>(), this.root, result, this.root);\n\n\t\t\treturn new BTFileParseResult(result.toString(), this.interruptersMatchings);\n\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Could not generate an expresion for the behaviour tree: \"\n\t\t\t\t\t+ e.getMessage(), e);\n\t\t}\n\t}\n\n\t/**\n\t * Given the result of the method\n\t * {@link #parseBTFile(FileInputStream, String, String, List, List)}, this method completes the\n\t * declaration of the behaviour tree, adding whatever stuff is necessary in order for the tree\n\t * to be usable.\n\t * <p>\n\t * This method returns a String such as:\n\t * <ul>\n\t * <li>The \"new\" expression <code>generationResult</code> is assigned to a variable of name\n\t * <code>treeVariableName</code>.\n\t * <li>New statements are added so that the interrupters-perform interruptions matches in\n\t * <code>generationResult</code> are carried out.\n\t * </ul>\n\t * \n\t * If <code>declareTree</code> is true, then <code>treeVariableName</code> will be declared (as\n\t * a {@link ModelTask}). Otherwise, this method will assume that the variable already exists.\n\t * \n\t * @param treeVariableName\n\t *            name of the variable that will store the tree.\n\t * @param generationResult\n\t *            the BTFileParseResult from which the final expression for declaring the tree is\n\t *            constructed.\n\t * @param declareTree\n\t *            flag that indicates whether the tree returned expression should also declare the\n\t *            variable <code>treeVariableName</code> or assume that it already exists. If true,\n\t *            it will be declared.\n\t * @return a String as described above.\n\t */\n\tprivate String completeModelBTDeclaration(String treeVariableName,\n\t\t\tBTFileParseResult generationResult, boolean declareTree) {\n\t\tString result = new String();\n\n\t\tresult += (declareTree ? ModelTask.class.getCanonicalName() + \" \" : \"\") + treeVariableName\n\t\t\t\t+ \" = \" + generationResult.getModelBTExpression() + \";\";\n\n\t\tif (generationResult.getInterruptersMatches().size() != 0) {\n\t\t\tresult += \"\\n\\n\";\n\t\t\tfor (InterrupterMatch match : generationResult.getInterruptersMatches()) {\n\t\t\t\tresult += getInterrupterExpression(treeVariableName, match) + \";\";\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Given an InterrupterMatch, this method creates a expression that assigns the perform\n\t * interrupter its corresponding interrupter. <code>treeVariableName</code> is the name of the\n\t * ModelTask variable that stores the tree.\n\t */\n\tprivate String getInterrupterExpression(String treeVariableName, InterrupterMatch match) {\n\t\t/* First, get a \"new\" expression for the position of the interrupter. */\n\t\tString interrupterPositionDeclaration = getPositionNewExpression(match\n\t\t\t\t.getInterrupterPosition());\n\n\t\t/*\n\t\t * Then, get a \"new\" expression for the position of the perform interruption.\n\t\t */\n\t\tString performInterruptionPositionDeclaration = getPositionNewExpression(match\n\t\t\t\t.getPerformInterruptionPosition());\n\n\t\t/*\n\t\t * Expression that points to the subtree where the match between interrupter and perform\n\t\t * interruption takes place.\n\t\t */\n\t\tString destinationTreeExpression = treeVariableName;\n\n\t\tfor (Position pathToTree : match.getPathToTree()) {\n\t\t\tdestinationTreeExpression += \".findNode(\" + getPositionNewExpression(pathToTree)\n\t\t\t\t\t+ \").getGuard()\";\n\t\t}\n\n\t\t/* Finally create the expression that sets the match. */\n\t\tString result = \"((\" + ModelPerformInterruption.class.getCanonicalName() + \")\"\n\t\t\t\t+ destinationTreeExpression + \".findNode(\" + performInterruptionPositionDeclaration\n\t\t\t\t+ \")).setInterrupter((\" + ModelInterrupter.class.getCanonicalName() + \")\"\n\t\t\t\t+ destinationTreeExpression + \".findNode(\" + interrupterPositionDeclaration + \"))\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns a \"new\" expression for a Position object.\n\t */\n\tprivate String getPositionNewExpression(Position pos) {\n\t\tString result = \"new \" + Position.class.getCanonicalName() + \"(\";\n\n\t\tif (pos.getMoves().size() != 0) {\n\t\t\tfor (Integer move : pos.getMoves()) {\n\t\t\t\tresult += move + \", \";\n\t\t\t}\n\n\t\t\tresult = result.substring(0, result.length() - 2);\n\t\t}\n\n\t\tresult += \")\";\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * This method creates the \"new\" statement for a BT given its representation in XML format.\n\t * <p>\n\t * <code>e</code> is the element that is currently being analyzed, that for which the expression\n\t * will be produced (it must be a Node element of the XML file).\n\t * <p>\n\t * <code>pathToCurrentTree</code> represents the path to the behaviour tree that is currently\n\t * being analyzed. An empty list represents the original behaviour tree. A non-empty list\n\t * represents a guard of some node of the tree, or even a guard of a guard of the original tree.\n\t * See {@link InterrupterMatch} for more information about this. <code>currentRoot</code> is the\n\t * root of the tree that is currently being analyzed.\n\t * <p>\n\t * The expression that is returned is complete except for the fact that interrupters are not\n\t * assigned to perform interruptions.\n\t * <p>\n\t * All the matches among interrupters and perform interruptions are stored in\n\t * {@link #interruptersMatchings}, so that they can be used later on to complete the expression\n\t * for tree.\n\t */\n\tprivate void processElement(List<Position> pathToCurrentTree, Element currentRoot,\n\t\t\tStringBuffer result, Element e) {\n\t\tif (e.getName().equals(TAG_CHILDREN)) {\n\t\t\t/* If tag is \"children\", process all the children. */\n\t\t\tList<Element> children = e.getChildren();\n\n\t\t\tfor (Element child : children) {\n\t\t\t\tStringBuffer partialResult = new StringBuffer();\n\t\t\t\tprocessElement(pathToCurrentTree, currentRoot, partialResult, child);\n\t\t\t\tresult.append(\", \" + partialResult);\n\t\t\t}\n\t\t} else if (e.getName().equals(TAG_NODE)) {\n\t\t\t/* First of all, process the guard. */\n\t\t\tElement guard = e.getChild(TAG_GUARD);\n\n\t\t\tString guardExpression;\n\n\t\t\tif (guard != null) {\n\t\t\t\tStringBuffer guardExpressionBuffer = new StringBuffer();\n\t\t\t\tList<Position> nextPath = new LinkedList<Position>(pathToCurrentTree);\n\t\t\t\tnextPath.add(findNode(currentRoot, e.getAttributeValue(ATTR_ID), new Position()));\n\t\t\t\tprocessElement(nextPath, guard.getChild(TAG_NODE), guardExpressionBuffer,\n\t\t\t\t\t\tguard.getChild(TAG_NODE));\n\t\t\t\tguardExpression = guardExpressionBuffer.toString();\n\t\t\t} else {\n\t\t\t\tguardExpression = \"null\";\n\t\t\t}\n\n\t\t\t/* Then, construct an expression for the node itself. */\n\t\t\tString type = e.getAttributeValue(ATTR_TYPE);\n\n\t\t\tif (type != null) {\n\t\t\t\tif (type.equals(VAL_SELECTOR)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_SELECTOR + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_SEQUENCE)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_SEQUENCE + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_RANDOM_SEQUENCE)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_RANDOM_SEQUENCE + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_RANDOM_SELECTOR)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_RANDOM_SELECTOR + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_INTERRUPTER)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_INTERRUPTER + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_LIMIT)) {\n\t\t\t\t\tString runs = e.getChild(TAG_PARAMETERS).getChild(TAG_PARAMETER).getText();\n\t\t\t\t\tresult.append(\"new \" + CLASS_LIMIT + \"(\" + guardExpression + \", \" + runs);\n\t\t\t\t} else if (type.equals(VAL_INVERTER)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_INVERTER + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_PERFORM_INTERRUPTION)) {\n\t\t\t\t\t/* Note that the interrupter is set to null. */\n\n\t\t\t\t\tList<Element> parameters = e.getChild(TAG_PARAMETERS)\n\t\t\t\t\t\t\t.getChildren(TAG_PARAMETER);\n\n\t\t\t\t\t/* First, retrieve the expected result parameter. */\n\t\t\t\t\tElement desiredResultParameter = null;\n\n\t\t\t\t\tfor (Element currentParameter : parameters) {\n\t\t\t\t\t\tif (currentParameter.getAttributeValue(ATTR_NAME).equals(\n\t\t\t\t\t\t\t\tVAL_EXPECTED_RESULT)) {\n\t\t\t\t\t\t\tdesiredResultParameter = currentParameter;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tStatus desiredResult = statusFromString(desiredResultParameter.getText());\n\n\t\t\t\t\tresult.append(\"new \" + CLASS_PERFORM_INTERRUPTION + \"(\" + guardExpression\n\t\t\t\t\t\t\t+ \", null, \" + CLASS_STATUS + \".\" + desiredResult.toString());\n\n\t\t\t\t\t/*\n\t\t\t\t\t * Now we have to retrieve the ID of the interrupter that this perform\n\t\t\t\t\t * interruption will interrupt.\n\t\t\t\t\t */\n\t\t\t\t\tElement nodeIDParameter = null;\n\n\t\t\t\t\tfor (Element currentParameter : parameters) {\n\t\t\t\t\t\tif (currentParameter.getAttributeValue(ATTR_NAME).equals(VAL_NODE_ID)) {\n\t\t\t\t\t\t\tnodeIDParameter = currentParameter;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tString nodeID = nodeIDParameter.getText();\n\n\t\t\t\t\t/*\n\t\t\t\t\t * Now create the InterrupterMatch that represents the match between the\n\t\t\t\t\t * interrupter and the perform interruption.\n\t\t\t\t\t */\n\t\t\t\t\tPosition interrupterPosition = findNode(currentRoot, nodeID, new Position());\n\n\t\t\t\t\tif (interrupterPosition == null) {\n\t\t\t\t\t\tthrow new RuntimeException(\"Could not find node with ID \\\"\" + nodeID\n\t\t\t\t\t\t\t\t+ \"\\\" in the behaviour tree.\");\n\t\t\t\t\t}\n\n\t\t\t\t\tPosition performInterruptionPosition = findNode(currentRoot,\n\t\t\t\t\t\t\te.getAttributeValue(ATTR_ID), new Position());\n\n\t\t\t\t\tthis.interruptersMatchings.add(new InterrupterMatch(interrupterPosition,\n\t\t\t\t\t\t\tperformInterruptionPosition, pathToCurrentTree));\n\t\t\t\t} else if (type.equals(VAL_REPEAT)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_REPEAT + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_UNTIL_FAIL)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_UNTIL_FAIL + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_WAIT)) {\n\t\t\t\t\tString duration = e.getChild(TAG_PARAMETERS).getChild(TAG_PARAMETER).getText();\n\t\t\t\t\tresult.append(\"new \" + CLASS_WAIT + \"(\" + guardExpression + \", \" + duration);\n\t\t\t\t} else if (type.equals(VAL_PARALLEL)) {\n\t\t\t\t\tParallelPolicy policy = parallelPolicyFromString(e.getChild(TAG_PARAMETERS)\n\t\t\t\t\t\t\t.getChild(TAG_PARAMETER).getText());\n\t\t\t\t\tresult.append(\"new \" + CLASS_PARALLEL + \"(\" + guardExpression + \",\"\n\t\t\t\t\t\t\t+ CLASS_PARALLEL_POLICY + \".\" + policy.toString());\n\t\t\t\t} else if (type.equals(VAL_SUBTREE_LOOKUP)) {\n\t\t\t\t\tString subtreeName = e.getChild(TAG_PARAMETERS).getChild(TAG_PARAMETER)\n\t\t\t\t\t\t\t.getText();\n\t\t\t\t\tresult.append(\"new \" + CLASS_SUBTREE_LOOKUP + \"(\" + guardExpression + \",\"\n\t\t\t\t\t\t\t+ \"\\\"\" + subtreeName + \"\\\"\");\n\t\t\t\t} else if (type.equals(VAL_DYNAMIC_PRIORITY_LIST)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_DYNAMIC_PRIORITY_LIST + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_STATIC_PRIORITY_LIST)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_STATIC_PRIORITY_LIST + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_HIERARCHICAL_CONTEXT_MANAGER)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_HIERARCHICAL_CONTEXT_MANAGER + \"(\"\n\t\t\t\t\t\t\t+ guardExpression);\n\t\t\t\t} else if (type.equals(VAL_SAFE_CONTEXT_MANAGER)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_SAFE_CONTEXT_MANAGER + \"(\" + guardExpression);\n\n\t\t\t\t} else if (type.equals(VAL_SAFE_OUTPUT_CONTEXT_MANAGER)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_SAFE_OUTPUT_CONTEXT_MANAGER + \"(\"\n\t\t\t\t\t\t\t+ guardExpression + \", \" + getSafeOutputContextOutputListOfVariables(e));\n\n\t\t\t\t} else if (type.equals(VAL_SUCCESS)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_SUCCESS + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_FAILURE)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_FAILURE + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_SUCCEEDER)) {\n\t\t\t\t\tresult.append(\"new \" + CLASS_SUCCEEDER + \"(\" + guardExpression);\n\t\t\t\t} else if (type.equals(VAL_VARIABLE_RENAMER)) {\n\t\t\t\t\tList parameters = e.getChild(TAG_PARAMETERS).getChildren();\n\t\t\t\t\tElement param1 = (Element) parameters.get(0);\n\t\t\t\t\tElement param2 = (Element) parameters.get(1);\n\n\t\t\t\t\tString variableName = new String();\n\t\t\t\t\tString newVariableName = new String();\n\n\t\t\t\t\tif (param1.getAttributeValue(ATTR_NAME).equals(VAL_VARIABLE_NAME)) {\n\t\t\t\t\t\tvariableName = param1.getText();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewVariableName = param1.getText();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (param2.getAttributeValue(ATTR_NAME).equals(VAL_VARIABLE_NAME)) {\n\t\t\t\t\t\tvariableName = param2.getText();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewVariableName = param2.getText();\n\t\t\t\t\t}\n\n\t\t\t\t\tresult.append(\"new \" + CLASS_VARIABLE_RENAMER + \"(\" + guardExpression + \", \\\"\"\n\t\t\t\t\t\t\t+ variableName + \"\\\", \\\"\" + newVariableName + \"\\\"\");\n\t\t\t\t} else if (type.equals(VAL_ACTION)) {\n\t\t\t\t\tString actionName = e.getAttributeValue(ATTR_NAME);\n\t\t\t\t\tParsedAction mmpmAction = getAction(actionName);\n\t\t\t\t\tif (mmpmAction == null) {\n\t\t\t\t\t\tthrow new RuntimeException(\"The tree read from \" + this.treeFileName\n\t\t\t\t\t\t\t\t+ \" makes use of an action -\" + actionName\n\t\t\t\t\t\t\t\t+ \"- that could not be found in the domain files\");\n\t\t\t\t\t}\n\t\t\t\t\tString parameters = getActionStaticParameters(e, getAction(actionName));\n\t\t\t\t\tresult.append(\"new \" + actionsPackage + \".\" + actionName + \"(\"\n\t\t\t\t\t\t\t+ guardExpression + (parameters == null ? \"\" : \", \" + parameters));\n\t\t\t\t} else if (type.equals(VAL_CONDITION)) {\n\t\t\t\t\tString conditionName = e.getAttributeValue(ATTR_NAME);\n\t\t\t\t\tParsedMethod mmpmCondition = getCondition(conditionName);\n\t\t\t\t\tif (mmpmCondition == null) {\n\t\t\t\t\t\tthrow new RuntimeException(\"The tree read from \" + this.treeFileName\n\t\t\t\t\t\t\t\t+ \" makes use of a condition -\" + conditionName\n\t\t\t\t\t\t\t\t+ \"- that could not be found in the domain files\");\n\t\t\t\t\t}\n\t\t\t\t\tString parameters = getConditionStaticParameters(e, mmpmCondition);\n\t\t\t\t\tresult.append(\"new \" + conditionsPackage + \".\" + e.getAttributeValue(ATTR_NAME)\n\t\t\t\t\t\t\t+ \"(\" + guardExpression + (parameters == null ? \"\" : \", \" + parameters));\n\t\t\t\t}\n\n\t\t\t\tList<Element> children = e.getChildren();\n\n\t\t\t\tif (children.size() != 0) {\n\t\t\t\t\tElement childrenNode = null;\n\n\t\t\t\t\tfor (int i = 0; i < children.size(); i++) {\n\t\t\t\t\t\tElement currentChild = children.get(i);\n\n\t\t\t\t\t\tif (currentChild.getName().equals(TAG_CHILDREN)) {\n\t\t\t\t\t\t\tchildrenNode = currentChild;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (childrenNode != null) {\n\t\t\t\t\t\tStringBuffer partialResult = new StringBuffer();\n\t\t\t\t\t\tprocessElement(pathToCurrentTree, currentRoot, partialResult, childrenNode);\n\t\t\t\t\t\tresult.append(partialResult);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tresult.append(\")\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Given the String representation of a parallel task policy in the XML file, this method\n\t * returns the corresponding {@link ParallelPolicy} object.\n\t * \n\t * @param value\n\t *            the string representation of the parallel policy.\n\t * @return the ParallelPolicy associated to <code>value</code>.\n\t */\n\tprivate ParallelPolicy parallelPolicyFromString(String value) {\n\t\tif (value.equalsIgnoreCase(VAL_SEQUENCE_POLICY)) {\n\t\t\treturn ParallelPolicy.SEQUENCE_POLICY;\n\t\t}\n\t\tif (value.equalsIgnoreCase(VAL_SELECTOR_POLICY)) {\n\t\t\treturn ParallelPolicy.SELECTOR_POLICY;\n\t\t}\n\t\tthrow new RuntimeException(\"Invalid string for parallel policy: \" + value);\n\t}\n\n\t/**\n\t * Given the String representation of a task status in the XML file, this method returns the\n\t * corresponding {@link Status} object.\n\t * \n\t * @param value\n\t *            the string representation of the task status.\n\t * @return the Status associated to <code>value</code>.\n\t */\n\tprivate Status statusFromString(String value) {\n\t\tif (value.equalsIgnoreCase(VAL_SUCCESS_STATUS)) {\n\t\t\treturn Status.SUCCESS;\n\t\t}\n\t\tif (value.equalsIgnoreCase(VAL_FAILURE_STATUS)) {\n\t\t\treturn Status.FAILURE;\n\t\t}\n\t\tthrow new RuntimeException(\"Invalid string for task status: \" + value);\n\t}\n\n\t/**\n\t * <code>e</code> is an Element representing a node ({@link #TAG_NODE}) of type action (\n\t * {@link #VAL_ACTION}) in the BT XML file. <code>actionDefinition</code> represents the MMPM\n\t * definition of such action (MMPM action). This method returns a String representing the list\n\t * of values for the parameters that the corresponding ModelAction object receives in its\n\t * constructor.\n\t * <p>\n\t * For each parameter in the XML file, two values are created:\n\t * <ul>\n\t * <li>The value itself: if an actual value is specified in the XML file (that is, the value of\n\t * the parameter is not going to be read from the context), an object containing that value is\n\t * created. Otherwise, it is null.\n\t * <li>The context location: if an actual value is not specified (that is, the value is going to\n\t * be read from the context), then a String containing the location in the context is created.\n\t * Otherwise, it is null.\n\t * </ul>\n\t * \n\t * The parameters are separated by commas. If the element does not have any parameters, null is\n\t * returned.\n\t * \n\t * @param e\n\t *            the XML node element representing the action.\n\t * @param actionDefinition\n\t *            the MMPM definition of the action.\n\t * @return a String as described above.\n\t */\n\tprivate String getActionStaticParameters(Element e, ParsedAction actionDefinition) {\n\t\tString result = null;\n\n\t\tElement parametersElement = e.getChild(TAG_PARAMETERS);\n\t\tif (parametersElement != null) {\n\t\t\tList<Element> parameters = parametersElement.getChildren();\n\t\t\tList<ParsedActionParameter> parametersDefinition = actionDefinition.getParameters();\n\n\t\t\tif (parameters.size() != parametersDefinition.size()) {\n\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\"The number of parameters of the action \"\n\t\t\t\t\t\t\t\t+ actionDefinition.getName()\n\t\t\t\t\t\t\t\t+ \" defined in the MMPM domain file does not match that of the action in the XML file\");\n\t\t\t}\n\n\t\t\tif (parameters.size() != 0) {\n\t\t\t\tIterator<Element> parametersIterator = parameters.iterator();\n\t\t\t\tIterator<ParsedActionParameter> parametersDefinitionIterator = parametersDefinition\n\t\t\t\t\t\t.iterator();\n\n\t\t\t\tresult = new String();\n\n\t\t\t\twhile (parametersIterator.hasNext()) {\n\t\t\t\t\tElement currentParam = parametersIterator.next();\n\t\t\t\t\tParsedActionParameter currentParamDefinition = parametersDefinitionIterator\n\t\t\t\t\t\t\t.next();\n\n\t\t\t\t\tif (currentParam.getAttributeValue(ATTR_FROM_CONTEXT).equals(\"true\")) {\n\t\t\t\t\t\tresult += \"null, \" + \"\\\"\" + currentParam.getText() + \"\\\"\" + \", \";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * When the parameter does not come from the context, an appropriate object\n\t\t\t\t\t\t * must be constructed.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tresult += getNewExpression(currentParamDefinition.getType(),\n\t\t\t\t\t\t\t\tcurrentParam.getText())\n\t\t\t\t\t\t\t\t+ \", null, \";\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tresult = result.substring(0, result.length() - 2);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * <code>e</code> is an Element representing a node ({@link #TAG_NODE}) of type condition (\n\t * {@link #VAL_CONDITION}) in the BT XML file. <code>conditionDefinition</code> represents the\n\t * MMPM definition of such condition (MMPM sensor). This method returns a String representing\n\t * the list of values for the parameters that the corresponding ModelCondition object receives\n\t * in its constructor.\n\t * <p>\n\t * For each parameter in the XML file, two values are created:\n\t * <ul>\n\t * <li>The value itself: if an actual value is specified in the XML file (that is, the value of\n\t * the parameter is not going to be read from the context), an object containing that value is\n\t * created. Otherwise, it is null.\n\t * <li>The context location: if an actual value is not specified (that is, the value is going to\n\t * be read from the context), then a String containing the location in the context is created.\n\t * Otherwise, it is null.\n\t * </ul>\n\t * \n\t * The parameters are separated by commas. If the element does not have any parameters, null is\n\t * returned.\n\t * \n\t * @param e\n\t *            the XML node element representing the condition.\n\t * @param conditionDefinition\n\t *            the MMPM definition of the condition.\n\t * @return a String as described above.\n\t */\n\tprivate String getConditionStaticParameters(Element e, ParsedMethod conditionDefinition) {\n\t\tString result = null;\n\n\t\tElement parametersElement = e.getChild(TAG_PARAMETERS);\n\t\tif (parametersElement != null) {\n\t\t\tList<Element> parameters = parametersElement.getChildren();\n\t\t\tList<ParsedActionParameter> parametersDefinition = conditionDefinition.getParameters();\n\n\t\t\tif (parameters.size() != parametersDefinition.size()) {\n\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\"The number of parameters of the sensor \"\n\t\t\t\t\t\t\t\t+ conditionDefinition.getName()\n\t\t\t\t\t\t\t\t+ \" defined in the MMPM domain file does not match that of the condition in the XML file\");\n\t\t\t}\n\n\t\t\tif (parameters.size() != 0) {\n\t\t\t\tIterator<Element> parametersIterator = parameters.iterator();\n\t\t\t\tIterator<ParsedActionParameter> parametersDefinitionIterator = parametersDefinition\n\t\t\t\t\t\t.iterator();\n\n\t\t\t\tresult = new String();\n\n\t\t\t\twhile (parametersIterator.hasNext()) {\n\t\t\t\t\tElement currentParam = parametersIterator.next();\n\t\t\t\t\tParsedActionParameter currentParamDefinition = parametersDefinitionIterator\n\t\t\t\t\t\t\t.next();\n\n\t\t\t\t\tif (currentParam.getAttributeValue(ATTR_FROM_CONTEXT).equals(\"true\")) {\n\t\t\t\t\t\t/* If the parameter comes from the context... */\n\t\t\t\t\t\tresult += \"null, \" + \"\\\"\" + currentParam.getText() + \"\\\"\" + \", \";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * When the parameter does not come from the context, an appropriate object\n\t\t\t\t\t\t * must be constructed.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tresult += getNewExpression(currentParamDefinition.getType(),\n\t\t\t\t\t\t\t\tcurrentParam.getText())\n\t\t\t\t\t\t\t\t+ \", null, \";\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tresult = result.substring(0, result.length() - 2);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Given a MMPM parameter type and a String read from the BT XML file, this function returns a\n\t * String representing a \"new\" statement that creates an object of a compatible type with the\n\t * specified value. Keep in mind that MMPM types are converted according to\n\t * {@link Util#fromMMPMParameterType(ActionParameterType)}. Note that\n\t * {@link ActionParameterType#ENTITY_ID} is not allowed, since such MMPM type is treated as a\n\t * Java Object that must neccesarily be retrieved from the context.\n\t * \n\t * @param type\n\t *            the MMPM type of the expression.\n\t * @param value\n\t *            the value of the expression.\n\t * @return the \"new\" expression that constructs a variable of a type compatible with\n\t *         <code>type</code> and value <code>value</code>.\n\t */\n\tprivate String getNewExpression(ActionParameterType type, String value) {\n\t\tClass actualClass = Util.fromMMPMParameterType(type);\n\n\t\tif (actualClass.equals(Integer.class)) {\n\t\t\treturn \"(int)\" + value;\n\t\t} else if (actualClass.equals(Float.class)) {\n\t\t\treturn \"(float)\" + value;\n\t\t} else if (actualClass.equals(Boolean.class)) {\n\t\t\treturn \"(boolean)\" + value;\n\t\t} else if (actualClass.equals(String.class)) {\n\t\t\treturn \"\\\"\" + value + \"\\\"\";\n\t\t} else if (actualClass.equals(float[].class)) {\n\t\t\tString[] numbers = value.split(\"( )+\");\n\t\t\tString result = \"new \" + float[].class.getCanonicalName() + \"{\";\n\t\t\tfor (String currentNumber : numbers) {\n\t\t\t\tresult += currentNumber + \", \";\n\t\t\t}\n\t\t\tresult = result.substring(0, result.length() - 2);\n\t\t\tresult += \"}\";\n\t\t\treturn result;\n\t\t}\n\n\t\tthrow new RuntimeException(\"Unexpected action parameter type: \" + type.name());\n\t}\n\n\t/**\n\t * Given a Node element ({@link #TAG_NODE}) <code>nodeElement</code> of the BT in the XML file,\n\t * this method returns the position of a descendant Node element (also including\n\t * <code>nodeElement</code>) whose identifier ( {@link #ATTR_ID}) is <code>nodeID</code>. The\n\t * position is computed from <code>currentPosition</code>, which is the position of\n\t * <code>nodeElement</code> in the tree.\n\t * <p>\n\t * If such a node is not found, null is returned.\n\t * \n\t * @param nodeElement\n\t *            the element from which the search starts.\n\t * @param nodeID\n\t *            the identifier of the node being searched for.\n\t * @param currentPosition\n\t *            the position of <code>nodeElement</code> in the tree.\n\t * @return the node with identifier <code>nodeID</code>, or null in case it is not found.\n\t */\n\tprivate Position findNode(Element nodeElement, String nodeID, Position currentPosition) {\n\n\t\tif (nodeElement.getAttributeValue(ATTR_ID).equals(nodeID)) {\n\t\t\treturn currentPosition;\n\t\t}\n\n\t\tElement childrenElement = nodeElement.getChild(TAG_CHILDREN);\n\n\t\tif (childrenElement != null) {\n\t\t\tList<Element> children = childrenElement.getChildren();\n\n\t\t\tfor (int i = 0; i < children.size(); i++) {\n\t\t\t\tPosition currentChildPosition = new Position(currentPosition);\n\t\t\t\tcurrentChildPosition.addMove(i);\n\t\t\t\tPosition found = findNode(children.get(i), nodeID, currentChildPosition);\n\t\t\t\tif (found != null) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * An InterrupterMatch just represents a match between an interrupter and a perform interruption\n\t * task in a BT. This class mainly stores two positions, the positions of the tasks that match.\n\t * <p>\n\t * When a match has to be performed, we must take into account that the match itself may be in\n\t * the tasks of a node's guard. This match may even be between tasks of a guard of a node's\n\t * guard, and so on.\n\t * <p>\n\t * We may therefore think that matches happen between tasks in trees, and that each guard is a\n\t * tree independent from other guards as well as the original tree. Therefore, the\n\t * InterrupterMatch also includes some information to know what is the tree (guard, or guard\n\t * within guard, and so on) where the match has to be applied. This is just a list of Position\n\t * objects. If the list if empty, the match has to be done in the original tree. If not, each\n\t * Position object represents a path from the root of the last tree to the next guard. For\n\t * example, if the list contains one Position object, the match is between two tasks in the tree\n\t * whose root is the guard of the node pointed by such position. If the list contains two\n\t * Position objects, then the same process is applied twice: the first Position object points to\n\t * a guard object (that of the node pointed by the position). The second Position object is used\n\t * to get the next guard, starting from that obtained from the first Position. The match is\n\t * between two tasks of the tree whose root is this last guard.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static class InterrupterMatch {\n\t\t/** The position of the interrupter. */\n\t\tprivate Position interrupterPosition;\n\t\t/** The position of the perform interruption. */\n\t\tprivate Position performInterruptionPosition;\n\t\t/** The path to the subtree where the match takes place. */\n\t\tprivate List<Position> pathToTree;\n\n\t\t/**\n\t\t * Creates an InterrupterMatch with two positions.\n\t\t * \n\t\t * @param interrupterPosition\n\t\t *            the position of the interrupter.\n\t\t * @param performInterruptionPosition\n\t\t *            the position of the perform interruption.\n\t\t * @param pathToTree\n\t\t *            the path to the tree where the match takes place, as described in\n\t\t *            {@link InterrupterMatch}.\n\t\t */\n\t\tpublic InterrupterMatch(Position interrupterPosition, Position performInterruptionPosition,\n\t\t\t\tList<Position> pathToTree) {\n\n\t\t\tif (interrupterPosition == null) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\n\t\t\tif (performInterruptionPosition == null) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\n\t\t\tif (pathToTree == null) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\n\t\t\tthis.interrupterPosition = interrupterPosition;\n\t\t\tthis.performInterruptionPosition = performInterruptionPosition;\n\t\t\tthis.pathToTree = pathToTree;\n\t\t}\n\n\t\t/**\n\t\t * Returns the position of the interrupter.\n\t\t */\n\t\tpublic Position getInterrupterPosition() {\n\t\t\treturn this.interrupterPosition;\n\t\t}\n\n\t\t/**\n\t\t * Returns the position of the perform interruption.\n\t\t */\n\t\tpublic Position getPerformInterruptionPosition() {\n\t\t\treturn this.performInterruptionPosition;\n\t\t}\n\n\t\t/**\n\t\t * Returns the path to the tree where the match takes place. Returns an empty list if the\n\t\t * match is done between two tasks of the original behaviour tree.\n\t\t */\n\t\tpublic List<Position> getPathToTree() {\n\t\t\treturn this.pathToTree;\n\t\t}\n\t}\n\n\t/**\n\t * Class that stores the result of the method\n\t * {@link ModelBTGenerator#parseBTFile(FileInputStream, String, String, List, List)} .\n\t * <p>\n\t * When a BT XML file is parsed, two things are generated:\n\t * <ul>\n\t * <li>An \"new\" expression for the tree, not even ended in \";\". This expression, however, is\n\t * incomplete, since interrupters are not associated with any perform interruption.\n\t * <li>A match between interrupters and perform interruption tasks in the tree. This match is\n\t * represented as a list containing {@link InterrupterMatch} object, one for each match.\n\t * </ul>\n\t * \n\t * After parsing the BT XML file, the result (BTFileParseResult) should be further processed in\n\t * order to complete the declaration expression of the behaviour tree. One of the things that\n\t * must be done is, for instance, do the actual match between interrupters and perform\n\t * interruption tasks of the created tree.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate static class BTFileParseResult {\n\t\t/** The expression of the BT, with no \";\" at the end. */\n\t\tprivate String modelBTExpression;\n\t\t/**\n\t\t * The list of match between interrupters and perform interruptions.\n\t\t */\n\t\tprivate List<InterrupterMatch> interruptersMatches;\n\n\t\t/**\n\t\t * Builds a {@link BTFileParseResult}.\n\t\t * \n\t\t * @param modelBTExpression\n\t\t *            the expression of the BT, with no \";\" at the end.\n\t\t * @param interruptersMatchings\n\t\t *            the list of match between interrupters and perform interruptions that should\n\t\t *            be done in the tree represented by <code>modelBTExpression</code>.\n\t\t */\n\t\tpublic BTFileParseResult(String modelBTExpression,\n\t\t\t\tList<InterrupterMatch> interruptersMatchings) {\n\t\t\tif (modelBTExpression == null) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\n\t\t\tif (interruptersMatchings == null) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\n\t\t\tthis.modelBTExpression = modelBTExpression;\n\t\t\tthis.interruptersMatches = interruptersMatchings;\n\t\t}\n\n\t\t/**\n\t\t * Returns the expression of the BT.\n\t\t */\n\t\tpublic String getModelBTExpression() {\n\t\t\treturn this.modelBTExpression;\n\t\t}\n\n\t\t/**\n\t\t * Returns the matches that must be performed between interrupters and performs\n\t\t * interruptions in the tree.\n\t\t */\n\t\tpublic List<InterrupterMatch> getInterruptersMatches() {\n\t\t\treturn this.interruptersMatches;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the ParsedAction in {@link #actionsDefinition} whose name is <code>name</code>, or\n\t * null if not found.\n\t */\n\tprivate ParsedAction getAction(String name) {\n\t\tfor (ParsedAction a : this.actionsDefinition)\n\t\t\tif (a.getName().equals(name))\n\t\t\t\treturn a;\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns the ParsedMethod in {@link #conditionsDefinition} whose name is <code>name</code>, or\n\t * null if not found.\n\t */\n\tprivate ParsedMethod getCondition(String name) {\n\t\tfor (ParsedMethod m : this.conditionsDefinition)\n\t\t\tif (m.getName().equals(name))\n\t\t\t\treturn m;\n\t\treturn null;\n\t}\n\n\t/**\n\t * Given a SafeOutputContextManager node of the XML file, this method returns a String\n\t * representing the declaration of a List containing the names of its output variables.\n\t */\n\tprivate String getSafeOutputContextOutputListOfVariables(Element e) {\n\t\t/* First, check if the list of variables is syntactically correct. */\n\t\tString listOfVariablesString = e.getChild(TAG_PARAMETERS).getChild(TAG_PARAMETER).getText();\n\t\tMatcher matcher = pattern.matcher(listOfVariablesString);\n\n\t\tif (!matcher.matches()) {\n\t\t\tthrow new RuntimeException(\"List of variables syntactically incorrect: \"\n\t\t\t\t\t+ listOfVariablesString);\n\t\t}\n\n\t\t/* Now construct a List with all output variables. */\n\t\tList<String> listOfVariables = new LinkedList<String>();\n\n\t\tint startQuotations = listOfVariablesString.indexOf('\"');\n\n\t\twhile (true) {\n\t\t\tint endQuotations = listOfVariablesString.indexOf('\"', startQuotations + 1);\n\n\t\t\tlistOfVariables\n\t\t\t\t\t.add(listOfVariablesString.substring(startQuotations + 1, endQuotations));\n\n\t\t\tstartQuotations = listOfVariablesString.indexOf('\"', endQuotations + 1);\n\n\t\t\tif (startQuotations == -1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t * Now construct an expression that creates the list of the output variable of the\n\t\t * SafeOuputContext.\n\t\t */\n\t\tString result = Arrays.class.getCanonicalName() + \".asList(\";\n\n\t\tString arrayExpression = \"new \" + String[].class.getCanonicalName() + \"{\";\n\n\t\tfor (String variable : listOfVariables) {\n\t\t\tarrayExpression += \"\\\"\" + variable + \"\\\", \";\n\t\t}\n\t\tarrayExpression = arrayExpression.substring(0, arrayExpression.length() - 2) + \"}\";\n\n\t\tresult += arrayExpression + \")\";\n\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/tools/btlibrarygenerator/util/Util.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.btlibrarygenerator.util;\n\nimport java.io.File;\nimport java.util.Map;\n\nimport org.eclipse.jdt.core.JavaCore;\nimport org.eclipse.jdt.core.ToolFactory;\nimport org.eclipse.jdt.core.formatter.CodeFormatter;\nimport org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;\nimport org.eclipse.jface.text.Document;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.text.edits.TextEdit;\n\nimport gatech.mmpm.ActionParameterType;\n\n/**\n * General utilities used in the creation of BT libraries.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\n@SuppressWarnings(\"unchecked\")\npublic class Util {\n\t/**\n\t * The {@link CodeFormatter} that is used to format source code files. It is\n\t * statically initialized.\n\t */\n\tstatic private CodeFormatter codeFormatter;\n\n\t/**\n\t * Given a MMPM parameter type, this method returns a Class object\n\t * representing such a type. MMPM has some built-in types that are not\n\t * present in Java, so a conversion must be performed. The conversion is\n\t * performed as follows:\n\t * \n\t * <pre>\n\t * if (type == ActionParameterType.BOOLEAN) {\n\t * \treturn Boolean.class;\n\t * } else if (type == ActionParameterType.ENTITY_ID) {\n\t * \treturn String.class;\n\t * } else if (type == ActionParameterType.ENTITY_TYPE) {\n\t * \treturn String.class;\n\t * } else if (type == ActionParameterType.FLOAT) {\n\t * \treturn Float.class;\n\t * } else if (type == ActionParameterType.INTEGER) {\n\t * \treturn Integer.class;\n\t * } else if (type == ActionParameterType.STRING) {\n\t * \treturn String.class;\n\t * } else if (type == ActionParameterType.PLAYER) {\n\t * \treturn String.class;\n\t * } else if (type == ActionParameterType.COORDINATE) {\n\t * \treturn float[].class;\n\t * } else if (type == ActionParameterType.DIRECTION) {\n\t * \treturn Integer.class;\n\t * } else if (type == ActionParameterType.OBJECT) {\n\t * \treturn Object.class;\n\t * }\n\t * </pre>\n\t * \n\t * If the input type is not recognized, an exception is thrown.\n\t * \n\t * @param type\n\t *            the type to be converted.\n\t * @return a Class object representing the type <code>type</code>.\n\t */\n\tpublic static Class fromMMPMParameterType(ActionParameterType type) {\n\t\tif (type == ActionParameterType.BOOLEAN) {\n\t\t\treturn Boolean.class;\n\t\t} else if (type == ActionParameterType.ENTITY_ID) {\n\t\t\treturn String.class;\n\t\t} else if (type == ActionParameterType.ENTITY_TYPE) {\n\t\t\treturn String.class;\n\t\t} else if (type == ActionParameterType.FLOAT) {\n\t\t\treturn Float.class;\n\t\t} else if (type == ActionParameterType.INTEGER) {\n\t\t\treturn Integer.class;\n\t\t} else if (type == ActionParameterType.STRING) {\n\t\t\treturn String.class;\n\t\t} else if (type == ActionParameterType.PLAYER) {\n\t\t\treturn String.class;\n\t\t} else if (type == ActionParameterType.COORDINATE) {\n\t\t\treturn float[].class;\n\t\t} else if (type == ActionParameterType.DIRECTION) {\n\t\t\treturn Integer.class;\n\t\t} else if (type == ActionParameterType.OBJECT) {\n\t\t\treturn Object.class;\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\"Unexpected action parameter type\");\n\t}\n\n\t/**\n\t * If a directory name does not contain the separator character at the very\n\t * end, it is added. Otherwise, the same input directory is returned.\n\t */\n\tpublic static String addDirectorySeparator(String directory) {\n\t\t/* If directory does not end in separator, add it. */\n\n\t\tif (!directory.endsWith(File.separator)) {\n\t\t\treturn directory + File.separator;\n\t\t}\n\n\t\treturn directory;\n\t}\n\n\t/**\n\t * Checks if a file name already exists in the file system. If so, returns a\n\t * new file name based on <code>fileName</code>, which represents a file\n\t * that does not exist in the file system (the name is the same as\n\t * <code>fileName</code> except for the fact that is has been appended a\n\t * number at its end, before the file extension).\n\t */\n\tpublic static String overwrites(String fileName) {\n\t\tFile file = new File(fileName);\n\t\tif (!file.exists()) {\n\t\t\treturn fileName;\n\t\t} else {\n\t\t\tint counter = 1;\n\t\t\twhile (true) {\n\t\t\t\tString alternativeFileName = removeExtension(fileName) + counter++;\n\t\t\t\tString extension = getExtension(fileName);\n\t\t\t\tif (extension != null) {\n\t\t\t\t\talternativeFileName += \".\" + extension;\n\t\t\t\t}\n\t\t\t\tfile = new File(alternativeFileName);\n\t\t\t\tif (!file.exists()) {\n\t\t\t\t\treturn alternativeFileName;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes the extension from a file name. If the file name has no\n\t * extension, it is left unchanged.\n\t */\n\tpublic static String removeExtension(String fileName) {\n\t\tString parts[] = fileName.split(\"\\\\.\");\n\t\tif (parts.length == 0) {\n\t\t\treturn fileName;\n\t\t} else {\n\t\t\tString result = new String();\n\t\t\tfor (int i = 0; i < parts.length - 1; i++) {\n\t\t\t\tresult += parts[i] + \".\";\n\t\t\t}\n\t\t\treturn result.substring(0, result.length() - 1);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the extension of a file name, or null if it has none.\n\t */\n\tpublic static String getExtension(String fileName) {\n\t\tString parts[] = fileName.split(\"\\\\.\");\n\t\tif (parts.length == 0) {\n\t\t\treturn null;\n\t\t} else {\n\t\t\treturn parts[parts.length - 1];\n\t\t}\n\t}\n\n\t/**\n\t * If a directory name contains the separator character at the very end, it\n\t * is removed. Otherwise, the same input directory is returned.\n\t */\n\tpublic static String removeDirectorySeparator(String directory) {\n\t\t/* If directory ends with separator, remove it. */\n\n\t\tif (directory.endsWith(File.separator)) {\n\t\t\treturn directory.substring(0, directory.length() - 1);\n\t\t}\n\n\t\treturn directory;\n\t}\n\n\t/**\n\t * This method formats a source code file (its content is in\n\t * <code>sourceCode</code>) according to the Eclipse SDK defaults formatting\n\t * settings, and returns the formatted code.\n\t * <p>\n\t * Note that the input source code must be syntactically correct according\n\t * to the Java 1.7 version. Otherwise, an exception is thrown.\n\t * \n\t * @param sourceCode\n\t *            the source code to format.\n\t * @return the formatted source code.\n\t */\n\tpublic static String format(String sourceCode) {\n\t\ttry {\n\t\t\tTextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT\n\t\t\t\t\t| CodeFormatter.F_INCLUDE_COMMENTS, sourceCode, 0, sourceCode.length(), 0,\n\t\t\t\t\tSystem.getProperty(\"line.separator\"));\n\n\t\t\tIDocument document = new Document(sourceCode);\n\n\t\t\tedit.apply(document);\n\n\t\t\treturn document.get();\n\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(\"The input source code is not sintactically correct:\\n\\n\" + sourceCode);\n\t\t}\n\t}\n\n\t/**\n\t * Determines if a file exists.\n\t */\n\tpublic static boolean fileExists(String fileName) {\n\t\tFile f = new File(fileName);\n\t\treturn f.exists();\n\t}\n\n\t/* Initialization of the code formatter. */\n\tstatic {\n\t\t/* Take default Eclipse formatting options. */\n\t\tMap options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();\n\n\t\t/* Initialize the compiler settings to be able to format 1.7 code */\n\t\toptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);\n\t\toptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7);\n\t\toptions.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7);\n\n\t\t/* Change the option to wrap each enum constant on a new line */\n\t\toptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,\n\t\t\t\tDefaultCodeFormatterConstants.createAlignmentValue(true,\n\t\t\t\t\t\tDefaultCodeFormatterConstants.WRAP_ONE_PER_LINE,\n\t\t\t\t\t\tDefaultCodeFormatterConstants.INDENT_ON_COLUMN));\n\n\t\toptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, 78);\n\n\t\t/* Instanciate the default code formatter with the given options */\n\t\tcodeFormatter = ToolFactory.createCodeFormatter(options);\n\t}\n}\n"
  },
  {
    "path": "JBTCore/src/jbt/util/Pair.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.util;\n\nimport java.io.Serializable;\n\n/**\n * Pair represents a pair of objects\n * \n * @author Wikipedia\n * @param <T>\n *            type of the first element of the pair.\n * @param <S>\n *            type of the second element of the pair.\n */\npublic class Pair<T, S> implements Serializable {\n\tprivate static final long serialVersionUID = 1L;\n\t/**\n\t * First element of the pair.\n\t */\n\tprivate T first;\n\t/**\n\t * Second element of the pair.\n\t */\n\tprivate S second;\n\n\t/**\n\t * Constructs a Pair.\n\t * \n\t * @param f\n\t *            first element of the pair.\n\t * @param s\n\t *            second element of the pair.\n\t */\n\tpublic Pair(T f, S s) {\n\t\tfirst = f;\n\t\tsecond = s;\n\t}\n\n\t/**\n\t * Returns the first element of the pair.\n\t * \n\t * @return the first element of the pair.\n\t */\n\tpublic T getFirst() {\n\t\treturn first;\n\t}\n\n\t/**\n\t * Returns the second element of the pair.\n\t * \n\t * @return the second element of the pair.\n\t */\n\tpublic S getSecond() {\n\t\treturn second;\n\t}\n\n\t/**\n\t * Sets the value of the first element of the pair.\n\t * \n\t * @param f\n\t *            value for the first element of the pair.\n\t */\n\tpublic void setFirst(T f) {\n\t\tfirst = f;\n\t}\n\n\t/**\n\t * Sets the value of the second element of the pair.\n\t * \n\t * @param s\n\t *            value for the second element of the pair.\n\t */\n\tpublic void setSecond(S s) {\n\t\tsecond = s;\n\t}\n\n\t/**\n\t * \n\t * @see java.lang.Object#toString()\n\t */\n\tpublic String toString() {\n\t\treturn \"(\" + first.toString() + \", \" + second.toString() + \")\";\n\t}\n\n\t/**\n\t * \n\t * @see java.lang.Object#equals(java.lang.Object)\n\t */\n\tpublic boolean equals(Object o) {\n\t\tif (this == o) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!(o instanceof Pair)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn ((Pair) o).getFirst().equals(this.first)\n\t\t\t\t&& ((Pair) o).getSecond().equals(this.second);\n\t}\n\n\t/**\n\t * \n\t * @see java.lang.Object#hashCode()\n\t */\n\tpublic int hashCode() {\n\t\treturn this.first.hashCode() + this.second.hashCode();\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<classpath>\r\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6\"/>\r\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\r\n\t<classpathentry kind=\"src\" path=\"src\"/>\r\n\t<classpathentry kind=\"lib\" path=\"libs/jdom.jar\"/>\r\n\t<classpathentry kind=\"lib\" path=\"libs/mmpm.jar\"/>\r\n\t<classpathentry kind=\"output\" path=\"bin\"/>\r\n</classpath>\r\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/.gitignore",
    "content": "/bin\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>jbt.tools.bteditor</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/.settings/org.eclipse.jdt.core.prefs",
    "content": "#Thu Jun 10 14:14:01 CEST 2010\neclipse.preferences.version=1\norg.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\norg.eclipse.jdt.core.compiler.compliance=1.6\norg.eclipse.jdt.core.compiler.problem.assertIdentifier=error\norg.eclipse.jdt.core.compiler.problem.enumIdentifier=error\norg.eclipse.jdt.core.compiler.source=1.6\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: BT Editor\nBundle-SymbolicName: jbt.tools.bteditor; singleton:=true\nBundle-Version: 0.0.2\nRequire-Bundle: org.eclipse.core.runtime,\n org.eclipse.ui,\n org.eclipse.ui.forms;bundle-version=\"3.5.0\"\nBundle-Activator: jbt.tools.bteditor.Activator\nBundle-RequiredExecutionEnvironment: JavaSE-1.6\nBundle-ActivationPolicy: lazy\nBundle-ClassPath: .,\n libs/jdom.jar,\n libs/mmpm.jar\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/bteditor.product",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<?pde version=\"3.5\"?>\r\n\r\n<product name=\"JBT Editor\" id=\"jbt.tools.bteditor.product\" application=\"jbt.tools.bteditor.application\" version=\"0.0.2\" useFeatures=\"true\" includeLaunchers=\"true\">\r\n\r\n   <aboutInfo>\r\n      <image path=\"/jbt.tools.bteditor/icons/jbt.png\"/>\r\n      <text>\r\n         JBT Editor\n\nJBT Editor is an RCP application for defining behaviour trees in a standard XML format.\n\n(c) Copyright Ricardo Juan Palma Durán 2010.  All rights reserved.\n\nCredits:\n\nIcons: iconspedia (http://www.iconspedia.com/) and icons at Wikimedia Commons (http://commons.wikimedia.org/wiki/Category:Icons).\r\n      </text>\r\n   </aboutInfo>\r\n\r\n   <configIni use=\"default\">\r\n   </configIni>\r\n\r\n   <launcherArgs>\r\n      <vmArgs>-Xmx1024M</vmArgs>\r\n      <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>\r\n   </launcherArgs>\r\n\r\n   <windowImages i16=\"/jbt.tools.bteditor/icons/jbt16.png\" i32=\"/jbt.tools.bteditor/icons/jbt32.png\" i48=\"/jbt.tools.bteditor/icons/jbt48.png\" i64=\"/jbt.tools.bteditor/icons/jbt64.png\" i128=\"/jbt.tools.bteditor/icons/jbt128.png\"/>\r\n\r\n   <launcher name=\"JBTEditor\">\r\n      <linux icon=\"/jbt.tools.bteditor/icons/jbt.xpm\"/>\r\n      <macosx icon=\"/jbt.tools.bteditor/icons/jbt.icns\"/>\r\n      <solaris/>\r\n      <win useIco=\"true\">\r\n         <ico path=\"/jbt.tools.bteditor/icons/jbt.ico\"/>\r\n         <bmp/>\r\n      </win>\r\n   </launcher>\r\n\r\n   <vm>\r\n   </vm>\r\n\r\n   <plugins>\r\n      <plugin id=\"com.ibm.icu\"/>\r\n      <plugin id=\"javax.servlet\"/>\r\n      <plugin id=\"jbt.tools.bteditor\"/>\r\n      <plugin id=\"org.eclipse.core.commands\"/>\r\n      <plugin id=\"org.eclipse.core.contenttype\"/>\r\n      <plugin id=\"org.eclipse.core.databinding\"/>\r\n      <plugin id=\"org.eclipse.core.databinding.observable\"/>\r\n      <plugin id=\"org.eclipse.core.databinding.property\"/>\r\n      <plugin id=\"org.eclipse.core.expressions\"/>\r\n      <plugin id=\"org.eclipse.core.jobs\"/>\r\n      <plugin id=\"org.eclipse.core.runtime\"/>\r\n      <plugin id=\"org.eclipse.core.runtime.compatibility.auth\"/>\r\n      <plugin id=\"org.eclipse.core.runtime.compatibility.registry\" fragment=\"true\"/>\r\n      <plugin id=\"org.eclipse.equinox.app\"/>\r\n      <plugin id=\"org.eclipse.equinox.common\"/>\r\n      <plugin id=\"org.eclipse.equinox.preferences\"/>\r\n      <plugin id=\"org.eclipse.equinox.registry\"/>\r\n      <plugin id=\"org.eclipse.help\"/>\r\n      <plugin id=\"org.eclipse.jface\"/>\r\n      <plugin id=\"org.eclipse.jface.databinding\"/>\r\n      <plugin id=\"org.eclipse.osgi\"/>\r\n      <plugin id=\"org.eclipse.osgi.services\"/>\r\n      <plugin id=\"org.eclipse.swt\"/>\r\n      <plugin id=\"org.eclipse.swt.gtk.linux.x86_64\" fragment=\"true\"/>\r\n      <plugin id=\"org.eclipse.ui\"/>\r\n      <plugin id=\"org.eclipse.ui.workbench\"/>\r\n   </plugins>\r\n\r\n   <features>\r\n      <feature id=\"jbt.tools.bteditor.feature\" version=\"0.0.1\"/>\r\n   </features>\r\n\r\n   <configurations>\r\n      <plugin id=\"org.eclipse.core.runtime\" autoStart=\"true\" startLevel=\"0\" />\r\n      <plugin id=\"org.eclipse.equinox.common\" autoStart=\"true\" startLevel=\"2\" />\r\n      <plugin id=\"org.eclipse.osgi\" autoStart=\"true\" startLevel=\"-1\" />\r\n   </configurations>\r\n\r\n</product>\r\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = plugin.xml,\\\n               META-INF/,\\\n               libs/jdom.jar,\\\n               .,\\\n               libs/mmpmold.jar,\\\n               plugin_customization.ini,\\\n               icons/,\\\n               files/,\\\n               libs/mmpm.jar\nsource.. = src/\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/files/standardNodes.xml",
    "content": "<!-- \nThis file defines the nodes that are internal to the application. The format of such nodes is:\n\n<Node>\n\t<Type>Type of the node as stored in the XML file of a BT. Must be specified.</Type>\n\t<ReadableType>Type of the node as displayed by the application. Must be specified.</ReadableType>\n\t<Children>Number of children of the node. Can be either \"I\" or a non-negative number. \"I\" means \"1 or more children\". Must be specified.</Children>\n\t<Icon>Path of the icon of the node. Must be specified.</Icon>\n</Node>\n\nIf the node has parameters, it can include another child, <Parameters></Parameters>, which includes <Parameter/> elements.\nA <Parameter/> element has several attributes:\n\n- name: name of the attribute. This attribute must be specified.\n- type: type of tha attribute, that is, what kind of value the attribute stores. Valid types are those specified in\nthe ParameterType enum (located in the ConceptualBTNode class). This attribute must be specified.\n- contextable: this attribute must be specified, and tells if the attribute can or cannot be read from the context. Currently,\nthis attribute is false by default in all standard tasks (tasks read from MMPM files do have contextable parameters), since\nthe execution model implemented in JBT does not support them (which could be improved in the future). Values for this \nattribute are \"true\" or \"false\".\n- nodeTypes: in case \"type\" is \"NODE_ID\", then this parameter specifies the types of the node identified by the parameter.\nIts value can be either an empty list (any sequence of blank spaces, or even \"\"), in which case any type is allowed, or a list of types separated by blank spaces (e.g., \n\"Interrupter Sequence Parallel\").\n\nNodes can be organized in categories. A Category element can contain both categories and nodes, and it has an attribute\n\"name\" that must be specified. The \"name\" is the name of the category that is displayed in the application. \n\n<Category name=\"Category name\">\n\t<Category name=\"Subcategory\">\n\t\t...\n\t</Category>\n\n\t<Node>\n\t\t...\n\t</Node>\n\t...\n</Category>\n\nNOTE THAT THE ROOT OF THE XML FILE MUST BE A Category ELEMENT.\n-->\n\n<Category name=\"Standard nodes\">\r\n\t<Category name=\"Composite\">\r\n\t\t<Node>\r\n\t\t\t<Type>Sequence</Type>\r\n\t\t\t<ReadableType>Sequence</ReadableType>\r\n\t\t\t<Children>I</Children>\r\n\t\t\t<Icon>icons/sequence.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>Selector</Type>\r\n\t\t\t<ReadableType>Selector</ReadableType>\r\n\t\t\t<Children>I</Children>\r\n\t\t\t<Icon>icons/selector.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>Parallel</Type>\r\n\t\t\t<ReadableType>Parallel</ReadableType>\r\n\t\t\t<Parameters>\r\n\t\t\t\t<Parameter name=\"policy\" type=\"PARALLEL_POLICY\" contextable=\"false\"/>\r\n\t\t\t</Parameters>\r\n\t\t\t<Children>I</Children>\r\n\t\t\t<Icon>icons/parallel.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>RandomSelector</Type>\r\n\t\t\t<ReadableType>Random Selector</ReadableType>\r\n\t\t\t<Children>I</Children>\r\n\t\t\t<Icon>icons/randomSelector.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>RandomSequence</Type>\r\n\t\t\t<ReadableType>Random Sequence</ReadableType>\r\n\t\t\t<Children>I</Children>\r\n\t\t\t<Icon>icons/randomSequence.png</Icon>\r\n\t\t</Node>\n\t\t<Node>\n\t\t\t<Type>StaticPriorityList</Type>\n\t\t\t<ReadableType>Static Priority List</ReadableType>\n\t\t\t<Children>I</Children>\n\t\t\t<Icon>icons/staticPriorityList.png</Icon>\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>DynamicPriorityList</Type>\r\n\t\t\t<ReadableType>Dynamic Priority List</ReadableType>\r\n\t\t\t<Children>I</Children>\r\n\t\t\t<Icon>icons/dynamicPriorityList.png</Icon>\r\n\t\t</Node>\r\n\t</Category>\r\n\t<Category name=\"Decorator\">\r\n\t\t<Node>\r\n\t\t\t<Type>HierarchicalContextManager</Type>\r\n\t\t\t<ReadableType>Hierarchical Context Manager</ReadableType>\r\n\t\t\t<Children>1</Children>\r\n\t\t\t<Icon>icons/hierarchicalContextManager.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>SafeOutputContextManager</Type>\r\n\t\t\t<Parameters>\r\n\t\t\t\t<Parameter name=\"listOfVariables\" type=\"LIST_OF_VARIABLES\" contextable=\"false\"/>\r\n\t\t\t</Parameters>\r\n\t\t\t<ReadableType>Safe Output Context Manager</ReadableType>\r\n\t\t\t<Children>1</Children>\r\n\t\t\t<Icon>icons/safeOutputContextManager.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>SafeContextManager</Type>\r\n\t\t\t<ReadableType>Safe Context Manager</ReadableType>\r\n\t\t\t<Children>1</Children>\r\n\t\t\t<Icon>icons/safeContextManager.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>Interrupter</Type>\r\n\t\t\t<ReadableType>Interrupter</ReadableType>\r\n\t\t\t<Children>1</Children>\r\n\t\t\t<Icon>icons/interrupter.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>Inverter</Type>\r\n\t\t\t<ReadableType>Inverter</ReadableType>\r\n\t\t\t<Children>1</Children>\r\n\t\t\t<Icon>icons/inverter.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>Limit</Type>\r\n\t\t\t<ReadableType>Limit</ReadableType>\r\n\t\t\t<Children>1</Children>\r\n\t\t\t<Parameters>\r\n\t\t\t\t<Parameter name=\"runs\" type=\"INTEGER\" contextable=\"false\"/>\r\n\t\t\t</Parameters>\r\n\t\t\t<Icon>icons/limit.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>Repeat</Type>\r\n\t\t\t<ReadableType>Repeat</ReadableType>\r\n\t\t\t<Children>1</Children>\r\n\t\t\t<Icon>icons/repeat.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>UntilFail</Type>\r\n\t\t\t<ReadableType>Until Fail</ReadableType>\r\n\t\t\t<Children>1</Children>\r\n\t\t\t<Icon>icons/untilFail.png</Icon>\r\n\t\t</Node>\n\t\t<Node>\n\t\t\t<Type>Succeeder</Type>\n\t\t\t<ReadableType>Succeeder</ReadableType>\n\t\t\t<Children>1</Children>\n\t\t\t<Icon>icons/succeeder.png</Icon>\r\n\t\t</Node>\r\n\t</Category>\r\n\t<Category name=\"Leaf\">\r\n\t\t<Node>\r\n\t\t\t<Type>Wait</Type>\r\n\t\t\t<ReadableType>Wait</ReadableType>\r\n\t\t\t<Children>0</Children>\r\n\t\t\t<Parameters>\r\n\t\t\t\t<Parameter name=\"duration\" type=\"INTEGER\" contextable=\"false\"/>\r\n\t\t\t</Parameters>\r\n\t\t\t<Icon>icons/wait.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>SubtreeLookup</Type>\r\n\t\t\t<ReadableType>Subtree Lookup</ReadableType>\r\n\t\t\t<Children>0</Children>\r\n\t\t\t<Parameters>\r\n\t\t\t\t<Parameter name=\"subtreeName\" type=\"STRING\"/>\r\n\t\t\t</Parameters>\r\n\t\t\t<Icon>icons/subtreeLookup.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>PerformInterruption</Type>\r\n\t\t\t<ReadableType>Perform Interruption</ReadableType>\r\n\t\t\t<Children>0</Children>\r\n\t\t\t<Parameters>\r\n\t\t\t\t<Parameter name=\"expectedResult\" type=\"STATUS_CODE\" contextable=\"false\"></Parameter>\r\n\t\t\t\t<Parameter name=\"nodeID\" type=\"NODE_ID\" nodetypes=\"Interrupter\" contextable=\"false\"></Parameter>\r\n\t\t\t</Parameters>\r\n\t\t\t<Icon>icons/performInterruption.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>VariableRenamer</Type>\r\n\t\t\t<ReadableType>Variable Renamer</ReadableType>\r\n\t\t\t<Children>0</Children>\r\n\t\t\t<Parameters>\r\n\t\t\t\t<Parameter name=\"variableName\" type=\"STRING\" contextable=\"false\"/>\r\n\t\t\t\t<Parameter name=\"newVariableName\" type=\"STRING\" contextable=\"false\"/>\r\n\t\t\t</Parameters>\r\n\t\t\t<Icon>icons/variableRenamer.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>Success</Type>\r\n\t\t\t<ReadableType>Success</ReadableType>\r\n\t\t\t<Children>0</Children>\r\n\t\t\t<Icon>icons/success.png</Icon>\r\n\t\t</Node>\r\n\t\t<Node>\r\n\t\t\t<Type>Failure</Type>\r\n\t\t\t<ReadableType>Failure</ReadableType>\r\n\t\t\t<Children>0</Children>\r\n\t\t\t<Icon>icons/failure.png</Icon>\r\n\t\t</Node>\r\n\t</Category>\r\n</Category>"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/icons/jbt.xpm",
    "content": "/* XPM */\nstatic char *jbt[] = {\n/* columns rows colors chars-per-pixel */\n\"250 250 256 2\",\n\"   c #000000\",\n\".  c #080B06\",\n\"X  c #10170B\",\n\"o  c #0A3B02\",\n\"O  c #0C2F04\",\n\"+  c #313130\",\n\"@  c #2F2900\",\n\"#  c #753804\",\n\"$  c #4A3B00\",\n\"%  c #065706\",\n\"&  c #094A05\",\n\"*  c #076805\",\n\"=  c #077705\",\n\"-  c #167905\",\n\";  c #0D6E0C\",\n\":  c #2A740E\",\n\">  c #255808\",\n\",  c #744807\",\n\"<  c #666505\",\n\"1  c #535806\",\n\"2  c #515151\",\n\"3  c #6F6F6F\",\n\"4  c #626159\",\n\"5  c #875707\",\n\"6  c #904F0B\",\n\"7  c #BA5A01\",\n\"8  c #A8570A\",\n\"9  c #966505\",\n\"0  c #AF6E0B\",\n\"q  c #C7670B\",\n\"w  c #D97819\",\n\"e  c #C97314\",\n\"r  c #E17E1B\",\n\"t  c #803E00\",\n\"y  c #058807\",\n\"u  c #198706\",\n\"i  c #199606\",\n\"p  c #0A9616\",\n\"a  c #0A8B14\",\n\"s  c #268907\",\n\"d  c #269A08\",\n\"f  c #38980A\",\n\"g  c #348D11\",\n\"h  c #16A113\",\n\"j  c #2BA508\",\n\"k  c #2DAA09\",\n\"l  c #25A308\",\n\"z  c #32AD09\",\n\"x  c #39A60A\",\n\"c  c #36B10A\",\n\"v  c #3BB50B\",\n\"b  c #3EB90C\",\n\"n  c #3ABA07\",\n\"m  c #3AA818\",\n\"M  c #3C9727\",\n\"N  c #358D27\",\n\"B  c #13A925\",\n\"V  c #1AB32A\",\n\"C  c #3DB42A\",\n\"Z  c #2DB427\",\n\"A  c #459A12\",\n\"S  c #6F920A\",\n\"D  c #45A90A\",\n\"F  c #43BC0C\",\n\"G  c #48B70A\",\n\"H  c #54B80D\",\n\"J  c #4BA61C\",\n\"K  c #54AC19\",\n\"L  c #45BD1C\",\n\"P  c #45B816\",\n\"I  c #5AB71A\",\n\"U  c #55AB0B\",\n\"Y  c #62BA1C\",\n\"T  c #73AE0C\",\n\"R  c #429C23\",\n\"E  c #47A826\",\n\"W  c #45B32E\",\n\"Q  c #4AB52B\",\n\"!  c #4EB92A\",\n\"~  c #44B724\",\n\"^  c #53BE26\",\n\"/  c #51BD29\",\n\"(  c #55B722\",\n\")  c #45AE2E\",\n\"_  c #68BA26\",\n\"`  c #70BC33\",\n\"'  c #38C81A\",\n\"]  c #2DC121\",\n\"[  c #4BC40D\",\n\"{  c #47C10D\",\n\"}  c #54CB0E\",\n\"|  c #59CE0F\",\n\" . c #55C40E\",\n\".. c #53D60D\",\n\"X. c #5CD20E\",\n\"o. c #55D908\",\n\"O. c #4AC314\",\n\"+. c #4CCE1D\",\n\"@. c #46C318\",\n\"#. c #4ED117\",\n\"$. c #51D312\",\n\"%. c #5ED410\",\n\"&. c #55CB14\",\n\"*. c #62D60F\",\n\"=. c #65D80E\",\n\"-. c #63CD1E\",\n\";. c #64C719\",\n\":. c #61D510\",\n\">. c #65DA11\",\n\",. c #6ADE12\",\n\"<. c #66D21E\",\n\"1. c #6AD51D\",\n\"2. c #6DDA1E\",\n\"3. c #6BD414\",\n\"4. c #71DD1C\",\n\"5. c #74CA0F\",\n\"6. c #6EE016\",\n\"7. c #6FE118\",\n\"8. c #73E21C\",\n\"9. c #78E21E\",\n\"0. c #49CA23\",\n\"q. c #47C728\",\n\"w. c #56C126\",\n\"e. c #5AC524\",\n\"r. c #5ECA23\",\n\"t. c #54C128\",\n\"y. c #61CD21\",\n\"u. c #6CC625\",\n\"i. c #73C92B\",\n\"p. c #64D221\",\n\"a. c #6AD621\",\n\"s. c #73DD24\",\n\"d. c #77D829\",\n\"f. c #79C737\",\n\"g. c #7CD634\",\n\"h. c #6DC233\",\n\"j. c #76E421\",\n\"k. c #7AE525\",\n\"l. c #7CE42B\",\n\"z. c #7DE92B\",\n\"x. c #77E329\",\n\"c. c #7EE431\",\n\"v. c #7EEC33\",\n\"b. c #7CF035\",\n\"n. c #77BD42\",\n\"m. c #7BC543\",\n\"M. c #B98A02\",\n\"N. c #8EB20A\",\n\"B. c #B1B207\",\n\"V. c #9AA009\",\n\"C. c #D18B09\",\n\"Z. c #EA990C\",\n\"A. c #F19D0D\",\n\"S. c #E58818\",\n\"D. c #EC9312\",\n\"F. c #D2B307\",\n\"G. c #FDAB01\",\n\"H. c #F8A605\",\n\"J. c #FEB301\",\n\"K. c #FFBC00\",\n\"L. c #F5B702\",\n\"P. c #EEAF07\",\n\"I. c #F9B629\",\n\"U. c #91CB0F\",\n\"Y. c #AFC914\",\n\"T. c #84D83A\",\n\"R. c #84CD3A\",\n\"E. c #81E92D\",\n\"W. c #81E62C\",\n\"Q. c #82E634\",\n\"!. c #84EB33\",\n\"~. c #89EC36\",\n\"^. c #86EB3A\",\n\"/. c #8BED3B\",\n\"(. c #88E43B\",\n\"). c #90EF3D\",\n\"_. c #93E735\",\n\"`. c #8BF13D\",\n\"'. c #84F139\",\n\"]. c #92F03E\",\n\"[. c #93E32C\",\n\"{. c #ACD72C\",\n\"}. c #D5D204\",\n\"|. c #FEC400\",\n\" X c #FFCB00\",\n\".X c #F7C704\",\n\"XX c #FFD300\",\n\"oX c #FFDB00\",\n\"OX c #F6D501\",\n\"+X c #F3D00E\",\n\"@X c #E8E800\",\n\"#X c #FFE300\",\n\"$X c #FFEC00\",\n\"%X c #F3E902\",\n\"&X c #FFF400\",\n\"*X c #FFFE00\",\n\"=X c #F7F703\",\n\"-X c #FFFF17\",\n\";X c #FED02D\",\n\":X c #FFFF26\",\n\">X c #FFFE39\",\n\",X c #EBEB25\",\n\"<X c #CDD81D\",\n\"1X c #87CA47\",\n\"2X c #8AD645\",\n\"3X c #94D94E\",\n\"4X c #8CEE41\",\n\"5X c #8CE546\",\n\"6X c #94E947\",\n\"7X c #8EF242\",\n\"8X c #93F244\",\n\"9X c #99F346\",\n\"0X c #95F54B\",\n\"qX c #9CF54B\",\n\"wX c #98F84E\",\n\"eX c #96F84C\",\n\"rX c #9BE753\",\n\"tX c #9CFA54\",\n\"yX c #9CF854\",\n\"uX c #88EB54\",\n\"iX c #A0F64F\",\n\"pX c #A2F651\",\n\"aX c #A5F954\",\n\"sX c #A1FD5B\",\n\"dX c #ABFC5C\",\n\"fX c #A8F759\",\n\"gX c #A2EC57\",\n\"hX c #AFFD60\",\n\"jX c #B0FE61\",\n\"kX c #A0DC46\",\n\"lX c #FECB51\",\n\"zX c #FFFF4D\",\n\"xX c #FFFE44\",\n\"cX c #FFFF54\",\n\"vX c #FEFB70\",\n\"bX c #FCD16F\",\n\"nX c #DDAF49\",\n\"mX c #999999\",\n\"MX c #888888\",\n\"NX c #A8A8A8\",\n\"BX c #B6B6B6\",\n\"VX c #FFF88F\",\n\"CX c #FFF3AE\",\n\"ZX c #F8D99A\",\n\"AX c #DCDCDC\",\n\"SX c #D5D5D5\",\n\"DX c #C8C7C6\",\n\"FX c #FEF6D0\",\n\"GX c #E4E4E4\",\n\"HX c #ECECEC\",\n\"JX c #E5E6EC\",\n\"KX c #FFFBE5\",\n\"LX c #F4F4F4\",\n\"PX c #FDFDFD\",\n\"IX c #FEFBF5\",\n\"UX c None\",\n/* pixels */\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX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L.XX*X*X*X$XoX XK.K.L.L.P.P.P.G.G.J.J.K.XX$X*X*X&X*X*X*X$X X X|.G.G.A.G.P.|.,             BXPXPXPXPXPXPXPXPXSX.               . $ M.D G G G G [ [ [ [ O.[ O.O.@.L @.L L ~ @.~ ~ ~ ~ C UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX! / / / ^ ^ w.^ w.w.e.e.e.y.e.y.y.y.y.y.-.y.<.<.1.1.1.1.2.s.s.s.x.x.c.c.^.^.^.4X4X7X0X0XyXyXyXsXsXyXsXwXwXeXeXeX7X7X`.`.^.^._.P.|.&X&X XJ.J.L.F.U.U.,.=.5.5.X.5. .U.N.F.G.G.|.&X*X*X*X*X*X#X X XK.G.A.L.L.XX,             BXLXPXPXPXPXPXPXPXPXAX.               . $ S x D G G { [ [ [ [ [ @.O.L @.L L L L L L L C q.C C UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX! / / / ^ w.w.w.e.e.e.e.e.e.e.e.y.y.y.y.-.1.p.p.1.1.1.2.2.4.d.s.x.c.g.c.v.^.4X4X7X0X0X0XyXyXyXsXsXtXtXwXeXeXeXeX7X7X`./.^.!.}.G.|.K.G.P.Y.U.9.6.6.>.=.=.X.X.| } } [ [  .H T F.L.XX&X*X*X*X&X#X X|.G.G.K..XXX1             BXPXPXPXPXPXPXPXPXPXPXDX.               . > v x D G G G { [ [ [ [ @.O.O.O.O.L L L L L L L C ~ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX^ / ^ ^ ^ e.t.e.^ e.e.e.-.y.y.y.y.y.y.<.y.<.<.1.1.1.2.4.2.s.d.x.c.c.c.Q.^.^.4X7X7X0XeXyXyXsXsXsXsXpXtXtXwX0X0X8X`.`.`.`.'.Y.L.G.P.<XU.9.9.8.7.6.6.,.>.=.%.o.X.} } } [ [ { F G T B.|.&X*X*X*X&XXX|.K.|..X.XXX1             BXLXPXPXPXPXPXPXPXPXPXPXSX                  > x D G G [ G [ [ [ [ [ O.O.@.@.L L L L L C L C L UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX/ ^ / ^ w.w.^ e.e.e.e.e.e.e.e.y.y.y.-.-.y.-.<.<.1.1.1.1.4.d.s.s.x.d.c.c.^.^.4X4X4X0XuXeXyXtXtXsXsXsXsXtXwXeX0X0XeX`.`.`.'._.P.L.Y.[.W.k.k.k.8.7.6.6.,.>.=.%.X.X.} } [ [ { { F F G G T P.$X*X*X*X#X X|. X.XL.oX<             BXIXPXPXPXPXPXPXPXPXPXPXIXDX                . > x v G G G G { [ [ [ O.O.O.O.@.L L @.L L ~ ~ ~ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX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UXUXUXUXUXUXUX^ ^ ^ e.^ e.e.e.;.e.r.r.y.y.y.y.<.y.<.<.<.1.1.1.2.2.s.s.s.l.c.c.c.c.^.4X4X4X4X0X0XwXyXyXsXsXhXsXtXtXtXeXeX0X8X8X`.`.`.'.'.E.!.z.z.k.k.8.8.8.7.6.,.,.>.>.X.X.X.} } } } { { F b v n v z z T }.*X*X$X XXX=X=X*X<             BXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXNX                . : D D G G G F { [ O.O.{ O.P @.@.L L L L ~ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX^ e.e.e.e.e.e.e.e.r.y.y.y.y.-.<.-.p.1.<.1.1.1.2.2.s.s.s.l.d.l.c.(.^.^.4X4X7X6X0X0XwXyXtXsXhXtXsXsXwXwXeXeX8X8X`.8X`.`.'.E.'.z.z.z.k.k.k.8.8.7.6.6.,.>.:.X.X.| | } [ [ [ { F F b v v c z z N.oX*X&X#X$X*X=X*X1             BXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXIXNX                . : D x G G G F F [ [ O.O.O.O.@.O.L L L ~ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXw.^ e.e.e.e.e.e.y.e.-.y.y.y.y.-.<.<.1.1.1.1.1.2.2.s.s.s.x.c.c.c.c.(.b.^.4X7X0X0X0XyXyXsXsXsXsXtXtXwXwXeX8X0X8X`.`.`.'.~.!.v.E.z.z.k.k.j.8.8.6.6.,.>.>.>.%.X.X.} } } [ [ { { F F v v c z k U B.&X*X*X*X=X=X&X<             BXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXLXmX                X : D D D G F H { { O.O.H O.@.L @.@./ @.UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXe.e.e.e.e.e.e.y.e.y.e.y.y.y.-.p.y.<.<.1.1.1.2.2.2.s.x.d.x.l.c.^.v.^.4X4X4X7X0X0XwXyXyXsXsXsXtXaXtXwXeXeXeXeX`.`.`.~.'.'.!.b.z.z.z.k.j.8.8.8.6.6.,.>.>.>.X.X.| } } [ } [ { F F b v v c c z l T OX*X*X*X=X#XK.$             BXLXPXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXMX                O : D D G G G F [ O.O.O.O.@.O.@.L @.UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXe.e.e.r.r.e.r.y.y.y.y.y.-.y.<.<.<.<.1.1.1.2.2.4.s.s.x.x.c.c.Q.(.^.4X4X7X7X0XeXwXyXtXsXsXsXsXyXyXeXeX7XeX7X7X`.`.`.'.~.!.E.z.z.k.j.j.8.8.7.7.7.,.,.,.>.X.X.} } } } [ [ { F F F v v v z z k D B.$X*X*XoXP.G.$             BXLXPXIXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLXMX                X : D D D G F F [ { [ O.O.@.@.@.L UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXe.e.e.e.e.;.e.y.r.y.-.y.-.<.<.1.1.1.1.1.2.2.d.s.s.s.x.c.c.^.v.^.4X^.4X7X0X0XeXyXyXyXsXsXsXyXyXyXtXeXeXeX7X].`.`.`.'.~.E.E.E.z.z.z.8.j.8.7.7.7.6.6.o.=.X.X.X.X.} } [ [ { { F F F v c c z z l N.XX*X#XJ.A.B.o             NXLXPXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXLX3                 O s D D D G G G { { G  .O.@.O.UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXe.e.y.r.e.y.y.y.y.y.-.p.<.<.<.;.1.1.1.2.4.s.x.l.x.d.c.c.v.(.^.4X4X7X6X0X0XyXyXyXsXhXsXsXsXtXyXeXeXeX].7X7X`.`.`.'.'.E.b.z.z.j.j.k.j.8.8.7.6.,.,.,.=.X.X.| } } } [ [ { F F v F v c c z k k U }.#XJ.G.V.f o             NXLXLXPXPXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXHX3                 O s D D G G G F O.[ O.O.O.@.UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXe.e.y.y.y.y.;.y.<.y.<.<.1.1.1.1.2.2.2.4.s.d.s.c.c.c.(.c.^.4X4X4X7X7X0XyXyXyXsXsXsXsXsXyXeXyXeXeXeXeX7X7X`.`.'.'.'.E.E.E.z.z.k.j.8.8.7.7.,.6.,.o.=.X.X.| } } } [ [ { { F F v v v c c k k D B.K.G.C.D i o             BXLXLXIXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXHX3                 O g x D D G G F F O.H O.UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXr.e.y.r.<.y.y.<.<.<.<.1.1.1.2.2.2.s.s.s.s.x.c.c.Q.(.^.4X4X4X7X0XuX0XwXyXyXsXsXsXtXtXtXtXeXeX0X7X8X7X`.`.`.'.~.!.!.z.z.z.j.k.j.k.8.7.7.6.,.,.o.,.o.X.| } } [ [ [ [ { F F b b c c c k k k V.G.H.T i i o             BXLXLXPXPXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXGX2                 @ A A D G G F P H O.UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXy.y.-.r.-.-.-.p.<.<.<.1.1.1.2.s.s.s.d.x.x.l.c.Q.v.4X^.4X4X7X0X0X0XtXyXyXsXsXsXhXtXtXtXwXeX0X0X7X7X7X`.'.~.'.E.'.z.z.b.j.k.8.8.8.7.7.,.,.,.,.=.=.X.X.X.} } [ [ { { F b b v v c c z k k T G.B.f i l o             NXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXJX4                 O A f D D G F G UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXy.r.<.-.p.<.<.1.1.1.2.1.2.2.2.s.x.x.d.c.c.c.Q.^.^.4X4X7X6X0X0XwXyXyXsXsXsXsXsXtXtXwXwXeX0X0X7X7X`.~.`.!.!.'.E.E.z.z.j.j.j.8.8.7.7.,.,.,.,.=.%.o.| } } } } [ [ { F F n v v c c z z l T P.T i i h o             BXLXLXLXLXPXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXAX2                 o f x D G G UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXy.<.p.<.<.<.<.1.1.3.2.2.2.d.s.s.x.c.c.c.Q.^.^.^.4X4X7X7X0X0XwXyXyXsXhXsXsXtXtXtXwXeXeX0X7X7X7X`.`.'.'.'.'.E.z.z.z.z.j.j.j.7.7.6.6.,.,.o.=.%.X.X.X.} } [ [ [ { F F F b v c c c k k S V.D l i l o             NXLXLXLXLXPXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXSX2                 O f D f UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX-.<.p.<.<.1.1.1.2.2.2.4.d.s.x.x.c.c.c.c.^.^.^.4X4X7X0X0XwXyXyXyXsXhXtXsXtXtXtXeXeXeXeXeX7X].`.~.'.!.!.!.E.z.z.j.z.8.z.7.7.7.7.6.,.>.>.*.X.X.| } } } } [ [ { { F b v v v c z z k U T j d d l o             NXLXLXLXPXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXAX2                 & : UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX<.<.1.1.1.1.1.2.4.s.s.x.d.l.g.c.v.^.^.4X4X4X4X7X0X0XwXyXyXsXsXhXtXtXtXtXtXeXeXeX7X].7X`.`.`.~.'.!.E.E.z.z.z.z.8.8.8.8.7.7.6.6.>.=.*.*.X.| } } } [ [ [ { F F b b v c c z z k k l d l i l o           . NXLXLXLXLXLXPXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXSX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1.1.1.2.2.2.4.s.s.d.k.x.c.c.c.^.^.^.^.4X4X7X0X0X0XtXyXyXsXsXsXsXtXtXyXyXeXeX7XeX7X7X`.`.`.~.'.!.'.z.z.z.z.8.k.8.8.7.7.7.,.>.,.>.=.X.X.| | } } [ [ [ { F F F v v v c c z k k j l d i l o             NXLXLXLXLXPXPXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXSX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX;.-.2.4.a.s.s.d.x.l.c.c.c.^.^.^.4X4X7X8X0XuXtXyXyXsXsXsXsXtXtXtXtXeXeX0XeXeX7X`.`.`.'.~.!.!.E.E.z.z.k.k.k.j.8.8.7.7.,.,.>.>.=.X.X.$.| } } } [ [ [ F F b b v c c z z z k j l l d l o             NXLXLXLXLXLXLXLXPXPXIXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXDX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXN E I a.j.d.x.d.x.x.c.c.^.^.^.4X4X4X0X0X0XwXwXyXyXsXsXsXsXsXyXyXtXeXeXeX8X8X].`.`.`.`.'.'.E.E.z.z.z.z.j.j.j.8.8.6.6.,.,.>.>.%.X.X.X.} } } } [ { { { F F b v v c c z z k j l l d l o             NXLXLXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXDX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXN N N M K y.a.x.x.c.c.c.c.v.^.^.4X4X4X0X7X0XyXyXyXyXsXhXsXsXyXyXyXtXeXeX8X7X8X].`.`.`.!.'.'.E.b.E.z.z.k.j.j.8.8.8.6.6.,.,.>.=.=.%.X.X.| } } [ } [ { F F F b v v c c z z k k j d d l &             NXLXLXLXLXLXLXLXLXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXBX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXN M M M N M M K u.i.c.c.Q.^.^.^.4X4X5X7X7XqX0XwXyXyXyXsXsXsXsXyXyXtXeXeXeXeXeX`.`.`.`.`.'.~.E.'.z.z.z.z.z.j.j.k.7.8.6.6.,.,.>.>.=.X.X.| | } } } [ [ { { F F b v v c c z z k k j l d l o             NXHXHXHXLXLXLXLXLXPXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXBX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXN N N M M M R M M M E e.i.g.^.^.^.4X4X7X7X0XuXwXwXyXyXsXsXsXsXsXsXyXtXeXeXeXeX7X8X].`.`.`.'.!.'.E.E.z.z.z.k.j.j.8.8.6.6.6.,.,.>.>.=.X.X.X.} } } [ [ [ { F F b F n v c c c k k k j j i l o             BXHXLXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXBX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXM M M M M M R R R R R R R J _ h.g.T./.7X7X7X0XwXwXyXyXsXsXsXsXsXsXtXtXwXeXeX8X7X].].`.`.`.'.~.'.E.!.z.z.z.k.k.9.j.8.8.7.7.7.,.,.>.>.o.>.X.| X.} } [ [ { { { F F v v v v c c z k k j l d l o             BXHXHXLXLXLXLXLXPXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXNX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXM N M M M M M R R R R R J J E R A K _ d.g.4X0X0XwXwXyXsXsXsXsXsXsXtXtXtXwXwX0XeXeXeX7X7X`.`.'.'.'.!.E.!.z.z.z.j.k.j.8.8.7.7.7.,.,.>.=.>.%.X.X.X.} } } } { { { F F F v v v c z z z k j j d l &             NXHXLXLXHXHXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXNXX                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXM M M M M R M ) R E R E J R J J J E J K K Y u.i.g.5XwXyXsXsXsXsXsXsXtXtXwXwXwX0X8XeX`.7X`.`.`.'.'.!.!.E.z.z.z.k.k.k.j.8.7.7.7.6.,.,.>.>.%.%.o.X.} X.} [ } [ { { F F F v v v c c z k k j l d l o             NXHXHXLXLXLXLXLXLXLXLXPXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXNXX .                 UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXM M ) M M ) ) M R ) R J E J J J K J K K K K K K K K I h.f.T.5X0XyXdXtXaXsXtXwXwX0X0X7X7X7X7X`.].`.'.'.E.!.v.z.z.z.k.j.j.j.8.8.7.6.6.,.,.>.>.=.%.X.X.} } } } [ [ { { F F F v v v c z z z k j l d j &             NXHXHXHXHXLXLXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXNXX                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXM M ) M C E R R ) R E J E J E J E K E K K K I K I I Y _ I _ _ i.f.R.2X6X6XyXwXiXiXqX0XeX7X7X`.`.`.'.`.!.!.!.!.E.z.z.k.k.j.j.8.7.7.7.6.,.,.=.>.=.X.*.| X.} } [ [ [ { { [ F F F v v v c z z k k j d k o             NXHXLXLXHXLXLXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXmX.                 UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXC M M M ) R R E ) R E E E E E K E ( K K K ( I I I I I Y Y _ _ _ ` ` ` ` f.1X1X1X3XkX5X6X7X8X8X`.`.`.`.!.!.'.E.E.z.z.k.z.k.k.8.8.8.7.6.6.,.,.>.=.*.*.| | } } } } } { [ { F F F v v v c c c z k j j d j &             NXHXHXHXLXHXHXLXLXLXLXPXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXmX.                 UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXC M M C M R ) E E E E E E J ( ( J I K I ( I I I I I I Y Y _ _ _ ` ` ` ` R.R.` m.1X1X1X1X3X2X2X2X2XT.T.~.E.'.~.'.!.E.z.E.k.j.j.8.8.7.6.7.6.,.,.>.=.*.X.| | } } } } } [ [ F F F F F v v n v c c c z l d d o             NXHXHXHXHXLXLXLXLXLXLXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXmX.                 UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) M ) ) ) ) R ) E E E E ( E E ( E ( ( ( ( I I ( I I Y Y ;._ u._ u.` ` ` R.` m.m.1X1X1X1XmX1X1X1Xm.R.m.R.f.g.i.f.i.i.d.s.d.d.8.j.8.8.7.6.6.6.,.,.,.=.=.=.*.X.%...} } } [ } [ F v v v z x d f d s u - - = = O             NXHXHXJXLXHXLXLXLXLXLXLXPXLXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXMX                  UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXM M C ) E E Q ) ) E Q ( E ( Q ( ( K ( I ( I I e.I Y Y Y Y _ u.u.u.i.i.f.f.f.R.1X1X1X1X1X3X1X1X1Xm.1X1XR.` 1X` R.` ` ` ` _ _ _ r._ Y I Y Y Y Y H I H H U U D D D D x A A f f f f s s s s s - - - - * * * % * O             NXHXHXHXLXHXLXLXLXLXLXLXLXLXPXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLXmX                  UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) C ) ) ) ) ) E ) ) E E ( E ( ( ( I ( ( ( I I I Y I ;.Y ;.;.u._ ` i.f.i.f.R.f.1XR.1X1X2X3X1X1X1X1Xm.1X` ` 1X` ` ` ` ` _ _ _ _ T _ I Y I K K U U U U U D D A A D f A f f f g s s : s - s s - - - - * - * * * * O             NXHXHXHXHXHXHXLXHXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPX3                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) ) ) ) ) ) ) E E ( Q ( Q ( ( Q ( ^ e.I I I ;.e.;.;.;.;.u.u.u.i.i.i.f.f.f.f.R.1X1X1X3X1X3X3X1X3X1Xn.1XR.` m.R.` ` R.` T ` _ _ Y _ _ Y I T K U I U U U A D D D A f A f f g s s s s s s s - : : - - - - * * * * O             NXHXHXHXLXHXHXLXLXLXLXLXLXLXLXPXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLXMX                  UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) C ) W W Q E Q Q ! Q ( Q ( ( / I ^ I ^ I e.r.;.I ;.;.;.;.u.u.u.i.i.f.R.f.1XR.R.1X2X2XmX3X3X1X1X1X1XR.1X1XR.1X` R.` ` ` ` _ ` _ _ K Y Y Y Y K I H U U U U U A D D A f f f f f f f s s s : s - u - - - - * * * * O             NXGXHXHXHXHXLXHXHXLXLXLXLXLXPXLXPXPXPXIXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXIX3                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) W ) W W W Q Q ! ! ! ^ ^ ( / I ^ e.I e.e.^ ;.e.;.;.;.;.u.-.a.i.i.d.f.f.g.R.T.1X2X2X3X3X3X3X3X1X3X1X1X1XR.R.1XR.f.` R.` _ ` _ _ _ _ _ _ T Y Y I Y U I U U G D D D A A f f f f f s s s s s s : s - - - - - * * * * O             NXGXHXHXHXHXHXLXLXHXLXLXLXLXLXPXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLX3                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) W W ) W W Q Q ! / ! ^ ^ ^ ^ ^ ^ I e.e.^ ;.;.;.u.;.<.;.-.1.i.i.i.d.f.g.g.T.R.2XT.2X2X3X3X3X3X3X3X3X2X2X1X1X2XR.R.f.f.R.` R._ ` U._ _ _ _ Y Y I Y U Y K H U U U U D A A D A f f f f f s f s s s s s - - - - - - = * O             NXJXHXHXHXHXHXHXHXLXLXLXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLX3                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) ) W W W W ! ! ! / / / ^ ^ ^ ^ e.e.r.e.e.;.;.-.;.-.<.;.;.1.u.d.i.d.i.g.T.T.T.2XT.2X2X3X3X3XgX3X3X3X3X1X2X2XR.R.R.R.f.f.` ` i.i.u._ u.u.Y _ Y Y Y U Y U H K H U D J D D D D f f f f f s f s s s - s - u - - - - * * - O             NXGXGXHXHXHXHXLXLXHXLXHXLXLXLXLXPXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLX2                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) ) ) W W ! ! ! ! / / ^ ^ e.^ e.e.e.e.e.y.y.y.y.-.-.-.;.3.d.2.u.d.d.d.T.g.T.T.T.2X5X2X3X3X3X3X3X3X3X3X3X2X2X1X1XR.R.f.f.R.R.i.i.` i.` u._ _ Y Y Y Y Y H Y H H H U U G D D D f f D f f s f s f s s s s s - - - - - - * = O             NXGXGXHXJXHXHXHXHXLXLXLXLXLXLXPXLXPXLXPXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXHX3                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) W W ) W ! ! ! q.n.q.t.h.t.r.t.t.r.r.r.p.r.y.%.p.p.1.1.1.2.d.d.d.i.d.T.T.T.T.T.T.5XkX3X6X3X3XgX3X3X3X3X3X3X2X2X2XT.R.g.T.f.f.f.g.i.i.u.u.u.u.Y Y Y ;.Y 5.H H Y H U G U U D D D x A x f f d s f g d s s s u u - y - - * = O             NXGXHXGXHXHXHXHXLXHXHXLXLXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLX2                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) ) ) W W W ! ! ! q.W t.t.q.t.t.r.r.r.p.r.p.p.p.<.p.a.1.1.1.4.2.d.d.W.d.T.T.Q.T.(.2X3X3X5X3XrX3XgXgX3X3XgX3X3X3X2XT.2XR.R.R.R.g.i.f.i.i.i.u.u.u.u.;.;.Y Y H Y Y H H H U G U D D D D x f x f f f s d s s s u s u u - - - = = O             NXGXGXHXGXHXHXHXHXLXLXHXLXLXLXLXLXIXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXJX2                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) W W W W W W ! W ! ! q.! t.t.t.t.r.r.r.r.r.r.p.p.1.a.a.2.2.2.4.d.d.d.W.R.T.Q.T.T.5X(.kX6XrX3XrXrXrXrXrXrX3X3X3X3X2X2X2XT.T.T.T.i.g.i.i.i.i.i.d.u.u.u.;.Y ;.Y Y H H H H H H G G D D D D f x f f f f d f s s d s u s - - - = - = O             NXGXHXGXHXHXHXHXHXLXLXLXHXLXLXLXLXLXPXIXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLX2                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) W W W W W W ! t.! ! t.t.t.t.r.t.r.r.r.p.p.p.p.d.a.a.2.a.2.s.s.d.W.k.d.T.T.5X_.(.5X6X5X6XrXrXgXgXgXgXrXrXgX3XrX3XkX5XT.2XT.R.T.R.d.R.f.U.i.i.u.u.5.u.5.Y ;.;.;.H H ;.H H P U G D D D D D x x x f d f d s d s s u s u u u - = = O             NXGXGXHXGXHXHXHXHXHXHXHXLXLXLXLXLXLXLXLXPXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXGX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) ) W W W W W ! W t.h.q.t.t.t.r.r.r.r.r.p.+.p.p.a.x.2.2.2.4.9.s.l.d.W.l.Q.!.(.(./.5X6X6X6XrXrXrXgXgXgXgXgXrXrXrX6X3X2XT.2X(.T.T.T.T.T.g.d.i.i.u.i.i.u.u.;.;.;.;. .Y  . .Y H H G G U J D x D x x x f f d d d d s s s u u u u - = y O             NXGXGXHXHXGXHXHXHXHXLXHXLXLXHXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXHX+ .                 UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) ) ) W W W ! ! ! t.! t.! t.q.t.r.t.r.r.p.p.p.p.p.p.p.2.s.7.4.j.j.l.l.W.Q.Q.(./._./.6X6X6X9XrXrXgXgXfXgXgXgXrXrXkX6X6X6X5XkXT.T.T.T.T.R.d.R.d.W.i.i.5.u.1.5.u.;.;.5. .5.H  . .H H H G G D P D x D x f x f d f d s d s s u u u u - u O             NXAXGXGXGXHXGXHXHXHXHXHXHXLXLXLXLXLXLXLXPXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXGX+                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) ) ) W ! W ! t.! ! t.t.t.t.h.t.r.r.r.r.p.p.p.p.p.a.x.2.8.4.j.x.x.z.W.Q.!._.(./._.6X6X6XrXrXpXgXgXfXfXgXgXgXgXrXrXrX6X5XkX5XT._.T.T.W.T.i.d.d.i.d.4.i.i.3.u.<.;.;.;.;.5. . .H H H H G G D D c x x x x j f f d d d d s s i u u y - y O             NXGXGXHXHXGXGXHXHXLXHXLXHXLXLXLXLXLXLXPXLXPXLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXSXX                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) W W W W W t.! W t.t.t.t.t.t.t.r.r.r.p.p.p.p.p.2.2.p.2.4.4.4.j.j.W.W.Q.!.(././.6X4X6XqXqXiXgXgXhXgXhXfXfXpXrXgXrX6XkX6X5X6X5X).T.T.T.T.T.W.T.g.i.W.i.i.1.i.1.;.;.;.5.| ;. . .5. .H H G G G G D D x x x x j f f f d s d i s u u u - u O             NXGXGXGXGXGXHXHXGXHXHXHXLXHXLXHXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXJXX                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) ) W W W W ! ! ! ! t.t.t.t.t.t.0.h.r.r.0.p.p.p.p.a.a.a.7.7.4.9.j.j.k.W.W.!.(./.).).).8X9XqXiXpXpXfXfXhXfXgXhXgXfXgXrX9X6X6X6X6X5X_.2X(.T.T.W.T.d.d.W.d.i.4.d.5.i.3.1.;.;.;.| | H  . .H  .H H G D G m x x x x j f j f d d s s i i u u - u o             NXAXGXGXGXHXHXGXHXHXHXHXLXHXLXHXLXLXPXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXDXX                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) W ) W W W ! t.! W h.t.t.t.t.t.r.r.q.r.r.p.p.p.p.p.p.7.a.a.x.4.j.x.x.l.W.E.!.!./.).).9X8XqXqXiXpXfXfXdXhXhXfXfXgXpXgXgX6XrX9X6X6X6X5X_.(.(.(.T.T.T.d.d.d.d.4.d.a.5.1.;.3.3.3.;.| 5. . . .H H H G G G D v v x x j x d d d d d d d s i u u y O             NXAXGXGXGXGXGXHXHXHXHXHXHXLXLXHXLXLXLXLXLXPXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXAXX                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) W W W W ! W W ! ! q.t.t.t.t.t.r.t.r.r.r.p.p.p.p.p.p.a.a.a.7.x.s.j.x.z.W.E.!.(.~.).).9X9X6XiXiXaXfXfXdXjXjXdXdXfXfXfXpXiXiXrX6X6X6X_._.(._.(.Q.Q.W.W.d.W.W.d.4.d.i.4.1.2.;.3.;.5.| 5. .|  .H  .P H G G P x D c x x x j x f d d s d i u u u i O             NXGXGXGXGXGXHXGXGXHXHXHXHXLXHXLXHXLXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXDXX                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX) W W W W W t.! ! ! t.! t.t.t.t.r.r.r.r.r.p.p.p.p.p.x.p.7.7.2.7.j.j.l.W.Q.!.~.~./.).).8X9XqXwXiXaXdXdXdXjXjXdXdXfXfXfXpXiXiXiX9X6X].6X)./.(.(._.Q.T.W.T.d.d.d.i.2.2.3.2.2.3.3.:.=.;.| |  . .| H H F G G G G G x x x x j j d j d d i s i i u y o             mXGXGXGXGXGXGXGXHXHXHXHXHXHXLXHXLXLXLXLXLXLXPXLXPXLXIXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXBX.                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW W W W q.W q.W t.! t.t.t.t.t.r.r.r.r.r.p.p.p.p.p.p.p.a.2.7.2.7.x.j.k.W.l.E.!.~.(./.).8X6X9XqXiXpXaXfXdXhXjXhXdXdXfXdXaXaXiXiXiX9X9X].).9X).)._.(.Q.Q.W.W.W.W.W.d.4.4.4.2.3.2.3.3.3.X.;.| |  . . . .[ F G G D v c c x z x x d j d d d d i u u i o             NXAXGXGXGXGXGXGXHXGXGXHXHXLXHXLXLXLXLXLXLXLXLXLXPXPXLXPXPXPXPXPXPXPXLXLXPXLXLXPXLXIXIXPXLXPXIXLXPXLXIXPXIXLXPXLXIXPXLXPXIXPXBX.                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW W W W W W n.W ! t.! t.q.q.q.h.t.r.r.r.r.p.+.p.p.p.2.2.2.a.x.2.j.x.x.l.W.W.!.(././.).8X9X9XqXqXpXaXfXdXhXjXhXhXdXdXfXfXaXaXiXiXqXqX9X9X6X].).(./.~._.W.Q.W.d.W.4.4.d.d.4.4.2.3.3.3.=.*.*.| | |  . .[ [ H G F v G G D c c x j x j d l d s i i u i o             mXGXGXGXGXGXGXGXGXHXHXHXHXHXHXHXHXLXLXLXLXLXLXPXLXPXPXPXPXPXPXPXPXPXDXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmXmX2                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW W W W n.W W q.W W t.t.t.h.t.r.t.t.r.r.r.p.p.p.p.a.2.a.2.7.7.7.j.x.k.W.W.W.!.~./.).).8X9X9XqXiXiXfXfXdXhXjXhXdXdXdXfXaXaXiXiXiXqX9X9X9X].].)./.~.(.~.W.W.W.W.W.s.W.s.4.4.4.8.3.3.,.3.=.=.;.| | |  . .[ G O.F F v x c x m z x j j j d l d d i u i o             mXAXGXGXGXGXGXGXHXGXGXHXHXHXHXHXLXHXHXLXLXLXLXLXLXLXLXPXIXPXPXPXPXPXMX.                                                                             UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW W W W W W W q.W h.q.t.t.t.t.r.t.r.p.p.r.r.p.p.p.a.p.2.2.2.2.j.j.j.x.W.W.!.Q.!.).).).).8X9XqXiXiXaXfXdXdXhXjXhXhXdXdXfXaXiXiXiXqXqX9X9X9X].].).)./.~.~.~.W.W.W.W.W.k.9.W.4.8.4.4.2.,.3.=.=.:.:.| |  . . . .O.G F G F v v c z x z j j j d l i i i i O             NXAXGXAXGXGXGXGXGXHXHXHXGXHXLXHXHXLXLXLXLXLXLXPXLXPXLXPXPXPXPXPXPXPXGX+                                                                               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW W ! W ! ! ! ! q.t.t.t.r.q.r.q.r.q.r.r.q.b.r.p.p.7.a.7.2.2.7.x.j.j.x.W.W.!.!.~./.).8X8X9X9XqXqXaXaXsXdXdXjXjXdXdXdXdXaXaXaXiXqX9XiX9X9X].].).].`.~.~.~.~.E.E.E.E.W.W.9.8.9.8.8.6.6.,.,.=.=.=.*.X.| | } [ O.[ { { F F v v c x z x k j j d l i d i i &             NXAXAXGXGXGXGXGXHXGXGXHXGXHXHXHXHXLXHXLXLXLXLXPXLXLXPXLXPXPXPXPXPXPXPX3 .                                                                               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW W ! W W ! ! ! / t.t.t.t.q.h.t.r.h.p.p.p.p.r.p.a.a.a.a.a.7.7.7.x.x.x.b.E.E.(.~./.).).).9X6XqXiXpXaXfXdXhXjXjXhXhXdXaXaXaXaXiXiXiXiX9X9X].9X].).].].~.~.~.E.E.E.E.E.E.9.k.k.8.8.8.8.6.6.,.,.>.=.*.X.| } } }  .[ { H F F F v G c z z z k j j l d d i i o             mXAXAXGXAXGXGXGXGXGXHXGXHXHXHXHXHXHXLXHXLXLXLXLXLXPXLXPXLXPXPXPXPXPXPXSX+                                                                                 UXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW ! W ! t.! ! t./ t.q.t.t.r.r.r.p.r.p.r.p.p.p.p.a.a.p.2.7.2.7.x.j.x.x.z.Q.!.(.~./.).6X8X9XqXqXiXpXaXdXdXhXjXjXjXdXdXdXdXaXaXiXiXiX9X9X9X9X9X].].].~.~.~.~.E.E.E.E.E.9.9.k.9.9.8.8.6.6.6.6.>.>.=.*.X.X.| } } [ [ [ F F F v v v c c z z k k l l l i i l o             mXAXGXAXGXAXGXGXGXHXGXHXHXHXHXHXHXLXHXLXLXLXLXLXLXLXPXPXPXPXPXPXPXPXPXPX3 .                                                                                 UXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW W W ! ! ! ! ! t./ t.h.t.r.t.t.r.r.r.r.r.p.p.p.a.p.a.7.2.x.7.x.x.j.z.z.z.E.!.~././.).].9X9XqXqXiXaXaXdXdXjXjXjXdXdXdXdXaXaXiXiXqX9XiX9X9X9X].].).~.].~.~.~.E.~.E.9.E.E.k.k.k.8.8.8.6.6.6.,.>.>.>.X.X.X.} } } } [ [ [ F F F v v c c z z k j j l d d i l o             NXAXAXGXGXAXGXGXGXGXGXGXHXHXHXHXHXHXHXHXLXHXLXLXLXLXLXLXLXPXIXPXPXPXPXPXAX+                 .         . .     . . X   . .     . . .                           UXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW ! ! W ! ! t.! t.q.t.h.t.t.t.r.r.q.p.p.p.p.p.p.2.2.7.2.7.4.4.j.k.l.W.E.!.!._././.)./.8X9XqXqXpXpXaXfXdXdXjXjXdXdXdXdXaXaXaXaXiXiX9X9X9X9X].].].).).~.~.~.~.E.E.E.E.9.9.k.9.9.9.9.8.6.6.,.,.>.>.%.%.%.X.| } } } [ { { { F F b v v c z z z k j l l l i l o             mXAXAXAXGXAXGXGXGXGXHXGXHXHXHXHXHXHXLXHXLXHXLXLXLXLXLXLXLXPXPXLXPXPXPXPXPX4 .             O O O O O O O O O O O o O O O O O o O O + O O X . . . . .           UXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW W ! ! t.! t.! t.t.r.q.r.r.r.r.p.p.p.p.p.p.p.p.2.2.p.2.x.9.j.j.x.z.l.W.Q.!./././.4X8X9X9XqXqXpXaXaXdXdXjXjXhXjXdXdXaXaXaXiXiXiXiXiX9X9X9X9X].).).).~.~.E.E.E.E.E.E.E.E.k.k.9.8.8.8.6.6.6.,.,.>.>.=.%.X.} } } } [ [ { { F F b v v c c z z k j j l i i l o             NXAXAXGXAXGXAXGXGXGXGXHXGXGXHXHXHXHXHXLXLXLXHXSXLXLXLXPXLXPXPXPXPXPXPXPXPXBXX             & > : : : : : : : : : : : : : : : : : : : : : : UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX! ! ! ! W ! t.t.t.t.t.q.r.q.r.r.r.p.p.p.p.p.p.a.p.2.7.x.7.j.s.x.k.W.W.!.!.!.~.).).8X9X9XqXqXpXpXaXdXdXdXjXjXjXdXdXdXaXaXiXiXiXiX9XiX9X9X9X].].]._.).).~.~.~.E.E.E.E.E.9.9.k.9.9.8.6.6.6.,.,.,.=.>.%.%.o.| } } } [ [ [ F F b b v v c c z k k k j l l d i o             mXAXAXAXGXAXGXGXGXGXGXHXHXHXGXHXHXHXHXHXLXHXmX2 DXPXLXPXPXLXLXPXPXPXPXPXPXPX4               > : : > : : : : : : : : N : N : : : : : : : : UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXW t.! t.t.t.t.q.h.t.r.r.r.h.r.r.p.+.p.p.p.x.p.a.x.7.a.2.7.j.j.z.l.l.E.Q.!.(./.).8X).8X9XqXiXpXaXaXfXdXjXjXjXjXdXdXdXaXaXaXiXiXiXiX9X9X9X].].].).).~.~.~.~.~.E.E.E.9.k.E.k.k.9.8.8.8.6.6.,.,.>.>.=.%.%.X.| } } } [ [ { F F F b b v c c z z k j j l l i l o             mXAXAXAXAXGXAXGXGXGXGXGXGXGXHXGXHXHXHXLXHXmX.   3 PXLXLXLXLXPXPXLXPXPXPXPXPXDXX             @ : : : : : : g g g N : g : N N : N N : N N : UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX! ! t.t.t.t.t.t.t.r.r.r.r.r.r.p.r.p.p.p.a.a.p.2.2.2.4.4.j.x.x.z.z.W.W.!.~././.).).9X9XqXqXiXaXaXaXdXdXjXjXjXdXdXdXaXdXaXaXiXiXiXiX9X].9X9X].].].~.].~.~.~.E.E.E.E.E.W.6.W.k.8.8.8.8.6.6.6.6.>.>.=.%.%.X.| } } } [ [ { { F F b v v v c c z z j j l l d i &             mXAXAXGXAXGXGXAXGXGXGXHXGXGXHXGXHXHXLXLXMXX     + DXPXLXLXPXLXPXPXPXPXPXPXPXPX2             . > : : g : : g g g g g g g N g N g g N g N N UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX! t.W t.t.t.t.t.r.t.r.t.r.r.r.p.p.p.p.a.a.2.2.2.s.4.4.j.j.k.k.W.W.Q.!.~././.).6X8X6X9XqXiXiXaXaXdXdXdXjXjXjXdXdXdXaXaXaXiXiXqXiX9XiX9X9X].].].].].~.~.~.~.~.E.E.E.E.E.6.W.k.9.8.8.8.6.6.,.>.>.>.>.:.%.} | } } } [ [ [ { F F b b v c c z z k k j l d i l &             mXAXAXAXAXAXAXGXAXGXGXGXGXHXHXHXHXLXJXMXX         3 PXLXLXPXPXLXPXLXPXPXPXPXPXNXX           . > : : : g g g g f f g m g g m g N m M N g N UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX! ! t.t.t.t.t.h.t.r.t.r.r.p.p.p.p.p.p.x.a.2.2.2.7.8.4.j.k.k.l.W.E.!.!.~./.).).).].9XqXiXiXaXaXdXdXjXjXjXjXdXdXdXaXaXaXaXiXiXiXiX9X9X9X].].].].].~.].E.~.E.E.~.E.E.E.E.E.6.9.9.8.8.6.6.6.6.,.>.>.=.:.X.X.} } } } [ [ [ { F F b b v v c c z z k j j l d l o             mXAXAXAXAXAXAXGXGXGXGXGXGXGXGXHXHXHXMX            + DXPXLXLXLXLXLXPXPXPXPXPXPXLX+             . : : A g g f f f R m m m m M m m M M m m M UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXt.! t.t.t.t.t.q.r.r.r.r.p.0.p.p.p.p.p.p.p.2.2.2.4.s.j.d.k.l.W.W.Q.!.(././.).).9X9X9XqXiXiXaXaXdXdXdXjXjXjXdXdXdXdXaXaXiXiXiXqX9X9X].9X9X].].~.].~.].~.~.E.E.E.E.E.E.6.E.E.9.8.8.8.8.6.6.6.,.>.>.=.:.X.X.| } } } } [ { { F F b b v c v z z k j j j l d l o             mXSXAXAXAXAXAXAXAXGXGXGXGXGXGXHXHX3 X             . MXPXLXLXPXPXLXPXPXPXPXPXPXPXNX.             > g : g A f J m x J m J m m m m m m Z M M UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXt.t.t.t.q.t.t.r.r.r.r.p.p.p.p.p.p.p.a.a.a.2.a.7.8.j.k.s.k.W.W.W.!.!.~././.].].9X9X9XiXiXiXaXaXdXdXjXjXdXjXdXdXdXaXaXaXaXiXiXiX9XiX9X9X].].].].~.~.~.~.~.~.E.E.E.E.W.E.6.E.k.8.8.8.6.6.6.6.,.>.>.=.:.%.X.| | } } } [ [ { { F b b b v c c z k k k j l d l o             mXAXAXAXAXAXGXGXAXGXGXGXGXGXJXJXMX                  + DXPXLXLXLXPXLXLXPXPXPXPXPXPX+             X s g g f f m m J m P P m P P C ~ m m C m UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXt.t.q.t.h.r.r.t.q.r.r.p.r.p.p.p.p.a.2.a.a.2.7.8.s.4.x.W.k.W.E.!.!._././.).].].9XiXiXiXiXaXaXdXdXdXjXjXjXdXdXdXaXdXaXaXiXiXiXqXiX].9X9X].].].].~.].~.E.~.E.E.E.E.E.6.E.E.6.9.9.8.8.6.6.6.,.,.,.>.=.%.X.X.} } } } [ [ [ { F F F b v v c c z z k k j l l l o             mXAXAXAXAXAXAXAXAXGXAXGXGXJXGX3 .                     3 IXLXLXPXLXPXPXPXPXPXPXPXPXmXX             > g f g m x D P P P P L P P P L m C m UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXh.q.t.r.r.r.q.g.p.q.p.r.p.p.p.p.2.2.2.7.2.8.2.j.j.x.k.W.Q.W.!.!././.4X8X_.iX9X9XiXiXaXaXaXdXjXjXjXjXdXdXdXdXaXaXaXiXiXiXqXqX9X9X9X].].].].].~.].~.[.E.[.E.E.E.E.W.E.W.6.9.8.8.8.8.6.6.,.,.,.>.=.>.X.X.} } } } [ [ [ { F F b b v v v c z k k k j l d l o             mXSXSXAXAXAXAXAXAXGXGXGXGXGX3                         + DXPXLXLXPXLXLXPXPXPXPXPXPXHX+             O g g f A D m D P P P P P ~ m C P ~ P UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXr.t.t.r.q.r.r.r.p.h.p.p.p.p.2.2.p.2.a.2.8.2.j.j.j.l.z.W.Q.!.!.(./.).).).9X9X9X9XiXiXaXaXdXdXdXjXjXjXdXdXdXdXdXaXaXiXiXiXqXqX9X9X9X].].].~.].~.~.[.E.E.E.E.E.E.E.6.E.6.W.9.8.8.8.6.6.,.,.,.>.>.%.%.X.X.} } } } [ [ [ { { F F b n c v v z z k k k l d k o             mXSXSXAXAXAXAXAXAXGXGXGXGX3                           . MXPXLXLXLXPXPXPXIXPXPXPXPXPX3 .           . > g f f x G m P P P L L L L L L ~ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXn.q.h.r.r.p.r.p.p.p.p.x.p.a.a.p.7.7.7.7.x.j.x.k.x.z.!.Q.!.~.~./.).).9X9X6XqXqXiXpXaXaXdXdXhXjXjXhXdXdXdXdXaXaXiXiXiXiXiX9X9X9X].].].].].~.].~.~.~.~.E.E.E.E.E.E.6.E.6.W.6.E.6.6.6.6.,.,.>.>.=.%.X.X.X.| } } [ [ [ [ { F F b b v c c c z z k j l d l o             mXAXAXAXAXAXAXAXGXAXGXGX4 .             .               + SXPXLXLXPXPXLXPXPXPXPXPXPXLXX             X f f f D D P P F P L P @.L L L ~ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXr.q.r.r.r.r.r.p.0.p.p.p.a.a.2.2.a.j.7.s.j.x.k.z.Q.z.Q.~.~.).).).).8X9X9XqXiXpXaXaXdXdXjXjXjXjXdXdXdXaXaXaXaXaXiXiXiX9X9X9X9X9X].].].~.].~.~.~.~.E.[.E.E.E.E.E.6.6.E.E.6.6.6.6.6.6.,.,.>.>.>.=.X.X.} } } } [ [ [ { { F F b b v v c z z k k j l l k o             mXSXSXSXSXAXAXAXAXGXAX4                 . X             . MXPXLXLXLXLXPXPXLXPXPXPXPXPX3 .             : g f x D m P G P O.P @.L L L UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXr.r.r.r.r.r.p.p.p.p.2.p.a.x.a.j.7.2.x.j.x.x.l.z.W.!.!.~././.).).9X8X9XqXqXiXsXaXfXdXjXdXjXjXhXhXdXdXdXaXaXaXiXiXiXiXiX9X9X9X9X].].].].~.].~.~.~.E.E.E.E.E.E.E.W.6.W.6.6.6.6.6.6.6.,.>.>.>.%.%.X.X.X.X.} } } [ [ { { F F b v v v c c z z k k l d j &             mXAXSXAXSXAXAXAXGXAX2 .                 o & X             + DXPXLXPXLXPXPXPXPXPXPXPXPXGX+             O g f A x D D P @.P L @.@.P UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXr.r.r.p.p.p.p.p.x.p.2.p.2.2.2.7.j.j.x.x.x.W.W.!.!.~./././.4X8X9X9XqXqXiXpXaXaXaXdXdXjXjXdXhXdXdXdXdXaXaXaXiXiX9XiX9X9X9X9X].].]._.].~.~._.~.E.~.E.E.E.E.9.E.6.E.6.W.6.E.6.6.6.6.,.6.>.>.=.%.X.X.X.} } } [ [ [ [ F F F b b v v c c z z k j j d j o             mXSXAXSXAXAXAXAXAX2                 . o % % & .           . MXPXLXLXPXLXLXPXPXPXPXPXPXPX2 .           . : f f x m G P G O.O.@.O.UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXp.r.p.p.p.p.a.p.2.2.7.a.7.7.8.j.s.x.l.z.l.!.!.!.(.~.).).].8X8X9XqXqXiXpXaXfXdXdXjXjXjXjXdXdXdXaXaXaXaXiXiXiXiX9XiX].iX].].].].].].~.~.~.~.~.~.E.E.E.E.E.6.E.6.E.6.W.W.6.6.6.6.6.>.>.>.=.%.X.X.| } } } [ } [ { F { F b b v v c c c z k k j d j o             mXAXAXSXAXSXGXAX2 .                 O & + ; % X . .         2 SXPXPXLXPXPXLXLXPXPXPXPXPXSX.             O A f A D c P G H O.L UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXp.p.p.p.a.a.2.2.2.a.a.x.7.8.j.k.k.l.W.Q.E.Q.~././.).).8X9X6XqXqXiXiXaXaXfXdXdXjXjXjXjXdXdXdXdXaXaXaXaXiXiX9XiX9XiX].9X].].].].~.].~.~.E.~.E.E.E.E.E.E.E.6.E.6.W.6.6.6.6.6.6.,.,.,.>.=.:.%.X.| } } } } [ [ [ { F F F b v v c c z z k k j d k o             mXSXSXAXSXAXAX+                   o % % ; % % &   .           mXPXLXLXLXLXPXPXPXPXPXPXPXPX2               : f f f D P F P L UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXa.p.p.2.a.a.2.a.2.x.a.7.x.x.k.W.W.W.E.!.~.~././.).).8X9XqXqXqXpXiXaXfXdXdXhXjXjXjXjXdXdXdXaXaXaXaXiXiXiX9X9X9X].].].].].].].~.~.~.~.~.~.E.E.E.E.6.6.E.E.6.E.6.6.6.6.6.6.,.,.>.>.>.%.:.X.X.} | } } [ } [ { { F F F b b v v c c z z k k l k &             mXAXAXSXAXSX2                   o % % % % % ; % X             + SXPXLXPXLXPXPXLXLXPXPXPXPXAX.             > f A f D D F G UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXa.p.p.1.a.7.7.7.7.x.x.x.k.l.W.Q.!.!.~./.).).).8X8X9XqXqXiXpXiXaXdXdXdXhXjXjXdXdXdXdXaXdXaXaXaXiXiXiXiX9X].iX].].].].]._.].~.~.~.~.E.[.E.E.E.E.E.W.6.W.6.W.6.W.6.6.6.6.,.,.>.>.=.>.X.X.X.| } } } [ [ [ { F F F b b v v c z z z k j d k o             mXSXSXAXSX+                   & & % % ; ; ; ; ; & .           . MXLXLXLXLXPXLXPXPXPXPXPXPXPX2             . : f f D m D UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXa.2.2.s.7.2.4.4.j.x.k.W.W.W.Q.!.~.~./.).).9X8X9X9XqXqXiXpXaXaXdXdXhXhXjXhXhXdXdXdXaXaXaXaXiXiXiXiXiX].iX].9X].].].].].~.].E.~.E.~.E.E.E.E.E.9.9.z.k.k.6.6.6.6.6.6.6.,.,.,.,.=.:.X.X.} } } } } [ [ { [ F F F F v v v c c z k k k d z o             mXSXGXSX+                   o & % % % + ; ; ; ; a X .           2 AXPXLXIXPXLXPXPXPXPXPXPXPXBX.             > f f D f UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX2.s.2.2.8.9.j.j.x.l.z.W.W.!.!.~./.)./.4X).9X9XqXqXqXpXpXaXdXdXdXhXjXjXhXhXdXdXaXdXaXaXaXiXiX9XiX9XiXiX].].9X].].`.].].~.~.~.~.E.E.E.E.E.E.z.z.9.8.8.W.6.W.6.6.6.6.,.,.,.=.=.:.X.X.X.| } } [ } [ [ F F F F F b v v c c z z k k l k o             mXAXDX+ .                 o & & % % ; ; ; ; a ; a + . .           NXPXLXLXLXPXLXPXPXLXPXPXPXIX+               f g UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7.s.4.j.x.j.k.W.W.W.!.!.(.~././.).).9X9X9XqXiXiXiXaXaXdXdXhXjXjXhXhXdXdXaXdXaXaXaXiXiXiXiX9XiX].].9X].].].~.~.].~._.~.~.~.~.E.E.9.E.9.z.9.9.9.k.6.6.6.6.6.6.,.,.,.>.=.=.%.X.X.X.X.} } } [ [ [ [ F F F v b v v c c z z k j d k &             NXDX+                   o & % % % * ; ; ; ; a ; ; ; X             2 AXPXLXPXLXPXPXPXPXPXPXPXPXBX              O UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX9.s.k.l.l.z.W.!.Q.~./././.).8X].9X6X9XqXiXiXaXfXsXdXdXjXjXjXhXhXdXdXdXdXaXaXaXiXiXiXiX9X9X9X9X].].].].].].~.~.~.~.E.E.E.E.E.E.E.z.z.9.z.9.8.E.W.6.6.6.6.,.,.,.>.,.o.X.X.X.} } } } [ } [ { { F F F F b v v c c c z x k j z o             MX+                   & & & & % % * ; ; ; a ; a a a %               mXPXLXLXLXPXLXLXIXPXPXPXPXPX+               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXj.x.k.W.W.!.!.!./././.).).).9X6X9XqXiXqXsXaXaXdXdXjXjXjXjXhXhXdXdXaXaXaXaXaXaXiXiXiX].iX9XiX].].].].].~.~.~.~.~.~.E.E.E.E.9.9.E.9.9.9.k.8.6.6.6.6.6.6.6.,.=.>.>.=.%.%.X.X.| } } [ } [ { { { F F v v v v v c z z z j j k o             .                   & & & & % % % * ; ; = a a a a a ; o . . .       2 DXLXLXPXLXPXPXPXPXPXPXPXPXBX                UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXz.W.!.W.!.~.~././.).8X8X9X9XqXqXiXpXaXaXdXdXdXdXjXjXhXhXdXdXdXdXaXaXaXiXiXiXiXiX9X].9X].].].].].].].~.~.~.~.~.E.E.E.E.E.E.E.9.E.9.8.k.6.W.6.W.6.6.,.,.=.,.>.=.%.X.X.} X.} } } } [ [ { { F F F F v v c c z c k j j k &                               & & & & % % * * * ; ; = a a a a a a % . .         . NXPXLXLXLXLXPXLXPXPXPXPXPXJX+               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX!.!.!./././.).).).8X8X9XqXqXiXpXaXaXaXdXdXjXjXjXhXhXdXaXdXaXaXaXiXiXiXiXiXiX9X9X9X].].].].].].].~.~.~.~.~.~.E.E.E.9.E.9.z.9.9.k.8.6.6.6.6.6.6.,.,.,.,.=.>.=.%.X.X.} } } [ [ [ [ { { { F F F b v v c c z z j f z &                           . & & & % % % % * * = a a ; a a a a a B ; X .           4 JXPXPXLXPXLXPXPXPXPXPXPXPXMX                UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX~./.).).4X9X9X9XqXqXiXpXaXaXdXdXdXdXjXjXjXjXdXdXdXaXdXaXaXaXaXiXiX].].iX9X9X9X].].].~.].~.~.~.~.~.E.~.E.E.E.E.z.E.9.k.k.9.8.E.6.6.6.6.6.6.,.,.=.=.o.%.X.X.X.X.} } } } [ [ { { F F F v v v v c c z z k j k o                         . & & & % % % % % * = = ; a a a a a a p a a & .             NXPXLXLXLXPXLXPXLXPXPXPXPXPX.               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX).4X8X8X9XqXqXqXqXpXyXyXdXdXhXhXhXhXhXhXdXdXdXdXaXaXaXaXiXiXiX].9X9X].9X].].].].].~.~.].~.~.~.E.~.E.E.W.W.9.W.9.k.k.8.k.9.9.8.6.6.6.,.,.>.>.>.>.:.X.X.| } } } } } [ [ [ { F F F b n v v v c z z k j k o                       . & % & % % % * * * * = = = y y a y a p a a p ; X             2 AXPXLXLXPXLXPXLXPXPXPXPXPXmX.             UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX9X9XqXqXiXpXsXfXhXdXdXhXjXjXhXhXhXdXdXaXaXaXaXiXiXiXiXiXiXiX9X9X].].9X].].`.~.~.~.`.[.~.E.E.E.E.E.W.W.k.9.8.k.8.8.6.6.8.8.6.6.6.,.>.>.>.=.:.%.X.| X.} } O.[ [ [ { { F F b b v v v c c z z x d k &                     . % & % % % * % * * * * = = y y y y p p a p p p B %             . NXLXLXLXLXPXLXPXPXPXPXPXPXHXX               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXwXqXpXpXaXsXhXdXdXhXjXhXhXhXdXdXaXdXaXaXaXaXiXiXiXiX].9X9X9X].].9X].].].~.].~.~.E.E.~.E.E.E.E.k.E.k.k.k.8.8.k.9.6.6.6.6.6.,.,.,.>.>.X.%.X.X.} } } } } } [ [ { F F F F F v b v c c z z k j v o                   . & % % % % % * * * * * = = y y a a p y p p p p a a ; O             4 GXPXLXPXLXPXPXPXPXPXPXPXPX4               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXpXfXhXjXdXhXjXjXjXhXhXdXdXdXaXaXaXaXaXqXiX9XiXiX9X9X9X9X].].].].].].~.~.~.~.~.E.E.E.E.E.E.k.E.k.k.k.k.8.9.9.6.6.6.,.,.,.,.>.>.=.:.%.X.| X.} }  .} [ [ { { { F F F b v v v c c z x j z &                 X & % % % % * * * * * * = = = = = y y y y p a p p a a a &               DXPXLXLXLXLXLXPXIXPXPXPXPXMX              UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXdXhXjXjXjXdXdXdXdXaXaXaXaXaXiXaXiX].iX].9X].].].].].].].~.~.~.~.~.E.~.~.E.E.W.W.9.E.k.9.9.9.8.8.6.6.9.6.6.,.,.,.>.>.>.=.:.%.X.X.} } } } } [ [ { { F F F F b v v c c c z k j z o               X & % % % > % * * * = = = = = = y y y y a a p p p p a p B ; X             4 JXLXLXPXPXPXLXLXPXPXPXPX3               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXjXjXdXdXdXaXdXdXaXaXpXiXiXiXiXiX].].iXiX].].].].~.~.].].~.~.~.E.E.E.E.z.W.E.9.E.9.k.9.k.8.9.6.6.6.6.,.,.,.,.>.=.=.:.X.X.} $.| } } [ } [ [ { { F F b b v v v c c z x j v o             O % * > * > * * * - = = = = y = = y y y y a a a p p p a a UXUX                BXLXPXLXLXLXPXPXPXPXPXPX+               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXdXdXdXaXaXaXiXiXiXiXiX].iXiX9X].].].].].].~.].~.~.~.W.~.~.E.E.E.z.k.k.9.k.9.k.8.8.6.8.6.6.6.,.,.>.>.>.>.%.:.X.X.| | } } }  .[ [ [ { { F F b b b v v c c z k j z o           O % > * % > * * * * = = = = y = = = = y y y a a p p UXUXUXUXUXUXUX              4 GXLXLXLXLXPXLXPXPXLXMX                UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXaXiXiXiXiX9XiX].].].9X].].~.].~.]._.~.~.~.~.W.W.E.E.z.E.E.k.k.k.9.9.8.j.9.9.6.8.6.6.,.6.>.>.>.=.:.X.X.| | } } [ [ } [ [ { { F F F b b v c c c x z j c &         O > - * > * * - * - - = = y y = y y y y = y UXUXUXUXUXUXUXUXUXUXUXUX              X DXPXLXPXLXPXPXPXJX3 .               UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXiX9X9X9X9X].].].].`.`.~.~.~.~.!.!.~.E.E.W.c.l.z.z.k.j.j.j.9.9.8.6.6.6.6.6.,.,.,.>.=.%.=.X.X.| } } } } } } { { { { F F F b v v c n c c k x c &       O - > - * > * - - - = - y - y y y y UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX          .   4 SXJXHXHXGXAXBXX                   UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX9X].].].].).~.~.~.!.!.~.W.E.E.c.v.k.k.k.j.j.8.9.9.9.8.8.7.6.6.,.,.>.>.>.=.%.X.X.| | | } } [ [ [ [ { { F F F b v v n c c x k k z o     O - - - - - - - - * - - = UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX                X 4 3 3 4 X                     UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX~.~.^.!.^.uXE.d.d.g.k.k.x.z.k.9.s.9.8.8.8.7.6.6.,.,.>.=.=.=.%.%.| | X.} } } } [ [ [ { { { P b b b n v v x z x j c &   o u s - - > * % % UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX                                              UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXV.S N.N.T U.5.i.5.5.W.,.5.,.5.3.=.5.=.=.=.=.=.*.X.| | }  .}  .}  .G H K G G Q G D D A f A A A : A c O . UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX                                            UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX# 6 , , , 6 # , < 9 < < 9 S S S S 9 S S S T S S T S S S S S S S S < < 4 < < < < , , , , # # # # # UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX                                        UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX, 6 6 6 6 6 6 5 5 5 5 9 5 5 9 5 5 < 5 5 5 , , , , , , , , # 6 # , , , 6 # # , , # , # # # # # # # UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX                                    UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX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UXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\"\n};\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n\n   <extension\n         id=\"application\"\n         point=\"org.eclipse.core.runtime.applications\">\n      <application>\n         <run\n               class=\"jbt.tools.bteditor.Application\">\n         </run>\n      </application>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.perspectives\">\n      <perspective\n            name=\"RCP Perspective\"\n            class=\"jbt.tools.bteditor.Perspective\"\n            id=\"jbt.tools.bteditor.perspective\">\n      </perspective>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.views\">\n      <view\n            class=\"jbt.tools.bteditor.views.NodesNavigator\"\n            icon=\"icons/nodesNavigator.png\"\n            id=\"jbt.tools.bteditor.views.NodesNavigator\"\n            name=\"Nodes Navigator\"\n            restorable=\"true\">\n      </view>\n      <view\n            class=\"jbt.tools.bteditor.views.NodeInfo\"\n            icon=\"icons/info.png\"\n            id=\"jbt.tools.bteditor.views.NodeInfo\"\n            name=\"Node Info\"\n            restorable=\"true\">\n      </view>\n      <view\n            class=\"jbt.tools.bteditor.views.NodesSearcher\"\n            icon=\"icons/search.png\"\n            id=\"jbt.tools.bteditor.views.NodesSearcher\"\n            name=\"Nodes Searcher\"\n            restorable=\"true\">\n      </view>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.editors\">\n      <editor\n            class=\"jbt.tools.bteditor.editor.BTEditor\"\n            default=\"false\"\n            icon=\"icons/BT.png\"\n            id=\"jbt.tools.bteditor.editor.BTEditor\"\n            name=\"BT Editor\">\n      </editor>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.editorActions\">\n      <editorContribution\n            id=\"jbt.tools.bteditor.editor.BTEditorContribution\"\n            targetID=\"jbt.tools.bteditor.editor.BTEditor\">\n         <action\n               class=\"jbt.tools.bteditor.actions.CollapseTreeAction\"\n               icon=\"icons/collapseTree.png\"\n               id=\"jbt.tools.bteditor.actions.CollapseTreeAction\"\n               label=\"Collapse Tree\"\n               style=\"push\"\n               toolbarPath=\"Normal\"\n               tooltip=\"Collapses all the nodes of the active behaviour tree\">\n         </action>\n         <action\n               class=\"jbt.tools.bteditor.actions.ExpandTreeAction\"\n               icon=\"icons/expandTree.png\"\n               id=\"jbt.tools.bteditor.actions.ExpandTreeAction\"\n               label=\"Expand Tree\"\n               style=\"push\"\n               toolbarPath=\"Normal\"\n               tooltip=\"Expands all the nodes of the active behaviour tree\">\n         </action>\n         <action\n               class=\"jbt.tools.bteditor.actions.ClearErrorsAction\"\n               icon=\"icons/clearErrors.png\"\n               id=\"jbt.tools.bteditor.actions.ClearErrorsAction\"\n               label=\"Clear Errors\"\n               style=\"push\"\n               toolbarPath=\"Normal\"\n               tooltip=\"Clear the errors of the active behaviour tree\">\n         </action>\n         <action\n               class=\"jbt.tools.bteditor.actions.CheckErrorsAction\"\n               icon=\"icons/checkBT.png\"\n               id=\"jbt.tools.bteditor.actions.CheckErrorsAction\"\n               label=\"Check Errors\"\n               style=\"push\"\n               toolbarPath=\"Normal\"\n               tooltip=\"Checks for errors in the active behavior tree\">\n         </action>\n      </editorContribution>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.bindings\">\n      <key\n            commandId=\"org.eclipse.ui.file.save\"\n            contextId=\"org.eclipse.ui.contexts.window\"\n            schemeId=\"jbt.tools.bteditor.defaultScheme\"\n            sequence=\"Ctrl+S\">\n      </key>\n      <scheme\n            id=\"jbt.tools.bteditor.defaultScheme\"\n            name=\"Default Scheme\">\n      </scheme>\n   </extension>\n   <extension\n         id=\"product\"\n         point=\"org.eclipse.core.runtime.products\">\n      <product\n            application=\"jbt.tools.bteditor.application\"\n            name=\"JBT Editor\">\n         <property\n               name=\"appName\"\n               value=\"JBT Editor\">\n         </property>\n         <property\n               name=\"aboutText\"\n               value=\"JBT Editor&#x0A;&#x0A;JBT Editor is an RCP application for defining behaviour trees in a standard XML format.&#x0A;&#x0A;(c) Copyright Ricardo Juan Palma Durán 2010.  All rights reserved.&#x0A;&#x0A;Credits:&#x0A;&#x0A;Icons: iconspedia (http://www.iconspedia.com/) and icons at Wikimedia Commons (http://commons.wikimedia.org/wiki/Category:Icons).\">\n         </property>\n         <property\n               name=\"aboutImage\"\n               value=\"icons/jbt.png\">\n         </property>\n         <property\n               name=\"windowImages\"\n               value=\"icons/jbt16.png,icons/jbt32.png,icons/jbt48.png,icons/jbt64.png,icons/jbt128.png\">\n         </property>\n      </product>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.handlers\">\n      <handler\n            class=\"jbt.tools.bteditor.DisableNewEditorHandler\"\n            commandId=\"org.eclipse.ui.window.newEditor\">\n         <enabledWhen>\n            <count\n                  value=\"*\">\n            </count></enabledWhen>\n         <activeWhen>\n            <count\n                  value=\"*\">\n            </count>\n         </activeWhen>\n      </handler>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/plugin_customization.ini",
    "content": "org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false\r\norg.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = false\r\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/Activator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"jbt.tools.bteditor\";\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n\t/**\n\t * Returns an image descriptor for the image file at the given\n\t * plug-in relative path\n\t *\n\t * @param path the path\n\t * @return the image descriptor\n\t */\n\tpublic static ImageDescriptor getImageDescriptor(String path) {\n\t\treturn imageDescriptorFromPlugin(PLUGIN_ID, path);\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/Application.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\n\nimport jbt.tools.bteditor.util.StandardDialogs;\n\nimport org.eclipse.equinox.app.IApplication;\nimport org.eclipse.equinox.app.IApplicationContext;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.PlatformUI;\n\n/**\n * This class controls all aspects of the application's execution\n */\npublic class Application implements IApplication {\n\tpublic static final String PLUGIN_ID = \"jbt.tools.bteditor\";\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @seeorg.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.\n\t * IApplicationContext)\n\t */\n\tpublic Object start(IApplicationContext context) throws Exception {\n\t\tDisplay display = PlatformUI.createDisplay();\n\n\t\t/*\n\t\t * Before doing anything at all, standard nodes must be loaded. If they\n\t\t * cannot be loaded, the application will not start.\n\t\t */\n\t\ttry {\n\t\t\tNodesLoader.loadStandardNodes();\n\t\t\tApplicationIcons.loadIcons();\n\t\t} catch (Exception e) {\n\t\t\tStandardDialogs\n\t\t\t\t\t.exceptionDialog(\n\t\t\t\t\t\t\t\"Could not start application\",\n\t\t\t\t\t\t\t\"There were errors while loading the set of standard nodes\",\n\t\t\t\t\t\t\te);\n\t\t\treturn IApplication.EXIT_OK;\n\t\t}\n\n\t\ttry {\n\t\t\tint returnCode = PlatformUI.createAndRunWorkbench(display,\n\t\t\t\t\tnew ApplicationWorkbenchAdvisor());\n\t\t\tif (returnCode == PlatformUI.RETURN_RESTART)\n\t\t\t\treturn IApplication.EXIT_RESTART;\n\t\t\telse\n\t\t\t\treturn IApplication.EXIT_OK;\n\t\t} finally {\n\t\t\t/* Dispose loaded icons. */\n\t\t\tApplicationIcons.disposeIcons();\n\t\t\tdisplay.dispose();\n\t\t}\n\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see org.eclipse.equinox.app.IApplication#stop()\n\t */\n\tpublic void stop() {\n\t\tfinal IWorkbench workbench = PlatformUI.getWorkbench();\n\t\tif (workbench == null)\n\t\t\treturn;\n\t\tfinal Display display = workbench.getDisplay();\n\t\tdisplay.syncExec(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tif (!display.isDisposed())\n\t\t\t\t\tworkbench.close();\n\t\t\t}\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/ApplicationActionBarAdvisor.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport jbt.tools.bteditor.actions.DialogExportAsCppAction;\nimport jbt.tools.bteditor.actions.DialogLoadMMPMDomainAction;\nimport jbt.tools.bteditor.actions.DialogOpenBTAction;\nimport jbt.tools.bteditor.actions.NewBTAction;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.jface.action.GroupMarker;\nimport org.eclipse.jface.action.IContributionItem;\nimport org.eclipse.jface.action.ICoolBarManager;\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.IToolBarManager;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.action.ToolBarManager;\nimport org.eclipse.ui.IWorkbenchActionConstants;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.actions.ActionFactory;\nimport org.eclipse.ui.actions.ContributionItemFactory;\nimport org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;\nimport org.eclipse.ui.application.ActionBarAdvisor;\nimport org.eclipse.ui.application.IActionBarConfigurer;\n\npublic class ApplicationActionBarAdvisor extends ActionBarAdvisor {\n\tprivate IWorkbenchWindow window;\n\n\tprivate IWorkbenchAction openBTAction;\n\tprivate Action newBTAction;\n\tprivate IWorkbenchAction saveBTAction;\n\tprivate IWorkbenchAction saveBTAsAction;\n\tprivate IWorkbenchAction loadMMPMDomainAction;\n\tprivate IWorkbenchAction aboutAction;\n\tprivate IWorkbenchAction exportAsCppAction;\n\n\tprivate IContributionItem viewsList;\n\n\tpublic ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {\n\t\tsuper(configurer);\n\t}\n\n\tprotected void makeActions(IWorkbenchWindow window) {\n\t\tthis.window = window;\n\n\t\tthis.saveBTAction = ActionFactory.SAVE.create(this.window);\n\t\tthis.saveBTAsAction = ActionFactory.SAVE_AS.create(this.window);\n\t\tthis.exportAsCppAction = new DialogExportAsCppAction(this.window);\n\t\tthis.openBTAction = new DialogOpenBTAction(this.window);\n\t\tthis.newBTAction = new NewBTAction();\n\t\tthis.loadMMPMDomainAction = new DialogLoadMMPMDomainAction(this.window);\n\t\tthis.viewsList = ContributionItemFactory.VIEWS_SHORTLIST.create(this.window);\n\t\tthis.aboutAction = ActionFactory.ABOUT.create(this.window);\n\n\t\t/* For key bindings and for copy and paste actions... */\n\t\tthis.register(this.saveBTAction);\n\t\tthis.register(ActionFactory.COPY.create(this.window));\n\t\tthis.register(ActionFactory.PASTE.create(this.window));\n\t}\n\n\tprotected void fillMenuBar(IMenuManager menuBar) {\n\t\tMenuManager fileMenu = new MenuManager(\"File\");\n\t\tMenuManager viewMenu = new MenuManager(\"View\");\n\t\tMenuManager helpMenu = new MenuManager(\"Help\");\n\n\t\tMenuManager showViewMenu = new MenuManager(\"Show view\");\n\n\t\tfileMenu.add(this.newBTAction);\n\t\tfileMenu.add(this.openBTAction);\n\t\tfileMenu.add(this.saveBTAction);\n\t\tfileMenu.add(this.saveBTAsAction);\n\t\tfileMenu.add(this.exportAsCppAction);\n\t\tfileMenu.add(this.loadMMPMDomainAction);\n\n\t\tshowViewMenu.add(this.viewsList);\n\t\tviewMenu.add(showViewMenu);\n\n\t\thelpMenu.add(this.aboutAction);\n\n\t\tmenuBar.add(fileMenu);\n\t\tmenuBar.add(viewMenu);\n\t\tmenuBar.add(helpMenu);\n\t}\n\n\tprotected void fillCoolBar(ICoolBarManager coolBar) {\n\t\tIToolBarManager firstCoolBar = new ToolBarManager(coolBar.getStyle());\n\t\tcoolBar.add(firstCoolBar);\n\t\tfirstCoolBar.add(this.newBTAction);\n\t\tfirstCoolBar.add(this.saveBTAction);\n\t\tfirstCoolBar.add(this.saveBTAsAction);\n\t\tfirstCoolBar.add(this.exportAsCppAction);\n\t\tfirstCoolBar.add(this.openBTAction);\n\t\tfirstCoolBar.add(this.loadMMPMDomainAction);\n\t\tcoolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/ApplicationIcons.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport java.io.FileInputStream;\nimport java.io.IOException;\nimport java.net.URL;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Hashtable;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.util.IconsPaths;\n\nimport org.eclipse.core.runtime.FileLocator;\nimport org.eclipse.core.runtime.Path;\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.jdom.Document;\nimport org.jdom.Element;\nimport org.jdom.input.SAXBuilder;\n\n/**\n * Class used to manage common icons in the application. These include icons\n * for standard nodes (those read form the\n * {@link NodesLoader#STANDARD_NODES_FILE} file), as well for \"actions\",\n * \"conditions\", \"categories\" and \"guards\" (whose path can be accessed via\n * {@link IconsPaths}).\n * <p>\n * They can be retrieved by their path in the plugin, and they are\n * automatically disposed by the application.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ApplicationIcons {\n\t/** List of the icons. Can be retrieved by their path in the plugin. */\n\tprivate static Map<String, Image> applicationIcons = new Hashtable<String, Image>();\n\n\t/**\n\t * Returns an icon by its path in the plugin, or null if it cannot be\n\t * found.\n\t * <p>\n\t * The returned image does not have to be disposed. It is automatically\n\t * managed by the application.\n\t * <p>\n\t * This function should be called after loading the icons (\n\t * {@link #loadIcons()}).\n\t */\n\tpublic static Image getIcon(String iconLocation) {\n\t\treturn applicationIcons.get(iconLocation);\n\t}\n\n\t/**\n\t * Loads all the common standard icons.\n\t * \n\t * @throws IOException\n\t *             in case there is an error while loading the icons.\n\t */\n\tpublic static void loadIcons() throws IOException {\n\t\tURL url = FileLocator.find(Activator.getDefault().getBundle(), new Path(\n\t\t\t\tNodesLoader.STANDARD_NODES_FILE), Collections.EMPTY_MAP);\n\n\t\tURL fileUrl = null;\n\t\tfileUrl = FileLocator.toFileURL(url);\n\t\tFileInputStream file = new FileInputStream(fileUrl.getPath());\n\n\t\t/* First get icons from the standard nodes file. */\n\t\tparseStandardNodesFile(file);\n\n\t\t/* Then non standard icons. */\n\t\tloadNonStandardIcons();\n\t}\n\n\tprivate static List<Exception> parseStandardNodesFile(FileInputStream file) {\n\t\tList<Exception> exceptions = new Vector<Exception>();\n\n\t\tSAXBuilder builder = new SAXBuilder();\n\t\ttry {\n\t\t\tDocument doc = builder.build(file);\n\n\t\t\tElement root = doc.getRootElement();\n\n\t\t\tparseElement(root);\n\t\t} catch (Exception e) {\n\t\t\texceptions.add(e);\n\t\t}\n\n\t\treturn exceptions;\n\t}\n\n\tprivate static void parseElement(Element e) {\n\t\tString nodeType = e.getName();\n\n\t\tif (nodeType.equals(\"Category\")) {\n\t\t\tList<Element> children = e.getChildren();\n\n\t\t\tfor (Element child : children) {\n\t\t\t\tparseElement(child);\n\t\t\t}\n\t\t} else if (nodeType.equals(\"Node\")) {\n\t\t\tString path = e.getChildText(\"Icon\");\n\t\t\tloadIcon(path);\n\t\t}\n\t}\n\n\tprivate static void loadNonStandardIcons() {\n\t\tloadIcon(IconsPaths.ACTION);\n\t\tloadIcon(IconsPaths.CONDITION);\n\t\tloadIcon(IconsPaths.ROOT);\n\t\tloadIcon(IconsPaths.CATEGORY);\n\t\tloadIcon(IconsPaths.GUARD);\n\t\tloadIcon(IconsPaths.BT);\n\t}\n\n\t/**\n\t * Loads an icon into {@link #applicationIcons} from an icon path.\n\t */\n\tprivate static void loadIcon(String iconPath) {\n\t\tImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(\n\t\t\t\tActivator.PLUGIN_ID, iconPath);\n\t\tImage icon = imageDescriptor == null ? null : imageDescriptor.createImage();\n\n\t\tapplicationIcons.put(iconPath, icon);\n\t}\n\n\t/**\n\t * Disposes all the icons stored by the ApplicationIcons.\n\t */\n\tpublic static void disposeIcons() {\n\t\tCollection<Image> icons = applicationIcons.values();\n\t\tfor (Image icon : icons) {\n\t\t\tif (icon != null) {\n\t\t\t\ticon.dispose();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ApplicationIcons() {\n\t};\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/ApplicationWorkbenchAdvisor.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport org.eclipse.ui.application.IWorkbenchWindowConfigurer;\nimport org.eclipse.ui.application.WorkbenchAdvisor;\nimport org.eclipse.ui.application.WorkbenchWindowAdvisor;\n\npublic class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {\n\tprivate static final String PERSPECTIVE_ID = \"jbt.tools.bteditor.perspective\";\n\n\tpublic WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {\n\t\treturn new ApplicationWorkbenchWindowAdvisor(configurer);\n\t}\n\n\tpublic String getInitialWindowPerspectiveId() {\n\t\treturn PERSPECTIVE_ID;\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/ApplicationWorkbenchWindowAdvisor.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport org.eclipse.ui.application.ActionBarAdvisor;\nimport org.eclipse.ui.application.IActionBarConfigurer;\nimport org.eclipse.ui.application.IWorkbenchWindowConfigurer;\nimport org.eclipse.ui.application.WorkbenchWindowAdvisor;\n\npublic class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {\n\n\tpublic ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {\n\t\tsuper(configurer);\n\t}\n\n\tpublic ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {\n\t\treturn new ApplicationActionBarAdvisor(configurer);\n\t}\n\n\tpublic void preWindowOpen() {\n\t\tIWorkbenchWindowConfigurer configurer = getWindowConfigurer();\n\n\t\tconfigurer.setShowCoolBar(true);\n\t\tconfigurer.setShowMenuBar(true);\n\t\tconfigurer.setShowStatusLine(true);\n\t}\n\n\tpublic void postWindowOpen() {\n\t\t/* Maximize the window. */\n\t\tgetWindowConfigurer().getWindow().getShell().setMaximized(true);\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/BTCPPManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.PrintStream;\nimport java.util.Calendar;\n\nimport jbt.tools.bteditor.NodesLoader.NodeCategories;\nimport jbt.tools.bteditor.model.BT;\nimport jbt.tools.bteditor.model.BTNode;\nimport jbt.tools.bteditor.model.BTNode.Parameter;\nimport jbt.tools.bteditor.model.BTNode.VarParameter;\nimport jbt.tools.bteditor.model.ConceptualBTNode;\nimport jbt.tools.bteditor.model.ConceptualBTNode.NodeInternalType;\nimport jbt.tools.bteditor.model.ConceptualBTNode.ParameterType;\n\nimport org.jdom.Document;\nimport org.jdom.Element;\n\n/**\n * Class used to export and load behaviour trees into/from XML files.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTCPPManager {\n\t\n\t/**\n\t * Exports a {@link BT} into an CPP file. Also creates a header file\n\t */\n\tpublic static void export(BT tree, String fileName) throws IOException {\n\t\t\n\t\t//Uncomment blocks to export different files\n\t\t\n\t\t//String headerName = fileName.replace(\".cpp\", \".h\");\n\t\t//FileOutputStream headerFile = new FileOutputStream(headerName);\n\t\t//exportHeader(tree, headerFile);\n\t\t//\t\t\n\t\t//FileOutputStream file = new FileOutputStream(fileName);\n\t\t//export(tree, file);\n\t\t//file.close();\n\t\t\n\t\tString inlineName = fileName.replace(\".cpp\", \".inl\");\n\t\tFileOutputStream inlineFile = new FileOutputStream(inlineName);\n\t\texportInline(tree, inlineFile);\n\t\tinlineFile.close();\n\t}\n\t\n\t/**\n\t * Exports a {@link BT} into a CPP file\n\t */\n\tpublic static void exportInline(BT tree, FileOutputStream file) throws IOException {\n\n\t\t// Connect print stream to the output stream\n\t\tPrintStream p = new PrintStream( file );\n\t\tcreateInlineFile(tree,p);\n\t\tp.close();\n\t\n\t\tfile.close();\n\t}\n\n\t/**\n\t * Exports a {@link BT} into a CPP file\n\t */\n\tpublic static void export(BT tree, FileOutputStream file) throws IOException {\n\n\t\t// Connect print stream to the output stream\n\t\tPrintStream p = new PrintStream( file );\n\t\tcreateCPPFile(tree, p);\n\t\tp.close();\n\t\n\t\tfile.close();\n\t}\n\t\n\t/**\n\t * Exports a {@link BT} into a .H file\n\t */\n\tpublic static void exportHeader(BT tree, FileOutputStream file) throws IOException {\n\n\t\tPrintStream p = new PrintStream( file );\n\t\tcreateHeaderFile(tree, p);\n\t\tp.close();\n\t\n\t\tfile.close();\n\t}\n\n\t/**\n\t * Creates and .CPP file from a {@link BT}.\n\t */\n\tprivate static void createCPPFile(BT tree, PrintStream p) {\n\t\t\n\t\tString BTName = tree.getRoot().getName();\n\t\t\n\t\tp.println(\"/**\");\n\t\tp.println(\" @file \"+BTName+\".cpp\");\n\t\tp.println(\" Contiene la implementaci�n de un componente de BT\");\n\t\tp.println();\n\t\tp.println(\" @author Fichero generado autom�ticamente con JBT Editor\");\n\t\tp.println(\"*/\");\n\t\tp.println();\n\t\tp.println(\"#include \\\"\"+BTName+\".h\\\"\");\n\t\tp.println(\"#include \\\"LatentAction.h\\\"\");\n\t\tp.println();\n\t\tp.println(\"#include <alive/TreeBuilder.h>\");\n\t\tp.println();\n\t\tp.println();\n\t\tp.println(\"namespace OIM {\");\n\t\tp.println(\"\");\n\t\tp.println(\"\\tIMP_FACTORIA(C\"+BTName+\");\");\n\t\tp.println(\"\\tIMPL_SUBCLASS_TYPE(C\"+BTName+\", CBTComponent);\");\n\t\tp.println(\"\\talive::Node *C\"+BTName+\"::createBehaviourTree() {\");\n\t\tp.println(\"\\t\\treturn\");\n\t\tp.println(\"\\t\\t\\talive::TreeBuilder()\");\n\t\t\n\t\t//TODO write file info\n\t\tElement rootElement = new Element(\"Tree\");\n\t\tprocessNode(tree.getRoot(), p, \"\\t\\t\\t\");\n\t\t\n\t\tp.println();\n\t\tp.println(\"\\t}\");\n\t\tp.println();\n\t\tp.println(\"} //namespace OIM\");\n\t}\n\t\n\t/**\n\t * Creates and .CPP file from a {@link BT}.\n\t */\n\tprivate static void createInlineFile(BT tree, PrintStream p) {\n\t\t\n\t\tString BTName = tree.getRoot().getName();\n\t\t\n\t\tp.println(\"\\t\\treturn\");\n\t\tp.println(\"\\t\\t\\talive::TreeBuilder()\");\n\t\t\n\t\t//TODO write file info\n\t\tElement rootElement = new Element(\"Tree\");\n\t\tprocessNode(tree.getRoot(), p, \"\\t\\t\\t\");\n\t}\n\t\n\t/**\n\t * Creates a .H from a {@link BT}. \n\t */\n\tprivate static void createHeaderFile(BT tree, PrintStream p) {\n\t\t\n\t\tCalendar cal = Calendar.getInstance();\n\t\tint currentYear = cal.get(Calendar.YEAR);\n\t\tString BTName = tree.getRoot().getName();\n\t\t\n\t\tp.println(\"/**\");\n\t\tp.println(\"@file \"+BTName+\".h\");\n\t\tp.println(\" Contiene la declaraci�n de un componente de BT\");\n\t\tp.println();\n\t\tp.println(\" @author Fichero generado autom�ticamente con JBT Editor\");\n\t\t\n\t\tp.println(\"*/\");\n\t\t\n\t\tp.println(\"#ifndef OIM_\"+BTName+\"_H\");\n\t\tp.println(\"#define OIM_\"+BTName+\"_H\");\n\t\tp.println();\n\t\tp.println(\"#include \\\"BTComponent.h\\\"\");\n\t\tp.println();\n\t\tp.println(\"#include <vector>\");\n\t\tp.println();\n\t\tp.println(\"namespace OIM {\");\n\t\t\n\t\tp.println(\"/**\");\n\t\tp.println(\"\\tComponente de IA de una entidad que funciona utilizando\");\n\t\tp.println(\"\\tun �rbol de comportamiento concreto de prueba.\");\n\t\tp.println(\"\\t<p>\");\n\t\tp.println(\"\\tEl componente simplemente hereda de CBTComponent y\");\n\t\tp.println(\"\\tredefine el m�todo factor�a para la creaci�n del\");\n\t\tp.println(\"\\t�rbol de comportamiento a utilizar.\");\n\t\tp.println(\"\\t@author Marco Antonio G�mez Mart�n\");\n\t\tp.println(\"\\t@date \"+currentYear);\n\t\tp.println(\"*/\");\n\t\t\n\t\tp.println(\"\\tclass C\"+BTName+\" : public CBTComponent {\");\n\t\tp.println(\"\\t\\tDEC_FACTORIA(C\"+BTName+\");\");\n\t\tp.println(\"\\t\\tDECL_TYPE();\");\n\t\tp.println(\"\\tprotected:\");\n\t\tp.println(\"\\t\\t/**\");\n\t\tp.println(\"\\t\\t M�todo factor�a que crea el �rbol de comportamiento\");\n\t\tp.println(\"\\t\\t utilizado por la entidad que contiene el componente.\");\n\t\tp.println(\"\\t\\t <p>\");\n\t\tp.println(\"\\t\\t En este caso, crea un BT para probar las acciones.\");\n\t\tp.println(\"\\t\\t @return �rbol de comportamiento a ejecutar por la entidad\");\n\t\tp.println(\"\\t\\t  a la que pertenece el componente.\");\n\t\tp.println(\"\\t\\t */\");\n\t\tp.println(\"\\t\\tvirtual alive::Node *createBehaviourTree();\");\n\t\tp.println(\"\\t};\");\n\t\tp.println();\n\t\tp.println(\"} // namespace OIM\");\n\t\tp.println();\n\t\tp.println(\"#endif // OIM_BTComponent_H\");\n\t}\n\n\t/**\n\t * Creates the method calls of a {@link BTNode}.\n\t */\n\tprivate static void processNode(BTNode node, PrintStream p, String margin) {\n\t\t\n\t\tString nodeType = node.getConceptualNode().getType();\n\t\tNodeCategories category = NodesLoader.getCategoryOf(nodeType);\n\t\tString endToken = margin+\".end()\\n\";\n\t\t\n\t\tswitch(category)\n\t\t{\n\t\t\tcase COMPOSITE:\n\t\t\t\t\n\t\t\t\tp.println(margin+\".composite<alive::\"+nodeType+\">()\");\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\tcase DECORATOR:\n\t\t\t\t\n\t\t\t\tp.println(margin+\".decorator<\"+nodeType+\">()\");\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\tcase LEAF:\n\t\t\t\t\n\t\t\t\tp.println(margin+\".execute<\"+nodeType+\">()\");\n\t\t\t\tbreak;\n\t\t}\n\t\t\n\t\t/* Process guard. */\n\t\t//if (node.getGuard() != null) {\n\t\t//\tElement guardElement = new Element(\"Guard\");\n\t\t//\tguardElement.setContent(processNode(node.getGuard(), p));\n\t\t//\tresult.addContent(guardElement);\n\t\t//}\n\n\t\t/* Process parameters. */\n\t\tif (node.getConceptualNode().getParameters().size() != 0) {\n\t\t\tprocessParameters(node, p, margin+\"\\t\");\n\t\t}\n\t\t\n\t\t/* Process children. */\n\t\tif (node.getNumChildren() != 0) {\n\t\t\tElement children = new Element(\"Children\");\n\t\t\tfor (BTNode child : node.getChildren()) {\n\t\t\t\tprocessNode(child, p, margin+\"\\t\");\n\t\t\t}\n\t\t}\n\t\tif (!(node.getConceptualNode().getType().equals(NodeInternalType.ROOT.toString()))) {\n\t\t\tp.print(endToken);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tp.print(margin+\";\");\n\t\t}\n\t}\n\n\t/**\n\t * Creates the method calls associated to all the parameters of a {@link BTNode}.\n\t */\n\tprivate static void processParameters(BTNode node, PrintStream p, String margin) {\n\t\t\n\t\tfor (int i=0; i<node.getParameters().size();++i)\n\t\t{\n\t\t\tParameter par = node.getParameters().get(i);\n\t\t\tParameterType type = node.getConceptualNode().getParameters().get(i).getType();\n\t\t\tString textToWrite = \"\";\n\t\t\t\n\t\t\tVarParameter varParameter = null;\n\t\t\t\n\t\t\tif (ParameterType.isVariable(type))\n\t\t\t{\n\t\t\t\tvarParameter = (VarParameter)par;\n\t\t\t}\n\t\t\t\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t    case VARIABLE_INT:\n\t\t\t    \t\n\t\t\t    \tif (!varParameter.getIsConstant())\n\t\t\t    \t\ttextToWrite = \"IntParam\"+\"(\\\"\"+varParameter.getVariableName()+\"\\\", \"+varParameter.getValue()+\")\";\n\t\t\t    \telse\n\t\t\t    \t\ttextToWrite = \"\"+varParameter.getValue()+\"\";\n\t\t\t    \tbreak;\n\t\t\t    \t\n\t\t\t    case VARIABLE_FLOAT:\n\t\t\t    \t\n\t\t\t    \tif (!varParameter.getIsConstant())\n\t\t\t    \t\ttextToWrite = \"FloatParam\"+\"(\\\"\"+varParameter.getVariableName()+\"\\\", \"+Float.parseFloat(varParameter.getValue())+\"f)\";\n\t\t\t    \telse\n\t\t\t    \t\ttextToWrite = \"\"+Float.parseFloat(varParameter.getValue())+\"f\";\n\t\t\t    \t\t\n\t\t\t    \tbreak;\n\t\t\t    \t\t\n\t\t\t    case VARIABLE_STRING:\n\t\t\t    \t\n\t\t\t    \tif (!varParameter.getIsConstant())\n\t\t\t    \t\ttextToWrite = \"StringParam\"+\"(\\\"\"+varParameter.getVariableName()+\"\\\", \\\"\"+varParameter.getValue()+\"\\\")\";\n\t\t\t    \telse\n\t\t\t    \t\ttextToWrite = \"\\\"\"+varParameter.getValue()+\"\\\"\";\n\t\t\t\n\t\t\t    \tbreak;\n\t\t\t    \t\n\t\t\t\tcase BOOLEAN:\n\t\t\t\tcase INTEGER:\n\t\t\t\t\ttextToWrite = par.getValue();\n\t\t\t\t\tbreak;\n\t\t\t\tcase REAL:\n\t\t\t\t\ttextToWrite = Float.parseFloat(par.getValue())+\"f\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase STRING:\n\t\t\t\t\ttextToWrite = \"\\\"\"+par.getValue()+\"\\\"\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tp.println(margin+\"\\t.\"+par.getName()+\"(\"+textToWrite+\")\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/BTXMLManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport java.io.FileInputStream;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\n\nimport jbt.tools.bteditor.model.BT;\nimport jbt.tools.bteditor.model.BTNode;\nimport jbt.tools.bteditor.model.BTNode.VarParameter;\nimport jbt.tools.bteditor.model.ConceptualBTNode;\nimport jbt.tools.bteditor.model.BTNode.Identifier;\nimport jbt.tools.bteditor.model.BTNode.Parameter;\nimport jbt.tools.bteditor.model.ConceptualBTNode.NodeInternalType;\nimport jbt.tools.bteditor.model.ConceptualBTNode.ParameterType;\n\nimport org.jdom.Document;\nimport org.jdom.Element;\nimport org.jdom.input.SAXBuilder;\nimport org.jdom.output.Format;\nimport org.jdom.output.XMLOutputter;\n\n/**\n * Class used to export and load behaviour trees into/from XML files.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTXMLManager {\n\t/**\n\t * Exports a {@link BT} into an XML file.\n\t */\n\tpublic static void export(BT tree, String fileName) throws IOException {\n\t\tFileOutputStream file = new FileOutputStream(fileName);\n\t\texport(tree, file);\n\t\tfile.close();\n\t}\n\n\t/**\n\t * Exports a {@link BT} into an XML file.\n\t */\n\tpublic static void export(BT tree, FileOutputStream file) throws IOException {\n\t\tDocument doc = createDocument(tree);\n\t\tXMLOutputter outputter = new XMLOutputter();\n\t\tFormat format = Format.getPrettyFormat();\n\t\toutputter.setFormat(format);\n\t\toutputter.output(doc, file);\n\t\tfile.close();\n\t}\n\n\t/**\n\t * Loads a {@link BT} from an XML file with the output format of\n\t * {@link #export(BT, FileOutputStream)} or {@link #export(BT, String)}.\n\t */\n\tpublic static BT load(String fileName) throws IOException {\n\t\tFileInputStream file = new FileInputStream(fileName);\n\t\tBT loadedTree = load(file);\n\t\tloadedTree.reassignUnderlyingBT(loadedTree.getRoot());\n\t\tfile.close();\n\t\treturn loadedTree;\n\t}\n\n\t/**\n\t * Loads a {@link BT} from an XML file with the output format of\n\t * {@link #export(BT, FileOutputStream)} or {@link #export(BT, String)}.\n\t */\n\tpublic static BT load(FileInputStream file) throws IOException {\n\t\tSAXBuilder builder = new SAXBuilder();\n\t\ttry {\n\t\t\tDocument doc = builder.build(file);\n\t\t\treturn loadTree(doc);\n\t\t} catch (Exception e) {\n\t\t\tthrow new IOException(e.getMessage(), e);\n\t\t}\n\t}\n\n\t/**\n\t * Loads a {@link BT} from a {@link Document} containing the BT in the\n\t * format of {@link #export(BT, FileOutputStream)} or\n\t * {@link #export(BT, FileOutputStream)}.\n\t */\n\tprivate static BT loadTree(Document doc) throws IOException {\n\t\treturn new BT(loadNode(doc.getRootElement().getChild(\"Node\")));\n\t}\n\n\t/**\n\t * Loads a BTNode from a {@link Element} containing the node in the format\n\t * of {@link #export(BT, FileOutputStream)} or {@link #export(BT, String)} .\n\t */\n\tprivate static BTNode loadNode(Element e) throws IOException {\n\t\tBTNode result = new BTNode(null);\n\n\t\t/*\n\t\t * First of all, create the conceptual node associated to this BTNode.\n\t\t * If it cannot be found in the BT library, the load fails.\n\t\t */\n\t\tConceptualBTNode xmlModel = NodesLoader.getNode(e.getAttributeValue(\"type\"),\n\t\t\t\te.getAttributeValue(\"name\"));\n\t\tif (xmlModel == null) {\n\t\t\tthrow new IOException(\n\t\t\t\t\t\"Could not find type \"\n\t\t\t\t\t\t\t+ e.getAttributeValue(\"type\")\n\t\t\t\t\t\t\t+ (e.getAttributeValue(\"name\") == null ? \"\" : \"-\"\n\t\t\t\t\t\t\t\t\t+ e.getAttributeValue(\"name\")) + \". Tree not loaded.\");\n\t\t}\n\t\tresult.setConceptualNode(xmlModel);\n\n\t\t/* Set ID. */\n\t\tresult.setID(new Identifier(e.getAttributeValue(\"id\")));\n\n\t\t/* Set name (just for the root node) */\n\t\tif (result.getConceptualNode().getType().equals(NodeInternalType.ROOT.toString())) {\n\t\t\tString name = e.getAttributeValue(\"name\");\n\t\t\tif (name != null) {\n\t\t\t\tresult.setName(name);\n\t\t\t}\n\t\t}\n\n\t\t/* Set parameters. */\n\t\tElement parameters = e.getChild(\"Parameters\");\n\n\t\tif (parameters != null) {\n\t\t\tint i = 0;\n\t\t\tfor (Object parameter : parameters.getChildren(\"Parameter\")) {\n\t\t\t\tElement p = (Element) parameter;\n\n\t\t\t\tParameter actualParameter = new Parameter();\n\t\t\t\tactualParameter.setName(p.getAttributeValue(\"name\"));\n\t\t\t\tString fromContextString = p.getAttributeValue(\"fromcontext\");\n\n\t\t\t\tboolean fromContext;\n\t\t\t\tif (fromContextString.equals(\"true\")) {\n\t\t\t\t\tfromContext = true;\n\t\t\t\t} else if (fromContextString.equals(\"false\")) {\n\t\t\t\t\tfromContext = false;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new IOException(\"Unexpected \\\"fromcontext\\\" value: \" + fromContextString);\n\t\t\t\t}\n\n\t\t\t\tactualParameter.setFromContext(fromContext);\n\t\t\t\t\n\t\t\t\tConceptualBTNode.Parameter par = xmlModel.getParameters().get(i);\n\t\t\t\t\n\t\t\t\tif (ParameterType.isVariable(par.getType()))\n\t\t\t\t{\n\t\t\t\t\tVarParameter varParameterResult = new VarParameter (actualParameter);\n\t\t\t\t\tboolean isConstant = p.getAttributeValue(\"isConstant\").equals(\"true\") ? true : false;\n\t\t\t\t\tvarParameterResult.setIsConstant(isConstant);\n\n\t\t\t\t\tif (!isConstant)\n\t\t\t\t\t\tvarParameterResult.setVariableName(p.getAttributeValue(\"variableName\"));\n\t\t\t\t\telse\n\t\t\t\t\t\tvarParameterResult.setVariableName(\"\");\n\n\t\t\t\t\tvarParameterResult.setValue(p.getText());\n\t\t\t\t\tresult.addParameter(varParameterResult);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tactualParameter.setValue(p.getText());\n\t\t\t\t\tresult.addParameter(actualParameter);\n\t\t\t\t}\n\t\t\t\t++i;\n\t\t\t}\n\t\t}\n\n\t\t/* Recursively set the children. */\n\t\tElement children = e.getChild(\"Children\");\n\n\t\tif (children != null) {\n\t\t\tfor (Object child : children.getChildren(\"Node\")) {\n\t\t\t\tBTNode btChild = loadNode((Element) child);\n\t\t\t\tbtChild.setParent(result);\n\t\t\t\tresult.addChild(btChild);\n\t\t\t}\n\t\t}\n\n\t\t/* Set the guard. */\n\t\tElement guard = e.getChild(\"Guard\");\n\n\t\tif (guard != null) {\n\t\t\tresult.setGuard(loadNode((Element) guard.getChildren().get(0)));\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Creates a {@link Document} from a {@link BT}. This is used for exporting\n\t * the BT into XML.\n\t */\n\tprivate static Document createDocument(BT tree) {\n\t\tDocument document = new Document();\n\n\t\tElement rootElement = new Element(\"Tree\");\n\n\t\trootElement.addContent(processNode(tree.getRoot()));\n\n\t\tdocument.setRootElement(rootElement);\n\n\t\treturn document;\n\t}\n\n\t/**\n\t * Creates an {@link Element} from a {@link BTNode}.\n\t */\n\tprivate static Element processNode(BTNode node) {\n\t\tElement result = new Element(\"Node\");\n\t\tresult.setAttribute(\"id\", node.getID().toString());\n\n\t\tif (node.getConceptualNode().getHasName()) {\n\t\t\tif (node.getConceptualNode().getType().equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\tresult.setAttribute(\"name\", node.getName());\n\t\t\t} else {\n\t\t\t\tresult.setAttribute(\"name\", node.getConceptualNode().getName());\n\t\t\t}\n\t\t}\n\n\t\tresult.setAttribute(\"type\", node.getConceptualNode().getType());\n\n\t\t/* Process guard. */\n\t\tif (node.getGuard() != null) {\n\t\t\tElement guardElement = new Element(\"Guard\");\n\t\t\tguardElement.setContent(processNode(node.getGuard()));\n\t\t\tresult.addContent(guardElement);\n\t\t}\n\n\t\t/* Process parameters. */\n\t\tif (node.getConceptualNode().getParameters().size() != 0) {\n\t\t\tresult.addContent(processParameters(node));\n\t\t}\n\n\t\t/* Process children. */\n\t\tif (node.getNumChildren() != 0) {\n\t\t\tElement children = new Element(\"Children\");\n\t\t\tfor (BTNode child : node.getChildren()) {\n\t\t\t\tchildren.addContent(processNode(child));\n\t\t\t}\n\t\t\tresult.addContent(children);\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\t/**\n\t * Creates an {@link Element} containing all the parameters of a\n\t * {@link BTNode}.\n\t */\n\tprivate static Element processParameters(BTNode node) {\n\t\tElement result = new Element(\"Parameters\");\n\t\tint i = 0;\n\n\t\tfor (Parameter p : node.getParameters()) {\n\t\t\t\n\t\t\tElement currentParam = new Element(\"Parameter\");\n\t\t\tcurrentParam.setAttribute(\"name\", p.getName());\n\t\t\tcurrentParam.setText(p.getValue());\n\t\t\tcurrentParam.setAttribute(\"fromcontext\", p.getFromContext() ? \"true\" : \"false\");\n\t\t\t\n\t\t\tConceptualBTNode.Parameter aux = node.getConceptualNode().getParameters().get(i);\n\t\t\tif (ParameterType.isVariable(aux.getType()))\n\t\t\t{\n\t\t\t\tVarParameter varParameter = (VarParameter)p;\n\t\t\t\t\n\t\t\t\tboolean isConstant = varParameter.getIsConstant();\n\t\t\t\tcurrentParam.setAttribute(\"isConstant\", isConstant ? \"true\" : \"false\");\n\t\t\t\t\n\t\t\t\tif (!isConstant)\n\t\t\t\t{\n\t\t\t\t\tcurrentParam.setAttribute(\"variableName\", varParameter.getVariableName());\n\t\t\t\t} \n\t\t\t}\n\t\t\tcurrentParam.setText(p.getValue());\n\n\t\t\tresult.addContent(currentParam);\n\t\t\t\n\t\t\t++i;\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/DisableNewEditorHandler.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\n\n/**\n * Handler for disabling the \"New Editor\" standard action of editors' context\n * menu.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class DisableNewEditorHandler extends AbstractHandler {\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\treturn null;\n\t}\n\n\tpublic boolean isEnabled() {\n\t\t/*\n\t\t * By doing this, the element \"New Editor\" in the context menu is\n\t\t * disabled.\n\t\t */\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/NodesLoader.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport gatech.mmpm.ActionParameterType;\nimport gatech.mmpm.tools.parseddomain.ParsedAction;\nimport gatech.mmpm.tools.parseddomain.ParsedActionParameter;\nimport gatech.mmpm.tools.parseddomain.ParsedDomain;\nimport gatech.mmpm.tools.parseddomain.ParsedMethod;\n\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.IOException;\nimport java.net.URL;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.Hashtable;\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.model.ConceptualBTNode;\nimport jbt.tools.bteditor.model.ConceptualBTNode.NodeInternalType;\nimport jbt.tools.bteditor.model.ConceptualBTNode.Parameter;\nimport jbt.tools.bteditor.model.ConceptualBTNode.ParameterType;\nimport jbt.tools.bteditor.model.ConceptualNodesTree;\nimport jbt.tools.bteditor.model.ConceptualNodesTree.ConceptualBTNodeItem;\nimport jbt.tools.bteditor.util.IconsPaths;\nimport jbt.tools.bteditor.util.Pair;\n\nimport org.eclipse.core.runtime.FileLocator;\nimport org.eclipse.core.runtime.Path;\nimport org.jdom.Document;\nimport org.jdom.Element;\nimport org.jdom.input.SAXBuilder;\n\n/**\n * NodesLoader is in charge of loading nodes that can be used by the application\n * when building behaviour trees.\n * <p>\n * There are two types of nodes:\n * <ul>\n * <li>Standard nodes: these are internal to the application, that is, the\n * application knows of them in advance. These are nodes such as Parallel,\n * Sequence, or Wait.\n * <li>Non-standard nodes: these nodes are specified by external clients in MMPM\n * domain files. These are low level nodes in a BT, that is, actions and\n * conditions. Actions are obtained from the action set of the MMPM domain file,\n * and conditions are obtained from the sensor set of the MMPM domain file.\n * </ul>\n * \n * Standard nodes are defined in a XML file located at\n * {@link #STANDARD_NODES_FILE}. That file specifies the XML format of the\n * standard nodes. Standard nodes are loaded into the application at star-up\n * time. In fact, if they are not properly loaded, the application does not\n * start.\n * <p>\n * Non-standard nodes are loaded from MMPM domain files. Only actions and\n * sensors are read from the MMPM file. Actions are transformed into nodes of\n * type {@link NodeInternalType#ACTION}, and sensors are transformed into nodes\n * of type {@link NodeInternalType#CONDITION}. These are the nodes upon which\n * external users build domain dependent behaviour trees.\n * <p>\n * Standard and non-standard nodes become {@link ConceptualBTNode}s when they\n * are loaded so that they can be easily used in the application.\n * <p>\n * NodesLoader stores both standard and non-standard nodes into\n * {@link ConceptualNodesTree}s in order to organize them in categories.\n * <p>\n * {@link #loadStandardNodes()} loads all the standard nodes specified in the\n * file {@link #STANDARD_NODES_FILE} and creates a ConceptualNodesTree for them.\n * Also, the list of standard nodes contains a special node that is not defined\n * in the file, the root node, which is statically created and included in the\n * list.\n * <p>\n * {@link #loadNonStandardNodes(String)} loads all the actions and sensors\n * (conditions) from a MMPM domain file, and creates a ConceptualNodesTree whose\n * root category is the short name of the file. The root category contains two\n * sub categories, one for actions (which includes all the actions loaded from\n * the file), and another one for conditions (which contains all the boolean\n * sensors loaded form the file).\n * <p>\n * The NodesLoader class can also be used for retrieving nodes by type.\n * \n * @author Ricardo Juan Palma Durán\n * \n * Modified by Fernando Matarrubia\n * \n * The main purpose of the modification is to add the functionality\n * of register all the standard nodes paired with their category in a hashtable \n * When the c++ file is written, that info would be needed in order to \n * separate the different node types by their category\n */\npublic class NodesLoader {\n\t\n\t/** ConceptualNodesTree for standard nodes. */\n\tprivate static ConceptualNodesTree standardNodesTree = new ConceptualNodesTree();\n\t\n\t/** Standard nodes. They are indexed by type. */\n\tprivate static Hashtable<String, ConceptualBTNode> standardNodes = new Hashtable<String, ConceptualBTNode>();\n\t\n\t/** All nodes sorted by their category */\n\tprivate static Hashtable<String, String> nodesByCategory = new Hashtable<String, String>();\n\t/**\n\t * ConceptualNodesTrees for non standard nodes. They are indexed by the name\n\t * of the file from which they are loaded.\n\t */\n\tprivate static Hashtable<String, ConceptualNodesTree> nonStandardTrees = new Hashtable<String, ConceptualNodesTree>();\n\t/**\n\t * Non-standard nodes. They are indexed both by type and name (the type is\n\t * the first element in the Pair, and the name is the second one).\n\t */\n\tprivate static Hashtable<Pair<String, String>, ConceptualBTNode> nonStandardNodes = new Hashtable<Pair<String, String>, ConceptualBTNode>();\n\n\t/** The file that contains the definition of all standard nodes. */\n\tpublic static final String STANDARD_NODES_FILE = \"files/standardNodes.xml\";\n\t\n\t/** Public enum that contains the different node categories */\n\tpublic enum NodeCategories\n\t{\n\t\tCOMPOSITE,\tDECORATOR, LEAF, DUMMY\n\t};\n\n\t/**\n\t * Loads all the standard nodes defined in the file\n\t * {@link #STANDARD_NODES_FILE}. After doing so, standard nodes can be\n\t * accessed through {@link #getStandardNodes()} and\n\t * {@link #getNode(String, String)}.\n\t * <p>\n\t * Throws an exception if there is any error loading the standard nodes.\n\t */\n\tpublic static void loadStandardNodes() throws IOException {\n\t\tloadRoot();\n\n\t\tURL url = FileLocator.find(Activator.getDefault().getBundle(),\n\t\t\t\tnew Path(STANDARD_NODES_FILE), Collections.EMPTY_MAP);\n\n\t\tURL fileUrl = null;\n\t\tfileUrl = FileLocator.toFileURL(url);\n\t\tFileInputStream file = new FileInputStream(fileUrl.getPath());\n\n\t\tparseStandardNodesFile(file);\n\t}\n\n\t/**\n\t * Loads the actions and sensors from a MMPM domain file. Creates a new\n\t * ConceptualNodesTree whose root category is the short name of the file.\n\t * The root category contains two sub categories, one for actions (which\n\t * includes all the actions loaded from the file), and another one for\n\t * conditions (which contains all the boolean sensors loaded form the file).\n\t * The tree can be accessed through {@link #getNonStandardNodesTree(String)}\n\t * , and its nodes can be accessed through {@link #getNode(String, String)}.\n\t */\n\tpublic static ConceptualNodesTree loadNonStandardNodes(String fileName) throws IOException {\n\t\tFileInputStream fileStream = new FileInputStream(fileName);\n\t\tSAXBuilder builder = new SAXBuilder();\n\t\tConceptualNodesTree tree = new ConceptualNodesTree();\n\t\tFile file = new File(fileName);\n\n\t\ttry {\n\t\t\tDocument doc = builder.build(fileStream);\n\n\t\t\tParsedDomain parsedDomain = new ParsedDomain();\n\t\t\tparsedDomain.init(doc.getRootElement(), null);\n\n\t\t\tList<ParsedAction> actions = parsedDomain.getActionSet().getAction();\n\n\t\t\tList<ParsedMethod> conditions = parsedDomain.getSensorSet().getMethods();\n\n\t\t\tfor (ParsedAction action : actions) {\n\t\t\t\tConceptualBTNode xmlAction = loadNonStandardAction(action);\n\t\t\t\tnonStandardNodes.put(\n\t\t\t\t\t\tnew Pair<String, String>(xmlAction.getType(), action.getName()), xmlAction);\n\t\t\t\ttree.insertNode(\n\t\t\t\t\t\tfile.getName() + ConceptualNodesTree.CATEGORY_SEPARATOR + \"Actions\",\n\t\t\t\t\t\tnew ConceptualBTNodeItem(xmlAction));\n\t\t\t}\n\n\t\t\tfor (ParsedMethod condition : conditions) {\n\t\t\t\tif (condition.getReturnedType() == ActionParameterType.BOOLEAN) {\n\t\t\t\t\tConceptualBTNode xmlCondition = loadNonStandardCondition(condition);\n\t\t\t\t\tnonStandardNodes.put(\n\t\t\t\t\t\t\tnew Pair<String, String>(xmlCondition.getType(), condition.getName()),\n\t\t\t\t\t\t\txmlCondition);\n\t\t\t\t\ttree.insertNode(file.getName() + ConceptualNodesTree.CATEGORY_SEPARATOR\n\t\t\t\t\t\t\t+ \"Conditions\", new ConceptualBTNodeItem(xmlCondition));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnonStandardTrees.put(fileName, tree);\n\t\t\treturn tree;\n\t\t} catch (Exception e) {\n\t\t\tthrow new IOException(e.getMessage(), e);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the standard nodes tree or null if it has not been loaded yet\n\t * (see {@link #loadStandardNodes()}).\n\t */\n\tpublic static ConceptualNodesTree getStandardNodesTree() {\n\t\treturn standardNodesTree;\n\t}\n\n\t/**\n\t * Returns the non-standard nodes tree that was loaded from the file whose\n\t * name is <code>fileName</code>. Returns null if that tree cannot be found.\n\t */\n\tpublic static ConceptualNodesTree getNonStandardNodesTree(String fileName) {\n\t\treturn nonStandardTrees.get(fileName);\n\t}\n\n\t/**\n\t * Returns all the non-standard nodes trees currently loaded by the\n\t * NodesLoader.\n\t */\n\tpublic static List<ConceptualNodesTree> getNonStandardNodesTrees() {\n\t\treturn Arrays.asList(nonStandardTrees.values().toArray(\n\t\t\t\tnew ConceptualNodesTree[nonStandardTrees.size()]));\n\t}\n\n\t/**\n\t * Removes the non-standard nodes tree that was loaded from the file\n\t * <code>fileName</code> from the list held by the NodesLoader.\n\t */\n\tpublic static void removeNonStandardNodesTree(String fileName) {\n\t\tnonStandardTrees.remove(fileName);\n\t}\n\n\t/**\n\t * Returns all the file names of the non-standard nodes trees held by the\n\t * NodesLoader.\n\t */\n\tpublic static String[] getNonStandardTreeNames() {\n\t\treturn nonStandardTrees.keySet().toArray(new String[nonStandardTrees.size()]);\n\t}\n\n\t/**\n\t * Returns a List with all the standard nodes.\n\t */\n\tpublic static List<ConceptualBTNode> getStandardNodes() {\n\t\treturn new Vector<ConceptualBTNode>(standardNodes.values());\n\t}\n\n\t/**\n\t * Returns a List with all the non-standard nodes.\n\t */\n\tpublic static List<ConceptualBTNode> getNonStandardNodes() {\n\t\treturn new Vector<ConceptualBTNode>(nonStandardNodes.values());\n\t}\n\n\t/**\n\t * Retrieves a node from all the nodes held by the NodesLoader. For standard\n\t * nodes this retrieval process is done through the type ( <code>type</code>\n\t * ) only, in which case <code>name</code> is ignored.\n\t * <p>\n\t * For non-standard nodes, (actions and conditions), the retrieval process\n\t * is carried out by using both the type of the node and its name. This is\n\t * necessary since all actions share the same type (\n\t * {@link NodeInternalType#ACTION}), and so do conditions (\n\t * {@link NodeInternalType#CONDITION}), so the only way of telling them\n\t * apart is by using their name.\n\t */\n\tpublic static ConceptualBTNode getNode(String type, String name) {\n\t\tif (type.equals(NodeInternalType.ACTION.toString())\n\t\t\t\t|| type.equals(NodeInternalType.CONDITION.toString())) {\n\t\t\treturn nonStandardNodes.get(new Pair<String, String>(type, name));\n\t\t} else {\n\t\t\treturn standardNodes.get(type);\n\t\t}\n\t}\n\n\tprivate static ConceptualBTNode loadNonStandardCondition(ParsedMethod condition) {\n\t\tConceptualBTNode xmlNode = new ConceptualBTNode();\n\n\t\txmlNode.setReadableType(condition.getName());\n\t\txmlNode.setType(NodeInternalType.CONDITION.toString());\n\t\txmlNode.setIcon(IconsPaths.CONDITION);\n\t\txmlNode.setNumChildren(0);\n\t\txmlNode.setHasName(true);\n\t\txmlNode.setName(condition.getName());\n\n\t\tList<ParsedActionParameter> parameters = condition.getParameters();\n\n\t\tfor (ParsedActionParameter parameter : parameters) {\n\t\t\tParameter xmlNodeParameter = new Parameter();\n\t\t\txmlNodeParameter.setName(parameter.getName());\n\t\t\txmlNodeParameter.setType(fromMMPMParameterType(parameter.getType()));\n\t\t\t/* MMPM parameters are always contextable. */\n\t\t\txmlNodeParameter.setContextable(true);\n\t\t\txmlNode.addParameter(xmlNodeParameter);\n\t\t}\n\n\t\treturn xmlNode;\n\t}\n\n\tprivate static ConceptualBTNode loadNonStandardAction(ParsedAction action) {\n\t\tConceptualBTNode xmlNode = new ConceptualBTNode();\n\n\t\txmlNode.setReadableType(action.getName());\n\t\txmlNode.setType(NodeInternalType.ACTION.toString());\n\t\txmlNode.setIcon(IconsPaths.ACTION);\n\t\txmlNode.setNumChildren(0);\n\t\txmlNode.setHasName(true);\n\t\txmlNode.setName(action.getName());\n\n\t\tList<ParsedActionParameter> parameters = action.getParameters();\n\n\t\tfor (ParsedActionParameter parameter : parameters) {\n\t\t\tParameter xmlNodeParameter = new Parameter();\n\t\t\txmlNodeParameter.setName(parameter.getName());\n\t\t\txmlNodeParameter.setType(fromMMPMParameterType(parameter.getType()));\n\t\t\t/* MMPM parameters are always contextable. */\n\t\t\txmlNodeParameter.setContextable(true);\n\t\t\txmlNode.addParameter(xmlNodeParameter);\n\t\t}\n\n\t\treturn xmlNode;\n\t}\n\n\tprivate static ParameterType fromMMPMParameterType(ActionParameterType type) {\n\t\tif (type == ActionParameterType.BOOLEAN) {\n\t\t\treturn ParameterType.BOOLEAN;\n\t\t} else if (type == ActionParameterType.ENTITY_ID) {\n\t\t\treturn ParameterType.STRING;\n\t\t} else if (type == ActionParameterType.ENTITY_TYPE) {\n\t\t\treturn ParameterType.STRING;\n\t\t} else if (type == ActionParameterType.FLOAT) {\n\t\t\treturn ParameterType.REAL;\n\t\t} else if (type == ActionParameterType.INTEGER) {\n\t\t\treturn ParameterType.INTEGER;\n\t\t} else if (type == ActionParameterType.STRING) {\n\t\t\treturn ParameterType.STRING;\n\t\t} else if (type == ActionParameterType.PLAYER) {\n\t\t\treturn ParameterType.STRING;\n\t\t} else if (type == ActionParameterType.COORDINATE) {\n\t\t\treturn ParameterType.COORDINATE;\n\t\t} else if (type == ActionParameterType.DIRECTION) {\n\t\t\treturn ParameterType.DIRECTION;\n\t\t} else if (type == ActionParameterType.OBJECT) {\n\t\t\treturn ParameterType.OBJECT;\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\"Unexpected action parameter type\");\n\t}\n\n\tprivate static List<Exception> parseStandardNodesFile(FileInputStream file) {\n\t\tList<Exception> exceptions = new Vector<Exception>();\n\n\t\tSAXBuilder builder = new SAXBuilder();\n\t\ttry {\n\t\t\tDocument doc = builder.build(file);\n\n\t\t\tElement root = doc.getRootElement();\n\n\t\t\tparseElement(null, root);\n\t\t} catch (Exception e) {\n\t\t\texceptions.add(e);\n\t\t}\n\n\t\treturn exceptions;\n\t}\n\n\tprivate static void parseElement(String currentPath, Element e) {\n\t\tString nodeType = e.getName();\n\n\t\tif (nodeType.equals(\"Category\")) {\n\t\t\tString categoryName = e.getAttributeValue(\"name\");\n\t\t\tList<Element> children = e.getChildren();\n\n\t\t\tfor (Element child : children) {\n\t\t\t\tString nextPath = currentPath == null ? categoryName : currentPath\n\t\t\t\t\t\t+ ConceptualNodesTree.CATEGORY_SEPARATOR + categoryName;\n\t\t\t\tparseElement(nextPath, child);\n\t\t\t}\n\t\t} else if (nodeType.equals(\"Node\")) {\n\t\t\tConceptualBTNode xmlNode = new ConceptualBTNode();\n\t\t\txmlNode.setType(e.getChild(\"Type\").getValue());\n\t\t\tString numChildren = e.getChild(\"Children\").getValue();\n\t\t\txmlNode.setNumChildren(numChildren.equals(\"I\") ? -1 : Integer.parseInt(numChildren));\n\t\t\txmlNode.setIcon(e.getChild(\"Icon\").getValue());\n\t\t\txmlNode.setReadableType(e.getChild(\"ReadableType\").getValue());\n\t\t\txmlNode.setHasName(false);\n\t\t\tparseParameters(xmlNode, e);\n\t\t\t\n\t\t\tConceptualBTNodeItem nodeToInsert = new ConceptualBTNodeItem(xmlNode);\n\t\t\tstandardNodesTree.insertNode(currentPath, nodeToInsert);\n\t\t\tstandardNodes.put(xmlNode.getType(), xmlNode);\n\t\t\tnodesByCategory.put(xmlNode.getType(), currentPath);\n\t\t}\n\t}\n\t\n\tpublic static NodeCategories getCategoryOf(String type)\n\t{\n\t\tif (nodesByCategory.containsKey(type))\n\t\t{\n\t\t\tString category = nodesByCategory.get(type);\n\t\t\tString parentType = category.split(ConceptualNodesTree.CATEGORY_SEPARATOR)[1];\n\t\t\t\n\t\t\tif (parentType.contentEquals(\"Composite\"))\n\t\t\t{\n\t\t\t\treturn NodeCategories.COMPOSITE;\n\t\t\t}\n\t\t\telse if (parentType.contentEquals(\"Decorator\"))\n\t\t\t{\n\t\t\t\treturn NodeCategories.DECORATOR;\n\t\t\t}\n\t\t\telse if (parentType.contentEquals(\"Leaf\"))\n\t\t\t{\n\t\t\t\treturn NodeCategories.LEAF;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn NodeCategories.DUMMY;\n\t}\n\n\tprivate static void parseParameters(ConceptualBTNode node, Element e) {\n\t\tElement paramsElement = e.getChild(\"Parameters\");\n\t\tif (paramsElement != null) {\n\t\t\tList<Element> parameters = paramsElement.getChildren();\n\n\t\t\tfor (Element parameter : parameters) {\n\t\t\t\tparseParameter(node, parameter);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void parseParameter(ConceptualBTNode node, Element e) {\n\t\tParameter parameterToAdd = new Parameter();\n\t\tparameterToAdd.setName(e.getAttributeValue(\"name\"));\n\t\tParameterType type = ParameterType.valueOf(e.getAttributeValue(\"type\"));\n\t\tparameterToAdd.setType(type);\n\n\t\tif (type == ParameterType.NODE_ID) {\n\t\t\tString nodeTypes = e.getAttributeValue(\"nodetypes\");\n\t\t\tnodeTypes = nodeTypes.trim();\n\n\t\t\tif (!nodeTypes.equals(\"\")) {\n\t\t\t\tString[] individualNodeTypes = nodeTypes.split(\"( )+\");\n\n\t\t\t\tfor (String s : individualNodeTypes) {\n\t\t\t\t\tparameterToAdd.addNodeClass(s);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tString contextable = e.getAttributeValue(\"contextable\");\n\n\t\t\tif (contextable.equals(\"true\")) {\n\t\t\t\tparameterToAdd.setContextable(true);\n\t\t\t} else if (contextable.equals(\"false\")) {\n\t\t\t\tparameterToAdd.setContextable(false);\n\t\t\t} else {\n\t\t\t\tthrow new RuntimeException(\"Invalid value for \\\"contextable\\\" attribute\");\n\t\t\t}\n\t\t} \n\t\t\n\t\tnode.addParameter(parameterToAdd);\n\t}\n\n\tprivate static void loadRoot() {\n\t\tConceptualBTNode root = new ConceptualBTNode();\n\t\troot.setIcon(IconsPaths.ROOT);\n\t\troot.setNumChildren(1);\n\t\troot.setType(NodeInternalType.ROOT.toString());\n\t\troot.setReadableType(NodeInternalType.ROOT.toString());\n\t\troot.setHasName(true);\n\n\t\tstandardNodes.put(NodeInternalType.ROOT.toString(), root);\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/Perspective.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor;\n\nimport jbt.tools.bteditor.views.NodeInfo;\nimport jbt.tools.bteditor.views.NodesNavigator;\nimport jbt.tools.bteditor.views.NodesSearcher;\n\nimport org.eclipse.ui.IFolderLayout;\nimport org.eclipse.ui.IPageLayout;\nimport org.eclipse.ui.IPerspectiveFactory;\n\npublic class Perspective implements IPerspectiveFactory {\n\tprivate static final String RIGHT_FOLDER_ID = \"RightFolder\";\n\tprivate static final String BOTTOM_RIGHT_FOLDER_ID = \"BottomRightFolder\";\n\n\tpublic void createInitialLayout(IPageLayout layout) {\n\t\tlayout.setEditorAreaVisible(true);\n\n\t\tlayout.addView(NodesNavigator.ID, IPageLayout.LEFT, 0.3f, layout.getEditorArea());\n\n\t\tIFolderLayout rightFolderLayout = layout.createFolder(RIGHT_FOLDER_ID, IPageLayout.RIGHT,\n\t\t\t\t0.6f, layout.getEditorArea());\n\t\t\n\t\tIFolderLayout bottomRightFolderLayout=layout.createFolder(BOTTOM_RIGHT_FOLDER_ID, IPageLayout.BOTTOM, 0.5f, RIGHT_FOLDER_ID);\n\t\t\n\t\trightFolderLayout.addView(NodeInfo.ID);\n\t\tbottomRightFolderLayout.addView(NodesSearcher.ID);\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/CheckErrorsAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport jbt.tools.bteditor.editor.BTEditor;\n\nimport org.eclipse.jface.action.IAction;\nimport org.eclipse.jface.viewers.ISelection;\n\npublic class CheckErrorsAction extends EditorActionDelegate{\n\tpublic CheckErrorsAction(){\n\t\tsuper();\n\t}\n\t\n\t\n\tpublic void run(IAction action) {\n\t\tBTEditor editor=(BTEditor)this.getEditor();\n\t\teditor.checkTree();\n\t}\n\n\tpublic void selectionChanged(IAction action, ISelection selection) {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/ClearErrorsAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport jbt.tools.bteditor.editor.BTEditor;\n\nimport org.eclipse.jface.action.IAction;\nimport org.eclipse.jface.viewers.ISelection;\n\npublic class ClearErrorsAction extends EditorActionDelegate {\n\tpublic ClearErrorsAction(){\n\t\tsuper();\n\t}\n\t\n\tpublic void run(IAction action) {\n\t\tBTEditor editor = (BTEditor) this.getEditor();\n\t\teditor.clearErrors();\n\t}\n\n\tpublic void selectionChanged(IAction action, ISelection selection) {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/CollapseTreeAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport jbt.tools.bteditor.editor.BTEditor;\n\nimport org.eclipse.jface.action.IAction;\nimport org.eclipse.jface.viewers.ISelection;\n\npublic class CollapseTreeAction extends EditorActionDelegate{\n\tpublic void run(IAction action) {\n\t\t((BTEditor)this.getEditor()).expandTree(false);\n\t}\n\n\tpublic void selectionChanged(IAction action, ISelection selection) {\n\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/DialogExportAsCppAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport java.util.List;\n\nimport jbt.tools.bteditor.Application;\nimport jbt.tools.bteditor.editor.BTEditor;\nimport jbt.tools.bteditor.editor.BTEditorInput;\nimport jbt.tools.bteditor.model.BT;\nimport jbt.tools.bteditor.util.Extensions;\nimport jbt.tools.bteditor.util.IconsPaths;\nimport jbt.tools.bteditor.util.StandardDialogs;\nimport jbt.tools.bteditor.util.Utilities;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.FileDialog;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\n\n/**\n * Action that loads several behaviour trees into the application. It first\n * opens a dialog where the user selects the files that contain the trees. Then,\n * these trees are opened in separate editors.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class DialogExportAsCppAction extends Action implements IWorkbenchAction {\n\tprivate IWorkbenchWindow window;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param window the main window.\n\t */\n\tpublic DialogExportAsCppAction(IWorkbenchWindow window) {\n\t\tthis.window = window;\n\t\tthis.setText(\"Export BT to an inline file\");\n\t\tthis.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, IconsPaths.INL));\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.jface.action.Action#run()\n\t */\n\tpublic void run() {\n\t\t\n\t\tBTEditor myEditor = Utilities.getActiveBTEditor();\t\n\t\tif (myEditor==null || !myEditor.checkTree())\n\t\t{\n\t\t\tStandardDialogs.errorDialog(\"Tree not saved\",\n\t\t\t\t\t\"Errors were detected while validating the tree\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/*\n\t\t\t * Open dialog for asking the user to enter some file names.\n\t\t\t */\n\t\t\tFileDialog dialog = new FileDialog(this.window.getShell(), SWT.SAVE);\n\t\t\tString[] individualFilters = Extensions.getFiltersFromExtensions(Extensions.getInlFileExtensions());\n\t\t\tString[] unifiedFilter = new String[] { Extensions.getUnifiedFilterFromExtensions(Extensions.getInlFileExtensions()) };\n\t\t\tString[] filtersToUse = Extensions.joinArrays(individualFilters, unifiedFilter);\n\t\t\tdialog.setFilterExtensions(filtersToUse);\n\t\t\tdialog.setText(\"Export BT to an inline file\");\n\t\t\t\n\t\t\tString fileName = dialog.open();\n\t\t\t\n\t\t\tif (fileName != null)\n\t\t\t{\n\t\t\t\tList<BTEditor> editors = Utilities.getBTEditors();\n\t\n\t\t\t\tfor (BTEditor editor : editors) {\n\t\t\t\t\tBTEditorInput editorInput = (BTEditorInput) editor.getEditorInput();\n\t\t\t\t\tif (editorInput.isFromFile() && editorInput.getTreeName().equals(fileName)) {\n\t\t\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\t\t\"There is a behaviour tree already open with the same name (\"\n\t\t\t\t\t\t\t\t\t\t+ fileName + \"). Close it first.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\tString targetFileName = Extensions.joinFileNameAndExtension(fileName,\n\t\t\t\t\t\tExtensions.getInlFileExtensions()[dialog.getFilterIndex()]);\n\t\t\t\t\n\t\t\t\tBT tree = Utilities.getActiveBTEditor().getBT();\n\t\t\t\t\n\t\t\t\tnew ExportToCppAction(tree, targetFileName).run();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void dispose() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/DialogLoadMMPMDomainAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport java.io.File;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.Application;\nimport jbt.tools.bteditor.util.Extensions;\nimport jbt.tools.bteditor.util.IconsPaths;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.FileDialog;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\n\n/**\n * Action that loads several MMPM domain files into the application. It first\n * opens a dialog where the user selects the domain files. Then, these domains\n * are loaded into the application.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class DialogLoadMMPMDomainAction extends Action implements\n\t\tIWorkbenchAction {\n\tprivate IWorkbenchWindow window;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param window\n\t *            the main window.\n\t */\n\tpublic DialogLoadMMPMDomainAction(IWorkbenchWindow window) {\n\t\tthis.window = window;\n\t\tthis.setText(\"Load MMPM Domain\");\n\t\tthis.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(\n\t\t\t\tApplication.PLUGIN_ID, IconsPaths.LOAD_MMPM_DOMAIN));\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.jface.action.Action#run()\n\t */\n\tpublic void run() {\n\t\t/*\n\t\t * Open dialog for asking the user to enter some file names.\n\t\t */\n\t\tFileDialog dialog = new FileDialog(this.window.getShell(), SWT.MULTI);\n\t\tString[] individualFilters = Extensions\n\t\t\t\t.getFiltersFromExtensions(Extensions.getMMPMDomainFileExtensions());\n\t\tString[] unifiedFilter = new String[] { Extensions\n\t\t\t\t.getUnifiedFilterFromExtensions(Extensions\n\t\t\t\t\t\t.getMMPMDomainFileExtensions()) };\n\t\tString[] filtersToUse = Extensions.joinArrays(individualFilters,\n\t\t\t\tunifiedFilter);\n\t\tdialog.setFilterExtensions(filtersToUse);\n\t\tdialog.setText(\"Open BT\");\n\n\t\tif (dialog.open() != null) {\n\t\t\t/* Get the name of the files (NOT absolute path). */\n\t\t\tString[] singleNames = dialog.getFileNames();\n\n\t\t\t/*\n\t\t\t * This vector will store the absolute path of every single selected\n\t\t\t * file.\n\t\t\t */\n\t\t\tVector<String> absolutePath = new Vector<String>();\n\n\t\t\tfor (int i = 0, n = singleNames.length; i < n; i++) {\n\t\t\t\tStringBuffer buffer = new StringBuffer(dialog.getFilterPath());\n\t\t\t\tif (buffer.charAt(buffer.length() - 1) != File.separatorChar)\n\t\t\t\t\tbuffer.append(File.separatorChar);\n\t\t\t\tbuffer.append(singleNames[i]);\n\t\t\t\tabsolutePath.add(buffer.toString());\n\t\t\t}\n\n\t\t\tnew LoadMMPMDomainAction(absolutePath).run();\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose()\n\t */\n\tpublic void dispose() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/DialogOpenBTAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport java.io.File;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.Application;\nimport jbt.tools.bteditor.util.Extensions;\nimport jbt.tools.bteditor.util.IconsPaths;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.FileDialog;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\n\n/**\n * Action that loads several behaviour trees into the application. It first\n * opens a dialog where the user selects the files that contain the trees. Then,\n * these trees are opened in separate editors.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class DialogOpenBTAction extends Action implements IWorkbenchAction {\n\tprivate IWorkbenchWindow window;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param window the main window.\n\t */\n\tpublic DialogOpenBTAction(IWorkbenchWindow window) {\n\t\tthis.window = window;\n\t\tthis.setText(\"Open BT\");\n\t\tthis.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(\n\t\t\t\tApplication.PLUGIN_ID, IconsPaths.OPEN_BT));\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.jface.action.Action#run()\n\t */\n\tpublic void run() {\n\t\t/*\n\t\t * Open dialog for asking the user to enter some file names.\n\t\t */\n\t\tFileDialog dialog = new FileDialog(this.window.getShell(), SWT.MULTI);\n\t\tString[] individualFilters = Extensions\n\t\t\t\t.getFiltersFromExtensions(Extensions.getBTFileExtensions());\n\t\tString[] unifiedFilter = new String[] { Extensions\n\t\t\t\t.getUnifiedFilterFromExtensions(Extensions\n\t\t\t\t\t\t.getBTFileExtensions()) };\n\t\tString[] filtersToUse = Extensions.joinArrays(individualFilters,\n\t\t\t\tunifiedFilter);\n\t\tdialog.setFilterExtensions(filtersToUse);\n\t\tdialog.setText(\"Open BT\");\n\n\t\t/*\n\t\t * If the user has selected at least one file name, we must open it.\n\t\t * Note that the user may select several files.\n\t\t */\n\t\tif (dialog.open() != null) {\n\t\t\t/* Get the name of the files (NOT absolute path). */\n\t\t\tString[] singleNames = dialog.getFileNames();\n\n\t\t\t/*\n\t\t\t * This vector will store the absolute path of every single selected\n\t\t\t * file.\n\t\t\t */\n\t\t\tVector<String> absolutePath = new Vector<String>();\n\n\t\t\tfor (int i = 0, n = singleNames.length; i < n; i++) {\n\t\t\t\tStringBuffer buffer = new StringBuffer(dialog.getFilterPath());\n\t\t\t\tif (buffer.charAt(buffer.length() - 1) != File.separatorChar)\n\t\t\t\t\tbuffer.append(File.separatorChar);\n\t\t\t\tbuffer.append(singleNames[i]);\n\t\t\t\tabsolutePath.add(buffer.toString());\n\t\t\t}\n\n\t\t\tnew OpenBTAction(absolutePath).run();\n\t\t}\n\t}\n\n\tpublic void dispose() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/EditorActionDelegate.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport org.eclipse.jface.action.IAction;\nimport org.eclipse.ui.IEditorActionDelegate;\nimport org.eclipse.ui.IEditorPart;\n\npublic abstract class EditorActionDelegate implements IEditorActionDelegate {\n\tprivate IEditorPart editor;\n\tprivate IAction accion;\n\n\tpublic void setActiveEditor(IAction action, IEditorPart targetEditor){\n\t\tthis.editor = targetEditor;\n\t\tthis.accion = action;\n\t}\n\n\tpublic IEditorPart getEditor(){\n\t\treturn this.editor;\n\t}\n\n\tpublic IAction getAction(){\n\t\treturn this.accion;\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/ExpandTreeAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport jbt.tools.bteditor.editor.BTEditor;\n\nimport org.eclipse.jface.action.IAction;\nimport org.eclipse.jface.viewers.ISelection;\n\npublic class ExpandTreeAction extends EditorActionDelegate {\n\tpublic void run(IAction action) {\n\t\t((BTEditor)this.getEditor()).expandTree(true);\n\t}\n\n\tpublic void selectionChanged(IAction action, ISelection selection) {\n\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/ExportToCppAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport java.io.IOException;\nimport jbt.tools.bteditor.BTCPPManager;\nimport jbt.tools.bteditor.model.BT;\nimport org.eclipse.jface.action.Action;\n\n/**\n * Action that saves a behaviour tree in a CPP file. If there is currently an\n * open behaviour tree coming from a file and with the same name, the saving\n * process fails, and an exception is thrown.\n * \n * @author Ricardo Juan Palma Durán & Fernando Matarrubia\n * \n */\npublic class ExportToCppAction extends Action {\n\t/** The tree to save. */\n\tprivate BT btToSave;\n\t/** The name of the file where the tree must be saved. */\n\tprivate String fileName;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param tree\n\t *            the tree to save.\n\t * @param fileName\n\t *            the name of the file where the tree is going to be saved.\n\t */\n\tpublic ExportToCppAction(BT tree, String fileName) {\n\t\tthis.btToSave = tree;\n\t\tthis.fileName = fileName;\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.jface.action.Action#run()\n\t */\n\tpublic void run(){\n\t\ttry {\n\t\t\tBTCPPManager.export(this.btToSave, this.fileName);\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(e.getMessage());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/LoadMMPMDomainAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport java.io.IOException;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.NodesLoader;\nimport jbt.tools.bteditor.model.ConceptualNodesTree;\nimport jbt.tools.bteditor.util.StandardDialogs;\nimport jbt.tools.bteditor.util.Utilities;\nimport jbt.tools.bteditor.views.NodesNavigator;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.ui.IViewPart;\n\n/**\n * Action that loads, into the {@link NodesLoader}, the actions and conditions\n * (sensors) present in a MMPM domain file.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class LoadMMPMDomainAction extends Action {\n\t/** Names of the files to open. */\n\tprivate Vector<String> fileNames;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param fileNames\n\t *            the names of the files to load.\n\t */\n\tpublic LoadMMPMDomainAction(Vector<String> fileNames) {\n\t\tthis.fileNames = fileNames;\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.jface.action.Action#run()\n\t */\n\tpublic void run() {\n\t\tVector<Exception> exceptions = new Vector<Exception>();\n\n\t\tfor (String currentFile : this.fileNames) {\n\t\t\ttry {\n\t\t\t\tConceptualNodesTree newTree = NodesLoader\n\t\t\t\t\t\t.loadNonStandardNodes(currentFile);\n\n\t\t\t\tIViewPart view = Utilities.getView(NodesNavigator.class);\n\n\t\t\t\tif (view != null) {\n\t\t\t\t\tNodesNavigator treeView = (NodesNavigator) view;\n\t\t\t\t\ttreeView.addTree(newTree);\n\t\t\t\t}\n\n\t\t\t} catch (IOException e) {\n\t\t\t\texceptions.add(e);\n\t\t\t}\n\t\t}\n\n\t\tif (exceptions.size() != 0) {\n\t\t\tStandardDialogs.exceptionDialog(\"Error loading MMPM domain file\",\n\t\t\t\t\t\"There were errors when opening MMPM domain files\",\n\t\t\t\t\texceptions);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/NewBTAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport jbt.tools.bteditor.Application;\nimport jbt.tools.bteditor.editor.BTEditor;\nimport jbt.tools.bteditor.editor.BTEditorInput;\nimport jbt.tools.bteditor.util.IconsPaths;\nimport jbt.tools.bteditor.util.StandardDialogs;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\n\n/**\n * Action that creates a new BT and opens an editor for it.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class NewBTAction extends Action {\n\t/** Integer used for generating names for the trees that are created. */\n\tprivate static int currentTreeNumber = 1;\n\n\t/**\n\t * Constructor.\n\t */\n\tpublic NewBTAction() {\n\t\tthis.setText(\"New BT\");\n\t\tthis.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(\n\t\t\t\tApplication.PLUGIN_ID, IconsPaths.NEW_BT));\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.jface.action.Action#run()\n\t */\n\tpublic void run() {\n\t\tIWorkbenchPage activePage = PlatformUI.getWorkbench()\n\t\t\t\t.getWorkbenchWindows()[0].getActivePage();\n\n\t\tBTEditorInput editorInput = new BTEditorInput(\"new \"\n\t\t\t\t+ currentTreeNumber, false, false);\n\n\t\tcurrentTreeNumber++;\n\n\t\ttry {\n\t\t\tactivePage.openEditor(editorInput, BTEditor.ID);\n\t\t} catch (PartInitException e) {\n\t\t\tStandardDialogs.exceptionDialog(\"Error when creating new tree\",\n\t\t\t\t\t\"There was an unexpected error when creating the tree\", e);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/OpenBTAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.editor.BTEditor;\nimport jbt.tools.bteditor.editor.BTEditorInput;\nimport jbt.tools.bteditor.util.StandardDialogs;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\n\n/**\n * Action for loading behaviour trees into the application, and opens an editor\n * for every tree that is properly opened. The trees are read from XML files.\n * This action can open several trees simultaneously.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class OpenBTAction extends Action {\n\t/** Names of the files that contain the trees to open. */\n\tprivate Vector<String> fileNames;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param fileNames\n\t *            names of the files that contain the trees to open.\n\t */\n\tpublic OpenBTAction(Vector<String> fileNames) {\n\t\tthis.fileNames = fileNames;\n\t}\n\n\tpublic void run() {\n\t\tIWorkbenchPage activePage = PlatformUI.getWorkbench()\n\t\t\t\t.getWorkbenchWindows()[0].getActivePage();\n\t\t\n\t\tVector<Exception> exceptions=new Vector<Exception>();\n\n\t\tfor (String fileName : this.fileNames) {\n\t\t\tBTEditorInput editorInput = new BTEditorInput(fileName, true, false);\n\n\t\t\ttry {\n\t\t\t\tactivePage.openEditor(editorInput, BTEditor.ID);\n\t\t\t} catch (PartInitException e) {\n\t\t\t\texceptions.add(e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(exceptions.size()!=0){\n\t\t\tStandardDialogs.exceptionDialog(\"Error opening tree\",\n\t\t\t\t\t\"There was an error when opening the tree\", exceptions);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/SaveBTAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport java.io.IOException;\n\nimport jbt.tools.bteditor.BTXMLManager;\nimport jbt.tools.bteditor.model.BT;\n\nimport org.eclipse.jface.action.Action;\n\n/**\n * Action that saves a behaviour tree in a XML file. If there is currently an\n * open behaviour tree coming from a file and with the same name, the saving\n * process fails, and an exception is thrown.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class SaveBTAction extends Action {\n\t/** The tree to save. */\n\tprivate BT btToSave;\n\t/** The name of the file where the tree must be saved. */\n\tprivate String fileName;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param tree\n\t *            the tree to save.\n\t * @param fileName\n\t *            the name of the file where the tree is going to be saved.\n\t */\n\tpublic SaveBTAction(BT tree, String fileName) {\n\t\tthis.btToSave = tree;\n\t\tthis.fileName = fileName;\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.jface.action.Action#run()\n\t */\n\tpublic void run(){\n\t\ttry {\n\t\t\tBTXMLManager.export(this.btToSave, this.fileName);\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(e.getMessage());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/actions/SaveBTAsAction.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.actions;\n\nimport java.util.List;\n\nimport jbt.tools.bteditor.editor.BTEditor;\nimport jbt.tools.bteditor.editor.BTEditorInput;\nimport jbt.tools.bteditor.model.BT;\nimport jbt.tools.bteditor.util.Extensions;\nimport jbt.tools.bteditor.util.Utilities;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.FileDialog;\nimport org.eclipse.ui.PlatformUI;\n\n/**\n * Action that saves a behaviour tree in a XML file. It first asks the user to\n * enter a file name in a dialog, and then saves the tree. If there is any\n * problem in the saving process, an expcetion is thrown. If there is an open\n * tree coming from a file with the same name that the user specifies, the\n * saving process also fails, and an exception is thrown.\n */\npublic class SaveBTAsAction extends Action {\n\t/** The tree to save. */\n\tprivate BT tree;\n\t/** The file where the tree will be stored. */\n\tprivate String selectedFile;\n\t/** The file name that is initially displayed in the file dialog. */\n\tprivate String initialFileName;\n\n\t/**\n\t * Constructor.\n\t * \n\t * @param tree\n\t *            tree to save.\n\t * @param initialFileNAme\n\t *            the file name that is initially displayed in the file dialog.\n\t */\n\tpublic SaveBTAsAction(BT tree, String initialFileName) {\n\t\tthis.tree = tree;\n\t\tthis.initialFileName = initialFileName;\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.jface.action.Action#run()\n\t */\n\tpublic void run() {\n\t\tFileDialog dialog = new FileDialog(\n\t\t\t\tPlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(), SWT.SAVE);\n\t\t\n\t\tdialog.setOverwrite(true);\n\t\tdialog.setFilterExtensions(Extensions.getFiltersFromExtensions(Extensions\n\t\t\t\t.getBTFileExtensions()));\n\t\tdialog.setText(\"Save BT as\");\n\t\tdialog.setFileName(this.initialFileName);\n\t\t\n\t\tString fileName = dialog.open();\n\n\t\tif (fileName != null) {\n\t\t\tList<BTEditor> editors = Utilities.getBTEditors();\n\n\t\t\tfor (BTEditor editor : editors) {\n\t\t\t\tBTEditorInput editorInput = (BTEditorInput) editor.getEditorInput();\n\t\t\t\tif (editorInput.isFromFile() && editorInput.getTreeName().equals(fileName)) {\n\t\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\t\"There is a behaviour tree already open with the same name (\"\n\t\t\t\t\t\t\t\t\t+ fileName + \"). Close it first.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tString targetFileName = Extensions.joinFileNameAndExtension(fileName,\n\t\t\t\t\tExtensions.getBTFileExtensions()[dialog.getFilterIndex()]);\n\n\t\t\tnew SaveBTAction(this.tree, targetFileName).run();\n\n\t\t\tthis.selectedFile = targetFileName;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the name of the file where the tree has been stored. Returns null\n\t * if the tree could not be saved or if {@link #run()} has not been called\n\t * yet.\n\t */\n\tpublic String getSelectedFile() {\n\t\treturn this.selectedFile;\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/editor/BTEditor.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.editor;\n\nimport java.awt.Checkbox;\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.Collection;\nimport java.util.Hashtable;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.ApplicationIcons;\nimport jbt.tools.bteditor.BTXMLManager;\nimport jbt.tools.bteditor.NodesLoader;\nimport jbt.tools.bteditor.actions.SaveBTAction;\nimport jbt.tools.bteditor.actions.SaveBTAsAction;\nimport jbt.tools.bteditor.event.ITreeModifierListener;\nimport jbt.tools.bteditor.event.TreeModifiedEvent;\nimport jbt.tools.bteditor.model.BT;\nimport jbt.tools.bteditor.model.BTNode;\nimport jbt.tools.bteditor.model.BTNode.Identifier;\nimport jbt.tools.bteditor.model.BTNode.Parameter;\nimport jbt.tools.bteditor.model.ConceptualBTNode;\nimport jbt.tools.bteditor.model.ConceptualBTNode.NodeInternalType;\nimport jbt.tools.bteditor.model.ConceptualBTNode.ParameterType;\nimport jbt.tools.bteditor.util.IconsPaths;\nimport jbt.tools.bteditor.util.OverlayImageIcon;\nimport jbt.tools.bteditor.util.Pair;\nimport jbt.tools.bteditor.util.StandardDialogs;\nimport jbt.tools.bteditor.util.Utilities;\nimport jbt.tools.bteditor.viewers.BTNodeIndentifierTransfer;\nimport jbt.tools.bteditor.viewers.ConceptualBTNodeTransfer;\nimport jbt.tools.bteditor.views.NodeInfo;\n\nimport org.eclipse.core.runtime.IProgressMonitor;\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.jface.action.IAction;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.dialogs.Dialog;\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.jface.viewers.DecoratingLabelProvider;\nimport org.eclipse.jface.viewers.DoubleClickEvent;\nimport org.eclipse.jface.viewers.IDoubleClickListener;\nimport org.eclipse.jface.viewers.ILabelDecorator;\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.ILabelProviderListener;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerSorter;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.dnd.DND;\nimport org.eclipse.swt.dnd.DragSourceEvent;\nimport org.eclipse.swt.dnd.DragSourceListener;\nimport org.eclipse.swt.dnd.DropTargetEvent;\nimport org.eclipse.swt.dnd.DropTargetListener;\nimport org.eclipse.swt.dnd.Transfer;\nimport org.eclipse.swt.events.KeyAdapter;\nimport org.eclipse.swt.events.KeyEvent;\nimport org.eclipse.swt.events.MenuDetectEvent;\nimport org.eclipse.swt.events.MenuDetectListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.graphics.Rectangle;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\nimport org.eclipse.swt.widgets.Tree;\nimport org.eclipse.swt.widgets.TreeItem;\nimport org.eclipse.ui.IActionBars;\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IEditorSite;\nimport org.eclipse.ui.IPartListener;\nimport org.eclipse.ui.IPartService;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.actions.ActionFactory;\nimport org.eclipse.ui.part.EditorPart;\n\n/**\n * Editor that is used for editing behavior trees ({@link BT}). This editor just\n * shows the tree in a tree-like way, letting the user modify a behaviour tree.\n * <p>\n * This editor can be used to insert nodes into the tree, delete them, and edit\n * their parameters. Nodes are inserted via a drag and drop mechanism.\n * <p>\n * For insertion purposes, this class is compatible with the\n * {@link ConceptualBTNodeTransfer} class, so a new empty node is inserted as a\n * child of the target of a drop operation when the underlying data is\n * compatible with {@link ConceptualBTNodeTransfer}.\n * <p>\n * Also, nodes of the tree can be moved around by using the drag and drop\n * mechanism. This class is compatible with the\n * {@link BTNodeIndentifierTransfer} class, so a dragged node is inserted as a\n * sibling of the target of the drop operation.\n * <p>\n * A context menu lets the user delete nodes (nodes can be deleted also by using\n * the delete and back space keys) and edit nodes' guards. Copying and pasting\n * nodes from the BTEditor into another editor (or the same one) is supported\n * through the context menu and global actions (Ctrl+C and Ctrl+V). However, it\n * should be noted that dragging from a BTEditor and dropping onto another\n * editor is not still supported.\n * <p>\n * For those nodes that have parameters, their value can be set by double\n * clicking on them.\n * <p>\n * This editor implements the {@link ITreeModifierListener} in order to change\n * the dirty status of the editor when the underlying tree is modified.\n * <p>\n * An important feature of the BTEditor is that it can be used to also edit the\n * guard of a node of another tree. BTEditors are opened with\n * {@link BTEditorInput} objects. BTEditorInput can specify where the tree that\n * the BTEditor edits comes from, and one of the possible options is to tell the\n * BTEditorInput that the tree comes from a node's guard. In such case, the\n * BTEditor has pretty much the same functionality as a normal BTEditor, with\n * small differences.\n * <p>\n * For instance, the way it responds to the <i>save</i> action is different.\n * When the BTEditor that contains a guard is saved, the guard is not saved into\n * a file, but stored into the node whose guard is being edited. Also, the root\n * node of a guard does not have a name, unlike that of normal tree.\n * <p>\n * A BTEditor's behaviour tree can therefore have guards being edited at any\n * time. In such case, if the editor is closed, all the editors editing guards\n * of the tree will be dissociated from the tree, and as a result, they will not\n * be considered guards any more (just a normal behaviour tree).\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTEditor extends EditorPart implements ITreeModifierListener {\n\tpublic static final String ID = \"jbt.tools.bteditor.editor.BTEditor\";\n\n\t/** The viewer that is being used to display the tree. */\n\tprivate TreeViewer viewer;\n\t/** The tree that the BTEditor is managing. */\n\tprivate BT tree;\n\t/** Flag that indicates whether the tree is dirty or not. */\n\tprivate boolean dirty;\n\t/**\n\t * Red color for cells containing erroneous items.\n\t */\n\tprivate Color ERROR_COLOR = Utilities.getDisplay().getSystemColor(SWT.COLOR_RED);\n\t/**\n\t * List of all the editors that are currently editing the guards of this\n\t * tree's nodes. BTEditors are indexed by the BTNode whose guard is being\n\t * edited.\n\t */\n\tprivate Map<BTNode, BTEditor> openGuardEditors;\n\t/**\n\t * In case this BTEditor is editing a guard, this variable stores the\n\t * behaviour tree that contains the node whose guard is being edited (\n\t * {@link #guardNode}).\n\t */\n\tprivate BT guardTree;\n\t/**\n\t * In case this BTEditor is editing a guard, this variable stores the BTNode\n\t * whose guard is being edited.\n\t */\n\tprivate BTNode guardNode;\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)\n\t */\n\tpublic void doSave(IProgressMonitor monitor) {\n\t\t/* First, check if the tree has no structural errors. */\n\t\tif (!checkTree()) {\n\t\t\tStandardDialogs.errorDialog(\"Tree not saved\",\n\t\t\t\t\t\"Errors were detected while validating the tree\");\n\t\t\tmonitor.setCanceled(true);\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * The save the tree.\n\t\t */\n\t\ttry {\n\t\t\tif (this.isFromFile()) {\n\t\t\t\t/* If the tree comes from a file, save the tree into a file. */\n\t\t\t\tnew SaveBTAction(this.tree, ((BTEditorInput) getEditorInput()).getTreeName()).run();\n\t\t\t\tthis.dirty = false;\n\t\t\t\tfirePropertyChange(EditorPart.PROP_DIRTY);\n\t\t\t} else if (this.isFromGuard()) {\n\t\t\t\t/*\n\t\t\t\t * If the tree comes from a guard, then set the tree as a guard\n\t\t\t\t * of the \"this.guardNode\". Note that we set a clone of the\n\t\t\t\t * guard, not the original one. By doing so, the guard of the\n\t\t\t\t * original node will not be modified even if this editor's tree\n\t\t\t\t * is modified.\n\t\t\t\t */\n\t\t\t\tBTNode guard = this.tree.getRoot().getChildren().get(0);\n\t\t\t\tif (guard != null) {\n\t\t\t\t\tthis.guardNode.setGuard(guard.clone());\n\t\t\t\t\tthis.guardTree.fireTreeChanged(this);\n\t\t\t\t\tBTEditorInput editorInput = (BTEditorInput) this.getEditorInput();\n\t\t\t\t\tUtilities.getBTEditor(Long.parseLong(editorInput.getTreeName().split(\n\t\t\t\t\t\t\tFile.pathSeparator)[0])).viewer.refresh();\n\t\t\t\t}\n\t\t\t\tthis.dirty = false;\n\t\t\t\tfirePropertyChange(EditorPart.PROP_DIRTY);\n\t\t\t} else {\n\t\t\t\t/* Otherwise, do a save as. */\n\t\t\t\tdoSaveAs();\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tStandardDialogs.exceptionDialog(\"Tree not saved\",\n\t\t\t\t\t\"Errors were detected while saving the tree\", e);\n\t\t\tmonitor.setCanceled(true);\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.EditorPart#doSaveAs()\n\t */\n\tpublic void doSaveAs() {\n\t\t/* First, check if the tree has no structural errors. */\n\t\tif (!checkTree()) {\n\t\t\tStandardDialogs.errorDialog(\"Tree not saved\",\n\t\t\t\t\t\"Errors were detected while validating the tree\");\n\t\t\treturn;\n\t\t}\n\n\t\tSaveBTAsAction action = new SaveBTAsAction(this.tree, this.getEditorInput().getName());\n\n\t\ttry {\n\t\t\taction.run();\n\t\t\tif (action.getSelectedFile() != null) {\n\t\t\t\tBTEditorInput editorInput = (BTEditorInput) getEditorInput();\n\t\t\t\teditorInput.setTreeName(action.getSelectedFile());\n\t\t\t\tthis.dirty = false;\n\t\t\t\tsetIsFromFile(true);\n\n\t\t\t\t/*\n\t\t\t\t * If the tree comes from a guard, it must be dissociated from\n\t\t\t\t * its original tree. From then on, this BTEditor will be\n\t\t\t\t * managed as a normal BTEditor.\n\t\t\t\t */\n\t\t\t\tif (isFromGuard()) {\n\t\t\t\t\tdissociateFromParentTree();\n\t\t\t\t}\n\n\t\t\t\tsetPartName(editorInput.getName());\n\n\t\t\t\tfirePropertyChange(EditorPart.PROP_DIRTY);\n\t\t\t\tfirePropertyChange(PROP_TITLE);\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tStandardDialogs.exceptionDialog(\"Error saving the tree\",\n\t\t\t\t\t\"There was an error when saving the tree\", e);\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,\n\t *      org.eclipse.ui.IEditorInput)\n\t */\n\tpublic void init(IEditorSite site, IEditorInput input) throws PartInitException {\n\t\tif (!(input instanceof BTEditorInput)) {\n\t\t\tthrow new PartInitException(\"Illegal IEditorInput. Must be \"\n\t\t\t\t\t+ BTEditorInput.class.getCanonicalName());\n\t\t}\n\n\t\tsetSite(site);\n\t\tsetInputWithNotify(input);\n\t\tBTEditorInput editorInput = (BTEditorInput) input;\n\t\tsetPartName(input.getName());\n\t\tthis.openGuardEditors = new Hashtable<BTNode, BTEditor>();\n\n\t\t/* Set the IPartListener that will handle close events. */\n\t\tIPartService partService = (IPartService) this.getSite().getService(IPartService.class);\n\t\tpartService.addPartListener(new BTEditorPartListener());\n\n\t\tif (editorInput.isFromFile()) {\n\t\t\t/* If the tree comes from a file, load the file. */\n\t\t\ttry {\n\t\t\t\tthis.tree = BTXMLManager.load(editorInput.getTreeName());\n\t\t\t\tthis.tree.addTreeModifiedListener(this);\n\t\t\t\tthis.dirty = false;\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new PartInitException(\"There were errors while loading the tree: \"\n\t\t\t\t\t\t+ e.getMessage(), e);\n\t\t\t}\n\t\t} else if (editorInput.isFromGuard()) {\n\t\t\t/*\n\t\t\t * If the tree comes from a guard, we have to construct a new tree\n\t\t\t * whose root is the guard.\n\t\t\t */\n\t\t\tthis.tree = new BT();\n\t\t\tthis.tree.addTreeModifiedListener(this);\n\n\t\t\tBTEditor activeEditor = Utilities.getActiveBTEditor();\n\t\t\tthis.guardTree = activeEditor.getBT();\n\n\t\t\tString[] pieces = editorInput.getTreeName().split(File.pathSeparator);\n\t\t\tthis.guardNode = this.guardTree.findNode(new Identifier(pieces[1]));\n\n\t\t\t/*\n\t\t\t * Important: the root node (type ROOT) of the guard's tree is not a\n\t\t\t * normal ROOT, since it has no name. Therefore, we clone the\n\t\t\t * original ROOT type and remove its ability to provide a name.\n\t\t\t */\n\t\t\tConceptualBTNode conceptualNoNameRoot = NodesLoader.getNode(\n\t\t\t\t\tNodeInternalType.ROOT.toString(), null).clone();\n\t\t\tconceptualNoNameRoot.setHasName(false);\n\t\t\tBTNode noNameRoot = this.tree.createNode(conceptualNoNameRoot);\n\n\t\t\tBTNode guard = this.guardNode.getGuard();\n\n\t\t\tif (guard != null) {\n\t\t\t\t/* If the node had a guard, then the editor is not dirty. */\n\t\t\t\tBTNode clonedGuard = guard.clone();\n\t\t\t\tclonedGuard.setParent(noNameRoot);\n\t\t\t\tnoNameRoot.addChild(clonedGuard);\n\t\t\t\tthis.dirty = false;\n\t\t\t} else {\n\t\t\t\t/* Otherwise, the editor is dirty. */\n\t\t\t\tthis.dirty = true;\n\t\t\t}\n\n\t\t\tthis.tree.setRoot(noNameRoot);\n\n\t\t\tthis.setTitleImage(ApplicationIcons.getIcon(IconsPaths.GUARD));\n\t\t} else {\n\t\t\t/* Otherwise, create a new empty BT. */\n\t\t\tthis.tree = new BT();\n\t\t\tthis.tree.addTreeModifiedListener(this);\n\t\t\ttree.setRoot(tree.createNode(NodesLoader.getNode(NodeInternalType.ROOT.toString(), null)));\n\t\t\tthis.dirty = true;\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.EditorPart#isDirty()\n\t */\n\tpublic boolean isDirty() {\n\t\treturn this.dirty;\n\t}\n\n\t/**\n\t * Returns true;\n\t */\n\tpublic boolean isSaveAsAllowed() {\n\t\treturn true;\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)\n\t */\n\tpublic void createPartControl(Composite parent) {\n\t\tinitializeViewer(parent, SWT.NONE);\n\n\t\tIActionBars bars = this.getEditorSite().getActionBars();\n\n\t\tif (bars.getGlobalActionHandler(ActionFactory.COPY.getId()) == null) {\n\t\t\tbars.setGlobalActionHandler(ActionFactory.COPY.getId(), new BTEditorCopyNode());\n\t\t\tbars.updateActionBars();\n\t\t}\n\t\tif (bars.getGlobalActionHandler(ActionFactory.PASTE.getId()) == null) {\n\t\t\tbars.setGlobalActionHandler(ActionFactory.PASTE.getId(), new BTEditorPasteNode());\n\t\t\tbars.updateActionBars();\n\t\t}\n\n\t\t/* Expands all the nodes of the tree. */\n\t\tthis.expandTree(true);\n\n\t\t/*\n\t\t * Selection listener that updates the NodeInfo view in order to show\n\t\t * the currently selected node.\n\t\t */\n\t\tthis.viewer.addSelectionChangedListener(new ISelectionChangedListener() {\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tNodeInfo nodeInfoView = (NodeInfo) Utilities.getView(NodeInfo.class);\n\n\t\t\t\tif (nodeInfoView != null) {\n\t\t\t\t\tList<BTNode> selectedElements = getSelectedElements();\n\n\t\t\t\t\tif (selectedElements.size() == 1) {\n\t\t\t\t\t\tnodeInfoView.setNode(selectedElements.get(0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.WorkbenchPart#setFocus()\n\t */\n\tpublic void setFocus() {\n\t\t/*\n\t\t * Update the NodeInfo view so that it displays the information of the\n\t\t * currently selected node.\n\t\t */\n\t\tNodeInfo nodeInfoView = (NodeInfo) Utilities.getView(NodeInfo.class);\n\n\t\tif (nodeInfoView != null) {\n\t\t\tList<BTNode> selectedElements = getSelectedElements();\n\n\t\t\tif (selectedElements.size() == 1) {\n\t\t\t\tnodeInfoView.setNode(selectedElements.get(0));\n\t\t\t} else {\n\t\t\t\tnodeInfoView.setNode(null);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void initializeViewer(Composite parent, int style) {\n\t\t/* Initializes the viewer. */\n\t\tthis.viewer = new TreeViewer(parent, style);\n\t\tthis.viewer.setContentProvider(new BTContentProvider());\n\t\tBTLabelProvider btLabelProvider = new BTLabelProvider();\n\t\tDecoratingLabelProvider decoratingLabelProvider = new DecoratingLabelProvider(\n\t\t\t\tbtLabelProvider, btLabelProvider);\n\t\tthis.viewer.setLabelProvider(decoratingLabelProvider);\n\t\tthis.viewer.setInput(this.tree);\n\n\t\tfinal Tree treeWidget = (Tree) this.viewer.getControl();\n\n\t\t/* Key listener for deleting nodes. The root node cannot be deleted. */\n\t\ttreeWidget.addKeyListener(new KeyAdapter() {\n\t\t\tpublic void keyPressed(KeyEvent e) {\n\t\t\t\tif (e.keyCode == SWT.DEL || e.keyCode == SWT.BS) {\n\t\t\t\t\tList<BTNode> selectedNodes = getSelectedElements();\n\t\t\t\t\tif (selectedNodes.size() != 0) {\n\t\t\t\t\t\tnew DeleteNode(selectedNodes).run();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t});\n\n\t\t/* Adding drag support. */\n\t\tthis.viewer.addDragSupport(DND.DROP_MOVE,\n\t\t\t\tnew Transfer[] { BTNodeIndentifierTransfer.getInstance() },\n\t\t\t\tnew BTEditorDragSourceListener());\n\n\t\t/* Adding drop support. */\n\t\tthis.viewer\n\t\t\t\t.addDropSupport(DND.DROP_MOVE,\n\t\t\t\t\t\tnew Transfer[] { ConceptualBTNodeTransfer.getInstance(),\n\t\t\t\t\t\t\t\tBTNodeIndentifierTransfer.getInstance() },\n\t\t\t\t\t\tnew BTEditorDropTargetListener());\n\n\t\t/* Menu listener that creates the context menu. */\n\t\ttreeWidget.addMenuDetectListener(new MenuDetectListener() {\n\t\t\tpublic void menuDetected(MenuDetectEvent e) {\n\t\t\t\tList<BTNode> selectedNodes = getSelectedElements();\n\t\t\t\tif (selectedNodes.size() != 0) {\n\t\t\t\t\tMenuManager menuManager = new MenuManager();\n\t\t\t\t\tmenuManager.add(new DeleteNode(selectedNodes));\n\t\t\t\t\tmenuManager.add(new ExpandNodes(selectedNodes));\n\t\t\t\t\tmenuManager.add(new CollapseNodes(selectedNodes));\n\n\t\t\t\t\tif (selectedNodes.size() == 1) {\n\t\t\t\t\t\tBTNode selectedNode = selectedNodes.get(0);\n\t\t\t\t\t\tif (!selectedNode.getConceptualNode().getType()\n\t\t\t\t\t\t\t\t.equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\t\t\t\tmenuManager.add(new EditGuard(selectedNode));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmenuManager.add(new CopyNode());\n\t\t\t\t\t\tPasteNode pasteAction = new PasteNode();\n\t\t\t\t\t\tmenuManager.add(pasteAction);\n\t\t\t\t\t}\n\n\t\t\t\t\ttreeWidget.setMenu(menuManager.createContextMenu(treeWidget));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t/*\n\t\t * Listener that shows a panel for editing the parameters of the node.\n\t\t */\n\t\tthis.viewer.addDoubleClickListener(new IDoubleClickListener() {\n\t\t\tpublic void doubleClick(DoubleClickEvent event) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) event.getSelection();\n\t\t\t\tif (!selection.isEmpty()) {\n\t\t\t\t\tBTNode selectedNode = (BTNode) selection.getFirstElement();\n\t\t\t\t\tif (selectedNode.getConceptualNode().getParameters().size() != 0\n\t\t\t\t\t\t\t|| (selectedNode.getConceptualNode().getType() == NodeInternalType.ROOT\n\t\t\t\t\t\t\t\t\t.toString() && !isFromGuard())) {\n\t\t\t\t\t\tnew NodeParametersDialog(Utilities.getShell(), selectedNode).open();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Expands or collapses all the nodes of the tree. If <code>expand</code> is\n\t * true, the tree is expanded. If false, it is collapsed.\n\t */\n\tpublic void expandTree(boolean expand) {\n\t\tif (expand) {\n\t\t\tthis.viewer.expandAll();\n\t\t} else {\n\t\t\tthis.viewer.collapseAll();\n\t\t}\n\t\tthis.clearErrors();\n\t}\n\n\t/**\n\t * Returns a list of the selected elements, or an empty list if none is\n\t * selected.\n\t */\n\tpublic List<BTNode> getSelectedElements() {\n\t\treturn ((IStructuredSelection) this.viewer.getSelection()).toList();\n\t}\n\n\t/**\n\t * \n\t * @see jbt.tools.bteditor.event.ITreeModifierListener#treeModified(jbt.tools.bteditor.event.TreeModifiedEvent)\n\t */\n\tpublic void treeModified(TreeModifiedEvent event) {\n\t\tthis.dirty = true;\n\t\tfirePropertyChange(EditorPart.PROP_DIRTY);\n\t}\n\n\t/**\n\t * Checks the validity of the tree. It highlights the nodes that are\n\t * incorrect.\n\t * \n\t * @return true if the tree is correct, and false otherwise.\n\t */\n\tpublic boolean checkTree() {\n\t\tthis.clearErrors();\n\t\tList<BTNode> incorrectNodes = this.tree.checkTree();\n\t\tif (incorrectNodes.size() != 0) {\n\t\t\tfor (BTNode n : incorrectNodes) {\n\t\t\t\tthis.setErrorColor(n);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Returns the BT that is being edited by this BTEditor.\n\t * \n\t * @return the BT that is being edited by this BTEditor.\n\t */\n\tpublic BT getBT() {\n\t\treturn this.tree;\n\t}\n\n\t/**\n\t * Selects a node of the BT. If the node does not exist, nothing happens.\n\t * \n\t * @param node\n\t *            the node to select.\n\t */\n\tpublic void selectNode(BTNode node) {\n\t\tthis.viewer.setSelection(new StructuredSelection(node), true);\n\t}\n\n\t/**\n\t * Selects a node of the BT. If the node does not exist, nothing happens.\n\t * \n\t * @param nodeID\n\t *            the identifier of the node to select.\n\t */\n\tpublic void selectNode(Identifier nodeID) {\n\t\tBTNode node = this.tree.findNode(nodeID);\n\n\t\tif (node != null) {\n\t\t\tthis.viewer.setSelection(new StructuredSelection(node), true);\n\t\t}\n\t}\n\n\t/**\n\t * Returns true if the BT that this BTEditor is editing comes from a file,\n\t * and false otherwise.\n\t * \n\t * @return true if the BT that this BTEditor is editing comes from a file,\n\t *         and false otherwise.\n\t */\n\tprivate boolean isFromFile() {\n\t\treturn ((BTEditorInput) getEditorInput()).isFromFile();\n\t}\n\n\t/**\n\t * Sets if the BT that this BTEditor is editing comes from a file.\n\t * \n\t * @param isFromFile\n\t *            true if the BT comes from a file, and false otherwise.\n\t */\n\tprivate void setIsFromFile(boolean isFromFile) {\n\t\t((BTEditorInput) getEditorInput()).setIsFromFile(isFromFile);\n\t}\n\n\t/**\n\t * Returns true if the BT that this BTEditor is editing comes from a guard,\n\t * and false otherwise.\n\t * \n\t * @return true if the BT that this BTEditor is editing comes from a guard,\n\t *         and false otherwise.\n\t */\n\tprivate boolean isFromGuard() {\n\t\treturn ((BTEditorInput) getEditorInput()).isFromGuard();\n\t}\n\n\t/**\n\t * Sets if the BT that this BTEditor is editing comes from a guard.\n\t * \n\t * @param isFromGuard\n\t *            true if the BT comes from a guard, and false otherwise.\n\t */\n\tprivate void setIsFromGuard(boolean isFromGuard) {\n\t\t((BTEditorInput) getEditorInput()).setIsFromGuard(isFromGuard);\n\t}\n\n\t/**\n\t * Highlights with an error color the node <code>node</code>.\n\t */\n\tprivate void setErrorColor(BTNode node) {\n\t\tTreeItem item = findNode(this.viewer.getTree().getTopItem(), node);\n\t\tif (item != null) {\n\t\t\titem.setBackground(ERROR_COLOR);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the TreeItem associated to <code>node</code>. The search starts\n\t * from the node by <code>item</code>, so all the nodes whose root is\n\t * <code>item</code> are searched for. Returns null if no such element is\n\t * found.\n\t */\n\tprivate TreeItem findNode(TreeItem item, BTNode node) {\n\t\tif (node == item.getData()) {\n\t\t\treturn item;\n\t\t} else {\n\t\t\tfor (TreeItem child : item.getItems()) {\n\t\t\t\tTreeItem found = findNode(child, node);\n\t\t\t\tif (found != null) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Clears the errors that may be being showed in the tree of the editor.\n\t */\n\tpublic void clearErrors() {\n\t\tthis.tree.clearErrors();\n\t\tTreeItem rootItem = viewer.getTree().getTopItem();\n\t\t/*\n\t\t * This check is done because when the TreeViewer is created in the\n\t\t * BTEditor, somehow the rootItem is null despite the fact that there is\n\t\t * an actual root element in the tree. I do not know why this happened.\n\t\t * Actually, after so many changes, I do not know if this still happens\n\t\t * :S\n\t\t */\n\t\tif (rootItem != null) {\n\t\t\tinternalClearErrorColors(rootItem);\n\t\t}\n\t}\n\n\t/**\n\t * Clears the error color from all the nodes of the tree whose root element\n\t * is <code>item</code>.\n\t */\n\tprivate void internalClearErrorColors(TreeItem item) {\n\t\titem.setBackground(null);\n\t\tfor (TreeItem child : item.getItems()) {\n\t\t\tinternalClearErrorColors(child);\n\t\t}\n\t}\n\n\t/**\n\t * Label provider of the underlying TreeViewer.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate static class BTLabelProvider implements ILabelProvider, ILabelDecorator {\n\t\tprivate List<Image> disposableImages = new LinkedList<Image>();\n\n\t\tpublic void addListener(ILabelProviderListener listener) {\n\t\t}\n\n\t\tpublic void dispose() {\n\t\t\tfor (Image i : this.disposableImages) {\n\t\t\t\ti.dispose();\n\t\t\t}\n\t\t}\n\n\t\tpublic boolean isLabelProperty(Object element, String property) {\n\t\t\treturn false;\n\t\t}\n\n\t\tpublic void removeListener(ILabelProviderListener listener) {\n\t\t}\n\n\t\tpublic Image getImage(Object element) {\n\t\t\tBTNode node = (BTNode) element;\n\n\t\t\treturn ApplicationIcons.getIcon(node.getConceptualNode().getIcon());\n\t\t}\n\n\t\tpublic String getText(Object element) {\n\t\t\tBTNode node = (BTNode) element;\n\n\t\t\tif (node.getConceptualNode().getType()\n\t\t\t\t\t.equals(NodeInternalType.SUBTREE_LOOKUP.toString())) {\n\t\t\t\tfor (Parameter p : node.getParameters()) {\n\t\t\t\t\tif (p.getName().equals(\"subtreeName\")) {\n\t\t\t\t\t\treturn node.getConceptualNode().getReadableType() + \" - \" + p.getValue();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn node.getConceptualNode().getReadableType();\n\t\t}\n\n\t\t/**\n\t\t * If the BTNode has a guard, it is decorated. Otherwise, it is left\n\t\t * unchanged.\n\t\t * \n\t\t * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image,\n\t\t *      java.lang.Object)\n\t\t */\n\t\tpublic Image decorateImage(Image image, Object element) {\n\t\t\t/* Overlay decorator image over base image. */\n\t\t\tBTNode node = (BTNode) element;\n\n\t\t\tif (node.getGuard() != null) {\n\t\t\t\tImage result;\n\t\t\t\tOverlayImageIcon overlayIcon = new OverlayImageIcon(image,\n\t\t\t\t\t\tApplicationIcons.getIcon(IconsPaths.GUARD));\n\t\t\t\tresult = overlayIcon.getImage();\n\t\t\t\tthis.disposableImages.add(result);\n\t\t\t\treturn result;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tpublic String decorateText(String text, Object element) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Content provider for the underlying TreeViewer. Its input is a {@link BT}\n\t * .\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate static class BTContentProvider implements ITreeContentProvider {\n\t\tpublic Object[] getChildren(Object parentElement) {\n\t\t\tBTNode node = (BTNode) parentElement;\n\n\t\t\treturn node.getChildren().toArray();\n\t\t}\n\n\t\tpublic Object getParent(Object element) {\n\t\t\tBTNode node = (BTNode) element;\n\n\t\t\treturn node.getParent();\n\t\t}\n\n\t\tpublic boolean hasChildren(Object element) {\n\t\t\tBTNode node = (BTNode) element;\n\n\t\t\treturn node.getNumChildren() > 0;\n\t\t}\n\n\t\tpublic Object[] getElements(Object inputElement) {\n\t\t\tBTNode root = ((BT) inputElement).getRoot();\n\t\t\tif (root != null) {\n\t\t\t\treturn new Object[] { root };\n\t\t\t} else {\n\t\t\t\treturn new Object[] {};\n\t\t\t}\n\t\t}\n\n\t\tpublic void dispose() {\n\t\t}\n\n\t\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\t}\n\t}\n\n\t/**\n\t * Copies the currently selected BTNode of the currently active BTEditor\n\t * (<b>not necessarily this one</b>) into the\n\t * {@link BTEditorCopyAndPasteManager} for future paste operations. If the\n\t * root node is selected, what is copied is its child (if it has one). If no\n\t * node is selected, nothing is copied. If several nodes are currently\n\t * selected, nothing is copied. If there is no active BTEditor, nothing is\n\t * copied either.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class BTEditorCopyNode extends Action implements IAction {\n\t\tprivate BTNode selectedNode;\n\n\t\tpublic BTEditorCopyNode() {\n\t\t\tthis.setText(\"Copy\");\n\t\t}\n\n\t\tpublic void run() {\n\t\t\tBTEditor activeEditor = Utilities.getActiveBTEditor();\n\t\t\tif (activeEditor != null) {\n\t\t\t\tList<BTNode> selectedElements = activeEditor.getSelectedElements();\n\t\t\t\tif (selectedElements.size() == 1) {\n\t\t\t\t\tthis.selectedNode = selectedElements.get(0);\n\n\t\t\t\t\tif (this.selectedNode.getConceptualNode().getType()\n\t\t\t\t\t\t\t.equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\t\t\tif (this.selectedNode.getChildren().size() != 0) {\n\t\t\t\t\t\t\tthis.selectedNode = this.selectedNode.getChildren().get(0);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.selectedNode = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this.selectedNode != null) {\n\t\t\t\t\tBTEditorCopyAndPasteManager.getInstance().copy(this.selectedNode);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Paste into the currently selected node of the currently active BTEditor\n\t * (<b>not necessarily this one</b>) whatever BTNode is currently copied in\n\t * the {@link BTEditorCopyAndPasteManager}. The node is pasted as a child of\n\t * the currently selected node. If no node is currently copied in the\n\t * BTEditorCopyAndPasteManager, nothing is done. If the currently selected\n\t * node cannot hold any more children, nothing is done. Also, if there is no\n\t * active BTEditor, nothing is done.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class BTEditorPasteNode extends Action implements IAction {\n\t\tprivate BTNode selectedNode;\n\n\t\tpublic BTEditorPasteNode() {\n\t\t\tthis.setText(\"Paste\");\n\t\t}\n\n\t\tpublic void run() {\n\t\t\tif (!BTEditorCopyAndPasteManager.getInstance().hasCopy()) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tBTEditor activeEditor = Utilities.getActiveBTEditor();\n\t\t\tif (activeEditor != null) {\n\t\t\t\tList<BTNode> selectedElements = activeEditor.getSelectedElements();\n\t\t\t\tif (selectedElements.size() == 1) {\n\t\t\t\t\tthis.selectedNode = selectedElements.get(0);\n\n\t\t\t\t\tif (this.selectedNode.getConceptualNode().getNumChildren() != -1\n\t\t\t\t\t\t\t&& this.selectedNode.getConceptualNode().getNumChildren() <= this.selectedNode\n\t\t\t\t\t\t\t\t\t.getNumChildren()) {\n\t\t\t\t\t\tthis.selectedNode = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this.selectedNode != null) {\n\t\t\t\t\tBTNode pastedNode = BTEditorCopyAndPasteManager.getInstance().paste();\n\t\t\t\t\tactiveEditor.tree.recomputeIDs(pastedNode);\n\n\t\t\t\t\tif (pastedNode.getBT() != activeEditor.tree) {\n\t\t\t\t\t\tactiveEditor.tree.reassignUnderlyingBT(pastedNode);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.selectedNode.addChild(pastedNode);\n\t\t\t\t\tpastedNode.setParent(this.selectedNode);\n\t\t\t\t\tactiveEditor.tree.updateNodeCounter();\n\t\t\t\t\tactiveEditor.viewer.refresh(this.selectedNode);\n\t\t\t\t\tactiveEditor.treeChanged(this);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Copies the currently selected BTNode into the\n\t * {@link BTEditorCopyAndPasteManager} for future paste operations. If no\n\t * node is selected, nothing is copied. If the root node is selected, what\n\t * is copied is its child (if it has one). If several nodes are currently\n\t * selected, nothing is copied either.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class CopyNode extends Action implements IAction {\n\t\tprivate BTNode selectedNode;\n\n\t\tpublic CopyNode() {\n\t\t\tthis.setText(\"Copy\");\n\t\t}\n\n\t\tpublic void run() {\n\t\t\tList<BTNode> selectedElements = getSelectedElements();\n\n\t\t\tif (selectedElements.size() == 1) {\n\t\t\t\tthis.selectedNode = selectedElements.get(0);\n\n\t\t\t\tif (this.selectedNode.getConceptualNode().getType()\n\t\t\t\t\t\t.equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\t\tif (this.selectedNode.getChildren().size() != 0) {\n\t\t\t\t\t\tthis.selectedNode = this.selectedNode.getChildren().get(0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.selectedNode = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.selectedNode != null) {\n\t\t\t\tBTEditorCopyAndPasteManager.getInstance().copy(this.selectedNode);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Paste into the currently selected node whatever BTNode is currently\n\t * copied in the {@link BTEditorCopyAndPasteManager}. The node is pasted as\n\t * a child of the currently selected node. If no node is currently copied in\n\t * the BTEditorCopyAndPasteManager, nothing is done. Also, if the currently\n\t * selected node cannot hold any more children, nothing is done.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class PasteNode extends Action implements IAction {\n\t\tprivate BTNode selectedNode;\n\n\t\tpublic PasteNode() {\n\t\t\tthis.setText(\"Paste\");\n\t\t}\n\n\t\tpublic void run() {\n\t\t\tif (!BTEditorCopyAndPasteManager.getInstance().hasCopy()) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tList<BTNode> selectedElements = getSelectedElements();\n\t\t\tif (selectedElements.size() == 1) {\n\t\t\t\tthis.selectedNode = selectedElements.get(0);\n\n\t\t\t\tif (this.selectedNode.getConceptualNode().getNumChildren() != -1\n\t\t\t\t\t\t&& this.selectedNode.getConceptualNode().getNumChildren() <= this.selectedNode\n\t\t\t\t\t\t\t\t.getNumChildren()) {\n\t\t\t\t\tthis.selectedNode = null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.selectedNode != null) {\n\t\t\t\tBTNode pastedNode = BTEditorCopyAndPasteManager.getInstance().paste();\n\n\t\t\t\tif (pastedNode.getBT() != tree) {\n\t\t\t\t\ttree.reassignUnderlyingBT(pastedNode);\n\t\t\t\t}\n\n\t\t\t\ttree.recomputeIDs(pastedNode);\n\t\t\t\tthis.selectedNode.addChild(pastedNode);\n\t\t\t\tpastedNode.setParent(this.selectedNode);\n\t\t\t\ttree.updateNodeCounter();\n\t\t\t\tviewer.refresh(this.selectedNode);\n\t\t\t\ttreeChanged(this);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Action for deleting a list of nodes from the tree. The root node is not\n\t * deleted.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class DeleteNode extends Action {\n\t\tprivate List<BTNode> selectedNodes;\n\n\t\tpublic DeleteNode(List<BTNode> selectedNodes) {\n\t\t\tthis.setText(\"Delete node\");\n\t\t\tthis.selectedNodes = selectedNodes;\n\t\t}\n\n\t\tpublic void run() {\n\t\t\tboolean nodeDeleted = false;\n\n\t\t\tfor (BTNode node : this.selectedNodes) {\n\t\t\t\tif (!node.getConceptualNode().getType().equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\t\tif (openGuardEditors.containsKey(node)) {\n\t\t\t\t\t\tboolean delete = StandardDialogs\n\t\t\t\t\t\t\t\t.confirmationDialog(\n\t\t\t\t\t\t\t\t\t\t\"Node with open guard\",\n\t\t\t\t\t\t\t\t\t\t\"Node \"\n\t\t\t\t\t\t\t\t\t\t\t\t+ node.getID().toString()\n\t\t\t\t\t\t\t\t\t\t\t\t+ \" has an open guard. If this node is removed, the guard will be dissociated from the tree. Are you sure you want to delete the node?\");\n\n\t\t\t\t\t\tif (delete) {\n\t\t\t\t\t\t\tBTNode parent = node.getParent();\n\t\t\t\t\t\t\tparent.removeChild(node);\n\t\t\t\t\t\t\tviewer.refresh(parent);\n\t\t\t\t\t\t\tnodeDeleted = true;\n\n\t\t\t\t\t\t\tBTEditor guardEditor = openGuardEditors.get(node);\n\t\t\t\t\t\t\tBTEditorInput editorInput = (BTEditorInput) guardEditor\n\t\t\t\t\t\t\t\t\t.getEditorInput();\n\t\t\t\t\t\t\teditorInput.setTreeName(editorInput.getName());\n\t\t\t\t\t\t\tguardEditor.dissociateFromParentTree();\n\t\t\t\t\t\t\tguardEditor.dirty = true;\n\t\t\t\t\t\t\tguardEditor.firePropertyChange(PROP_TITLE);\n\t\t\t\t\t\t\tguardEditor.firePropertyChange(PROP_DIRTY);\n\n\t\t\t\t\t\t\topenGuardEditors.remove(node);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tBTNode parent = node.getParent();\n\t\t\t\t\t\tparent.removeChild(node);\n\t\t\t\t\t\tviewer.refresh(parent);\n\t\t\t\t\t\tnodeDeleted = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (nodeDeleted) {\n\t\t\t\ttreeChanged(viewer);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Action that expands nodes of the tree.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class ExpandNodes extends Action {\n\t\tprivate List<BTNode> nodesToExpand;\n\n\t\tpublic ExpandNodes(List<BTNode> nodesToExpand) {\n\t\t\tthis.setText(\"Expand node\");\n\t\t\tthis.nodesToExpand = nodesToExpand;\n\t\t}\n\n\t\tpublic void run() {\n\t\t\tfor (BTNode node : this.nodesToExpand) {\n\t\t\t\tviewer.expandToLevel(node, TreeViewer.ALL_LEVELS);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate class EditGuard extends Action {\n\t\tprivate BTNode node;\n\n\t\tpublic EditGuard(BTNode node) {\n\t\t\tthis.setText(\"Edit Guard\");\n\t\t\tthis.node = node;\n\t\t}\n\n\t\tpublic void run() {\n\t\t\tnew GuardEditionDialog(Utilities.getShell(), this.node).open();\n\t\t}\n\t}\n\n\t/**\n\t * Action that expands nodes of the tree.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class CollapseNodes extends Action {\n\t\tprivate List<BTNode> nodesToCollapse;\n\n\t\tpublic CollapseNodes(List<BTNode> nodesToCollapse) {\n\t\t\tthis.setText(\"Collapse node\");\n\t\t\tthis.nodesToCollapse = nodesToCollapse;\n\t\t}\n\n\t\tpublic void run() {\n\t\t\tfor (BTNode node : this.nodesToCollapse) {\n\t\t\t\tviewer.collapseToLevel(node, TreeViewer.ALL_LEVELS);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Dialog that lets the user:\n\t * <ul>\n\t * <li>Add a guard to a node.\n\t * <li>Modify the guard's parameters.\n\t * <li>Remove the guard from a node.\n\t * </ul>\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class GuardEditionDialog extends Dialog {\n\t\tprivate BTNode node;\n\t\tprivate TreeViewer guardsViewer;\n\t\tprivate Button editGuardButton;\n\t\tprivate Button addSimpleGuardButton;\n\t\tprivate Button removeGuardButton;\n\t\tprivate Button addComplexGuardButton;\n\n\t\tpublic GuardEditionDialog(Shell parentShell, BTNode node) {\n\t\t\tsuper(parentShell);\n\t\t\tthis.node = node;\n\t\t\tthis.setBlockOnOpen(false);\n\t\t\tthis.setShellStyle(SWT.RESIZE | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.MAX);\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see\n\t\t * org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse\n\t\t * .swt.widgets.Composite)\n\t\t */\n\t\tprotected Control createContents(Composite parent) {\n\t\t\tControl contents = super.createContents(parent);\n\n\t\t\treturn contents;\n\t\t}\n\n\t\t/**\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)\n\t\t */\n\t\tprotected Control createDialogArea(Composite parent) {\n\t\t\tComposite composite = (Composite) super.createDialogArea(parent);// new\n\n\t\t\tcomposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\t\tcomposite.setLayout(new GridLayout(2, false));\n\n\t\t\t/*\n\t\t\t * We force the default size of the list displaying the guard to be\n\t\t\t * two rows, and to have at least a minimum width.\n\t\t\t */\n\t\t\tComposite guardsViewerComposite = new Composite(composite, SWT.NONE) {\n\t\t\t\tpublic Point computeSize(int wHint, int hHint, boolean changed) {\n\t\t\t\t\treturn new Point(wHint < 200 ? 200 : wHint, guardsViewer.getTree()\n\t\t\t\t\t\t\t.getItemHeight() * 2);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tguardsViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\t\tguardsViewerComposite.setLayout(new FillLayout());\n\n\t\t\tthis.guardsViewer = new TreeViewer(guardsViewerComposite);\n\t\t\tthis.guardsViewer.setContentProvider(new BTContentProvider());\n\t\t\tthis.guardsViewer.setLabelProvider(new BTLabelProvider());\n\n\t\t\t/* Double click listener for editing the guards parameters. */\n\t\t\tthis.guardsViewer.addDoubleClickListener(new IDoubleClickListener() {\n\t\t\t\tpublic void doubleClick(DoubleClickEvent event) {\n\t\t\t\t\tif (node.getGuard() != null) {\n\t\t\t\t\t\tif (node.getGuard().getChildren().size() != 0) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\topenGuardEditor(node);\n\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t} catch (PartInitException ex) {\n\t\t\t\t\t\t\t\tStandardDialogs.exceptionDialog(\"Error opening the guard\",\n\t\t\t\t\t\t\t\t\t\t\"There was an unexpected error when opening the guard\", ex);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (node.getGuard().getConceptualNode().getParameters().size() != 0) {\n\t\t\t\t\t\t\tnew NodeParametersDialog(getShell(), node.getGuard()).open();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (this.node.getGuard() != null) {\n\t\t\t\tBT input = new BT(this.node.getGuard());\n\t\t\t\tthis.guardsViewer.setInput(input);\n\t\t\t}\n\n\t\t\tComposite buttonsComposite = new Composite(composite, SWT.NONE);\n\t\t\tbuttonsComposite.setLayout(new GridLayout(1, true));\n\t\t\tbuttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));\n\n\t\t\tthis.addSimpleGuardButton = createAddSimpleGuardButton(buttonsComposite);\n\t\t\tthis.addComplexGuardButton = createAddComplexGuardButton(buttonsComposite);\n\t\t\tthis.editGuardButton = createEditGuardButton(buttonsComposite);\n\t\t\tthis.removeGuardButton = createRemoveGuardButton(buttonsComposite);\n\n\t\t\treturn composite;\n\t\t}\n\n\t\tprivate Button createAddSimpleGuardButton(Composite parent) {\n\t\t\tButton addSimpleGuardButton = new Button(parent, SWT.PUSH);\n\n\t\t\taddSimpleGuardButton.setText(\"Add simple guard\");\n\t\t\taddSimpleGuardButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));\n\n\t\t\tfinal GuardEditionDialog guardEditionDialog = this;\n\n\t\t\taddSimpleGuardButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\tnew GuardInsertionDialog(Utilities.getShell(), node, guardEditionDialog).open();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn addSimpleGuardButton;\n\t\t}\n\n\t\tprivate Button createAddComplexGuardButton(Composite parent) {\n\t\t\tButton addGuardButton = new Button(parent, SWT.PUSH);\n\n\t\t\taddGuardButton.setText(\"Add complex guard\");\n\t\t\taddGuardButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));\n\n\t\t\taddGuardButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\topenGuardEditor(node);\n\t\t\t\t\t\tclose();\n\t\t\t\t\t} catch (PartInitException ex) {\n\t\t\t\t\t\tStandardDialogs.exceptionDialog(\"Error opening the guard\",\n\t\t\t\t\t\t\t\t\"There was an unexpected error when opening the guard\", ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn addGuardButton;\n\t\t}\n\n\t\tprivate Button createEditGuardButton(Composite parent) {\n\t\t\tButton editGuardButton = new Button(parent, SWT.PUSH);\n\n\t\t\teditGuardButton.setText(\"Edit guard\");\n\t\t\teditGuardButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));\n\n\t\t\teditGuardButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\tif (node.getGuard() != null) {\n\t\t\t\t\t\tif (node.getGuard().getChildren().size() != 0) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\topenGuardEditor(node);\n\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t} catch (PartInitException ex) {\n\t\t\t\t\t\t\t\tStandardDialogs.exceptionDialog(\"Error when creating new tree\",\n\t\t\t\t\t\t\t\t\t\t\"There was an unexpected error when creating the tree\", ex);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (node.getGuard().getConceptualNode().getParameters().size() != 0) {\n\t\t\t\t\t\t\tnew NodeParametersDialog(getShell(), node.getGuard()).open();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn editGuardButton;\n\t\t}\n\n\t\tprivate Button createRemoveGuardButton(Composite parent) {\n\t\t\tfinal Button removeGuardButton = new Button(parent, SWT.PUSH);\n\n\t\t\tremoveGuardButton.setText(\"Remove guard\");\n\t\t\tremoveGuardButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));\n\n\t\t\tremoveGuardButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\tif (node.getGuard() != null) {\n\t\t\t\t\t\tnode.setGuard(null);\n\t\t\t\t\t\tguardsViewer.setInput(null);\n\n\t\t\t\t\t\t/* Dissociate the editor that is editing the guard. */\n\t\t\t\t\t\tif (openGuardEditors.containsKey(node)) {\n\t\t\t\t\t\t\tBTEditor guardEditor = openGuardEditors.get(node);\n\t\t\t\t\t\t\tBTEditorInput editorInput = (BTEditorInput) guardEditor\n\t\t\t\t\t\t\t\t\t.getEditorInput();\n\t\t\t\t\t\t\teditorInput.setTreeName(editorInput.getName());\n\t\t\t\t\t\t\tguardEditor.dissociateFromParentTree();\n\t\t\t\t\t\t\tguardEditor.dirty = true;\n\t\t\t\t\t\t\tguardEditor.firePropertyChange(PROP_TITLE);\n\t\t\t\t\t\t\tguardEditor.firePropertyChange(PROP_DIRTY);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttreeChanged(removeGuardButton);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn removeGuardButton;\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.\n\t\t * widgets .Shell)\n\t\t */\n\t\tprotected void configureShell(Shell shell) {\n\t\t\tsuper.configureShell(shell);\n\t\t\tshell.setText(\"Guard Editor\");\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.\n\t\t * eclipse .swt.widgets.Composite)\n\t\t */\n\t\tprotected void createButtonsForButtonBar(Composite parent) {\n\t\t\tcreateButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)\n\t\t */\n\t\tprotected void buttonPressed(int buttonId) {\n\t\t\tthis.setReturnCode(buttonId);\n\t\t\tif (buttonId == IDialogConstants.CLOSE_ID) {\n\t\t\t\tviewer.update(this.node, null);\n\t\t\t\tclose();\n\t\t\t}\n\t\t}\n\n\t\tpublic void setGuard() {\n\t\t\tif (this.node.getGuard() != null) {\n\t\t\t\tBT input = new BT(this.node.getGuard());\n\t\t\t\tthis.guardsViewer.setInput(input);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Dialog that shows all the loaded leaf nodes and lets the user select one\n\t * to be inserted as the guard of a node.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class GuardInsertionDialog extends Dialog {\n\t\tprivate BTNode node;\n\t\tprivate TableViewer leafNodesViewer;\n\t\tprivate GuardEditionDialog guardEditionDialog;\n\n\t\tpublic GuardInsertionDialog(Shell parentShell, BTNode node,\n\t\t\t\tGuardEditionDialog guardEditionDialog) {\n\t\t\tsuper(parentShell);\n\t\t\tthis.node = node;\n\t\t\tthis.setBlockOnOpen(false);\n\t\t\tthis.guardEditionDialog = guardEditionDialog;\n\t\t\tthis.setShellStyle(SWT.RESIZE | SWT.CLOSE | SWT.APPLICATION_MODAL);\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see\n\t\t * org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse\n\t\t * .swt.widgets.Composite)\n\t\t */\n\t\tprotected Control createContents(Composite parent) {\n\t\t\tControl contents = super.createContents(parent);\n\n\t\t\treturn contents;\n\t\t}\n\n\t\t/**\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)\n\t\t */\n\t\tprotected Control createDialogArea(Composite parent) {\n\t\t\tComposite composite = (Composite) super.createDialogArea(parent);\n\n\t\t\t/*\n\t\t\t * We force the default size of the list displaying the list of leaf\n\t\t\t * nodes guard to be seven rows.\n\t\t\t */\n\t\t\tComposite leafNodesViewerComposite = new Composite(composite, SWT.NONE) {\n\t\t\t\tpublic Point computeSize(int wHint, int hHint, boolean changed) {\n\t\t\t\t\treturn new Point(leafNodesViewer.getTable().computeSize(SWT.DEFAULT,\n\t\t\t\t\t\t\tSWT.DEFAULT).x, leafNodesViewer.getTable().getItemHeight() * 7);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tleafNodesViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\t\tleafNodesViewerComposite.setLayout(new FillLayout());\n\t\t\tthis.leafNodesViewer = new TableViewer(leafNodesViewerComposite, SWT.BORDER\n\t\t\t\t\t| SWT.SINGLE);\n\t\t\tthis.leafNodesViewer.setContentProvider(new ConceptualBTNodeListContentProvider());\n\t\t\tthis.leafNodesViewer.setLabelProvider(new ConceptualBTNodeListLabelProvider());\n\n\t\t\t/*\n\t\t\t * Build a list with all the nodes that can be used as guards, which\n\t\t\t * are leaf nodes.\n\t\t\t */\n\t\t\tList<ConceptualBTNode> standardNodes = NodesLoader.getStandardNodes();\n\t\t\tList<ConceptualBTNode> nonStandardNodes = NodesLoader.getNonStandardNodes();\n\t\t\tList<ConceptualBTNode> leafNodes = new Vector<ConceptualBTNode>();\n\n\t\t\tfor (ConceptualBTNode node : standardNodes) {\n\t\t\t\tif (node.getNumChildren() == 0) {\n\t\t\t\t\tleafNodes.add(node);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (ConceptualBTNode node : nonStandardNodes) {\n\t\t\t\tif (node.getNumChildren() == 0) {\n\t\t\t\t\tleafNodes.add(node);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* This list is the input to the viewer. */\n\t\t\tthis.leafNodesViewer.setInput(leafNodes);\n\t\t\tthis.leafNodesViewer.getTable().select(0);\n\n\t\t\t/*\n\t\t\t * Set a sorter for the elements. First standard nodes, then\n\t\t\t * conditions, and finally actions.\n\t\t\t */\n\t\t\tthis.leafNodesViewer.setSorter(new ViewerSorter() {\n\t\t\t\tpublic int compare(Viewer viewer, Object e1, Object e2) {\n\t\t\t\t\tConceptualBTNode node1 = (ConceptualBTNode) e1;\n\t\t\t\t\tConceptualBTNode node2 = (ConceptualBTNode) e2;\n\n\t\t\t\t\tString node1Type = node1.getType();\n\t\t\t\t\tString node2Type = node2.getType();\n\n\t\t\t\t\tif ((node1Type.equals(NodeInternalType.ACTION.toString()) || node1Type\n\t\t\t\t\t\t\t.equals(NodeInternalType.CONDITION.toString()))\n\t\t\t\t\t\t\t&& node2Type.equals(node1Type)) {\n\t\t\t\t\t\treturn node1.getReadableType().compareToIgnoreCase(node2.getReadableType());\n\t\t\t\t\t}\n\n\t\t\t\t\tif (node1Type.equals(NodeInternalType.ACTION.toString())\n\t\t\t\t\t\t\t&& node2Type.equals(NodeInternalType.CONDITION.toString())) {\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (node1Type.equals(NodeInternalType.CONDITION.toString())\n\t\t\t\t\t\t\t&& node2Type.equals(NodeInternalType.ACTION.toString())) {\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!node1Type.equals(NodeInternalType.ACTION.toString())\n\t\t\t\t\t\t\t&& !node1Type.equals(NodeInternalType.CONDITION.toString())) {\n\t\t\t\t\t\tif (!node2Type.equals(NodeInternalType.ACTION.toString())\n\t\t\t\t\t\t\t\t&& !node2Type.equals(NodeInternalType.CONDITION.toString())) {\n\t\t\t\t\t\t\treturn node1.getReadableType().compareToIgnoreCase(\n\t\t\t\t\t\t\t\t\tnode2.getReadableType());\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn node1.getReadableType().compareToIgnoreCase(node2.getReadableType());\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t/* Add double click listener. */\n\t\t\tthis.leafNodesViewer.addDoubleClickListener(new IDoubleClickListener() {\n\t\t\t\tpublic void doubleClick(DoubleClickEvent event) {\n\t\t\t\t\tsetGuardFromSelection();\n\t\t\t\t\ttreeChanged(this);\n\t\t\t\t\tclose();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn composite;\n\t\t}\n\n\t\t/**\n\t\t * Content provider for a list of {@link ConceptualBTNode} objects.\n\t\t * \n\t\t * Its input is a List&lt;ConceptualBTNode&gt;.\n\t\t * \n\t\t * @author Ricardo Juan Palma Durán\n\t\t * \n\t\t */\n\t\tprivate class ConceptualBTNodeListContentProvider implements IStructuredContentProvider {\n\t\t\tpublic Object[] getElements(Object inputElement) {\n\t\t\t\treturn ((List<ConceptualBTNode>) inputElement).toArray();\n\t\t\t}\n\n\t\t\tpublic void dispose() {\n\t\t\t}\n\n\t\t\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Label provider for objects of type ConceptualBTNode.\n\t\t * \n\t\t * @author Ricardo Juan Palma Durán\n\t\t * \n\t\t */\n\t\tprivate class ConceptualBTNodeListLabelProvider implements ILabelProvider {\n\n\t\t\tpublic Image getImage(Object element) {\n\t\t\t\tConceptualBTNode node = (ConceptualBTNode) element;\n\n\t\t\t\treturn ApplicationIcons.getIcon(node.getIcon());\n\t\t\t}\n\n\t\t\tpublic String getText(Object element) {\n\t\t\t\tConceptualBTNode node = (ConceptualBTNode) element;\n\n\t\t\t\treturn node.getReadableType();\n\t\t\t}\n\n\t\t\tpublic void addListener(ILabelProviderListener listener) {\n\t\t\t}\n\n\t\t\tpublic void dispose() {\n\t\t\t}\n\n\t\t\tpublic boolean isLabelProperty(Object element, String property) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tpublic void removeListener(ILabelProviderListener listener) {\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.\n\t\t * widgets .Shell)\n\t\t */\n\t\tprotected void configureShell(Shell shell) {\n\t\t\tsuper.configureShell(shell);\n\t\t\tshell.setText(\"Guard Editor\");\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.\n\t\t * eclipse .swt.widgets.Composite)\n\t\t */\n\t\tprotected void createButtonsForButtonBar(Composite parent) {\n\t\t\tcreateButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);\n\t\t\tcreateButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)\n\t\t */\n\t\tprotected void buttonPressed(int buttonId) {\n\t\t\tthis.setReturnCode(buttonId);\n\t\t\tif (buttonId == IDialogConstants.CLOSE_ID) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\tsetGuardFromSelection();\n\t\t\t\ttreeChanged(this);\n\t\t\t\tclose();\n\t\t\t}\n\t\t}\n\n\t\tprivate void setGuardFromSelection() {\n\t\t\tConceptualBTNode selectedConceptualBTNode = (ConceptualBTNode) ((IStructuredSelection) this.leafNodesViewer\n\t\t\t\t\t.getSelection()).toList().get(0);\n\t\t\tthis.node.setGuard(tree.createNode(selectedConceptualBTNode));\n\t\t\tthis.guardEditionDialog.setGuard();\n\t\t}\n\t}\n\n\t/**\n\t * Dialog that is used to enter parameter values.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class NodeParametersDialog extends Dialog {\n\t\tprivate BTNode node;\n\t\tprivate NameEditorComposite nameEditor;\n\t\tprivate ParametersEditorComposite nodeEditor;\n\n\t\t/**\n\t\t * Constructor. <code>node</code> must be a node with parameters.\n\t\t */\n\t\tpublic NodeParametersDialog(Shell shell, BTNode node) {\n\t\t\tsuper(shell);\n\t\t\tthis.setBlockOnOpen(false);\n\t\t\tthis.node = node;\n\t\t\tthis.setShellStyle(SWT.RESIZE | SWT.CLOSE | SWT.APPLICATION_MODAL);\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see\n\t\t * org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse\n\t\t * .swt.widgets.Composite)\n\t\t */\n\t\tprotected Control createContents(Composite parent) {\n\t\t\tControl contents = super.createContents(parent);\n\n\t\t\treturn contents;\n\t\t}\n\n\t\t/**\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)\n\t\t */\n\t\tprotected Control createDialogArea(Composite parent) {\n\t\t\tComposite composite = (Composite) super.createDialogArea(parent);\n\n\t\t\tif (this.node.getConceptualNode().getType().equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\tthis.nameEditor = new NameEditorComposite(composite, SWT.NONE, this.node.getName());\n\t\t\t\tthis.nameEditor.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));\n\t\t\t}\n\n\t\t\tif (this.node.getConceptualNode().getParameters().size() != 0) {\n\t\t\t\tGroup parametersGroup = new Group(composite, SWT.NONE);\n\t\t\t\tparametersGroup.setText(\"Parameters\");\n\t\t\t\tparametersGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\t\t\tparametersGroup.setLayout(new GridLayout(1, false));\n\t\t\t\tthis.nodeEditor = new ParametersEditorComposite(parametersGroup, SWT.NONE,\n\t\t\t\t\t\tthis.node);\n\t\t\t\tthis.nodeEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\t\t}\n\t\t\t\n\t\t\t\n\n\t\t\treturn composite;\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.\n\t\t * widgets .Shell)\n\t\t */\n\t\tprotected void configureShell(Shell shell) {\n\t\t\tsuper.configureShell(shell);\n\t\t\tshell.setText(\"Node Editor\");\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.\n\t\t * eclipse .swt.widgets.Composite)\n\t\t */\n\t\tprotected void createButtonsForButtonBar(Composite parent) {\n\t\t\tcreateButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);\n\n\t\t\tcreateButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);\n\n\t\t}\n\n\t\t/*\n\t\t * (non-Javadoc)\n\t\t * \n\t\t * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)\n\t\t */\n\t\tprotected void buttonPressed(int buttonId) {\n\t\t\tthis.setReturnCode(buttonId);\n\t\t\tif (buttonId == IDialogConstants.CLOSE_ID) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\tif (this.nodeEditor != null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tList<Parameter> params = this.nodeEditor.getParameters();\n\t\t\t\t\t\tthis.node.clearParameters();\n\t\t\t\t\t\tfor (Parameter p : params) {\n\t\t\t\t\t\t\tthis.node.addParameter(p);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tMessageDialog.openError(this.getShell(), \"Error validating parameters\",\n\t\t\t\t\t\t\t\te.getMessage());\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (this.nameEditor != null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.node.setName(this.nameEditor.getNodeName());\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tMessageDialog.openError(this.getShell(), \"Error validating name\",\n\t\t\t\t\t\t\t\te.getMessage());\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttreeChanged(viewer);\n\n\t\t\t\tif (node.getConceptualNode().getType()\n\t\t\t\t\t\t.equals(NodeInternalType.SUBTREE_LOOKUP.toString())) {\n\t\t\t\t\tviewer.update(node, null);\n\t\t\t\t}\n\n\t\t\t\tclose();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Composite for editing the name of the root tree.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class NameEditorComposite extends Composite {\n\t\tprivate Label nameLabel;\n\t\tprivate Text nameValue;\n\n\t\t/**\n\t\t * <code>initialName</code> is the name that is displayed when the\n\t\t * Composite is created. It may be null, in which case no name is\n\t\t * displayed.\n\t\t */\n\t\tpublic NameEditorComposite(Composite parent, int style, String initialName) {\n\t\t\tsuper(parent, style);\n\t\t\tthis.setLayout(new GridLayout(2, false));\n\n\t\t\tthis.nameLabel = new Label(this, SWT.NONE);\n\t\t\tthis.nameLabel.setText(\"Name\");\n\t\t\tthis.nameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));\n\n\t\t\tthis.nameValue = new Text(this, SWT.BORDER);\n\t\t\tthis.nameValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\t\tthis.nameValue.setText(initialName == null ? \"\" : initialName);\n\t\t}\n\n\t\t/**\n\t\t * Returns the name, or throws an exception if it is not a valid name.\n\t\t */\n\t\tpublic String getNodeName() throws RuntimeException {\n\t\t\tif (this.nameValue.getText().equals(\"\")) {\n\t\t\t\tthrow new RuntimeException(\"Invalid name\");\n\t\t\t}\n\t\t\treturn this.nameValue.getText();\n\t\t}\n\t}\n\n\t/**\n\t * Composite for editing the parameters of a node. It internally stores many\n\t * {@link ParameterComposite}, one for every parameter of the node.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class ParametersEditorComposite extends Composite {\n\t\tprivate BTNode node;\n\t\tprivate List<ParameterComposite> parameterComposites;\n\n\t\tpublic ParametersEditorComposite(Composite parent, int style, BTNode node) {\n\t\t\tsuper(parent, style);\n\t\t\tthis.node = node;\n\n\t\t\tthis.setLayout(new GridLayout(1, false));\n\t\t\tthis.parameterComposites = new Vector<ParameterComposite>();\n\n\t\t\tList<jbt.tools.bteditor.model.ConceptualBTNode.Parameter> parameters = this.node\n\t\t\t\t\t.getConceptualNode().getParameters();\n\n\t\t\tfor (int i = 0; i < parameters.size(); i++) {\n\t\t\t\tString currentParameterValue = this.node.getParameters().size() > 0 ? this.node\n\t\t\t\t\t\t.getParameters().get(i).getValue() : null;\n\n\t\t\t\tboolean currentFromContext = this.node.getParameters().size() > 0 ? this.node\n\t\t\t\t\t\t.getParameters().get(i).getFromContext() : false;\n\n\t\t\t\tboolean isConstant = true;\n\t\t\t\tif (ParameterType.isVariable(this.node.getConceptualNode().getParameters().get(i).getType()))\n\t\t\t\t{\n\t\t\t\t\tString fieldValue = null;\n\t\t\t\t\tBTNode.VarParameter varNodeParameter = null;\n\t\t\t\t\tif (this.node.getParameters().size() > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tvarNodeParameter = (BTNode.VarParameter)this.node.getParameters().get(i);\n\t\t\t\t\t\tfieldValue = varNodeParameter.getVariableName();\n\t\t\t\t\t\tisConstant = varNodeParameter.getIsConstant();\n\t\t\t\t\t}\n\t\t\t\t\tVarParameterComposite pc = new VarParameterComposite(this, SWT.NONE, parameters.get(i),\n\t\t\t\t\t\t\tcurrentParameterValue, currentFromContext, isConstant, fieldValue, varNodeParameter);\n\t\t\t\t\tthis.parameterComposites.add(pc);\n\t\t\t\t\tpc.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tParameterComposite pc = new ParameterComposite(this, SWT.NONE, parameters.get(i),\n\t\t\t\t\t\t\tcurrentParameterValue, currentFromContext);\n\t\t\t\t\tthis.parameterComposites.add(pc);\n\t\t\t\t\tpc.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic List<Parameter> getParameters() throws RuntimeException {\n\t\t\tList<Parameter> result = new Vector<Parameter>();\n\n\t\t\tfor (ParameterComposite pc : this.parameterComposites) {\n\t\t\t\tresult.add(pc.getParameter());\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\t}\n\n\t/**\n\t * Composite for editing an individual parameter. If the parameter is\n\t * contextable, the value of the context location where to find the\n\t * parameter may be specified.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class ParameterComposite extends Composite {\n\t\tprivate jbt.tools.bteditor.model.ConceptualBTNode.Parameter parameter;\n\t\tprivate Label nameLabel;\n\t\tprivate Text valueText;\n\t\tprivate Checkbox isConstant;\n\t\tprivate Button fromContextButton;\n\t\tprivate static final int DEFAULT_TEXT_FIELD_WIDTH = 100;\n\n\t\t\n\t\tpublic ParameterComposite(Composite parent, int style)\n\t\t{\n\t\t\tsuper(parent, style);\n\t\t}\n\t\t/**\n\t\t * <code>initialValue</code> may be null.\n\t\t */\n\t\tpublic ParameterComposite(Composite parent, int style,\n\t\t\t\tjbt.tools.bteditor.model.ConceptualBTNode.Parameter parameter, String initialValue,\n\t\t\t\tboolean initialFromContext) {\n\t\t\tsuper(parent, style);\n\n\t\t\tthis.setLayout(new GridLayout(3, false));\n\t\t\t\n\t\t\tthis.parameter = parameter;\n\n\t\t\tString tooltip = getTooltip(parameter);\n\n\t\t\tthis.nameLabel = new Label(this, SWT.NONE);\n\t\t\tthis.nameLabel.setText(this.parameter.getName() + \" (\"\n\t\t\t\t\t+ this.parameter.getType().getReadableType() + \")\");\n\t\t\tthis.nameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));\n\t\t\tthis.nameLabel.setToolTipText(tooltip);\n\n\t\t\tthis.valueText = new Text(this, SWT.BORDER);\n\t\t\tthis.valueText.setText(initialValue == null ? \"\" : initialValue);\n\t\t\tGridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\t\tdata.widthHint = DEFAULT_TEXT_FIELD_WIDTH;\n\t\t\tthis.valueText.setLayoutData(data);\n\t\t\tthis.valueText.setToolTipText(tooltip);\n\n\t\t\tif (this.parameter.getContextable()) {\n\t\t\t\tthis.fromContextButton = new Button(this, SWT.CHECK);\n\t\t\t\tthis.fromContextButton.setText(\"From context\");\n\t\t\t\tthis.fromContextButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,\n\t\t\t\t\t\tfalse));\n\t\t\t\tthis.fromContextButton.setSelection(initialFromContext);\n\t\t\t\tthis.fromContextButton\n\t\t\t\t\t\t.setToolTipText(\"If activated, the specified value represents the place, in the context, where the value of the variable will be retrieved from\");\n\n\t\t\t\tif (this.parameter.getType() == ParameterType.OBJECT) {\n\t\t\t\t\tthis.fromContextButton.setEnabled(false);\n\t\t\t\t\tthis.fromContextButton.setSelection(true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Returns the parameter shown by the Composite, and throws an exception\n\t\t * in case there is some error in the parameter.\n\t\t */\n\t\tpublic Parameter getParameter() throws RuntimeException {\n\t\t\t/*\n\t\t\t * If the parameter must come from the context, then any non-empty\n\t\t\t * string value is allowed.\n\t\t\t */\n\t\t\tif (this.parameter.getContextable() && this.fromContextButton.getSelection()) {\n\t\t\t\tif (this.valueText.getText().equals(\"\")) {\n\t\t\t\t\tthrow new RuntimeException(\"Invalid parameter value for parameter \"\n\t\t\t\t\t\t\t+ this.parameter.getName() + \". Must be a non-empty string.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (!BTNode.checkParameter(parameter, this.valueText.getText(), tree)) {\n\t\t\t\t\tthrow new RuntimeException(\"Invalid parameter value (\"\n\t\t\t\t\t\t\t+ this.valueText.getText() + \") for parameter \"\n\t\t\t\t\t\t\t+ this.parameter.getName());\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tParameter result = new Parameter();\n\t\t\tresult.setName(this.parameter.getName());\n\t\t\tresult.setValue(this.valueText.getText());\n\n\t\t\tif (this.parameter.getContextable()) {\n\t\t\t\tresult.setFromContext(this.fromContextButton.getSelection());\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\t/**\n\t\t * Returns an appropriate descriptive tooltip for a\n\t\t * {@link jbt.tools.bteditor.model.ConceptualBTNode.Parameter}.\n\t\t */\n\t\tprivate String getTooltip(\n\t\t\t\tjbt.tools.bteditor.model.ConceptualBTNode.Parameter parameterDefinition) {\n\t\t\tParameterType parameterType = parameterDefinition.getType();\n\n\t\t\tif (parameterType == ParameterType.BOOLEAN) {\n\t\t\t\treturn \"Boolean value. Can be either \\\"true\\\" or \\\"false\\\"\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.COORDINATE) {\n\t\t\t\treturn \"Coordinate value. Must be a sequence of real numbers separated by blank spaces\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.DIRECTION) {\n\t\t\t\treturn \"Direction value. Can be any integer value\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.INTEGER) {\n\t\t\t\treturn \"Integer value\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.NODE_ID) {\n\t\t\t\tString validTypes = \"\";\n\n\t\t\t\tif (parameterDefinition.getNodeClasses().size() != 0) {\n\t\t\t\t\tfor (String type : parameterDefinition.getNodeClasses()) {\n\t\t\t\t\t\tvalidTypes += NodesLoader.getNode(type, null).getReadableType() + \", \";\n\t\t\t\t\t}\n\n\t\t\t\t\tvalidTypes = validTypes.substring(0, validTypes.length() - 2);\n\t\t\t\t}\n\n\t\t\t\treturn \"Node identifier. Must be the identifier of a node of the tree\"\n\t\t\t\t\t\t+ (validTypes.equals(\"\") ? \"\" : \", with one of the following types: \"\n\t\t\t\t\t\t\t\t+ validTypes);\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.OBJECT) {\n\t\t\t\treturn \"Object. Always retrieved from the context\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.PARALLEL_POLICY) {\n\t\t\t\treturn \"Parallel task policy. Can be either \\\"sequence\\\" or \\\"selector\\\"\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.REAL) {\n\t\t\t\treturn \"Real value\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.STATUS_CODE) {\n\t\t\t\treturn \"Task termination status code. Can be either \\\"success\\\" or \\\"failure\\\"\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.STRING) {\n\t\t\t\treturn \"String value. Any non-empty string\";\n\t\t\t}\n\t\t\tif (parameterType == ParameterType.LIST_OF_VARIABLES) {\n\t\t\t\treturn \"List of variables, surrounded each one by \\\"\\\", and separated by blank spaces\";\n\t\t\t}\n\t\t\treturn \"\";\n\t\t}\n\t\t\n\t\tprotected Composite getCompositeParent()\n\t\t{\n\t\t\treturn this.getParent();\n\t\t}\n\t}\n\t\n\t/**\n\t * Composite for editing an variable individual parameter. If the parameter is\n\t * contextable, the value of the context location where to find the\n\t * parameter may be specified. Also check if the parameter is a key-value pair\n\t * and shows the dialog regarding that\n\t * \n\t * @author Fernando Matarrubia Garc�a\n\t * \n\t */\n\tprivate class VarParameterComposite extends ParameterComposite {\n\t\tprivate jbt.tools.bteditor.model.ConceptualBTNode.Parameter parameter;\n\t\tprivate Label nameLabel;\n\t\tprivate Text valueText;\n\t\tprivate final Button isConstant;\n\t\tprivate final Text variableNameText;\n\t\tprivate Button fromContextButton;\n\t\tprivate static final int DEFAULT_TEXT_FIELD_WIDTH = 100;\n\t\tprivate BTNode.VarParameter varNodeParameter;\n\n\t\t/**\n\t\t * <code>initialValue</code> may be null.\n\t\t */\n\t\tpublic VarParameterComposite(Composite parent, int style,\n\t\t\t\tjbt.tools.bteditor.model.ConceptualBTNode.Parameter parameter, String initialValue,\n\t\t\t\tboolean initialFromContext, boolean isConstant, String defaultVarText,  BTNode.VarParameter varNodeParameter) {\n\t\t\t\n\t\t\tsuper(parent, style);\n\t\t\t\n\t\t\tthis.varNodeParameter = varNodeParameter;\n\n\t\t\tthis.setLayout(new GridLayout(4, true));\n\n\t\t\tthis.parameter = parameter;\n\n\t\t\tString tooltip = super.getTooltip(parameter);\n\n\t\t\tthis.nameLabel = new Label(this, SWT.NONE);\n\t\t\tthis.nameLabel.setText(this.parameter.getName() + \" (\"\n\t\t\t\t\t+ this.parameter.getType().getReadableType() + \")\");\n\t\t\tthis.nameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));\n\t\t\tthis.nameLabel.setToolTipText(tooltip);\n\t\t\t\n\t\t\tthis.isConstant = new Button(this, SWT.CHECK);\n\t\t\tthis.isConstant.setText(\"Constant\");\n\t\t\tGridData data2 = new GridData(SWT.LEFT, SWT.CENTER, true, false);\n\t\t\tdata2.widthHint = DEFAULT_TEXT_FIELD_WIDTH;\n\t\t\tthis.isConstant.setLayoutData(data2);\n\t\t\tthis.isConstant.setSelection(isConstant);\n\t\t\tthis.isConstant.setToolTipText(\"If activated, the \\\"Constant\\\" field is enabled. That means that the parameter is a special key-value type\");\n\n\t\t\tthis.variableNameText = new Text(this, SWT.BORDER);\n\t\t\tthis.variableNameText.setText(defaultVarText == null ? \"\" : defaultVarText);\n\t\t\tGridData data3 = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\t\tdata2.widthHint = DEFAULT_TEXT_FIELD_WIDTH;\n\t\t\tthis.variableNameText.setLayoutData(data3);\n\t\t\tthis.variableNameText.setToolTipText(tooltip);\n\t\t\tthis.variableNameText.setEnabled(!isConstant);\n\t\t\t\n\t\t\tthis.valueText = new Text(this, SWT.BORDER);\n\t\t\tthis.valueText.setText(initialValue == null ? \"\" : initialValue);\n\t\t\tGridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\t\tdata.widthHint = DEFAULT_TEXT_FIELD_WIDTH;\n\t\t\tthis.valueText.setLayoutData(data);\n\t\t\tthis.valueText.setToolTipText(tooltip);\n\t\t\t\n\t\t\tListener listener = new Listener() {\n\t\t\t\t \n\t\t\t      public void handleEvent(Event event) {\n\t\t\t      \n\t\t\t    \t  variableNameText.setEnabled(!VarParameterComposite.this.isConstant.getSelection());\n\t\t\t    \t  setIsConstant(VarParameterComposite.this.isConstant.getSelection());\n\t\t\t      }\n\t\t\t};\n\t\t\t\n\t\t\tthis.isConstant.addListener(SWT.Selection, listener);\n\n\t\t\tif (this.parameter.getContextable()) {\n\t\t\t\tthis.fromContextButton = new Button(this, SWT.CHECK);\n\t\t\t\tthis.fromContextButton.setText(\"From context\");\n\t\t\t\tthis.fromContextButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,\n\t\t\t\t\t\tfalse));\n\t\t\t\tthis.fromContextButton.setSelection(initialFromContext);\n\t\t\t\tthis.fromContextButton\n\t\t\t\t\t\t.setToolTipText(\"If activated, the specified value represents the place, in the context, where the value of the variable will be retrieved from\");\n\n\t\t\t\tif (this.parameter.getType() == ParameterType.OBJECT) {\n\t\t\t\t\tthis.fromContextButton.setEnabled(false);\n\t\t\t\t\tthis.fromContextButton.setSelection(true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Returns the parameter shown by the Composite, and throws an exception\n\t\t * in case there is some error in the parameter.\n\t\t */\n\t\tpublic Parameter getParameter() throws RuntimeException {\n\t\t\t/*\n\t\t\t * If the parameter must come from the context, then any non-empty\n\t\t\t * string value is allowed.\n\t\t\t */\n\t\t\tif (this.parameter.getContextable() && this.fromContextButton.getSelection()) {\n\t\t\t\tif (this.valueText.getText().equals(\"\")) {\n\t\t\t\t\tthrow new RuntimeException(\"Invalid parameter value for parameter \"\n\t\t\t\t\t\t\t+ this.parameter.getName() + \". Must be a non-empty string.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (!BTNode.checkVarParameter(parameter, this.valueText.getText(), this.variableNameText.getText(), this.isConstant.getSelection(), tree)) {\n\t\t\t\t\tthrow new RuntimeException(\"Invalid parameter value (\"\n\t\t\t\t\t\t\t+ this.valueText.getText() + \") for parameter \"\n\t\t\t\t\t\t\t+ this.parameter.getName());\n\t\t\t\t}\n\t\t\t}\n\t\t\tBTNode.Parameter aux = new BTNode.Parameter();\n\t\t\t\n\n\t\t\taux.setName(this.parameter.getName());\n\t\t\taux.setValue(this.valueText.getText());\n\t\t\t\n\t\t\tBTNode.VarParameter result = new BTNode.VarParameter(aux);\n\t\t\tresult.setIsConstant(this.isConstant.getSelection());\n\t\t\tresult.setVariableName(this.variableNameText.getText());\n\n\t\t\tif (this.parameter.getContextable()) {\n\t\t\t\tresult.setFromContext(this.fromContextButton.getSelection());\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/*\n\t\t * Helper function that sets the Field Value of a Variable Node Parameter\n\t\t * This function is called from the checkbox event listener\n\t\t */\n\t\tpublic void setIsConstant(boolean isConstant)\n\t\t{\n\t\t\tif (varNodeParameter != null)\n\t\t\t{\n\t\t\t\tvarNodeParameter.setIsConstant(isConstant);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Drag listener used by the BTEditor. This drag listener transfers the\n\t * selected element {@link BTNode}, and is compatible with the\n\t * {@link BTNodeIndentifierTransfer} type.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class BTEditorDragSourceListener implements DragSourceListener {\n\t\tpublic void dragStart(DragSourceEvent event) {\n\t\t\tList<BTNode> selection = ((IStructuredSelection) viewer.getSelection()).toList();\n\n\t\t\tif (selection.size() == 1) {\n\t\t\t\tif (!selection.get(0).getConceptualNode().getType()\n\t\t\t\t\t\t.equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\t\tevent.doit = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tevent.doit = false;\n\t\t}\n\n\t\tpublic void dragSetData(DragSourceEvent event) {\n\t\t\tif (BTNodeIndentifierTransfer.getInstance().isSupportedType(event.dataType)) {\n\t\t\t\tevent.data = ((IStructuredSelection) viewer.getSelection()).getFirstElement();\n\t\t\t}\n\t\t}\n\n\t\tpublic void dragFinished(DragSourceEvent event) {\n\t\t}\n\t}\n\n\t/**\n\t * Drop target listener used by the BTEditor. This drop target listener is\n\t * compatible with two transfer types, {@link ConceptualBTNodeTransfer} and\n\t * {@link BTNodeIndentifierTransfer}.\n\t * <p>\n\t * When the data being transfered is compatible with\n\t * {@link ConceptualBTNodeTransfer}, a new empty BTNode is created as a\n\t * child or as a sibling of the target of the drop operation (depending on\n\t * the specific position of the cursor at the moment the operation is\n\t * performed).\n\t * <p>\n\t * When the data being transfered is compatible with\n\t * {@link BTNodeIndentifierTransfer}, that node is removed from its current\n\t * position and inserted as a sibling or as a child of the target of the\n\t * drop operation (depending on the specific position of the cursor at the\n\t * moment the operation is performed).\n\t * <p>\n\t * <b>It should be noted that dragging from a BTEditor and dropping onto\n\t * another editor is not supported.</b>\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class BTEditorDropTargetListener implements DropTargetListener {\n\t\tpublic void dragEnter(DropTargetEvent event) {\n\t\t\tfor (int i = 0; i < event.dataTypes.length; i++) {\n\t\t\t\tif (BTNodeIndentifierTransfer.getInstance().isSupportedType(event.dataTypes[i])) {\n\t\t\t\t\tevent.currentDataType = event.dataTypes[i];\n\t\t\t\t\tevent.detail = DND.DROP_MOVE;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (ConceptualBTNodeTransfer.getInstance().isSupportedType(event.dataTypes[i])) {\n\t\t\t\t\tevent.currentDataType = event.dataTypes[i];\n\t\t\t\t\tevent.detail = DND.DROP_MOVE;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic void dragLeave(DropTargetEvent event) {\n\t\t\tevent.detail = DND.DROP_MOVE;\n\t\t}\n\n\t\tpublic void dragOperationChanged(DropTargetEvent event) {\n\t\t\tevent.detail = DND.DROP_MOVE;\n\t\t}\n\n\t\tpublic void dragOver(DropTargetEvent event) {\n\t\t\tif (ConceptualBTNodeTransfer.getInstance().isSupportedType(event.currentDataType)) {\n\t\t\t\tif (event.item == null) {\n\t\t\t\t\tevent.detail = DND.DROP_NONE;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tBTNode node = (BTNode) event.item.getData();\n\n\t\t\t\tif (node.getConceptualNode().getType().equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\t\t/*\n\t\t\t\t\t * The root node is always allowed as a target for inserting\n\t\t\t\t\t * as a child.\n\t\t\t\t\t */\n\t\t\t\t\tevent.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL\n\t\t\t\t\t\t\t| DND.FEEDBACK_EXPAND;\n\t\t\t\t} else {\n\t\t\t\t\t/*\n\t\t\t\t\t * If the target is not the root, then the source node can\n\t\t\t\t\t * be inserted as a child or as a sibling of the target.\n\t\t\t\t\t */\n\t\t\t\t\tif (!closeToBottom((TreeItem) event.item)) {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Cannot move if the limit number of children is\n\t\t\t\t\t\t * exceeded.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (node.getConceptualNode().getNumChildren() != -1) {\n\t\t\t\t\t\t\tif (node.getConceptualNode().getNumChildren() <= node.getNumChildren()) {\n\t\t\t\t\t\t\t\tevent.detail = DND.DROP_NONE;\n\t\t\t\t\t\t\t\tevent.feedback = DND.FEEDBACK_EXPAND;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tevent.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL\n\t\t\t\t\t\t\t\t| DND.FEEDBACK_EXPAND;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Cannot move if the limit number of children is\n\t\t\t\t\t\t * exceeded.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tBTNode parent = node.getParent();\n\n\t\t\t\t\t\tif (parent.getConceptualNode().getNumChildren() != -1) {\n\t\t\t\t\t\t\tif (parent.getConceptualNode().getNumChildren() <= parent\n\t\t\t\t\t\t\t\t\t.getNumChildren()) {\n\t\t\t\t\t\t\t\tevent.detail = DND.DROP_NONE;\n\t\t\t\t\t\t\t\tevent.feedback = DND.FEEDBACK_EXPAND;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tevent.feedback = DND.FEEDBACK_INSERT_AFTER | DND.FEEDBACK_SCROLL\n\t\t\t\t\t\t\t\t| DND.FEEDBACK_EXPAND;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tevent.detail = DND.DROP_MOVE;\n\t\t\t} else if (BTNodeIndentifierTransfer.getInstance().isSupportedType(\n\t\t\t\t\tevent.currentDataType)) {\n\t\t\t\tif (event.item == null) {\n\t\t\t\t\tevent.detail = DND.DROP_NONE;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tBTNode node = (BTNode) event.item.getData();\n\n\t\t\t\t/* Cannot move as a sibling of the root. */\n\t\t\t\tif (node.getConceptualNode().getType().equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\t\tevent.detail = DND.DROP_NONE;\n\t\t\t\t\tevent.feedback = DND.FEEDBACK_EXPAND;\n\t\t\t\t} else {\n\t\t\t\t\tBTNode parent = node.getParent();\n\n\t\t\t\t\tif (!closeToBottom((TreeItem) event.item)) {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Cannot move if the limit number of children is\n\t\t\t\t\t\t * exceeded.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (node.getConceptualNode().getNumChildren() != -1) {\n\t\t\t\t\t\t\tif (node.getConceptualNode().getNumChildren() <= node.getNumChildren()) {\n\t\t\t\t\t\t\t\tevent.detail = DND.DROP_NONE;\n\t\t\t\t\t\t\t\tevent.feedback = DND.FEEDBACK_EXPAND;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tevent.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL\n\t\t\t\t\t\t\t\t| DND.FEEDBACK_EXPAND;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/*\n\t\t\t\t\t\t * Cannot move if the limit number of children is\n\t\t\t\t\t\t * exceeded.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tif (parent.getConceptualNode().getNumChildren() != -1) {\n\t\t\t\t\t\t\tif (parent.getConceptualNode().getNumChildren() <= parent\n\t\t\t\t\t\t\t\t\t.getNumChildren()) {\n\t\t\t\t\t\t\t\tevent.detail = DND.DROP_NONE;\n\t\t\t\t\t\t\t\tevent.feedback = DND.FEEDBACK_EXPAND;\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tevent.feedback = DND.FEEDBACK_INSERT_AFTER | DND.FEEDBACK_SCROLL\n\t\t\t\t\t\t\t\t| DND.FEEDBACK_EXPAND;\n\t\t\t\t\t}\n\n\t\t\t\t\tevent.detail = DND.DROP_MOVE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic void drop(DropTargetEvent event) {\n\t\t\tif (ConceptualBTNodeTransfer.getInstance().isSupportedType(event.currentDataType)) {\n\t\t\t\tPair<String, String> nodeIdentifier = (Pair<String, String>) event.data;\n\t\t\t\tBTNode selectedNode = (BTNode) event.item.getData();\n\n\t\t\t\tConceptualBTNode newConceptualNode = NodesLoader.getNode(nodeIdentifier.getFirst(),\n\t\t\t\t\t\tnodeIdentifier.getSecond());\n\n\t\t\t\t/*\n\t\t\t\t * This is a bit messy.\n\t\t\t\t * \n\t\t\t\t * If the target node (\"selectedNode\") is the root:\n\t\t\t\t * \n\t\t\t\t * 1) If the root has no child, then the dropped node is\n\t\t\t\t * inserted as the child of the root.\n\t\t\t\t * \n\t\t\t\t * 2) If it has one child (the root can only have one child),\n\t\t\t\t * the dropped node is inserted as its new only child, and the\n\t\t\t\t * old one is inserted as a child of the new one. If the dropped\n\t\t\t\t * node does not support children, then the drop operation is\n\t\t\t\t * canceled.\n\t\t\t\t * \n\t\t\t\t * If the target node is not the root, then proceed as usual: the\n\t\t\t\t * dropped node is inserted as a child or as a sibling of the\n\t\t\t\t * target node.\n\t\t\t\t */\n\t\t\t\tif (selectedNode.getConceptualNode().getType()\n\t\t\t\t\t\t.equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\t\tif (selectedNode.getNumChildren() != 0) {\n\t\t\t\t\t\tif (newConceptualNode.getNumChildren() == 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tBTNode newNode = tree.createNode(NodesLoader.getNode(\n\t\t\t\t\t\t\t\t\tnodeIdentifier.getFirst(), nodeIdentifier.getSecond()));\n\n\t\t\t\t\t\t\tBTNode oldRoot = selectedNode.getChildren().get(0);\n\t\t\t\t\t\t\tselectedNode.removeChild(oldRoot);\n\t\t\t\t\t\t\tnewNode.setParent(selectedNode);\n\t\t\t\t\t\t\tselectedNode.addChild(newNode);\n\t\t\t\t\t\t\toldRoot.setParent(newNode);\n\t\t\t\t\t\t\tnewNode.addChild(oldRoot);\n\n\t\t\t\t\t\t\tviewer.refresh(selectedNode);\n\t\t\t\t\t\t\tviewer.expandToLevel(selectedNode, 1);\n\t\t\t\t\t\t\ttreeChanged(viewer);\n\t\t\t\t\t\t\tclearErrors();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tBTNode newNode = tree.createNode(NodesLoader.getNode(nodeIdentifier.getFirst(),\n\t\t\t\t\t\tnodeIdentifier.getSecond()));\n\n\t\t\t\t/*\n\t\t\t\t * Insert the source node as a child or as sibling of the target\n\t\t\t\t * depending on the current relative position of the cursor to\n\t\t\t\t * the target.\n\t\t\t\t */\n\t\t\t\tif (!closeToBottom((TreeItem) event.item)) {\n\t\t\t\t\tnewNode.setParent(selectedNode);\n\t\t\t\t\tselectedNode.addChild(newNode);\n\t\t\t\t\tviewer.expandToLevel(selectedNode, 1);\n\t\t\t\t\tviewer.refresh(selectedNode);\n\n\t\t\t\t} else {\n\t\t\t\t\tselectedNode.addAsSibling(newNode);\n\t\t\t\t\tviewer.refresh(selectedNode.getParent());\n\t\t\t\t}\n\n\t\t\t\ttreeChanged(viewer);\n\t\t\t\tclearErrors();\n\t\t\t}\n\t\t\tif (BTNodeIndentifierTransfer.getInstance().isSupportedType(event.currentDataType)) {\n\t\t\t\tBTNode target = (BTNode) event.item.getData();\n\t\t\t\tIdentifier id = (Identifier) event.data;\n\t\t\t\tBTNode source = tree.findNode(id);\n\n\t\t\t\tif (source.hasAsDescendant(target)) {\n\t\t\t\t\tevent.detail = DND.DROP_NONE;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t/*\n\t\t\t\t * Insert the source node as a child or as sibling of the target\n\t\t\t\t * depending on the current relative position of the cursor to\n\t\t\t\t * the target.\n\t\t\t\t */\n\t\t\t\tif (!closeToBottom((TreeItem) event.item)) {\n\t\t\t\t\ttarget.addChild(source);\n\t\t\t\t\tsource.getParent().removeChild(source);\n\t\t\t\t\tsource.setParent(target);\n\t\t\t\t} else {\n\t\t\t\t\ttarget.addAsSibling(source);\n\t\t\t\t}\n\n\t\t\t\tviewer.refresh();\n\t\t\t\tviewer.expandToLevel(target, 1);\n\t\t\t\ttreeChanged(viewer);\n\t\t\t\tclearErrors();\n\t\t\t}\n\t\t}\n\n\t\tpublic void dropAccept(DropTargetEvent event) {\n\t\t}\n\n\t\t/**\n\t\t * Given a TreeItem of the tree, this function analyses whether the\n\t\t * current cursor position is close to its bottom or not. This is used\n\t\t * to tell whether the dropped element is inserted as a child or as a\n\t\t * sibling of the target node.\n\t\t * \n\t\t * @return true if the cursor position is close to the bottom of\n\t\t *         <code>treeItem</code>.\n\t\t */\n\t\tprivate boolean closeToBottom(TreeItem treeItem) {\n\t\t\tDisplay display = treeItem.getDisplay();\n\t\t\tPoint cursorLocation = treeItem.getDisplay().getCursorLocation();\n\t\t\tRectangle itemLocation = treeItem.getBounds();\n\t\t\tint height = viewer.getTree().getItemHeight();\n\t\t\tint margin = ((int) height * 0.20) <= 1 ? 1 : (int) (height * 0.20);\n\n\t\t\t/*\n\t\t\t * If the margin is null, return true, since insertion as sibling\n\t\t\t * prevails over insertion as child.\n\t\t\t */\n\t\t\tif (margin == 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tint limitHeight = itemLocation.y + height - 1 - margin;\n\n\t\t\tPoint mappedCoords = display.map(null, viewer.getTree(), cursorLocation);\n\n\t\t\tif (mappedCoords.y >= limitHeight) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Method that is called when the tree has experimented a change. This will\n\t * notify all the listeners of the underlying tree by firing a\n\t * {@link TreeModifiedEvent}.\n\t */\n\tprivate void treeChanged(Object source) {\n\t\tthis.tree.fireTreeChanged(source);\n\t}\n\n\t/**\n\t * Opens a BTEditor for editing the guard of a BTNode.\n\t */\n\tprivate void openGuardEditor(final BTNode node) throws PartInitException {\n\t\tIWorkbenchPage activePage = Utilities.getMainWindowActivePage();\n\n\t\tBTEditorInput editorInput = new BTEditorInput(\n\t\t\t\t((BTEditorInput) getEditorInput()).getEditorID() + File.pathSeparator\n\t\t\t\t\t\t+ node.getID().toString(), false, true);\n\n\t\tBTEditor openEditor = (BTEditor) activePage.openEditor(editorInput, BTEditor.ID);\n\n\t\tif (!openGuardEditors.containsKey(node)) {\n\t\t\topenGuardEditors.put(node, openEditor);\n\t\t}\n\t}\n\n\t/**\n\t * The IPartListener that BTEditors use to manage close events. When a\n\t * BTEditor is closed, two things happen:\n\t * \n\t * <ul>\n\t * <li>If this is an BTEditor that contains nodes whose guards are being\n\t * edited in other editors, then those editors are dissociated from its\n\t * corresponding tree, so that they are no longer editing a guard, but a\n\t * normal behaviour tree.\n\t * <li>If this is a BTEditor that is editing a guard, then it removes itself\n\t * from the list of BTEditors {@link BTEditor#openGuardEditors}.\n\t * </ul>\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class BTEditorPartListener implements IPartListener {\n\t\tpublic void partActivated(IWorkbenchPart part) {\n\t\t}\n\n\t\tpublic void partBroughtToTop(IWorkbenchPart part) {\n\t\t}\n\n\t\tpublic void partClosed(IWorkbenchPart part) {\n\t\t\t/*\n\t\t\t * Must be kept in mind that this IPartListener is shared among all\n\t\t\t * the editors, so trying to acces \"this\" will just not work. The\n\t\t\t * BTEditor that is closed is the input argument \"part\".\n\t\t\t */\n\t\t\tif (part instanceof BTEditor) {\n\t\t\t\t/*\n\t\t\t\t * First dissociate all the editors that are editing nodes'\n\t\t\t\t * guards of this tree.\n\t\t\t\t */\n\t\t\t\tBTEditor editorToClose = (BTEditor) part;\n\t\t\t\tCollection<BTEditor> guardEditors = editorToClose.openGuardEditors.values();\n\n\t\t\t\tfor (BTEditor editor : guardEditors) {\n\t\t\t\t\tBTEditorInput editorInput = (BTEditorInput) editor.getEditorInput();\n\t\t\t\t\teditorInput.setTreeName(editorInput.getName());\n\t\t\t\t\teditor.dissociateFromParentTree();\n\t\t\t\t\teditor.dirty = true;\n\t\t\t\t\teditor.firePropertyChange(PROP_TITLE);\n\t\t\t\t\teditor.firePropertyChange(PROP_DIRTY);\n\t\t\t\t}\n\n\t\t\t\t// if (guardEditors.size() != 0) {\n\t\t\t\t// StandardDialogs\n\t\t\t\t// .informationDialog(\n\t\t\t\t// \"Guards still open\",\n\t\t\t\t// \"The closed behaviour tree contained some open guards. They have been dissociated from the tree, but they are kept open.\");\n\t\t\t\t// }\n\n\t\t\t\tguardEditors.clear();\n\n\t\t\t\t/*\n\t\t\t\t * Then, if this editor is editing a guard, remove itself from\n\t\t\t\t * the \"openGuardEditors\" list of the editor that contains the\n\t\t\t\t * tree that has the node whose guard is being edited by this\n\t\t\t\t * editor.\n\t\t\t\t */\n\t\t\t\tif (editorToClose.isFromGuard()) {\n\t\t\t\t\tBTEditorInput editorInput = (BTEditorInput) editorToClose.getEditorInput();\n\t\t\t\t\tString[] pieces = editorInput.getTreeName().split(File.pathSeparator);\n\t\t\t\t\tlong parentEditorID = Long.parseLong(pieces[0]);\n\t\t\t\t\tBTEditor parentEditor = Utilities.getBTEditor(parentEditorID);\n\t\t\t\t\tif (parentEditor != null) {\n\t\t\t\t\t\tparentEditor.openGuardEditors.remove(editorToClose.guardNode);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic void partDeactivated(IWorkbenchPart part) {\n\t\t}\n\n\t\tpublic void partOpened(IWorkbenchPart part) {\n\t\t}\n\t}\n\n\t/**\n\t * This is used for BTEditors that are editing guards. It dissociates the\n\t * BTEditor from the tree that contains the node whose guard is being\n\t * edited. By doing so, this editor will be considered not to come from a guard\n\t * (<code>setIsFromGuard(false)</code>), so it will change its title image to\n\t * that of a normal BT. Also, {@link BTEditor#guardNode} and\n\t * {@link BTEditor#guardTree} are set to null. Finally, the root node of the\n\t * tree (that of type ROOT) is modified so that it is a normal ROOT node\n\t * (that is, it can have a name).\n\t */\n\tprivate void dissociateFromParentTree() {\n\t\tif (isFromGuard()) {\n\t\t\tthis.setIsFromGuard(false);\n\t\t\tthis.setTitleImage(ApplicationIcons.getIcon(IconsPaths.BT));\n\n\t\t\tBTNode newRoot = this.tree.createNode(NodesLoader.getNode(\n\t\t\t\t\tNodeInternalType.ROOT.toString(), null));\n\n\t\t\tif (this.tree.getRoot().getChildren().size() != 0) {\n\t\t\t\tnewRoot.addChild(this.tree.getRoot().getChildren().get(0));\n\t\t\t}\n\n\t\t\tthis.tree.setRoot(newRoot);\n\t\t\tthis.guardNode = null;\n\t\t\tthis.guardTree = null;\n\t\t\tthis.viewer.refresh();\n\t\t\tthis.viewer.expandAll();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/editor/BTEditorCopyAndPasteManager.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.editor;\n\nimport jbt.tools.bteditor.model.BTNode;\n\n/**\n * This class manages the copy and paste mechanism implemented by the\n * {@link BTEditor} class.\n * <p>\n * This class offers two main methods, {@link #copy(BTNode)} and\n * {@link #paste()}. When <code>copy()</code> gets called, the\n * BTEditorCopyAndPasteManager creates a copy (by cloning) of the BTNode to\n * copy. From then on, whenever <code>paste()</code> is called, a new copy (by\n * cloning) of it is returned.\n * <p>\n * This is a singleton class, so there is only one instance of\n * BTEditorCopyAndPasteManager.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTEditorCopyAndPasteManager {\n\t/** The only instance of BTEditorCopyAndPasteManager. */\n\tprivate static BTEditorCopyAndPasteManager instance;\n\t/** The BTNode that has been copied. */\n\tprivate BTNode copiedBranch;\n\n\t/**\n\t * Copies the node <code>branchToCopy</code>. This makes the\n\t * BTEditorCopyAndPasteManager store a copy (by calling\n\t * {@link BTNode#clone()}) of <code>branchToCopy</code>. From then on,\n\t * {@link #paste()} will return a copy of the copy created by this method.\n\t */\n\tpublic void copy(BTNode branchToCopy) {\n\t\tthis.copiedBranch = branchToCopy.clone();\n\t}\n\n\t/**\n\t * This method can be called only after {@link #copy(BTNode)} has been\n\t * called. This method returns a copy (by invoking {@link BTNode#clone()})\n\t * of the node that was copied by {@link #copy(BTNode)}.\n\t */\n\tpublic BTNode paste() {\n\t\treturn this.copiedBranch.clone();\n\t}\n\n\t/**\n\t * Returns the only instance of BTEditorCopyAndPasteManager.\n\t */\n\tpublic static BTEditorCopyAndPasteManager getInstance() {\n\t\tif (instance == null) {\n\t\t\tinstance = new BTEditorCopyAndPasteManager();\n\t\t}\n\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Returns true if a {@link #copy(BTNode)} operation has been made, or false\n\t * if not.\n\t */\n\tpublic boolean hasCopy() {\n\t\treturn this.copiedBranch != null;\n\t}\n\n\t/**\n\t * Private constructor to force the singleton pattern.\n\t */\n\tprivate BTEditorCopyAndPasteManager() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/editor/BTEditorIDGenerator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.editor;\n\n/**\n * A singleton class that generates IDs for BTEditor objects. Every new BTEditor\n * has an unique ID which is represented as a long value.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTEditorIDGenerator {\n\t/** The only instance of this class. */\n\tprivate static BTEditorIDGenerator instance;\n\t/** Counter for generated IDs. */\n\tprivate long counter = 0;\n\n\t/**\n\t * Returns the only instance of BTEditorIDGenerator.\n\t */\n\tpublic static BTEditorIDGenerator getInstance() {\n\t\tif (instance == null) {\n\t\t\tinstance = new BTEditorIDGenerator();\n\t\t}\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Returns the next BTEditor ID.\n\t */\n\tpublic long getNextID() {\n\t\treturn this.counter++;\n\t}\n\n\t/**\n\t * Private constructor to force the singleton pattern.\n\t */\n\tprivate BTEditorIDGenerator() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/editor/BTEditorInput.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.editor;\n\nimport java.io.File;\n\nimport jbt.tools.bteditor.util.Utilities;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.ui.IEditorInput;\nimport org.eclipse.ui.IPersistableElement;\n\n/**\n * EditorInput for a {@link BTEditor_}.\n * <p>\n * The BTEditorInput is used when creating a new BTEditor. It contains the name\n * of the tree and several fields that indicate where the tree comes from.\n * <p>\n * A behaviour tree may have three different origins:\n * <ul>\n * <li>New behaviour tree, in which case the tree is created from scratch (it is\n * a new empty tree).\n * <li>From a file, in which case the name of the tree is used as the name of\n * the file that contains the tree.\n * <li>From a node's guard, in which case the tree name must be the ID of the\n * editor (see {@link BTEditorIDGenerator}) that contains the tree that contains\n * the guard, followed by the {@link File#separatorChar}, followed by the ID of\n * the node that contains such guard. For instance, on Windows, a valid name\n * would be \"23;Node_17\"\n * </ul>\n * \n * The BTEditorInput also contains the ID of its corresponding BTEditor. Such ID\n * is generated by the BTEditorInput at construction time through the class\n * {@link BTEditorIDGenerator}.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTEditorInput implements IEditorInput {\n\t/**\n\t * Name of the tree. If {@link #isFromFile} is true, then it represents the\n\t * name of the file that contains the tree that will be loaded when opening\n\t * the editor.\n\t */\n\tprivate String treeName;\n\t/** Flag that indicates if the tree comes from a file or not. */\n\tprivate boolean isFromFile;\n\t/** Flag that indicates if the tree comes from a guard. */\n\tprivate boolean isFromGuard;\n\t/** The ID of the editor associated to this guard. */\n\tprivate long editorID;\n\t/**\n\t * In case the tree comes from a guard, this stores the name and tooltip\n\t * returned by {@link #getName()} and {@link #getToolTipText()}.\n\t */\n\tprivate String guardsName;\n\n\t/**\n\t * Constructor. Constructs a new BTEditorInput for opening a BTEditor. The\n\t * behaviour tree that is loaded into the BTEditor depends on the\n\t * BTEditorInput. Actually, a behaviour tree may have three different\n\t * origins:\n\t * \n\t * <ul>\n\t * <li>New behaviour tree, in which case the tree is created from scratch\n\t * (it is a new empty tree), <code>treeName</code> is the name of the tree,\n\t * <code>isFromFile</code> must be false and <code>isFromGuard</code> must\n\t * be false.\n\t * <li>From a file, in which case <code>treeName</code> is used as the name\n\t * of the file that contains the tree, <code>isFromFile</code> must be true\n\t * and <code>isFromGuard</code> must be false.\n\t * <li>From a node's guard, in which case <code>treeName</code> must be the\n\t * ID of the editor (see {@link BTEditorIDGenerator}) that contains the tree\n\t * that contains the guard, followed by the {@link File#separatorChar},\n\t * followed by the ID of the node that contains such guard. For instance, on\n\t * Windows, a valid name would be \"23;Node_17\". <code>isFromFile</code> must\n\t * be false and <code>isFromGuard</code> must be true.\n\t * </ul>\n\t * \n\t * \n\t * @param treeName\n\t *            the name of the tree.\n\t * @param isFromFile\n\t *            true if the tree must be loaded from a file, and false\n\t *            otherwise. Note that <code>isFromFile</code> and\n\t *            <code>isFromGuard</code> cannot be both true.\n\t * @param isFromGuard\n\t *            true if the tree comes from a guard, and false otherwise. Note\n\t *            that <code>isFromFile</code> and <code>isFromGuard</code>\n\t *            cannot be both true.\n\t */\n\tpublic BTEditorInput(String treeName, boolean isFromFile, boolean isFromGuard) {\n\t\tthis.treeName = treeName;\n\t\tthis.isFromFile = isFromFile;\n\t\tthis.isFromGuard = isFromGuard;\n\n\t\tif (this.isFromFile == this.isFromGuard && this.isFromFile) {\n\t\t\tthrow new RuntimeException(\"A tree cannot come both from a file and from a guard\");\n\t\t}\n\n\t\tthis.editorID = BTEditorIDGenerator.getInstance().getNextID();\n\n\t\tif (this.isFromGuard) {\n\t\t\tString[] pieces = this.treeName.split(File.pathSeparator);\n\t\t\tBTEditor editor = Utilities.getBTEditor(Long.parseLong(pieces[0]));\n\t\t\tthis.guardsName = \"Guard of \" + pieces[1] + \" in \"\n\t\t\t\t\t+ ((BTEditorInput) editor.getEditorInput()).getName();\n\t\t}\n\t}\n\n\t/**\n\t * Returns the name of the tree.\n\t * <p>\n\t * If {@link #isFromFile()} is true, this name is the name of the file that\n\t * contains the tree.\n\t * <p>\n\t * If {@link #isFromGuard()} is true, this is the ID of the editor (see\n\t * {@link BTEditorIDGenerator}) that contains the tree that contains the\n\t * guard, followed by the {@link File#separatorChar}, followed by the ID of\n\t * the node that contains such guard.\n\t * \n\t */\n\tpublic String getTreeName() {\n\t\treturn this.treeName;\n\t}\n\n\t/**\n\t * Sets the name of the tree.\n\t * <p>\n\t * If {@link #isFromFile()} is true, this name must be the name of the file\n\t * that contains the tree.\n\t * <p>\n\t * If {@link #isFromGuard()} is true, this must be the ID of the editor (see\n\t * {@link BTEditorIDGenerator}) that contains the tree that contains the\n\t * guard, followed by the {@link File#separatorChar}, followed by the ID of\n\t * the node that contains such guard.\n\t */\n\tpublic void setTreeName(String treeName) {\n\t\tthis.treeName = treeName;\n\t}\n\n\t/**\n\t * Returns if the tree comes from a file.\n\t */\n\tpublic boolean isFromFile() {\n\t\treturn this.isFromFile;\n\t}\n\n\t/**\n\t * Sets if the tree comes from a file.\n\t */\n\tpublic void setIsFromFile(boolean isFromFile) {\n\t\tthis.isFromFile = isFromFile;\n\t}\n\n\t/**\n\t * Returns true if the tree comes from a guard, and false otherwise.\n\t */\n\tpublic boolean isFromGuard() {\n\t\treturn isFromGuard;\n\t}\n\n\t/**\n\t * Sets if the tree comes from a guard.\n\t */\n\tpublic void setIsFromGuard(boolean isFromGuard) {\n\t\tthis.isFromGuard = isFromGuard;\n\t}\n\n\t/**\n\t * Returns the ID of the BTEditor managed by this BTEditorInput.\n\t */\n\tpublic long getEditorID() {\n\t\treturn this.editorID;\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.IEditorInput#exists()\n\t */\n\tpublic boolean exists() {\n\t\treturn false;\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.IEditorInput#getImageDescriptor()\n\t */\n\tpublic ImageDescriptor getImageDescriptor() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * <ul>\n\t * <li>If {@link #isFromFile()} is true, then returns the short version of\n\t * the file returned by {@link #getTreeName()}..\n\t * <li>If {@link #isFromGuard()} is true, returns\n\t * <code>Guard of XXXX in YYYY</code>, where <code>XXXX</code> is the ID of\n\t * the guard the tree comes from, and <code>YYYY</code> is the name of the\n\t * tree (as obtained by this {@link #getName()}) that contains the guard.\n\t * <li>If both are false, then returns {@link #getTreeName()}.\n\t * \n\t * @see org.eclipse.ui.IEditorInput#getName()\n\t */\n\tpublic String getName() {\n\t\tif (this.isFromFile) {\n\t\t\tFile f = new File(this.treeName);\n\t\t\treturn f.getName();\n\t\t} else if (this.isFromGuard) {\n\t\t\treturn this.guardsName;\n\t\t} else {\n\t\t\treturn this.treeName;\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.IEditorInput#getPersistable()\n\t */\n\tpublic IPersistableElement getPersistable() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * If {@link #isFromFile()} is false or {@link #isFromGuard()} is false,\n\t * this method returns {@link #getTreeName()}. If {@link #isFromGuard()} is\n\t * true, returns {@link #getName()}.\n\t * \n\t * @see org.eclipse.ui.IEditorInput#getToolTipText()\n\t */\n\tpublic String getToolTipText() {\n\t\tif (this.isFromGuard) {\n\t\t\treturn getName();\n\t\t}\n\t\treturn getTreeName();\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)\n\t */\n\tpublic Object getAdapter(Class adapter) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * \n\t * @see java.lang.Object#equals(java.lang.Object)\n\t */\n\tpublic boolean equals(Object o) {\n\t\tif (o == this) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (!(o instanceof BTEditorInput)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tBTEditorInput input = (BTEditorInput) o;\n\n\t\tif (this.treeName.equals(input.treeName) && (this.isFromFile == input.isFromFile)\n\t\t\t\t&& (this.isFromGuard == input.isFromGuard)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/event/ITreeModifierListener.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.event;\n\nimport jbt.tools.bteditor.model.BT;\n\n/**\n * Interface for those entities that listen to changes in a behaviour tree (\n * {@link BT})\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic interface ITreeModifierListener {\n\t/**\n\t * Called when a change in the BT that is being listened occurs.\n\t */\n\tpublic void treeModified(TreeModifiedEvent event);\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/event/TreeModifiedEvent.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.event;\n\nimport java.util.EventObject;\n\nimport jbt.tools.bteditor.model.BT;\n\n/**\n * Event issued when a {@link BT} is modified.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class TreeModifiedEvent extends EventObject {\n\tprivate static final long serialVersionUID = 1L;\n\tprivate BT tree;\n\n\t/**\n\t * Constructor. Must specify the tree that has been modified.\n\t */\n\tpublic TreeModifiedEvent(Object source, BT tree) {\n\t\tsuper(source);\n\t\tthis.tree = tree;\n\t}\n\n\t/**\n\t * Returns the tree that has been modified.\n\t */\n\tpublic BT getTree() {\n\t\treturn this.tree;\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/model/BT.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.model;\n\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.event.ITreeModifierListener;\nimport jbt.tools.bteditor.event.TreeModifiedEvent;\nimport jbt.tools.bteditor.model.BTNode.Identifier;\nimport jbt.tools.bteditor.model.ConceptualBTNode.Parameter;\nimport jbt.tools.bteditor.model.ConceptualBTNode.ParameterType;\n\n/**\n * A BT represents a behaviour tree that can be edited, loaded and exported. This type of trees is\n * edited in the {@link BTEditor_}. A BT only stores the root of the tree, which is a {@link BTNode}\n * .\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BT {\n\t/** The root of the tree. */\n\tprivate BTNode root;\n\t/**\n\t * Counter of how many nodes have been created through the {@link #createNode(ConceptualBTNode)}\n\t * . This counter is used when generating ids for nodes of this tree.\n\t */\n\tprivate long nodeCounter = 0;\n\t/** Listeners that are listening to changes in the tree. */\n\tprivate List<ITreeModifierListener> listeners = new Vector<ITreeModifierListener>();\n\n\t/**\n\t * Default constructor. Constructs a BT with no root.\n\t */\n\tpublic BT() {\n\t}\n\n\t/**\n\t * Constructs a BT with a root.\n\t */\n\tpublic BT(BTNode root) {\n\t\tthis.root = root;\n\t\tupdateNodeCounter();\n\t}\n\n\t/**\n\t * Sets the root of the tree.\n\t */\n\tpublic void setRoot(BTNode root) {\n\t\tthis.root = root;\n\t\tupdateNodeCounter();\n\t}\n\n\t/**\n\t * Returns the root of the tree or null in case it has not been set.\n\t */\n\tpublic BTNode getRoot() {\n\t\treturn this.root;\n\t}\n\n\t/**\n\t * Finds a node in the tree, by using an identifier. Returns null if not found.\n\t */\n\tpublic BTNode findNode(Identifier id) {\n\t\treturn internalFindNode(this.root, id);\n\t}\n\n\t/**\n\t * Creates a BTNode from a ConceptualBTNode for this tree. This method creates a BTNode and sets\n\t * its ID to an unique identifier for the tree. Also it sets the underlying conceptual node of\n\t * the BTNode to <code>conceptualNode</code>.\n\t */\n\tpublic BTNode createNode(ConceptualBTNode conceptualNode) {\n\t\tBTNode node = new BTNode(new Identifier(nodeCounter));\n\t\tnodeCounter++;\n\t\tnode.setConceptualNode(conceptualNode);\n\t\tnode.setBT(this);\n\t\treturn node;\n\t}\n\n\t/**\n\t * Adds a listener that will be notified when changes in the tree occur.\n\t */\n\tpublic void addTreeModifiedListener(ITreeModifierListener listener) {\n\t\tthis.listeners.add(listener);\n\t}\n\n\t/**\n\t * This method must be called when there is a change in the tree. By doing so, all entities that\n\t * are listening to changes in the tree will be notified.\n\t */\n\tpublic void fireTreeChanged(Object source) {\n\t\tfor (ITreeModifierListener l : this.listeners) {\n\t\t\tl.treeModified(new TreeModifiedEvent(source, this));\n\t\t}\n\t}\n\n\t/**\n\t * Checks the validity of all the nodes of the tree. Returns a list with the nodes that contain\n\t * errors.\n\t */\n\tpublic List<BTNode> checkTree() {\n\t\tList<BTNode> nodes = new Vector<BTNode>();\n\t\tinternalCheckTree(this.root, nodes);\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * Clear the errors of all of the nodes of the tree.\n\t */\n\tpublic void clearErrors() {\n\t\tinternalClearErrors(this.root);\n\t}\n\n\t/**\n\t * Given a BTNode, this method recompute its ID as well as the IDs of all its children and\n\t * guards. After calling this method, these IDs will not clash any of those of this BT's nodes.\n\t * This method can be used, for example, when a whole branch must be added to this tree. In such\n\t * case, this method can be used to recompute the IDs of the nodes of the branch so that there\n\t * is no conflict among IDs.\n\t * <p>\n\t * It is important to notice that after recomputing the IDs, they are still consistent among\n\t * each other. For instance, if before recomputing the ID a node <i>A</i> had ID \"Node_34\", and\n\t * it referenced by another node <i>B</i>, after recomputing IDs the reference will still be\n\t * valid (it will not be \"Node_34\", but whatever new ID <i>A</i> has will be properly referenced\n\t * by <i>B</i>).\n\t * \n\t * @param node\n\t *            the root of the branch (tree) whose nodes will get their IDs recomputed.\n\t */\n\tpublic void recomputeIDs(BTNode node) {\n\t\tIdentifier largestID = computeLargestID(this.root);\n\t\tIdentifier lowestID = computeLowestID(node);\n\t\treassignIDs(node, largestID.getValue() - lowestID.getValue() + 1);\n\t}\n\n\t/**\n\t * Given a BTNode, this method sets, as the current underlying BT of <code>node</code> and all\n\t * of its descendants (including guards), this BT.\n\t * \n\t * @param node\n\t *            the root of the branch (tree) whose underlying BT will be modified.\n\t */\n\tpublic void reassignUnderlyingBT(BTNode node) {\n\t\tnode.setBT(this);\n\n\t\tfor (BTNode child : node.getChildren()) {\n\t\t\treassignUnderlyingBT(child);\n\t\t}\n\n\t\tif (node.getGuard() != null) {\n\t\t\treassignUnderlyingBT(node.getGuard());\n\t\t}\n\t}\n\n\t/**\n\t * Reassigns the all the IDs in the branch whose root is <code>node</code>. This method just\n\t * adds <code>offset</code> to the value of all the nodes (including guards) of the branch.\n\t */\n\tprivate void reassignIDs(BTNode node, long offset) {\n\t\tnode.getID().setValue(node.getID().getValue() + offset);\n\n\t\t/* If some parameter has type \"node_id\", then it must be changed too. */\n\t\tif (node.getParameters().size() != 0) {\n\t\t\tfor (int i = 0; i < node.getConceptualNode().getParameters().size(); i++) {\n\t\t\t\tParameter cParameter = node.getConceptualNode().getParameters().get(i);\n\t\t\t\tif (cParameter.getType() == ParameterType.NODE_ID) {\n\t\t\t\t\tIdentifier newValue = new Identifier(node.getParameters().get(i).getValue());\n\t\t\t\t\tnewValue.setValue(newValue.getValue() + offset);\n\t\t\t\t\tnode.getParameters().get(i).setValue(newValue.toString());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (BTNode child : node.getChildren()) {\n\t\t\treassignIDs(child, offset);\n\t\t}\n\n\t\tif (node.getGuard() != null) {\n\t\t\treassignIDs(node.getGuard(), offset);\n\t\t}\n\t}\n\n\t/**\n\t * Computes the largest ID of a whole branch of a BT (including guards). The root of the branch\n\t * is <code>node</code>.\n\t */\n\tprivate Identifier computeLargestID(BTNode node) {\n\t\tIdentifier largestKnownID = node.getID().clone();\n\t\tfor (BTNode child : node.getChildren()) {\n\t\t\tcomputeLargestID(child, largestKnownID);\n\t\t}\n\n\t\tif (node.getGuard() != null) {\n\t\t\tIdentifier guardLargestIdentifier = computeLargestID(node.getGuard());\n\t\t\tif (guardLargestIdentifier.getValue() > largestKnownID.getValue()) {\n\t\t\t\tlargestKnownID.setValue(guardLargestIdentifier.getValue());\n\t\t\t}\n\t\t}\n\n\t\treturn largestKnownID;\n\t}\n\n\t/**\n\t * Stores into <code>largestKnownID</code> (which initially must be a valid Identifier for the\n\t * BT) the largest Identifier of the nodes in <code>node</code> (including guards).\n\t */\n\tprivate void computeLargestID(BTNode node, Identifier largestKnownID) {\n\t\tif (node.getID().getValue() > largestKnownID.getValue()) {\n\t\t\tlargestKnownID.setValue(node.getID().getValue());\n\t\t}\n\n\t\tfor (BTNode currentChild : node.getChildren()) {\n\t\t\tcomputeLargestID(currentChild, largestKnownID);\n\t\t}\n\n\t\tif (node.getGuard() != null) {\n\t\t\tIdentifier guardLargestIdentifier = computeLargestID(node.getGuard());\n\t\t\tif (guardLargestIdentifier.getValue() > largestKnownID.getValue()) {\n\t\t\t\tlargestKnownID.setValue(guardLargestIdentifier.getValue());\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Computes the lowest ID of a whole branch of a BT (including guards). The root of the branch\n\t * is <code>node</code>.\n\t */\n\tprivate Identifier computeLowestID(BTNode node) {\n\t\tIdentifier lowestKnownID = node.getID().clone();\n\t\tfor (BTNode child : node.getChildren()) {\n\t\t\tcomputeLowestID(child, lowestKnownID);\n\t\t}\n\n\t\tif (node.getGuard() != null) {\n\t\t\tIdentifier guardLowestIdentifier = computeLowestID(node.getGuard());\n\t\t\tif (guardLowestIdentifier.getValue() < lowestKnownID.getValue()) {\n\t\t\t\tlowestKnownID.setValue(guardLowestIdentifier.getValue());\n\t\t\t}\n\t\t}\n\n\t\treturn lowestKnownID;\n\t}\n\n\t/**\n\t * Stores into <code>lowestKnownID</code> (which initially must be a valid Identifier for the\n\t * BT) the lowest Identifier of the nodes in <code>node</code> (including guards).\n\t */\n\tprivate void computeLowestID(BTNode node, Identifier lowestKnownID) {\n\t\tif (node.getID().getValue() < lowestKnownID.getValue()) {\n\t\t\tlowestKnownID.setValue(node.getID().getValue());\n\t\t}\n\n\t\tfor (BTNode currentChild : node.getChildren()) {\n\t\t\tcomputeLowestID(currentChild, lowestKnownID);\n\t\t}\n\n\t\tif (node.getGuard() != null) {\n\t\t\tIdentifier guardLowestIdentifier = computeLowestID(node.getGuard());\n\t\t\tif (guardLowestIdentifier.getValue() < lowestKnownID.getValue()) {\n\t\t\t\tlowestKnownID.setValue(guardLowestIdentifier.getValue());\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clear the errors of the nodes of the tree whose root is <code>node</code> .\n\t */\n\tprivate void internalClearErrors(BTNode node) {\n\t\tnode.clearErrors();\n\t\tfor (BTNode child : node.getChildren()) {\n\t\t\tinternalClearErrors(child);\n\t\t}\n\t}\n\n\t/**\n\t * Checks the validity of all the nodes of the tree whose root is <code>node</code>, and stores\n\t * those that are incorrect into <code>ids</code>.\n\t */\n\tprivate void internalCheckTree(BTNode node, List<BTNode> nodes) {\n\t\tif (!node.check()) {\n\t\t\tnodes.add(node);\n\t\t}\n\t\tfor (BTNode child : node.getChildren()) {\n\t\t\tinternalCheckTree(child, nodes);\n\t\t}\n\t}\n\n\t/**\n\t * Finds a node by identifier, starting the search in <code>currentNode</code>. This is a\n\t * recursive method that is called again on the children. Returns null if the node cannot be\n\t * found.\n\t */\n\tprivate BTNode internalFindNode(BTNode currentNode, Identifier id) {\n\t\tif (currentNode.getID().equals(id)) {\n\t\t\treturn currentNode;\n\t\t}\n\n\t\tfor (BTNode n : currentNode.getChildren()) {\n\t\t\tBTNode nodeFound = internalFindNode(n, id);\n\t\t\tif (nodeFound != null) {\n\t\t\t\treturn nodeFound;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Updates the internal counter that the BT uses to create nodes via\n\t * {@link #createNode(ConceptualBTNode)}, so that the counter is bigger than the biggest number\n\t * associated to any of the node's identifiers in the tree. This method should be called when\n\t * the tree gets removed or added nodes. Note that it is automatically called when\n\t * {@link #setRoot(BTNode)} is called.\n\t */\n\tpublic void updateNodeCounter() {\n\t\tthis.nodeCounter = 1;\n\t\trecursiveUpdateNodeCounter(this.root);\n\t}\n\n\t/**\n\t * Updates the field {@link #nodeCounter} so that the counter is bigger than the biggest number\n\t * associated to any of the identifiers of descendants of\n\t * <code>currentNode<code> (including itself).\n\t */\n\tprivate void recursiveUpdateNodeCounter(BTNode currentNode) {\n\t\tlong order = currentNode.getID().getValue();\n\n\t\tif (order >= this.nodeCounter) {\n\t\t\tthis.nodeCounter = order + 1;\n\t\t}\n\n\t\tfor (BTNode child : currentNode.getChildren()) {\n\t\t\trecursiveUpdateNodeCounter(child);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/model/BTNode.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.model;\n\nimport java.io.Serializable;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Observable;\nimport java.util.Observer;\nimport java.util.Vector;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nimport jbt.tools.bteditor.model.ConceptualBTNode.NodeInternalType;\nimport jbt.tools.bteditor.model.ConceptualBTNode.ParameterType;\n\n/**\n * The node of a behaviour tree that can be edited by the {@link BTEditor_}.\n * These are the nodes that a {@link BT} is composed of.\n * <p>\n * A BTNode stores a list with the parameters of the node and their value. It\n * also stores the list of children of the node (which are other BTNode\n * objects). A BTNode also has a parent (or null in case it is the root of the\n * tree). A BTNode has an identifier ({@link Identifier}) that must be unique\n * among the nodes of the tree.\n * <p>\n * A BTNode also stores a reference to a {@link ConceptualBTNode}. The\n * ConceptualBTNode is used for getting conceptual information about the node.\n * It could be said that, on the one hand, the ConceptualBTNode stores the\n * conceptual structure of the node, while on the other, the BTNode stores a\n * particular instance of a ConceptualBTNode (that is, the children the node\n * has, as well as values for each parameter).\n * <p>\n * For a particular BT, BTNode objects should be created through\n * {@link BT#createNode(ConceptualBTNode)}.\n * <p>\n * This class extends {@link Observable} so that {@link Observer}s can be\n * notified when changes take place. Basically, all the methods that somehow\n * change the BTNode will notify all Observers by calling\n * {@link #notifyObservers()}. Even this may not seem very efficient, we do not\n * have strong constraints on the performance of this application.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class BTNode extends Observable implements Serializable {\n\tprivate static final long serialVersionUID = 1L;\n\t/** Name of the node. This is used only for the root of the tree. */\n\tprivate String name;\n\t/** List of the parameters of the node. */\n\tprivate List<Parameter> parameters;\n\t/** List of the children of the node. */\n\tprivate List<BTNode> children;\n\t/** Guard of the node. */\n\tprivate BTNode guard;\n\t/** Parent of the node. May be null if it has no parent. */\n\tprivate BTNode parent;\n\t/** The underlying conceptual node. */\n\tprivate ConceptualBTNode conceptualNode;\n\t/**\n\t * The current error message of the node. This is set when the node is\n\t * checked, and contains a description of any error found in the node.\n\t */\n\tprivate String errorMessage;\n\t/** Identifier of the node. */\n\tprivate Identifier ID;\n\t/** BT that the BTNode belongs to. */\n\tprivate BT tree;\n\t/** Pattern for verifying {@link ParameterType#LIST_OF_VARIABLES} values. */\n\tprivate static final Pattern pattern = Pattern.compile(\"(( )*\\\"[a-zA-Z_0-9\\\\s]+\\\"( )*)+\");\n\n\t/**\n\t * Identifier of a node. The identifier of a node is an integer, and its\n\t * representation as a String is \"Node_X\", where \"X\" is the integer. Note\n\t * that the integer must not be a negative value.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static class Identifier implements Serializable {\n\t\tprivate static final long serialVersionUID = 1L;\n\t\t/**\n\t\t * The identifier is just an integer value. The string version of the\n\t\t * identifier is \"Node_X\", where \"X\" is #value.\n\t\t */\n\t\tprivate long value;\n\n\t\t/**\n\t\t * Constructs an Identifier from a long value.\n\t\t */\n\t\tpublic Identifier(long value) {\n\t\t\tif (value < 0) {\n\t\t\t\tthrow new RuntimeException(\"Negative value are not allowed.\");\n\t\t\t}\n\t\t\tthis.value = value;\n\t\t}\n\n\t\t/**\n\t\t * Constructs an Identifier from a String. The String must be of the\n\t\t * form \"Node_X\", where \"X\" is a non-negative number. <code>id</code> is\n\t\t * initially trimmed.\n\t\t * \n\t\t * @param id\n\t\t */\n\t\tpublic Identifier(String id) {\n\t\t\ttry {\n\t\t\t\tString newID = id.trim();\n\t\t\t\tString[] pieces = newID.split(\"_\");\n\n\t\t\t\tif (pieces.length != 2) {\n\t\t\t\t\tthrow new RuntimeException();\n\t\t\t\t}\n\n\t\t\t\tif (!pieces[0].equals(\"Node\")) {\n\t\t\t\t\tthrow new RuntimeException();\n\t\t\t\t}\n\n\t\t\t\tthis.value = Long.parseLong(pieces[1]);\n\n\t\t\t\tif (this.value < 0) {\n\t\t\t\t\tthrow new RuntimeException(\"Negative value are not allowed.\");\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\"Invalid String representation for an Identifier: \" + id, e);\n\t\t\t}\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn \"Node_\" + value;\n\t\t}\n\n\t\tpublic long getValue() {\n\t\t\treturn this.value;\n\t\t}\n\n\t\tpublic void setValue(long value) {\n\t\t\tif (value < 0) {\n\t\t\t\tthrow new RuntimeException(\"Negative value are not allowed.\");\n\t\t\t}\n\t\t\tthis.value = value;\n\t\t}\n\n\t\tpublic boolean equals(Object o) {\n\t\t\tif (this == o) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!(o instanceof Identifier)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn this.value == ((Identifier) o).value;\n\t\t}\n\n\t\t/**\n\t\t * Makes a deep copy of this Identifier.\n\t\t * \n\t\t * @see java.lang.Object#clone()\n\t\t */\n\t\tpublic Identifier clone() {\n\t\t\treturn new Identifier(this.value);\n\t\t}\n\t}\n\n\t/**\n\t * A parameter of a BTNode. A BTNode parameter is composed of a name and a\n\t * value. Both name and value are strings.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static class Parameter implements Serializable {\n\t\tprivate static final long serialVersionUID = 1L;\n\t\t/** Name of the parameter. */\n\t\tprivate String value;\n\t\t/** Value of the parameter. */\n\t\tprivate String name;\n\t\t/**\n\t\t * Flag that indicates whether the parameter must be read from the\n\t\t * context or not. If the parameter must be read from the context, its\n\t\t * value must be a non-empty string.\n\t\t */\n\t\tprivate boolean fromContext;\n\n\t\t/**\n\t\t * Returns the name of the parameter, or null if not set.\n\t\t */\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\t/**\n\t\t * Sets the name of the parameter.\n\t\t */\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\n\t\t/**\n\t\t * Returns the value of the parameter, or null if not set.\n\t\t */\n\t\tpublic String getValue() {\n\t\t\treturn value;\n\t\t}\n\n\t\t/**\n\t\t * Sets the value of the parameter.\n\t\t */\n\t\tpublic void setValue(String value) {\n\t\t\tthis.value = value;\n\t\t}\n\n\t\t/**\n\t\t * Sets if the parameter must be read from the context or not.\n\t\t */\n\t\tpublic void setFromContext(boolean fromContext) {\n\t\t\tthis.fromContext = fromContext;\n\t\t}\n\n\t\t/**\n\t\t * Returns true if the value must be read from the context, and false\n\t\t * otherwise.\n\t\t */\n\t\tpublic boolean getFromContext() {\n\t\t\treturn this.fromContext;\n\t\t}\n\n\t\t/**\n\t\t * Makes a deep copy of this Parameter.\n\t\t * \n\t\t * @see java.lang.Object#clone()\n\t\t */\n\t\tpublic Parameter clone() {\n\t\t\tParameter copy = new Parameter();\n\t\t\tcopy.fromContext = this.fromContext;\n\n\t\t\tif (this.value != null)\n\t\t\t\tcopy.value = new String(this.value);\n\t\t\telse\n\t\t\t\tcopy.value = null;\n\n\t\t\tif (this.name != null)\n\t\t\t\tcopy.name = new String(this.name);\n\t\t\telse\n\t\t\t\tcopy.name = null;\n\n\t\t\treturn copy;\n\t\t}\n\t}\n\t\n\tpublic static class VarParameter extends Parameter\n\t{\n\t\tprivate static final long serialVersionUID = 1L;\n\t\t/** Name of the field that describes the parameter. */\n\t\tprivate String variableName;\n\t\tprivate boolean isConstant;\n\t\t\n\t\tpublic VarParameter(Parameter par)\n\t\t{\n\t\t\tsuper.value = par.value;\n\t\t\tsuper.name = par.name;\n\t\t\tsuper.fromContext= par.fromContext;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Gets if the parameter is a key-value pair or not\n\t\t */\n\t\tpublic boolean getIsConstant() {\n\t\t\treturn isConstant;\n\t\t}\n\n\t\t/**\n\t\t * Sets if the parameter is a key-value pair or not\n\t\t */\n\t\tpublic void setIsConstant(boolean isConstant) {\n\t\t\tthis.isConstant = isConstant;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Returns the name of the field stored in the parameter\n\t\t */\n\t\tpublic String getVariableName() {\n\t\t\treturn variableName;\n\t\t}\n\t\t\n\t\tpublic void setVariableName(String value) {\n\t\t\tthis.variableName = value;\n\t\t}\n\t\t\n\t\t/**\n\t\t * Makes a deep copy of this Parameter.\n\t\t * \n\t\t * @see java.lang.Object#clone()\n\t\t */\n\t\tpublic VarParameter clone()\n\t\t{\n\t\t\tVarParameter copy = new VarParameter(super.clone());\n\t\t\t\n\t\t\tif (this.variableName != null)\n\t\t\t\tcopy.variableName = this.variableName;\n\t\t\telse\n\t\t\t\tcopy.variableName = null;\n\t\t\t\n\t\t\tcopy.isConstant = this.isConstant;\n\t\t\t\n\t\t\treturn copy;\n\t\t}\n\t}\n\n\t/**\n\t * Default constructor. Constructs a BTNode with no identifier.\n\t */\n\tpublic BTNode() {\n\t\tthis.parameters = new Vector<Parameter>();\n\t\tthis.children = new Vector<BTNode>();\n\t}\n\n\t/**\n\t * Constructs a BTNode with an identifier.\n\t */\n\tpublic BTNode(Identifier id) {\n\t\tthis.parameters = new Vector<Parameter>();\n\t\tthis.children = new Vector<BTNode>();\n\t\tthis.ID = id;\n\t}\n\n\t/**\n\t * Returns the BT that this BTNode belongs to, or null if not set yet.\n\t * \n\t * @return the BT that this BTNode belongs to, or null if not set yet.\n\t */\n\tpublic BT getBT() {\n\t\treturn this.tree;\n\t}\n\n\t/**\n\t * Sets the BT that this BTNode belongs to.\n\t * \n\t * @param tree\n\t *            the BT that this BTNode belongs to.\n\t */\n\tpublic void setBT(BT tree) {\n\t\tthis.tree = tree;\n\t}\n\n\t/**\n\t * Returns the underlying conceptual node, or null if not set yet.\n\t */\n\tpublic ConceptualBTNode getConceptualNode() {\n\t\treturn conceptualNode;\n\t}\n\n\t/**\n\t * Sets the underlying conceptual node.\n\t */\n\tpublic void setConceptualNode(ConceptualBTNode conceptualNode) {\n\t\tthis.conceptualNode = conceptualNode;\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Gets the parent of the node. Returns null if not set. If the node has no\n\t * parent, it also returns null.\n\t */\n\tpublic BTNode getParent() {\n\t\treturn parent;\n\t}\n\n\t/**\n\t * Sets the parent of the node. May be null for the root of the tree.\n\t */\n\tpublic void setParent(BTNode parent) {\n\t\tthis.parent = parent;\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Returns the identifier of the node, or null if not set.\n\t */\n\tpublic Identifier getID() {\n\t\treturn this.ID;\n\t}\n\n\t/**\n\t * Returns the name of the node, or null if not set.\n\t */\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\t/**\n\t * Sets the name of the node.\n\t */\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Returns the parameters of the node, or an empty list if it has none.\n\t */\n\tpublic List<Parameter> getParameters() {\n\t\treturn parameters;\n\t}\n\n\t/**\n\t * Sets the list of parameters of the node. Can be an empty list if no\n\t * parameter is wanted.\n\t */\n\tpublic void setParameters(List<Parameter> parameters) {\n\t\tthis.parameters = parameters;\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Returns the number of children of the node.\n\t */\n\tpublic int getNumChildren() {\n\t\treturn this.children.size();\n\t}\n\n\t/**\n\t * Returns a list with all the children of the node, or an empty list if it\n\t * has none.\n\t */\n\tpublic List<BTNode> getChildren() {\n\t\treturn this.children;\n\t}\n\n\t/**\n\t * Returns the error message, or null if no error message.\n\t */\n\tpublic String getErrorMessage() {\n\t\treturn this.errorMessage;\n\t}\n\n\t/**\n\t * Adds a child to the list of children of this node.\n\t */\n\tpublic void addChild(BTNode child) {\n\t\tthis.children.add(child);\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Removes a child from the list of children of the node.\n\t */\n\tpublic void removeChild(BTNode child) {\n\t\tthis.children.remove(child);\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Adds a parameter to the list of parameters of this node.\n\t */\n\tpublic void addParameter(Parameter parameter) {\n\t\tthis.parameters.add(parameter);\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Makes <code>other</code> be a sibling of this node. This method inserts\n\t * <code>other</code> into the list of children of this's parent, and\n\t * removes it from the list of children of its current parent (if it has\n\t * any). This node must have a parent. Otherwise, this method does nothing.\n\t */\n\tpublic void addAsSibling(BTNode other) {\n\t\tif (this.parent != null) {\n\t\t\tif (other.hasAsDescendant(this)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (other.parent != null) {\n\t\t\t\tother.parent.getChildren().remove(other);\n\t\t\t}\n\n\t\t\tint thisPos = this.parent.getChildren().indexOf(this);\n\t\t\tthis.parent.getChildren().add(thisPos + 1, other);\n\t\t\tother.parent = this.parent;\n\t\t\tsetChanged();\n\t\t\tnotifyObservers();\n\t\t}\n\t}\n\n\t/**\n\t * Sets the identifier of this node.\n\t */\n\tpublic void setID(Identifier id) {\n\t\tthis.ID = id;\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Sets the guard of the node.\n\t * \n\t * @param guard\n\t */\n\tpublic void setGuard(BTNode guard) {\n\t\tthis.guard = guard;\n\t}\n\n\t/**\n\t * Returns the guard of the node, or null if it has no guard.\n\t */\n\tpublic BTNode getGuard() {\n\t\treturn this.guard;\n\t}\n\n\t/**\n\t * Returns true if <code>other</code> is a descendant of this node, and\n\t * false otherwise.\n\t */\n\tpublic boolean hasAsDescendant(BTNode other) {\n\t\tif (other == this) {\n\t\t\treturn true;\n\t\t}\n\n\t\tfor (BTNode n : this.getChildren()) {\n\t\t\tif (n.hasAsDescendant(other)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Clears the list of parameters of this node.\n\t */\n\tpublic void clearParameters() {\n\t\tthis.parameters.clear();\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Clears the errors of this node.\n\t */\n\tpublic void clearErrors() {\n\t\tthis.errorMessage = null;\n\t\tsetChanged();\n\t\tnotifyObservers();\n\t}\n\n\t/**\n\t * Checks if this node has no error in its structure. The structure of the\n\t * node is checked against the underlying ConceptualNode. Returns true if no\n\t * error is detected, and false otherwise. In case there is any error, a\n\t * description of it will be accessible through {@link #getErrorMessage()}.\n\t * \n\t */\n\tpublic boolean check() {\n\t\tboolean result = true;\n\t\tboolean hadErrors = this.errorMessage != null;\n\n\t\t/* This is for the root node. */\n\t\tif (this.conceptualNode.getHasName()\n\t\t\t\t&& this.conceptualNode.getType().equals(NodeInternalType.ROOT.toString())) {\n\t\t\tif (this.name == null || this.name.equals(\"\")) {\n\t\t\t\tthis.errorMessage = \"Name cannot be empty\";\n\t\t\t\tresult = false;\n\t\t\t}\n\t\t}\n\n\t\tif (this.conceptualNode.getNumChildren() != 0) {\n\t\t\tif (this.conceptualNode.getNumChildren() == -1) {\n\t\t\t\tif (this.children.size() == 0) {\n\t\t\t\t\tthis.errorMessage = \"Must have at least one child\";\n\t\t\t\t\tresult = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (this.children.size() != this.conceptualNode.getNumChildren()) {\n\t\t\t\t\tthis.errorMessage = \"Must have exactly \" + this.conceptualNode.getNumChildren()\n\t\t\t\t\t\t\t+ \" children\";\n\t\t\t\t\tresult = false;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.children.size() != 0) {\n\t\t\t\tthis.errorMessage = \"This type of node cannot have children\";\n\t\t\t\tresult = false;\n\t\t\t}\n\t\t}\n\n\t\tif (conceptualNode.getParameters().size() != 0) {\n\t\t\tif (this.parameters.size() != conceptualNode.getParameters().size()) {\n\t\t\t\tthis.errorMessage = \"Not all the parameters have a value\";\n\t\t\t\tresult = false;\n\t\t\t} else {\n\t\t\t\tfor (int i = 0; i < conceptualNode.getParameters().size(); i++) {\n\t\t\t\t\tjbt.tools.bteditor.model.ConceptualBTNode.Parameter p = conceptualNode\n\t\t\t\t\t\t\t.getParameters().get(i);\n\t\t\t\t\tString actualValue;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tactualValue = this.parameters.get(i).getValue();\n\t\t\t\t\t\tif (this.parameters.get(i).getFromContext()) {\n\t\t\t\t\t\t\tif (actualValue.equals(\"\")) {\n\t\t\t\t\t\t\t\tthis.errorMessage = \"Invalid value for parameter \" + p.getName();\n\t\t\t\t\t\t\t\tresult = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (ParameterType.isVariable(p.getType()))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tBTNode.VarParameter varParameter = (BTNode.VarParameter)this.parameters.get(i);\n\t\t\t\t\t\t\t\tString defaultTextValue = varParameter.getVariableName();\n\t\t\t\t\t\t\t\tif (!checkVarParameter(p, actualValue, defaultTextValue, varParameter.getIsConstant(), this.tree)){\n\t\t\t\t\t\t\t\t\tthis.errorMessage = \"Invalid value for parameter \" + p.getName();\n\t\t\t\t\t\t\t\t\tresult = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!checkParameter(p, actualValue, this.tree)) {\n\t\t\t\t\t\t\t\tthis.errorMessage = \"Invalid value for parameter \" + p.getName();\n\t\t\t\t\t\t\t\tresult = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tthis.errorMessage = e.getMessage();\n\t\t\t\t\t\tresult = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/* Do not forget to check the guard. */\n\t\tif (this.guard != null) {\n\t\t\tif (!this.guard.check()) {\n\t\t\t\tthis.errorMessage = \"Error in the guard: \" + this.guard.errorMessage;\n\t\t\t\tresult = false;\n\t\t\t}\n\t\t}\n\n\t\tif (result) {\n\t\t\tif (hadErrors) {\n\t\t\t\tthis.errorMessage = null;\n\t\t\t\tsetChanged();\n\t\t\t\tnotifyObservers();\n\t\t\t}\n\t\t} else {\n\t\t\tsetChanged();\n\t\t\tnotifyObservers();\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Checks if the value of a parameter is consistent with the type of the\n\t * parameter. Returns true if no error is detected, and false otherwise. The\n\t * BT that the parameter is supposed to belong must be provided, because the\n\t * correctness of some values can only be checked within a BT (for instance,\n\t * the {@link ParameterType#NODE_ID}).\n\t */\n\tpublic static boolean checkParameter(\n\t\t\tjbt.tools.bteditor.model.ConceptualBTNode.Parameter parameterDefinition, String value,\n\t\t\tBT tree) {\n\t\tParameterType type = parameterDefinition.getType();\n\n\t\tif (type == ParameterType.INTEGER) {\n\t\t\ttry {\n\t\t\t\tInteger.parseInt(value);\n\t\t\t\treturn true;\n\t\t\t} catch (Exception e) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (type == ParameterType.REAL) {\n\t\t\ttry {\n\t\t\t\tDouble.parseDouble(value);\n\t\t\t\treturn true;\n\t\t\t} catch (Exception e) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (type == ParameterType.STRING) {\n\t\t\tif (value.length() == 0) {\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (type == ParameterType.STATUS_CODE) {\n\t\t\tString[] values = ParameterType.STATUS_CODE.getPossibleValues();\n\n\t\t\tfor (String currentValue : values) {\n\t\t\t\tif (value.equals(currentValue)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} else if (type == ParameterType.NODE_ID) {\n\t\t\tif (value.length() == 0) {\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tIdentifier id = new Identifier(value);\n\n\t\t\t\t\t/*\n\t\t\t\t\t * Check that node exists and that its type is compatible with\n\t\t\t\t\t * the types that the parameter supports.\n\t\t\t\t\t */\n\t\t\t\t\tBTNode referencedNode = tree.findNode(id);\n\n\t\t\t\t\tif (referencedNode != null) {\n\t\t\t\t\t\tif (parameterDefinition.getNodeClasses().contains(\n\t\t\t\t\t\t\t\treferencedNode.getConceptualNode().getType())\n\t\t\t\t\t\t\t\t|| parameterDefinition.getNodeClasses().size() == 0) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn false;\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (type == ParameterType.BOOLEAN) {\n\t\t\tString[] values = ParameterType.BOOLEAN.getPossibleValues();\n\n\t\t\tfor (String currentValue : values) {\n\t\t\t\tif (value.equals(currentValue)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} else if (type == ParameterType.COORDINATE) {\n\t\t\tString[] numbers = value.split(\"( )+\");\n\n\t\t\tfor (String number : numbers) {\n\t\t\t\ttry {\n\t\t\t\t\tDouble.parseDouble(number);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} else if (type == ParameterType.DIRECTION) {\n\t\t\ttry {\n\t\t\t\tDouble.parseDouble(value);\n\t\t\t} catch (Exception e) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} else if (type == ParameterType.PARALLEL_POLICY) {\n\t\t\tString[] values = ParameterType.PARALLEL_POLICY.getPossibleValues();\n\n\t\t\tfor (String currentValue : values) {\n\t\t\t\tif (value.equals(currentValue)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} else if (type == ParameterType.LIST_OF_VARIABLES) {\n\t\t\tMatcher matcher = pattern.matcher(value);\n\n\t\t\treturn matcher.matches();\n\t\t} else if (ParameterType.isVariable(type)) {\n\t\t\t\n\t\t\tif (value.length() == 0) {\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\"Unexpected parameter type \" + type.toString());\n\t}\n\t\n\t/**\n\t * Checks if the value of a var parameter is consistent with the type of the\n\t * parameter. This is done this way to ensure that both the fields of the key-value pair\n\t * are well formed\n\t * the {@link ParameterType#NODE_ID}).\n\t */\n\tpublic static boolean checkVarParameter(\n\t\t\tjbt.tools.bteditor.model.ConceptualBTNode.Parameter parameterDefinition, String value, String variableName, boolean isConstant,\n\t\t\tBT tree) {\n\t\t\n\t\tParameterType type = parameterDefinition.getType();\n\n\t\tif (ParameterType.isVariable(type)) {\n\t\t\t\n\t\t\tif (!isConstant)\n\t\t\t{\n\t\t\t\tif (variableName.length() == 0)\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\t\tswitch (parameterDefinition.getType())\n\t\t\t\t{\n\t\t\t\t\tcase VARIABLE_FLOAT:\n\t\t\t\t\t{\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tFloat.parseFloat(value);\n\t\t\t\t\t\t\tif (value.length() == 0)\n\t\t\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\n\t\t\t\t\tcase VARIABLE_INT:\n\t\t\t\t\t{\n\t\t\t\t\t\t\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tInteger.parseInt(value);\n\t\t\t\t\t\t\tif (value.length() == 0)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\tcase VARIABLE_STRING:\n\t\t\t\t\t{\n\t\t\t\t\t\tif (value.length() == 0)\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\tthrow new IllegalArgumentException(\"Unexpected parameter type \" + type.toString());\n\t\t}\n\t\n\n\t/**\n\t * Makes a deep copy of this BTNode. Children are recursively cloned, as\n\t * well as the guard. The underlying ConceptualBTNode and the BT that this\n\t * BTNode belongs to are not deeply copied, but just assigned. The parent of\n\t * the returned node is null, but its children are properly linked.\n\t * <p>\n\t * This method should be carefully used. Keep in mind that node identifiers\n\t * are unique in a BT, so the returned copy is only valid as long as the BT\n\t * it belongs to does not have any node with the same name. Otherwise, the\n\t * identifiers should be changed.\n\t * \n\t * @see java.lang.Object#clone()\n\t */\n\tpublic BTNode clone() {\n\t\tBTNode copy = new BTNode();\n\n\t\tif (this.conceptualNode != null)\n\t\t\tcopy.conceptualNode = this.conceptualNode;\n\t\telse\n\t\t\tcopy.conceptualNode = null;\n\n\t\tif (this.errorMessage != null)\n\t\t\tcopy.errorMessage = this.errorMessage;\n\t\telse\n\t\t\tcopy.errorMessage = null;\n\n\t\tif (this.guard != null)\n\t\t\tcopy.guard = this.guard.clone();\n\t\telse\n\t\t\tcopy.guard = null;\n\n\t\tif (this.ID != null)\n\t\t\tcopy.ID = this.ID.clone();\n\t\telse\n\t\t\tcopy.ID = null;\n\n\t\tif (this.name != null)\n\t\t\tcopy.name = new String(this.name);\n\t\telse\n\t\t\tcopy.name = null;\n\n\t\tcopy.parameters = new LinkedList<Parameter>();\n\n\t\tif (this.parameters.size() != 0) {\n\t\t\tfor (Parameter p : this.parameters) {\n\t\t\t\tcopy.parameters.add(p.clone());\n\t\t\t}\n\t\t}\n\n\t\tcopy.children = new LinkedList<BTNode>();\n\n\t\tif (this.children.size() != 0) {\n\t\t\tfor (BTNode child : this.children) {\n\t\t\t\tBTNode clonedChild = child.clone();\n\t\t\t\tclonedChild.setParent(copy);\n\t\t\t\tcopy.children.add(clonedChild);\n\t\t\t}\n\t\t}\n\n\t\tcopy.tree = this.tree;\n\n\t\treturn copy;\n\t}\n\n\tpublic String toString() {\n\t\treturn \"ID: \" + this.ID + \" - Type: \" + this.conceptualNode.getReadableType()\n\t\t\t\t+ \" - Num. Children: \" + this.children.size();\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/model/ConceptualBTNode.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.model;\n\nimport gatech.mmpm.ActionParameterType;\n\nimport java.io.Serializable;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.NodesLoader;\n\n/**\n * ConceptualBTNode represents a behaviour tree node conceptually, containing\n * information about its type of node, how many children it can contain, what\n * parameters it has, and so on.\n * <p>\n * A ConceptualBTNode is used for building actual nodes of trees, as well as\n * checking the validity of actual nodes.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ConceptualBTNode implements Serializable {\n\tprivate static final long serialVersionUID = 1L;\n\n\t/**\n\t * Some types of nodes that are internal to the application.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static enum NodeInternalType {\n\t\tROOT {\n\t\t\tpublic String toString() {\n\t\t\t\treturn \"Root\";\n\t\t\t}\n\t\t},\n\t\tACTION {\n\t\t\tpublic String toString() {\n\t\t\t\treturn \"Action\";\n\t\t\t}\n\t\t},\n\t\tCONDITION {\n\t\t\tpublic String toString() {\n\t\t\t\treturn \"Condition\";\n\t\t\t}\n\t\t},\n\t\tSUBTREE_LOOKUP {\n\t\t\tpublic String toString() {\n\t\t\t\treturn \"SubtreeLookup\";\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Type that is displayed in the application. */\n\tprivate String readableType;\n\t/**\n\t * Actual type of the node. This is the type that is written into the XML\n\t * file when exporting a BT.\n\t */\n\tprivate String type;\n\t/**\n\t * Conceptual description of the parameters of this node. May be empty\n\t * (empty list) for nodes with no parameters.\n\t */\n\tprivate List<Parameter> parameters;\n\t/**\n\t * Number of children of the node. Ranges from -1 to infinity. A value of -1\n\t * means that the node can have from 1 to infinity children. A value\n\t * different from -1 means that the node must have exactly that number of\n\t * children.\n\t */\n\tprivate int numChildren;\n\t/**\n\t * Route of the icon that is displayed for this kind of node.\n\t */\n\tprivate String icon;\n\t/**\n\t * Indicates if the node has a name.\n\t */\n\tprivate boolean hasName;\n\t/**\n\t * Static name of the node. If {@link #hasName} is false, the no has no\n\t * name, an {@link #name} is null. Otherwise, this variable stores the\n\t * static name of the node (or null in case it has not been set yet).\n\t * <p>\n\t * Actions and conditions have a static name.\n\t */\n\tprivate String name;\n\n\t/**\n\t * Enum that contains all the types of the parameters that are accepted by\n\t * behaviour tree nodes.\n\t * <p>\n\t * It must be noted that actions and conditions that are loaded from\n\t * external MMPM domain files have some other parameter types that are\n\t * converted into ParameterType before using them. For instance, the MMPM\n\t * {@link ActionParameterType#ENTITY_ID} is converted into a\n\t * {@link ParameterType#STRING} since behaviour trees do not care about\n\t * entities IDs. For more information about this conversion, see\n\t * {@link NodesLoader#fromMMPMParameterType(ActionParameterType type)}.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static enum ParameterType implements Serializable {\n\t\tBOOLEAN {\n\t\t\tpublic String[] getPossibleValues() {\n\t\t\t\treturn new String[] { \"true\", \"false\" };\n\t\t\t}\n\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Boolean\";\n\t\t\t}\n\n\t\t},\n\t\tINTEGER {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Integer\";\n\t\t\t}\n\t\t},\n\t\tREAL {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Real\";\n\t\t\t}\n\t\t},\n\t\tSTRING {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"String\";\n\t\t\t}\n\t\t},\n\t\tSTATUS_CODE {\n\t\t\tpublic String[] getPossibleValues() {\n\t\t\t\treturn new String[] { \"success\", \"failure\" };\n\t\t\t}\n\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Status code\";\n\t\t\t}\n\n\t\t},\n\t\tNODE_ID {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Node id\";\n\t\t\t}\n\t\t},\n\t\tPARALLEL_POLICY {\n\t\t\tpublic String[] getPossibleValues() {\n\t\t\t\treturn new String[] { \"sequence\", \"selector\" };\n\t\t\t}\n\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Parallel policy\";\n\t\t\t}\n\n\t\t},\n\t\tCOORDINATE {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Coordinate\";\n\t\t\t}\n\t\t},\n\t\tDIRECTION {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Direction\";\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * A list of variables, each one surrounded by quotation marks, and\n\t\t * separated by blank spaces. For instance:\n\t\t * <p>\n\t\t * \"var1\" \"var2\" \"var3\"\n\t\t */\n\t\tLIST_OF_VARIABLES {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"List of variables\";\n\t\t\t}\n\t\t},\n\t\tOBJECT {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Object\";\n\t\t\t}\n\t\t},\n\t\t\n\t\tVARIABLE_INT {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Int\";\n\t\t\t}\n\t\t},\n\t\t\n\t\tVARIABLE_FLOAT {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"Real\";\n\t\t\t}\n\t\t},\n\t\n\t\tVARIABLE_STRING {\n\t\t\tpublic String getReadableType() {\n\t\t\t\treturn \"String\";\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * Returns the set of possible values for an particular ParameterType.\n\t\t * In case the ParameterType has an infinite number of possible values,\n\t\t * it returns null.\n\t\t * <p>\n\t\t * This method is used, for instance, for {@link #PARALLEL_POLICY},\n\t\t * which has only two possible values, \"SEQUENCE\" and \"PARALLEL\".\n\t\t * <p>\n\t\t * The default implementation of this method returns null.\n\t\t */\n\t\tpublic String[] getPossibleValues() {\n\t\t\treturn null;\n\t\t};\n\n\t\t/**\n\t\t * Returns a user friendly version of the type.\n\t\t */\n\t\tpublic abstract String getReadableType();\n\t\t\n\t\t/**\n\t\t * Checks if a type is a variable\n\t\t */\n\t\tpublic static boolean isVariable(ParameterType type)\n\t\t{\n\t\t\tif (type == VARIABLE_INT || type == VARIABLE_FLOAT || type == VARIABLE_STRING)\n\t\t\t\treturn true;\n\t\t\t\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * The specification of a ConceptualBTNode parameter. A Parameter is\n\t * basically a name and a type, meaning that a parameter is identified by a\n\t * name and it has a value of a particular type.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static class Parameter implements Serializable {\n\t\tprivate static final long serialVersionUID = 1L;\n\t\t/** Name of the parameter. */\n\t\tprivate String name;\n\t\t/** Type of the parameter. */\n\t\tprivate ParameterType type;\n\t\t/**\n\t\t * Tells if the parameter can or cannot be read from the context. This\n\t\t * is mainly used by the BTEditor: some parameters can be read from the\n\t\t * context , but others cannot, and must have a specific value.\n\t\t */\n\t\tprivate boolean contextable = false;\n\t\t/**\n\t\t * This is used for checking certain special parameters. When a\n\t\t * parameter is a reference to a node, that node may have to be of a\n\t\t * particular kind, in which case this field stores that kind.\n\t\t */\n\t\tprivate List<String> nodeClasses = new LinkedList<String>();\n\n\t\t/**\n\t\t * When a parameter is a reference to a node (\n\t\t * {@link ParameterType#NODE_ID}), that node may have to be of a\n\t\t * particular kind, in which case this method returns the list of\n\t\t * allowed types. If an empty list is returned, it means all kinds\n\t\t * are allowed.\n\t\t */\n\t\tpublic List<String> getNodeClasses() {\n\t\t\treturn nodeClasses;\n\t\t}\n\n\t\t/**\n\t\t * When a parameter is a reference to a node (\n\t\t * {@link ParameterType#NODE_ID}), that node may have to be of a\n\t\t * particular kind, in which case this method adds one allowed\n\t\t * type.\n\t\t */\n\t\tpublic void addNodeClass(String nodeClass) {\n\t\t\tthis.nodeClasses.add(nodeClass);\n\t\t}\n\n\t\t/**\n\t\t * Returns the name of the node parameter.\n\t\t */\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\t/**\n\t\t * Sets the name of the parameter.\n\t\t */\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\n\t\t/**\n\t\t * Returns the type of the parameter.\n\t\t */\n\t\tpublic ParameterType getType() {\n\t\t\treturn type;\n\t\t}\n\n\t\t/**\n\t\t * Sets the type of the parameter.\n\t\t */\n\t\tpublic void setType(ParameterType type) {\n\t\t\tthis.type = type;\n\t\t}\n\n\t\t/**\n\t\t * Sets of the parameter can or cannot be read from the context.\n\t\t */\n\t\tpublic void setContextable(boolean contextable) {\n\t\t\tthis.contextable = contextable;\n\t\t}\n\n\t\t/**\n\t\t * Returns true if the parameter can be read from the context, of false\n\t\t * if it cannot.\n\t\t */\n\t\tpublic boolean getContextable() {\n\t\t\treturn this.contextable;\n\t\t}\n\n\t\t/**\n\t\t * This function returns a deep copy of this Parameter.\n\t\t * \n\t\t * @see java.lang.Object#clone()\n\t\t */\n\t\tpublic Parameter clone() {\n\t\t\tParameter copy = new Parameter();\n\t\t\tcopy.contextable = this.contextable;\n\t\t\tcopy.name = this.name == null ? null : new String(this.name);\n\t\t\tcopy.type = this.type;\n\t\t\tcopy.nodeClasses = new LinkedList<String>();\n\n\t\t\tfor (String nodeClass : this.nodeClasses) {\n\t\t\t\tcopy.nodeClasses.add(new String(nodeClass));\n\t\t\t}\n\n\t\t\treturn copy;\n\t\t}\n\t}\n\t\n\t/**\n\t * Constructs an empty ConceptualBTNode.\n\t */\n\tpublic ConceptualBTNode() {\n\t\tthis.parameters = new Vector<Parameter>();\n\t}\n\n\t/**\n\t * Returns the type of the node, or null if not set. This is the type that\n\t * is written into the XML file when exporting a behaviour tree.\n\t */\n\tpublic String getType() {\n\t\treturn type;\n\t}\n\n\t/**\n\t * Sets the type of the conceptual node.\n\t */\n\tpublic void setType(String type) {\n\t\tthis.type = type;\n\t}\n\n\t/**\n\t * Returns the list of parameters of the conceptual node, or an empty list\n\t * if it has no parameters.\n\t */\n\tpublic List<Parameter> getParameters() {\n\t\treturn parameters;\n\t}\n\n\t/**\n\t * Seths the list of parameters of the conceptual node.\n\t */\n\tpublic void setParameters(List<Parameter> parameters) {\n\t\tthis.parameters = parameters;\n\t}\n\n\t/**\n\t * Returns the number of children that this node can have. A value of -1\n\t * means that the node can have an undetermined amount of children (but at\n\t * least one). A value other than -1 means that the node must have exactly\n\t * that number of children.\n\t */\n\tpublic int getNumChildren() {\n\t\treturn numChildren;\n\t}\n\n\t/**\n\t * Sets the number of children that this node can have. A value of -1 means\n\t * that the node can have an undetermined amount of children (but at least\n\t * one). A value other than -1 means that the node must have exactly that\n\t * number of children.\n\t */\n\tpublic void setNumChildren(int numChildren) {\n\t\tthis.numChildren = numChildren;\n\t}\n\n\t/**\n\t * Returns the path of the icon associated to this conceptual node, or null\n\t * if not set.\n\t */\n\tpublic String getIcon() {\n\t\treturn icon;\n\t}\n\n\t/**\n\t * Sets the path of the icon associated to this conceptual node.\n\t */\n\tpublic void setIcon(String icon) {\n\t\tthis.icon = icon;\n\t}\n\n\t/**\n\t * Adds a parameter to the list of parameters of this node.\n\t */\n\tpublic void addParameter(Parameter parameter) {\n\t\tthis.parameters.add(parameter);\n\t}\n\n\t/**\n\t * Returns a readable version of the type of the conceptual node, or null if\n\t * not set.\n\t */\n\tpublic String getReadableType() {\n\t\treturn readableType;\n\t}\n\n\t/**\n\t * Sets the readable version of the type of the node.\n\t */\n\tpublic void setReadableType(String type) {\n\t\tthis.readableType = type;\n\t}\n\n\t/**\n\t * Returns if this node has a name. If false, {@link #getName()} is null.\n\t * Otherwise, {@link #getName()} returns the name (or null in case it has\n\t * not been set yet).\n\t */\n\tpublic boolean getHasName() {\n\t\treturn hasName;\n\t}\n\n\t/**\n\t * Sets if the node has a name. If false, {@link #getName()} is null.\n\t * Otherwise, {@link #getName()} returns the name (or null in case it has\n\t * not been set yet).\n\t */\n\tpublic void setHasName(boolean hasName) {\n\t\tthis.hasName = hasName;\n\t}\n\n\t/**\n\t * If {@link #getHasName()} is true, returns the name of the node or null in\n\t * case it has not been set. If false, it returns null.\n\t */\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\t/**\n\t * Sets the name of the node.\n\t */\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\t/**\n\t * This method returns a deep copy of this ConceptualBTNode.\n\t * \n\t * @see java.lang.Object#clone()\n\t */\n\tpublic ConceptualBTNode clone() {\n\t\tConceptualBTNode copy = new ConceptualBTNode();\n\n\t\tcopy.hasName = this.hasName;\n\t\tcopy.icon = this.icon == null ? null : new String(this.icon);\n\t\tcopy.name = this.name == null ? null : new String(this.name);\n\t\tcopy.numChildren = this.numChildren;\n\t\tcopy.parameters = new LinkedList<ConceptualBTNode.Parameter>();\n\n\t\tfor (Parameter p : this.parameters) {\n\t\t\tcopy.parameters.add(p.clone());\n\t\t}\n\n\t\tcopy.readableType = this.readableType == null ? null : new String(this.readableType);\n\t\tcopy.type = this.type == null ? null : new String(this.type);\n\n\t\treturn copy;\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/model/ConceptualNodesTree.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.model;\n\nimport java.util.List;\nimport java.util.Vector;\n\n/**\n * A tree-like structure used to organize {@link ConceptualBTNode}s in\n * categories.\n * <p>\n * This tree is composed of two types of nodes:\n * <ul>\n * <li> {@link CategoryItem}: represents categories. It can contain both\n * CategoryItem (in order to create a hierarchy of categories) and NodeItem\n * objects.\n * <li> {@link ConceptualBTNodeItem}: contains a ConceptualBTNode.\n * </ul>\n * \n * This class defines a method, {@link #insertNode(String, ConceptualBTNodeItem)}, that is\n * used to insert nodes (CategoryItem and NodeItem) into the tree.\n * <p>\n * This tree may have several roots, since there may be many nodes at the top\n * level (that is, within no category). All these nodes are roots of the tree.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ConceptualNodesTree {\n\t/** Categories separator. */\n\tpublic static final String CATEGORY_SEPARATOR = new String(\"/\");\n\n\t/** Roots of the tree. */\n\tprotected List<NodesTreeItem> roots;\n\n\t/**\n\t * Constructs an empty ConceptualNodesTree.\n\t */\n\tpublic ConceptualNodesTree() {\n\t\tthis.roots = new Vector<NodesTreeItem>();\n\t}\n\n\t/**\n\t * Returns the roots of the tree.\n\t */\n\tpublic List<NodesTreeItem> getRoots() {\n\t\treturn roots;\n\t}\n\n\t/**\n\t * Sets the roots of the tree.\n\t */\n\tpublic void setRoots(List<NodesTreeItem> roots) {\n\t\tthis.roots = roots;\n\t}\n\n\t/**\n\t * Inserts a NodesTreeItem into the tree, at a particular position. The position\n\t * is specified by the <code>category</code> parameter. This parameter is a\n\t * String representing the category where the NodeItem must be inserted.\n\t * <p>\n\t * <code>category</code> can be null, in which case the node is inserted as\n\t * a root of the tree. Otherwise, the category must follow this format:\n\t * <p>\n\t * <code>subCat1 + {@link #CATEGORY_SEPARATOR} + subCat2 + {@link #CATEGORY_SEPARATOR} + ... +\n\t * {@link #CATEGORY_SEPARATOR} + subCatN</code>\n\t * <p>\n\t * If the specified category does not exist in the tree, it is created on\n\t * the fly.\n\t */\n\tpublic void insertNode(String category, NodesTreeItem node) {\n\t\t/* If the category is null, the node is inserted at the top level. */\n\t\tif (category == null) {\n\t\t\tnode.setParent(null);\n\t\t\tthis.roots.add(node);\n\t\t\treturn;\n\t\t}\n\t\t/*\n\t\t * Otherwise, follow the standard algorithm. First we extract each of\n\t\t * the categories that the path where this node is going to be inserted\n\t\t * is composed of.\n\t\t */\n\t\tString[] subCategories = category.split(CATEGORY_SEPARATOR);\n\t\t/*\n\t\t * Main loop. Here we find the CategoryItem where the NodeItem must be\n\t\t * inserted. \"currentItem\" represents the CategoryItem we are looking\n\t\t * for.\n\t\t */\n\t\tCategoryItem currentItem = null;\n\t\tfor (int i = 0; i < subCategories.length; i++) {\n\t\t\t/*\n\t\t\t * At every level of the tree, we get the children of the current\n\t\t\t * category, and check if there is one whose name matches\n\t\t\t * \"subCategories[i]\". If there is such a category, we move on to\n\t\t\t * it. Otherwise, we create a new category whose name is\n\t\t\t * \"subCategories[i]\".\n\t\t\t */\n\t\t\tList<NodesTreeItem> children = i == 0 ? this.roots : currentItem\n\t\t\t\t\t.getChildren();\n\n\t\t\t/* Check if there is a category matching the current one. */\n\t\t\tboolean subCategoryExists = false;\n\t\t\tfor (int j = 0; j < children.size(); j++) {\n\t\t\t\tif (children.get(j) instanceof CategoryItem\n\t\t\t\t\t\t&& children.get(j).getName().equals(subCategories[i])) {\n\t\t\t\t\t/*\n\t\t\t\t\t * If the category does exist, we move on to the next level\n\t\t\t\t\t * of the tree.\n\t\t\t\t\t */\n\t\t\t\t\tcurrentItem = (CategoryItem) children.get(j);\n\t\t\t\t\tsubCategoryExists = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t/*\n\t\t\t * If the category does not exist, it must be created. Then, move on\n\t\t\t * to the next level of the tree.\n\t\t\t */\n\t\t\tif (!subCategoryExists) {\n\t\t\t\tCategoryItem newCategory = new CategoryItem();\n\t\t\t\tnewCategory.setName(subCategories[i]);\n\t\t\t\tif (i == 0) {\n\t\t\t\t\tnewCategory.setParent(null);\n\t\t\t\t\tthis.roots.add(newCategory);\n\t\t\t\t} else {\n\t\t\t\t\tnewCategory.setParent(currentItem);\n\t\t\t\t\tcurrentItem.addChild(newCategory);\n\t\t\t\t}\n\t\t\t\tcurrentItem = newCategory;\n\t\t\t}\n\t\t}\n\t\t/*\n\t\t * When we have reached the category where the node must be inserted, it\n\t\t * is inserted into it.\n\t\t */\n\t\tcurrentItem.addChild(node);\n\t\tnode.setParent(currentItem);\n\t}\n\n\t/**\n\t * A node of the {@link ConceptualNodesTree}.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static abstract class NodesTreeItem {\n\t\tprotected NodesTreeItem parent;\n\n\t\tpublic NodesTreeItem getParent() {\n\t\t\treturn parent;\n\t\t}\n\n\t\tpublic void setParent(NodesTreeItem parent) {\n\t\t\tthis.parent = parent;\n\t\t}\n\n\t\tpublic abstract String getName();\n\t}\n\n\t/**\n\t * A category of the {@link ConceptualNodesTree}.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static class CategoryItem extends NodesTreeItem {\n\t\tprivate String name;\n\t\tprivate List<NodesTreeItem> children;\n\n\t\tpublic CategoryItem() {\n\t\t\tthis.children = new Vector<NodesTreeItem>();\n\t\t}\n\n\t\tpublic void addChild(NodesTreeItem child) {\n\t\t\tthis.children.add(child);\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\n\t\tpublic List<NodesTreeItem> getChildren() {\n\t\t\treturn this.children;\n\t\t}\n\n\t\tpublic int getNumChildren() {\n\t\t\treturn this.children.size();\n\t\t}\n\t}\n\n\t/**\n\t * A {@link ConceptualBTNode} of the {@link ConceptualNodesTree}.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tpublic static class ConceptualBTNodeItem extends NodesTreeItem {\n\t\tprivate ConceptualBTNode nodeModel;\n\n\t\tpublic ConceptualBTNodeItem(ConceptualBTNode nodeModel) {\n\t\t\tthis.nodeModel = nodeModel;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn this.nodeModel.getReadableType();\n\t\t}\n\n\t\tpublic ConceptualBTNode getNodeModel() {\n\t\t\treturn this.nodeModel;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/util/DetailsDialog.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.util;\n\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.jface.dialogs.IconAndMessageDialog;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\n\n/**\n * This class represents a dialog that shows an icon, a message, and a text area\n * where plain text can be shown.\n * <p>\n * This class represents the classic \"details\" dialog that shows a \"details\"\n * button to see a detailed report of the message.\n * <p>\n * This dialog has two buttons, a \"close\" button and a \"details\" button. By\n * pressing the details button, the details area can be hidden or made visible.\n * The icon that is showed by the dialog can also be set.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class DetailsDialog extends IconAndMessageDialog {\n\t/**\n\t * Type of icon to use. Must be {@link #ERROR}, {@link #WARNING},\n\t * {@link #INFORMATION} or {@link #QUESTION}.\n\t */\n\tprotected int iconType;\n\t/**\n\t * Text shown in the details area.\n\t */\n\tprotected String details;\n\t/**\n\t * Text area where the details are shown.\n\t */\n\tprotected Text detailsText;\n\t/**\n\t * Boolean that tells if the details text ({@link #detailsText}) is\n\t * currently created or not. The visualization and hiding of the details\n\t * area is done by creating and destroying {@link #detailsText}. This flag\n\t * tells if {@link #detailsText} is actyallu created or not.\n\t */\n\tprotected boolean detailsTextCreated = false;\n\t/**\n\t * Constant for an error icon.\n\t */\n\tpublic static final int ERROR = 0;\n\t/**\n\t * Constant for a warning icon.\n\t */\n\tpublic static final int WARNING = 1;\n\t/**\n\t * Constant for an information icon.\n\t */\n\tpublic static final int INFORMATION = 2;\n\t/**\n\t * Constant for a question icon.\n\t */\n\tpublic static final int QUESTION = 3;\n\t/**\n\t * Button used to hide and visualize the details area.\n\t */\n\tprotected Button detailsButton;\n\t/**\n\t * Title of the dialog.\n\t */\n\tprotected String title;\n\n\t/**\n\t * Constructs a DetailsDialog. The style of the dialog (the shell) is\n\t * <code>SWT.CLOSE | SWT.RESIZE | SWT.MAX | SWT.MODELESS</code>. .\n\t * \n\t * @param title\n\t *            title of the dialog.\n\t * @param message\n\t *            main message shown by the dialog.\n\t * @param details\n\t *            text that is shown in the details area.\n\t * @param iconType\n\t *            type of the icon that is shown in the dialog. Must be one of\n\t *            the following: <code>{@link #ERROR}</code>,\n\t *            <code>{@link #WARNING}</code>,\n\t *            <code>{@link #INFORMATION}</code> ,\n\t *            <code>{@link #QUESTION}</code>.\n\t * @param parentShell\n\t *            this dialog's parent shell. If null, it is a top level shell.\n\t */\n\tpublic DetailsDialog(String title, String message, String details, int iconType,\n\t\t\tShell parentShell) {\n\t\tthis(title, message, details, iconType, parentShell, SWT.CLOSE | SWT.RESIZE | SWT.MAX\n\t\t\t\t| SWT.MODELESS);\n\t}\n\n\t/**\n\t * Constructs a DetailsDialog. The dialog style can be specified.\n\t * \n\t * @param title\n\t *            title of the dialog.\n\t * @param message\n\t *            main message shown by the dialog.\n\t * @param details\n\t *            text that is shown in the details area.\n\t * @param iconType\n\t *            type of the icon that is shown in the dialog. Must be one of\n\t *            the following: <code>{@link #ERROR}</code>,\n\t *            <code>{@link #WARNING}</code>,\n\t *            <code>{@link #INFORMATION}</code> ,\n\t *            <code>{@link #QUESTION}</code>.\n\t * @param parentShell\n\t *            this dialog's parent shell. If null, it is a top level shell.\n\t * @param shellStyle\n\t *            style of the dialog's shell.\n\t */\n\tpublic DetailsDialog(String title, String message, String details, int iconType,\n\t\t\tShell parentShell, int shellStyle) {\n\t\tsuper(parentShell);\n\t\tif (message == null) {\n\t\t\tthrow new IllegalArgumentException(\"Message cannot be null\");\n\t\t}\n\t\tthis.message = message;\n\t\tif (iconType < 0 || iconType > 3) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid icon type (\" + iconType + \")\");\n\t\t}\n\t\tif (details == null) {\n\t\t\tthrow new IllegalArgumentException(\"Details cannot be null\");\n\t\t}\n\t\tif (title == null) {\n\t\t\tthrow new IllegalArgumentException(\"Title cannot be null\");\n\t\t}\n\t\tthis.details = details;\n\t\tthis.iconType = iconType;\n\t\tthis.title = title;\n\t\tthis.setBlockOnOpen(false);\n\t\tthis.setShellStyle(shellStyle);\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see\n\t * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets\n\t * .Composite)\n\t */\n\tprotected Control createDialogArea(Composite parent) {\n\t\treturn createMessageArea(parent);\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see\n\t * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse\n\t * .swt.widgets.Composite)\n\t */\n\tprotected void createButtonsForButtonBar(Composite parent) {\n\t\tcreateButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);\n\t\tthis.detailsButton = createButton(parent, IDialogConstants.DETAILS_ID,\n\t\t\t\tIDialogConstants.SHOW_DETAILS_LABEL, false);\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)\n\t */\n\tprotected void buttonPressed(int buttonId) {\n\t\tif (buttonId == IDialogConstants.DETAILS_ID) {\n\t\t\t/*\n\t\t\t * If the details button has been pressed, then the details area\n\t\t\t * must be shown or hidden, depending on whether it as hidden or\n\t\t\t * not. After doing so, the dialog must be resized.\n\t\t\t */\n\t\t\tPoint dialogOldDimensions = getShell().getSize();\n\t\t\tif (this.detailsTextCreated) {\n\t\t\t\t/*\n\t\t\t\t * If the details area is being showed, we delete it. Also, the\n\t\t\t\t * label on the details button must be changed.\n\t\t\t\t */\n\t\t\t\tthis.detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL);\n\t\t\t\tthis.detailsText.dispose();\n\t\t\t}\n\t\t\telse {\n\t\t\t\t/*\n\t\t\t\t * If the text area is not being showed, it must be created and\n\t\t\t\t * showed. In order to do so, we initialize \"this.detailsText\".\n\t\t\t\t * Also, the label on the details button must be changed.\n\t\t\t\t */\n\t\t\t\tthis.detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL);\n\t\t\t\tthis.detailsText = new Text((Composite) getContents(), SWT.BORDER | SWT.READ_ONLY\n\t\t\t\t\t\t| SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL);\n\t\t\t\tthis.detailsText.setText(this.details);\n\t\t\t\tGridData data = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\t\t\tthis.detailsText\n\t\t\t\t\t\t.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));\n\t\t\t\tdata.horizontalSpan = 2;\n\t\t\t\tthis.detailsText.setLayoutData(data);\n\t\t\t}\n\t\t\tgetContents().getShell().layout();\n\t\t\tthis.detailsTextCreated = !this.detailsTextCreated;\n\n\t\t\t/*\n\t\t\t * The dialog is finalli resized.\n\t\t\t */\n\t\t\tPoint dialogNewDimensions = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);\n\t\t\tint screenHeight = Display.getCurrent().getClientArea().height;\n\t\t\tgetShell()\n\t\t\t\t\t.setSize(\n\t\t\t\t\t\t\tnew Point(dialogOldDimensions.x, Math.min(dialogNewDimensions.y,\n\t\t\t\t\t\t\t\t\tscreenHeight)));\n\t\t}\n\t\telse {\n\t\t\t/*\n\t\t\t * Close the dialog...\n\t\t\t */\n\t\t\tclose();\n\t\t}\n\t\tsetReturnCode(buttonId);\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see org.eclipse.jface.dialogs.IconAndMessageDialog#getImage()\n\t */\n\tprotected Image getImage() {\n\t\tswitch (this.iconType) {\n\t\t\tcase ERROR:\n\t\t\t\treturn getErrorImage();\n\t\t\tcase WARNING:\n\t\t\t\treturn getWarningImage();\n\t\t\tcase INFORMATION:\n\t\t\t\treturn getInfoImage();\n\t\t\tcase QUESTION:\n\t\t\t\treturn getQuestionImage();\n\t\t\tdefault:\n\t\t\t\tthrow new RuntimeException(\"Invalid type of image: \" + this.iconType);\n\t\t}\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see\n\t * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets\n\t * .Shell)\n\t */\n\tprotected void configureShell(Shell shell) {\n\t\tsuper.configureShell(shell);\n\t\tshell.setText(this.title);\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/util/Extensions.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.util;\n\n/**\n * Class that stores the file extensions that are supported by the application.\n * \n * @author Ricardo Juan Palma Durán\n * \n * Modified by Fernando Matarrubia (adding c++ extension)\n */\npublic class Extensions {\n\t\n\t/** Extensions of the files that can contain behaviour trees. */\n\tprivate static final String[] BTFileExtensions = new String[] { \"xbt\",\n\t\t\t\"xml\" };\n\t\n\t/** Extension of the file that can contain an inline c++ version of the behaviour tree */\n\tprivate static final String[] BTCppFileExtensions = new String[] {\"cpp\"};\n\t\n\t/** Extension of the file that can contain an inline c++ version of the behaviour tree */\n\tprivate static final String[] BTInlFileExtensions = new String[] {\"inl\"};\n\n\t/** Extensions of MMPM domain files. */\n\tprivate static final String[] MMPMDomainfileExtensions = new String[] { \"xml\" };\n\n\t/**\n\t * Returns an array containing the extensions of the files than can contain\n\t * behaviour trees.\n\t */\n\tpublic static String[] getBTFileExtensions() {\n\t\treturn BTFileExtensions;\n\t}\n\t\n\t/**\n\t * Returns an array containing the extensions of the special cpp files that\n\t * can contain behaviour trees\n\t */\n\tpublic static String[] getCppFileExtensions(){\n\t\t\n\t\treturn BTCppFileExtensions;\n\t}\n\t\n\t/**\n\t * Returns an array containing the extensions of the special inline files that\n\t * can contain behaviour trees\n\t */\n\tpublic static String[] getInlFileExtensions(){\n\t\t\n\t\treturn BTInlFileExtensions;\n\t}\n\n\t/**\n\t * Returns an array containing the extensions of MMPM domain files.\n\t */\n\tpublic static String[] getMMPMDomainFileExtensions() {\n\t\treturn MMPMDomainfileExtensions;\n\t}\n\n\t/**\n\t * Given an array with file extensions, this method returns filters for\n\t * those extensions to be used in SWT dialogs\n\t */\n\tpublic static String[] getFiltersFromExtensions(String[] extensions) {\n\t\tString[] result = new String[extensions.length];\n\t\tfor (int i = 0; i < result.length; i++) {\n\t\t\tresult[i] = \"*.\" + extensions[i];\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Given a set of file extensions, this method returns a single filter for\n\t * all of those extensions.\n\t */\n\tpublic static String getUnifiedFilterFromExtensions(String[] extensions) {\n\t\tString result = new String();\n\t\tfor (int i = 0; i < extensions.length - 1; i++) {\n\t\t\tresult += \"*.\" + extensions[i] + \";\";\n\t\t}\n\t\tresult += \"*.\" + extensions[extensions.length - 1];\n\t\treturn result;\n\t}\n\n\t/**\n\t * Joins two arrays of String.\n\t */\n\tpublic static String[] joinArrays(String[] array1, String[] array2) {\n\t\tString[] result = new String[array1.length + array2.length];\n\t\tSystem.arraycopy(array1, 0, result, 0, array1.length);\n\t\tSystem.arraycopy(array2, 0, result, array1.length, array2.length);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Joins a file name and an extension. If the file name ends with \".\"+\n\t * <code>extension</code> , then <code>fileName</code> itself is returned.\n\t * Otherwise, it returns <code>fileName+\".\"+extension</code>.\n\t */\n\tpublic static String joinFileNameAndExtension(String fileName,\n\t\t\tString extension) {\n\t\tif (fileName.endsWith(\".\" + extension)) {\n\t\t\treturn fileName;\n\t\t} else {\n\t\t\treturn fileName + \".\" + extension;\n\t\t}\n\t}\n\n\tprivate Extensions() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/util/IconsPaths.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.util;\n\n/**\n * Paths of application general icons (these do not change).\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class IconsPaths {\n\tpublic static final String OPEN_BT = \"/icons/openBT.png\";\n\tpublic static final String NEW_BT = \"/icons/newBT.png\";\n\tpublic static final String ROOT = \"/icons/root.png\";\n\tpublic static final String ACTION = \"/icons/action.png\";\n\tpublic static final String CATEGORY = \"/icons/category.png\";\n\tpublic static final String CONDITION = \"/icons/condition.png\";\n\tpublic static final String LOAD_MMPM_DOMAIN = \"/icons/loadMMPMDomain.png\";\n\tpublic static final String GUARD = \"/icons/guard.png\";\n\tpublic static final String BT = \"/icons/BT.png\";\n\tpublic static final String CPP = \"/icons/cpp.png\";\n\tpublic static final String INL = \"/icons/inl.png\";\n\n\tprivate IconsPaths() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/util/OverlayImageIcon.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.util;\n\nimport org.eclipse.jface.resource.CompositeImageDescriptor;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.ImageData;\nimport org.eclipse.swt.graphics.Point;\n\n/**\n * This class is used for overlaying image icons.\n * \n * @author balajik\n * \n */\npublic class OverlayImageIcon extends CompositeImageDescriptor {\n\t/**\n\t * Base image of the object\n\t */\n\tprivate Image baseImage;\n\n\t/**\n\t * Size of the base image\n\t */\n\tprivate Point sizeOfImage;\n\n\t/**\n\t * Decoration\n\t */\n\tprivate Image decoration;\n\n\t/**\n\t * Constructor for overlayImageIcon.\n\t */\n\tpublic OverlayImageIcon(Image baseImage, Image decoration) {\n\t\t// Base image of the object\n\t\tthis.baseImage = baseImage;\n\t\t// Demo Image Object\n\t\tthis.decoration = decoration;\n\t\tthis.sizeOfImage = new Point(baseImage.getBounds().width, baseImage.getBounds().height);\n\t}\n\n\t/**\n\t * @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int,\n\t *      int) DrawCompositeImage is called to draw the composite image.\n\t * \n\t */\n\tprotected void drawCompositeImage(int arg0, int arg1) {\n\t\t// Draw the base image\n\t\tdrawImage(baseImage.getImageData(), 0, 0);\n\t\tImageData imageData = decoration.getImageData();\n\n\t\t// Draw on bottom right corner\n\t\tdrawImage(imageData, sizeOfImage.x - imageData.width, sizeOfImage.y - imageData.height);\n\t}\n\n\t/**\n\t * @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize() get\n\t *      the size of the object\n\t */\n\tprotected Point getSize() {\n\t\treturn sizeOfImage;\n\t}\n\n\t/**\n\t * Get the image formed by overlaying different images on the base image\n\t * \n\t * @return composite image\n\t */\n\tpublic Image getImage() {\n\t\treturn createImage();\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/util/Pair.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.util;\n\nimport java.io.Serializable;\n\n/**\n * Pair represents a pair of objects\n * \n * @author Wikipedia\n * @param <T>\n *            type of the first element of the pair.\n * @param <S>\n *            type of the second element of the pair.\n */\npublic class Pair<T, S> implements Serializable {\n\tprivate static final long serialVersionUID = 1L;\n\t/*\n\t * First element of the pair.\n\t */\n\tprivate T first;\n\t/*\n\t * Second element of the pair.\n\t */\n\tprivate S second;\n\n\t/**\n\t * Constructs a Pair.\n\t * \n\t * @param f\n\t *            first element of the pair.\n\t * @param s\n\t *            second element of the pair.\n\t */\n\tpublic Pair(T f, S s) {\n\t\tfirst = f;\n\t\tsecond = s;\n\t}\n\n\t/**\n\t * Returns the first element of the pair.\n\t * \n\t * @return the first element of the pair.\n\t */\n\tpublic T getFirst() {\n\t\treturn first;\n\t}\n\n\t/**\n\t * Returns the second element of the pair.\n\t * \n\t * @return the second element of the pair.\n\t */\n\tpublic S getSecond() {\n\t\treturn second;\n\t}\n\n\t/**\n\t * Sets the value of the first element of the pair.\n\t * \n\t * @param f\n\t *            value for the first element of the pair.\n\t */\n\tpublic void setFirst(T f) {\n\t\tfirst = f;\n\t}\n\n\t/**\n\t * Sets the value of the second element of the pair.\n\t * \n\t * @param s\n\t *            value for the second element of the pair.\n\t */\n\tpublic void setSecond(S s) {\n\t\tsecond = s;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see java.lang.Object#toString()\n\t */\n\tpublic String toString() {\n\t\treturn \"(\" + first.toString() + \", \" + second.toString() + \")\";\n\t}\n\t\n\tpublic boolean equals(Object o){\n\t\tif(this==o)\n\t\t\treturn true;\n\t\t\n\t\tif(o instanceof Pair){\n\t\t\treturn first.equals(((Pair)o).first) && second.equals(((Pair)o).second); \n\t\t}\n\t\telse{\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tpublic int hashCode(){\n\t\treturn first.hashCode()+second.hashCode();\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/util/StandardDialogs.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.util;\n\nimport java.util.List;\n\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.swt.SWT;\n\n/**\n * Class that contains a bunch of standard SWT dialogs to be used by calling\n * simple methods.\n * <p>\n * All these dialogs block when opened.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class StandardDialogs {\n\t/*\n\t * Private constructor.\n\t */\n\tprivate StandardDialogs() {}\n\n\tpublic static void informationDialog(String title, String informationMessage) {\n\t\tMessageDialog.openInformation(null, title, informationMessage);\n\t}\n\n\tpublic static void errorDialog(String title, String errorMessage) {\n\t\tMessageDialog.openError(null, title, errorMessage);\n\t}\n\n\tpublic static void exceptionDialog(String title, String errorMessage, Exception e) {\n\t\tDetailsDialog dialog = new DetailsDialog(title, errorMessage,\n\t\t\t\tUtilities.stackTraceToString(e), DetailsDialog.ERROR, null, SWT.APPLICATION_MODAL\n\t\t\t\t\t\t| SWT.RESIZE | SWT.MIN | SWT.MAX | SWT.CLOSE);\n\t\tdialog.setBlockOnOpen(true);\n\t\tdialog.open();\n\t}\n\n\tpublic static void exceptionDialog(String title, String errorMessage, List<Exception> exceptions) {\n\t\tString exceptionMessage = new String();\n\t\tfor (Exception currentException : exceptions) {\n\t\t\texceptionMessage += \"** Exception **\\n\\n\"\n\t\t\t\t\t+ Utilities.stackTraceToString(currentException) + \"\\n\\n\";\n\t\t}\n\t\tDetailsDialog dialog=new DetailsDialog(title, errorMessage, exceptionMessage, DetailsDialog.ERROR, null,\n\t\t\t\tSWT.APPLICATION_MODAL | SWT.RESIZE | SWT.MIN | SWT.MAX | SWT.CLOSE);\n\t\t\n\t\tdialog.setBlockOnOpen(true);\n\t\tdialog.open();\n\t}\n\n\tpublic static void warningDialog(String title, String warningMessage) {\n\t\tMessageDialog.openWarning(null, title, warningMessage);\n\t}\n\n\tpublic static boolean confirmationDialog(String title, String confirmationMessage) {\n\t\treturn MessageDialog.openConfirm(null, title, confirmationMessage);\n\t}\n\n\tpublic static boolean questionDialog(String title, String question) {\n\t\treturn MessageDialog.openQuestion(null, title, question);\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/util/Utilities.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.util;\n\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.io.StringWriter;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.editor.BTEditor;\nimport jbt.tools.bteditor.editor.BTEditorIDGenerator;\nimport jbt.tools.bteditor.editor.BTEditorInput;\n\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.IEditorPart;\nimport org.eclipse.ui.IEditorReference;\nimport org.eclipse.ui.IViewPart;\nimport org.eclipse.ui.IViewReference;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.part.EditorPart;\n\n/**\n * General utilities used in the tool.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class Utilities {\n\t/**\n\t * Returns a IViewPart by its class. If cannot be found, returns null.\n\t */\n\tpublic static IViewPart getView(Class c) {\n\t\tIWorkbenchPage page = getMainWindowActivePage();\n\n\t\tif (page != null) {\n\t\t\tIViewReference[] views = page.getViewReferences();\n\t\t\tfor (int i = 0; i < views.length; i++) {\n\t\t\t\tif (views[i].getView(true) != null) {\n\t\t\t\t\tif (c.isInstance(views[i].getView(false))) {\n\t\t\t\t\t\treturn views[i].getView(false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns a List containing all the BTEditor that are currently open.\n\t */\n\tpublic static List<BTEditor> getBTEditors() {\n\t\tIWorkbenchPage activePage = getMainWindowActivePage();\n\n\t\tif (activePage != null) {\n\t\t\tIEditorReference[] editors = activePage.getEditorReferences();\n\t\t\tif (editors.length == 0)\n\t\t\t\treturn new Vector<BTEditor>();\n\t\t\tList<BTEditor> returnedEditors = new Vector<BTEditor>();\n\t\t\tfor (int i = 0; i < editors.length; i++) {\n\t\t\t\tif (editors[i].getEditor(false) instanceof BTEditor) {\n\t\t\t\t\treturnedEditors.add((BTEditor) editors[i].getEditor(false));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn returnedEditors;\n\t\t}\n\n\t\treturn new LinkedList<BTEditor>();\n\t}\n\n\t/**\n\t * Given a BTEditor ID (see {@link BTEditorIDGenerator}), this method\n\t * returns the corresponding BTEditor, or null if not found.\n\t */\n\tpublic static BTEditor getBTEditor(long btEditorID) {\n\t\tList<BTEditor> btEditors = getBTEditors();\n\n\t\tfor (BTEditor editor : btEditors) {\n\t\t\tif (((BTEditorInput) editor.getEditorInput()).getEditorID() == btEditorID) {\n\t\t\t\treturn editor;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns the currently active BTEditor, or null if no BTEditor is active.\n\t */\n\tpublic static BTEditor getActiveBTEditor() {\n\t\tIWorkbenchPage page = getMainWindowActivePage();\n\n\t\tif (page != null) {\n\t\t\tIEditorPart editor = page.getActiveEditor();\n\t\t\tif (editor instanceof BTEditor)\n\t\t\t\treturn (BTEditor) editor;\n\t\t\telse\n\t\t\t\treturn null;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns the main application window.\n\t */\n\tpublic static IWorkbenchWindow getMainWindow() {\n\t\treturn PlatformUI.getWorkbench().getWorkbenchWindows()[0];\n\t}\n\n\t/**\n\t * Returns the active page of the window returned by\n\t * {@link #getMainWindow()}, or null if not found.\n\t */\n\tpublic static IWorkbenchPage getMainWindowActivePage() {\n\t\treturn getMainWindow().getActivePage();\n\t}\n\n\t/**\n\t * Returns the application's display.\n\t */\n\tpublic static Display getDisplay() {\n\t\treturn PlatformUI.getWorkbench().getDisplay();\n\t}\n\n\t/**\n\t * Returns the application's shell.\n\t */\n\tpublic static Shell getShell() {\n\t\treturn PlatformUI.getWorkbench().getDisplay().getActiveShell();\n\t}\n\n\t/**\n\t * Returns the stack trace of a Throwable as a String. This can be used for\n\t * exceptions, for example. This method may return an empty (\"\") String in\n\t * case an error occurs or in case <code>t</code> does not have a strack\n\t * trace.\n\t */\n\tpublic static String stackTraceToString(Throwable t) {\n\t\tString retValue = \"\";\n\t\tStringWriter sw = null;\n\t\tPrintWriter pw = null;\n\t\ttry {\n\t\t\tsw = new StringWriter();\n\t\t\tpw = new PrintWriter(sw);\n\t\t\tt.printStackTrace(pw);\n\t\t\tretValue = sw.toString();\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tif (pw != null)\n\t\t\t\t\tpw.close();\n\t\t\t\tif (sw != null)\n\t\t\t\t\tsw.close();\n\t\t\t} catch (IOException e) {\n\t\t\t}\n\t\t}\n\t\treturn retValue;\n\t}\n\n\t/**\n\t * Activates an editor.\n\t * \n\t * @param editor\n\t *            the editor to activate.\n\t */\n\tpublic static void activateEditor(EditorPart editor) {\n\t\tIWorkbenchPage page = editor.getSite().getPage();\n\t\tpage.activate(editor);\n\t}\n\n\tprivate Utilities() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/viewers/BTNodeIndentifierTransfer.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.viewers;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.io.ObjectInputStream;\nimport java.io.ObjectOutputStream;\n\nimport jbt.tools.bteditor.model.BTNode;\nimport jbt.tools.bteditor.model.BTNode.Identifier;\n\nimport org.eclipse.swt.dnd.ByteArrayTransfer;\nimport org.eclipse.swt.dnd.DND;\nimport org.eclipse.swt.dnd.TransferData;\n\n/**\n * This transfer class transfers BTNode objects. However, only the BTNode identifier is\n * transfered.\n * \n * @author Ricardo Juan Palma Durán\n *\n */\npublic class BTNodeIndentifierTransfer extends ByteArrayTransfer {\n\tprivate static final String TYPENAME = \"BTNodeIndentifierTransfer\";\n\tprivate static final int TYPEID = registerType(TYPENAME);\n\t\n\tprivate static BTNodeIndentifierTransfer instance = null;\n\n\tprivate BTNodeIndentifierTransfer(){}\n\n\tpublic static BTNodeIndentifierTransfer getInstance(){\n\t\tif(instance == null){\n\t\t\tinstance = new BTNodeIndentifierTransfer();\n\t\t}\n\t\treturn instance;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.swt.dnd.Transfer#getTypeNames()\n\t */\n\tprotected String[] getTypeNames(){\n\t\treturn new String[]{TYPENAME};\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.swt.dnd.Transfer#getTypeIds()\n\t */\n\tprotected int[] getTypeIds(){\n\t\treturn new int[]{TYPEID};\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.swt.dnd.Transfer#validate(java.lang.Object)\n\t */\n\tprotected boolean validate(Object object){\n\t\treturn(object != null && object instanceof BTNode);\n\t}\n\t\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.swt.dnd.ByteArrayTransfer#javaToNative(java.lang.Object,\n\t * org.eclipse.swt.dnd.TransferData)\n\t */\n\tpublic void javaToNative(Object object, TransferData transferData){\n\t\tif(!validate(object)){\n\t\t\tDND.error(DND.ERROR_INVALID_DATA);\n\t\t}\n\t\t\n\t\tif( !isSupportedType(transferData)){\n\t\t\tDND.error(DND.ERROR_INVALID_DATA);\n\t\t}\n\t\t\n\t\tBTNode node=(BTNode)object;\n\t\t\n\t\ttry{\n\t\t\tByteArrayOutputStream out = new ByteArrayOutputStream();\n\t\t\tObjectOutputStream writeOut = new ObjectOutputStream(out);\n\t\n\t\t\twriteOut.writeObject(node.getID());\n\t\t\t\n\t\t\tbyte[] buffer = out.toByteArray();\n\t\t\twriteOut.close();\n\t\t\tout.close();\n\t\t\tsuper.javaToNative(buffer, transferData);\n\t\t}\n\t\tcatch(IOException e){\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see\n\t * org.eclipse.swt.dnd.ByteArrayTransfer#nativeToJava(org.eclipse.swt.dnd\n\t * .TransferData)\n\t */\n\tpublic Object nativeToJava(TransferData transferData){\n\t\tif(!isSupportedType(transferData)){\n\t\t\treturn null;\n\t\t}\n\t\tbyte[] buffer = (byte[])super.nativeToJava(transferData);\n\t\tif(buffer == null)\n\t\t\treturn null;\n\t\ttry{\n\t\t\tByteArrayInputStream in = new ByteArrayInputStream(buffer);\n\t\t\tObjectInputStream readIn = new ObjectInputStream(in);\n\t\t\tIdentifier id=(Identifier)readIn.readObject();\n\t\t\t\n\t\t\treadIn.close();\n\t\t\tin.close();\n\t\t\treturn id;\n\t\t}\n\t\tcatch(Exception ex){\n\t\t\tex.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/viewers/ConceptualBTNodeTransfer.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.viewers;\n\nimport jbt.tools.bteditor.util.Pair;\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.io.ObjectInputStream;\nimport java.io.ObjectOutputStream;\n\nimport jbt.tools.bteditor.model.ConceptualBTNode;\n\nimport org.eclipse.swt.dnd.ByteArrayTransfer;\nimport org.eclipse.swt.dnd.DND;\nimport org.eclipse.swt.dnd.TransferData;\n\n/**\n * This transfer class transfers {@link ConceptualBTNode} objects. However, only\n * the pair \"type\"-\"name\" is transfered, and recovered as a Pair<String,String>\n * whose first element is \"type\" and whose second element is \"name\".\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ConceptualBTNodeTransfer extends ByteArrayTransfer {\n\tprivate static final String TYPENAME = \"ConceptualBTNodeTransfer\";\n\tprivate static final int TYPEID = registerType(TYPENAME);\n\n\tprivate static ConceptualBTNodeTransfer instance = null;\n\n\tprivate ConceptualBTNodeTransfer() {\n\t}\n\n\tpublic static ConceptualBTNodeTransfer getInstance() {\n\t\tif (instance == null) {\n\t\t\tinstance = new ConceptualBTNodeTransfer();\n\t\t}\n\t\treturn instance;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see org.eclipse.swt.dnd.Transfer#getTypeNames()\n\t */\n\tprotected String[] getTypeNames() {\n\t\treturn new String[] { TYPENAME };\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see org.eclipse.swt.dnd.Transfer#getTypeIds()\n\t */\n\tprotected int[] getTypeIds() {\n\t\treturn new int[] { TYPEID };\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see org.eclipse.swt.dnd.Transfer#validate(java.lang.Object)\n\t */\n\tprotected boolean validate(Object object) {\n\t\treturn (object != null && object instanceof ConceptualBTNode);\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see org.eclipse.swt.dnd.ByteArrayTransfer#javaToNative(java.lang.Object,\n\t * org.eclipse.swt.dnd.TransferData)\n\t */\n\tpublic void javaToNative(Object object, TransferData transferData) {\n\t\tif (!validate(object)) {\n\t\t\tDND.error(DND.ERROR_INVALID_DATA);\n\t\t}\n\n\t\tif (!isSupportedType(transferData)) {\n\t\t\tDND.error(DND.ERROR_INVALID_DATA);\n\t\t}\n\n\t\tConceptualBTNode node = (ConceptualBTNode) object;\n\n\t\ttry {\n\t\t\tByteArrayOutputStream out = new ByteArrayOutputStream();\n\t\t\tObjectOutputStream writeOut = new ObjectOutputStream(out);\n\n\t\t\twriteOut.writeObject(node.getType());\n\t\t\twriteOut.writeObject(node.getName());\n\n\t\t\tbyte[] buffer = out.toByteArray();\n\t\t\twriteOut.close();\n\t\t\tout.close();\n\t\t\tsuper.javaToNative(buffer, transferData);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * \n\t * @see\n\t * org.eclipse.swt.dnd.ByteArrayTransfer#nativeToJava(org.eclipse.swt.dnd\n\t * .TransferData)\n\t */\n\tpublic Object nativeToJava(TransferData transferData) {\n\t\tif (!isSupportedType(transferData)) {\n\t\t\treturn null;\n\t\t}\n\t\tbyte[] buffer = (byte[]) super.nativeToJava(transferData);\n\t\tif (buffer == null)\n\t\t\treturn null;\n\t\ttry {\n\t\t\tString type;\n\t\t\tString name;\n\t\t\tByteArrayInputStream in = new ByteArrayInputStream(buffer);\n\t\t\tObjectInputStream readIn = new ObjectInputStream(in);\n\n\t\t\ttype = (String) readIn.readObject();\n\t\t\tname = (String) readIn.readObject();\n\n\t\t\treadIn.close();\n\t\t\tin.close();\n\t\t\treturn new Pair<String, String>(type, name);\n\t\t} catch (Exception ex) {\n\t\t\tex.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/viewers/ConceptualNodesTreeViewer.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.viewers;\n\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.ApplicationIcons;\nimport jbt.tools.bteditor.model.ConceptualNodesTree;\nimport jbt.tools.bteditor.model.ConceptualNodesTree.CategoryItem;\nimport jbt.tools.bteditor.model.ConceptualNodesTree.ConceptualBTNodeItem;\nimport jbt.tools.bteditor.model.ConceptualNodesTree.NodesTreeItem;\nimport jbt.tools.bteditor.util.IconsPaths;\n\nimport org.eclipse.jface.viewers.DoubleClickEvent;\nimport org.eclipse.jface.viewers.IDoubleClickListener;\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.ILabelProviderListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.dnd.DND;\nimport org.eclipse.swt.dnd.DragSourceEvent;\nimport org.eclipse.swt.dnd.DragSourceListener;\nimport org.eclipse.swt.dnd.Transfer;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Tree;\n\n/**\n * ConceptualNodesTreeViewer is a Composite that is able to display, in a\n * tree-like fashion, several {@link ConceptualNodesTree}s.\n * <p>\n * It also defines a drag and drop mechanism for dragging nodes from the view so\n * that they can be dropped anywhere else in the application. This drag and drop\n * mechanism is compatible with the transfer type\n * {@link ConceptualBTNodeTransfer}.\n * <p>\n * Double clicking a category node expands -or collapses- that category.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class ConceptualNodesTreeViewer extends Composite {\n\t/** The TreeViewer that is internally used for displaying the trees. */\n\tprivate TreeViewer treeViewer;\n\t/** The trees thar are being displayed. */\n\tprivate List<ConceptualNodesTree> trees;\n\n\t/**\n\t * Constructor.\n\t */\n\tpublic ConceptualNodesTreeViewer(Composite parent, int style) {\n\t\tsuper(parent, style);\n\t\tthis.trees = new Vector<ConceptualNodesTree>();\n\t\tthis.setLayout(new FillLayout());\n\n\t\tthis.treeViewer = new TreeViewer(this, SWT.SINGLE);\n\t\tTree treeWidget = (Tree) this.treeViewer.getControl();\n\t\t// treeWidget.setLinesVisible(true);\n\n\t\tthis.treeViewer.setContentProvider(new BTContentProvider());\n\t\tthis.treeViewer.setLabelProvider(new BTLabelProvider());\n\t\tthis.treeViewer.setInput(this.trees);\n\n\t\t/* Drag and drop support. */\n\t\tTransfer[] transfers = new Transfer[] { ConceptualBTNodeTransfer.getInstance() };\n\t\tthis.treeViewer.addDragSupport(DND.DROP_MOVE, transfers, new NodesTreeViewerDragListener());\n\n\t\t/* Double click listener for expanding and collapsing categories. */\n\t\tthis.treeViewer.addDoubleClickListener(new IDoubleClickListener() {\n\t\t\tpublic void doubleClick(DoubleClickEvent event) {\n\t\t\t\tObject node = ((StructuredSelection) event.getSelection()).getFirstElement();\n\t\t\t\tif (node instanceof CategoryItem) {\n\t\t\t\t\tif (treeViewer.getExpandedState(node)) {\n\t\t\t\t\t\ttreeViewer.collapseToLevel(node, 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttreeViewer.expandToLevel(node, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Adds a new {@link ConceptualNodesTree} that will be displayed together\n\t * with all the trees that were being displayed.\n\t */\n\tpublic void addTree(ConceptualNodesTree tree) {\n\t\tthis.trees.add(tree);\n\t\tthis.treeViewer.refresh();\n\t}\n\n\t/**\n\t * Drag source listener of the tree. It is compatible with\n\t * {@link ConceptualBTNodeTransfer}.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class NodesTreeViewerDragListener implements DragSourceListener {\n\t\tpublic void dragFinished(DragSourceEvent event) {\n\t\t}\n\n\t\tpublic void dragSetData(DragSourceEvent event) {\n\t\t\tif (ConceptualBTNodeTransfer.getInstance().isSupportedType(event.dataType)) {\n\t\t\t\tevent.data = ((ConceptualBTNodeItem) ((IStructuredSelection) treeViewer\n\t\t\t\t\t\t.getSelection()).getFirstElement()).getNodeModel();\n\t\t\t}\n\t\t}\n\n\t\tpublic void dragStart(DragSourceEvent event) {\n\t\t\tIStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();\n\n\t\t\tif (!selection.isEmpty()) {\n\t\t\t\tif (selection.getFirstElement() instanceof ConceptualBTNodeItem) {\n\t\t\t\t\tConceptualBTNodeItem selectedNode = (ConceptualBTNodeItem) selection\n\t\t\t\t\t\t\t.getFirstElement();\n\t\t\t\t\tevent.doit = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tevent.doit = false;\n\t\t}\n\t}\n\n\t/**\n\t * Contente provider of the tree.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate static class BTContentProvider implements ITreeContentProvider {\n\t\tpublic Object[] getChildren(Object parentElement) {\n\t\t\tif (parentElement instanceof CategoryItem) {\n\t\t\t\tCategoryItem category = (CategoryItem) parentElement;\n\t\t\t\treturn category.getChildren().toArray();\n\t\t\t} else {\n\t\t\t\treturn new Object[] {};\n\t\t\t}\n\t\t}\n\n\t\tpublic Object getParent(Object element) {\n\t\t\treturn ((NodesTreeItem) element).getParent();\n\t\t}\n\n\t\tpublic boolean hasChildren(Object element) {\n\t\t\tif (element instanceof CategoryItem) {\n\t\t\t\tCategoryItem category = (CategoryItem) element;\n\t\t\t\treturn category.getNumChildren() > 0;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tpublic Object[] getElements(Object inputElement) {\n\t\t\tList<ConceptualNodesTree> trees = (List<ConceptualNodesTree>) inputElement;\n\t\t\tObject[] elements = new Object[trees.size()];\n\t\t\tfor (int i = 0; i < trees.size(); i++) {\n\t\t\t\tConceptualNodesTree tree = trees.get(i);\n\t\t\t\telements[i] = tree.getRoots().get(0);\n\t\t\t}\n\t\t\treturn elements;\n\t\t}\n\n\t\tpublic void dispose() {\n\t\t}\n\n\t\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\t}\n\t}\n\n\t/**\n\t * Label provider of the tree.\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate static class BTLabelProvider implements ILabelProvider {\n\t\tpublic Image getImage(Object element) {\n\t\t\tif (element instanceof CategoryItem) {\n\t\t\t\treturn ApplicationIcons.getIcon(IconsPaths.CATEGORY);\n\t\t\t} else {\n\t\t\t\tConceptualBTNodeItem nodeItem = (ConceptualBTNodeItem) element;\n\t\t\t\treturn ApplicationIcons.getIcon(nodeItem.getNodeModel().getIcon());\n\t\t\t}\n\t\t}\n\n\t\tpublic String getText(Object element) {\n\t\t\treturn ((NodesTreeItem) element).getName();\n\t\t}\n\n\t\tpublic void addListener(ILabelProviderListener listener) {\n\t\t}\n\n\t\tpublic void dispose() {\n\t\t}\n\n\t\tpublic boolean isLabelProperty(Object element, String property) {\n\t\t\treturn false;\n\t\t}\n\n\t\tpublic void removeListener(ILabelProviderListener listener) {\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/viewers/NodeInfoViewer.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.viewers;\n\nimport java.util.List;\nimport java.util.Observable;\nimport java.util.Observer;\n\nimport jbt.tools.bteditor.model.BTNode;\nimport jbt.tools.bteditor.model.ConceptualBTNode.NodeInternalType;\nimport jbt.tools.bteditor.model.BTNode.Parameter;\nimport jbt.tools.bteditor.util.Utilities;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.DisposeEvent;\nimport org.eclipse.swt.events.DisposeListener;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.ui.forms.widgets.FormToolkit;\nimport org.eclipse.ui.forms.widgets.ScrolledForm;\nimport org.eclipse.ui.forms.widgets.TableWrapData;\nimport org.eclipse.ui.forms.widgets.TableWrapLayout;\n\n/**\n * This class is used to display some information about a {@link BTNode}. This\n * Composite implements the {@link Observer} interface so that it gets notified\n * whenever the BTNode changes. By doing so, it can properly keep the displayed\n * information updated.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class NodeInfoViewer extends Composite implements Observer {\n\t/**\n\t * The BTNode whose information is being displayed.\n\t */\n\tprivate BTNode node;\n\t/**\n\t * Toolkit used to manage the form that displays the information (\n\t * {@link #global}).\n\t */\n\tprivate FormToolkit toolkit;\n\t/**\n\t * Form that displays all the node's information.\n\t */\n\tprivate ScrolledForm global;\n\n\t/**\n\t * Constructor.\n\t */\n\tpublic NodeInfoViewer(Composite parent, int style) {\n\t\tsuper(parent, style);\n\t\tthis.setLayout(new FillLayout());\n\n\t\tthis.toolkit = new FormToolkit(Utilities.getDisplay());\n\t\tthis.global = this.toolkit.createScrolledForm(this);\n\t\tTableWrapLayout layout = new TableWrapLayout();\n\t\tlayout.numColumns = 2;\n\t\tthis.global.getBody().setLayout(layout);\n\n\t\t/* For disposing the toolkit. */\n\t\tthis.addDisposeListener(new DisposeListener() {\n\t\t\tpublic void widgetDisposed(DisposeEvent e) {\n\t\t\t\ttoolkit.dispose();\n\t\t\t}\n\t\t});\n\n\t\t/* For the wheel event. */\n\t\tthis.global.addListener(SWT.Activate, new Listener() {\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tglobal.setFocus();\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Sets the node whose information will be displayed. If <code>node</code>\n\t * is null, no information is displayed. This method registers the\n\t * NodeInfoViewer as an observer of <code>node</code>, so whenever\n\t * <code>node</code> changes, the NodeInfoViewer will be notified and will\n\t * update the displayed information accordingly.\n\t */\n\tpublic void setNode(BTNode node) {\n\t\tif (this.node != null) {\n\t\t\tthis.node.deleteObserver(this);\n\t\t}\n\n\t\tthis.node = node;\n\t\tif (node != null)\n\t\t\tthis.node.addObserver(this);\n\t\tupdateView();\n\t}\n\n\t/**\n\t * \n\t * @see java.util.Observer#update(java.util.Observable, java.lang.Object)\n\t */\n\tpublic void update(Observable o, Object arg) {\n\t\tupdateView();\n\t}\n\n\t/**\n\t * Updates all the information that is displayed on the Composite, by\n\t * obtaining it from the BTNode.\n\t */\n\tprivate void updateView() {\n\t\t/* Clean previos information. */\n\t\tif (this.global.getBody().getChildren().length != 0) {\n\t\t\tfor (Control c : this.global.getBody().getChildren()) {\n\t\t\t\tc.dispose();\n\t\t\t}\n\t\t}\n\n\t\t/* If child is null, do nothing. */\n\t\tif (this.node == null) {\n\t\t\treturn;\n\t\t}\n\n\t\tComposite parent = this.global.getBody();\n\t\tthis.toolkit.createLabel(parent, \"Type\").setLayoutData(\n\t\t\t\tnew TableWrapData(TableWrapData.LEFT));\n\t\tLabel valueLabel = this.toolkit.createLabel(parent, \"\", SWT.RIGHT);\n\t\tvalueLabel.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));\n\n\t\tif (!this.node.getConceptualNode().getType().equals(NodeInternalType.ACTION.toString())\n\t\t\t\t&& !this.node.getConceptualNode().getType()\n\t\t\t\t\t\t.equals(NodeInternalType.CONDITION.toString())) {\n\t\t\tvalueLabel.setText(this.node.getConceptualNode().getReadableType());\n\t\t} else {\n\t\t\tvalueLabel.setText(this.node.getConceptualNode().getType());\n\t\t}\n\n\t\t/* Shows node's ID. */\n\t\tthis.toolkit.createLabel(parent, \"ID\");\n\t\tthis.toolkit.createLabel(parent, this.node.getID().toString(), SWT.RIGHT).setLayoutData(\n\t\t\t\tnew TableWrapData(TableWrapData.FILL_GRAB));\n\n\t\t/* Shows name of the node. */\n\t\tif (this.node.getConceptualNode().getHasName()) {\n\t\t\tthis.toolkit.createLabel(parent, \"Name\");\n\n\t\t\tvalueLabel = this.toolkit.createLabel(parent, \"\", SWT.RIGHT);\n\t\t\tvalueLabel.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));\n\n\t\t\t/* This is for the root. */\n\t\t\tif (this.node.getConceptualNode().getType().equals(NodeInternalType.ROOT.toString())) {\n\t\t\t\tif (this.node.getName() != null) {\n\t\t\t\t\tvalueLabel.setText(this.node.getName());\n\t\t\t\t} else {\n\t\t\t\t\tvalueLabel.setText(\"Not assigned\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvalueLabel.setText(this.node.getConceptualNode().getReadableType());\n\t\t\t}\n\t\t}\n\n\t\t/* Show parameters. */\n\t\tList<Parameter> parameters = this.node.getParameters();\n\n\t\tfor (Parameter p : parameters) {\n\t\t\tLabel nameLabel = this.toolkit.createLabel(parent, \"\");\n\t\t\tvalueLabel = this.toolkit.createLabel(parent, p.getValue(), SWT.RIGHT);\n\t\t\tvalueLabel.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));\n\n\t\t\tnameLabel.setText(p.getName() + (p.getFromContext() ? \" (from context)\" : \"\"));\n\t\t}\n\n\t\t/* Show error message. */\n\t\tif (this.node.getErrorMessage() != null) {\n\t\t\tthis.toolkit.createLabel(parent, \"ERROR\");\n\t\t\tthis.toolkit.createLabel(parent, this.node.getErrorMessage(), SWT.RIGHT).setLayoutData(\n\t\t\t\t\tnew TableWrapData(TableWrapData.FILL_GRAB));\n\t\t}\n\n\t\t/* Lay out the Composite so that it refreshes. */\n\t\tglobal.reflow(true);\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/views/NodeInfo.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.views;\n\nimport java.util.List;\n\nimport jbt.tools.bteditor.editor.BTEditor;\nimport jbt.tools.bteditor.model.BTNode;\nimport jbt.tools.bteditor.util.Utilities;\nimport jbt.tools.bteditor.viewers.NodeInfoViewer;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.part.ViewPart;\n\n/**\n * ViewPart that shows the information of the selected node of the currently\n * active editor. Internally, this view just stores a NodeInfoViewer.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class NodeInfo extends ViewPart {\n\tpublic static String ID = \"jbt.tools.bteditor.views.NodeInfo\";\n\tprivate NodeInfoViewer nodeInfoViewer;\n\n\tpublic void createPartControl(Composite parent) {\n\t\tthis.nodeInfoViewer = new NodeInfoViewer(parent, SWT.NONE);\n\n\t\t/* Initialize view's content with the currently selected node. */\n\t\tBTEditor activeBTEditor = Utilities.getActiveBTEditor();\n\n\t\tif (activeBTEditor != null) {\n\t\t\tList<BTNode> selectedElements = activeBTEditor.getSelectedElements();\n\t\t\tif (selectedElements.size() != 0) {\n\t\t\t\tthis.nodeInfoViewer.setNode(selectedElements.get(0));\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void setFocus() {\n\t}\n\n\t/**\n\t * Sets the node whose information is being displayed.\n\t */\n\tpublic void setNode(BTNode node) {\n\t\tthis.nodeInfoViewer.setNode(node);\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/views/NodesNavigator.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.views;\n\nimport jbt.tools.bteditor.NodesLoader;\nimport jbt.tools.bteditor.model.ConceptualNodesTree;\nimport jbt.tools.bteditor.viewers.ConceptualNodesTreeViewer;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.part.ViewPart;\n\n/**\n * This is the ViewPart that shows the list of available nodes, that is, the\n * list of nodes that can be used to build behaviour trees.\n * <p>\n * Internally, this view just contains a {@link ConceptualNodesTreeViewer} that shows the\n * list of nodes that are currently loaded into the application (see\n * {@link NodesLoader}.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class NodesNavigator extends ViewPart {\n\tpublic static String ID = \"jbt.tools.bteditor.views.NodesNavigator\";\n\tprivate ConceptualNodesTreeViewer viewer;\n\n\tpublic void createPartControl(Composite parent) {\n\t\t/* Load both standard and non-standard nodes. */\n\t\tthis.viewer = new ConceptualNodesTreeViewer(parent, SWT.NONE);\n\n\t\tthis.viewer.addTree(NodesLoader.getStandardNodesTree());\n\n\t\tfor (ConceptualNodesTree tree : NodesLoader.getNonStandardNodesTrees()) {\n\t\t\tthis.viewer.addTree(tree);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a {@link ConceptualNodesTree} to the list of trees displayed by this\n\t * view. All the nodes of the tree will be displayed.\n\t */\n\tpublic void addTree(ConceptualNodesTree tree) {\n\t\tviewer.addTree(tree);\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.WorkbenchPart#setFocus()\n\t */\n\tpublic void setFocus() {\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor/src/jbt/tools/bteditor/views/NodesSearcher.java",
    "content": "/*\n * Copyright (C) 2012 Ricardo Juan Palma Durán\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage jbt.tools.bteditor.views;\n\nimport java.util.List;\nimport java.util.Vector;\n\nimport jbt.tools.bteditor.editor.BTEditor;\nimport jbt.tools.bteditor.model.BT;\nimport jbt.tools.bteditor.model.BTNode;\nimport jbt.tools.bteditor.model.BTNode.Identifier;\nimport jbt.tools.bteditor.util.Utilities;\n\nimport org.eclipse.jface.viewers.ILabelProviderListener;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.ITableLabelProvider;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerSorter;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.KeyAdapter;\nimport org.eclipse.swt.events.KeyEvent;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Text;\nimport org.eclipse.ui.part.ViewPart;\n\n/**\n * The NodesSearcher class is an Eclipse view that lets the user search nodes in\n * a behaviour tree. This view shows a simple text field where the user can\n * input the identifier or the partial identifier of a behaviour tree node (\n * {@link BTNode}), and then perform the search by clicking a button or pressing\n * the \"enter\". The view shows a list containing the nodes of the BT in the\n * currently active BTEditor that match such an identifier. By clicking a node\n * of the search result, it gets selected, and the BTEditor that contains it\n * gets activated. If the text field is left empty, the search list will contain\n * all the nodes of the tree.\n * \n * @author Ricardo Juan Palma Durán\n * \n */\npublic class NodesSearcher extends ViewPart {\n\tpublic static String ID = \"jbt.tools.bteditor.views.NodesSearcher\";\n\n\t/** Composite that stores all the widget that this ViewPart displays. */\n\tprivate Composite global;\n\t/** TableViewer that displays the search results. */\n\tprivate TableViewer resultsTable;\n\t/** The result of the search. It stores a set of BTNode identifiers. */\n\tprivate List<Identifier> searchResult;\n\t/**\n\t * Text field where the user inputs the identifier or the partial identifier\n\t * of the node.\n\t */\n\tprivate Text searchTextField;\n\t/** BTEditor whose BT was the target of the search. */\n\tprivate BTEditor targetEditor;\n\t/**\n\t * Label that displays the name of the BTEditor whose BT was the target of\n\t * the search.\n\t */\n\tprivate Label targetEditorName;\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)\n\t */\n\tpublic void createPartControl(Composite parent) {\n\t\tthis.searchResult = new Vector<Identifier>();\n\n\t\t/* Initialize the global composite. */\n\t\tthis.global = new Composite(parent, SWT.NONE);\n\t\tGridLayout layout = new GridLayout(1, false);\n\t\tlayout.marginHeight = 0;\n\t\tlayout.marginWidth = 0;\n\t\tthis.global.setLayout(layout);\n\n\t\t/*\n\t\t * Create the top part of the composite (the part containing the search\n\t\t * text field and the search button.\n\t\t */\n\t\tcreateTopComposite(this.global);\n\t\t/*\n\t\t * Create the bottom part of the composite (the part containing the\n\t\t * search result).\n\t\t */\n\t\tcreateBottomComposite(this.global);\n\t}\n\n\t/**\n\t * \n\t * @see org.eclipse.ui.part.WorkbenchPart#setFocus()\n\t */\n\tpublic void setFocus() {\n\t}\n\n\t/**\n\t * Creates the Composite that contains the result of the search. The\n\t * Composite contains the {@link #resultsTable} element.\n\t * \n\t * @param parent\n\t *            the Composite where the created Composite will be placed.\n\t */\n\tprivate void createBottomComposite(Composite parent) {\n\t\tthis.resultsTable = new TableViewer(parent, SWT.SINGLE | SWT.BORDER);\n\t\tthis.resultsTable.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\tthis.resultsTable.setLabelProvider(new ResultsTableLabelProvider());\n\t\tthis.resultsTable.setContentProvider(new ResultsTableContentProvider());\n\t\tthis.resultsTable.setInput(this.searchResult);\n\n\t\t/* Sort elements by its String representation. */\n\t\tthis.resultsTable.setSorter(new ViewerSorter());\n\n\t\t/*\n\t\t * Listener that will select the node in the target BTEditor and which\n\t\t * also activates the target BTEditor.\n\t\t */\n\t\tthis.resultsTable.addSelectionChangedListener(new ISelectionChangedListener() {\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tISelection selection = event.getSelection();\n\n\t\t\t\tif (!selection.isEmpty()) {\n\t\t\t\t\tIdentifier selectedNode = (Identifier) ((IStructuredSelection) selection)\n\t\t\t\t\t\t\t.getFirstElement();\n\t\t\t\t\ttargetEditor.selectNode(selectedNode);\n\t\t\t\t\tUtilities.activateEditor(targetEditor);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.targetEditorName = new Label(parent, SWT.NONE);\n\t\tthis.targetEditorName.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));\n\t}\n\n\t/**\n\t * Creates the Composite that shows the search text field and the search\n\t * button.\n\t * \n\t * @param parent\n\t *            the Composite where the created Composite will be placed.\n\t */\n\tprivate void createTopComposite(Composite parent) {\n\t\tComposite searchComposite = new Composite(parent, SWT.NONE);\n\t\tsearchComposite.setLayout(new GridLayout(3, false));\n\n\t\tsearchComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));\n\n\t\tLabel label = new Label(searchComposite, SWT.NONE);\n\t\tlabel.setText(\"Node ID:\");\n\t\tlabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));\n\t\tthis.searchTextField = createTextField(searchComposite);\n\t\tcreateSearchButton(searchComposite);\n\t}\n\n\t/**\n\t * Creates the search Button.\n\t * \n\t * @param parent\n\t *            the Composite where the Button is placed.\n\t */\n\tprivate void createSearchButton(Composite parent) {\n\t\tButton button = new Button(parent, SWT.PUSH);\n\t\tbutton.setText(\"Search\");\n\t\tbutton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\n\n\t\t/* When clicked, the button performs the search. */\n\t\tbutton.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString searchText = searchTextField.getText();\n\t\t\t\tperformSearch(searchText);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Creates the search text field (Text).\n\t * \n\t * @param parent\n\t *            the Composite where the text field is placed.\n\t * @return the text field.\n\t */\n\tprivate Text createTextField(Composite parent) {\n\t\tfinal Text textField = new Text(parent, SWT.BORDER);\n\n\t\ttextField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\n\t\t/* If \"enter\" is pressed, perform the search. */\n\t\ttextField.addKeyListener(new KeyAdapter() {\n\t\t\tpublic void keyPressed(KeyEvent e) {\n\t\t\t\tif (e.keyCode == SWT.CR) {\n\t\t\t\t\tperformSearch(textField.getText());\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn textField;\n\t}\n\n\t/**\n\t * Label provider for the search results table (\n\t * {@link NodesSearcher#resultsTable}).\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class ResultsTableLabelProvider implements ITableLabelProvider {\n\t\tpublic void addListener(ILabelProviderListener listener) {\n\t\t}\n\n\t\tpublic void dispose() {\n\t\t}\n\n\t\tpublic boolean isLabelProperty(Object element, String property) {\n\t\t\treturn false;\n\t\t}\n\n\t\tpublic void removeListener(ILabelProviderListener listener) {\n\t\t}\n\n\t\tpublic Image getColumnImage(Object element, int columnIndex) {\n\t\t\treturn null;\n\t\t}\n\n\t\tpublic String getColumnText(Object element, int columnIndex) {\n\t\t\treturn ((Identifier) element).toString();\n\t\t}\n\t}\n\n\t/**\n\t * Content provider for the search results table (\n\t * {@link NodesSearcher#resultsTable}).\n\t * \n\t * @author Ricardo Juan Palma Durán\n\t * \n\t */\n\tprivate class ResultsTableContentProvider implements IStructuredContentProvider {\n\t\tpublic void dispose() {\n\n\t\t}\n\n\t\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\n\t\t}\n\n\t\tpublic Object[] getElements(Object inputElement) {\n\t\t\treturn ((List) inputElement).toArray();\n\t\t}\n\t}\n\n\t/**\n\t * Given the search text, this method searches, in the BT of the currently\n\t * active BTEditor, those nodes whose ID contains <code>text</code>,\n\t * ignoring case. It stores, in {@link NodesSearcher#searchResult}, the set\n\t * of nodes with a matching ID. Also it updates the\n\t * {@link NodesSearcher#resultsTable} and\n\t * {@link NodesSearcher#targetEditorName} fields.\n\t * \n\t * @param text\n\t *            the search text.\n\t */\n\tprivate void performSearch(String text) {\n\t\tBTEditor activeEditor = Utilities.getActiveBTEditor();\n\t\tthis.searchResult.clear();\n\n\t\tif (activeEditor != null) {\n\t\t\tthis.targetEditor = activeEditor;\n\t\t\tBT currentBT = activeEditor.getBT();\n\t\t\tsearchNode(text, this.searchResult, currentBT.getRoot());\n\t\t\tthis.targetEditorName.setText(\"Searched in: \" + this.targetEditor.getTitle());\n\t\t}\n\n\t\tthis.global.layout();\n\t\tthis.resultsTable.refresh();\n\t}\n\n\t/**\n\t * Method that recursivelly perform the search, starting from\n\t * <code>currentNode</code>. If stores in <code>foundNodes</code> the\n\t * matching nodes. <code>text</code> is the search text.\n\t */\n\tprivate void searchNode(String text, List<Identifier> foundNodes, BTNode currentNode) {\n\t\tif (currentNode.getID().toString().toLowerCase().contains(text)) {\n\t\t\tfoundNodes.add(currentNode.getID());\n\t\t}\n\n\t\tfor (BTNode child : currentNode.getChildren()) {\n\t\t\tsearchNode(text, foundNodes, child);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor.feature/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>jbt.tools.bteditor.feature</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.FeatureBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.FeatureNature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor.feature/build.properties",
    "content": "bin.includes = feature.xml\n"
  },
  {
    "path": "JBTEditor/jbt.tools.bteditor.feature/feature.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<feature\r\n      id=\"jbt.tools.bteditor.feature\"\r\n      label=\"JBT Editor\"\r\n      version=\"0.0.1\"\r\n      plugin=\"jbt.tools.bteditor\">\r\n\r\n   <description url=\"http://www.example.com/description\">\r\n      [Enter Feature Description here.]\r\n   </description>\r\n\r\n   <copyright url=\"http://www.example.com/copyright\">\r\n      [Enter Copyright Description here.]\r\n   </copyright>\r\n\r\n   <license url=\"http://www.example.com/license\">\r\n      [Enter License Description here.]\r\n   </license>\r\n\r\n   <includes\r\n         id=\"org.eclipse.rcp\"\r\n         version=\"0.0.0\"/>\r\n\r\n   <plugin\r\n         id=\"jbt.tools.bteditor\"\r\n         download-size=\"0\"\r\n         install-size=\"0\"\r\n         version=\"0.0.0\"\r\n         unpack=\"false\"/>\r\n\r\n   <plugin\r\n         id=\"org.eclipse.ui.forms\"\r\n         download-size=\"0\"\r\n         install-size=\"0\"\r\n         version=\"0.0.0\"\r\n         unpack=\"false\"/>\r\n\r\n</feature>\r\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "Apache License\n\nVersion 2.0, January 2004\n\n1. Definitions.\n\n\"License\" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.\n\n\"Licensor\" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.\n\n\"Legal Entity\" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, \"control\" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.\n\n\"You\" (or \"Your\") shall mean an individual or Legal Entity exercising permissions granted by this License.\n\n\"Source\" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.\n\n\"Object\" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.\n\n\"Work\" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).\n\n\"Derivative Works\" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.\n\n\"Contribution\" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, \"submitted\" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as \"Not a Contribution.\"\n\n\"Contributor\" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.\n\n2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.\n\n3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.\n\n4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:\n\nYou must give any other recipients of the Work or Derivative Works a copy of this License; and\n\nYou must cause any modified files to carry prominent notices stating that You changed the files; and\n\nYou must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and\n\nIf the Work includes a \"NOTICE\" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.\n\n5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.\n\n6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.\n\n7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.\n\n8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.\n\n9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.\n"
  },
  {
    "path": "README.txt",
    "content": "*******\nLicense\n*******\n\nJBT is released under the Apache License, Version 2.0.\n\n****************************\nWhat's Java Behaviour Trees?\n****************************\n\nJBT is a Java framework for building and running behaviour trees. In the past few years, behaviour trees have been widely accepted as a tool for defining the behaviour of video games characters. However, to the best of our knowledge, there is no free-software Java implementation of such concept. With JBT we intend to provide a solid framework to build and run behaviour trees in Java.\n\nJBT has two main parts. On the one hand, there is the JBT Core (it is the Eclipse SDK project under the \"./JBTCore\" directory), which implements all the classes needed to create and run behaviour trees. JBT Core basically lets the user create behaviour trees in pure Java and then run them. In order to ease the task of creating behaviour trees, JBT Core includes several tools that automatize the process of creating behaviour trees. In particular, it can create the Java source code of a behaviour tree from its description in an XML format. By doing so, the user of this framework basically has to worry only about defining behaviour trees in XML files and implementing the low level actions and conditions that his trees will use, which are domain-dependant (that is, they depend on the game being played).\n\nOn the other hand, there is the JBT Editor (which is composed of two Eclipse SDK projects under the \"./JBTEditor\" directory). The JBT Editor is a GUI application that can be used for defining behaviour trees, and then exporting them into XML files in the format that the JBT Core understands. The JBT Editor offers a set of standard nodes for building behaviour trees. It includes nodes such as sequences, parallels, decorators, etc. For low level actions and conditions, the user can provide their conceptual definition through Make Me Play Me (MMPM) domain files (for more information on MMPM, see the Sourceforge page of the project \"Darmok 2\"). The JBT Editor is an Eclipse RCP application. You must use Eclipse SDK in order to run it.\n\nJBT implements a behaviour tree model which is mainly based on that of the book \"Artificial Intelligence for Games\", second edition, by Ian Millington and John Funge. JBT also includes the concept of \"guard\" and static and dynamic priority lists, which make use of guards. JBT behaviour trees are driven by ticks, which means that, in order for them to have CPU time, they need to be externally ticked. By following this pattern, the user can control how much CPU time the behaviour tree consumes.\n\n***********************\nFor more information...\n***********************\n\nFor more information on JBT, see the user's guide, which is located under the directory \"./UserGuide\". It contains the documentation itself along with the Latex source files.\n\n*********************\nDirectories structure\n*********************\n\n./Documentation: contains the project's documentation, explaining what JBT is and how the framework works. It also contains the source code of the documentation, which is written in Latex. Images are in several formats, including ODG.\n\n./JBTCore: contains the main framework of JBT, that is, the set of classes that are needed in order to use it. However, it is encouraged to use the JBT Editor, placed in \"./JBTEditor\". This project is structured as an Eclipse project, so we encourage the user to use Eclipse SDK when working on it.\n\n./JBTEditor: contains the JBT Editor, a GUI application that lets the user define behaviour trees and export them into XML files that are easily handled by JBT. When creating behaviour trees, the user should use this application. This is an Eclipse RCP application, so Eclipse SDK must be used to run it. In order to run the application, just open the file \"bteditor.product\" with the \"Product Configuration Editor\" (right click on the file, then \"Open With -> Product Configuration Editor\"), and in the \"Overview\" page, click on \"Launch an Eclipse application\".\n\n./UserGuide: contains the user's guide. It also contains the source code of the user's guide, which is written in Latex. Images are in several formats, including ODG.\n\n*******************\nBinary distribution\n*******************\n\nIf you just want to get the compiled version of JBT or its documentation, go to our SourceForge download page:\n\nhttps://sourceforge.net/projects/jbt/files/?source=navbar\n\n"
  },
  {
    "path": "UserGuide/UserGuide.tex",
    "content": "\\documentclass[a4paper]{article}\n\n\\usepackage{graphicx}\n\\usepackage{minted}\n\\usepackage{xspace}\n\\usepackage{verbatim}\n\n\\newcommand{\\starcraft}{StarCraft\\xspace}\n\n\\title{Java Behaviour Trees, User Guide}\n\\author{Ricardo Juan Palma Dur\\'an}\n\n\\begin{document}\n\\maketitle\n\\vspace{-0.5cm}\n\n\\tableofcontents\n\\clearpage\n\n\\section{Introduction}\n\nJava Behaviour Trees (JBT) is a Java framework for building and running behaviour trees (BTs). In the past few years, BTs have been widely accepted as a tool for defining the behaviour of video games characters. However, to the best of our knowledge, there is no free-software Java implementation of such technology. With JBT we intend to provide a solid framework to build and run BTs in Java.\n\nJBT has two main parts. On the one hand, there is the JBT Core (it is the Eclipse SDK project under the \"./JBTCore\" directory of the repository), which implements all the classes needed to create and run BTs. JBT Core basically lets the user create BTs in pure Java and then run them. In order to ease the task of creating BTs, JBT Core includes several tools that automatize the process of creating BTs. In particular, it can create the Java source code of a BT from its description in an XML format. By doing so, the user of this framework basically has to worry only about defining BTs in XML files and implementing the low level actions and conditions that his trees will use, which are domain-dependant (that is, they depend on the game being played). We provide a .jar file with all the JBT Core classes. Of course, in order to get the last version of the JBT Core the repository can be accessed.\n\nOn the other hand, there is the JBT Editor (which is composed of two Eclipse SDK projects under the \"./JBTEditor\" directory of the repository). The JBT Editor is a GUI application that can be used for defining BTs, and then exporting them into XML files in the format that the JBT Core understands. The JBT Editor offers a set of standard nodes\\footnote{Note that, when talking about BTs, \\textit{node} and \\textit{task} are used interchangeably.} for building BTs. It includes nodes such as sequences, parallels, decorators, etc. For low level actions and conditions, the user can provide their conceptual definition through Make Me Play Me (MMPM) domain files (for more information on MMPM, see the Sourceforge page of the project \"Darmok 2\"). The JBT Editor is an Eclipse RCP application, so you must use Eclipse SDK in order to run it. An alternative to run it is to use the executable files provided for each platform. Of course, if order to get the last version of the JBT Editor the repository can be accessed.\n\nJBT implements a BT model which is mainly based on that of the book \"Artificial Intelligence for Games\", second edition, by Ian Millington and John Funge. JBT also includes the concept of \"guard\" and static and dynamic priority lists, which make use of guards. JBT BTs are driven by ticks, which means that, in order for them to have CPU time, they need to be externally ticked. By following this pattern, the user can control how much CPU time the BT consumes.\n\nIn this document we explain how JBT can be used to build and run BTs. This process has the following steps:\n\n\\begin{itemize}\n  \\item Defining low level actions and conditions to be used in the trees. These actions and conditions are defined in the MMPM format.\n  \\item Implementing the low level actions and conditions. The user has to define how the low level actions and conditions work. JBT does not know how these domain-dependent actions and conditions work, so the user has to provide a Java implementation of them.\n  \\item Creating BTs with the JBT Editor. Here, the user creates BTs that are exported into generic XML files.\n  \\item Creating the Java declaration of the BTs that were declared in the XML files. This is automatically done by one of JBT's tools.\n  \\item Running the BTs by using the core classes of JBT. \n\\end{itemize}\n\nIn the next sections we will describe all of these steps. Also, we will conceptualize them through a real example on a real game, since we will build a tree that is able to control a Terran Marine of the Real Time Strategy Game \\starcraft.\n\n\\section{JBT, an Overview}\n\nIn this section we describe the JBT architecture as well as the main features that BTs have.\n\n\\subsection{Model Driven by Ticks}\\label{sec:ModelDrivenByTicks}\n\nJBT implements a BT model driven by ticks. A BT must be evaluated through ticks, so every game cycle an external caller \\textit{ticks} the tree in order for the tree to update its status. A tick is just a way of giving the tree some CPU time to update their status; in particular, ticks are used to give the nodes of the tree some time to evaluate whether they have finished or not, and consequently make the tree evolve.\n\nThe simplest approach to BTs driven by ticks is that of ticking the root node and then letting each node recursively tick its children according to its semantics. However, this is a very inefficient process, since in general the major part of the nodes of the tree are just waiting for their children to finish. Therefore, they should not receive ticks, since unless their children are done they will do nothing useful when receiving the tick. Therefore, in general only very few nodes should be ticked at a game cycle, and as a result JBT implements a model in which there is a list of \\textit{tickable} nodes. Only the nodes in the list can be ticked.\n\n\\subsection{Model Independent from Execution}\\label{sec:ModelIndependentFromExecution}\n\nWhen running a BT, there should be a clear distinction between the tree that is being run (the model) and how it is actually being run (the execution). For each particular behaviour, we distinguish between the \\textit{Model BT} that defines it and how it is being run. The \\textit{how} is what the \\textit{BT Executor} does. Basically, for every entity in the game that wants to run a behaviour (Model BT), there is a BT Executor. The BT Executor takes the Model BT and processes it (without modifying it), simulating the behaviour that is represented by the Model BT. This choice implies that, apart from the Model BT, there is another type of tree, the \\textit{Execution BT}. When an entity wants to execute a behaviour, the BT Executor takes the Model BT and creates an Execution BT to execute the behaviour. The BT Executor along with the Execution BT know how to run the behaviour that the Model BT represents.\n\n\\subsection{Architecture}\\label{sec:Architecture}\n\nFigure \\ref{fig:Overview} shows an overview of the JBT Core architecture. There is a Model BT that represents a particular behaviour. Also, there is a BT Executor for every entity that wants to run the Model BT. Each BT Executor makes use of the Model BT and builds an Execution BT that actually runs the behaviour conceptualized by the Model BT. An external Game AI ticks the BT Executors, in order for them to update the trees that they are running.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=\\textwidth]{./Images/Overview.pdf}\n \\caption{Overview of the BT architecture}\n \\label{fig:Overview}\n\\end{figure}\n\nThe user of the framework does not have to know all the details about how JBT internally works. However, since he has to implement some classes in order to run his own trees, at least he should know the general architecture of JBT.\n\n\\subsection{BT Model}\\label{sec:BTModel}\n\nBefore even starting to explain all the steps required to build and run BTs with JBT, we have to first think about what BT model JBT offers. JBT implements a BT model that is mainly based on that of \\cite{Millington09}. Our model also include guards and static and dynamic priority lists, as described in \\cite{QueryEnabledBTs}. With this model the user can implement a wide range of behaviours. \n\nFor instance, the tree of figure \\ref{fig:SimpleOpenDoor} represents a simple tree that is used by a game character that wants to open a door. First of all, it checks if the door is closed (condition \\textit{DoorClosed}). If so, then it tries to open it by executing the action \\textit{OpenDoor}.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.3\\textwidth]{./Images/SimpleOpenDoor.png}\n \\caption{a simple behaviour tree}\n \\label{fig:SimpleOpenDoor}\n\\end{figure}\n\nIn the tree of figure \\ref{fig:SimpleOpenDoor} we can see four nodes. The node called \\textit{Root} is just the root of the tree, and it has no actual meaning apart from it. Then there is a \\textit{Sequence} node, which runs in sequence both of its children, the \\textit{DoorClosed} condition and the \\textit{OpenDoor} action. The Sequence node is a standard node, but both the DoorClosed and the OpenDoor nodes are domain dependent, that is, they have been defined by the user so they have a useful meaning within the context of the game being played.\n\nThe tree of figure \\ref{fig:ComplexEnterRoom} represents the behaviour of a character that is trying to enter a room. The topmost selector succeeds as long as one of its children succeed. The first child tries to enter the room when the door is locked. In such case, the character tries several tactics to open the door. First, if it has the key, it uses it to open the door. If it does not have the key, but it has a grenade, then it uses the grenade in order to blow the door up. Finally, if none of the above conditions are met, the character will try to enter the room through its window (note that here a \\textit{Subtree Lookup} node is used. This node just runs a tree that is already defined; in this case, the tree that will be run is \\textit{EnterThroughWindow}). On the other hand, if the door is not locked and it is closed, the character will just open it up. \n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.7\\textwidth]{./Images/ComplexEnterRoom.png}\n \\caption{a complex behaviour tree}\n \\label{fig:ComplexEnterRoom}\n\\end{figure}\n\n\\subsubsection{Execution Context}\\label{sec:ExecutionContext}\n\nAll nodes in a BT have an \\textit{execution context}, which is usually shared by all of them. The execution context, or \\textit{context} for short, acts as a blackboard that can be used by nodes in order to write and read variables. For instance, a node may write a variable into the context, under a name \\textit{MyVariable}. This variable can be read then by using its name, \\textit{MyVariable}. This way, the context can be seen as a way for the nodes of a BT to communicate.\n\nHowever, not always all the nodes share the same context. In general, the context of a BT is passed down from parents to children. Thus, the initial context is that of the root of the tree, which will pass it to its children. The root's children will pass the context to their own children, and so on. Nevertheless, some nodes do not pass their own context to their children, but another one instead. This new context may be empty or not, and it may be of a different type. JBT supports the following types:\n\n\\begin{itemize}\n    \\item Basic Context: this is just a normal context, with no especial features. It is the context that the user of the framework can create. Other types of contexts are managed through decorator tasks, and the user cannot create them.\n    \\item Hierarchical Context: a Hierarchical Context has another context (the \\textit{input context}) as a base. When the Hierarchical Context cannot find a variable within its own set of variables, it will ask its input context for the variable. Note that the Hierarchical Context can be used to build a complex hierarchy of context: if the input context is a Hierarchical Context too, the request for the variable may go up the hierarchy until a non-Hierarchical Context is reached.\n    \\item Safe Context: a Safe Context has another context (the \\textit{input context}) as a base. Initially, all variables are read form the input context. However, when a variable is modified, its value is not modified in the input context, but locally modified instead. From then on, the variable will be locally read (that is, from the set of variables of the Safe Context) instead of reading if from the input context. Thus, the input context is never modified. A Safe Context can be used to situations in which a certain context (the input context) must be used in read-only mode.\n    \\item Safe Output Context: a Safe Output Context behaves much in the same way as the Safe Context. It has another context, the \\textit{input context}, as a base. However, this context also contains a set of \\textit{output variables} (that is, a list of variables' names). The list of output variables represents the variables that can be modified in the input context. Variables other than those in the list of output variables will be stored locally in the set of variables of Safe Output Context, just as if it were a Safe Context. Thus, when the Safe Output Context modifies the value of a variable, it will normally set its value in a local variable (that is, a variable belonging to the Safe Output Context). However, if the variable is one of the list of output variables, the value will be set in the input context, which will therefore be modified. When retrieving variables, a variable in the list of output variables will always be retrieved from the input context. A variable that is not in the list of output variables will also be retrieved from the input context; however, when such variable is modified, the value will be retrieved from the Safe Output Context (that is, from the moment a variable that is not in the list of output variables is modified, it is managed locally).\n\\end{itemize}\n\n\\subsubsection{Native Tasks}\n\nJBT offers a wide range of tasks that can be used to build behaviour trees. JBT basically implements the BT model described in \\cite{Millington09}, but extended with guards.\n\nJBT supports the following tasks:\n\n\\begin{itemize}\n  \\item Composite tasks: tasks with one or more children, whose execution depends on the execution of their children. The task's children are ordered.\n  \\begin{itemize}\n    \\item Sequence: task that sequentially executes all its children in order. If one fails, the Sequence task fails. If all succeeds, the Sequence task succeeds.\n    \\item Selector: task that sequentially executes all its children in order. If one succeeds, the Selector task succeeds. If all fail, the Selector task fails.\n    \\item Parallel: task that concurrently executes all its children. A Parallel task does have a \\textit{parallel policy}. If the parallel task's policy is \\textit{sequence}, the parallel fails if one child fails; if all succeed, then the parallel succeed. If the parallel task's policy is \\textit{selector}, the parallel fails if all its children fail. If one succeeds, then the parallel also succeeds.\n    \\item Random Selector: task that executes all its children in a random order. If one fails, the Sequence task fails. If all succeeds, the Sequence task succeeds.\n    \\item Random Sequence: task that sequentially executes all its children in random order. If one succeeds, the Selector task succeeds. If all fail, the Selector task fails.\n    \\item Dynamic Priority List: task that executes the child with the highest priority whose guard is evaluated to true. At every AI cycle, the children's guards are re-evaluated, so if the guard of the running child is evaluated to false, it is terminated, and the child with the highest priority starts running. The Dynamic Priority List task finishes when no guard is evaluated to true (thus failing) or when its active child finishes (returning the active child's termination status).\n    \\item Static Priority List: task that executes the child with the highest priority whose guard is evaluated to true. Unlike the Dynamic Priority List, the Static Priority List does not keep evaluating its children's guards once a child is spawned. The Static Priority List task finishes when no guard is evaluated to true (thus failing) or when its active child finishes (returning the active child's termination status).\n  \\end{itemize}\n  \\item Decorator tasks: tasks with one child whose purpose is to alter the way other tasks behave.\n  \\begin{itemize}\n    \\item Interrupter: task that controls the termination of its child task. An Interrupter simply lets its child task run normally. If the child returns a result, the Interrupter will return it. However, the Interrupter can be asked to terminate the child task and return an specified status when done so. The task that can interrupt an Interrupter is the Perform Interruption task.\n    \\item Inverter: task used to invert the status code returned by its child. When the decorated task finishes, its status code gets inverted.\n    \\item Limit: task that limits the number of times a task can be executed. This decorator is used when a task (the child of the decorator) must be run a maximum number of times. When the maximum number of times is exceeded, the decorator will fail forever on.\n    \\item Repeat: task that runs its child task forever. When its child task finishes, it runs it once more.\n    \\item Until Fail: task that runs its child as long as it does not fail. When the child task fails, Until Fail succeeds.\n    \\item Succeeder: task that runts its child but, no matter its returned status, the succeeder will always succeed.\n    \\item Hierarchical Context Manager: task that creates a new context for its child. The context that it creates is an empty (with no variables) Hierarchical Context whose input context is the context that is passed to the Hierarchical Context Manager.\n    \\item Safe Output Context Manager: task that creates a new context for its child. The context that it creates is an empty (with no variables) Safe Output Context whose input context is the context that is passed to the Safe Output Context Manager.\n    \\item Safe Context Manager: task that creates a new context for its child. The context that it creates is an empty (with no variables) Safe Context whose input context is the context that is passed to the Safe Context Manager.\n  \\end{itemize}\n  \\item Leaf tasks: tasks with no children.\n  \\begin{itemize}\n    \\item Wait: task that keeps running for a period of time, and then succeeds. The user can specify for how long (in milliseconds) the Wait task should be running.\n    \\item Subtree Lookup: see the following sections to see what this node does.\n    \\item Perform Interruption: task that interrupts an Interrupter task.\n    \\item Variable Renamer: task that renames a variable in the context.\n    \\item Success: task that immediately succeeds.\n    \\item Failure: task that immediately fails.\n    \\item Action: generic action that is executed in the game engine.\n    \\item Condition: generic condition that is executed in the game engine.\n  \\end{itemize}\n\\end{itemize}\n\n\\section{Step 1: Defining Low Level Actions and Conditions}\\label{sec:DefiningLowLevelActionsAndConditions}\n\nThe first step\\footnote{Well, it does not necessarily have to be the first step, but we have to start at somewhere.} when creating BTs is to define the set of low level actions and conditions that the trees will be using. These actions and conditions are domain dependent, that is, they depend on the game that the trees will be run for. For instance, if we are dealing with a first person shooter (FPS from now on), then we may need actions and conditions such as those used in the trees of section \\ref{sec:BTModel}. \n\nHowever, we are going to build a more complex example. Here we are going to define a behaviour tree that is able to control a Terran Marine of \\starcraft, so we have to define actions and conditions that are useful for such context. The behaviour that we want to implant in the Terran Marine is as follows:\n\nThe marine is constantly checking three conditions. If there is no danger around the marine, then he just patrols around its current position. Patrolling around a position means that the marine will move randomly around a central point, and will attack whatever he finds on its way. However, if he finds himself in a low level danger situation (that is, a dangerous situation he thinks he can survive), he will try to kill whatever enemy finds dangerous. On the other hand, if he finds himself in a high level danger situation (that is, a dangerous situation he thinks he cannot survive), he will run away to the closest base.\n\nWe therefore define some actions and conditions that will be used by the BT:\n\n\\begin{itemize}\n  \\item Actions: \n  \\begin{itemize}\n\t\\item Attack: this action just makes the marine attacks a specific unit.\n\t\\item Move: this action makes the marine move to a specific target position on the map.\n\t\\item AttackMove: this action makes the marine mote to a specific target position on the map. Also, if he finds an enemy on its way, he will combat the enemy.\n\t\\item ComputeClosestBasePosition: this action computes the position of the base that is closest to the marine.\n\t\\item ComputeCharacterPosition: this action just computes the current position of the marine.\n\t\\item ComputeRandomClosePosition: given a position $A$, this action computes a random position that is close to $A$.\n  \\end{itemize}\n  \\item Conditions:\n  \\begin{itemize}\n\t\\item LowDanger: this condition checks if the marine is in a low danger situation.\n\t\\item HighDanger: this condition checks if the marine is in a high danger situation.\n  \\end{itemize}\n\\end{itemize}\n\nActions and conditions must be defined according to the MMPM domain file format. For those unaware of what MMPM is, this does not really pose a problem, since what we are really interested in is the format that MMPM follows in order to define actions and conditions.\n\nA MMPM domain file defines the conceptual level of a game (its \\textit{domain}), by declaring what \\textit{entities}, \\textit{actions}, \\textit{sensors} and \\textit{goals} are present in the game. We will not describe all of them, but only what we need to declare actions and conditions that can be used in BTs.\n\nA MMPM domain file has the following structure:\n\n\\begin{minted}{xml}\n  <Domain package=\"valid Java package name\">\n    <ActionSet>\n      <!-- Actions declaration -->\n    </ActionSet>\n    \n    <SensorSet>\n      <!-- Sensors declaration -->\n    </SensorSet>\n\n    <GoalSet>\n      <!-- Goals declaration -->\n    </GoalSet>\n\n    <EntitySet>\n      <!-- Entities declaration -->\n    </EntitySet>\n  </Domain>\n\\end{minted}\n\nHowever, we are only interested in the set of actions and conditions, so $<GoalSet>$ and $<EntitySet>$ can be left empty (but they actually have to be present). The $<ActionSet>$ element defines the set of actions that are present in the game, which are also the set of low level actions that can be used when building BTs. An $<ActionSet>$ element contains a sequence of $<Action>$ elements, each one being an action. An $<Action>$ element has one attribute, its name (which is called $name$). The $<SensorSet>$ element defines the set of \\textit{sensors} that can be used in the game. A $<SensorSet>$ element contains a sequence of $<Sensor>$ elements, each one being a sensor. A $<Sensor>$ element has two attributes: its $name$ and its $type$. In MMPM, a \\textit{sensor} is an operation that queries something about the world. As a result, a sensor can return \\textit{any}\\footnote{Really not \\textit{any}.} type of value. Here we are interested in sensors whose type is \\textit{boolean} ($BOOLEAN$ in the MMPM domain file), since they represent what in BTs is known as conditions, that is, a query operation that returns either true or false. Therefore, the set of boolean sensors of the MMPM domain file is the set of conditions that can be used when building BTs. \n\nBoth actions and sensors may have input parameters. An input parameter is a parameter that is supposed to be used by the action or sensor when running. For instance, the \\textit{Move} action above does have one input parameter, which is the target position where the unit must go to. An input parameter has a name and a type. Thus, both $<Action>$ and $<Sensor>$ elements may have a sequence of $<Parameter>$ elements, each one being a parameter. Each $<Parameter>$ element has two attributes, its $name$ and its $type$. Therefore, actions and sensors have the following structure:\n\n\\begin{minted}{xml}\n<Action name=\"MyActionName\">\n  <Parameter name=\"ParameterName1\" type=\"ParameterType1\"/>\n  ...\n  <Parameter name=\"ParameterNameN\" type=\"ParameterTypeN\"/>\n</Action>\n\n<Sensor name=\"MySensorName\" type=\"BOOLEAN\">\n  <Parameter name=\"ParameterName1\" type=\"ParameterType1\"/>\n  ...\n  <Parameter name=\"ParameterNameM\" type=\"ParameterTypeM\"/>\n</Sensor>\n\\end{minted}\n\nMMPM supports the following types for parameter types: $FLOAT$, $BOOLEAN$, $STRING$, $INTEGER$, $DIRECTION$, $COORDINATE$, $PLAYER$, $ENTITY\\_ID$ and $ENTITY\\_TYPE$. This set of parameter types may seem overwhelming, which is why in general several of them are not used. $FLOAT$, $BOOLEAN$, $STRING$ and $INTEGER$ are self-explanatory. $DIRECTION$ represents an integer value, which is why, if it is used as the type of a parameter, JBT will treat it just as an integer. $COORDINATE$ represents a coordinate in an N-dimensional coordinate system. In practice, a $COORDINATE$ value is a non-empty sequence of real values (for instance, \"23 -4.5 67\", \"-3.45 \" or \"12.45 -0.34 9.44 -12.3\"). $PLAYER$ represents the name of a player of the game, so in practice it is treated as a string ($STRING$). $ENTITY\\_ID$ represents the identifier of an entity in the game. In practice, it is treated as a string ($STRING$). $ENTITY\\_TYPE$ represents the type of an entity. In practice, it is treated as a string ($STRING$).\n\nAs a consequence, the user will generally use just $FLOAT$, $BOOLEAN$, $STRING$, $INTEGER$ and $COORDINATE$, since the rest of MMPM parameter types are equivalent to $STRING$.\n\nMMPM format, however, does not include an important parameter type, \\textit{object}. In general, there will be actions and sensors will make use of input parameters of many types. In order to be able to manage a wide range of types, JBT extends the MMPM domain file format so that parameters also accept the $OBJECT$ type. An $OBJECT$ is just a variable of any type.\n\nThe MMPM domain file that defines the set of actions and conditions for the Terran Marine example is as follows:\n\n\\begin{minted}{xml}\n  <Domain package=\"mypackage\">\n    <ActionSet>\n      <!-- Orders the current unit to attack another unit -->\n      <Action  name=\"Attack\">\n        <Parameter name=\"target\" type=\"ENTITY_ID\"/>\n      </Action>\n\n      <!-- Orders the current unit to go to a target position -->\n      <Action  name=\"Move\">\n        <Parameter name=\"target\" type=\"COORDINATE\"/>\n      </Action>\n\n      <!-- Orders the current unit to go to a target position. If\n      an enemy is found along the way, the unit will combat him -->\n      <Action name=\"AttackMove\">\n        <Parameter name=\"target\" type=\"COORDINATE\"/>\n      </Action>\n\n      <!-- Orders the position of the base that is closest to the\n      current unit -->\n      <Action  name=\"ComputeClosestBasePosition\"/>\n\n      <!-- Computes the position of the current unit -->\n      <Action  name=\"ComputeCharacterPosition\"/>\n      \n      <!-- Computes a random position that is close to the input\n      position -->\n      <Action name=\"ComputeRandomClosePosition\">\n        <Parameter name=\"initialPosition\" type=\"COORDINATE\"/>\n      </Action>\n    </ActionSet>\n    \n    <SensorSet>\n      <!-- Checks if the current unit is in a low danger situation -->\n      <Sensor name=\"LowDanger\" type=\"BOOLEAN\"/>\n\n      <!-- Checks if the current unit is in a high danger situation -->\n      <Sensor name=\"HighDanger\" type=\"BOOLEAN\"/>\n    </SensorSet>\n\n    <EntitySet>\n    </EntitySet>\n\n    <GoalSet>\n    </GoalSet>\n  </Domain>\n\\end{minted}\n\nOne of the ways nodes in BTs communicate with each other is by using the execution \\textit{context}: a node may write a variable into the context and another node may use it later. In this scenario it is therefore very important that nodes know the name of the variables that other nodes put into the context. In the set of actions and conditions above there are several nodes that manipulate the context. In particular:\n\n\\begin{itemize}\n  \\item The \\textit{ComputeCharacterPosition} action writes into the context a variable of type $COORDINATE$ containing the current position of the unit. The name of such variable is \\textit{CharacterPosition}.\n  \\item The \\textit{ComputeClosestBasePosition} action writes into the context a variable of type $COORDINATE$ containing the position of the closest base. The name of such variable is \\textit{ClosestBasePosition}.\n  \\item The \\textit{ComputeRandomClosePosition} action writes into the context a variable of type $COORDINATE$ containing a random position that is close to the input position. The name of such variable is \\textit{RandomClosePosition}.\n  \\item The \\textit{LowDanger} sensor writes into the context a variable of type $ENTITY\\_ID$ containing the identifier of the closest dangerous enemy. The name of such variable is \\textit{LowDangerTarget}.\n\\end{itemize}\n\n\\section{Step 2: Implementing Low Level Actions and Conditions}\\label{sec:ImplementingLowLevelActionsAndConditions}\n\nOnce that low level actions and conditions have been defined (see section \\ref{sec:DefiningLowLevelActionsAndConditions}), the next step is to provide an implementation for them. JBT does not know what does an action such as \\textit{ComputeCharacterPosition} or \\textit{AttackMove}. Therefore, it is the user of the framework who has to tell JBT how they work.\n\nThe life cycle of actions and conditions of a BT is very simple: initially, when the flow of execution reaches the node, it is \\textit{spawned}. From then on, at every \\textbf{game tick}, the node is \\textit{ticked}. Every time the node is ticked, it has to report about its termination status, so that the tree may evolve in case the node has finished. As a result, the programmer will have to define how all the domain dependent actions and conditions behave when they are spawned and ticked.\n\nActions and conditions are each represented by two classes of the JBT Core, \\textit{jbt.model.task.leaf.action.ModelAction.java} and \\textit{jbt.execution.task.leaf.action.ExecutionAction.java} in the case of actions, and \\textit{jbt.model.task.leaf.condition.ModelCondition.java} and \\textit{jbt.execution.task.leaf.condition.ExecutionCondition.java} in the case of conditions. Domain dependent actions such as the ones defined above must extend these classes in order for JBT to know how to work with them.\n\nIn JBT there are two classes for every type of node. Remember from section \\ref{sec:ModelIndependentFromExecution} that in JBT there are two types of BTs, the \\textit{Model BT} and the \\textit{Execution BT}. The Model BT is composed of \\textit{model tasks\\footnote{Remember that in BT terminology, a task and a node are the same thing.}}, while the Execution BT is composed of \\textit{execution tasks}. It is the execution tasks that define how the tasks work, that is, how they behave when they are spawned and ticked. In the case of actions and conditions, the four classes presented above are the base classes for their respective representation as model tasks and execution tasks.\n\nJBT Core offers a tool that semi-automatize the task of creating all the classes from each action and condition of the MMPM domain file. It is the Java class \\textit{jbt.tools.btlibrarygenerator.ActionsAndConditionsGenerator.java}.\n\nFor every MMPM action, ActionsAndConditionsGenerator creates two classes: one extending ModelAction, which conceptually represents the action, and another one extending ExecutionAction, which represents how the action actually works -whose abstract methods must be completed in order for the action to perform any task at all. We will explain this later-.\n\nAlso, for every MMPM boolean sensor, two classes are created: one extending ModelCondition, which conceptually represents the condition (sensor), and another one extending ExecutionCondition, which represents how the condition actually works -whose abstract methods must be completed in order for the condition to perform any task at all. We will explain this later-.\n\nThe syntax of the program is as follows:\n\n\\begin{verbatim}\nActionsAndConditionsGenerator -c configurationFile [-r relativePath] [-o] \n\\end{verbatim}\n\nWhere \\verb@configurationFile@ is an XML file that contains all the information required to run the application. The syntax of such file is:\n\n\\begin{minted}{xml}\n<Configuration>\n  <DomainFile>MMPMDomainFile1</DomainFile>\n  <DomainFile>MMPMDomainFile2</DomainFile>\n  ...\n  <DomainFile>MMPMDomainFileN</DomainFile>\n  \n  <ModelActionsPackage>Name of the package for generated model\n  action classes</ModelActionsPackage>\n  \n  <ModelConditionsPackage>Name of the package for generated model \n  condition classes</ModelConditionsPackage>\n  \n  <ModelActionsOutputDirectory>Name of the directory where model \n  actions are created</ModelActionsOutputDirectory>\n  \n  <ModelConditionsOutputDirectory>Name of the directory where model \n  conditions are created</ModelConditionsOutputDirectory>\n  \n  <ExecutionActionsPackage>Name of the package for generated \n  execution action classes</ExecutionActionsPackage>\n  \n  <ExecutionConditionsPackage>Name of the package for generated\n  execution condition classes</ExecutionConditionsPackage>\n  \n  <ExecutionActionsOutputDirectory>Name of the directory where \n  execution actions are created</ExecutionActionsOutputDirectory>\n  \n  <ExecutionConditionsOutputDirectory>Name of the directory where \n  execution conditions are created</ExecutionConditionsOutputDirectory>\n</Configuration>\n\\end{minted}\n\nThe order in which the elements are specified is not relevant. If the input files do contain only actions, parameters related to conditions may not be specified, and vice versa.\n\nThe -r option is used to add a path to the beginning of the files listed in the configuration file; as a result, each file is considered to be placed at the path specified in the -r option. The -r option may not be specified, in which case the files are considered to be at the current execution directory.\n\nThe -o option (standing for \\textit{overwrite}) is either is specified or not. If it is not specified, generated output files will not overwrite any existing file in the file system, and as a result, the corresponding class file will not be produced in case there is a file with the same name in the file system. If the option -o is specified, then generated output files will overwrite any file in the file system whose name matches.\n\nSo, in brief, this program parses a MMPM domain file and, for each action and boolean sensors produces the JBT classes that are required to run such actions and conditions in a BT. In particular, the created execution classes define what they will do when spawned and ticked.\n\nThe generated ModelAction and ModelCondition classes are complete, so they do not need to be modified after being created by the ActionsAndConditionsGenerator. However, the ExecutionAction and ExecutionCondition generated classes contain a set of abstract method that must be implemented according to the semantics of the respective actions and conditions, so that they do what they are expected to do. This is the only step that must be done in order for JBT to be able to work with the low level actions and conditions provided by the user.\n\nIn particular, the abstract methods that must be implemented are:\n\n\\begin{minted}{java}\nprotected void internalSpawn();\nprotected Status internalTick();\nprotected void internaTerminate();\nprotected void restoreState(ITaskState state);\nprotected ITaskState storeState();\nprotected ITaskState storeTerminationState(); \n\\end{minted}\n\n\\textit{internalSpawn()} and \\textit{internalTick()} are the most important methods, so they should be well implemented.\n\n\\textit{internalSpawn()} represents the spawning process of the task (action or condition). When the flow of execution of the tree reaches the task, \\textit{internalSpawn()} gets called. Therefore, this method must be defined so that it starts the process associated to the task. For instance, the \\textit{internalSpawn()} method of the \\textit{Move} action above should order the current unit to go to the target position; the \\textit{internalSpawn()} method of the \\textit{Attack} action above should order the current unit to attack the target enemy. \n\nThe automatically generated skeleton contains an initial implementation of the \\textit{internalSpawn()} method, which is as follows:\n\n\\begin{minted}{java}\nprotected void internalSpawn() {\n  /*\n   * Do not remove this first line unless you know what it does and you\n   * need not do it.\n   */\n  this.getExecutor().requestInsertionIntoList(\n    jbt.execution.core.BTExecutor.BTExecutorList.TICKABLE, this);\n\n  /* TODO: this method's implementation must be completed. */\n  System.out.println(this.getClass().getCanonicalName() + \" spawned\");\n}     \n\\end{minted}\n\nThis initial definition contains a very important aspect of the execution process of the task. As it is said in the comments, the first line should not be removed unless the user knows what it does and he thinks it is not necessary to do it. What that line does is to request that the task be inserted into the list of tickable nodes (section \\ref{sec:ModelDrivenByTicks}). Since in general this is what we want the task to do (because we want the task to receive ticks), \\textbf{that line should not be removed}.\n\nWhen implementing all these abstract methods, the user may access the execution context of the task by calling \\textit{this.getContext()}. That method just returns the context of the task as an \\textit{IContext} object. The \\textit{IContext} interface defines two main methods, one for reading a variable from the context, and another one for writing a variable into the context:\n\n\\begin{minted}{java}\npublic interface IContext {\n  /**\n   * Returns the value of a variable whose name is <code>name</code>, or null\n   * if it is not found.\n   */\n  public Object getVariable(String name);\n\n  /**\n   * Sets the value of a variable. If the variable already existed, its value\n   * is overwritten. <code>value</code> may be null in order to clear the\n   * value of the variable.\n   */\n  public boolean setVariable(String name, Object value);\n  ...\n}\n\\end{minted}\n\nRemember that MMPM domain files also let the designer specify input parameters for actions and sensors. These are parameters that actions and sensors are supposed to use when running. The generated JBT ExecutionAction and ExecutionCondition classes include \\textit{getter} methods for such input parameters. As a result, the programmer will be able to access the value of the input parameters in the abstract methods he has to implement, by using the getter methods. The value for the input parameters are either retrieved from the execution context(IContext) or directly provided at construction time, but these details are hidden from the programmer that implements the action or condition (he should just use the getter methods to retrieve whatever input parameters may be needed). For instance, for the \\textit{Attack} action, the next getter method is created:\n\n\\begin{minted}{java}\n/**\n  * Returns the value of the parameter \"target\", or null in case it has not\n  * been specified or it cannot be found in the context.\n  */\npublic java.lang.String getTarget(){...}\n\\end{minted}\n\nThus, in the implementation of all the abstract methods, the user should use this \\textit{getTarget()} method if he wanted to retrieve the identifier of the target unit to attack. This whole thing about the getter methods may be a little bit confusing at first. However, bear in mind that when the user creates a behaviour tree (which we will explain later), he can either specify that the input parameter of a task must be retrieved from a variable of the context, or provide an actual value for the parameter. When the task is spawned and run, it does not really care about where the parameter comes from as long as there is a value that it can use. The generated getter methods hide these details, so no matter where the parameter comes from (either from the context or from an actual value provided by the user when he created the BT), it just provides the value that the task expects to use.\n\nOnce the task has been spawned, it will be ticked whenever the BT gets ticked. The ticking process is performed by the \\textit{internalTick()} method. Thus, from the moment the task gets spawned, at every tick, \\textit{internalTick()} will be called. \n\n\\textit{internalTick()} is in charge of keeping track of the termination status of the task. If the task has not finished yet when \\textit{internalTick()} is called, then it must return the termination status \\textit{Status.RUNNING}. If the task has finished successfully, then the method should return the termination status \\textit{Status.SUCCESS}. If the task has finished unsuccessfully, then the method should return \\textit{Status.FAILURE}. For instance, the \\textit{internalTick()} method of the \\textit{Move} action of our Terran Marine example should check if the unit has arrived at the target position. If it has not, then \\textit{Status.RUNNING} should be returned. If the unit has arrived at the target position, then \\textit{Status.SUCCESS} should be returned. Finally, y for some reason the action could not be completed (for instance because the target position is unreachable), then \\textit{Status.FAILURE} should be returned. Note that, even though the \\textit{Status} enum has more values other than \\textit{SUCCESS}, \\textit{FAILURE} and \\textit{RUNNING}, the \\textit{internalTick()} method must return only one of these three. Doing otherwise will throw an exception.\n\nOne of the ideas behind the \\textit{driven by ticks} architecture is that, when the tree is ticked, it should not take very long for it to return, so \\textit{internalSpawn()} and \\textit{internalTick()} are supposed to return very quickly. However, sometimes tasks perform computationally expensive processes. In that case, instead of performing the expensive computation inside the \\textit{internalSpawn()} method of the task, it should be performed in another execution thread. When \\textit{internalSpawn()} is called, it should create another thread that carries out the computation. On the other hand, the \\textit{internalTick()} method would query the thread to check if its computation has finished or not, and return \\textit{Status.RUNNING}, \\textit{Status.SUCCESS} or \\textit{Status.FAILURE} accordingly.\n\nThe \\textit{internalTerminate()} method is not so important. Sometimes, when a BT is running, some of its tasks get abruptly interrupted. This happens for instance when one of the children of a parallel task (which is following the \\textit{sequence policy}) fails. When that happens, all of its children, which were being concurrently evaluated, get terminated, so they must stop running. Other scenario in which this happens is when a perform interruption task interrupts an interrupter. In that case, the interrupter and its child stop running.\n\nIt is for cases like these that the \\textit{internalTerminate()} method is defined. The \\textit{internalTerminate()} method must make the task stop running. For instance, in the case of the \\textit{Move} action, it should order the unit to stop moving. Moreover, if the task started some other thread to perform some computations, it should stop it. In general, when the \\textit{internalTerminate()} is called, the task should stop running and should also free whatever resources it acquired.\n\nWith respect to the \\textit{storeState()}, \\textit{storeTermination} and \\textit{restoreState(ITaskState state)}, they are related to \\textit{persistent tasks}. Some tasks in BTs are persistent in the sense that, after finishing, if they are spawned again, they should remember past information. Take for example the Limit task. A Limit task allows to run its child node only a certain number of times (for example, 5). After being spawned, it has to remember how many times it has been run so far, so that, once the threshold is exceeded, it fails. In general, it could be said that some tasks need to retain some persistent information to be used in the future when the task is spawned again.\n\nAll the persistent information of a task should be saved into an \\textit{ITaskState} object. The ITaskState interface represents a collection of variables that can be accessed:\n\n\\begin{minted}{java}\npublic interface ITaskState {\n  /* Returns the value of a state variable by its name. */\n  public Object getStateVariable(String name);\n} \n\\end{minted}\n\nWhen a task finishes, (it returns \\textit{Status.SUCCESS} or \\textit{Status.FAILURE} in \\textit{internalTick()}), the \\textit{storeState()} method is automatically called by the framework. This method should then create and return an \\textit{ITaskState} object containing all the persistent information that the task may need if it is spawned again in the future. If no persistent information is needed, then \\textit{null} must be returned. An \\textit{ITaskState} object is just a collection of variables that can be retrieved by name. In order for the user to create \\textit{ITaskState} objects, he can make use of the factory class \\textit{jbt.execution.core.TaskStateFactory}.\n\nIt also may be the case that a task that is abruptly terminated (\\textit{internalTerminate()} is called) needs to store persistent information. If that is the case, then \\textit{storeTerminationState()} is automatically called by the framework, instead of \\textit{storeState()}. \\textit{storeTerminationState()} follows the same semantics as \\textit{storeState()}.\n\nThe persistent information that a task stores via its \\textit{storeState()} and \\textit{storeTerminationState()} methods is restored via the \\textit{restoreState(ITaskState state)} method. This method is called just before the task is spawned (that is, before calling \\textit{internalSpawn()}). In \\textit{restoreState(ITaskState state)} the task should analyse the input \\textit{ITaskState} object and restore whatever information it contains (if \\textit{null}, then it means that there is no past information to remember).\n\nIn the case of the \\textit{Move} action of the Terran Marine example, the \\textit{storeState()}, \\textit{storeTerminationState()} and \\textit{restoreState(ITaskState state)} methods are empty.\n\nAs a final example on implementing low level actions and conditions, lets follow the whole process for the few actions and conditions defined in the domain explained in section \\ref{sec:DefiningLowLevelActionsAndConditions}.\n\nLet us suppose that the MMPM domain file is stored in the file \\textit{TerranMarineDomain.xml}. Then, the ActionsAndConditionsGenerator application could be run with the next configuration file (stored in \\textit{configurationFile.xml}):\n\n\\begin{minted}{xml}\n<Configuration> \n  <DomainFile>TerranMarineDomain.xml</DomainFile>\n  <ModelActionsPackage>bts.actions</ModelActionsPackage>\n  <ModelConditionsPackage>bts.conditions</ModelConditionsPackage>\n  <ModelActionsOutputDirectory>src/bts/actions\n  </ModelActionsOutputDirectory>\n  <ModelConditionsOutputDirectory>src/bts/conditions\n  </ModelConditionsOutputDirectory>\n  <ExecutionActionsPackage>bts.actions.execution\n  </ExecutionActionsPackage>\n  <ExecutionConditionsPackage>bts.conditions.execution\n  </ExecutionConditionsPackage>\n  <ExecutionActionsOutputDirectory>src/bts/actions/execution\n  </ExecutionActionsOutputDirectory>\n  <ExecutionConditionsOutputDirectory>src/bts/conditions/execution\n  </ExecutionConditionsOutputDirectory>\n</Configuration>\n\\end{minted}\n\nLet us suppose that the ActionsAndConditionsGenerator is called with the following arguments:\n\n\\begin{verbatim}\nActionsAndConditionsGenerator -c configurationFile.xml -r /home/outputDirectory\n\\end{verbatim}\n\nThen, the ActionsAndConditionsGenerator will parse the domain file \\textit{/home/outputDirectory/\\-TerranMarine.xml}, and it will create output classes for each action and boolean sensor in the domain file, which will be stored in the corresponding files. For instance, for the \\textit{Attack} action, two classes will be created, \\textit{/home/outputDirectory/src/bts/actions/Attack.java} (the model task class) and \\textit{/home/outputDirectory/src/bts/actions/execution/Attack.java} (the execution task class). For the boolean \\textit{LowDanger} sensor, two classes will be created, \\textit{/home/outputDirectory/src/bts/conditions/LowDanger.java} (the model task class) and \\textit{/home/outputDirectory/src/bts/conditions/execution/LowDanger.java} (the execution task class). Then we should implement the abstract methods of all the execution classes. For instance, the implementation of the \\textit{Move.java} execution class may be like this:\n\n\\begin{minted}{java}\n/** ExecutionAction class created from MMPM action Move. */\npublic class Move extends jbt.execution.task.leaf.action.ExecutionAction {\n  ...\n  /**\n   * Returns the value of the parameter \"target\", or null if not found\n   * anywhere.\n   */\n  public float[] getTarget() {\n    /* Whatever has been automatically generated. */\n    ...\n  }\n\n  protected void internalSpawn() {\n    this.getExecutor().requestInsertionIntoList(\n            jbt.execution.core.BTExecutor.BTExecutorList.TICKABLE, this);\n\n    /* \n     * Retrieve the identifier of the entity (Terran Marine) running \n     * this action from the context. Here we are supposing that the \n     * context will contain it.\n     */\n    String currentEntityID = (String) this.getContext().\n                                      getVariable(\"CurrentEntityID\");\n\n    /* \n     * Now we assume that there is a generic \"Game Engine\" that can\n     * be used to send generic orders to units of the game. Note that, in\n     * order to retrieve the target position, we use the automatically\n     * generated getter method.\n     */\n    GameEngine.sendMoveOrder(currentEntityID, this.getTarget());\n  }\n\n  protected jbt.execution.core.ExecutionTask.Status internalTick() {\n    /*\n     * In this method we will just check whether the unit has reached the\n     * target position. If the target position is unreachable, then \n     * Status.FAILURE is returned. Otherwise, if the unit has reached the\n     * target position, Status.SUCCESS is returned. Otherwise,\n     * Status.RUNNING is returned.\n     */\n    String currentEntityID = (String) this.getContext().\n                                      getVariable(\"CurrentEntityID\");\n\n    if(!Util.reachablePosition(currentEntityID, this.getTarget())){\n      return Status.FAILURE;\n    }\n\n    float[] currentPosition = GameEngine.getPosition(currentEntityID);\n    float[] targetPosition = this.getTarget();\n\n    if(Math.distance(currentPosition, targetPosition) < 0.5){\n      return Status.SUCCESS;\n    }\n    else{\n      return Status.RUNNING;\n    }\n  }\n\n  protected void internalTerminate() {\n    /* We just order the unit to stop. */\n    String currentEntityID = (String) this.getContext().getVariable(\n            Constants.CONTEXT_CURRENT_ENTITY);\n\n    GameEngine.stopUnit(currentEntityID);\n  }\n\n  protected void restoreState(jbt.execution.core.ITaskState state) {\n    /* Does nothing. */\n  }\n\n  protected jbt.execution.core.ITaskState storeState() {\n    /* No persistent state information to return. */\n    return null;\n  }\n\n  protected jbt.execution.core.ITaskState storeTerminationState() {\n    /* No persistent state information to return. */\n    return null;\n  }\n}\n\\end{minted}\n\n\\section{Step 3: Creating BTs with the JBT Editor}\\label{sec:CreatingBTsWithTheJBTEditor}\n\nOnce that the domain dependent actions and conditions of the game have been defined and a JBT implementation for them has been provided, the next steps are quite easy to follow. \n\nIt is now when the user should define the behaviour trees to use in the game. Following our Terran Marine example, we will define several trees that implement the behaviour that we described in section \\ref{sec:DefiningLowLevelActionsAndConditions}.\n\nBehaviour trees are first described in XML files. Here we are not going to describe the XML format that JBT understands, since we discourage the user from writing them in plain text. Instead, we propose to use the JBT Editor (composed of the two projects under the ``./JBTEditor'' directory of the repository), a GUI application through which it is really easy to define behaviour trees.\n\nThe JBT Editor is an Eclipse RCP application. As such, it must be run under the Eclipse SDK environment or use the executable files provided for each platform. When opening if from Eclipse, you have to open the project \\textit{jbt.tools.bteditor}, and then open the file \\textit{bteditor.product} with the Product Configuration Editor. Once it has been opened, go to the ``Overview'' page, and click on ``Launch an Eclipse application''. A window like that of figure \\ref{fig:JBTEditor} should show up.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=\\textwidth]{./Images/JBTEditor.png}\n \\caption{JBT Editor after being opened}\n \\label{fig:JBTEditor}\n\\end{figure}\n\nThe JBT Editor is a very simple tool, so learning how to use it should not take very long.\n\nIn order to create a new BT, just click on the ``new BT'' icon or select ``File->New BT''. A new editor should open up showing an empty BT (that is, a tree containing only a single node, the root of the tree. To the right of the window there is a tree-like menu (the \\textit{Nodes Navigator}) where the user can select nodes to build the tree. In order to add a node to a tree, just drag it from the Nodes Navigator and drop it onto whatever node of the tree to insert it as a child or sibling of the target node. The root node can have only one child. However, other nodes, such as sequences or selectors may have many of them. Decorators can have only one child, and leaf nodes do not have any children.\n\nBy using the set of provided standard nodes of the Nodes Navigator, the user can build complex behaviour trees. However, in order to build really useful trees, the user must use the domain-dependent actions and conditions from the game. The JBT Editor lets the user load a MMPM domain file as described in section \\ref{sec:DefiningLowLevelActionsAndConditions}. Just click on the ``Load MMPM Domain'' or select ``File->Load MMPM Domain'' and select the file that contains the low level actions and conditions. After doing so, the Nodes Navigator will be added a new entry for the actions and conditions within the domain file, which the user will be able to use when building BTs.\n\nFor instance, if we load the domain file described in section \\ref{sec:DefiningLowLevelActionsAndConditions}, we get the actions and conditions shown in figure \\ref{fig:LoadedDomain}.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.4\\textwidth]{./Images/LoadedDomain.png}\n \\caption{The Nodes Navigator after loading the domain file}\n \\label{fig:LoadedDomain}\n\\end{figure}\n\nThe JBT Editor lets the user specify values for the input parameters of nodes. By double clicking on a node that has input parameters, a dialog where the user can specify values for the input parameters. For instance, if the AttackMove action is double clicked, then the dialog of figure \\ref{fig:InputParameterDialog} is shown. In the dialog the user can specify a value for the parameter ``target'', whose type is $COORDINATE$. Thus, the text field only supports values such as ``45 62'' or ``10 -3 45''. As we mentioned in section \\ref{sec:ImplementingLowLevelActionsAndConditions}, when building a BT, the user can specify whether the input parameters of actions and conditions are retrieved from the context or an actual value is provided at construction time. The ``From context'' check box lets the user specify if the parameter has to be retrieved from the context or not. If the check box is not ticked, then the user must provide a value for the parameter in the text field. However, if the check box is ticked, then what the user does is to specify the name of the context's variable where the value of the parameter will be retrieved from.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.4\\textwidth]{./Images/InputParameterDialog.png}\n \\caption{The dialog for editing the input parameters of the AttackMove action}\n \\label{fig:InputParameterDialog}\n\\end{figure}\n\nFor instance, in figure \\ref{fig:ParameterNotFromContext} the user has specified a value (``12 34 4.5'') for the input parameter ``target'' of the AttackMove action. However, in figure \\ref{fig:ParameterFromContext} the user has indicated that the value of the input parameter ``target'' will be retrieved from the variable ``TargetVariable'' of the context.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.4\\textwidth]{./Images/ParameterNotFromContext.png}\n \\caption{A parameter for which an actual value is provided}\n \\label{fig:ParameterNotFromContext}\n\\end{figure}\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.4\\textwidth]{./Images/ParameterFromContext.png}\n \\caption{A parameter whose value will be retrieved from the context}\n \\label{fig:ParameterFromContext}\n\\end{figure}\n\nOnce the BT has been completed, the user can save it as an XML file. In order to do so, just click on the ``Save'' or ``Save As'' icons (or select ``File->Save'' or ``File->Save As'') and enter a file name.\n\nWhen saving a BT, the JBT Editor checks if the structure of the tree is correct. If not, incorrect nodes are highlighted in red color and an explanation for the error is shown in the \\textit{Node Info} view (to the right of the window) when the node is selected.\n\nAlso note that a name for the BT must be provided. The name of a BT is specified in the root node of the tree. When the root is double clicked, a dialog appears that lets the user assign the tree a name. BTs' names are very important, because it is the way that trees are referenced. In particular, names are essential in terms of reusability. For instance, the \\textit{Subtree Lookup} task simulates a particular BT, and the way that the Subtree Lookup knows what BT to simulate is by providing the name of the tree.\n\nLet us now design the BT that implements the Terran Marine behaviour that we described in section \\ref{sec:DefiningLowLevelActionsAndConditions}. An initial implementation for such tree could be that of figure \\ref{fig:InitialTerranMarineBT}. \n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.4\\textwidth]{./Images/InitialTerranMarineBT.png}\n \\caption{Initial tree for the Terran Marine behaviour}\n \\label{fig:InitialTerranMarineBT}\n\\end{figure}\n\nThe behaviour is pretty simple: the tree is always executing (see the \\textit{Repeat} node) a \\textit{Dynamic Priority List} (DPL) that is constantly checking three conditions:\n\n\\begin{itemize}\n  \\item If the current unit is in a low danger situation, then the unit is ordered to attack the closest dangerous enemy. This is represented by the first child of the DPL.\n  \\item If the current unit is in a high danger situation, then the unit runs away to the closest base. This is represented by the second child of the DPL (the Sequence).\n  \\item Finally, if none of the above conditions are met, the unit just ``patrols''. This is represented by the third child of the DPL, the Subtree Lookup node (we will further explain this later).\n\\end{itemize}\n\nThere are some details that must still be defined though. So far, the tree does not provide a way of checking the three conditions above. In order to do so, we can make use of guards, since the DPL interacts with children that have guards defined. In order to add a guard to a node, just right click on the node and select ``Edit Guard''. A dialog should appear that lets the user edit the guard of the node.\n\nIn JBT, guards are represented by BTs. In particular, a guard can be a single node or a complete and correct BT. When the user clicks on ``Add simple guard'', a dialog lets the user select a single leaf node (action, condition or a standard leaf node) to be used as a guard. If the user clicks on the ``Add complex guard'', however, a new editor is opened so the user can create a complete BT to be used as the node's guard. \n\nIn our example, the guard of the \\textit{Attack} action is just the condition \\textit{LowDanger}. Therefore, we have to click on the ``Add simple guard'' button and select the ``LowDanger'' task from the list, as shown in figure \\ref{fig:LowDangerGuard}. Note that after inserting the guard, a small shield icon will appear on top of the node that has been added a guard.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.55\\textwidth]{./Images/LowDangerGuard.png}\n \\caption{Selecting a guard for the \\textit{Attack} node}\n \\label{fig:LowDangerGuard}\n\\end{figure}\n\nIn the case of the \\textit{Sequence} node, its guard is just the condition \\textit{HighDanger}, so we add it just the same way. Now we have to define the input parameters of the tasks.\n\nFirst of all there is the \\textit{Attack} node. The intended behaviour is for the soldier to attack the closest unit once that the \\textit{LowDanger} condition has been triggered. Thankfully, \\textit{LowDanger} writes into the context the identifier of the closest entity (as we described in section \\ref{sec:DefiningLowLevelActionsAndConditions}), in a variable with name \\textit{LowDangerTarget}. Therefore, the input parameter of \\textit{Attack} should be as represented in figure \\ref{fig:AttackParameter}, since the value of the input parameter of the \\textit{Attack} action is present in a variable of the context whose name is \\textit{LowDangerTarget}.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.4\\textwidth]{./Images/AttackParameter.png}\n \\caption{The input parameter of \\textit{Attack}}\n \\label{fig:AttackParameter}\n\\end{figure}\n\nWith respect to the \\textit{Move} action, the idea is that the unit goes to the closest base. Since the position of the closest base has been computed by the \\textit{ComputeClosestBasePosition} action and written into the context in a variable with name \\textit{ClosestBasePosition}, then the input argument of \\textit{Move} must be read from the context and its value must be the variable name \\textit{ClosestBasePosition}.\n\nNow let us look at the final part of the tree. When none of the danger conditions are met, the marine has to patrol around its current position. Since \\textit{patrolling} is a complex task that may be reused in another trees, we decide to put it into another BT and reuse of from the Terran Marine BT. This is accomplished by the Subtree Lookup task, whose input parameter is set to \\textit{StandardPatrol}. \\textit{StandardPatrol} is the name of the tree that will implement the patrol behaviour.\n\nThe tree of figure \\ref{fig:StandardPatrol} implements the patrol behaviour. Initially, the current position of the unit is computed by the \\textit{ComputeCharacterPosition} action. This position is written into the variable \\textit{CharacterPosition} of the context, as we mentioned in section \\ref{sec:DefiningLowLevelActionsAndConditions}. From then on, the is a forever loop (Repeat node) that constantly computes a random position that is close to the one computed by the \\textit{ComputeCharacterPosition} task, and then orders the unit to \\textit{AttackMove} to that target position. It is important to note that the tree must have a name (it is set in the root of the tree), in this case \\textit{StandardPatrol}, which is the name that was used in the \\textit{SubtreeLookup} task of the Terran Marine BT.\n\n\\begin{figure}\n \\centering\n \\includegraphics[width=0.4\\textwidth]{./Images/StandardPatrol.png}\n \\caption{The BT for the Standard Patrol behaviour}\n \\label{fig:StandardPatrol}\n\\end{figure}\n\nNote that a name for the Terran Marine BT must be provided, so we will assume that its name is \\textit{TerranMarine}.\n\n\\section{Step 4: Creating a Java Declaration of the BTs}\n\nOnce our BTs have been defined in the XML format of the JBT Editor, the next steps are quite easy. Actually, there is no more complex work to be done by the user from now on.\n\nSo far we have provided a definition and implementation of domain dependent low level actions and conditions. We have also defined our BTs and stored them in XML files using the JBT Editor. The next step is to provide a Java implementation of the trees so that JBT can actually run them.\n\nThis step is automatically performed by the JBT Core. The JBT Core has an application, the \\textit{jbt.tools.btlibrarygenerator.BTLibraryGenerator.java}, that basically takes the XML definition of some BTs and creates a .java file that contains the implementation of such trees.\n\nIn JBT, BTs are grouped together in BT libraries. A BT library is just a collection of BTs that can be retrieved by name (actually, the name that is specified for the tree in the JBT Editor). A BT library is implemented by the \\textit{IBTLibrary} interface. This interface just represents a set of BTs that can be retrieved by name:\n\n\\begin{minted}{java}\npublic interface IBTLibrary extends Iterable<Pair<String, ModelTask>> {\n    /* Returns the BT of name name, or \"null\" if not found. */\n    public ModelTask getBT(String name);\n}\n\\end{minted}\n\nNote that, in JBT, a Model BT (see section \\ref{sec:ModelIndependentFromExecution}) is represented by the abstract class \\textit{ModelTask}. Thus, when we ask an \\textit{IBTLibrary} to give us a BT by its name, it just retrieves the Mode BT that represents the tree, which is represented by a \\textit{ModelTask}.\n\nWhat the BTLibraryGenerator does is to automatically create a BT library, that is, a class that implements the \\textit{IBTLibrary} interface, that can be used to retrieve the BTs defined in the XML files. In particular, given a set of behaviour trees specified in XML files and the MMPM definition of the low level actions and conditions that are used in the trees, it creates the corresponding Java class.\n\nThe syntax of this program is as follows:\n\n\\begin{verbatim}\nBTLibraryGenerator -c configurationFile [-r relativePath] [-o] \n\\end{verbatim}\n\nWhere \\verb@configurationFile@ is an XML file that contains all the information required to run the application. The syntax of such a file is:\n\n\\begin{minted}{xml}\n<Configuration>\n  <BTLibrary>\n    <BTFile>BTFile1</BTFile>\n    <BTFile>BTFile2</BTFile>\n    ...\n    <BTFile>BTFileN</BTFile>    \n \n    <DomainFile>MMPMDomainFile1</DomainFile>\n    <DomainFile>MMPMDomainFile2</DomainFile>\n    ...\n    <DomainFile>MMPMDomainFileN</DomainFile>\n  \n    <ModelActionsPackage>Name of the package where model action \n    classes are placed</ModelActionsPackage>\n  \n    <ModelConditionsPackage>Name of the package where model \n    condition classes are placed</ModelConditionsPackage>\n  \n    <LibraryClassName>Name of the class that is going to be \n    created</LibraryClassName>\n  \n    <LibraryPackage>Name of the package for the generated BT \n    library</LibraryPackage>\n    \n    <LibraryOutputDirectory>Name of the directory where the \n    generated library is going to be stored</LibraryOutputDirectory>\n  </BTLibrary>\n  \n  <BTLibrary>\n  ...\n  </BTLibrary>\n\n  ...\n</Configuration>\n\\end{minted}\n\nThe order in which the elements are specified is not relevant.\n\nIn the file the user can define several BT libraries, each one within the \\textit{BTLibrary} element. For each BT library defined in a \\textit{BTLibrary} element, the program will produce an output file (class implementing the \\textit{IBTLibrary} interface) for the library.\n\nThe -r option is used to add a path to the beginning of the files listed in the configuration file; as a result, each file is considered to be placed at the path specified in the -r option. The -r option may not be specified, in which case the files are considered to be at the current execution directory.\n\nThe -o option (standing for overwrite) is either is specified or not. If it is not specified, the generated output files will not overwrite any existing file in the file system, and as a result, a behaviour tree library may not be produced in case there is a file with the same name in the file system. If the option -o is specified, then generated output files will overwrite any file in the file system whose name matches.\n\nIn the Terran Marine example, we want to create a BT library that contains the two BTs that we created in section \\ref{sec:CreatingBTsWithTheJBTEditor}. Let us suppose that the tree defining the Terran Marine behaviour was stored in the file \\textit{TerranMarine.xbt}, and that the tree defining the patrol behaviour was stored in the file \\textit{StandardPatrol.xbt}. Then, we could use the following configuration file to produce the BT library:\n\n\\begin{minted}{xml}\n<Configuration>\n  <BTLibrary>\n    <BTFile>TerranMarine.xbt</BTFile>\n    <BTFile>StandardPatrol.xbt</BTFile>\n    <LibraryClassName>TerranMarineBTLibrary</LibraryClassName>\n    <LibraryPackage>bts.btlibrary</LibraryPackage>\n    <LibraryOutputDirectory>src/bts/btlibrary</LibraryOutputDirectory>\n    <DomainFile>TerranMarineDomain.xml</DomainFile>\n    <ModelActionsPackage>bts.actions</ModelActionsPackage>\n    <ModelConditionsPackage>bts.conditions</ModelConditionsPackage>\n  </BTLibrary>\n</Configuration>\n\\end{minted}\n\nWhere note that \\textit{TerranMarineDomain.xml} is the domain file that we created in section \\ref{sec:DefiningLowLevelActionsAndConditions}. The \\textit{ModelActionsPackage} and \\textit{ModelConditionsPackage} must also be those specified in the configuration file of the ActionsAndConditionsGenerator.\n\nSo now let us suppose that the configuration file above is stored in a file called \\textit{BTConfigurationFile.xml}. The BTLibraryGenerator may be called with the following arguments:\n\n\\begin{verbatim}\nBTLibraryGenerator -c BTConfigurationFile.xml -r /home/outputDirectory\n\\end{verbatim}\n\nThen, the BTLibraryGenerator will parse the configuration file and it will realize that it has to create just one BT library (the only \\textit{BTLibrary} element in the configuration file). It will then parse the XML files of the trees that the library will contain (\\textit{TerranMarine.xbt} and \\textit{StandardPatrol.xbt}) and finally will create an BT library class named \\textit{TerranMarineBTLibrary}, which will be placed in the output directory \\textit{home/outputDirectory/stc/bts/btlibrary}. Our purpose here is not to analyse all the details of the produced class, but just point out that it can be used through the public interface that it implements (the \\textit{IBTLibrary} mentioned earlier). The class \\textit{TerranMarineBTLibrary} will contain both trees, so\n\n\\begin{minted}{java}\ngetBT(\"TerranMarine\");\n\\end{minted}\n\nwill return the tree implementing the Terran Marine behaviour, and\n\n\\begin{minted}{java}\ngetBT(\"StandardPatrol\");\n\\end{minted}\n\nwill return the tree implementing the patrol behaviour.\n\nThe way we can actually run these trees is explained in section \\ref{sec:RunningTheBehaviourTrees}.\n\n\\section{Step 5: Running the Behaviour Trees}\\label{sec:RunningTheBehaviourTrees}\n\nSo that is almost all. The last step is to run the trees that have been put into one or several BT libraries.\n\nThe way BTs are run in JBT is really simple, and follows the ideas mentioned in sections \\ref{sec:ModelDrivenByTicks}, \\ref{sec:ModelIndependentFromExecution} and \\ref{sec:Architecture}.\n\nBasically, the IBTLibrary is used to retrieve Model BTs. Once a Model BT has been retrieved, a BT Executor must be created to run it. The BT Executor must be fed with an initial context that the BT will use when running\\footnote{Remember that the BT that actually runs is the Execution BT, but that detail is of no interest at this point.}. Let's suppose that we have created our \\textit{TerranMarineBTLibrary}, and that we want to use it in order to control a particular Terran Marine in the game. First of all, two details must be taken into account.\n\nOn the one hand, the actions that we implemented (well, we actually implemented only one action, \\textit{Move}, but you get the idea) made the assumption that the identifier of the unit running the action was present in the context, under a variable named ``CurrentEntityID'' (you can revisit the implementation in section \\ref{sec:ImplementingLowLevelActionsAndConditions}). In general, it may be necessary for the context that is used by the tree to have some initial variables in it. In such case, an appropriate context should be created.\n\nOn the other hand, the \\textit{SubtreeLookup} task poses a big problem when it is run. Remember that the \\textit{SubtreeLookup} node simulates the behaviour of a tree given its name. However..., how does it know from where to retrieve a tree given its name? For instance, in the case of the Terran Marine tree, the \\textit{SubtreeLookup} is suppose to emulate a tree named \\textit{StandardPatrol}, but it does not know where to get such a tree from. \n\nThe context is used in order to fix this problem. Actually, the context must contain all the trees that are used within the internal execution of the tree. In this case it means that the context that is initially passed to the tree must contain the BT \\textit{StandardPatrol}. If it does not, when the Terran Marine tree is run it will throw an exception complaining about not being able to find the corresponding tree.\n\nWe can see that an appropriate context must be created to run the tree. JBT Core provides a factory class, the \\textit{jbt.execution.core.ContextFactory.java} that defines several methods for creating generic contexts (\\textit{IContext} objects of the Basic Context type described in section \\ref{sec:ExecutionContext}). In our case, we can make use of the method that takes as input an \\textit{IBTLibrary} and makes an \\textit{IContext} that contains all the BTs of the BT library. Then, we could make use of the methods in the \\textit{IContext} interface to add the identifier of the marine that is supposed to be run by the tree:\n\n\\begin{minted}{java}\n/* First of all, we create the BT library. */\nIBTLibrary btLibrary = new TerranMarineBTLibrary();\n\n/* Then we create the initial context that the tree will use. */\nIContext context = ContextFactory.createContext(btLibrary);\n\n/* \n * Now we are assuming that the marine that is going to be\n * controlled has an id of \"terranMarine1\"\n */\ncontext.setVariable(\"CurrentEntityID\",\"terranMarine1\");\n\\end{minted}\n\nThe next step is to create the BT Executor to run the tree. In JBT, a BT Executor is represented by the \\textit{IBTExecutor} interface. In order to create an \\textit{IBTExecutor} object to run a particular BT, the factory class \\textit{jbt.execution.core.BTExecutorFactory.java} must be used. The \\textit{BTExecutorFactory} has several methods for creating BT Executors; one of them receives as input the Model BT to run and the initial context:\n\n\\begin{minted}{java}\n/* Now we get the Model BT to run. */\nModelTask terranMarineTree = btLibrary.getBT(\"TerranMarine\");\n\n/* Then we create the BT Executor to run the tree. */\nIBTExecutor btExecutor = BTExecutorFactory.createBTExecutor(terranMarineTree, context);\n\n/* And finally we run the tree through the BT Executor. */\ndo{\n  btExecutor.tick();\n}while(btExecutor.getStatus() == Status.RUNNING);\n\\end{minted}\n\nNote that running a BT is a very simple process. The \\textit{IBTExecutor} interface defines one main method, \\textit{tick()}, which implements the ticking process of a BT. Every time the \\textit{tick()} method is called, the BT is given some CPU time to do its work, as was explained in section \\ref{sec:ModelDrivenByTicks}.\n\nIn order to check the current execution status of the tree, the \\textit{getStatus()} method is used. As long as the status is \\textit{Status.RUNNING}, the tree has not finished so it should continue to receive ticks.\n\\bibliographystyle{plain}\n\\bibliography{UserGuideBib}\n\n\\end{document}"
  },
  {
    "path": "UserGuide/UserGuideBib.bib",
    "content": "@Book{Millington09,\n  author =\t {Ian Millington and John Funge},\n  title = \t {Artificial Intelligence for Games},\n  publisher = \t {Morgan Kaufmann},\n  year = \t {2009},\n  edition =      {Second}\n}\n\n@misc{AIGameDev,\n\tauthor = {Alex J. Champandard},\n\ttitle = {http://aigamedev.com}\n}\n\n@article{QueryEnabledBTs,\n    author = {Fl{\\'{o}}rez-Puga, Gonzalo and G{\\'{o}}mez-Mart{\\'{\\i}}n, Marco A. and G{\\'{o}}mez-Mart{\\'{\\i}}n, Pedro P. and D{\\'{\\i}}az-Agudo, Bel{\\'{e}}n and Gonz{\\'{a}}lez-Calero, Pedro A.},\n    editor = {Lucas, Simon M.},\n     month = nov,\n     title = {Query Enabled Behaviour Trees},\n   journal = {IEEE Transactions On Computational Intelligence And AI In Games},\n    volume = {1},\n    number = {4},\n      year = {2009},\n     pages = {298-308},\n      issn = {1943-068X},\n       url = {http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=5325892},\n       doi = {10.1109/TCIAIG.2009.2036369}\n}\n"
  },
  {
    "path": "UserGuide/userguide.kilepr",
    "content": "[General]\ndef_graphic_ext=eps\nimg_extIsRegExp=false\nimg_extensions=.eps .jpg .jpeg .png .pdf .ps .fig .gif\nkileprversion=2\nkileversion=2.0.85\nlastDocument=UserGuide.tex\nmasterDocument=\nname=UserGuide\npkg_extIsRegExp=false\npkg_extensions=.cls .sty .bbx .cbx .lbx\nsrc_extIsRegExp=false\nsrc_extensions=.tex .ltx .latex .dtx .ins\n\n[Tools]\nMakeIndex=\nQuickBuild=\n\n[document-settings,item:UserGuide.tex]\nBookmarks=\nEncoding=UTF-8\nHighlighting=LaTeX\nIndentation Mode=\nMode=LaTeX\nReadWrite=true\n\n[item:UserGuide.tex]\narchive=true\ncolumn=73\nencoding=UTF-8\nhighlight=LaTeX\nline=512\nmode=LaTeX\nopen=true\norder=0\n\n[item:userguide.kilepr]\narchive=true\ncolumn=4\nencoding=\nhighlight=\nline=0\nmode=\nopen=false\norder=-1\n\n[view-settings,view=0,item:UserGuide.tex]\nCursorColumn=73\nCursorLine=512\n"
  }
]