Package jade.core

Examples of jade.core.BehaviourID


    List l = agentListeners.startScanning();
    if (l != null) {
      AgentEvent ev = null;
      if (b == b.root()) {
        // The behaviour has been added to the Agent
        ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, agentID, new BehaviourID(b), myID());
      }
      else {
        // The behaviour is actually a new child that has been added to a CompositeBehaviour
        //FIXME: TO be done
        //ev = new AgentEvent(AgentEvent.ADDED_SUB_BEHAVIOUR, agentID, new BehaviourID(b.getParent()), new BehaviourID(b), myID());
View Full Code Here


  private void fireRemovedBehaviour(AID agentID, Behaviour b) {
    // NOTE: A normal synchronized block could create deadlock problems
    // as it prevents concurrent scannings of the listeners list.
    List l = agentListeners.startScanning();
    if (l != null) {
      AgentEvent ev = new AgentEvent(AgentEvent.REMOVED_BEHAVIOUR, agentID, new BehaviourID(b), myID());
      Iterator it = l.iterator();
      while (it.hasNext()) {
        AgentListener al = (AgentListener) it.next();
        al.removedBehaviour(ev);
      }
View Full Code Here

  private void fireChangedBehaviourState(AID agentID, Behaviour b, String from, String to) {
    // NOTE: A normal synchronized block could create deadlock problems
    // as it prevents concurrent scannings of the listeners list.
    List l = agentListeners.startScanning();
    if (l != null) {
      AgentEvent ev = new AgentEvent(AgentEvent.CHANGED_BEHAVIOUR_STATE, agentID, new BehaviourID(b), from, to, myID());
      Iterator it = l.iterator();
      while (it.hasNext()) {
        AgentListener al = (AgentListener) it.next();
        al.changedBehaviourState(ev);
      }
View Full Code Here

      // Notify all the needed events 
      fireChangedAgentState(targetName, as, as);
     
      Iterator itReady = readyBehaviours.iterator();
      while(itReady.hasNext()) {
        BehaviourID bid = (BehaviourID)itReady.next();
        AgentEvent ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, targetName, bid, myContainer.getID());
        tn.addedBehaviour(ev);
      }
     
      Iterator itBlocked = blockedBehaviours.iterator();
      while(itBlocked.hasNext()) {
        BehaviourID bid = (BehaviourID)itBlocked.next();
        AgentEvent ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, targetName, bid, myContainer.getID());
        tn.addedBehaviour(ev);
        ev = new AgentEvent(AgentEvent.CHANGED_BEHAVIOUR_STATE, targetName, bid, Behaviour.STATE_READY, Behaviour.STATE_BLOCKED, myContainer.getID());
        tn.changedBehaviourState(ev);
      }
View Full Code Here

        state = b.getTo();
    }

    public void createTree(DefaultMutableTreeNode r, Iterator v) {
        while(v.hasNext()){
            BehaviourID b=(BehaviourID)v.next();
            //DefaultMutableTreeNode rc = new DefaultMutableTreeNode(new BehaviourTreeNode(b, blocked));
            DefaultMutableTreeNode rc = new DefaultMutableTreeNode(new BehaviourTreeNode(b, state));
            if (!b.isSimple()) {
                createTree(rc,b.getAllChildren());
            }
            r.add(rc);
        }
    }
View Full Code Here

           
            while(e.hasMoreElements())
            {
                DefaultMutableTreeNode node =(DefaultMutableTreeNode)e.nextElement();
                BehaviourTreeNode bNode = (BehaviourTreeNode)node.getUserObject();
                BehaviourID b = bNode.getBehaviour();

                if (b.getCode() == behaviour.getCode() && b.equals(behaviour))
                {
                    Object[]o=node.getPath();
                    TreePath tp= new TreePath(o);
                    tree.setSelectionPath(tp);
                    description(gui.getBehaviourText(), b);
                   
                    // Update the blocked status.
                    /*if ((blocked && !bNode.isBlocked()) ||
                        (!blocked && bNode.isBlocked())) {
                        bNode.setBlocked(blocked);
                        model.nodeChanged(node);
                    }*/
                    if (!state.equals(bNode.getState())) {
                      bNode.setState(state);
                      model.nodeChanged(node);
                    }

                    bFound = true;
                    break;
                }
            }
           
            /* If we didn't find the node in the tree, add it now.
            if (!bFound)
                action = ADD_NODE;
            */
        }

        if (action == ADD_NODE)
        {
            //DefaultMutableTreeNode beh = new DefaultMutableTreeNode(new BehaviourTreeNode(behaviour, blocked));
            DefaultMutableTreeNode beh = new DefaultMutableTreeNode(new BehaviourTreeNode(behaviour, state));

            if (!behaviour.isSimple()) {
                createTree(beh, behaviour.getAllChildren());
            }

            model.insertNodeInto(beh,root,model.getChildCount(root));
        }
       
        if (action == REMOVE_NODE)
        {
            Enumeration e=root.breadthFirstEnumeration();
            e.nextElement();
            while(e.hasMoreElements())
            {
                DefaultMutableTreeNode node =(DefaultMutableTreeNode)e.nextElement();
                BehaviourTreeNode b = (BehaviourTreeNode)node.getUserObject();
                if (b.getBehaviour().equals(behaviour)){
                    model.removeNodeFromParent(node);
                    break;
                }
            }
        }
View Full Code Here

TOP

Related Classes of jade.core.BehaviourID

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