⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testagentframe.java

📁 java实现的P2P多agent中间件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/******************************************************************
 * JADE - Java Agent DEvelopment Framework is a framework to develop
 * multi-agent systems in compliance with the FIPA specifications.
 * Copyright (C) 2002 TILAB S.p.A.
 *
 * This file is donated by Acklin B.V. to the JADE project.
 *
 *
 * GNU Lesser General Public License
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation,
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 * ***************************************************************/
package jade.tools.testagent;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;

import jade.core.AID;
import jade.core.Agent;
import jade.tools.gui.ACLPanel;
import jade.tools.gui.ACLTracePanel;
import jade.lang.acl.ACLMessage;

/**
 *  This class is builds up the GUI of the TestAgent
 *
 * @author     Chris van Aart - Acklin B.V., the Netherlands
 * @created    May 6, 2002
 */

public class TestAgentFrame extends JFrame {

  /**
   *  Constructor for the TestAgentFrame object
   *
   * @param  agent  Description of Parameter
   */
  public TestAgentFrame(TestAgent agent) {
    getImages();
    this.agent = agent;
    aclPanel = new ACLPanel(agent);
    aclTreePanel = new ACLTracePanel(agent);
    try {
      jbInit();
      this.setSize(600, 600);
      this.setTitle("Jade TestAgent beta - " + agent.getName());
      this.setFrameIcon("images/dummy.gif");
      this.setVisible(true);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }


  /**
   *  Gets the ItsMsg attribute of the TestAgentFrame object
   *
   * @return    The ItsMsg value
   */
  public ACLMessage getItsMsg() {
    return aclPanel.getItsMsg();
  }


  public void getImages() {

    try {
      newIcon =
        new ImageIcon(this.getClass().getResource("images/new.gif"));
      openIcon =
        new ImageIcon(this.getClass().getResource("images/open.gif"));
      saveIcon =
        new ImageIcon(this.getClass().getResource("images/save.gif"));
      sendIcon =
        new ImageIcon(this.getClass().getResource("images/send.gif"));
      readQueueIcon =
        new ImageIcon(this.getClass().getResource("images/readqueue.gif"));
      saveQueueIcon =
        new ImageIcon(this.getClass().getResource("images/writequeue.gif"));
      currentIcon =
        new ImageIcon(this.getClass().getResource("images/current.gif"));
      replyIcon =
        new ImageIcon(this.getClass().getResource("images/reply.gif"));
      viewIcon =
        new ImageIcon(this.getClass().getResource("images/inspect.gif"));
      deleteIcon =
        new ImageIcon(this.getClass().getResource("images/delete.gif"));
      statisticsIcon =
        new ImageIcon(this.getClass().getResource("images/book.gif"));
      quitIcon =
        new ImageIcon(this.getClass().getResource("images/quit.gif"));
      systemIcon =
        new ImageIcon(this.getClass().getResource("images/system.gif"));
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }

  }


  /**
   *  Sets the ItsMsg attribute of the TestAgentFrame object
   *
   * @param  msg  The new ItsMsg value
   */
  public void setItsMsg(ACLMessage msg) {
    aclPanel.setItsMsg(msg);
  }


  /**
   *  Sets the FrameIcon attribute of the TestAgentFrame object
   *
   * @param  iconpath  The new FrameIcon value
   */
  public void setFrameIcon(String iconpath) {
    ImageIcon image = new ImageIcon(this.getClass().getResource(iconpath));
    setIconImage(image.getImage());
  }


  /**
   *  Adds a feature to the MessageNode attribute of the TestAgentFrame object
   *
   * @param  msg        The feature to be added to the MessageNode attribute
   * @param  direction  The feature to be added to the MessageNode attribute
   */
  public void addMessageNode(String direction, ACLMessage msg) {
    aclTreePanel.addMessageNode(direction, msg);
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void helloWorldMenuItem_actionPerformed(ActionEvent e) {
    agent.doHelloWorld();
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void amsRegMenuItem_actionPerformed(ActionEvent e) {
    agent.doRegisterAMS();
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void systemMenuItem_actionPerformed(ActionEvent e) {
    agent.doSystemOut();
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void exitMenuItem_actionPerformed(ActionEvent e) {
    agent.doExit();
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void newButton_actionPerformed(ActionEvent e) {
    agent.doNewMessage();
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void sendButton_actionPerformed(ActionEvent e) {
    agent.sendMessage();
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void pingLausanneMenuItem_actionPerformed(ActionEvent e) {
    agent.doLausannePing();
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void amsDeregMenuItem_actionPerformed(ActionEvent e) {
    agent.doDeRegisterAMS();
  }


  /**
   *  Description of the Method
   *
   * @param  e  Description of Parameter
   */
  void amsSearchMenuItem_actionPerformed(ActionEvent e) {
    agent.doSearchAMS();
  }


  void dfRegMenuItem_actionPerformed(ActionEvent e) {
    agent.doRegisterDF();
  }


  void dfDeregMenuItem_actionPerformed(ActionEvent e) {
    agent.doDeregisterDF();
  }


  void dfSearchMenuItem_actionPerformed(ActionEvent e) {
    agent.doSearchDF();
  }


  void aboutMenuItem_actionPerformed(ActionEvent e) {
    new AboutFrame().show();
  }


  void readQueueButton_actionPerformed(ActionEvent e) {
    this.aclTreePanel.loadQueue();
  }


  void writeQueueButton_actionPerformed(ActionEvent e) {
    this.aclTreePanel.saveQueue();
  }


  void currentButton_actionPerformed(ActionEvent e) {

    ACLMessage currentACL = this.aclTreePanel.getCurrentACL();
    if (currentACL != null) {
      this.aclPanel.setItsMsg((ACLMessage)currentACL.clone());
    }
  }


  void viewButton_actionPerformed(ActionEvent e) {
    this.aclTreePanel.doShowCurrentACL();
  }


  void deleteButton_actionPerformed(ActionEvent e) {
    this.aclTreePanel.deleteCurrent();
  }


  void statisticsButton_actionPerformed(ActionEvent e) {
    this.aclTreePanel.showStastistics();
  }


  void quitButton_actionPerformed(ActionEvent e) {
    agent.doDelete();
    System.exit(1);
  }


  void replyButton_actionPerformed(ActionEvent e) {
    agent.doReply();
  }


  void newMenuItem_actionPerformed(ActionEvent e) {
    agent.doNewMessage();
  }


  void loadMenuItem_actionPerformed(ActionEvent e) {
    this.aclPanel.loadACL();
  }


  void saveMenuItem_actionPerformed(ActionEvent e) {
    this.aclPanel.saveACL();
  }


  void sendMenuItem_actionPerformed(ActionEvent e) {
    agent.sendMessage();
  }


  void saveButton_actionPerformed(ActionEvent e) {
    this.aclPanel.saveACL();
  }


  void openButton_actionPerformed(ActionEvent e) {
    this.aclPanel.loadACL();
  }


  void saveQueueMenuItem_actionPerformed(ActionEvent e) {
    this.aclTreePanel.saveQueue();
  }


  void claerQueueMenuItem_actionPerformed(ActionEvent e) {
    this.aclTreePanel.clearACLModel();
  }


  void currentMenuItem_actionPerformed(ActionEvent e) {
    ACLMessage currentACL = this.aclTreePanel.getCurrentACL();
    if (currentACL != null) {
      this.aclPanel.setItsMsg((ACLMessage)currentACL.clone());
    }

  }


  void replyMenuItem_actionPerformed(ActionEvent e) {
    agent.doReply();
  }


  void deleteMenuItem_actionPerformed(ActionEvent e) {
    this.aclTreePanel.deleteCurrent();
  }


  void statisticsMenuItem_actionPerformed(ActionEvent e) {
    this.aclTreePanel.showStastistics();
  }


  void loadMsgMenuItem_actionPerformed(ActionEvent e) {
    this.aclPanel.loadACL();
  }


  void saveMsgMenuItem_actionPerformed(ActionEvent e) {
    this.aclPanel.saveACL();
  }


  void loadQMenuItem_actionPerformed(ActionEvent e) {
    this.aclTreePanel.loadQueue();
  }


  void saveQMenuItem_actionPerformed(ActionEvent e) {
    this.aclTreePanel.saveQueue();
  }


  void systemButton_actionPerformed(ActionEvent e) {
    this.aclTreePanel.doSystemOut();
  }


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -