home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.FlowLayout;
- import java.awt.Frame;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.Window;
-
- class SjScriptWatchdog extends Frame implements Runnable {
- private static final long DEFAULT_SLEEP_TIME = 60000L;
- private static String aMsgText = null;
- private JScriptRuntimeInstance aRTI;
- private Thread aMyThread;
- private long nSleepTime;
- private boolean bAllreadyStoped;
- private boolean bFrameCreated;
- private boolean bContinue;
- private Button aOk;
- private Button aCancel;
- private Label aMessage;
-
- public SjScriptWatchdog(JScriptRuntimeInstance var1) {
- super("JavaScript Wachhund");
- this.aRTI = var1;
- this.bAllreadyStoped = false;
- this.bFrameCreated = false;
- this.aMyThread = new Thread(this, "Script-Watchdog for " + this.aRTI);
- this.aMyThread.start();
- this.nSleepTime = 60000L;
- if (aMsgText == null) {
- aMsgText = JavaScript.GetWatchdogMessage();
- }
-
- }
-
- public void ScriptDone() {
- this.bAllreadyStoped = true;
- this.aMyThread.stop();
- ((Component)this).hide();
- ((Frame)this).dispose();
- }
-
- public boolean action(Event var1, Object var2) {
- if (var1.target == this.aOk) {
- ((Component)this).hide();
- return true;
- } else if (var1.target == this.aCancel) {
- this.bContinue = false;
- this.aRTI.StopExecution();
- this.bAllreadyStoped = true;
- ((Component)this).hide();
- ((Frame)this).dispose();
- return true;
- } else {
- return false;
- }
- }
-
- public void run() {
- this.bContinue = true;
-
- while(this.bContinue && !this.bAllreadyStoped) {
- try {
- Thread.sleep(this.nSleepTime);
- if (!this.bAllreadyStoped) {
- this.CreateMe();
- }
- } catch (InterruptedException var1) {
- this.bContinue = false;
- }
- }
-
- }
-
- private final void CreateMe() {
- if (!this.bFrameCreated) {
- this.bFrameCreated = true;
- ((Container)this).setLayout(new BorderLayout());
- Panel var1 = new Panel();
- Panel var2 = new Panel();
- ((Container)var2).setLayout(new FlowLayout());
- this.aOk = new Button("Ok");
- this.aCancel = new Button("Cancel");
- ((Container)var2).add(this.aOk);
- ((Container)var2).add(this.aCancel);
- this.aMessage = new Label(aMsgText);
- ((Container)var1).add(this.aMessage);
- ((Container)this).add("North", var1);
- ((Container)this).add("South", var2);
- ((Window)this).pack();
- ((Component)this).resize(300, 180);
- }
-
- ((Window)this).show();
- }
- }
-