{
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)));
// Languages
JPanel pLanguages = new JPanel();
pLanguages.setLayout(new BorderLayout());
pLanguages .setBorder(BorderFactory.createTitledBorder("Languages"));
languagesListPanel = new VisualStringList(dfdAgent.getAllLanguages(),dlgParent);
languagesListPanel.setDimension(new Dimension(400,45));
languagesListPanel.setEnabled(editable);
pLanguages.add(languagesListPanel);
main.add(pLanguages);
main.add(Box.createRigidArea(new Dimension (0,3)));
// Interaction protocols
JPanel pProtocols = new JPanel();
pProtocols .setLayout(new BorderLayout());
pProtocols .setBorder(BorderFactory.createTitledBorder("Interaction-protocols"));
protocolsListPanel = new VisualStringList(dfdAgent.getAllProtocols(),dlgParent);
protocolsListPanel.setDimension(new Dimension(400,45));
protocolsListPanel.setEnabled(editable);
pProtocols.add(protocolsListPanel);
main.add(pProtocols);
main.add(Box.createRigidArea(new Dimension (0,3)));
// Services list
JPanel pServices = new JPanel();
pServices.setBorder(BorderFactory.createTitledBorder("Agent services"));
servicesListPanel = new VisualServicesList(dfdAgent.getAllServices(),dlgParent);
servicesListPanel.setDimension(new Dimension(400,45));
servicesListPanel.setEnabled(editable);
servicesListPanel.setCheckMandatorySlots(checkMandatorySlots);
pServices.add(servicesListPanel);
main.add(pServices);
/* lease-time panel
* The duration or time at which the lease time for this registration
* will expire. The default value of lease time is assumed to be
* unlimeted
*/
JPanel pLeaseTime = new JPanel();
pLeaseTime.setEnabled(editable);
pLeaseTime.setToolTipText("The duration at which the lease for this registration will expire");
pLeaseTime.setSize(400, 45);
pLeaseTime.setBorder(BorderFactory.createTitledBorder("Lease Time"));
java.util.Date dleasetime = dfdAgent.getLeaseTime();
if(dleasetime == null) {
textFieldLeaseTime = new JTextField("unlimited");
} else {
textFieldLeaseTime = new JTextField(dleasetime.toString());
}
textFieldLeaseTime.setPreferredSize(new Dimension(335,26));
textFieldLeaseTime.setMinimumSize(new Dimension(335,26));
textFieldLeaseTime.setMaximumSize(new Dimension(335,26));
textFieldLeaseTime.setEnabled(false);
// add 2 buttons: one to set the date and the second to set the time
// of the lease-time unlimeted
setLTDateb = new JButton("Set");
setLTDateb.setEnabled(editable);
setLTDateb.setToolTipText("Set the date at which the lease time will expire");
pLeaseTime.add(setLTDateb);
pLeaseTime.add(textFieldLeaseTime);
// when the button setLT is presse the dialog jade.gui.TimeChooser
// is shown to set the date
// this is value is used to set the value of DFAgentDescription returned
// by the dialog (name of var is out see below)
absDateLeaseTime = dfdAgent.getLeaseTime();
setLTDateb.addActionListener(this);
// when the button 'unlimited is pressed set the lease time to
// the default value and the update the text field that shows
// the value of the lease time
main.add(pLeaseTime);
getContentPane().add(main,BorderLayout.NORTH);
// OK BUTTON
bPane = new JPanel();
bPane.setLayout(new BoxLayout(bPane, BoxLayout.X_AXIS));
JButton bOK = new JButton("OK");
bOK.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String param = (String) e.getActionCommand();
if (param.equals("OK"))
{ // the user pressed the OK button
if(editable)
{ // if it is editable then I have to collect all data in the GUI and create a DFAgentDescription to return to the caller
out = new DFAgentDescription();
if(checkSlots)
//AID
if (newAID == null) //newAID was set when the "Set" button was pressed
{