/* Author: Jeff Dalton * Updated: Wed Dec 5 00:49:19 2001 by Jeff Dalton * Copyright: (c) 2001, AIAI, University of Edinburgh */ package ix.test; import java.awt.event.*; import java.util.*; import ix.icore.*; import ix.ideel.*; import ix.util.*; import ix.util.lisp.*; /** * An example of various ways to entend BasicIdeel. */ public class Ip2Example extends BasicIdeel { // Parameters that can be set by command-line arguments // /\/: Sould they be superiorName etc? protected String superior = null; protected String subordinate = null; public Ip2Example() { super(); // Change some defaults displayName = "Ip2 Example"; symbolName = "Example"; logoLine1 = "Example I-X Process Panel"; logoLine2 = "Based on I-X Technology"; logoImage = "images/ip2-logo.gif"; domainName = null; } public static void main(String[] argv) { Util.printGreeting("IP2 Example"); new Ip2Example().mainStartup(argv); } /** * Command-line argument processing. */ protected void processCommandLineArguments() { super.processCommandLineArguments(); superior = Parameters.getParameter("superior", superior); subordinate = Parameters.getParameter("subordinate", subordinate); } /** * Completes setup and initialization. */ public void startup() { super.startup(); frame.addFileMenuItem("Save Issues", new ActionListener() { public void actionPerformed(ActionEvent e) { saveIssues(); } }); } public void saveIssues() { Debug.noteln("Saving issues"); List issuesToSave = new LListCollector(); for (Iterator i = controller.getIssues().iterator(); i.hasNext();) { IdeelIssue issue = (IdeelIssue)i.next(); if (issue.level == 0) issuesToSave.add(issue); } Debug.noteln("Pretend I'm sending a report containing", issuesToSave); // /\/: Calling reset() here is not ok in principle // but at present turns out to be ok in practice. reset(); } /** * Called to add items to the main frame menu bar's "Test" menu. */ protected void addTestMenuItems() { super.addTestMenuItems(); frame.addTestIssue(PRIORITY_HIGH, "consider example issue"); frame.addTestIssue(PRIORITY_HIGH, "note example issue", "Add a note issue"); } /** * Install issue handlers. */ protected void addIdeelIssueHandlers() { super.addIdeelIssueHandlers(); // See BasicIdeel for the definitions of these handler classes. if (superior != null) { controller.addUniversalIssueHandler (new EscalateHandler(superior) { public boolean appliesTo(IdeelIssue i) { // Apply only to top-level issues return i.level == 0; } }); } if (subordinate != null) { controller.addUniversalIssueHandler (new DelegateHandler(subordinate)); } } }