checkSlots = checkMandatorySlots;
if(dsc != null)
serviceDesc = dsc;
else
serviceDesc = new ServiceDescription();
JPanel main = new JPanel();
main.setLayout(new BoxLayout(main,BoxLayout.Y_AXIS));
JPanel p = new JPanel();
JLabel l;
//Name
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
l = new JLabel("Name");
l.setPreferredSize(new Dimension(130,20));
p.add(l);
p.add(Box.createHorizontalGlue());
txtName = new JTextField();
txtName.setPreferredSize(new Dimension(200,20));
txtName.setText(serviceDesc.getName());
txtName.setEditable(editable);
p.add(txtName);
main.add(p);
main.add(Box.createRigidArea(new Dimension (0,3)));
//Type
p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
l = new JLabel("Type");
l.setPreferredSize(new Dimension(130,20));
p.add(l);
p.add(Box.createHorizontalGlue());
txtType = new JTextField();
txtType.setPreferredSize(new Dimension (200,20));
txtType.setText(serviceDesc.getType());
txtType.setEditable(editable);
p.add(txtType);
main.add(p);
main.add(Box.createRigidArea(new Dimension (0,3)));
//Ownership
p = new JPanel();
p.setLayout(new BoxLayout(p,BoxLayout.X_AXIS));
l = new JLabel("Ownership");
l.setPreferredSize(new Dimension(130,20));
p.add(l);
p.add(Box.createHorizontalGlue());
txtOwner = new JTextField();
txtOwner.setPreferredSize(new Dimension(200,20));
txtOwner.setText(serviceDesc.getOwnership());
txtOwner.setEditable(editable);
p.add(txtOwner);
main.add(p);
main.add(Box.createRigidArea(new Dimension (0,3)));
//Languages
p = new JPanel();
p.setLayout(new BorderLayout());
p.setBorder(BorderFactory.createTitledBorder("Languages"));
languagesListPanel = new VisualStringList(serviceDesc.getAllLanguages(),getOwner());
languagesListPanel.setDimension(new Dimension(350,40));
languagesListPanel.setEnabled(editable);
p.add(languagesListPanel);
main.add(p);
main.add(Box.createRigidArea(new Dimension (0,3)));
//Ontologies
p = new JPanel();
p.setLayout(new BorderLayout());
p.setBorder(BorderFactory.createTitledBorder("Ontologies"));
ontologiesListPanel = new VisualStringList(serviceDesc.getAllOntologies(),getOwner());
ontologiesListPanel.setDimension(new Dimension(350,40));
ontologiesListPanel.setEnabled(editable);
p.add(ontologiesListPanel);
main.add(p);
main.add(Box.createRigidArea(new Dimension (0,3)));
//Protocols.
p = new JPanel();
p.setLayout(new BorderLayout());
p.setBorder(BorderFactory.createTitledBorder("Protocols"));
protocolsListPanel = new VisualStringList(serviceDesc.getAllProtocols(),getOwner());
protocolsListPanel.setDimension(new Dimension(350,40));
protocolsListPanel.setEnabled(editable);
p.add(protocolsListPanel);
main.add(p);
//Properties
p = new JPanel();
p.setLayout(new BorderLayout());
p.setBorder(BorderFactory.createTitledBorder("Properties"));
//#DOTNET_EXCLUDE_BEGIN
Iterator temp = serviceDesc.getAllProperties();
//#DOTNET_EXCLUDE_END
/*#DOTNET_INCLUDE_BEGIN
jade.util.leap.Iterator temp = serviceDesc.getAllProperties();
#DOTNET_INCLUDE_END*/
Properties props = new Properties();
while(temp.hasNext())
{
Property singleProp = (Property)temp.next();
props.setProperty(singleProp.getName(),singleProp.getValue().toString());
}
propertiesListPanel = new VisualPropertiesList(props,getOwner());
propertiesListPanel.setDimension(new Dimension(350,40));
propertiesListPanel.setEnabled(editable);
p.add(propertiesListPanel);
main.add(p);
//Button Panel
p = new JPanel();
p.setLayout(new BoxLayout(p, 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"))
{
if(editable)
{
if(checkSlots)
{
if(getSaveText(txtName) == null)
{
JOptionPane.showMessageDialog(null,"The name must not be empty !","Error Message", JOptionPane.ERROR_MESSAGE);
return;
}
if(getSaveText(txtType) == null)
{
JOptionPane.showMessageDialog(null,"The type must not be empty !","Error Message",JOptionPane.ERROR_MESSAGE);
return;
}
}
out = new ServiceDescription();
out.setName(getSaveText(txtName));
out.setType(getSaveText(txtType));
out.setOwnership(getSaveText(txtOwner));