/**
 * This file was automatically generated.  Do not manually modify this file.
 *
 * Runtime vendor: SunSoft, Inc.
 * Runtime version: 1.0
 *
 * Visual vendor: SunSoft, Inc.
 * Visual version: 1.0
 */


import sunsoft.jws.visual.rt.base.*;
import sunsoft.jws.visual.rt.type.*;
import java.awt.Event;


public class CommandeOps extends Operations {
  private Op ops[];

  private Commande group;
  private CommandeRoot gui;

  public void setGroup(Group group) {
    this.group = (Commande)group;
  }

  public void setRoot(Root root) {
    this.gui = (CommandeRoot)root;
    if (ops == null)
      initializeOps();
  }

  public boolean handleMessage(Message msg) {
    for (int i=0; i<ops.length; i++) {
      if (ops[i].hasCode()) {
	if (ops[i].matchMessage(msg)) {
	  handleCallback(i, msg, (msg.isAWT ? (Event)msg.arg : null));
	}
      }
      else {
	ops[i].handleMessage(msg);
      }
    }

    return false;
  }

  private void initializeOps() {
    ops = new Op[3];

    ops[0] = new Op(gui);
    ops[0].name = "Op1";
    ops[0].filter = new OpFilter();
    ops[0].filter.filterType = OpFilter.EVENT;
    ops[0].filter.target = gui.OK;
    ops[0].filter.id = 1001;
    ops[0].action = new OpAction();
    ops[0].action.actionType = OpAction.ATTRIBUTE;
    ops[0].action.target = new AMRef("MessageErreur");
    ops[0].action.name = "visible";
    ops[0].action.value = Boolean.FALSE;

    ops[1] = new Op(gui);
    ops[1].name = "Op1";
    ops[1].filter = new OpFilter();
    ops[1].filter.filterType = OpFilter.EVENT;
    ops[1].filter.target = gui.button1;
    ops[1].filter.id = 1001;
    ops[1].action = new OpAction();
    ops[1].action.actionType = OpAction.ATTRIBUTE;
    ops[1].action.target = new AMRef("ConfirmCommande");
    ops[1].action.name = "visible";
    ops[1].action.value = Boolean.FALSE;

    ops[2] = new Op(gui);
    ops[2].name = "Op1";
    ops[2].filter = new OpFilter();
    ops[2].filter.filterType = OpFilter.EVENT;
    ops[2].filter.target = gui.button2;
    ops[2].filter.id = 1001;
    ops[2].action = new OpAction();
    ops[2].action.actionType = OpAction.ATTRIBUTE;
    ops[2].action.target = new AMRef("CommandeTextile");
    ops[2].action.name = "visible";
    ops[2].action.value = Boolean.FALSE;
  }

  private void handleCallback(int index, Message msg, Event evt) {
    switch (index) {
    default:
      throw new Error("Bad callback index: " + index);
    }
  }


  // methods from lib/visual/gen/methods.java

  /**
   * Converts a string to the specified type.
   */
  private Object convert(String type, String value) {
    return(Converter.getConverter(type).convertFromString(value));
  }
}
