this.out = null;
this.editable = ed;
this.checkSlots = checkMandatorySlots;
if(agentIdentifier == null)
this.agentAID = new AID();
else
this.agentAID = agentIdentifier;
JLabel label;
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.Y_AXIS));
//mainPanel.setBackground(Color.black);
//Name
JPanel namePanel = new JPanel();
namePanel.setLayout(new BoxLayout(namePanel,BoxLayout.X_AXIS));
label = new JLabel("NAME");
label.setPreferredSize(new Dimension(80,26));
label.setMinimumSize(new Dimension(80,26));
label.setMaximumSize(new Dimension(80,26));
namePanel.add(label);
isLocalName = new JCheckBox();
isLocalName.setVisible(ed); //if the AID is editable then the checkbox is show otherwise no.
isLocalName.setToolTipText("Select if the name is not a GUID.");
namePanel.add(isLocalName);
nameText = new JTextField();
nameText.setBackground(Color.white);
nameText.setText(agentAID.getName());
nameText.setPreferredSize(new Dimension(125,26));
nameText.setMinimumSize(new Dimension(125,26));
nameText.setMaximumSize(new Dimension(125,26));
nameText.setEditable(editable);
namePanel.add(nameText);
mainPanel.add(namePanel);
//Addresses
JPanel addressesPanel = new JPanel();
addressesPanel.setLayout(new BorderLayout());
addressesPanel.setBorder(BorderFactory.createTitledBorder("Addresses"));
//#DOTNET_EXCLUDE_BEGIN
addressListPanel = new VisualStringList(agentAID.getAllAddresses(), getChildrenOwner());
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
java.util.ArrayList aList = new java.util.ArrayList();
jade.util.leap.Iterator it = agentAID.getAllAddresses();
while ( it.hasNext() )
{
aList.add( it.next() );
}
addressListPanel = new VisualStringList(aList.iterator(), getChildrenOwner());
#DOTNET_INCLUDE_END*/
addressListPanel.setDimension(new Dimension(200,40));
addressListPanel.setEnabled(editable);
addressesPanel.add(addressListPanel);
mainPanel.add(addressesPanel);
//Resolvers
JPanel resolversPanel = new JPanel();
resolversPanel.setLayout(new BorderLayout());
resolversPanel.setBorder(BorderFactory.createTitledBorder("Resolvers"));
//#DOTNET_EXCLUDE_BEGIN
resolverListPanel = new VisualAIDList(agentAID.getAllResolvers(), getChildrenOwner());
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
java.util.ArrayList bList = new java.util.ArrayList();
jade.util.leap.Iterator it2 = agentAID.getAllResolvers();
while ( it2.hasNext() )
{
bList.add( it2.next() );
}
resolverListPanel = new VisualAIDList(bList.iterator(), getChildrenOwner());
#DOTNET_INCLUDE_END*/
resolverListPanel.setDimension(new Dimension(200,40));
resolverListPanel.setEnabled(editable);
resolverListPanel.setCheckMandatorySlots(checkMandatorySlots);
resolversPanel.add(resolverListPanel);
mainPanel.add(resolversPanel);
//Properties
JPanel propertiesPanel = new JPanel();
propertiesPanel.setLayout(new BorderLayout());
propertiesPanel.setBorder(BorderFactory.createTitledBorder("Properties"));
propertiesListPanel = new VisualPropertiesList(agentAID.getAllUserDefinedSlot(), getChildrenOwner());
propertiesListPanel.setDimension(new Dimension(200,40));
propertiesListPanel.setEnabled(editable);
propertiesPanel.add(propertiesListPanel);
mainPanel.add(propertiesPanel);
//Button Ok-Cancel
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
JButton okButton = new JButton("OK");
okButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String param = (String)e.getActionCommand();
if(param.equals("OK"))
{
if(editable)
{
String name = (nameText.getText()).trim();
if (checkSlots)
if (name.length() == 0) {
JOptionPane.showMessageDialog(AIDGui.this,"AID must have a non-empty name.","Error Message",JOptionPane.ERROR_MESSAGE);
return;
}
out = new AID();
if(isLocalName.isSelected())
out.setLocalName(name);
else
out.setName(name);