package sale.events;

import java.util.EventObject;

import sale.FormSheet;
import sale.Display;

/**
  * An EventObject describing a FormSheet that was set or closed at a Display.
  *
  * @see sale.FormSheet
  * @see sale.Display
  *
  * @author Steffen Zschaler
  * @version 2.0 27/05/1999
  * @since v2.0
  */
public class FormSheetEvent extends EventObject {

  /**
    * The FormSheet that was affected by the event.
    *
    * @serial
    */
  private FormSheet m_fsFormSheet;

  /**
    * Was the event caused by an explicit call to the responsible method or was it caused indirectly?
    *
    * @serial
    */
  private boolean m_fExplicit;

  /**
    * Create a new FormSheetEvent.
    *
    * @param src the Display originating the event.
    * @param fs the FormSheet that was affected by the event.
    * @param fExplicit was the event caused by a direct call to the originating method or indirectly?
    */
  public FormSheetEvent (Display src,
                         FormSheet fs,
                         boolean fExplicit) {
    super (src);

    m_fsFormSheet = fs;
    m_fExplicit = fExplicit;
  }

  /**
    * Get the affected FormSheet.
    *
    * @override Never
    */
  public FormSheet getFormSheet() {
    return m_fsFormSheet;
  }

  /**
    * Was the event caused by a direct call to the originating method or indirectly?
    *
    * <p><code>formSheetSet</code> events are always considered explicit. In contrast,
    * <code>formSheetRemoved</code> events are explicit only if they were originated as the consequence
    * of a call to <code>closeFormSheet</code> or <code>setFormSheet (<b>null</b>)</code>. FormSheet
    * removals that were caused by setting another FormSheet are not considered explicit.</p>
    *
    * @override Never
    */
  public boolean isExplicit() {
    return m_fExplicit;
  }
}