// ===================================================
  // ObjHtmlPanel.Listener
  public void linkSelected(java.net.URL href, String target) {
    String url = href.toExternalForm();
    int slash = url.lastIndexOf('/');
    if (slash > 0) url = url.substring(slash + 1);

    Job t = actionMap.get(url);
    fapp.guiRun().run(this, new Job(t.getPermissions(), t.getCBRunnable()));
  }
  // ===================================================
  // ObjHtmlPanel.Listener
  public void linkSelected(java.net.URL href, String target) {
    String url = href.toExternalForm();
    int slash = url.lastIndexOf('/');
    if (slash > 0) url = url.substring(slash + 1);

    Job job = actionMap.get(url);
    if (job != null) app.guiRun().run(this, job);
  }
  /** Creates a new instance of ActionPanel */
  public void initRuntime(FrontApp xfapp) throws org.xml.sax.SAXException, java.io.IOException {
    this.fapp = xfapp;

    actionMap.put(
        "ticketsalesreport",
        new Job(
            "",
            new ETask() {
              public void run() throws Exception {
                //		JFrame root = (javax.swing.JFrame)WidgetTree.getRoot(getThis());
                Wizard wizard = new offstage.reports.ReportWizard(fapp, DevelActionPanel.this);
                wizard.runWizard("ticketparams");
              }
            }));

    actionMap.put(
        "mailmerge",
        new Job(
            "",
            new SqlTask() {
              public void run(SqlRun str) throws Exception {
                //		JFrame root = (javax.swing.JFrame)WidgetTree.getRoot(getThis());
                EQueryWizard wizard = new EQueryWizard(fapp, DevelActionPanel.this);
                if (wizard.runMailMerge()) {
                  System.out.println((String) wizard.getVal("submit"));
                  MailMerge.viewReport(
                      str, fapp, (EQuery) wizard.getVal("equery"), (File) wizard.getVal("file"));
                }
              }
            }));

    actionMap.put(
        "segmentation",
        new Job(
            "",
            new SqlTask() {
              public void run(SqlRun str) throws Exception {
                //		JFrame root = (javax.swing.JFrame)WidgetTree.getRoot(getThis());
                EQueryWizard wizard = new EQueryWizard(fapp, DevelActionPanel.this);
                if (wizard.runSegmentation()) {
                  EQuery equery = (EQuery) wizard.getVal("equery");
                  String idSql = equery.getSql(fapp.equerySchema());
                  SegmentationReport.writeCSV(
                      fapp,
                      str,
                      idSql,
                      (List<String>) wizard.getVal("segtypes"),
                      (File) wizard.getVal("file"));
                }
              }
            }));

    actionMap.put(
        "mailinglabels",
        new Job(
            "",
            new SqlTask() {
              public void run(SqlRun str) throws Exception {
                //		JFrame root = (javax.swing.JFrame)WidgetTree.getRoot(getThis());
                EQueryWizard wizard = new EQueryWizard(fapp, DevelActionPanel.this);
                wizard.runMailingLabels(str);
              }
            }));

    actionMap.put(
        "emails",
        new Job(
            "",
            new SqlTask() {
              public void run(SqlRun str) throws Exception {
                EQueryWizard wizard = new EQueryWizard(fapp, DevelActionPanel.this);
                if (!wizard.runBulkEmails(str)) return;

                // Text of the email we wish to send
                byte[] msgBytes = (byte[]) wizard.getVal("emails");
                // if (msg != null) System.out.println("Email = " + msg.subject);

                // SQL of people we wish to send to
                EQuery equery = (EQuery) wizard.getVal("equery");

                VettEmail.sendJangoMail(
                    fapp,
                    str,
                    msgBytes,
                    equery.getSql((fapp.equerySchema())),
                    equery.toXML((fapp.equerySchema())),
                    (Integer) wizard.getVal("equeryid"),
                    VettEmail.ET_BULK);

                //		//		JFrame root = (javax.swing.JFrame)WidgetTree.getRoot(getThis());
                //		EQueryWizard wizard = new EQueryWizard(fapp, DevelActionPanel.this);
                //		wizard.runCSEmails(str);
              }
            }));

    actionMap.put(
        "donationreport",
        new Job(
            "",
            new SqlTask() {
              public void run(SqlRun str) throws Exception {
                //		JFrame root = (javax.swing.JFrame)WidgetTree.getRoot(getThis());
                EQueryWizard wizard = new EQueryWizard(fapp, DevelActionPanel.this);
                if (wizard.runDonationReport()) {
                  EQuery equery = (EQuery) wizard.getVal("equery");
                  String idSql = equery.getSql(fapp.equerySchema());
                  DonationReport.writeCSV(
                      fapp,
                      str,
                      idSql,
                      ((Number) wizard.getVal("minyear")).intValue(),
                      ((Number) wizard.getVal("maxyear")).intValue(),
                      (File) wizard.getVal("file"));
                }
              }
            }));

    actionMap.put(
        "clausereport",
        new Job(
            "",
            new SqlTask() {
              public void run(SqlRun str) throws Exception {
                //		JFrame root = (javax.swing.JFrame)WidgetTree.getRoot(getThis());
                EQueryWizard wizard = new EQueryWizard(fapp, DevelActionPanel.this);
                if (wizard.runClauseReport()) {
                  EQuery equery = (EQuery) wizard.getVal("equery");
                  ClauseReport.writeClauseCSV(
                      fapp, str, (EQuery) wizard.getVal("equery"), (File) wizard.getVal("file"));
                }
              }
            }));

    actionMap.put(
        "castingreport",
        new Job(
            "",
            new SqlTask() {
              public void run(SqlRun str) throws Exception {
                //		JFrame root = (javax.swing.JFrame)WidgetTree.getRoot(getThis());
                EQueryWizard wizard = new EQueryWizard(fapp, DevelActionPanel.this);
                if (wizard.runClauseReport()) {
                  EQuery equery = (EQuery) wizard.getVal("equery");
                  ClauseReport.writeCastingCSV(
                      fapp, str, (EQuery) wizard.getVal("equery"), (File) wizard.getVal("file"));
                }
              }
            }));

    addListener(this);
    loadHtml();
  }
 /** @param permissions Comma-separated list of permissions */
 public void addAction(String url, String name, String permissions, CBTask runnable) {
   actionMap.put(url, new Job(permissions, runnable));
 }
 public void addAction(String url, String name, CBTask runnable) {
   actionMap.put(url, new Job((String[]) null, runnable));
 }