From 94b13da8bd7de1556d67b8834a465a4f78324852 Mon Sep 17 00:00:00 2001
From: mbirth <mbirth>
Date: Wed, 8 Dec 2004 08:23:31 +0000
Subject: [PATCH] Moved remotely

---
 MyInfoPrint.java | 114 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 114 insertions(+)
 create mode 100644 MyInfoPrint.java

diff --git a/MyInfoPrint.java b/MyInfoPrint.java
new file mode 100644
index 0000000..23e4a78
--- /dev/null
+++ b/MyInfoPrint.java
@@ -0,0 +1,114 @@
+import com.symbian.devnet.util.TaskSwitch;
+
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Label;
+import java.awt.Point;
+
+public class MyInfoPrint {
+  Frame parent;
+  Dialog diInfo;
+  Label lbInfo = new Label();
+  InfoPrintThread thIPT = new InfoPrintThread();
+  
+  public MyInfoPrint(Frame p) {
+    parent = p;
+    diInfo = new Dialog(parent, "infoPrint", false);
+  }
+
+  // waits 3 seconds and then hides the diInfo-Dialog
+  private class InfoPrintThread extends Thread {
+    private transient boolean stopnow;
+    
+    public void run() {
+      this.stopnow = false;
+      try {
+        // System.out.println("IPT: started.");
+        long dtStart = System.currentTimeMillis();
+        while (System.currentTimeMillis()<dtStart+3000 && !this.stopnow) {
+          try {
+            Thread.sleep(100);
+          } catch (InterruptedException exIE) {
+            System.out.println("Caught "+exIE.toString());
+            exIE.printStackTrace();
+          }
+        }
+        diInfo.setVisible(false);
+        // System.out.println("IPT: completed.");
+        return;
+      } catch (Exception ex) {
+        System.out.println("Exception in IPT: "+ex.toString());
+        ex.printStackTrace();
+      }
+    }
+    
+    public void setStopnow(boolean x) {
+      this.stopnow = x;
+    }
+  }
+  
+  private void doBox(String txt) {
+    while (thIPT.isAlive()) {
+      thIPT.setStopnow(true);
+      try {
+        Thread.sleep(100);
+      } catch (InterruptedException exIE) {
+        System.out.println("Caught "+exIE.toString());
+        exIE.printStackTrace();
+      }
+    }
+    diInfo.add(lbInfo);
+    lbInfo.setText(txt);
+    diInfo.pack();
+    Dimension dmWindow = parent.getSize();
+    Point ptWindow = parent.getLocation();
+    Dimension dmInfo = diInfo.getSize();
+    // System.out.println("Window is at "+ptWindow.x+"|"+ptWindow.y+" and "+dmWindow.width+"x"+dmWindow.height);
+    // System.out.println("InfoPrint is "+dmInfo.width+"x"+dmInfo.height);
+    Point ptInfo = new Point();
+    ptInfo.x = ptWindow.x+dmWindow.width-dmInfo.width;
+    ptInfo.y = ptWindow.y;
+    // System.out.println("InfoPrint will be positioned at "+ptInfo.x+"|"+ptInfo.y);
+    diInfo.setLocation(ptInfo);
+    diInfo.repaint();
+    diInfo.show();
+  }
+  
+  public void busy(String txt) {
+    if (System.getProperty("os.name").equals("EPOC")) {
+      infoPrint(txt);
+    } else {
+      doBox(txt);
+    }
+  }
+  
+  public void hide() {
+    while (thIPT.isAlive()) {
+      thIPT.setStopnow(true);
+      try {
+        Thread.sleep(100);
+      } catch (InterruptedException exIE) {
+        System.out.println("Caught "+exIE.toString());
+        exIE.printStackTrace();
+      }
+    }
+    diInfo.setVisible(false);
+  }
+
+  public void infoPrint(String txt) {
+    if (System.getProperty("os.name").equals("EPOC")) {
+      try {
+        TaskSwitch.infoPrint(txt);
+        return;
+      } catch (Exception ex) {
+        return;
+      }
+    } else {
+      doBox(txt);
+      // System.out.println("infoPrint: "+txt);
+      thIPT = new InfoPrintThread();
+      thIPT.start();
+    }
+  }
+}