jason.infra.centralised.KillAgentGUI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jason Show documentation
Show all versions of jason Show documentation
Jason is a fully-fledged interpreter for an extended version of AgentSpeak, a BDI agent-oriented logic programming language.
package jason.infra.centralised;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.util.Collections;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;
import jason.runtime.RuntimeServicesInfraTier;
public class KillAgentGUI extends BaseDialogGUI {
private static final long serialVersionUID = 1L;
private JList lAgs;
private RuntimeServicesInfraTier services;
public KillAgentGUI(Frame f, String title) {
super(f, title);
}
protected void initComponents() {
services = BaseCentralisedMAS.getRunner().getRuntimeServices();
getContentPane().setLayout(new BorderLayout());
// Fields
Vector agNames = new Vector(services.getAgentsNames());
Collections.sort(agNames);
lAgs = new JList(agNames);
lAgs.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JPanel p = new JPanel(new BorderLayout());
p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Current agents", TitledBorder.LEFT, TitledBorder.TOP));
p.add(lAgs, BorderLayout.CENTER);
getContentPane().add(p, BorderLayout.CENTER);
getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
ok.setText("Kill");
}
protected boolean ok() {
new Thread() {
public void run() {
Object[] sls = lAgs.getSelectedValues();
for (int i = 0; i < sls.length; i++) {
String agName = sls[i].toString();
services.killAgent(agName, "KillAgGUI");
}
}
} .start();
return true;
}
}