home *** CD-ROM | disk | FTP | other *** search
- package hhapplet;
-
- import java.applet.Applet;
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.Label;
- import java.awt.LayoutManager;
- import java.awt.List;
- import java.awt.Panel;
- import java.awt.TextField;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Enumeration;
- import java.util.Vector;
-
- public class FTSPane extends Panel implements DialogDoneTarget {
- protected Applet m_applet;
- protected List m_list;
- protected List m_listHolder;
- protected SearchTree m_forapplelistHolder;
- protected SearchTree m_forapplelist;
- protected TextField m_tfEdit = new TextField();
- protected FTSNorthPanel m_pnlNorth = new FTSNorthPanel(this);
- protected Button m_btnDisplay = new Button(ResourceLib.GetRes("Display"));
- protected Button m_btnFind = new Button(ResourceLib.GetRes("Find"));
- protected IndexSecondaryDialog m_dlgSecondary;
- protected int m_nSelectedIndex = -1;
- protected FTSSearcher m_ftsSearcher = null;
- protected Panel m_pnlEditArea = new Panel();
- protected Label m_lblEditArea = new Label(ResourceLib.GetRes("FtsInputPrompt"));
- protected LayoutManager m_layEditArea = new BorderLayout(0, 0);
- protected boolean m_bIsIE4 = false;
- protected boolean m_bIsNSWin16 = false;
- protected boolean m_bIsNSWin32 = false;
- protected boolean m_bIsIE3 = false;
- protected boolean m_bUseForAppleList = false;
- private LayoutManager m_layout;
- private Vector m_searchResVector;
-
- public boolean gotFocus(Event var1, Object var2) {
- 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) {
- this.m_tfEdit.requestFocus();
- }
-
- return true;
- }
-
- public void HideList() {
- if (!this.m_bUseForAppleList) {
- this.m_listHolder.clear();
- this.m_listHolder.addItem(ResourceLib.GetRes("Searching"));
- this.m_list.show(false);
- ((Container)this).add("Center", this.m_listHolder);
- this.m_listHolder.show(true);
- ((Container)this).layout();
- ((Component)this).paintAll(((Component)this).getGraphics());
- }
-
- ((Container)this).paintComponents(((Component)this).getGraphics());
- }
-
- public SearchTree getforappleList() {
- return this.m_forapplelist;
- }
-
- public void dialogDone() {
- this.m_dlgSecondary = null;
- this.m_tfEdit.requestFocus();
- }
-
- public FTSPane(Applet var1, FTSSearcher var2) {
- this.m_applet = var1;
- this.m_searchResVector = new Vector();
- this.m_ftsSearcher = var2;
- this.m_layout = new BorderLayout(2, 2);
- ((Container)this).setLayout(this.m_layout);
-
- try {
- if (System.getProperty("java.vendor").startsWith("Netscape")) {
- if (System.getProperty("os.name").startsWith("16-bit Windows")) {
- this.m_bIsNSWin16 = true;
- } else if (System.getProperty("os.name").startsWith("Windows")) {
- this.m_bIsNSWin32 = true;
- } else if (System.getProperty("os.name").startsWith("Mac")) {
- }
- } else if (System.getProperty("java.vendor").startsWith("Microsoft")) {
- if (System.getProperty("java.version").startsWith("1.1")) {
- this.m_bIsIE4 = true;
- } else {
- this.m_bIsIE3 = true;
- }
-
- if (System.getProperty("os.name").startsWith("Mac")) {
- this.m_bUseForAppleList = true;
- }
-
- if (System.getProperty("java.version").equalsIgnoreCase("1.1")) {
- this.m_bUseForAppleList = true;
- } else if (System.getProperty("java.version").equalsIgnoreCase("1.0.2")) {
- this.m_bUseForAppleList = true;
- }
- }
- } finally {
- ;
- }
-
- if (this.m_bUseForAppleList) {
- this.m_forapplelistHolder = new SearchTree(this);
- this.m_forapplelist = new SearchTree(this);
- } else {
- this.m_list = new List();
- this.m_listHolder = new List();
- this.m_list.setBackground(Color.white);
- }
-
- int var3 = BsscFontFixPatch.GetFontSize();
- if (this.m_list != null) {
- this.m_list.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var3));
- }
-
- this.m_tfEdit.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var3));
- this.m_btnDisplay.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var3));
- this.m_btnFind.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var3));
- this.m_pnlEditArea.setLayout(this.m_layEditArea);
- this.m_pnlEditArea.add("North", this.m_lblEditArea);
- this.m_pnlEditArea.add("Center", this.m_tfEdit);
- if (this.m_bUseForAppleList) {
- this.m_forapplelistHolder.addItem(ResourceLib.GetRes("LoadingFTS"));
- this.m_forapplelist.addItem(ResourceLib.GetRes("LoadingFTS"));
- } else {
- this.m_listHolder.addItem(ResourceLib.GetRes("LoadingFTS"));
- this.m_listHolder.setBackground(Color.white);
- }
-
- this.m_pnlNorth.add("North", this.m_pnlEditArea);
- this.m_pnlNorth.add("South", this.m_btnFind);
- ((Container)this).add("North", this.m_pnlNorth);
- if (this.m_bUseForAppleList) {
- ((Container)this).add("Center", this.m_forapplelist);
- } else {
- ((Container)this).add("Center", this.m_listHolder);
- }
-
- ((Container)this).add("South", this.m_btnDisplay);
- this.m_tfEdit.requestFocus();
- }
-
- public List getList() {
- return this.m_list;
- }
-
- public void ShowList() {
- if (this.m_bUseForAppleList) {
- this.m_forapplelist.setFilled(true);
- } else {
- System.out.println("Showing List...");
- this.m_listHolder.show(false);
- this.m_layout.removeLayoutComponent(this.m_listHolder);
- ((Container)this).add("Center", this.m_list);
- ((Container)this).add("South", this.m_btnDisplay);
- this.m_list.show(true);
- ((Container)this).layout();
- ((Component)this).paintAll(((Component)this).getGraphics());
- }
-
- ((Container)this).paintComponents(((Component)this).getGraphics());
- }
-
- public TextField getEditBox() {
- return this.m_tfEdit;
- }
-
- public boolean keyUp(Event var1, int var2) {
- if (this.m_bIsNSWin16) {
- var2 &= 255;
- }
-
- if ((this.m_bIsIE4 || this.m_bIsIE3 || this.m_bIsNSWin32) && var1.key == 10) {
- if (System.getProperty("java.version").startsWith("1.1.5") && this.m_bIsNSWin32) {
- return super.keyUp(var1, var2);
- }
-
- if (System.getProperty("java.version").startsWith("1.0.2") && System.getProperty("java.vendor").startsWith("Microsoft")) {
- return super.keyUp(var1, var2);
- }
-
- if (System.getProperty("java.version").startsWith("1.02") && System.getProperty("java.vendor").startsWith("Netscape")) {
- return super.keyUp(var1, var2);
- }
-
- if (var1.target == this.m_forapplelist || var1.target == this.m_list || var1.target == this.m_tfEdit) {
- this.action(var1, var1.target);
- return true;
- }
- }
-
- boolean var3 = super.keyUp(var1, var2);
- if (var2 >= 32 && var2 <= 126) {
- try {
- this.textChanged();
- if (var1.target == this.m_tfEdit) {
- this.m_tfEdit.requestFocus();
- }
- } finally {
- ;
- }
- }
-
- return var3;
- }
-
- protected void gotoSelectedIndex() {
- int var1 = -1;
- if (this.m_bUseForAppleList) {
- var1 = this.m_forapplelist.getSelectedIndex();
- } else {
- var1 = this.m_list.getSelectedIndex();
- }
-
- if (var1 != -1) {
- try {
- String var2 = this.m_applet.getParameter("Frame");
- Vector var3 = (Vector)this.m_searchResVector.elementAt(var1);
- String var4 = null;
- if (var3.size() > 1) {
- var4 = (String)var3.elementAt(1);
- }
-
- if (var4 != null && var4.length() != 0) {
- URL var5 = URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var4, "");
- String var6 = var5.toString();
- if (var6.indexOf("file:/\\\\") == 0) {
- var6 = "file://" + var6.substring(8);
- var5 = new URL(var6);
- }
-
- if (var2 == null) {
- this.m_applet.getAppletContext().showDocument(var5, "_self");
- } else {
- this.m_applet.getAppletContext().showDocument(var5, var2);
- }
- }
- } catch (MalformedURLException var7) {
- ((Throwable)var7).printStackTrace();
- }
- }
- }
-
- protected void finalize() throws Throwable {
- if (this.m_bUseForAppleList) {
- this.m_forapplelist.clear();
- this.m_forapplelist = null;
- } else {
- this.m_list.clear();
- this.m_list = null;
- }
-
- super.finalize();
- }
-
- public boolean action(Event var1, Object var2) {
- System.out.println("action(" + var1.toString() + ", " + var2.toString() + ")");
- if (var1.target != this.m_btnFind && var1.target != this.m_tfEdit) {
- this.gotoSelectedIndex();
- } else {
- this.HideList();
- this.m_ftsSearcher.doSearch(this.m_tfEdit.getText(), this.m_searchResVector);
- if (!this.m_bUseForAppleList) {
- this.m_list.clear();
- Enumeration var4 = this.m_searchResVector.elements();
-
- while(var4.hasMoreElements()) {
- this.m_list.addItem((String)((Vector)var4.nextElement()).elementAt(0));
- }
- } else {
- this.m_forapplelist.clear();
- Enumeration var3 = this.m_searchResVector.elements();
-
- while(var3.hasMoreElements()) {
- this.m_forapplelist.addItem((String)((Vector)var3.nextElement()).elementAt(0));
- }
-
- this.m_forapplelist.paint(this.m_forapplelist.getGraphics());
- }
-
- this.ShowList();
- ((Container)this).paintComponents(((Component)this).getGraphics());
- }
-
- return true;
- }
-
- public boolean handleEvent(Event var1) {
- 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) {
- this.action(var1, var1.target);
- return true;
- } else if (System.getProperty("java.version").equalsIgnoreCase("1.1.5") && this.m_bIsNSWin32 && var1.id == 402 && var1.key == 10 && var1.target != this.m_tfEdit) {
- this.action(var1, var1.target);
- return true;
- } else if (this.m_bIsIE4 && var1.id == 1001 && var1.target == this.m_tfEdit) {
- return true;
- } else {
- if (var1.target == this.m_list && var1.id == 701 && this.m_list.getSelectedIndex() != this.m_nSelectedIndex) {
- String var2 = this.m_list.getSelectedItem();
- String var3 = this.m_ftsSearcher.getTopicURL(this.m_list.getSelectedItem());
- this.m_nSelectedIndex = this.m_list.getSelectedIndex();
- if (var3 != null && var3.length() != 0 && var2 != null) {
- this.m_applet.showStatus(var2);
- this.m_list.requestFocus();
- }
- }
-
- return super.handleEvent(var1);
- }
- }
-
- public void textChanged() {
- }
- }
-