/*
 * Aleph Toolkit
 *
 * Copyright 1999, Brown University, Providence, RI.
 * 
 *                         All Rights Reserved
 * 
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose other than its incorporation into a
 * commercial product is hereby granted without fee, provided that the
 * above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of Brown University not be used in
 * advertising or publicity pertaining to distribution of the software
 * without specific, written prior permission.
 * 
 * BROWN UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY
 * PARTICULAR PURPOSE.  IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE FOR
 * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

package aleph.gui;

import aleph.Aleph;
import aleph.AlephDebug;
import aleph.Config;
import java.awt.Checkbox;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * Run-time checkbox choices
 *
 * @author Maurice Herlihy
 * @date   January 1999
 **/

public class RuntimePanel extends Panel {

  // my components
  private Checkbox profileBox; // profile
  private Checkbox java_gBox; // java_g
  private Checkbox logBox; // log console

  private State state;

  /**
   * Sole Constructor.
   **/
  public RuntimePanel (State state) {
    super();
    this.state    = state;

    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);
    GridBagConstraints c = new GridBagConstraints();

    // Profiling?
    boolean profile = (Aleph.getProperty("aleph.profile") != null);
    profileBox = new Checkbox("Profiling", profile);
    profileBox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
	RuntimePanel.this.state.profile = RuntimePanel.this.profileBox.getState();
      }
    });
    add(profileBox);

    // use java_g?
    boolean java_g = (Aleph.getProperty("aleph.java_g") != null);
    java_gBox = new Checkbox("Use java_g", java_g);
    java_gBox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
	RuntimePanel.this.state.java_g = RuntimePanel.this.java_gBox.getState();
      }
    });
    add(java_gBox);

    // log console?
    boolean logging = Boolean.getBoolean("aleph.logging");
    logBox = new Checkbox("Log console", logging);
    logBox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
	RuntimePanel.this.state.logging = RuntimePanel.this.logBox.getState();
      }
    });
    add(logBox);
  }

}
