// ==========================================================================
// $Id: AktionPopup.java,v 1.1 2002/09/15 15:02:30 hitoshi Exp $
// popup window action
// ==========================================================================
// Copyright (C) 2002 Yamauchi, Hitoshi
//
//   Max-Planck-Institut fuer Informatik AG4
//   Stuhlsatzenhausweg 85, 66123 Saarbruecken
//   http://www.mpi-sb.mpg.de/
// 
// This software can be redistributed only under GNU copyleft.
//
// @author Yamauchi Hitoshi »³Æâ ÀÆ
// ==========================================================================
// $Revision: 1.1 $
// $Date: 2002/09/15 15:02:30 $
// $Author: hitoshi $
// ==========================================================================
package de.mpg.mpisb.timerclock;

import  javax.swing.*;

/**
 * Action: window popup 
 * @see Actionable, ActionList
 */
public class AktionPopup extends Actionable
{
  /**
   * constructor
   */
  public AktionPopup(long firetime, TimerClockPanel tcp, String message)
  {
    this.setActionTime(firetime);
    this.mTCP = tcp;
    if((message == null) || (message.length() == 0))
    {
      this.mMessage = "ALARM: The time has come.";
    }
    this.mMessage = new String(message);    
  }

  /**
   * desctiption of this action
   */
  public String toString()
  {
    String s = "t = " + this.getActionTime() + ": popup a window : "
      + this.mMessage;
    return(s);
  }

  /**
   * set message for GUI
   */
  public void setMesaage(String mes)
  {
    this.mMessage = mes;    
  }

  /*============================================================
   * interface for action
   *===========================================================*/
  /**
   * do the action : popup a window
   */
  public void doit()
  {
    // This is only modal dialog.
    //     String mes = this.mMessage + "\nat " +
    //       this.mTCP.peekTimeFormatter().getFormattedString(this.getActionTime());
    //     JOptionPane.showMessageDialog(null, 
    // 				  mes,
    // 				  "TimerClock: AktionPopup",
    // 				  JOptionPane.WARNING_MESSAGE);

    String timeStr = 
      this.mTCP.peekTimeFormatter().getFormattedString(this.getActionTime());

    AktionPopupWindow jd = new AktionPopupWindow(null, false);
    jd.setMessage(timeStr, this.mMessage);
    boolean modal = false;
    jd.popup(modal);
  }
  
  // private variables
  private TimerClockPanel mTCP;
  private String          mMessage;
}
