/* Author: Jeff Dalton * Updated: Wed Nov 7 19:15:29 2001 by Jeff Dalton * Copyright: (c) 2001, AIAI, University of Edinburgh */ package ix.ileed; import javax.swing.*; import java.util.*; import java.io.*; import ix.iface.domain.DomainParser; import ix.icore.*; import ix.icore.domain.Domain; import ix.ideel.*; import ix.util.*; import ix.util.lisp.*; /** * The CoAX I-LEED class and application main program */ public class I_LEED extends BasicIleed { public I_LEED() { super(); // Change some defaults displayName = "Joint Task Force Commander"; symbolName = "JTFC"; logoLine1 = "I-LEED: I-X Leader's Event and Execution Display"; logoLine2 = "Based on I-X Technology"; logoImage = "images/ip2-logo.gif"; domainName = "binni-ileed.xml"; } /** * Main program. */ public static void main(String[] argv) { Util.printGreeting("I-LEED"); new I_LEED().mainStartup(argv); } protected void setupProcessModel() { processModel.initFromFile("coax-process.lsp"); // Connect model and viewer. processModel.setViewer(processViewer); processViewer.setProcessModel(processModel); } /** * Sets up any issues that should be in the panel at the start. */ protected void addIleedInitialIssues() { IdeelIssue sep_issue = new IdeelIssue("separate gao and agadez forces"); controller.addIssue(sep_issue); invokeIssueOption(sep_issue, "Expand using separate_forces_using_firestorm"); } protected void invokeIssueOption(IdeelIssue issue, String optionDescription) { for (Iterator i = issue.getOptions().iterator(); i.hasNext();) { IssueOption opt = (IssueOption)i.next(); if (opt.getActionDescription().equals(optionDescription)) { controller.handleIssue(issue, opt); } } } /** * Handles new issues from external sources. */ public void handleNewIssue(Issue issue) { super.handleNewIssue(issue); } /** * Handles new reports from external sources. */ public void handleNewReport(Report report) { // Need a more general mechanism for det where reports should go. /\/ String ref = (String)report.getProperties().get("ref"); if (ref != null && ref.equals("MBP-ILEED-1")) interpreter.interpret(report.getText()); else super.handleNewReport(report); } /** * Install CoAX I-LEED's own issue handlers for issues it can * handle automatically. */ void addIleedIssueHandlers() { super.addIleedIssueHandlers(); controller.addIssueHandler ("avoid", new IdeelIssueHandler("send issue to I-DEEL") { public void handleIssue(Issue i) { IdeelIssue issue = (IdeelIssue)i; issue.forwardIssue("IDEEL"); i.setStatus(STATUS_EXECUTING); } }); controller.addIssueHandler ("authorise", new IdeelIssueHandler("send to I-DEEL") { public void handleIssue(Issue i) { String text = Lisp.elementsToString((LList)i.getParameters()); BasicIssue b = new BasicIssue("note authorised " + text); b.getProperties().put("sender-id", getAgentIPCName()); IPC.sendObject("IDEEL", b); i.setStatus(STATUS_COMPLETE); if (!text.startsWith("firestorm mission")) return; BasicIssue r = new BasicIssue("report firestorm complete"); r.getProperties().put("sender-id", getAgentIPCName()); IPC.sendObject("IDEEL", r); } }); controller.addIssueHandler ("report", new IdeelIssueHandler("report to UNSGO") { public void handleIssue(Issue i) { String text = Lisp.elementsToString((LList)i.getParameters()); Report report = new Report(text); report.getProperties().put("sender-id", getAgentIPCName()); IPC.sendObject("ITEST", report); i.setStatus(STATUS_COMPLETE); } }); } }