2007-03-24 15:49:59 +00:00
|
|
|
/*
|
2007-04-11 09:39:46 +00:00
|
|
|
* $Id: AseAwkApplet.java,v 1.2 2007-04-11 09:39:46 bacon Exp $
|
2007-03-24 15:49:59 +00:00
|
|
|
*/
|
2006-11-26 16:17:51 +00:00
|
|
|
|
|
|
|
import java.applet.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.event.*;
|
2007-03-23 07:45:22 +00:00
|
|
|
import java.net.URL;
|
2007-01-25 14:14:56 +00:00
|
|
|
|
2007-04-10 08:04:52 +00:00
|
|
|
public class AseAwkApplet extends Applet
|
2006-11-26 16:17:51 +00:00
|
|
|
{
|
2007-04-11 09:39:46 +00:00
|
|
|
private TextArea srcIn;
|
|
|
|
private TextArea srcOut;
|
|
|
|
private TextArea conIn;
|
|
|
|
private TextArea conOut;
|
|
|
|
private TextField jniLib;
|
|
|
|
|
2006-11-26 16:17:51 +00:00
|
|
|
public void init ()
|
|
|
|
{
|
2007-04-11 09:39:46 +00:00
|
|
|
jniLib = new TextField ();
|
|
|
|
|
|
|
|
srcIn = new TextArea ();
|
|
|
|
srcOut = new TextArea ();
|
|
|
|
conIn = new TextArea ();
|
|
|
|
conOut = new TextArea ();
|
|
|
|
|
|
|
|
Button runBtn = new Button ("Run Awk");
|
2006-11-26 16:17:51 +00:00
|
|
|
|
2007-04-11 09:39:46 +00:00
|
|
|
runBtn.addActionListener (new ActionListener ()
|
2006-11-26 16:17:51 +00:00
|
|
|
{
|
|
|
|
public void actionPerformed (ActionEvent e)
|
|
|
|
{
|
|
|
|
run_awk ();
|
|
|
|
}
|
|
|
|
});
|
2007-04-11 09:39:46 +00:00
|
|
|
|
|
|
|
Panel topPanel = new Panel ();
|
|
|
|
BorderLayout topPanelLayout = new BorderLayout ();
|
|
|
|
topPanel.setLayout (topPanelLayout);
|
|
|
|
|
|
|
|
topPanelLayout.setHgap (2);
|
|
|
|
topPanelLayout.setVgap (2);
|
|
|
|
topPanel.add (new Label ("JNI Library: "), BorderLayout.WEST);
|
|
|
|
topPanel.add (jniLib, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
Panel centerPanel = new Panel ();
|
|
|
|
GridLayout centerPanelLayout = new GridLayout (2, 2);
|
|
|
|
|
|
|
|
centerPanel.setLayout (centerPanelLayout);
|
|
|
|
|
|
|
|
centerPanelLayout.setHgap (2);
|
|
|
|
centerPanelLayout.setVgap (2);
|
|
|
|
|
|
|
|
centerPanel.add (srcIn);
|
|
|
|
centerPanel.add (srcOut);
|
|
|
|
centerPanel.add (conIn);
|
|
|
|
centerPanel.add (conOut);
|
|
|
|
|
|
|
|
BorderLayout mainLayout = new BorderLayout ();
|
|
|
|
mainLayout.setHgap (2);
|
|
|
|
mainLayout.setVgap (2);
|
|
|
|
|
|
|
|
setLayout (mainLayout);
|
|
|
|
|
|
|
|
add (topPanel, BorderLayout.NORTH);
|
|
|
|
add (centerPanel, BorderLayout.CENTER);
|
|
|
|
add (runBtn, BorderLayout.SOUTH);
|
2006-11-26 16:17:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void stop () {}
|
|
|
|
public void paint (Graphics g) {}
|
|
|
|
|
|
|
|
private void run_awk ()
|
|
|
|
{
|
2007-04-10 08:04:52 +00:00
|
|
|
AseAwk awk = null;
|
2006-11-26 16:17:51 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2007-03-23 07:45:22 +00:00
|
|
|
/*
|
|
|
|
URL url = ase.awk.Awk.class.getResource ("aseawk_jni.dll");
|
|
|
|
if (url == null) url = ase.awk.Awk.class.getResource ("aseawk_jni.so");
|
|
|
|
|
|
|
|
if (url != null) System.load (url.getFile()); */
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
System.load ("c:/projects/ase/test/awk/aseawk_jni.dll");
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
System.err.println ("fuck you");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-10 08:04:52 +00:00
|
|
|
awk = new AseAwk ();
|
2006-11-26 16:17:51 +00:00
|
|
|
awk.parse ();
|
|
|
|
awk.run ();
|
|
|
|
}
|
|
|
|
catch (ase.awk.Exception e)
|
|
|
|
{
|
|
|
|
System.out.println ("ase.awk.Exception - " + e.getMessage());
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
if (awk != null) awk.close ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|