/**
 * This file was automatically generated.  Do not manually modify this file.
 *
 * Runtime vendor: SunSoft, Inc.
 * Runtime version: 1
 *
 * Visual vendor: SunSoft, Inc.
 * Visual version: 1
 */


import sunsoft.jws.visual.rt.base.*;
import sunsoft.jws.visual.rt.type.*;
import java.awt.Event;


public class SocketClientOps extends Operations {
  private Op ops[];

  private SocketClient group;
  private SocketClientRoot gui;

  public void setGroup(Group group) {
    this.group = (SocketClient)group;
  }

  public void setRoot(Root root) {
    this.gui = (SocketClientRoot)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[2];

    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.textfield1;
    ops[0].filter.id = 401;
    ops[0].filter.key = 10;
    ops[0].action = new OpAction();
    ops[0].action.actionType = OpAction.CODE;
    ops[0].action.target = new AMRef("textfield1");
    ops[0].action.name = "text";
    ops[0].action.value = "";

    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.CODE;
  }

  private void handleCallback(int index, Message msg, Event evt) {
    switch (index) {
    case 0:
      {
Client client=new Client(gui.textfield1,gui.textarea1);
client.start();
      }
      break;
    case 1:
      {
Client client=new Client(gui.textfield1, gui.textarea1);
client.start();
      }
      break;
    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));
  }
}
