From 61fd14fd7d9f06491485d6a9e5c728ab457499ce Mon Sep 17 00:00:00 2001 From: jacomi Date: Thu, 15 Apr 1999 09:47:30 +0000 Subject: Initial revision --- src/TestIvy.java | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100755 src/TestIvy.java (limited to 'src/TestIvy.java') diff --git a/src/TestIvy.java b/src/TestIvy.java new file mode 100755 index 0000000..46f484d --- /dev/null +++ b/src/TestIvy.java @@ -0,0 +1,115 @@ +package fr.dgac.ivy ; + +import java.awt.* ; +import java.awt.event.* ; + +class TestIvy extends Panel implements IvyApplicationListener{ + + Ivy bus ; + String regexp ; + TextField tfRegex, tfSend ; + TextArea ta ; + Button buApply, buSend, buClear ; + int regexp_id; + public TestIvy() throws IvyException { + super(new BorderLayout()); + regexp = ""; + // un textarea au centre + ta = new TextArea(); + ta.setEditable(false); + add(ta,BorderLayout.CENTER); + // une zone regex au nord + Panel p = new Panel(new BorderLayout()); + p.add(new Label("Regex:"),BorderLayout.WEST); + tfRegex = new TextField(regexp); + tfRegex.addActionListener(new REGCB()); + p.add(tfRegex,BorderLayout.CENTER); + add(p,BorderLayout.NORTH); + // une zone messages au sud + p = new Panel(new BorderLayout()); + p.add(new Label("Msg:"),BorderLayout.WEST); + tfSend = new TextField(""); + tfSend.addActionListener(new SENDCB()); + p.add(tfSend,BorderLayout.CENTER); + add(p,BorderLayout.SOUTH); + bus = new Ivy("JAVA TESTBUS","Testbus ridi",this); + bus.start(null); + append( "Ivy Domain: "+ bus.getDomain(null) ); + } + + public void stop() { + bus.stop(); + } + public void connect(IvyClient client) { + append(client.getApplicationName() + " connected " ); + } + public void disconnect(IvyClient client) { + append(client.getApplicationName() + " disconnected " ); + } + public void die(IvyClient client, int id) { + append(client.getApplicationName() + " die "+ id ); + } + public void directMessage(IvyClient client, int id, String arg) { + append(client.getApplicationName() + " direct Message "+ id + arg ); + } + /* inner */ class REGCB implements ActionListener, IvyMessageListener { + public void actionPerformed(ActionEvent e) { + // enlever l'ancienne regex + bus.unBindMsg(regexp_id); + // ajoute la nouvelle regex + regexp=tfRegex.getText(); + regexp.trim(); + regexp_id = bus.bindMsg(regexp,this); + tfRegex.setText(""); + } + public void receive(IvyClient client, String[] args) { + String out="client " + client.getApplicationName() + " envoie: [ "; + for (int i=0;i