home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / windowsxp / ftgateoffice / ftgateoffice.exe / Main / webhelp.jar / hhapplet / FTSPane.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-11-07  |  7.1 KB  |  325 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.Event;
  10. import java.awt.Font;
  11. import java.awt.Label;
  12. import java.awt.LayoutManager;
  13. import java.awt.List;
  14. import java.awt.Panel;
  15. import java.awt.TextField;
  16. import java.net.MalformedURLException;
  17. import java.net.URL;
  18. import java.util.Enumeration;
  19. import java.util.Vector;
  20.  
  21. public class FTSPane extends Panel implements DialogDoneTarget {
  22.    protected Applet m_applet;
  23.    protected List m_list;
  24.    protected List m_listHolder;
  25.    protected SearchTree m_forapplelistHolder;
  26.    protected SearchTree m_forapplelist;
  27.    protected TextField m_tfEdit = new TextField();
  28.    protected FTSNorthPanel m_pnlNorth = new FTSNorthPanel(this);
  29.    protected Button m_btnDisplay = new Button(ResourceLib.GetRes("Display"));
  30.    protected Button m_btnFind = new Button(ResourceLib.GetRes("Find"));
  31.    protected IndexSecondaryDialog m_dlgSecondary;
  32.    protected int m_nSelectedIndex = -1;
  33.    protected FTSSearcher m_ftsSearcher = null;
  34.    protected Panel m_pnlEditArea = new Panel();
  35.    protected Label m_lblEditArea = new Label(ResourceLib.GetRes("FtsInputPrompt"));
  36.    protected LayoutManager m_layEditArea = new BorderLayout(0, 0);
  37.    protected boolean m_bIsIE4 = false;
  38.    protected boolean m_bIsNSWin16 = false;
  39.    protected boolean m_bIsNSWin32 = false;
  40.    protected boolean m_bIsIE3 = false;
  41.    protected boolean m_bUseForAppleList = false;
  42.    private LayoutManager m_layout;
  43.    private Vector m_searchResVector;
  44.  
  45.    public boolean gotFocus(Event var1, Object var2) {
  46.       if (var1.target != this.m_tfEdit && var1.target != this.m_list && var1.target != this.m_forapplelist && var1.target != this.m_btnDisplay && var1.target != this.m_btnFind) {
  47.          this.m_tfEdit.requestFocus();
  48.       }
  49.  
  50.       return true;
  51.    }
  52.  
  53.    public void HideList() {
  54.       if (!this.m_bUseForAppleList) {
  55.          this.m_listHolder.clear();
  56.          this.m_listHolder.addItem(ResourceLib.GetRes("Searching"));
  57.          this.m_list.show(false);
  58.          ((Container)this).add("Center", this.m_listHolder);
  59.          this.m_listHolder.show(true);
  60.          ((Container)this).layout();
  61.          ((Component)this).paintAll(((Component)this).getGraphics());
  62.       }
  63.  
  64.       ((Container)this).paintComponents(((Component)this).getGraphics());
  65.    }
  66.  
  67.    public SearchTree getforappleList() {
  68.       return this.m_forapplelist;
  69.    }
  70.  
  71.    public void dialogDone() {
  72.       this.m_dlgSecondary = null;
  73.       this.m_tfEdit.requestFocus();
  74.    }
  75.  
  76.    public FTSPane(Applet var1, FTSSearcher var2) {
  77.       this.m_applet = var1;
  78.       this.m_searchResVector = new Vector();
  79.       this.m_ftsSearcher = var2;
  80.       this.m_layout = new BorderLayout(2, 2);
  81.       ((Container)this).setLayout(this.m_layout);
  82.  
  83.       try {
  84.          if (System.getProperty("java.vendor").startsWith("Netscape")) {
  85.             if (System.getProperty("os.name").startsWith("16-bit Windows")) {
  86.                this.m_bIsNSWin16 = true;
  87.             } else if (System.getProperty("os.name").startsWith("Windows")) {
  88.                this.m_bIsNSWin32 = true;
  89.             } else if (System.getProperty("os.name").startsWith("Mac")) {
  90.             }
  91.          } else if (System.getProperty("java.vendor").startsWith("Microsoft")) {
  92.             if (System.getProperty("java.version").startsWith("1.1")) {
  93.                this.m_bIsIE4 = true;
  94.             } else {
  95.                this.m_bIsIE3 = true;
  96.             }
  97.  
  98.             if (System.getProperty("os.name").startsWith("Mac")) {
  99.                this.m_bUseForAppleList = true;
  100.             }
  101.  
  102.             if (System.getProperty("java.version").equalsIgnoreCase("1.1")) {
  103.                this.m_bUseForAppleList = true;
  104.             } else if (System.getProperty("java.version").equalsIgnoreCase("1.0.2")) {
  105.                this.m_bUseForAppleList = true;
  106.             }
  107.          }
  108.       } finally {
  109.          ;
  110.       }
  111.  
  112.       if (this.m_bUseForAppleList) {
  113.          this.m_forapplelistHolder = new SearchTree(this);
  114.          this.m_forapplelist = new SearchTree(this);
  115.       } else {
  116.          this.m_list = new List();
  117.          this.m_listHolder = new List();
  118.          this.m_list.setBackground(Color.white);
  119.       }
  120.  
  121.       int var3 = BsscFontFixPatch.GetFontSize();
  122.       if (this.m_list != null) {
  123.          this.m_list.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var3));
  124.       }
  125.  
  126.       this.m_tfEdit.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var3));
  127.       this.m_btnDisplay.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var3));
  128.       this.m_btnFind.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var3));
  129.       this.m_pnlEditArea.setLayout(this.m_layEditArea);
  130.       this.m_pnlEditArea.add("North", this.m_lblEditArea);
  131.       this.m_pnlEditArea.add("Center", this.m_tfEdit);
  132.       if (this.m_bUseForAppleList) {
  133.          this.m_forapplelistHolder.addItem(ResourceLib.GetRes("LoadingFTS"));
  134.          this.m_forapplelist.addItem(ResourceLib.GetRes("LoadingFTS"));
  135.       } else {
  136.          this.m_listHolder.addItem(ResourceLib.GetRes("LoadingFTS"));
  137.          this.m_listHolder.setBackground(Color.white);
  138.       }
  139.  
  140.       this.m_pnlNorth.add("North", this.m_pnlEditArea);
  141.       this.m_pnlNorth.add("South", this.m_btnFind);
  142.       ((Container)this).add("North", this.m_pnlNorth);
  143.       if (this.m_bUseForAppleList) {
  144.          ((Container)this).add("Center", this.m_forapplelist);
  145.       } else {
  146.          ((Container)this).add("Center", this.m_listHolder);
  147.       }
  148.  
  149.       ((Container)this).add("South", this.m_btnDisplay);
  150.       this.m_tfEdit.requestFocus();
  151.    }
  152.  
  153.    public List getList() {
  154.       return this.m_list;
  155.    }
  156.  
  157.    public void ShowList() {
  158.       if (this.m_bUseForAppleList) {
  159.          this.m_forapplelist.setFilled(true);
  160.       } else {
  161.          System.out.println("Showing List...");
  162.          this.m_listHolder.show(false);
  163.          this.m_layout.removeLayoutComponent(this.m_listHolder);
  164.          ((Container)this).add("Center", this.m_list);
  165.          ((Container)this).add("South", this.m_btnDisplay);
  166.          this.m_list.show(true);
  167.          ((Container)this).layout();
  168.          ((Component)this).paintAll(((Component)this).getGraphics());
  169.       }
  170.  
  171.       ((Container)this).paintComponents(((Component)this).getGraphics());
  172.    }
  173.  
  174.    public TextField getEditBox() {
  175.       return this.m_tfEdit;
  176.    }
  177.  
  178.    public boolean keyUp(Event var1, int var2) {
  179.       if (this.m_bIsNSWin16) {
  180.          var2 &= 255;
  181.       }
  182.  
  183.       if ((this.m_bIsIE4 || this.m_bIsIE3 || this.m_bIsNSWin32) && var1.key == 10) {
  184.          if (System.getProperty("java.version").startsWith("1.1.5") && this.m_bIsNSWin32) {
  185.             return super.keyUp(var1, var2);
  186.          }
  187.  
  188.          if (System.getProperty("java.version").startsWith("1.0.2") && System.getProperty("java.vendor").startsWith("Microsoft")) {
  189.             return super.keyUp(var1, var2);
  190.          }
  191.  
  192.          if (System.getProperty("java.version").startsWith("1.02") && System.getProperty("java.vendor").startsWith("Netscape")) {
  193.             return super.keyUp(var1, var2);
  194.          }
  195.  
  196.          if (var1.target == this.m_forapplelist || var1.target == this.m_list || var1.target == this.m_tfEdit) {
  197.             this.action(var1, var1.target);
  198.             return true;
  199.          }
  200.       }
  201.  
  202.       boolean var3 = super.keyUp(var1, var2);
  203.       if (var2 >= 32 && var2 <= 126) {
  204.          try {
  205.             this.textChanged();
  206.             if (var1.target == this.m_tfEdit) {
  207.                this.m_tfEdit.requestFocus();
  208.             }
  209.          } finally {
  210.             ;
  211.          }
  212.       }
  213.  
  214.       return var3;
  215.    }
  216.  
  217.    protected void gotoSelectedIndex() {
  218.       int var1 = -1;
  219.       if (this.m_bUseForAppleList) {
  220.          var1 = this.m_forapplelist.getSelectedIndex();
  221.       } else {
  222.          var1 = this.m_list.getSelectedIndex();
  223.       }
  224.  
  225.       if (var1 != -1) {
  226.          try {
  227.             String var2 = this.m_applet.getParameter("Frame");
  228.             Vector var3 = (Vector)this.m_searchResVector.elementAt(var1);
  229.             String var4 = null;
  230.             if (var3.size() > 1) {
  231.                var4 = (String)var3.elementAt(1);
  232.             }
  233.  
  234.             if (var4 != null && var4.length() != 0) {
  235.                URL var5 = URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var4, "");
  236.                String var6 = var5.toString();
  237.                if (var6.indexOf("file:/\\\\") == 0) {
  238.                   var6 = "file://" + var6.substring(8);
  239.                   var5 = new URL(var6);
  240.                }
  241.  
  242.                if (var2 == null) {
  243.                   this.m_applet.getAppletContext().showDocument(var5, "_self");
  244.                } else {
  245.                   this.m_applet.getAppletContext().showDocument(var5, var2);
  246.                }
  247.             }
  248.          } catch (MalformedURLException var7) {
  249.             ((Throwable)var7).printStackTrace();
  250.          }
  251.       }
  252.    }
  253.  
  254.    protected void finalize() throws Throwable {
  255.       if (this.m_bUseForAppleList) {
  256.          this.m_forapplelist.clear();
  257.          this.m_forapplelist = null;
  258.       } else {
  259.          this.m_list.clear();
  260.          this.m_list = null;
  261.       }
  262.  
  263.       super.finalize();
  264.    }
  265.  
  266.    public boolean action(Event var1, Object var2) {
  267.       System.out.println("action(" + var1.toString() + ", " + var2.toString() + ")");
  268.       if (var1.target != this.m_btnFind && var1.target != this.m_tfEdit) {
  269.          this.gotoSelectedIndex();
  270.       } else {
  271.          this.HideList();
  272.          this.m_ftsSearcher.doSearch(this.m_tfEdit.getText(), this.m_searchResVector);
  273.          if (!this.m_bUseForAppleList) {
  274.             this.m_list.clear();
  275.             Enumeration var4 = this.m_searchResVector.elements();
  276.  
  277.             while(var4.hasMoreElements()) {
  278.                this.m_list.addItem((String)((Vector)var4.nextElement()).elementAt(0));
  279.             }
  280.          } else {
  281.             this.m_forapplelist.clear();
  282.             Enumeration var3 = this.m_searchResVector.elements();
  283.  
  284.             while(var3.hasMoreElements()) {
  285.                this.m_forapplelist.addItem((String)((Vector)var3.nextElement()).elementAt(0));
  286.             }
  287.  
  288.             this.m_forapplelist.paint(this.m_forapplelist.getGraphics());
  289.          }
  290.  
  291.          this.ShowList();
  292.          ((Container)this).paintComponents(((Component)this).getGraphics());
  293.       }
  294.  
  295.       return true;
  296.    }
  297.  
  298.    public boolean handleEvent(Event var1) {
  299.       if (System.getProperty("java.version").equalsIgnoreCase("1.0.2") && System.getProperty("java.vendor").startsWith("Microsoft") && var1.id == 402 && var1.key == 10 && var1.target != this.m_tfEdit) {
  300.          this.action(var1, var1.target);
  301.          return true;
  302.       } else if (System.getProperty("java.version").equalsIgnoreCase("1.1.5") && this.m_bIsNSWin32 && var1.id == 402 && var1.key == 10 && var1.target != this.m_tfEdit) {
  303.          this.action(var1, var1.target);
  304.          return true;
  305.       } else if (this.m_bIsIE4 && var1.id == 1001 && var1.target == this.m_tfEdit) {
  306.          return true;
  307.       } else {
  308.          if (var1.target == this.m_list && var1.id == 701 && this.m_list.getSelectedIndex() != this.m_nSelectedIndex) {
  309.             String var2 = this.m_list.getSelectedItem();
  310.             String var3 = this.m_ftsSearcher.getTopicURL(this.m_list.getSelectedItem());
  311.             this.m_nSelectedIndex = this.m_list.getSelectedIndex();
  312.             if (var3 != null && var3.length() != 0 && var2 != null) {
  313.                this.m_applet.showStatus(var2);
  314.                this.m_list.requestFocus();
  315.             }
  316.          }
  317.  
  318.          return super.handleEvent(var1);
  319.       }
  320.    }
  321.  
  322.    public void textChanged() {
  323.    }
  324. }
  325.