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

📄 dfagentdscdlg.java

📁 JADE(JAVA Agent开发框架)是一个完全由JAVA语言开发的软件,它简化了多Agent系统的实现。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************
JADE - Java Agent DEvelopment Framework is a framework to develop 
multi-agent systems in compliance with the FIPA specifications.
Copyright (C) 2000 CSELT S.p.A. 

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.gui;

//#J2ME_EXCLUDE_FILE

// Import required Java classes 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.List;
import java.util.Iterator;
import java.util.Enumeration;

// Import required JADE classes
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;
import jade.core.AID;

/**
   This class implements the gui to manipulate a
   <code>DFAgentDescription</code>.

@author Tiziana Trucco - CSELT S.p.A
@author alessandro Chiarotto - TILAB
@version $Date: 2005-04-15 17:45:02 +0200 (ven, 15 apr 2005) $ $Revision: 5669 $
*/
public class DFAgentDscDlg extends JDialog implements ActionListener
{
	
	/**
  @serial
  */
  Dialog     dlgParent;
  /**
  @serial
  */
  DFAgentDescription dfdAgent;
	/**
  @serial
  */
  DFAgentDescription out;
	/**
  @serial
  */
  AID newAID = null;
	/**
  @serial
  */
  boolean editable;
	/**
  @serial
  */
  boolean checkSlots;
	
	/**
  @serial
  */
  private VisualStringList ontologiesListPanel;
	/**
  @serial
  */
  private VisualStringList languagesListPanel;
	/**
  @serial
  */
  private VisualStringList protocolsListPanel;
	/**
  @serial
  */
  private VisualServicesList servicesListPanel;
	/**
  @serial
  */
  private JTextField agentName;
  
  /* Button to set the exipire date of the lease time */
  private JButton setLTDateb;
    
  /* expire date of lease time set by the user */ 
  private java.util.Date absDateLeaseTime;
  
  /* text field showing the value set by the user in the dialog */
  private JTextField textFieldLeaseTime;

  /*#DOTNET_INCLUDE_BEGIN
  private Component myComponent;
  private Component getOwner() {return myComponent;}
  #DOTNET_INCLUDE_END*/
  
    /**
       Create a dialog with the given parent.
       @param parent The <code>Frame</code> that is the parent window
       of this dialog.
    */
    public DFAgentDscDlg(Frame parent) 
    {
	super(parent);
	dlgParent = (Dialog) this;
	/*#DOTNET_INCLUDE_BEGIN
	myComponent = parent;
	#DOTNET_INCLUDE_END*/
    }

    /**
       Create a dialog with the given parent.
       @param parent The <code>Dialog</code> that is the parent window
       of this dialog.
    */
    public DFAgentDscDlg(Dialog parent) 
    {
	super(parent);
	dlgParent = (Dialog) this;
	/*#DOTNET_INCLUDE_BEGIN
	myComponent = parent;	
	#DOTNET_INCLUDE_END*/
    }
	
	/**
	* This method show a a giu for a <code>DFAgentDescription</code>.
	* @param dfd the DFAgentDescrption to show
	* @param ed true if the fields of the gui must be editable, false otherwise.
	* @param checkMandatorySlots true to verify that a value is specified for all the mandatory fields, false otherwise.  
	* @return a DFAgentDescription if the OK button is pressed, false if the Cancel button is pressed.
	*/
	public DFAgentDescription ShowDFDGui(DFAgentDescription dfd, boolean ed , boolean checkMandatorySlots)
	{
		setTitle("DF description");

		this.out = null;
		this.editable = ed;
		this.checkSlots = checkMandatorySlots;
	
		if(dfd != null)
		 {
		 	dfdAgent = dfd;
		 	newAID = dfd.getName();
		 }
		else
		 dfdAgent = new DFAgentDescription();
		 
		JPanel p = new JPanel();
		JPanel main = new JPanel();
	
		JLabel l;
		JPanel bPane;
		JButton AIDButton;
		
		main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
		
		p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
		Border raised = BorderFactory.createRaisedBevelBorder();
		main.setBorder(raised);
		
		// Agent name
		main.add(Box.createRigidArea(new Dimension(300,5)));

		l = new JLabel("Agent-name:");
		l.setPreferredSize(new Dimension(80,26));
		p.add(l);
		p.add(Box.createHorizontalGlue());
		agentName = new JTextField();
		agentName.setEditable(false);
		agentName.setPreferredSize(new Dimension (250, 26));
		agentName.setMinimumSize(new Dimension(250,26));
		agentName.setMaximumSize(new Dimension(250,26));
		agentName.setBackground(Color.white);
		AID aidtemp = dfdAgent.getName();
    if (aidtemp == null)
    	agentName.setText("");
    else
      agentName.setText(aidtemp.getName());
    
		AIDButton = new JButton(editable ? "Set":"View");
		
		AIDButton.addActionListener(new ActionListener(){
    	public void actionPerformed(ActionEvent e)
    	{
    		String command = e.getActionCommand();
    		AIDGui guiSender = new AIDGui(dlgParent);
    	
    		if(command.equals("View"))
    			guiSender.ShowAIDGui(dfdAgent.getName(), false,false);
    		else
    		  if(command.equals("Set"))
    		  	{
    		  		
    		  		newAID = guiSender.ShowAIDGui(dfdAgent.getName(),true,checkSlots);
    		  		
    		  		if (newAID != null)
    		  		{	
    		  			agentName.setText(newAID.getName());
    		  			dfdAgent.setName(newAID);
    		  		}
    		  	}
    			
    	}
    });
   
	  p.add(AIDButton); 
		p.add(agentName);
		main.add(p);
		main.add(Box.createRigidArea(new Dimension (0,3)));
		
	  // Ontologies 
	  JPanel pOntologies = new JPanel();
	  pOntologies.setLayout(new BorderLayout());
	  pOntologies .setBorder(BorderFactory.createTitledBorder("Ontologies"));
		ontologiesListPanel = new VisualStringList(dfdAgent.getAllOntologies(),dlgParent);
		ontologiesListPanel.setDimension(new Dimension(400,45));
		ontologiesListPanel.setEnabled(editable);
		pOntologies.add(ontologiesListPanel);
   	main.add(pOntologies);
		main.add(Box.createRigidArea(new Dimension (0,3)));
		

⌨️ 快捷键说明

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