home *** CD-ROM | disk | FTP | other *** search
/ Internet CD 2005 August / MICD_2005_08.iso / Multimedia / Twist / TwistEval.exe / Main / webhelp0.cab / hhapplet / IndexSecondaryDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-06-19  |  4.9 KB  |  195 lines

  1. package hhapplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.BorderLayout;
  5. import java.awt.Button;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import java.awt.Dimension;
  10. import java.awt.Event;
  11. import java.awt.Font;
  12. import java.awt.Frame;
  13. import java.awt.Label;
  14. import java.awt.List;
  15. import java.awt.Panel;
  16. import java.awt.Point;
  17. import java.awt.Toolkit;
  18. import java.awt.Window;
  19. import java.net.MalformedURLException;
  20. import java.net.URL;
  21. import java.util.Vector;
  22.  
  23. public class IndexSecondaryDialog extends Frame {
  24.    protected Button m_btnDisplay = null;
  25.    protected Button m_btnCancel = null;
  26.    protected List m_list = null;
  27.    protected Applet m_applet;
  28.    protected Vector m_vEntries;
  29.    protected DialogDoneTarget m_ddtDone;
  30.    private boolean m_bIsIE3 = false;
  31.    private Point m_pntPosition;
  32.  
  33.    public boolean gotFocus(Event var1, Object var2) {
  34.       if (var1.target == this) {
  35.          this.m_list.requestFocus();
  36.          return true;
  37.       } else {
  38.          return super.gotFocus(var1, var2);
  39.       }
  40.    }
  41.  
  42.    public void showTopic() {
  43.       ((Component)this).setBackground(new Color(192, 192, 192));
  44.       if (!System.getProperty("os.name").startsWith("Windows") && !System.getProperty("os.name").startsWith("Mac OS")) {
  45.          this.show();
  46.       }
  47.  
  48.       short var1 = 300;
  49.       short var2 = 240;
  50.       Dimension var3 = Toolkit.getDefaultToolkit().getScreenSize();
  51.       int var4 = var3.width / 2 - var1 / 2;
  52.       int var5 = var3.height / 2 - var2 / 2;
  53.       if (!System.getProperty("os.name").startsWith("Windows") && !System.getProperty("os.name").startsWith("Mac OS")) {
  54.          ((Component)this).reshape(var4, var5, var1, var2);
  55.       } else {
  56.          ((Component)this).resize(var1, var2);
  57.       }
  58.  
  59.       this.m_pntPosition = new Point(var4, var5);
  60.       if (System.getProperty("java.vendor").startsWith("Microsoft") && System.getProperty("java.version").startsWith("1.0")) {
  61.          this.m_bIsIE3 = true;
  62.       }
  63.  
  64.       int var6 = BsscFontFixPatch.GetFontSize();
  65.       this.m_list.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var6));
  66.  
  67.       for(int var7 = 0; var7 < this.m_vEntries.size(); ++var7) {
  68.          this.m_list.addItem(((IndexSecondaryEntry)this.m_vEntries.elementAt(var7)).name);
  69.       }
  70.  
  71.       this.m_list.select(0);
  72.       Panel var8 = new Panel();
  73.       ((Container)var8).add(this.m_btnDisplay);
  74.       ((Container)var8).add(this.m_btnCancel);
  75.       ((Container)this).setLayout(new BorderLayout(5, 5));
  76.       this.m_list.setBackground(Color.white);
  77.       ((Container)this).add("North", new Label("   " + ResourceLib.GetRes("RelateTopicListPrompt")));
  78.       ((Container)this).add("Center", this.m_list);
  79.       ((Container)this).add("South", var8);
  80.       if (!System.getProperty("os.name").startsWith("Windows") && !System.getProperty("os.name").startsWith("Mac OS")) {
  81.          ((Window)this).toFront();
  82.       } else {
  83.          ((Component)this).reshape(var4, var5, var1, var2);
  84.          ((Component)this).move(var4, var5);
  85.          ((Frame)this).setResizable(false);
  86.          this.show();
  87.       }
  88.    }
  89.  
  90.    public IndexSecondaryDialog(Applet var1, Vector var2, DialogDoneTarget var3) {
  91.       super(ResourceLib.GetRes("TopicsFound"));
  92.       this.m_applet = var1;
  93.       this.m_vEntries = var2;
  94.       this.m_ddtDone = var3;
  95.       this.m_btnDisplay = new Button(ResourceLib.GetRes("Display"));
  96.       this.m_btnCancel = new Button(ResourceLib.GetRes("Cancel"));
  97.       this.m_list = new List();
  98.    }
  99.  
  100.    public List getList() {
  101.       return this.m_list;
  102.    }
  103.  
  104.    protected void gotoSelectedIndex() {
  105.       int var1 = this.m_list.getSelectedIndex();
  106.       if (var1 != -1) {
  107.          try {
  108.             IndexSecondaryEntry var2 = (IndexSecondaryEntry)this.m_vEntries.elementAt(var1);
  109.             URL var3 = URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url);
  110.             String var4 = var3.toString();
  111.             if (var4.indexOf("file:/\\\\") == 0) {
  112.                var4 = "file://" + var4.substring(8);
  113.                var3 = new URL(var4);
  114.             }
  115.  
  116.             if (var2.frame != null) {
  117.                this.m_applet.getAppletContext().showDocument(var3, var2.frame);
  118.             } else {
  119.                this.m_applet.getAppletContext().showDocument(var3, "_self");
  120.             }
  121.          } catch (MalformedURLException var5) {
  122.             ((Throwable)var5).printStackTrace();
  123.          }
  124.  
  125.          this.closeDialog();
  126.          ((Frame)this).dispose();
  127.       }
  128.  
  129.    }
  130.  
  131.    public void show() {
  132.       if (this.m_bIsIE3) {
  133.          Dimension var1 = ((Component)this).size();
  134.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  135.          super.show();
  136.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  137.       } else {
  138.          super.show();
  139.       }
  140.  
  141.       this.m_list.requestFocus();
  142.    }
  143.  
  144.    public boolean action(Event var1, Object var2) {
  145.       if (var1.target != this.m_btnDisplay && var1.target != this.m_list) {
  146.          if (var1.target == this.m_btnCancel) {
  147.             this.closeDialog();
  148.             return true;
  149.          } else {
  150.             return false;
  151.          }
  152.       } else {
  153.          this.gotoSelectedIndex();
  154.          return true;
  155.       }
  156.    }
  157.  
  158.    protected void closeDialog() {
  159.       ((Frame)this).dispose();
  160.       if (this.m_ddtDone != null) {
  161.          this.m_ddtDone.dialogDone();
  162.       }
  163.  
  164.    }
  165.  
  166.    public boolean handleEvent(Event var1) {
  167.       if (!System.getProperty("java.version").startsWith("1.1.5") || !System.getProperty("java.vendor").startsWith("Netscape") || var1.id != 401 || var1.key != 10 || var1.target != this.m_btnDisplay && var1.target != this.m_btnCancel) {
  168.          if (var1.id == 201) {
  169.             this.closeDialog();
  170.             ((Frame)this).dispose();
  171.          } else {
  172.             if (var1.target == this.m_list && var1.key == 10 && var1.id == 401) {
  173.                this.gotoSelectedIndex();
  174.                return true;
  175.             }
  176.  
  177.             if (var1.target == this.m_list && var1.key == 10 && var1.id == 402) {
  178.                if (System.getProperty("java.version").equals("1.1") && System.getProperty("java.vendor").startsWith("Microsoft")) {
  179.                   this.gotoSelectedIndex();
  180.                   return true;
  181.                }
  182.             } else if (var1.key == 27 && var1.id == 402) {
  183.                this.closeDialog();
  184.                ((Frame)this).dispose();
  185.             }
  186.          }
  187.  
  188.          return super.handleEvent(var1);
  189.       } else {
  190.          this.action(var1, var1.target);
  191.          return true;
  192.       }
  193.    }
  194. }
  195.