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